Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2012-11-16 01:08:42 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2012-11-16 17:57:33 (GMT)
commit6d3c35a9368fdeef7f2bea22b401c6cd681ebe2d (patch)
tree36a02b9e46d5a479ae339c4ac1e4bd171565f0b1
parentf1bac3f450d2ad017c8bfb739cd425e1033b4fd2 (diff)
Disable sensitive when there's only one function.
* Update Sweetener to have the property sensitive in Items. * Add the conditionals when: - Adding a function - Removing a function - Using the command entrie * Also removed very old code. Signed-off-by: Daniel Francis <francis@sugarlabs.org>
-rw-r--r--canvas.py7
m---------desktop/sweetener0
-rw-r--r--options.py79
m---------sugar/sweetener0
4 files changed, 35 insertions, 51 deletions
diff --git a/canvas.py b/canvas.py
index 62c660b..818445a 100644
--- a/canvas.py
+++ b/canvas.py
@@ -204,6 +204,11 @@ class Canvas(gtk.HPaned):
self.functions_list.append_function(color, text)
self.update_graph(None, self.functions_list.get_list())
widget.set_text('')
+ number = len(self.functions_list.get_list())
+ if number == 1:
+ self.toolbar_box.remove_function.sensitive = False
+ else:
+ self.toolbar_box.remove_function.sensitive = True
def _update_scale(self, widget=None):
xscale, yscale = self.toolbar_box.view.get_scale()
@@ -340,6 +345,7 @@ class Canvas(gtk.HPaned):
def _remove_function(self, widget):
self.functions_list.remove_function()
self.update_graph(None, self.functions_list.get_list())
+ return len(self.functions_list.get_list())
def _append_function(self, widget):
if len(self.functions_list.get_list()) % 2 == 0:
@@ -348,6 +354,7 @@ class Canvas(gtk.HPaned):
color = profile.get_stroke_color(self)
self.functions_list.append_function(color)
self.update_graph(None, self.functions_list.get_list())
+ return len(self.functions_list.get_list())
def update_graph(self, widget, info):
# self._evaluate_cb(None, self.toolbar_box.evaluate_entry.get_text())
diff --git a/desktop/sweetener b/desktop/sweetener
-Subproject 9c7c915efa9d1815ea2e47f29ff549781d50c08
+Subproject d0a2a5ed99725f7ae9eb429467952e09b92b091
diff --git a/options.py b/options.py
index 81510c7..0ea4176 100644
--- a/options.py
+++ b/options.py
@@ -18,6 +18,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
+import logging
+logger = logging.getLogger('options')
+
from gettext import gettext as _
import gobject
import gtk
@@ -244,11 +247,11 @@ class ViewOptions(ItemGroup):
class Options(ItemBox):
- __gsignals__ = {'append-function': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
+ __gsignals__ = {'append-function': (gobject.SIGNAL_RUN_LAST,
+ gobject.TYPE_INT,
tuple()),
- 'remove-function': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
+ 'remove-function': (gobject.SIGNAL_RUN_LAST,
+ gobject.TYPE_INT,
tuple()),
'color-updated': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
@@ -274,13 +277,14 @@ class Options(ItemBox):
add_function = Item(gtk.STOCK_ADD, True)
add_function.tooltip = _('Append a new function')
add_function.connect('activate',
- lambda w: self.emit('append-function'))
+ self._append_function_cb)
self.ghost.append_item(add_function)
- remove_function = Item(gtk.STOCK_REMOVE, True)
- remove_function.tooltip = _('Remove the selected function')
- remove_function.connect('activate',
- lambda w: self.emit('remove-function'))
- self.ghost.append_item(remove_function)
+ self.remove_function = Item(gtk.STOCK_REMOVE, True)
+ self.remove_function.tooltip = _('Remove the selected function')
+ self.remove_function.connect('activate',
+ self._remove_function_cb)
+ self.ghost.append_item(self.remove_function)
+ self.remove_function.sensitive = False
self.color_item = ColorItem(activity, True)
self.color_item.tooltip = _('Plot color')
self.color_item.connect('updated',
@@ -316,45 +320,18 @@ class Options(ItemBox):
self.ghost.append_item(evaluate_entry_item)
self.help = Help(self)
-"""
- def export_as_png(self, path):
- jobject = datastore.create()
- jobject.metadata['title'] = self.activity.metadata["title"]
- jobject.metadata['mime_type'] = "image/png"
- self.emit('save-png', '/tmp/graph-plotter.png')
- jobject.set_file_path('/tmp/graph-plotter.png')
- datastore.write(jobject)
+ def _append_function_cb(self, widget):
+ number = self.emit('append-function')
+ logger.debug(number)
+ if number == 1:
+ self.remove_function.sensitive = False
+ else:
+ self.remove_function.sensitive = True
- def setup_help_button(self):
- helpbutton = HelpButton()
- helpbutton.add_section(_('Plotting functions'))
- helpbutton.add_paragraph(_('Append a new function.'), 'gtk-add')
- helpbutton.add_paragraph(_('Remove a function.'), 'gtk-remove')
- helpbutton.add_paragraph(
- _('Choose the color for the selected function.'),
- 'color-preview')
- helpbutton.add_section(_('Watching the graph'))
- helpbutton.add_paragraph(_('Zoom into the graph.'), 'zoom-in')
- helpbutton.add_paragraph(_('Zoom out from the graph.'), 'zoom-out')
- helpbutton.add_paragraph(_('Reset zoom level.'), 'zoom-original')
- helpbutton.add_paragraph(_('Customize the scale range. \n\
-Remember to press enter after editing the entries.'), 'cell-size')
- helpbutton.add_paragraph(
- _('You can zoom in directly into the graph by selecting an area to expand'))
- helpbutton.add_paragraph(
- _('Hold the Shift key and move the mouse to traverse the graph.'))
- helpbutton.add_paragraph(
- _('Do click for switch between the mouse pointing modes.'))
- helpbutton.add_section(_('Some settings'))
- helpbutton.add_paragraph(_('Connect the plotted points.'),
- 'connect-points')
- helpbutton.add_paragraph(_('Show the grid.'), 'insert-table')
- helpbutton.add_section(
- _('From algebraic expressions to linear expressions'))
- helpbutton.add_paragraph(_('Multiplication: ') + '*')
- helpbutton.add_paragraph(_('Division: ') + '/')
- helpbutton.add_paragraph(_('Integer division: ') + '//')
- helpbutton.add_paragraph(_('Power: ') + '^')
- helpbutton.show_all()
- self.toolbar.insert(helpbutton, -1)
-"""
+ def _remove_function_cb(self, widget):
+ number = self.emit('remove-function')
+ logger.debug(number)
+ if number == 1:
+ self.remove_function.sensitive = False
+ else:
+ self.remove_function.sensitive = True
diff --git a/sugar/sweetener b/sugar/sweetener
-Subproject 2b200cda7787769b6cc718a8ffd6addb4e67503
+Subproject e3affd5174a3171926bebad53dada2432b55875