[dia] [gtk-osx] Improve top menu integration for App part
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [gtk-osx] Improve top menu integration for App part
- Date: Fri, 19 Sep 2014 17:03:56 +0000 (UTC)
commit 21afdeaf027afe288fac157593683e01a71552c3
Author: Hans Breuer <hans breuer org>
Date: Fri Sep 19 18:48:55 2014 +0200
[gtk-osx] Improve top menu integration for App part
Move some menu items to the MAC specific menu named 'dia'.
At least About and Preferences belong their, also hide the
File/Quit entry to avoid redundance.
For further application wide entries like 'Diagram Tree' and
'Sheets and Objects' the movement is prepared, but not done yet.
app/interface.c | 59 +++++++++++++++++++++++++++++++-----------------------
app/menus.c | 10 ++++++++-
app/menus.h | 1 +
3 files changed, 44 insertions(+), 26 deletions(-)
---
diff --git a/app/interface.c b/app/interface.c
index bf04e3b..26b2b04 100644
--- a/app/interface.c
+++ b/app/interface.c
@@ -910,35 +910,44 @@ app_set_icon (GtkWindow *window)
#ifdef HAVE_MAC_INTEGRATION
static void
-_create_mac_integration (void)
+_create_mac_integration (GtkWidget *menubar)
{
GtkosxApplication *theOsxApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
- GtkWidget *menubar = NULL;
/* from control-x to command-x in one call? Does _not_ work as advertized */
gtkosx_application_set_use_quartz_accelerators (theOsxApp, TRUE);
- /* might be too early ... */
- menus_get_integrated_ui_menubar (&menubar, NULL, NULL);
+
if (menubar) {
- gtk_widget_hide (menubar); /* not working, it's shown elsewhere */
- /* move some items to the dia menu */
- {
- GSList *proxies, *proxy;
- GtkAction *action;
-
- action = menus_get_action ("HelpAbout");
- proxies = gtk_action_get_proxies (action);
-
- for (proxy = proxies; proxy != NULL; proxy = g_slist_next (proxy)) {
- g_print ("XXX ");
- if (1 || GTK_IS_MENU_ITEM (proxy->data)) {
- gtkosx_application_insert_app_menu_item (theOsxApp, GTK_WIDGET (proxy->data), 0);
- break;
- }
- }
- }
/* hijack the menubar */
gtkosx_application_set_menu_bar(theOsxApp, GTK_MENU_SHELL(menubar));
+ /* move some items to the dia menu - apparently must be _after_ hijack */
+ {
+ GtkWidget *item;
+
+ item = menus_get_widget (INTEGRATED_MENU "/Help/HelpAbout");
+ if (GTK_IS_MENU_ITEM (item))
+ gtkosx_application_insert_app_menu_item (theOsxApp, item, 0);
+ gtkosx_application_insert_app_menu_item (theOsxApp, gtk_separator_menu_item_new (), 1);
+ item = menus_get_widget (INTEGRATED_MENU "/File/FilePrefs");
+ if (GTK_IS_MENU_ITEM (item))
+ gtkosx_application_insert_app_menu_item (theOsxApp, item, 2);
+ item = menus_get_widget (INTEGRATED_MENU "/File/FilePlugins");
+ if (GTK_IS_MENU_ITEM (item))
+ gtkosx_application_insert_app_menu_item (theOsxApp, item, 3);
+#if 0 /* not sure if we should move these, too */
+ item = menus_get_widget (INTEGRATED_MENU "/File/FileTree");
+ if (GTK_IS_MENU_ITEM (item))
+ gtkosx_application_insert_app_menu_item (theOsxApp, item, 4);
+ item = menus_get_widget (INTEGRATED_MENU "/File/FileSheets");
+ if (GTK_IS_MENU_ITEM (item))
+ gtkosx_application_insert_app_menu_item (theOsxApp, item, 5);
+#endif
+ /* remove Quit from File menu */
+ item = menus_get_widget (INTEGRATED_MENU "/File/FileQuit");
+ if (GTK_IS_MENU_ITEM (item))
+ gtk_widget_hide (item);
+ }
+ gtk_widget_hide (menubar); /* not working, it's shown elsewhere */
/* setup the dock icon */
gtkosx_application_set_dock_icon_pixbuf (theOsxApp,
gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL));
@@ -1034,14 +1043,14 @@ create_integrated_ui (void)
* uses the tool buttons*/
menus_get_integrated_ui_menubar(&menubar, &toolbar, &accel_group);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+ gtk_widget_show (menubar);
#ifdef HAVE_GNOME
gnome_app_set_menus (GNOME_APP (window), GTK_MENU_BAR (menubar));
#else
# ifdef HAVE_MAC_INTEGRATION
- _create_mac_integration ();
+ _create_mac_integration (menubar);
# else
gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
- gtk_widget_show (menubar);
# endif
#endif
@@ -1119,14 +1128,14 @@ create_toolbox ()
* uses the tool buttons*/
menus_get_toolbox_menubar(&menubar, &accel_group);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+ gtk_widget_show (menubar);
#ifdef HAVE_GNOME
gnome_app_set_menus(GNOME_APP(window), GTK_MENU_BAR(menubar));
#else
# ifdef HAVE_MAC_INTEGRATION
- _create_mac_integration ();
+ _create_mac_integration (menubar);
# else
gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
- gtk_widget_show (menubar);
# endif
#endif
persistence_register_window(GTK_WINDOW(window));
diff --git a/app/menus.c b/app/menus.c
index a7901e7..fc748dd 100644
--- a/app/menus.c
+++ b/app/menus.c
@@ -1045,7 +1045,7 @@ menus_get_integrated_ui_menubar (GtkWidget **menubar,
/* maybe better to put this into toolbox_actions? */
gtk_action_group_add_toggle_actions (display_actions, integrated_ui_view_toggle_entries,
- G_N_ELEMENTS (integrated_ui_view_toggle_entries), NULL);
+ G_N_ELEMENTS (integrated_ui_view_toggle_entries), NULL);
/* for stand-alone they are per display */
gtk_ui_manager_insert_action_group (_ui_manager, display_actions, 0);
@@ -1177,6 +1177,14 @@ menus_get_action (const gchar *name)
return action;
}
+GtkWidget *
+menus_get_widget (const gchar *name)
+{
+ g_return_val_if_fail (_ui_manager != NULL, NULL);
+
+ return gtk_ui_manager_get_widget (_ui_manager, name);
+}
+
static int
cmp_action_names (const void *a, const void *b)
{
diff --git a/app/menus.h b/app/menus.h
index 08e4b49..9ae3cb1 100644
--- a/app/menus.h
+++ b/app/menus.h
@@ -48,6 +48,7 @@ GtkWidget * menus_create_display_menubar (GtkUIManager **ui_manager, Gtk
GtkActionGroup *menus_get_tool_actions (void);
GtkAction * menus_get_action (const gchar *name);
+GtkWidget * menus_get_widget (const gchar *name);
void menus_set_recent (GtkActionGroup *actions);
void menus_clear_recent (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]