[gnome-photos/menu-retirement] Wire the F10 accelerator key to the primary menu



commit e564f5e4d65d8aa9472b92da385956b61049ae30
Author: Yi-Soo An <yisooan gmail com>
Date:   Tue Jan 15 11:46:37 2019 +0900

    Wire the F10 accelerator key to the primary menu
    
    https://gitlab.gnome.org/GNOME/gnome-photos/merge_requests/83

 src/photos-application.c  | 8 ++++++++
 src/photos-main-toolbar.c | 6 ++++++
 2 files changed, 14 insertions(+)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index cbaece0a..99987428 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -91,6 +91,7 @@ struct _PhotosApplication
   GSimpleAction *edit_done_action;
   GSimpleAction *edit_revert_action;
   GSimpleAction *fs_action;
+  GSimpleAction *primary_menu_action;
   GSimpleAction *gear_action;
   GSimpleAction *import_action;
   GSimpleAction *import_cancel_action;
@@ -506,6 +507,7 @@ photos_application_actions_update (PhotosApplication *self)
   g_simple_action_set_enabled (self->sel_all_action, enable);
   g_simple_action_set_enabled (self->sel_none_action, enable);
   g_simple_action_set_enabled (self->selection_mode_action, enable);
+  g_simple_action_set_enabled (self->primary_menu_action, enable);
 
   enable = (mode == PHOTOS_WINDOW_MODE_IMPORT);
   g_simple_action_set_enabled (self->import_cancel_action, enable);
@@ -2722,6 +2724,10 @@ photos_application_startup (GApplication *application)
   self->gear_action = g_simple_action_new_stateful ("gear-menu", NULL, state);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->gear_action));
 
+  state = g_variant_new ("b", FALSE);
+  self->primary_menu_action = g_simple_action_new_stateful ("primary-menu", NULL, state);
+  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->primary_menu_action));
+
   self->import_action = g_simple_action_new ("import-current", NULL);
   g_signal_connect_swapped (self->import_action, "activate", G_CALLBACK (photos_application_import), self);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->import_action));
@@ -2870,6 +2876,7 @@ photos_application_startup (GApplication *application)
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.edit-current", edit_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.fullscreen", fullscreen_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.gear-menu", gear_menu_accels);
+  gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.primary-menu", gear_menu_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.help", help_menu_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.print-current", print_current_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.save-current", save_accels);
@@ -2955,6 +2962,7 @@ photos_application_dispose (GObject *object)
   g_clear_object (&self->edit_done_action);
   g_clear_object (&self->edit_revert_action);
   g_clear_object (&self->fs_action);
+  g_clear_object (&self->primary_menu_action);
   g_clear_object (&self->gear_action);
   g_clear_object (&self->import_action);
   g_clear_object (&self->import_cancel_action);
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 649fc8e1..91b438dd 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -46,6 +46,7 @@ struct _PhotosMainToolbar
   GtkBox parent_instance;
   GAction *search;
   GSimpleAction *gear_menu;
+  GSimpleAction *primary_menu;
   GtkWidget *favorite_button;
   GtkWidget *header_bar;
   GtkWidget *remote_display_button;
@@ -245,9 +246,12 @@ photos_main_toolbar_add_primary_menu_button (PhotosMainToolbar *self)
   primary_menu = G_MENU (gtk_builder_get_object (builder, "primary-menu"));
   image = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_BUTTON);
   menu_button = gtk_menu_button_new ();
+  gtk_actionable_set_action_name (GTK_ACTIONABLE (menu_button), "app.primary-menu");
   gtk_button_set_image (GTK_BUTTON (menu_button), image);
   gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), G_MENU_MODEL (primary_menu));
   gtk_header_bar_pack_end (GTK_HEADER_BAR (self->header_bar), menu_button);
+
+  g_simple_action_set_enabled (self->primary_menu, TRUE);
 }
 
 
@@ -382,6 +386,7 @@ photos_main_toolbar_clear_toolbar (PhotosMainToolbar *self)
   gtk_style_context_remove_class (context, "selection-mode");
 
   g_simple_action_set_enabled (self->gear_menu, FALSE);
+  g_simple_action_set_enabled (self->primary_menu, FALSE);
 }
 
 
@@ -717,6 +722,7 @@ photos_main_toolbar_init (PhotosMainToolbar *self)
   state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
 
   self->gear_menu = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (app), "gear-menu"));
+  self->primary_menu = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (app), "primary-menu"));
   self->search = g_action_map_lookup_action (G_ACTION_MAP (app), "search");
 
   action = g_action_map_lookup_action (G_ACTION_MAP (app), "selection-mode");


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