[california/wip/725776-monday: 7/7] New Preferences popopver in place of dropdown menu



commit 4466b63ba9f6faa86d0e9b71e981e7ec8e2da1d4
Author: Jim Nelson <jim yorba org>
Date:   Wed Aug 6 12:24:12 2014 -0700

    New Preferences popopver in place of dropdown menu

 po/POTFILES.in                 |    1 +
 src/Makefile.am                |    3 +-
 src/california-resources.xml   |    6 +-
 src/host/host-main-window.vala |   61 +++------------
 src/host/host-preferences.vala |   13 +++
 src/rc/preferences.ui          |  173 ++++++++++++++++++++++++++++++++++++++++
 src/rc/window-menu.interface   |   32 --------
 7 files changed, 202 insertions(+), 87 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 181be7c..966c889 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -29,6 +29,7 @@ src/view/week/week-controller.vala
 [type: gettext/glade]src/rc/google-authenticating.ui
 [type: gettext/glade]src/rc/google-calendar-list.ui
 [type: gettext/glade]src/rc/google-login.ui
+[type: gettext/glade]src/rc/preferences.ui
 [type: gettext/glade]src/rc/quick-create-event.ui
 [type: gettext/glade]src/rc/show-event.ui
 [type: gettext/glade]src/rc/webcal-subscribe.ui
diff --git a/src/Makefile.am b/src/Makefile.am
index a858b9a..6d92067 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -97,6 +97,7 @@ california_VALASOURCES = \
        host/host-event-time-settings.vala \
        host/host-import-calendar.vala \
        host/host-main-window.vala \
+       host/host-preferences.vala \
        host/host-quick-create-event.vala \
        host/host-show-event.vala \
        \
@@ -190,10 +191,10 @@ california_RC = \
        rc/google-authenticating.ui \
        rc/google-calendar-list.ui \
        rc/google-login.ui \
+       rc/preferences.ui \
        rc/quick-create-event.ui \
        rc/show-event.ui \
        rc/webcal-subscribe.ui \
-       rc/window-menu.interface \
        $(NULL)
 
 california_OPTIONAL_VALAFLAGS =
diff --git a/src/california-resources.xml b/src/california-resources.xml
index 6d65154..0f4b825 100644
--- a/src/california-resources.xml
+++ b/src/california-resources.xml
@@ -40,6 +40,9 @@
         <file compressed="true">rc/google-login.ui</file>
     </gresource>
     <gresource prefix="/org/yorba/california">
+        <file compressed="true">rc/preferences.ui</file>
+    </gresource>
+    <gresource prefix="/org/yorba/california">
         <file compressed="true">rc/quick-create-event.ui</file>
     </gresource>
     <gresource prefix="/org/yorba/california">
@@ -48,8 +51,5 @@
     <gresource prefix="/org/yorba/california">
         <file compressed="true">rc/webcal-subscribe.ui</file>
     </gresource>
-    <gresource prefix="/org/yorba/california">
-        <file compressed="true">rc/window-menu.interface</file>
-    </gresource>
 </gresources>
 
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 1619508..52bf110 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -71,9 +71,6 @@ public class MainWindow : Gtk.ApplicationWindow {
     private const string ACTION_RESET_FONT = "reset-font";
     private const string ACCEL_RESET_FONT = "KP_Multiply";
     
-    private const string DETAILED_ACTION_FOW = "win.first-of-week";
-    private const string ACTION_FOW = "first-of-week";
-    
     private static const ActionEntry[] action_entries = {
         { ACTION_QUICK_CREATE_EVENT, on_quick_create_event },
         { ACTION_JUMP_TO_TODAY, on_jump_to_today },
@@ -83,8 +80,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         { ACTION_WEEK, on_view_week },
         { ACTION_INCREASE_FONT, on_increase_font },
         { ACTION_DECREASE_FONT, on_decrease_font },
-        { ACTION_RESET_FONT, on_reset_font },
-        { ACTION_FOW, on_first_of_week, "s" }
+        { ACTION_RESET_FONT, on_reset_font }
     };
     
     private Gtk.Button quick_add_button;
@@ -207,9 +203,13 @@ public class MainWindow : Gtk.ApplicationWindow {
         
         Gtk.MenuButton window_menu = new Gtk.MenuButton();
         window_menu.valign = Gtk.Align.CENTER;
-        window_menu.menu_model = Resource.load<MenuModel>("window-menu.interface", "window-menu");
         window_menu.image = new Gtk.Image.from_icon_name("emblem-system-symbolic", Gtk.IconSize.MENU);
         
+        Gtk.Popover preferences_popover = new Gtk.Popover(window_menu);
+        preferences_popover.add(new Preferences());
+        
+        window_menu.popover = preferences_popover;
+        
         // Vertically center all buttons and put them in a SizeGroup to handle situations where
         // the text button is smaller than the icons buttons due to language (i.e. Hebrew)
         // see https://bugzilla.gnome.org/show_bug.cgi?id=729771
@@ -256,15 +256,11 @@ public class MainWindow : Gtk.ApplicationWindow {
         Settings.instance.notify[Settings.PROP_SMALL_FONT_PTS].connect(on_font_size_changed);
         Settings.instance.notify[Settings.PROP_NORMAL_FONT_PTS].connect(on_font_size_changed);
         on_font_size_changed();
-        
-        Calendar.System.instance.first_of_week_changed.connect(on_first_of_week_changed);
-        on_first_of_week_changed(Calendar.FirstOfWeek.DEFAULT, Calendar.System.first_of_week);
     }
     
     ~MainWindow() {
         Settings.instance.notify[Settings.PROP_SMALL_FONT_PTS].disconnect(on_font_size_changed);
         Settings.instance.notify[Settings.PROP_NORMAL_FONT_PTS].disconnect(on_font_size_changed);
-        Calendar.System.instance.first_of_week_changed.disconnect(on_first_of_week_changed);
     }
     
     public bool is_window_maximized() {
@@ -407,7 +403,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         Settings.instance.normal_font_pts = View.Palette.DEFAULT_NORMAL_FONT_PTS;
     }
     
-    public SimpleAction action_for(string action_name) {
+    private SimpleAction action_for(string action_name) {
         SimpleAction? action = lookup_action(action_name) as SimpleAction;
         assert(action != null);
         
@@ -415,54 +411,17 @@ public class MainWindow : Gtk.ApplicationWindow {
     }
     
     private void on_font_size_changed() {
-        ((SimpleAction) lookup_action(ACTION_INCREASE_FONT)).set_enabled(
+        action_for(ACTION_INCREASE_FONT).set_enabled(
             Settings.instance.small_font_pts < View.Palette.MAX_SMALL_FONT_PTS
             && Settings.instance.normal_font_pts < View.Palette.MAX_NORMAL_FONT_PTS);
-        ((SimpleAction) lookup_action(ACTION_DECREASE_FONT)).set_enabled(
+        action_for(ACTION_DECREASE_FONT).set_enabled(
             Settings.instance.small_font_pts > View.Palette.MIN_SMALL_FONT_PTS
             && Settings.instance.normal_font_pts > View.Palette.MIN_NORMAL_FONT_PTS);
-        ((SimpleAction) lookup_action(ACTION_RESET_FONT)).set_enabled(
+        action_for(ACTION_RESET_FONT).set_enabled(
             Settings.instance.small_font_pts != View.Palette.DEFAULT_SMALL_FONT_PTS
             && Settings.instance.normal_font_pts != View.Palette.DEFAULT_NORMAL_FONT_PTS);
     }
     
-    private void on_first_of_week(SimpleAction action, Variant? value) {
-        string? value_string = value as string;
-        if (String.is_empty(value_string))
-            return;
-        
-        Calendar.System.instance.first_of_week_changed.disconnect(on_first_of_week_changed);
-        switch (value_string) {
-            case "monday":
-                Calendar.System.first_of_week = Calendar.FirstOfWeek.MONDAY;
-            break;
-            
-            case "sunday":
-                Calendar.System.first_of_week = Calendar.FirstOfWeek.SUNDAY;
-            break;
-            
-            default:
-                assert_not_reached();
-        }
-        Calendar.System.instance.first_of_week_changed.connect(on_first_of_week_changed);
-    }
-    
-    private void on_first_of_week_changed(Calendar.FirstOfWeek old_fow, Calendar.FirstOfWeek new_fow) {
-        debug("on_first_of_week_changed: %s", new_fow.to_string());
-        switch (new_fow) {
-            case Calendar.FirstOfWeek.MONDAY:
-                action_for(ACTION_FOW).change_state("monday");
-            break;
-            
-            case Calendar.FirstOfWeek.SUNDAY:
-                action_for(ACTION_FOW).change_state("sunday");
-            break;
-            
-            default:
-                assert_not_reached();
-        }
-    }
-    
     private void on_request_create_timed_event(Calendar.ExactTimeSpan initial, Gtk.Widget relative_to,
         Gdk.Point? for_location) {
         Component.Event event = new Component.Event.blank();
diff --git a/src/host/host-preferences.vala b/src/host/host-preferences.vala
new file mode 100644
index 0000000..85199d0
--- /dev/null
+++ b/src/host/host-preferences.vala
@@ -0,0 +1,13 @@
+/* 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/preferences.ui")]
+public class Preferences : Gtk.Grid {
+}
+
+}
diff --git a/src/rc/preferences.ui b/src/rc/preferences.ui
new file mode 100644
index 0000000..8a251ea
--- /dev/null
+++ b/src/rc/preferences.ui
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <template class="CaliforniaHostPreferences" parent="GtkGrid">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="margin_left">8</property>
+    <property name="margin_right">8</property>
+    <property name="margin_top">8</property>
+    <property name="margin_bottom">8</property>
+    <property name="row_spacing">12</property>
+    <property name="column_spacing">8</property>
+    <child>
+      <object class="GtkLabel" id="zoom_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="xalign">1</property>
+        <property name="label" translatable="yes">Zoom</property>
+        <style>
+          <class name="dim-label"/>
+        </style>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">1</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="zoom_box">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">4</property>
+        <child>
+          <object class="GtkButton" id="zoom_increase_button">
+            <property name="label">+</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="tooltip_text" translatable="yes">Increase zoom</property>
+            <property name="action_name">win.increase-font</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="zoom_reset_button">
+            <property name="label">100%</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="tooltip_text" translatable="yes">Reset zoom</property>
+            <property name="action_name">win.reset-font</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="zoom_decrease_button">
+            <property name="label">-</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="tooltip_text" translatable="yes">Decrease zoom</property>
+            <property name="action_name">win.decrease-font</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">1</property>
+        <property name="top_attach">1</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="label1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="xalign">1</property>
+        <property name="label" translatable="yes">Start of week</property>
+        <style>
+          <class name="dim-label"/>
+        </style>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkRadioButton" id="monday_radiobutton">
+            <property name="label" translatable="yes">_Monday</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="use_underline">True</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRadioButton" id="sunday_radiobutton">
+            <property name="label" translatable="yes">_Sunday</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="use_underline">True</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+            <property name="group">monday_radiobutton</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRadioButton" id="system_radiobutton">
+            <property name="label" translatable="yes">S_ystem-defined</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="use_underline">True</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+            <property name="group">monday_radiobutton</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">1</property>
+        <property name="top_attach">0</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+  </template>
+</interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]