[gnome-clocks/editmode: 1/2] Implement selection mode toolbar
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/editmode: 1/2] Implement selection mode toolbar
- Date: Sun, 19 Aug 2012 20:24:22 +0000 (UTC)
commit 6848b576c4c7f07ef203e7150d423c550a123d23
Author: Seif Lotfy <seif lotfy com>
Date: Fri Aug 17 18:10:42 2012 +0200
Implement selection mode toolbar
data/gtk-style.css | 4 +++
gnomeclocks/app.py | 53 +++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 46 insertions(+), 11 deletions(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index 3a13e14..f0c7f25 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -9,6 +9,10 @@
border-radius: 0;
}
+.clocks-toolbar.selection-mode.toolbar {
+ border-width: 1px 0;
+}
+
.clocks-go {
background-image: linear-gradient(to bottom,
@clocks_go_color_a,
diff --git a/gnomeclocks/app.py b/gnomeclocks/app.py
index a0615b5..fc53d89 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,36 @@ 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")
+
+ sep = Gtk.SeparatorToolItem()
+ sep.set_draw(False)
+ sep.set_expand(True)
+ self.insert(sep, -1)
+
+ toolitem = Gtk.ToolItem()
+ toolbox = Gtk.Box()
+ toolitem.add(toolbox)
+ self.insert(toolitem, -1)
+
+ self.cancelButton = Gtk.Button()
+
+ label = Gtk.Label(_("Done"))
+ self.cancelButton.get_style_context().add_class('raised')
+ self.cancelButton.get_style_context().add_class('suggested-action')
+ 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 +176,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 +235,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 +243,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 +318,9 @@ 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
- else:
- self.set_single_toolbar()
+ def _on_selection_mode(self, button, selection_mode):
+ self.selection_toolbar.set_visible(selection_mode)
+ self.set_visible(not selection_mode)
def _delete_clock(self, button):
pass
@@ -301,7 +332,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]