[gthumb] converted application actions into window actions
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] converted application actions into window actions
- Date: Sun, 24 Nov 2019 12:32:12 +0000 (UTC)
commit ff81c83f1b029a4e6499da75c567c6ab516ed4a0
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Nov 13 20:02:50 2019 +0100
converted application actions into window actions
gthumb/gth-application.c | 27 ----------
gthumb/gth-browser-actions-callbacks.c | 92 +++++++++++-----------------------
gthumb/gth-browser-actions-callbacks.h | 12 ++---
gthumb/gth-browser-actions-entries.h | 23 +++++----
gthumb/gth-browser.c | 4 --
gthumb/resources/gears-menu.ui | 18 ++++++-
6 files changed, 64 insertions(+), 112 deletions(-)
---
diff --git a/gthumb/gth-application.c b/gthumb/gth-application.c
index b79915ef..7e06a174 100644
--- a/gthumb/gth-application.c
+++ b/gthumb/gth-application.c
@@ -134,32 +134,6 @@ gth_application_init (GthApplication *app)
}
-static const GActionEntry app_menu_entries[] = {
- { "new-window", gth_application_activate_new_window },
- { "preferences", gth_application_activate_preferences },
- { "shortcuts", gth_application_activate_show_shortcuts },
- { "help", gth_application_activate_show_help },
- { "about", gth_application_activate_about },
- { "quit", gth_application_activate_quit }
-};
-
-
-static void
-_gth_application_initialize_app_actions (GApplication *application)
-{
- const char * const new_window_accel[] = { "<Primary>n", NULL };
- const char * const quit_accel[] = { "<Primary>q", NULL };
-
- g_action_map_add_action_entries (G_ACTION_MAP (application),
- app_menu_entries,
- G_N_ELEMENTS (app_menu_entries),
- application);
-
- gtk_application_set_accels_for_action (GTK_APPLICATION (application), "app.new-window",
new_window_accel);
- gtk_application_set_accels_for_action (GTK_APPLICATION (application), "app.quit", quit_accel);
-}
-
-
static void
migrate_data (void)
{
@@ -174,7 +148,6 @@ gth_application_startup (GApplication *application)
g_object_set (gtk_settings_get_default (), "gtk-application-prefer-dark-theme", TRUE, NULL);
- _gth_application_initialize_app_actions (application);
gth_pref_initialize ();
migrate_data ();
gth_main_initialize ();
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index c3949d68..11c19106 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -40,80 +40,52 @@
#include "main.h"
-static GtkWidget *
-_gth_application_get_current_window (GApplication *application)
-{
- GList *windows;
-
- windows = gtk_application_get_windows (GTK_APPLICATION (application));
- if (windows == NULL)
- return NULL;
-
- return GTK_WIDGET (windows->data);
-}
-
-
void
-gth_application_activate_new_window (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+gth_browser_activate_new_window (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- GApplication *application = user_data;
- GtkWidget *browser;
- GtkWidget *window;
+ GtkWidget *browser = user_data;
+ GtkWidget *window;
- browser = _gth_application_get_current_window (application);
- window = gth_browser_new (gth_browser_get_location (GTH_BROWSER (browser)), NULL);
- gtk_window_present (GTK_WINDOW (window));
+ window = gth_browser_new (gth_browser_get_location (GTH_BROWSER (browser)), NULL);
+ gtk_window_present (GTK_WINDOW (window));
}
void
-gth_application_activate_preferences (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+gth_browser_activate_preferences (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- GApplication *application = user_data;
- GtkWidget *browser;
-
- browser = _gth_application_get_current_window (application);
- dlg_preferences (GTH_BROWSER (browser));
+ dlg_preferences (GTH_BROWSER (user_data));
}
void
-gth_application_activate_show_help (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+gth_browser_activate_show_help (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- GApplication *application = user_data;
- GtkWidget *browser;
-
- browser = _gth_application_get_current_window (application);
- show_help_dialog (GTK_WINDOW (browser), NULL);
+ show_help_dialog (GTK_WINDOW (user_data), NULL);
}
void
-gth_application_activate_show_shortcuts (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+gth_browser_activate_show_shortcuts (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- GApplication *application = user_data;
- GtkWidget *browser;
-
- browser = _gth_application_get_current_window (application);
- gth_shortcuts_window_new (GTH_WINDOW (browser));
+ gth_shortcuts_window_new (GTH_WINDOW (user_data));
}
void
-gth_application_activate_about (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+gth_browser_activate_about (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- GApplication *application = user_data;
- GthWindow *window;
+ GthBrowser *browser = user_data;
const char *authors[] = {
#include "AUTHORS.tab"
NULL
@@ -138,19 +110,18 @@ gth_application_activate_about (GSimpleAction *action,
};
GdkPixbuf *logo;
- window = (GthWindow *) _gth_application_get_current_window (application);
license_text = g_strconcat (_(license[0]), "\n\n",
_(license[1]), "\n\n",
_(license[2]),
NULL);
- logo = gtk_icon_theme_load_icon (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET
(window))),
+ logo = gtk_icon_theme_load_icon (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET
(browser))),
"gthumb",
128,
GTK_ICON_LOOKUP_NO_SVG,
NULL);
- gtk_show_about_dialog (GTK_WINDOW (window),
+ gtk_show_about_dialog (GTK_WINDOW (browser),
"version", PACKAGE_VERSION,
"copyright", "Copyright \xc2\xa9 2001-2013 Free Software Foundation, Inc.",
"comments", _("An image viewer and browser for GNOME."),
@@ -169,16 +140,11 @@ gth_application_activate_about (GSimpleAction *action,
void
-gth_application_activate_quit (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+gth_browser_activate_quit (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- GApplication *application = user_data;
- GList *windows;
-
- windows = gtk_application_get_windows (GTK_APPLICATION (application));
- if (windows != NULL)
- gth_quit (FALSE);
+ gth_quit (FALSE);
}
diff --git a/gthumb/gth-browser-actions-callbacks.h b/gthumb/gth-browser-actions-callbacks.h
index 98c78703..64db38ea 100644
--- a/gthumb/gth-browser-actions-callbacks.h
+++ b/gthumb/gth-browser-actions-callbacks.h
@@ -25,12 +25,12 @@
#include <gtk/gtk.h>
#include "glib-utils.h"
-DEF_ACTION_CALLBACK (gth_application_activate_new_window)
-DEF_ACTION_CALLBACK (gth_application_activate_preferences)
-DEF_ACTION_CALLBACK (gth_application_activate_show_shortcuts)
-DEF_ACTION_CALLBACK (gth_application_activate_show_help)
-DEF_ACTION_CALLBACK (gth_application_activate_about)
-DEF_ACTION_CALLBACK (gth_application_activate_quit)
+DEF_ACTION_CALLBACK (gth_browser_activate_new_window)
+DEF_ACTION_CALLBACK (gth_browser_activate_preferences)
+DEF_ACTION_CALLBACK (gth_browser_activate_show_shortcuts)
+DEF_ACTION_CALLBACK (gth_browser_activate_show_help)
+DEF_ACTION_CALLBACK (gth_browser_activate_about)
+DEF_ACTION_CALLBACK (gth_browser_activate_quit)
DEF_ACTION_CALLBACK (gth_browser_activate_browser_mode)
DEF_ACTION_CALLBACK (gth_browser_activate_browser_edit_file)
DEF_ACTION_CALLBACK (gth_browser_activate_browser_properties)
diff --git a/gthumb/gth-browser-actions-entries.h b/gthumb/gth-browser-actions-entries.h
index 74bad7c0..13b5f14f 100644
--- a/gthumb/gth-browser-actions-entries.h
+++ b/gthumb/gth-browser-actions-entries.h
@@ -29,6 +29,13 @@
static const GActionEntry gth_browser_actions[] = {
+ { "new-window", gth_browser_activate_new_window },
+ { "preferences", gth_browser_activate_preferences },
+ { "shortcuts", gth_browser_activate_show_shortcuts },
+ { "help", gth_browser_activate_show_help },
+ { "about", gth_browser_activate_about },
+ { "quit", gth_browser_activate_quit },
+
{ "browser-mode", gth_browser_activate_browser_mode },
{ "browser-edit-file", gth_browser_activate_browser_edit_file },
{ "browser-properties", toggle_action_activated, NULL, "false",
gth_browser_activate_browser_properties },
@@ -79,10 +86,12 @@ static const GthAccelerator gth_browser_accelerators[] = {
static const GthShortcut gth_browser_shortcuts[] = {
+ { "new-window", N_("New Window"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER | GTH_SHORTCUT_CONTEXT_FIXED,
GTH_SHORTCUT_CATEGORY_GENERAL, "<Primary>n" },
+ { "help", N_("Help"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER | GTH_SHORTCUT_CONTEXT_FIXED,
GTH_SHORTCUT_CATEGORY_GENERAL, "F1" },
+ { "quit", N_("Quit"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER | GTH_SHORTCUT_CONTEXT_FIXED,
GTH_SHORTCUT_CATEGORY_GENERAL, "<Primary>q" },
+
{ "browser-mode", N_("Show browser"), GTH_SHORTCUT_CONTEXT_INTERNAL | GTH_SHORTCUT_CONTEXT_VIEWER,
GTH_SHORTCUT_CATEGORY_GENERAL, "Escape" },
- { "close", N_("Close window"), GTH_SHORTCUT_CONTEXT_INTERNAL | GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER,
GTH_SHORTCUT_CATEGORY_GENERAL, "<Primary>w" },
- { "quit", N_("Quit"), GTH_SHORTCUT_CONTEXT_INTERNAL | GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER,
GTH_SHORTCUT_CATEGORY_GENERAL, "<Primary>q" },
- { "new-window", N_("New Window"), GTH_SHORTCUT_CONTEXT_INTERNAL |
GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_GENERAL, "<Primary>n" },
+ { "close", N_("Close window"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_GENERAL,
"<Primary>w" },
{ "open-location", N_("Open location"), GTH_SHORTCUT_CONTEXT_BROWSER,
GTH_SHORTCUT_CATEGORY_NAVIGATION, "o" },
{ "fullscreen", N_("Fullscreen"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_VIEWER,
"f" },
@@ -109,12 +118,4 @@ static const GthShortcut gth_browser_shortcuts[] = {
};
-static const GthMenuEntry gears_app_action_entries[] = {
- { N_("_Preferences"), "app.preferences" },
- { N_("Keyboard Shortcuts"), "app.shortcuts" },
- { N_("_Help"), "app.help" },
- { N_("_About gThumb"), "app.about" }
-};
-
-
#endif /* GTH_BROWSER_ACTION_ENTRIES_H */
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 4d9501f5..7b2d5e11 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -4420,10 +4420,6 @@ gth_browser_init (GthBrowser *browser)
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar),
browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_EDITOR_APPLY]);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar),
browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_EDITOR_COMMANDS]);
- gth_menu_manager_append_entries (gth_browser_get_menu_manager (browser,
GTH_BROWSER_MENU_MANAGER_GEARS_APP_ACTIONS),
- gears_app_action_entries,
- G_N_ELEMENTS (gears_app_action_entries));
-
/* browser navigation */
gth_browser_add_header_bar_button (browser,
diff --git a/gthumb/resources/gears-menu.ui b/gthumb/resources/gears-menu.ui
index 39857a28..1443d1f0 100644
--- a/gthumb/resources/gears-menu.ui
+++ b/gthumb/resources/gears-menu.ui
@@ -5,7 +5,7 @@
<section>
<item>
<attribute name="label" translatable="yes">New Window</attribute>
- <attribute name="action">app.new-window</attribute>
+ <attribute name="action">win.new-window</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Open Location…</attribute>
@@ -41,6 +41,22 @@
<section id="other-actions">
</section>
<section id="app-actions">
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">win.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
+ <attribute name="action">win.shortcuts</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">win.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About gThumb</attribute>
+ <attribute name="action">win.about</attribute>
+ </item>
</section>
</menu>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]