diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2009-01-27 13:22:57 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2009-01-27 13:22:57 +0800 |
commit | 4b140a897f1b45515ac9987e0b2d343c12f02f1c (patch) | |
tree | f6059f221bc93189d894659a96324a80a4da1f00 /shell | |
parent | 98d262b594caefd053a2d075e2d8482b2d8a12c8 (diff) | |
download | gsoc2013-evolution-4b140a897f1b45515ac9987e0b2d343c12f02f1c.tar.gz gsoc2013-evolution-4b140a897f1b45515ac9987e0b2d343c12f02f1c.tar.zst gsoc2013-evolution-4b140a897f1b45515ac9987e0b2d343c12f02f1c.zip |
Make action group management in shell windows more elegant.
svn path=/branches/kill-bonobo/; revision=37137
Diffstat (limited to 'shell')
-rw-r--r-- | shell/e-shell-window-actions.c | 54 | ||||
-rw-r--r-- | shell/e-shell-window-actions.h | 2 | ||||
-rw-r--r-- | shell/e-shell-window-private.c | 33 | ||||
-rw-r--r-- | shell/e-shell-window-private.h | 9 | ||||
-rw-r--r-- | shell/e-shell-window.c | 33 | ||||
-rw-r--r-- | shell/e-shell-window.h | 2 | ||||
-rw-r--r-- | shell/e-shell.c | 12 |
7 files changed, 66 insertions, 79 deletions
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index f944d88eb6..50749a7698 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -1806,18 +1806,15 @@ e_shell_window_actions_init (EShellWindow *shell_window) { GtkActionGroup *action_group; GtkUIManager *ui_manager; - const gchar *domain; g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); ui_manager = e_shell_window_get_ui_manager (shell_window); - domain = GETTEXT_PACKAGE; e_load_ui_definition (ui_manager, "evolution-shell.ui"); /* Shell Actions */ - action_group = shell_window->priv->shell_actions; - gtk_action_group_set_translation_domain (action_group, domain); + action_group = ACTION_GROUP (SHELL); gtk_action_group_add_actions ( action_group, shell_entries, G_N_ELEMENTS (shell_entries), shell_window); @@ -1836,55 +1833,20 @@ e_shell_window_actions_init (EShellWindow *shell_window) action_group, shell_gal_view_radio_entries, G_N_ELEMENTS (shell_gal_view_radio_entries), 0, G_CALLBACK (action_gal_view_cb), shell_window); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - /* GAL View Actions (empty) */ - action_group = shell_window->priv->gal_view_actions; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - /* New Item Actions (empty) */ - action_group = shell_window->priv->new_item_actions; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - /* New Source Actions (empty) */ - action_group = shell_window->priv->new_source_actions; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - /* Custom Rule Actions (empty) */ - action_group = shell_window->priv->custom_rule_actions; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* Switcher Actions */ - action_group = shell_window->priv->switcher_actions; - gtk_action_group_set_translation_domain (action_group, domain); + action_group = ACTION_GROUP (SWITCHER); gtk_action_group_add_radio_actions ( action_group, shell_switcher_entries, G_N_ELEMENTS (shell_switcher_entries), -1, G_CALLBACK (action_switcher_cb), shell_window); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - /* Lockdown Printing Actions */ - action_group = shell_window->priv->lockdown_printing; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* Lockdown Print Setup Actions */ - action_group = shell_window->priv->lockdown_print_setup; - gtk_action_group_set_translation_domain (action_group, domain); + action_group = ACTION_GROUP (LOCKDOWN_PRINT_SETUP); gtk_action_group_add_actions ( action_group, shell_lockdown_print_setup_entries, G_N_ELEMENTS (shell_lockdown_print_setup_entries), shell_window); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - /* Lockdown Save-to-Disk Actions */ - action_group = shell_window->priv->lockdown_save_to_disk; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* Fine tuning. */ @@ -1903,13 +1865,13 @@ e_shell_window_create_new_menu (EShellWindow *shell_window) /* Get sorted lists of "new item" and "new source" actions. */ - action_group = shell_window->priv->new_item_actions; + action_group = ACTION_GROUP (NEW_ITEM); new_item_actions = g_list_sort ( gtk_action_group_list_actions (action_group), (GCompareFunc) e_action_compare_by_label); - action_group = shell_window->priv->new_source_actions; + action_group = ACTION_GROUP (NEW_SOURCE); new_source_actions = g_list_sort ( gtk_action_group_list_actions (action_group), @@ -1979,7 +1941,7 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window) g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); - action_group = shell_window->priv->switcher_actions; + action_group = ACTION_GROUP (SWITCHER); switcher = E_SHELL_SWITCHER (shell_window->priv->switcher); ui_manager = e_shell_window_get_ui_manager (shell_window); merge_id = gtk_ui_manager_new_merge_id (ui_manager); @@ -2106,7 +2068,7 @@ e_shell_window_update_view_menu (EShellWindow *shell_window) view_id = e_shell_view_get_view_id (shell_view); g_return_if_fail (view_collection != NULL); - action_group = shell_window->priv->gal_view_actions; + action_group = ACTION_GROUP (GAL_VIEW); merge_id = shell_window->priv->gal_view_merge_id; /* Unmerge the previous menu. */ @@ -2213,7 +2175,7 @@ e_shell_window_update_search_menu (EShellWindow *shell_window) /* Add custom rules to the Search menu. */ - action_group = shell_window->priv->custom_rule_actions; + action_group = ACTION_GROUP (CUSTOM_RULES); merge_id = shell_window->priv->custom_rule_merge_id; /* Unmerge the previous menu. */ diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h index ca7e783a86..87ae13221c 100644 --- a/shell/e-shell-window-actions.h +++ b/shell/e-shell-window-actions.h @@ -103,6 +103,8 @@ E_SHELL_WINDOW_ACTION_GROUP ((window), "custom-rules") #define E_SHELL_WINDOW_ACTION_GROUP_GAL_VIEW(window) \ E_SHELL_WINDOW_ACTION_GROUP ((window), "gal-view") +#define E_SHELL_WINDOW_ACTION_GROUP_LOCKDOWN_APPLICATION_HANDLERS(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "lockdown-application-handlers") #define E_SHELL_WINDOW_ACTION_GROUP_LOCKDOWN_PRINTING(window) \ E_SHELL_WINDOW_ACTION_GROUP ((window), "lockdown-printing") #define E_SHELL_WINDOW_ACTION_GROUP_LOCKDOWN_PRINT_SETUP(window) \ diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 2c2ebc5564..987c0ab9fb 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -189,22 +189,21 @@ e_shell_window_private_init (EShellWindow *shell_window) signal_handler_ids = g_array_new (FALSE, FALSE, sizeof (gulong)); priv->ui_manager = gtk_ui_manager_new (); - priv->shell_actions = gtk_action_group_new ("shell"); - priv->gal_view_actions = gtk_action_group_new ("gal-view"); - priv->new_item_actions = gtk_action_group_new ("new-item"); - priv->new_source_actions = gtk_action_group_new ("new-source"); - priv->custom_rule_actions = gtk_action_group_new ("custom-rules"); - priv->switcher_actions = gtk_action_group_new ("switcher"); - priv->lockdown_printing = - gtk_action_group_new ("lockdown-printing"); - priv->lockdown_print_setup = - gtk_action_group_new ("lockdown-print-setup"); - priv->lockdown_save_to_disk = - gtk_action_group_new ("lockdown-save-to-disk"); priv->loaded_views = loaded_views; priv->active_view = "unknown"; priv->signal_handler_ids = signal_handler_ids; + e_shell_window_add_action_group (shell_window, "shell"); + e_shell_window_add_action_group (shell_window, "gal-view"); + e_shell_window_add_action_group (shell_window, "new-item"); + e_shell_window_add_action_group (shell_window, "new-source"); + e_shell_window_add_action_group (shell_window, "custom-rules"); + e_shell_window_add_action_group (shell_window, "switcher"); + e_shell_window_add_action_group (shell_window, "lockdown-application-handlers"); + e_shell_window_add_action_group (shell_window, "lockdown-printing"); + e_shell_window_add_action_group (shell_window, "lockdown-print-setup"); + e_shell_window_add_action_group (shell_window, "lockdown-save-to-disk"); + merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager); priv->custom_rule_merge_id = merge_id; @@ -422,17 +421,7 @@ e_shell_window_private_dispose (EShellWindow *shell_window) } DISPOSE (priv->shell); - DISPOSE (priv->ui_manager); - DISPOSE (priv->shell_actions); - DISPOSE (priv->gal_view_actions); - DISPOSE (priv->new_item_actions); - DISPOSE (priv->new_source_actions); - DISPOSE (priv->custom_rule_actions); - DISPOSE (priv->switcher_actions); - DISPOSE (priv->lockdown_printing); - DISPOSE (priv->lockdown_print_setup); - DISPOSE (priv->lockdown_save_to_disk); g_hash_table_remove_all (priv->loaded_views); diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h index ff8e5afcb2..3d0d913863 100644 --- a/shell/e-shell-window-private.h +++ b/shell/e-shell-window-private.h @@ -70,15 +70,6 @@ struct _EShellWindowPrivate { /*** UI Management ***/ GtkUIManager *ui_manager; - GtkActionGroup *shell_actions; - GtkActionGroup *gal_view_actions; - GtkActionGroup *new_item_actions; - GtkActionGroup *new_source_actions; - GtkActionGroup *custom_rule_actions; - GtkActionGroup *switcher_actions; - GtkActionGroup *lockdown_printing; - GtkActionGroup *lockdown_print_setup; - GtkActionGroup *lockdown_save_to_disk; guint custom_rule_merge_id; guint gal_view_merge_id; diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 53074d2352..3272b524e7 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -754,6 +754,35 @@ e_shell_window_set_safe_mode (EShellWindow *shell_window, } /** + * e_shell_window_add_action_group: + * @shell_window: an #EShellWindow + * @group_name: the name of the new action group + * + * Creates a new #GtkActionGroup and adds it to @shell_window<!-- -->'s + * user interface manager. This also takes care of details like setting + * the translation domain. + **/ +void +e_shell_window_add_action_group (EShellWindow *shell_window, + const gchar *group_name) +{ + GtkActionGroup *action_group; + GtkUIManager *ui_manager; + const gchar *domain; + + g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); + g_return_if_fail (group_name != NULL); + + ui_manager = e_shell_window_get_ui_manager (shell_window); + domain = GETTEXT_PACKAGE; + + action_group = gtk_action_group_new (group_name); + gtk_action_group_set_translation_domain (action_group, domain); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + g_object_unref (action_group); +} + +/** * e_shell_window_register_new_item_actions: * @shell_window: an #EShellWindow * @module_name: name of an #EShellModule @@ -788,7 +817,7 @@ e_shell_window_register_new_item_actions (EShellWindow *shell_window, g_return_if_fail (module_name != NULL); g_return_if_fail (entries != NULL); - action_group = shell_window->priv->new_item_actions; + action_group = ACTION_GROUP (NEW_ITEM); ui_manager = e_shell_window_get_ui_manager (shell_window); accel_group = gtk_ui_manager_get_accel_group (ui_manager); module_name = g_intern_string (module_name); @@ -877,7 +906,7 @@ e_shell_window_register_new_source_actions (EShellWindow *shell_window, g_return_if_fail (module_name != NULL); g_return_if_fail (entries != NULL); - action_group = shell_window->priv->new_source_actions; + action_group = ACTION_GROUP (NEW_SOURCE); ui_manager = e_shell_window_get_ui_manager (shell_window); accel_group = gtk_ui_manager_get_accel_group (ui_manager); module_name = g_intern_string (module_name); diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index 7543413a5c..f9cdb60cf4 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -97,6 +97,8 @@ void e_shell_window_set_active_view (EShellWindow *shell_window, gboolean e_shell_window_get_safe_mode (EShellWindow *shell_window); void e_shell_window_set_safe_mode (EShellWindow *shell_window, gboolean safe_mode); +void e_shell_window_add_action_group (EShellWindow *shell_window, + const gchar *group_name); /* These should be called from the shell module's window_created() handler. */ diff --git a/shell/e-shell.c b/shell/e-shell.c index a2ac783cb8..02c9627448 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -689,6 +689,14 @@ shell_class_init (EShellClass *class) e_shell_settings_install_property ( g_param_spec_boolean ( + "disable-application-handlers", + NULL, + NULL, + FALSE, + G_PARAM_READWRITE)); + + e_shell_settings_install_property ( + g_param_spec_boolean ( "disable-command-line", NULL, NULL, @@ -749,6 +757,10 @@ shell_init (EShell *shell) G_CALLBACK (shell_notify_online_mode_cb), NULL); e_shell_settings_bind_to_gconf ( + shell->priv->settings, "disable-application-handlers", + "/desktop/gnome/lockdown/disable_application_handlers"); + + e_shell_settings_bind_to_gconf ( shell->priv->settings, "disable-command-line", "/desktop/gnome/lockdown/disable_command_line"); |