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-10-07 02:24:39 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2012-10-07 02:24:39 (GMT)
commitd091144d4770c70a74a233890346daefa4f188b8 (patch)
tree0b51d7217e667873d122aba32dd5680bebe7f2ed
parent28048b1afaf1e7738cd27eddec0db5f8ca29507c (diff)
Load simple alert on desktops
-rwxr-xr-xapplication.py6
-rw-r--r--desktop/sweetener/alerts.py27
-rw-r--r--options.py24
3 files changed, 45 insertions, 12 deletions
diff --git a/application.py b/application.py
index 23556ab..0b584ce 100755
--- a/application.py
+++ b/application.py
@@ -32,6 +32,7 @@ glib.set_application_name(appname)
import gtk
from options import Options
from canvas import Canvas
+from sweetener.alerts import Alert
this_dir = os.path.split('__file__')[:-1]
if len(this_dir) == 1 and this_dir[0] == '':
@@ -157,6 +158,11 @@ class Application(gtk.Window):
else:
self._unfullscreen_button.hide()
+ def add_alert(self, alert):
+ if type(alert) == Alert:
+ alert.run()
+ alert.destroy()
+
def fullscreen(self):
self.options.hide()
self._is_fullscreen = True
diff --git a/desktop/sweetener/alerts.py b/desktop/sweetener/alerts.py
new file mode 100644
index 0000000..0b0be66
--- /dev/null
+++ b/desktop/sweetener/alerts.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import gtk
+
+
+class Alert(gtk.MessageDialog):
+ def __init__(self, parent, title, content, mtype):
+ gtk.MessageDialog.__init__(self, parent, gtk.DIALOG_MODAL,
+ type=mtype,
+ buttons=gtk.BUTTONS_OK)
+ self.set_markup('<b>Title</b>')
+ self.format_secondary_markup(content)
diff --git a/options.py b/options.py
index f1e7f70..ebf7afe 100644
--- a/options.py
+++ b/options.py
@@ -28,6 +28,7 @@ from sweetener.itemgroup import GhostGroup
from sweetener.coloritem import ColorItem
from sweetener.radioitem import RadioItem
from sweetener.settingsitem import SettingsItem
+from sweetener.alerts import Alert
class Options(ItemBox):
@@ -43,22 +44,17 @@ class Options(ItemBox):
content = gtk.HBox()
from sugar.graphics.toolbutton import ToolButton
simple_alert = ToolButton('alert-icon')
- content.pack_start(simple_alert, False, True, 0)
- simple_alert.show()
-
notify_alert = ToolButton('notify-alert-icon')
- content.pack_end(notify_alert, False, True, 0)
- notify_alert.show()
else:
content = gtk.VBox()
- simple_alert = gtk.Button('Simple')
- simple_alert.show()
- content.pack_start(simple_alert, True, True)
-
- notify_alert = gtk.Button('Notify')
- notify_alert.show()
- content.pack_start(notify_alert, True, True)
+ simple_alert = gtk.Button(_('Simple'))
+ notify_alert = gtk.Button(_('Notify'))
+ content.pack_start(simple_alert, True, True)
+ simple_alert.show()
+ content.pack_start(notify_alert, True, True)
+ notify_alert.show()
content.show()
+ simple_alert.connect('clicked', self.simple_alert)
self.alerts.content = content
self.canvas_ghost.append_item(self.alerts)
self.canvas_ghost.append_separator(True)
@@ -85,3 +81,7 @@ class Options(ItemBox):
self.stroke._stock_id = 'illustrate-stroke'
self.settings_group.append_item(self.stroke)
self.toolbar.show()
+
+ def simple_alert(self, widget):
+ alert = Alert(self.activity, _('Simple Alert'), _('Message'), gtk.MESSAGE_INFO)
+ self.activity.add_alert(alert)