[gnome-clocks/editmode] Add initial selection mode implementation, now only toolbar
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/editmode] Add initial selection mode implementation, now only toolbar
- Date: Fri, 17 Aug 2012 16:11:59 +0000 (UTC)
commit b0e955775dd4da1c2d616395142e033f26d00a91
Author: Seif Lotfy <seif lotfy com>
Date: Fri Aug 17 18:10:42 2012 +0200
Add initial selection mode implementation, now only toolbar
gnomeclocks/app.py | 50 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 40 insertions(+), 10 deletions(-)
---
diff --git a/gnomeclocks/app.py b/gnomeclocks/app.py
index 9b9d392..4b48d94 100644
--- a/gnomeclocks/app.py
+++ b/gnomeclocks/app.py
@@ -50,6 +50,7 @@ class Window(Gtk.ApplicationWindow):
self.toolbar = ClocksToolbar()
vbox.pack_start(self.toolbar, False, False, 0)
+ vbox.pack_start(self.toolbar.selection_toolbar, False, False, 0)
self.world = World()
self.alarm = Alarm()
@@ -69,6 +70,7 @@ class Window(Gtk.ApplicationWindow):
self.toolbar.connect("view-clock", self._on_view_clock)
self.toolbar.newButton.connect("clicked", self._on_new_clicked)
self.show_all()
+ self.toolbar.selection_toolbar.hide()
self.connect('key-press-event', self._on_key_press)
@@ -137,6 +139,31 @@ class Window(Gtk.ApplicationWindow):
elif keyname in ('q', 'w'):
self.app.quit()
+class SelectionToolbar(Gtk.Toolbar):
+ def __init__(self):
+ Gtk.Toolbar.__init__(self)
+ self.get_style_context().add_class("clocks-toolbar")
+ self.set_icon_size(Gtk.IconSize.MENU)
+ self.get_style_context().add_class(Gtk.STYLE_CLASS_MENUBAR)
+ self.get_style_context().add_class("selection-mode")
+
+ toolitem = Gtk.ToolItem()
+ toolitem.set_expand(True)
+ toolbox = Gtk.Box()
+ toolitem.add(toolbox)
+ self.insert(toolitem, -1)
+
+ self.cancelButton = Gtk.Button()
+
+ label = Gtk.Label(_("Cancel"))
+ self.cancelButton.get_style_context().add_class('raised')
+ self.cancelButton.add(label)
+ self.cancelButton.set_size_request(64, 34)
+
+ self.leftBox = box = Gtk.Box()
+ box.pack_start(self.cancelButton, False, False, 0)
+ toolbox.pack_start(box, True, True, 0)
+
class ClocksToolbar(Gtk.Toolbar):
__gsignals__ = {'view-clock': (GObject.SignalFlags.RUN_LAST,
@@ -144,8 +171,8 @@ class ClocksToolbar(Gtk.Toolbar):
def __init__(self):
Gtk.Toolbar.__init__(self)
- self.get_style_context().add_class("clocks-toolbar")
+ self.get_style_context().add_class("clocks-toolbar")
self.set_icon_size(Gtk.IconSize.MENU)
self.get_style_context().add_class(Gtk.STYLE_CLASS_MENUBAR)
@@ -203,7 +230,7 @@ class ClocksToolbar(Gtk.Toolbar):
image.set_from_gicon(icon, Gtk.IconSize.MENU)
self.applyButton.add(image)
self.applyButton.set_size_request(32, 32)
- self.applyButton.connect('clicked', self._on_selection_mode)
+ self.applyButton.connect('clicked', self._on_selection_mode, True)
self.rightBox = box = Gtk.Box()
box.pack_end(self.applyButton, False, False, 0)
toolbox.pack_start(box, True, True, 0)
@@ -211,6 +238,10 @@ class ClocksToolbar(Gtk.Toolbar):
self._buttonMap = {}
self._busy = False
+ self.selection_toolbar = SelectionToolbar()
+ self.selection_toolbar.cancelButton.connect("clicked",
+ self._on_selection_mode, False)
+
def _on_new_clicked(self, widget):
for view in self.views:
if view.button.get_active():
@@ -282,14 +313,13 @@ class ClocksToolbar(Gtk.Toolbar):
self._busy = False
self.emit("view-clock", self._buttonMap[widget])
- def _on_selection_mode(self, button):
- self.set_selection_mode(True)
-
- def set_selection_mode(self, val):
- if val == True:
- pass
+ def _on_selection_mode(self, button, selection_mode):
+ if selection_mode:
+ self.hide()
+ self.selection_toolbar.show()
else:
- self.set_single_toolbar()
+ self.show()
+ self.selection_toolbar.hide()
def _delete_clock(self, button):
pass
@@ -301,7 +331,7 @@ class ClocksApplication(Gtk.Application):
def do_activate(self):
self.win = win = Window(self)
- win.show_all()
+ win.show()
def quit_cb(self, action, parameter):
self.quit()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]