Commit 4466b63b authored by Jim Nelson's avatar Jim Nelson

New Preferences popopver in place of dropdown menu

parent bbd132fb
......@@ -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
......
......@@ -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 =
......
......@@ -39,6 +39,9 @@
<gresource prefix="/org/yorba/california">
<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>
......@@ -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>
......@@ -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();
......
/* 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 {
}
}
<?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>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="window-menu">
<section>
<item>
<attribute name="label" translatable="yes">_Monday</attribute>
<attribute name="action">win.first-of-week</attribute>
<attribute name="target">monday</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Sunday</attribute>
<attribute name="action">win.first-of-week</attribute>
<attribute name="target">sunday</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Zoom _In</attribute>
<attribute name="action">win.increase-font</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Zoom _Out</attribute>
<attribute name="action">win.decrease-font</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Normal Size</attribute>
<attribute name="action">win.reset-font</attribute>
</item>
</section>
</menu>
</interface>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment