Commit from One Laptop Per Child: Translation System by user HoboPrimate. 31 of 31...
[journal-activity.git] / modalalert.py
blob543a9ea6da3e55b450d38f021d8206427166c0e2
1 # Copyright (C) 2008 One Laptop Per Child
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 import gtk
18 from gettext import gettext as _
20 from sugar.graphics.icon import Icon
21 from sugar.graphics import style
22 from sugar import profile
24 class ModalAlert(gtk.Window):
26 __gtype_name__ = 'SugarModalAlert'
28 def __init__(self):
29 gtk.Window.__init__(self)
31 self.set_border_width(style.LINE_WIDTH)
32 offset = style.GRID_CELL_SIZE
33 width = gtk.gdk.screen_width() - offset * 2
34 height = gtk.gdk.screen_height() - offset * 2
35 self.set_size_request(width, height)
36 self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
37 self.set_decorated(False)
38 self.set_resizable(False)
39 self.set_modal(True)
41 self._main_view = gtk.EventBox()
42 self._vbox = gtk.VBox()
43 self._vbox.set_spacing(style.DEFAULT_SPACING)
44 self._vbox.set_border_width(style.GRID_CELL_SIZE * 2)
45 self._main_view.modify_bg(gtk.STATE_NORMAL,
46 style.COLOR_BLACK.get_gdk_color())
47 self._main_view.add(self._vbox)
48 self._vbox.show()
50 icon = Icon(file='activity/activity-journal.svg',
51 pixel_size=style.XLARGE_ICON_SIZE,
52 xo_color=profile.get_color())
53 self._vbox.pack_start(icon, False)
54 icon.show()
56 self._title = gtk.Label()
57 self._title.modify_fg(gtk.STATE_NORMAL,
58 style.COLOR_WHITE.get_gdk_color())
59 self._title.set_markup('<b>%s</b>' % _('Your Journal is full'))
60 self._vbox.pack_start(self._title, False)
61 self._title.show()
63 self._message = gtk.Label(_('Please delete some old Journal'
64 ' entries to make space for new ones.'))
65 self._message.modify_fg(gtk.STATE_NORMAL,
66 style.COLOR_WHITE.get_gdk_color())
67 self._vbox.pack_start(self._message, False)
68 self._message.show()
70 alignment = gtk.Alignment(xalign=0.5, yalign=0.5)
71 self._vbox.pack_start(alignment, expand=False)
72 alignment.show()
74 self._show_journal = gtk.Button()
75 self._show_journal.set_label(_('Show Journal'))
76 alignment.add(self._show_journal)
77 self._show_journal.show()
78 self._show_journal.connect('clicked', self.__show_journal_cb)
80 self.add(self._main_view)
81 self._main_view.show()
83 self.connect("realize", self.__realize_cb)
85 def __realize_cb(self, widget):
86 self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
87 self.window.set_accept_focus(True)
89 def __show_journal_cb(self, button):
90 '''The opener will listen on the destroy signal
91 '''
92 self.destroy()