作図ソフト dia の改良版
Revision | 21afdeaf027afe288fac157593683e01a71552c3 (tree) |
---|---|
Zeit | 2014-09-20 01:48:55 |
Autor | Hans Breuer <hans@breu...> |
Commiter | Hans Breuer |
[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.
@@ -910,35 +910,44 @@ app_set_icon (GtkWindow *window) | ||
910 | 910 | |
911 | 911 | #ifdef HAVE_MAC_INTEGRATION |
912 | 912 | static void |
913 | -_create_mac_integration (void) | |
913 | +_create_mac_integration (GtkWidget *menubar) | |
914 | 914 | { |
915 | 915 | GtkosxApplication *theOsxApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL); |
916 | - GtkWidget *menubar = NULL; | |
917 | 916 | |
918 | 917 | /* from control-x to command-x in one call? Does _not_ work as advertized */ |
919 | 918 | gtkosx_application_set_use_quartz_accelerators (theOsxApp, TRUE); |
920 | - /* might be too early ... */ | |
921 | - menus_get_integrated_ui_menubar (&menubar, NULL, NULL); | |
919 | + | |
922 | 920 | if (menubar) { |
923 | - gtk_widget_hide (menubar); /* not working, it's shown elsewhere */ | |
924 | - /* move some items to the dia menu */ | |
925 | - { | |
926 | - GSList *proxies, *proxy; | |
927 | - GtkAction *action; | |
928 | - | |
929 | - action = menus_get_action ("HelpAbout"); | |
930 | - proxies = gtk_action_get_proxies (action); | |
931 | - | |
932 | - for (proxy = proxies; proxy != NULL; proxy = g_slist_next (proxy)) { | |
933 | - g_print ("XXX "); | |
934 | - if (1 || GTK_IS_MENU_ITEM (proxy->data)) { | |
935 | - gtkosx_application_insert_app_menu_item (theOsxApp, GTK_WIDGET (proxy->data), 0); | |
936 | - break; | |
937 | - } | |
938 | - } | |
939 | - } | |
940 | 921 | /* hijack the menubar */ |
941 | 922 | gtkosx_application_set_menu_bar(theOsxApp, GTK_MENU_SHELL(menubar)); |
923 | + /* move some items to the dia menu - apparently must be _after_ hijack */ | |
924 | + { | |
925 | + GtkWidget *item; | |
926 | + | |
927 | + item = menus_get_widget (INTEGRATED_MENU "/Help/HelpAbout"); | |
928 | + if (GTK_IS_MENU_ITEM (item)) | |
929 | + gtkosx_application_insert_app_menu_item (theOsxApp, item, 0); | |
930 | + gtkosx_application_insert_app_menu_item (theOsxApp, gtk_separator_menu_item_new (), 1); | |
931 | + item = menus_get_widget (INTEGRATED_MENU "/File/FilePrefs"); | |
932 | + if (GTK_IS_MENU_ITEM (item)) | |
933 | + gtkosx_application_insert_app_menu_item (theOsxApp, item, 2); | |
934 | + item = menus_get_widget (INTEGRATED_MENU "/File/FilePlugins"); | |
935 | + if (GTK_IS_MENU_ITEM (item)) | |
936 | + gtkosx_application_insert_app_menu_item (theOsxApp, item, 3); | |
937 | +#if 0 /* not sure if we should move these, too */ | |
938 | + item = menus_get_widget (INTEGRATED_MENU "/File/FileTree"); | |
939 | + if (GTK_IS_MENU_ITEM (item)) | |
940 | + gtkosx_application_insert_app_menu_item (theOsxApp, item, 4); | |
941 | + item = menus_get_widget (INTEGRATED_MENU "/File/FileSheets"); | |
942 | + if (GTK_IS_MENU_ITEM (item)) | |
943 | + gtkosx_application_insert_app_menu_item (theOsxApp, item, 5); | |
944 | +#endif | |
945 | + /* remove Quit from File menu */ | |
946 | + item = menus_get_widget (INTEGRATED_MENU "/File/FileQuit"); | |
947 | + if (GTK_IS_MENU_ITEM (item)) | |
948 | + gtk_widget_hide (item); | |
949 | + } | |
950 | + gtk_widget_hide (menubar); /* not working, it's shown elsewhere */ | |
942 | 951 | /* setup the dock icon */ |
943 | 952 | gtkosx_application_set_dock_icon_pixbuf (theOsxApp, |
944 | 953 | gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL)); |
@@ -1034,14 +1043,14 @@ create_integrated_ui (void) | ||
1034 | 1043 | * uses the tool buttons*/ |
1035 | 1044 | menus_get_integrated_ui_menubar(&menubar, &toolbar, &accel_group); |
1036 | 1045 | gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); |
1046 | + gtk_widget_show (menubar); | |
1037 | 1047 | #ifdef HAVE_GNOME |
1038 | 1048 | gnome_app_set_menus (GNOME_APP (window), GTK_MENU_BAR (menubar)); |
1039 | 1049 | #else |
1040 | 1050 | # ifdef HAVE_MAC_INTEGRATION |
1041 | - _create_mac_integration (); | |
1051 | + _create_mac_integration (menubar); | |
1042 | 1052 | # else |
1043 | 1053 | gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0); |
1044 | - gtk_widget_show (menubar); | |
1045 | 1054 | # endif |
1046 | 1055 | #endif |
1047 | 1056 |
@@ -1119,14 +1128,14 @@ create_toolbox () | ||
1119 | 1128 | * uses the tool buttons*/ |
1120 | 1129 | menus_get_toolbox_menubar(&menubar, &accel_group); |
1121 | 1130 | gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); |
1131 | + gtk_widget_show (menubar); | |
1122 | 1132 | #ifdef HAVE_GNOME |
1123 | 1133 | gnome_app_set_menus(GNOME_APP(window), GTK_MENU_BAR(menubar)); |
1124 | 1134 | #else |
1125 | 1135 | # ifdef HAVE_MAC_INTEGRATION |
1126 | - _create_mac_integration (); | |
1136 | + _create_mac_integration (menubar); | |
1127 | 1137 | # else |
1128 | 1138 | gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0); |
1129 | - gtk_widget_show (menubar); | |
1130 | 1139 | # endif |
1131 | 1140 | #endif |
1132 | 1141 | persistence_register_window(GTK_WINDOW(window)); |
@@ -1045,7 +1045,7 @@ menus_get_integrated_ui_menubar (GtkWidget **menubar, | ||
1045 | 1045 | |
1046 | 1046 | /* maybe better to put this into toolbox_actions? */ |
1047 | 1047 | gtk_action_group_add_toggle_actions (display_actions, integrated_ui_view_toggle_entries, |
1048 | - G_N_ELEMENTS (integrated_ui_view_toggle_entries), NULL); | |
1048 | + G_N_ELEMENTS (integrated_ui_view_toggle_entries), NULL); | |
1049 | 1049 | |
1050 | 1050 | /* for stand-alone they are per display */ |
1051 | 1051 | gtk_ui_manager_insert_action_group (_ui_manager, display_actions, 0); |
@@ -1177,6 +1177,14 @@ menus_get_action (const gchar *name) | ||
1177 | 1177 | return action; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | +GtkWidget * | |
1181 | +menus_get_widget (const gchar *name) | |
1182 | +{ | |
1183 | + g_return_val_if_fail (_ui_manager != NULL, NULL); | |
1184 | + | |
1185 | + return gtk_ui_manager_get_widget (_ui_manager, name); | |
1186 | +} | |
1187 | + | |
1180 | 1188 | static int |
1181 | 1189 | cmp_action_names (const void *a, const void *b) |
1182 | 1190 | { |
@@ -48,6 +48,7 @@ GtkWidget * menus_create_display_menubar (GtkUIManager **ui_manager, Gtk | ||
48 | 48 | |
49 | 49 | GtkActionGroup *menus_get_tool_actions (void); |
50 | 50 | GtkAction * menus_get_action (const gchar *name); |
51 | +GtkWidget * menus_get_widget (const gchar *name); | |
51 | 52 | void menus_set_recent (GtkActionGroup *actions); |
52 | 53 | void menus_clear_recent (void); |
53 | 54 |