window: add more shortcuts

Add the following new shortcuts:

 - Home: moves to today
 - PageUp: previous week/month/year
 - PageDn: next week/month/year

https://bugzilla.gnome.org/show_bug.cgi?id=740844
This commit is contained in:
Georges Basile Stavracas Neto
2017-04-13 07:32:21 -03:00
parent 1362762efe
commit 78eb9a7435
2 changed files with 19 additions and 17 deletions
+3 -3
View File
@@ -56,21 +56,21 @@
<object class="GtkShortcutsShortcut"> <object class="GtkShortcutsShortcut">
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes" context="shortcut window">Go back</property> <property name="title" translatable="yes" context="shortcut window">Go back</property>
<property name="accelerator">&lt;alt&gt;Left</property> <property name="accelerator">&lt;alt&gt;Left Page_Up</property>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkShortcutsShortcut"> <object class="GtkShortcutsShortcut">
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes" context="shortcut window">Go forward</property> <property name="title" translatable="yes" context="shortcut window">Go forward</property>
<property name="accelerator">&lt;alt&gt;Right</property> <property name="accelerator">&lt;alt&gt;Right Page_Down</property>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkShortcutsShortcut"> <object class="GtkShortcutsShortcut">
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes" context="shortcut window">Show today</property> <property name="title" translatable="yes" context="shortcut window">Show today</property>
<property name="accelerator">&lt;alt&gt;Down &lt;Primary&gt;T</property> <property name="accelerator">&lt;alt&gt;Down &lt;Primary&gt;T Home</property>
</object> </object>
</child> </child>
<child> <child>
+16 -14
View File
@@ -176,8 +176,8 @@ enum
#define FAST_REFRESH_TIMEOUT 900000 /* ms */ #define FAST_REFRESH_TIMEOUT 900000 /* ms */
#define SLOW_REFRESH_TIMEOUT 3600000 /* ms */ #define SLOW_REFRESH_TIMEOUT 3600000 /* ms */
#define gcal_window_add_accelerator(app,action,accel) {\ #define gcal_window_add_accelerator(app,action,...) {\
const gchar *tmp[] = {accel, NULL};\ const gchar *tmp[] = {__VA_ARGS__, NULL};\
gtk_application_set_accels_for_action (GTK_APPLICATION (app), action, tmp);\ gtk_application_set_accels_for_action (GTK_APPLICATION (app), action, tmp);\
} }
@@ -1535,6 +1535,7 @@ gcal_window_class_init(GcalWindowClass *klass)
static void static void
gcal_window_init (GcalWindow *self) gcal_window_init (GcalWindow *self)
{ {
GApplication *app;
GtkBuilder *builder; GtkBuilder *builder;
GMenuModel *winmenu; GMenuModel *winmenu;
GSettings *helper_settings; GSettings *helper_settings;
@@ -1601,6 +1602,19 @@ gcal_window_init (GcalWindow *self)
self->active_date = g_new0 (icaltimetype, 1); self->active_date = g_new0 (icaltimetype, 1);
self->rtl = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL; self->rtl = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL;
/* setup accels */
app = g_application_get_default ();
gcal_window_add_accelerator (app, "win.next", "<Alt>Right", "Page_Down");
gcal_window_add_accelerator (app, "win.previous", "<Alt>Left", "Page_Up");
gcal_window_add_accelerator (app, "win.today", "<Alt>Down", "<Ctrl>t", "Home");
gcal_window_add_accelerator (app, "win.change-view(-1)", "<Ctrl>Page_Down");
gcal_window_add_accelerator (app, "win.change-view(-2)", "<Ctrl>Page_Up");
gcal_window_add_accelerator (app, "win.change-view(1)", "<Ctrl>1")
gcal_window_add_accelerator (app, "win.change-view(2)", "<Ctrl>2");
gcal_window_add_accelerator (app, "win.change-view(3)", "<Ctrl>3");
} }
/* Public API */ /* Public API */
@@ -1630,18 +1644,6 @@ gcal_window_new_with_view_and_date (GcalApplication *app,
"active-date", date, "active-date", date,
NULL); NULL);
/* setup accels */
gcal_window_add_accelerator (app, "win.next", "<Alt>Right");
gcal_window_add_accelerator (app, "win.previous", "<Alt>Left");
gcal_window_add_accelerator (app, "win.today", "<Alt>Down");
gcal_window_add_accelerator (app, "win.today", "<Ctrl>t");
gcal_window_add_accelerator (app, "win.change-view(-1)", "<Ctrl>Page_Down");
gcal_window_add_accelerator (app, "win.change-view(-2)", "<Ctrl>Page_Up");
gcal_window_add_accelerator (app, "win.change-view(1)", "<Ctrl>1")
gcal_window_add_accelerator (app, "win.change-view(2)", "<Ctrl>2");
gcal_window_add_accelerator (app, "win.change-view(3)", "<Ctrl>3");
/* loading size */ /* loading size */
load_geometry (win); load_geometry (win);