[california/wip/734511-buttons] This might do it.



commit fb902eb3fcad8dc481c96054d61f1c26c8507b90
Author: Jim Nelson <jim yorba org>
Date:   Fri Aug 8 17:49:52 2014 -0700

    This might do it.

 src/Makefile.am                      |    2 +
 src/california-resources.xml         |    3 +
 src/host/host-main-window-title.vala |   31 ++++++++++++
 src/host/host-main-window.vala       |   33 ++++---------
 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..1500957
--- /dev/null
+++ b/src/host/host-main-window-title.vala
@@ -0,0 +1,31 @@
+/* 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() {
+    }
+}
+
+}
+
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 5ad0fc7..e252d31 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,18 @@ public class MainWindow : Gtk.ApplicationWindow {
         headerbar.show_close_button = true;
 #endif
         
+        // Use custom headerbar title
+        headerbar.custom_title = custom_title;
+        if (rtl) {
+            custom_title.prev_image.icon_name = "go-previous-rtl-symbolic";
+            custom_title.next_image.icon_name = "go-next-rtl-symbolic";
+        }
+        
         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 +177,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 +200,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 +318,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]