Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/illustrate.py
diff options
context:
space:
mode:
Diffstat (limited to 'illustrate.py')
-rw-r--r--illustrate.py51
1 files changed, 47 insertions, 4 deletions
diff --git a/illustrate.py b/illustrate.py
index 5dc6a7d..c8fe839 100644
--- a/illustrate.py
+++ b/illustrate.py
@@ -35,7 +35,7 @@ from sugar.graphics.colorbutton import ColorToolButton
from sugar.graphics.toolbarbox import ToolbarBox
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.objectchooser import ObjectChooser
-from sugar.graphics.alert import NotifyAlert
+from sugar.graphics.alert import Alert, NotifyAlert
from helpbutton import HelpButton
from dialogs import ExampleDialog
@@ -78,15 +78,20 @@ class IllustrateActivity(activity.Activity):
toolbarbox.toolbar.insert(activity_button, 0)
separator = gtk.SeparatorToolItem()
- separator.set_expand(True)
- separator.set_draw(False)
+ separator.set_expand(False)
+ separator.set_draw(True)
toolbarbox.toolbar.insert(separator, -1)
dialog_btn = ToolButton("dialog-icon")
- dialog_btn.set_tooltip(_("Show an example of a dialog"))
+ dialog_btn.set_tooltip(_("Dialog example"))
dialog_btn.connect("clicked", self._show_example_dialog)
toolbarbox.toolbar.insert(dialog_btn, -1)
+ alert_btn = ToolButton("alert-icon")
+ alert_btn.set_tooltip(_("Alert example"))
+ alert_btn.connect("clicked", self._show_example_alert)
+ toolbarbox.toolbar.insert(alert_btn, -1)
+
options_button = ToolbarButton(icon_name='preferences-system')
options_toolbar = gtk.Toolbar()
@@ -136,6 +141,24 @@ class IllustrateActivity(activity.Activity):
self.show_all()
self._create_canvas(canvas)
+ self._create_alert_btn_palette(alert_btn)
+
+ def _create_alert_btn_palette(self, button):
+ palette = button.get_palette()
+ hbox = gtk.HBox()
+
+ simple = ToolButton("alert-icon")
+ simple.connect("clicked", self._show_example_alert, False)
+
+ notify = ToolButton("notify-alert-icon")
+ notify.connect("clicked", self._show_example_alert, True)
+
+ hbox.pack_start(simple, False, True, 0)
+ hbox.pack_start(notify, False, True, 0)
+
+ hbox.show_all()
+
+ palette.set_content(hbox)
def load_objectchooser(self, widget):
chooser = ObjectChooser(parent=self,
@@ -157,6 +180,26 @@ class IllustrateActivity(activity.Activity):
def _show_example_dialog(self, widget):
ExampleDialog()
+ def _show_example_alert(self, widget, notify=False):
+ if notify:
+ alert = NotifyAlert(10)
+ alert.props.title = _('Notify Alert')
+
+ elif not notify:
+ alert = Alert()
+ ok_icon = Icon(icon_name='dialog-ok')
+ alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon)
+ ok_icon.show()
+ alert.props.title = _('Simple Alert')
+
+ alert.props.msg = _('Message')
+
+ alert.connect('response', lambda a, r: self.remove_alert(a))
+
+ self.add_alert(alert)
+
+ alert.show()
+
def _set_fill_color(self, widget, pspec):
self._icon.props.fill_color = rgb2html(widget.get_color())