[file-roller] use a menubar if the shell doesn't support the app menu
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] use a menubar if the shell doesn't support the app menu
- Date: Fri, 22 Nov 2013 16:42:47 +0000 (UTC)
commit 26970a1f4e5de34c8733cb6ed1d06afbd3c73d1b
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Nov 22 17:38:07 2013 +0100
use a menubar if the shell doesn't support the app menu
[bug #715020]
po/POTFILES.in | 1 +
src/app-menu.c | 36 +++++++++++++++++++++++++++++++
src/app-menu.h | 1 +
src/file-roller.gresource.xml | 1 +
src/fr-application.c | 16 +++++++++++++-
src/ui/Makefile.am | 1 +
src/ui/app-menubar.ui | 47 +++++++++++++++++++++++++++++++++++++++++
7 files changed, 102 insertions(+), 1 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 53941e1..076503c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -135,6 +135,7 @@ src/test-server.c
src/typedefs.h
[type: gettext/glade]src/ui/add-dialog-options.ui
[type: gettext/glade]src/ui/add-options.ui
+[type: gettext/glade]src/ui/app-menubar.ui
[type: gettext/glade]src/ui/app-menu.ui
[type: gettext/glade]src/ui/ask-password.ui
[type: gettext/glade]src/ui/delete.ui
diff --git a/src/app-menu.c b/src/app-menu.c
index 8a51e0e..98e062f 100644
--- a/src/app-menu.c
+++ b/src/app-menu.c
@@ -215,3 +215,39 @@ initialize_app_menu (GApplication *application)
G_CALLBACK (pref_list_mode_changed),
application);
}
+
+
+void
+initialize_app_menubar (GApplication *application)
+{
+ GtkBuilder *builder;
+ GSettings *settings;
+
+ g_action_map_add_action_entries (G_ACTION_MAP (application),
+ app_menu_entries,
+ G_N_ELEMENTS (app_menu_entries),
+ application);
+
+ builder = _gtk_builder_new_from_resource ("app-menubar.ui");
+ gtk_application_set_menubar (GTK_APPLICATION (application),
+ G_MENU_MODEL (gtk_builder_get_object (builder, "app-menubar")));
+ g_object_unref (builder);
+
+ settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI);
+ g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_FOLDERS),
+ g_variant_new_boolean (g_settings_get_boolean (settings,
PREF_UI_VIEW_FOLDERS)));
+
+ settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING);
+ g_simple_action_set_state (GET_ACTION (PREF_LISTING_LIST_MODE),
+ g_variant_new_string (_g_enum_type_get_value (FR_TYPE_WINDOW_LIST_MODE,
+ g_settings_get_enum (settings,
PREF_LISTING_LIST_MODE))->value_nick));
+
+ g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI),
+ "changed::" PREF_UI_VIEW_FOLDERS,
+ G_CALLBACK (pref_view_folders_changed),
+ application);
+ g_signal_connect (fr_application_get_settings (FR_APPLICATION (application),
FILE_ROLLER_SCHEMA_LISTING),
+ "changed::" PREF_LISTING_LIST_MODE,
+ G_CALLBACK (pref_list_mode_changed),
+ application);
+}
diff --git a/src/app-menu.h b/src/app-menu.h
index bad2be9..7edd8b5 100644
--- a/src/app-menu.h
+++ b/src/app-menu.h
@@ -27,5 +27,6 @@
#include <gio/gio.h>
void initialize_app_menu (GApplication *application);
+void initialize_app_menubar (GApplication *application);
#endif /* APP_MENU_H */
diff --git a/src/file-roller.gresource.xml b/src/file-roller.gresource.xml
index 2687fd8..080073d 100644
--- a/src/file-roller.gresource.xml
+++ b/src/file-roller.gresource.xml
@@ -4,6 +4,7 @@
<file compressed="true">ui/add-dialog-options.ui</file>
<file compressed="true">ui/add-options.ui</file>
<file compressed="true">ui/app-menu.ui</file>
+ <file compressed="true">ui/app-menubar.ui</file>
<file compressed="true">ui/ask-password.ui</file>
<file compressed="true">ui/delete.ui</file>
<file compressed="true">ui/error-dialog.ui</file>
diff --git a/src/fr-application.c b/src/fr-application.c
index 60ea595..5ea4652 100644
--- a/src/fr-application.c
+++ b/src/fr-application.c
@@ -548,11 +548,25 @@ fr_application_register_archive_manager_service (FrApplication *self)
static void
fr_application_startup (GApplication *application)
{
+ GtkSettings *gtk_settings;
+ gboolean show_app_menu;
+ gboolean show_menubar;
+
G_APPLICATION_CLASS (fr_application_parent_class)->startup (application);
fr_application_register_archive_manager_service (FR_APPLICATION (application));
initialize_data ();
- initialize_app_menu (application);
+
+ gtk_settings = gtk_settings_get_default ();
+ g_object_get (G_OBJECT (gtk_settings),
+ "gtk-shell-shows-app-menu", &show_app_menu,
+ "gtk-shell-shows-menubar", &show_menubar,
+ NULL);
+
+ if (show_menubar)
+ initialize_app_menubar (application);
+ else if (show_app_menu)
+ initialize_app_menu (application);
}
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index 910e88e..0e00637 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -2,6 +2,7 @@ EXTRA_DIST = \
add-dialog-options.ui \
add-options.ui \
app-menu.ui \
+ app-menubar.ui \
ask-password.ui \
delete.ui \
error-dialog.ui \
diff --git a/src/ui/app-menubar.ui b/src/ui/app-menubar.ui
new file mode 100644
index 0000000..041ab17
--- /dev/null
+++ b/src/ui/app-menubar.ui
@@ -0,0 +1,47 @@
+<interface>
+ <menu id="app-menubar">
+ <submenu>
+ <attribute name="label" translatable="yes">_File</attribute>
+ <item>
+ <attribute name="action">app.new</attribute>
+ <attribute name="label" translatable="yes">_New Archive</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ </item>
+ </submenu>
+ <submenu>
+ <attribute name="label" translatable="yes">_View</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">View All _Files</attribute>
+ <attribute name="action">app.list-mode</attribute>
+ <attribute name="target">flat</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">View as a F_older</attribute>
+ <attribute name="action">app.list-mode</attribute>
+ <attribute name="target">as-dir</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="action">app.view-folders</attribute>
+ <attribute name="label" translatable="yes">_Folders</attribute>
+ </item>
+ </section>
+ </submenu>
+ <submenu>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <item>
+ <attribute name="action">app.help</attribute>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.about</attribute>
+ <attribute name="label" translatable="yes">_About Archive Manager</attribute>
+ </item>
+ </submenu>
+ </menu>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]