[california] Next/prev buttons on either side of date in header bar: Bug #734511
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Next/prev buttons on either side of date in header bar: Bug #734511
- Date: Tue, 12 Aug 2014 20:48:07 +0000 (UTC)
commit 76fb5f6a05973bdf94143eee761ede229751a802
Author: Jim Nelson <jim yorba org>
Date: Tue Aug 12 13:47:08 2014 -0700
Next/prev buttons on either side of date in header bar: Bug #734511
src/Makefile.am | 2 +
src/california-resources.xml | 3 +
src/host/host-main-window-title.vala | 35 ++++++++++++++
src/host/host-main-window.vala | 29 +++---------
src/rc/main-window-title.ui | 84 ++++++++++++++++++++++++++++++++++
5 files changed, 131 insertions(+), 22 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index dfd25be..de238ac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -101,6 +101,7 @@ california_VALASOURCES = \
host/host-event-time-settings.vala \
host/host-import-calendar.vala \
host/host-main-window.vala \
+ host/host-main-window-title.vala \
host/host-quick-create-event.vala \
host/host-show-event.vala \
\
@@ -195,6 +196,7 @@ california_RC = \
rc/google-authenticating.ui \
rc/google-calendar-list.ui \
rc/google-login.ui \
+ rc/main-window-title.ui \
rc/quick-create-event.ui \
rc/show-event.ui \
rc/window-menu.interface \
diff --git a/src/california-resources.xml b/src/california-resources.xml
index 5cfdfe8..0be1eb7 100644
--- a/src/california-resources.xml
+++ b/src/california-resources.xml
@@ -43,6 +43,9 @@
<file compressed="true">rc/google-login.ui</file>
</gresource>
<gresource prefix="/org/yorba/california">
+ <file compressed="true">rc/main-window-title.ui</file>
+ </gresource>
+ <gresource prefix="/org/yorba/california">
<file compressed="true">rc/quick-create-event.ui</file>
</gresource>
<gresource prefix="/org/yorba/california">
diff --git a/src/host/host-main-window-title.vala b/src/host/host-main-window-title.vala
new file mode 100644
index 0000000..01bd685
--- /dev/null
+++ b/src/host/host-main-window-title.vala
@@ -0,0 +1,35 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+namespace California.Host {
+
+[GtkTemplate (ui = "/org/yorba/california/rc/main-window-title.ui")]
+internal class MainWindowTitle : Gtk.Grid {
+ [GtkChild]
+ public Gtk.Button next_button;
+
+ [GtkChild]
+ public Gtk.Button prev_button;
+
+ [GtkChild]
+ public Gtk.Image next_image;
+
+ [GtkChild]
+ public Gtk.Image prev_image;
+
+ [GtkChild]
+ public Gtk.Label title_label;
+
+ public MainWindowTitle() {
+ if (get_direction() == Gtk.TextDirection.RTL) {
+ prev_image.icon_name = "go-previous-rtl-symbolic";
+ next_image.icon_name = "go-next-rtl-symbolic";
+ }
+ }
+}
+
+}
+
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 5ad0fc7..26dd5fd 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -91,6 +91,7 @@ public class MainWindow : Gtk.ApplicationWindow {
private Gee.HashSet<Binding> current_bindings = new Gee.HashSet<Binding>();
private Gtk.Stack view_stack = new Gtk.Stack();
private Gtk.HeaderBar headerbar = new Gtk.HeaderBar();
+ private MainWindowTitle custom_title = new MainWindowTitle();
private Gtk.Button today = new Gtk.Button.with_label(_("_Today"));
private Binding view_stack_binding;
private Gee.HashSet<string> view_stack_ids = new Gee.HashSet<string>();
@@ -153,29 +154,14 @@ public class MainWindow : Gtk.ApplicationWindow {
headerbar.show_close_button = true;
#endif
+ // Use custom headerbar title
+ headerbar.custom_title = custom_title;
+
today.valign = Gtk.Align.CENTER;
today.use_underline = true;
today.tooltip_text = _("Jump to today's date (Ctrl+T)");
today.set_action_name(DETAILED_ACTION_JUMP_TO_TODAY);
- Gtk.Button prev = new Gtk.Button.from_icon_name(rtl ? "go-previous-rtl-symbolic" :
"go-previous-symbolic",
- Gtk.IconSize.MENU);
- prev.valign = Gtk.Align.CENTER;
- prev.tooltip_text = _("Previous (Alt+Left)");
- prev.set_action_name(DETAILED_ACTION_PREVIOUS);
-
- Gtk.Button next = new Gtk.Button.from_icon_name(rtl ? "go-next-rtl-symbolic" : "go-next-symbolic",
- Gtk.IconSize.MENU);
- next.valign = Gtk.Align.CENTER;
- next.tooltip_text = _("Next (Alt+Right)");
- next.set_action_name(DETAILED_ACTION_NEXT);
-
- Gtk.Box nav_buttons = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
- nav_buttons.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED);
- nav_buttons.get_style_context().add_class(Gtk.STYLE_CLASS_RAISED);
- nav_buttons.pack_start(prev);
- nav_buttons.pack_end(next);
-
// TODO:
// Remove Gtk.StackSwitcher for a few reasons: (a) the buttons are kinda wide and
// would like to conserve header bar space; (b) want to add tooltips to buttons; and (c)
@@ -187,7 +173,6 @@ public class MainWindow : Gtk.ApplicationWindow {
// pack left-side of window
headerbar.pack_start(today);
- headerbar.pack_start(nav_buttons);
headerbar.pack_start(view_switcher);
quick_add_button = new Gtk.Button.from_icon_name("list-add-symbolic", Gtk.IconSize.MENU);
@@ -211,8 +196,8 @@ public class MainWindow : Gtk.ApplicationWindow {
// see https://bugzilla.gnome.org/show_bug.cgi?id=729771
Gtk.SizeGroup size = new Gtk.SizeGroup(Gtk.SizeGroupMode.VERTICAL);
size.add_widget(today);
- size.add_widget(prev);
- size.add_widget(next);
+ size.add_widget(custom_title.next_button);
+ size.add_widget(custom_title.prev_button);
size.add_widget(quick_add_button);
size.add_widget(calendars);
size.add_widget(window_menu);
@@ -329,7 +314,7 @@ public class MainWindow : Gtk.ApplicationWindow {
// bindings
Binding binding = current_controller.bind_property(View.Controllable.PROP_CURRENT_LABEL,
- headerbar, "title", BindingFlags.SYNC_CREATE);
+ custom_title.title_label, "label", BindingFlags.SYNC_CREATE);
current_bindings.add(binding);
binding = current_controller.bind_property(View.Controllable.PROP_IS_VIEWING_TODAY, today,
diff --git a/src/rc/main-window-title.ui b/src/rc/main-window-title.ui
new file mode 100644
index 0000000..1820157
--- /dev/null
+++ b/src/rc/main-window-title.ui
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <template class="CaliforniaHostMainWindowTitle" parent="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="row_spacing">4</property>
+ <property name="column_spacing">8</property>
+ <child>
+ <object class="GtkButton" id="prev_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Previous (Alt+Left)</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="hexpand">False</property>
+ <property name="vexpand">False</property>
+ <property name="action_name">win.previous</property>
+ <child>
+ <object class="GtkImage" id="next_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">go-previous-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="next_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Next (Alt+Right)</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="hexpand">False</property>
+ <property name="vexpand">False</property>
+ <property name="action_name">win.next</property>
+ <child>
+ <object class="GtkImage" id="prev_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">go-next-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="label">(title)</property>
+ <property name="wrap">True</property>
+ <property name="width_chars">24</property>
+ <property name="max_width_chars">24</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]