[evolution] Bug 336682 - Show keyboard shortcuts for Calendar views



commit 108fd8cd2f705850952e760b3408869a49d6adb7
Author: Milan Crha <mcrha redhat com>
Date:   Thu Aug 24 12:33:31 2017 +0200

    Bug 336682 - Show keyboard shortcuts for Calendar views

 data/views/calendar/galview.xml                 |   10 +++++-----
 src/e-util/gal-view-collection.c                |    3 +++
 src/e-util/gal-view-collection.h                |    1 +
 src/modules/calendar/e-cal-shell-view-actions.c |   10 +++++-----
 src/shell/e-shell-window-actions.c              |    5 ++++-
 5 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/data/views/calendar/galview.xml b/data/views/calendar/galview.xml
index 4654217..dfd0850 100644
--- a/data/views/calendar/galview.xml
+++ b/data/views/calendar/galview.xml
@@ -1,13 +1,13 @@
 <?xml version="1.0"?>
 <GalViewCollection default-view="Day_View">
   <GalView id="Day_View" _title="_Day View" filename="Day_View.galview" 
-    type="day_view"/>
+    type="day_view" accelerator="&lt;Control&gt;y"/>
   <GalView id="Work_Week_View" _title="_Work Week View" filename="Work_Week_View.galview" 
-    type="work_week_view"/>
+    type="work_week_view" accelerator="&lt;Control&gt;j"/>
   <GalView id="Week_View" _title="W_eek View" filename="Week_View.galview"
-    type="week_view"/>
+    type="week_view" accelerator="&lt;Control&gt;k"/>
   <GalView id="Month_View" _title="_Month View" filename="Month_View.galview"
-    type="month_view"/>
+    type="month_view" accelerator="&lt;Control&gt;m"/>
   <GalView id="List_View" _title="_List View" filename="List_View.galview"
-    type="etable"/>
+    type="etable" accelerator="&lt;Control&gt;l"/>
 </GalViewCollection>
diff --git a/src/e-util/gal-view-collection.c b/src/e-util/gal-view-collection.c
index 98b7e2e..91c9ac8 100644
--- a/src/e-util/gal-view-collection.c
+++ b/src/e-util/gal-view-collection.c
@@ -82,6 +82,7 @@ gal_view_collection_item_free (GalViewCollectionItem *item)
                                item->view_changed_id);
                g_object_unref (item->view);
        }
+       g_free (item->accelerator);
        g_free (item);
 }
 
@@ -220,6 +221,7 @@ load_single_file (GalViewCollection *collection,
        item->type = e_xml_get_string_prop_by_name (node, (const guchar *)"type");
        item->collection = collection;
        item->view_changed_id = 0;
+       item->accelerator = e_xml_get_string_prop_by_name (node, (const guchar *)"accelerator");
 
        if (item->filename) {
                gchar *fullpath;
@@ -755,6 +757,7 @@ gal_view_collection_append_with_title (GalViewCollection *collection,
        item->filename = g_strdup_printf ("%s.galview", item->id);
        item->view = view;
        item->collection = collection;
+       item->accelerator = NULL;
        g_object_ref (view);
 
        item->view_changed_id = g_signal_connect (
diff --git a/src/e-util/gal-view-collection.h b/src/e-util/gal-view-collection.h
index 9fecebb..3c76d86 100644
--- a/src/e-util/gal-view-collection.h
+++ b/src/e-util/gal-view-collection.h
@@ -74,6 +74,7 @@ struct _GalViewCollectionItem {
        gchar *type;
        GalViewCollection *collection;
        guint view_changed_id;
+       gchar *accelerator;
 };
 
 GType          gal_view_collection_get_type    (void) G_GNUC_CONST;
diff --git a/src/modules/calendar/e-cal-shell-view-actions.c b/src/modules/calendar/e-cal-shell-view-actions.c
index 0cbf934..50a5c7d 100644
--- a/src/modules/calendar/e-cal-shell-view-actions.c
+++ b/src/modules/calendar/e-cal-shell-view-actions.c
@@ -1628,35 +1628,35 @@ static GtkRadioActionEntry calendar_view_entries[] = {
        { "calendar-view-day",
          "view-calendar-day",
          N_("Day"),
-         NULL,
+         "<Control>y",
          N_("Show one day"),
          E_CAL_VIEW_KIND_DAY },
 
        { "calendar-view-list",
          "view-calendar-list",
          N_("List"),
-         NULL,
+         "<Control>l",
          N_("Show as list"),
          E_CAL_VIEW_KIND_LIST },
 
        { "calendar-view-month",
          "view-calendar-month",
          N_("Month"),
-         NULL,
+         "<Control>m",
          N_("Show one month"),
          E_CAL_VIEW_KIND_MONTH },
 
        { "calendar-view-week",
          "view-calendar-week",
          N_("Week"),
-         NULL,
+         "<Control>k",
          N_("Show one week"),
          E_CAL_VIEW_KIND_WEEK },
 
        { "calendar-view-workweek",
          "view-calendar-workweek",
          N_("Work Week"),
-         NULL,
+         "<Control>j",
          N_("Show one work week"),
          E_CAL_VIEW_KIND_WORKWEEK }
 };
diff --git a/src/shell/e-shell-window-actions.c b/src/shell/e-shell-window-actions.c
index 5de741e..b4d7d45 100644
--- a/src/shell/e-shell-window-actions.c
+++ b/src/shell/e-shell-window-actions.c
@@ -1700,7 +1700,10 @@ e_shell_window_update_view_menu (EShellWindow *shell_window)
                                _("Delete view: %s"), title);
                }
 
-               gtk_action_group_add_action (action_group, action);
+               if (item->built_in && item->accelerator)
+                       gtk_action_group_add_action_with_accel (action_group, action, item->accelerator);
+               else
+                       gtk_action_group_add_action (action_group, action);
 
                gtk_ui_manager_add_ui (
                        ui_manager, merge_id,


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