[gthumb] added an application menu
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] added an application menu
- Date: Thu, 2 Aug 2012 12:35:04 +0000 (UTC)
commit dd1aead4762192152e1abeb2306ef2872e7cb3e7
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu May 31 23:28:54 2012 +0200
added an application menu
configure.ac | 4 +-
gthumb/gth-window.c | 2 +-
gthumb/gth-window.h | 4 +-
gthumb/main.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 137 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 58f7d62..e40886d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,8 +56,8 @@ GNOME_CXX_WARNINGS
GLIB_GSETTINGS
GTHUMB_EXTENSION_RULES
-GLIB_REQUIRED=2.28.0
-GTK_REQUIRED=3.2.0
+GLIB_REQUIRED=2.32.0
+GTK_REQUIRED=3.4.0
EXIV2_REQUIRED=0.21
CLUTTER_REQUIRED=1.0.0
CLUTTER_GTK_REQUIRED=1.0.0
diff --git a/gthumb/gth-window.c b/gthumb/gth-window.c
index 6ae91d7..fc19e4f 100644
--- a/gthumb/gth-window.c
+++ b/gthumb/gth-window.c
@@ -26,7 +26,7 @@
#include "main.h"
-G_DEFINE_TYPE (GthWindow, gth_window, GTK_TYPE_WINDOW)
+G_DEFINE_TYPE (GthWindow, gth_window, GTK_TYPE_APPLICATION_WINDOW)
enum {
diff --git a/gthumb/gth-window.h b/gthumb/gth-window.h
index c4e0dfa..83bc5cd 100644
--- a/gthumb/gth-window.h
+++ b/gthumb/gth-window.h
@@ -54,13 +54,13 @@ typedef struct _GthWindowPrivate GthWindowPrivate;
struct _GthWindow
{
- GtkWindow __parent;
+ GtkApplicationWindow __parent;
GthWindowPrivate *priv;
};
struct _GthWindowClass
{
- GtkWindowClass __parent_class;
+ GtkApplicationWindowClass __parent_class;
/*< virtual functions >*/
diff --git a/gthumb/main.c b/gthumb/main.c
index d935156..0aba7e4 100644
--- a/gthumb/main.c
+++ b/gthumb/main.c
@@ -36,10 +36,12 @@
#include "eggdesktopfile.h"
#include "glib-utils.h"
#include "gth-browser.h"
+#include "gth-browser-actions-callbacks.h"
#include "gth-file-data.h"
#include "gth-file-source-vfs.h"
#include "gth-main.h"
#include "gth-preferences.h"
+#include "gth-window-actions-callbacks.h"
#include "main-migrate.h"
@@ -317,10 +319,140 @@ gth_application_init (GthApplication *app)
static void
+activate_new_window (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_browser_activate_action_file_new_window (NULL, windows->data);
+}
+
+
+static void
+activate_preferences (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_browser_activate_action_edit_preferences (NULL, windows->data);
+}
+
+
+static void
+activate_help (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_browser_activate_action_help_help (NULL, windows->data);
+}
+
+
+static void
+activate_about (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_browser_activate_action_help_about (NULL, windows->data);
+}
+
+
+static void
+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_window_activate_action_file_quit_application (NULL, windows->data);
+}
+
+
+static const GActionEntry app_menu_entries[] = {
+ { "new-window", activate_new_window },
+ { "preferences", activate_preferences },
+ { "help", activate_help },
+ { "about", activate_about },
+ { "quit", activate_quit }
+};
+
+
+static void
+_gth_application_initialize_app_menu (GApplication *application)
+{
+ GtkBuilder *builder;
+ GError *error = NULL;
+
+ g_action_map_add_action_entries (G_ACTION_MAP (application),
+ app_menu_entries,
+ G_N_ELEMENTS (app_menu_entries),
+ application);
+
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_string (builder,
+ "<interface>"
+ " <menu id='app-menu'>"
+ " <section>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>New _Window</attribute>"
+ " <attribute name='action'>app.new-window</attribute>"
+ " </item>"
+ " </section>"
+ " <section>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>_Preferences</attribute>"
+ " <attribute name='action'>app.preferences</attribute>"
+ " </item>"
+ " </section>"
+ " <section>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>_Help</attribute>"
+ " <attribute name='action'>app.help</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>_About gThumb</attribute>"
+ " <attribute name='action'>app.about</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>_Quit</attribute>"
+ " <attribute name='action'>app.quit</attribute>"
+ " </item>"
+ " </section>"
+ " </menu>"
+ "</interface>", -1, &error);
+ gtk_application_set_app_menu (GTK_APPLICATION (application),
+ G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
+
+ g_object_unref (builder);
+}
+
+
+static void
gth_application_startup (GApplication *application)
{
G_APPLICATION_CLASS (gth_application_parent_class)->startup (application);
+ _gth_application_initialize_app_menu (application);
gth_pref_initialize ();
migrate_data ();
gth_main_initialize ();
@@ -577,7 +709,6 @@ main (int argc, char *argv[])
program_argv0 = argv[0];
- g_thread_init (NULL);
g_type_init ();
/* text domain */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]