diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/Makefile.am | 1 | ||||
-rw-r--r-- | shell/e-shell-content.c | 8 | ||||
-rw-r--r-- | shell/e-shell-content.h | 3 | ||||
-rw-r--r-- | shell/e-shell-module.h | 3 | ||||
-rw-r--r-- | shell/e-shell-switcher.c | 2 | ||||
-rw-r--r-- | shell/e-shell-view.c | 133 | ||||
-rw-r--r-- | shell/e-shell-view.h | 40 | ||||
-rw-r--r-- | shell/e-shell-window-actions.c | 90 | ||||
-rw-r--r-- | shell/e-shell-window-private.c | 20 | ||||
-rw-r--r-- | shell/e-shell-window-private.h | 5 | ||||
-rw-r--r-- | shell/e-shell-window.c | 78 | ||||
-rw-r--r-- | shell/e-shell-window.h | 6 | ||||
-rw-r--r-- | shell/test/e-test-shell-view.c | 17 |
13 files changed, 195 insertions, 211 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am index f15661007e..16b560ce49 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -13,6 +13,7 @@ INCLUDES = \ -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ + -DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_HELPDIR=\""$(evolutionhelpdir)"\" \ -DEVOLUTION_MODULEDIR=\""$(moduledir)"\" \ diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c index 91aedf0d23..95cdc2d1cc 100644 --- a/shell/e-shell-content.c +++ b/shell/e-shell-content.c @@ -86,8 +86,8 @@ shell_content_entry_activated_cb (EShellContent *shell_content, shell_view = e_shell_content_get_shell_view (shell_content); shell_window = e_shell_view_get_shell_window (shell_view); - /* Verify the shell view is selected before proceeding. */ - if (!e_shell_view_is_selected (shell_view)) + /* Verify the shell view is active before proceeding. */ + if (!e_shell_view_is_active (shell_view)) return; action = E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE (shell_window); @@ -116,8 +116,8 @@ shell_content_entry_changed_cb (EShellContent *shell_content, shell_view = e_shell_content_get_shell_view (shell_content); shell_window = e_shell_view_get_shell_window (shell_view); - /* Verify the shell view is selected before proceeding. */ - if (!e_shell_view_is_selected (shell_view)) + /* Verify the shell view is active before proceeding. */ + if (!e_shell_view_is_active (shell_view)) return; action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window); diff --git a/shell/e-shell-content.h b/shell/e-shell-content.h index 3685a76639..6f4c83338a 100644 --- a/shell/e-shell-content.h +++ b/shell/e-shell-content.h @@ -113,6 +113,9 @@ void e_shell_content_set_scope_visible void e_shell_content_save_search_dialog (EShellContent *shell_content, const gchar *filename); +const gchar * e_shell_content_get_view_id (EShellContent *shell_content); +void e_shell_content_set_view_id (EShellContent *shell_content, + const gchar *view_id); G_END_DECLS diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h index 71fdc6b4e9..4e1a2cd181 100644 --- a/shell/e-shell-module.h +++ b/shell/e-shell-module.h @@ -58,8 +58,7 @@ typedef struct _EShellModulePrivate EShellModulePrivate; * the corresponding #EShellView subclass that the * module will register. * @aliases: Colon-separated list of aliases that can be used - * when referring to a module or view by name, such - * as in e_shell_window_set_current_view(). + * when referring to a module by name. * @schemes: Colon-separated list of URI schemes. The #EShell * will forward command-line URIs to the appropriate * module based on this list. diff --git a/shell/e-shell-switcher.c b/shell/e-shell-switcher.c index ae29900fb2..bcab54cf9f 100644 --- a/shell/e-shell-switcher.c +++ b/shell/e-shell-switcher.c @@ -20,6 +20,8 @@ #include "e-shell-switcher.h" +#include <glib/gi18n.h> + #define E_SHELL_SWITCHER_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_SHELL_SWITCHER, EShellSwitcherPrivate)) diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 15e658cd68..e40413f7f2 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -26,6 +26,7 @@ #include <e-shell-content.h> #include <e-shell-module.h> #include <e-shell-sidebar.h> +#include <e-shell-taskbar.h> #include <e-shell-window.h> #include <e-shell-window-actions.h> @@ -38,14 +39,13 @@ struct _EShellViewPrivate { gpointer shell_window; /* weak pointer */ gchar *title; + gchar *view_id; gint page_num; GtkAction *action; GtkWidget *shell_content; GtkWidget *shell_sidebar; GtkWidget *shell_taskbar; - - GalViewInstance *view_instance; }; enum { @@ -57,7 +57,7 @@ enum { PROP_SHELL_SIDEBAR, PROP_SHELL_TASKBAR, PROP_SHELL_WINDOW, - PROP_VIEW_INSTANCE + PROP_VIEW_ID }; enum { @@ -69,6 +69,42 @@ static gpointer parent_class; static gulong signals[LAST_SIGNAL]; static void +shell_view_init_view_collection (EShellViewClass *shell_view_class) +{ + EShellModule *shell_module; + const gchar *base_dir; + const gchar *module_name; + gchar *system_dir; + gchar *local_dir; + + shell_module = E_SHELL_MODULE (shell_view_class->type_module); + module_name = shell_view_class->type_module->name; + + base_dir = EVOLUTION_GALVIEWSDIR; + system_dir = g_build_filename (base_dir, module_name, NULL); + + base_dir = e_shell_module_get_data_dir (shell_module); + local_dir = g_build_filename (base_dir, "views", NULL); + + /* The view collection is never destroyed. */ + shell_view_class->view_collection = gal_view_collection_new (); + + gal_view_collection_set_title ( + shell_view_class->view_collection, + shell_view_class->label); + + gal_view_collection_set_storage_directories ( + shell_view_class->view_collection, + system_dir, local_dir); + + g_free (system_dir); + g_free (local_dir); + + /* This is all we can do. It's up to the subclasses to + * add the appropriate factories to the view collection. */ +} + +static void shell_view_set_action (EShellView *shell_view, GtkAction *action) { @@ -134,10 +170,10 @@ shell_view_set_property (GObject *object, g_value_get_object (value)); return; - case PROP_VIEW_INSTANCE: - e_shell_view_set_view_instance ( + case PROP_VIEW_ID: + e_shell_view_set_view_id ( E_SHELL_VIEW (object), - g_value_get_object (value)); + g_value_get_string (value)); return; } @@ -193,9 +229,9 @@ shell_view_get_property (GObject *object, E_SHELL_VIEW (object))); return; - case PROP_VIEW_INSTANCE: - g_value_set_object ( - value, e_shell_view_get_view_instance ( + case PROP_VIEW_ID: + g_value_set_string ( + value, e_shell_view_get_view_id ( E_SHELL_VIEW (object))); return; } @@ -231,11 +267,6 @@ shell_view_dispose (GObject *object) priv->shell_taskbar = NULL; } - if (priv->view_instance != NULL) { - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -248,6 +279,7 @@ shell_view_finalize (GObject *object) priv = E_SHELL_VIEW_GET_PRIVATE (object); g_free (priv->title); + g_free (priv->view_id); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); @@ -378,12 +410,12 @@ shell_view_class_init (EShellViewClass *class) g_object_class_install_property ( object_class, - PROP_VIEW_INSTANCE, - g_param_spec_object ( - "view-instance", - _("GAL View Instance"), - _("The GAL view instance for the shell view"), - GAL_VIEW_INSTANCE_TYPE, + PROP_VIEW_ID, + g_param_spec_string ( + "view-id", + _("Current View ID"), + _("The current view ID"), + NULL, G_PARAM_READWRITE)); signals[CHANGED] = g_signal_new ( @@ -397,9 +429,13 @@ shell_view_class_init (EShellViewClass *class) } static void -shell_view_init (EShellView *shell_view) +shell_view_init (EShellView *shell_view, + EShellViewClass *shell_view_class) { shell_view->priv = E_SHELL_VIEW_GET_PRIVATE (shell_view); + + if (shell_view_class->view_collection == NULL) + shell_view_init_view_collection (shell_view_class); } GType @@ -468,38 +504,36 @@ e_shell_view_set_title (EShellView *shell_view, if (title == NULL) title = E_SHELL_VIEW_GET_CLASS (shell_view)->label; + if (g_strcmp0 (shell_view->priv->title, title) == 0) + return; + g_free (shell_view->priv->title); shell_view->priv->title = g_strdup (title); g_object_notify (G_OBJECT (shell_view), "title"); } -GalViewInstance * -e_shell_view_get_view_instance (EShellView *shell_view) +const gchar * +e_shell_view_get_view_id (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return shell_view->priv->view_instance; + return shell_view->priv->view_id; } void -e_shell_view_set_view_instance (EShellView *shell_view, - GalViewInstance *instance) +e_shell_view_set_view_id (EShellView *shell_view, + const gchar *view_id) { g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - if (instance != NULL) - g_return_if_fail (GAL_IS_VIEW_INSTANCE (instance)); - - if (shell_view->priv->view_instance != NULL) { - g_object_unref (shell_view->priv->view_instance); - shell_view->priv->view_instance = NULL; - } + if (g_strcmp0 (shell_view->priv->view_id, view_id) == 0) + return; - if (instance != NULL) - shell_view->priv->view_instance = g_object_ref (instance); + g_free (shell_view->priv->view_id); + shell_view->priv->view_id = g_strdup (view_id); - g_object_notify (G_OBJECT (shell_view), "view-instance"); + g_object_notify (G_OBJECT (shell_view), "view-id"); } EShellWindow * @@ -511,22 +545,15 @@ e_shell_view_get_shell_window (EShellView *shell_view) } gboolean -e_shell_view_is_selected (EShellView *shell_view) +e_shell_view_is_active (EShellView *shell_view) { - EShellViewClass *class; - EShellWindow *shell_window; - const gchar *curr_view_name; - const gchar *this_view_name; + GtkAction *action; g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE); - class = E_SHELL_VIEW_GET_CLASS (shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - this_view_name = e_shell_view_get_name (shell_view); - curr_view_name = e_shell_window_get_current_view (shell_window); - g_return_val_if_fail (curr_view_name != NULL, FALSE); + action = e_shell_view_get_action (shell_view); - return (strcmp (curr_view_name, this_view_name) == 0); + return gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); } gint @@ -537,28 +564,28 @@ e_shell_view_get_page_num (EShellView *shell_view) return shell_view->priv->page_num; } -EShellContent * +gpointer e_shell_view_get_shell_content (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return E_SHELL_CONTENT (shell_view->priv->shell_content); + return shell_view->priv->shell_content; } -EShellSidebar * +gpointer e_shell_view_get_shell_sidebar (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return E_SHELL_SIDEBAR (shell_view->priv->shell_sidebar); + return shell_view->priv->shell_sidebar; } -EShellTaskbar * +gpointer e_shell_view_get_shell_taskbar (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return E_SHELL_TASKBAR (shell_view->priv->shell_taskbar); + return shell_view->priv->shell_taskbar; } void diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index a30abf5e6c..77c74a0cbc 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -1,6 +1,7 @@ -/* +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + * e-shell-view.h * - * This is only a CORBA wrapper around e_shell_window. + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -10,26 +11,21 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * General Public License for more details. * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. */ #ifndef E_SHELL_VIEW_H #define E_SHELL_VIEW_H #include <e-shell-common.h> -#include <e-shell-content.h> -#include <e-shell-sidebar.h> -#include <e-shell-taskbar.h> #include <e-shell-window.h> -#include <widgets/menus/gal-view-instance.h> +#include <widgets/menus/gal-view-collection.h> /* Standard GObject macros */ #define E_TYPE_SHELL_VIEW \ @@ -72,6 +68,9 @@ struct _EShellViewClass { * the GTypeInfo they pass to g_type_module_register_type(). */ GTypeModule *type_module; + /* A unique instance is created for each subclass. */ + GalViewCollection *view_collection; + /* Factory Methods */ GtkWidget * (*new_shell_content) (EShellView *shell_view); GtkWidget * (*new_shell_sidebar) (EShellView *shell_view); @@ -87,15 +86,14 @@ GtkAction * e_shell_view_get_action (EShellView *shell_view); const gchar * e_shell_view_get_title (EShellView *shell_view); void e_shell_view_set_title (EShellView *shell_view, const gchar *title); -GalViewInstance * - e_shell_view_get_view_instance (EShellView *shell_view); -void e_shell_view_set_view_instance (EShellView *shell_view, - GalViewInstance *instance); -gboolean e_shell_view_is_selected (EShellView *shell_view); +const gchar * e_shell_view_get_view_id (EShellView *shell_view); +void e_shell_view_set_view_id (EShellView *shell_view, + const gchar *view_id); +gboolean e_shell_view_is_active (EShellView *shell_view); gint e_shell_view_get_page_num (EShellView *shell_view); -EShellContent * e_shell_view_get_shell_content (EShellView *shell_view); -EShellSidebar * e_shell_view_get_shell_sidebar (EShellView *shell_view); -EShellTaskbar * e_shell_view_get_shell_taskbar (EShellView *shell_view); +gpointer e_shell_view_get_shell_content (EShellView *shell_view); +gpointer e_shell_view_get_shell_sidebar (EShellView *shell_view); +gpointer e_shell_view_get_shell_taskbar (EShellView *shell_view); EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view); void e_shell_view_changed (EShellView *shell_view); diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index 917c6fce3b..b13c6785b1 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -706,56 +706,36 @@ action_gal_define_views_cb (GtkAction *action, EShellWindow *shell_window) { EShellView *shell_view; - GalViewInstance *instance; + EShellViewClass *shell_view_class; + GalViewCollection *view_collection; GtkWidget *dialog; const gchar *view_name; - view_name = e_shell_window_get_current_view (shell_window); + view_name = e_shell_window_get_active_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); - instance = e_shell_view_get_view_instance (shell_view); - g_return_if_fail (instance != NULL); + shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); + view_collection = shell_view_class->view_collection; + g_return_if_fail (view_collection != NULL); - dialog = gal_define_views_dialog_new (instance->collection); + dialog = gal_define_views_dialog_new (view_collection); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - gal_view_collection_save (instance->collection); + gal_view_collection_save (view_collection); gtk_widget_destroy (dialog); } static void -action_gal_save_custom_view_cb (GtkAction *action, - EShellWindow *shell_window) -{ - EShellView *shell_view; - GalViewInstance *instance; - const gchar *view_name; - - view_name = e_shell_window_get_current_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); - instance = e_shell_view_get_view_instance (shell_view); - g_return_if_fail (instance != NULL); - - gal_view_instance_save_as (instance); -} - -static void action_gal_view_cb (GtkRadioAction *action, GtkRadioAction *current, EShellWindow *shell_window) { EShellView *shell_view; - GalViewInstance *instance; const gchar *view_name; const gchar *view_id; - view_name = e_shell_window_get_current_view (shell_window); + view_name = e_shell_window_get_active_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); - instance = e_shell_view_get_view_instance (shell_view); - g_return_if_fail (instance != NULL); - view_id = g_object_get_data (G_OBJECT (current), "view-id"); - g_return_if_fail (view_id != NULL); - - gal_view_instance_set_current_view_id (instance, view_id); + e_shell_view_set_view_id (shell_view, view_id); } static void @@ -869,7 +849,7 @@ action_search_clear_cb (GtkAction *action, EShellView *shell_view; const gchar *view_name; - view_name = e_shell_window_get_current_view (shell_window); + view_name = e_shell_window_get_active_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); shell_content = e_shell_view_get_shell_content (shell_view); e_shell_content_set_search_text (shell_content, ""); @@ -886,7 +866,7 @@ action_search_edit_cb (GtkAction *action, const gchar *filename; const gchar *view_name; - view_name = e_shell_window_get_current_view (shell_window); + view_name = e_shell_window_get_active_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); shell_content = e_shell_view_get_shell_content (shell_view); context = e_shell_content_get_search_context (shell_content); @@ -1380,7 +1360,7 @@ static GtkActionEntry shell_gal_view_entries[] = { N_("Save Custom View..."), NULL, N_("Save current custom view"), - G_CALLBACK (action_gal_save_custom_view_cb) }, + NULL }, /* Handled by subclasses. */ /*** Menus ***/ @@ -1436,7 +1416,7 @@ shell_window_extract_actions (EShellWindow *shell_window, * as belonging to the current EShellView and move them to the * destination list. */ - current_view = e_shell_window_get_current_view (shell_window); + current_view = e_shell_window_get_active_view (shell_window); /* Example: Suppose [A] and [C] are tagged for this EShellView. * @@ -1719,29 +1699,31 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window) } void -e_shell_window_update_gal_view_menu (EShellWindow *shell_window) +e_shell_window_update_view_menu (EShellWindow *shell_window) { EShellView *shell_view; + EShellViewClass *shell_view_class; GtkUIManager *ui_manager; GtkActionGroup *action_group; - GalViewInstance *instance; - GalViewCollection *collection; + GalViewCollection *view_collection; GtkRadioAction *radio_action; GtkAction *action; GList *list, *iter; GSList *radio_group; gboolean visible; - const gchar *view_name; const gchar *path; - gchar *gal_view_id; + const gchar *view_id; + const gchar *view_name; guint merge_id; gint count, ii; ui_manager = e_shell_window_get_ui_manager (shell_window); - view_name = e_shell_window_get_current_view (shell_window); + view_name = e_shell_window_get_active_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); - instance = e_shell_view_get_view_instance (shell_view); - g_debug ("GalViewInstance: %p", instance); + shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); + view_collection = shell_view_class->view_collection; + 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; merge_id = shell_window->priv->gal_view_merge_id; @@ -1752,25 +1734,13 @@ e_shell_window_update_gal_view_menu (EShellWindow *shell_window) /* XXX Annoying that GTK+ doesn't provide a function for this. * http://bugzilla.gnome.org/show_bug.cgi?id=550485 */ list = gtk_action_group_list_actions (action_group); - for (iter = list; iter != NULL; iter = iter->next) { - GtkAction *action = iter->data; - gtk_action_group_remove_action (action_group, action); - } + for (iter = list; iter != NULL; iter = iter->next) + gtk_action_group_remove_action (action_group, iter->data); g_list_free (list); - /* If there's no view instance then just hide the entire - * "Current View" menu and return. */ - action = ACTION (GAL_VIEW_MENU); - gtk_action_set_visible (action, instance != NULL); - if (instance == NULL) - return; - - /* We have a view instance, so forge ahead. */ - collection = instance->collection; - count = gal_view_collection_get_count (collection); + /* We have a view ID, so forge ahead. */ + count = gal_view_collection_get_count (view_collection); path = "/main-menu/view-menu/gal-view-menu/gal-view-list"; - gal_view_id = gal_view_instance_get_current_view_id (instance); - g_return_if_fail (gal_view_id != NULL); /* Default to "Custom View", unless we find our view ID. */ radio_action = GTK_RADIO_ACTION (ACTION (GAL_CUSTOM_VIEW)); @@ -1784,7 +1754,7 @@ e_shell_window_update_gal_view_menu (EShellWindow *shell_window) gchar *action_name; gchar *tooltip; - item = gal_view_collection_get_view_item (collection, ii); + item = gal_view_collection_get_view_item (view_collection, ii); action_name = g_strdup_printf ( "gal-view-%s-%d", view_name, ii); @@ -1800,7 +1770,7 @@ e_shell_window_update_gal_view_menu (EShellWindow *shell_window) G_OBJECT (radio_action), "view-id", g_strdup (item->id), (GDestroyNotify) g_free); - if (strcmp (item->id, gal_view_id) == 0) + if (view_id != NULL && strcmp (item->id, view_id) == 0) gtk_radio_action_set_current_value (radio_action, ii); action = GTK_ACTION (radio_action); diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 07b32a14f5..8ec551039f 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -193,6 +193,7 @@ e_shell_window_private_init (EShellWindow *shell_window) priv->new_source_actions = gtk_action_group_new ("new-source"); priv->switcher_actions = gtk_action_group_new ("switcher"); priv->loaded_views = loaded_views; + priv->active_view = "unknown"; merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager); priv->gal_view_merge_id = merge_id; @@ -323,7 +324,7 @@ e_shell_window_private_init (EShellWindow *shell_window) object = G_OBJECT (shell_window); key = "/apps/evolution/shell/view_defaults/component_id"; - gconf_bridge_bind_property (bridge, key, object, "current-view"); + gconf_bridge_bind_property (bridge, key, object, "active-view"); object = G_OBJECT (priv->content_pane); key = "/apps/evolution/shell/view_defaults/folder_bar/width"; @@ -414,13 +415,13 @@ e_shell_window_switch_to_view (EShellWindow *shell_window, notebook = GTK_NOTEBOOK (shell_window->priv->status_notebook); gtk_notebook_set_current_page (notebook, page_num); - shell_window->priv->current_view = view_name; - g_object_notify (G_OBJECT (shell_window), "current-view"); + shell_window->priv->active_view = view_name; + g_object_notify (G_OBJECT (shell_window), "active-view"); e_shell_window_update_icon (shell_window); e_shell_window_update_title (shell_window); e_shell_window_update_new_menu (shell_window); - e_shell_window_update_gal_view_menu (shell_window); + e_shell_window_update_view_menu (shell_window); /* Notify all loaded views. */ list = g_hash_table_get_values (shell_window->priv->loaded_views); @@ -436,12 +437,9 @@ e_shell_window_update_icon (EShellWindow *shell_window) const gchar *view_name; gchar *icon_name; - view_name = e_shell_window_get_current_view (shell_window); + view_name = e_shell_window_get_active_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); - if (!e_shell_view_is_selected (shell_view)) - return; - action = e_shell_view_get_action (shell_view); g_object_get (action, "icon-name", &icon_name, NULL); gtk_window_set_icon_name (GTK_WINDOW (shell_window), icon_name); @@ -456,13 +454,10 @@ e_shell_window_update_title (EShellWindow *shell_window) const gchar *view_name; gchar *window_title; - view_name = e_shell_window_get_current_view (shell_window); + view_name = e_shell_window_get_active_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); view_title = e_shell_view_get_title (shell_view); - if (!e_shell_view_is_selected (shell_view)) - return; - /* Translators: This is used for the main window title. */ window_title = g_strdup_printf (_("%s - Evolution"), view_title); gtk_window_set_title (GTK_WINDOW (shell_window), window_title); @@ -488,4 +483,3 @@ e_shell_window_update_new_menu (EShellWindow *shell_window) widget = shell_window->priv->menu_tool_button; gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (widget), menu); } - diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h index 7c04d87f6b..00eccaffbb 100644 --- a/shell/e-shell-window-private.h +++ b/shell/e-shell-window-private.h @@ -79,7 +79,7 @@ struct _EShellWindowPrivate { /*** Shell Views ***/ GHashTable *loaded_views; - const gchar *current_view; + const gchar *active_view; /*** Widgetry ***/ @@ -116,8 +116,7 @@ void e_shell_window_create_switcher_actions void e_shell_window_update_icon (EShellWindow *shell_window); void e_shell_window_update_title (EShellWindow *shell_window); void e_shell_window_update_new_menu (EShellWindow *shell_window); -void e_shell_window_update_gal_view_menu - (EShellWindow *shell_window); +void e_shell_window_update_view_menu (EShellWindow *shell_window); G_END_DECLS diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index d35ca0605a..96895908d8 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -29,7 +29,7 @@ enum { PROP_0, - PROP_CURRENT_VIEW, + PROP_ACTIVE_VIEW, PROP_SAFE_MODE, PROP_SHELL }; @@ -94,6 +94,10 @@ shell_window_new_view (EShellWindow *shell_window, shell_view, "notify::title", G_CALLBACK (e_shell_window_update_title), shell_window); + g_signal_connect_swapped ( + shell_view, "notify::view-id", + G_CALLBACK (e_shell_window_update_view_menu), shell_window); + return shell_view; } @@ -142,8 +146,8 @@ shell_window_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_CURRENT_VIEW: - e_shell_window_set_current_view ( + case PROP_ACTIVE_VIEW: + e_shell_window_set_active_view ( E_SHELL_WINDOW (object), g_value_get_string (value)); return; @@ -171,9 +175,9 @@ shell_window_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_CURRENT_VIEW: + case PROP_ACTIVE_VIEW: g_value_set_string ( - value, e_shell_window_get_current_view ( + value, e_shell_window_get_active_view ( E_SHELL_WINDOW (object))); return; @@ -226,17 +230,17 @@ shell_window_class_init (EShellWindowClass *class) object_class->finalize = shell_window_finalize; /** - * EShellWindow:current-view + * EShellWindow:active-view * - * Name of the currently active #EShellView. + * Name of the active #EShellView. **/ g_object_class_install_property ( object_class, - PROP_CURRENT_VIEW, + PROP_ACTIVE_VIEW, g_param_spec_string ( - "current-view", - _("Current Shell View"), - _("Name of the currently active shell view"), + "active-view", + _("Active Shell View"), + _("Name of the active shell view"), NULL, G_PARAM_READWRITE)); @@ -352,8 +356,8 @@ e_shell_window_new (EShell *shell, * will also instantiate the #EShellView the first time it's requested. * To reduce resource consumption, Evolution tries to delay instantiating * shell views until the user switches to them. So in general, only the - * currently active view name, as returned by - * e_shell_window_get_current_view(), should be requested. + * active view name, as returned by e_shell_window_get_active_view(), + * should be requested. * * Returns: the requested #EShellView, or %NULL if no such view is * registered @@ -546,65 +550,49 @@ e_shell_window_get_managed_widget (EShellWindow *shell_window, } /** - * e_shell_window_get_current_view: + * e_shell_window_get_active_view: * @shell_window: an #EShellWindow * - * Returns the name of the currently active #EShellView. + * Returns the name of the active #EShellView. * - * Returns: the name of the current view + * Returns: the name of the active view **/ const gchar * -e_shell_window_get_current_view (EShellWindow *shell_window) +e_shell_window_get_active_view (EShellWindow *shell_window) { g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL); - return shell_window->priv->current_view; + return shell_window->priv->active_view; } /** - * e_shell_window_set_current_view: + * e_shell_window_set_active_view: * @shell_window: an #EShellWindow - * @name_or_alias: the name of the shell view to switch to + * @view_name: the name of the shell view to switch to * - * Switches @shell_window to the #EShellView named (or with an alias of) - * @name_or_alias, causing the entire content of @shell_window to change. - * This is typically called as a result of the user clicking one of the - * switcher buttons. - * - * See #EShellModuleInfo for more information about shell view names and - * aliases. + * Switches @shell_window to the #EShellView named @view_name, causing + * the entire content of @shell_window to change. This is typically + * called as a result of the user clicking one of the switcher buttons. * * The name of the newly activated shell view is also written to GConf key * <filename>/apps/evolution/shell/view_defaults/component_id</filename>. - * This makes the current shell view persistent across Evolution sessions. + * This makes the active shell view persistent across Evolution sessions. * It also causes new shell windows created within the current Evolution * session to open to the most recently selected shell view. **/ void -e_shell_window_set_current_view (EShellWindow *shell_window, - const gchar *name_or_alias) +e_shell_window_set_active_view (EShellWindow *shell_window, + const gchar *view_name) { GtkAction *action; EShellView *shell_view; - EShell *shell; - GList *list; - const gchar *view_name; g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); - - view_name = name_or_alias; - shell = e_shell_window_get_shell (shell_window); - list = e_shell_list_modules (shell); - - if (view_name != NULL) - view_name = e_shell_get_canonical_name (shell, view_name); - - if (view_name == NULL && list != NULL) - view_name = G_TYPE_MODULE (list->data)->name; - g_return_if_fail (view_name != NULL); shell_view = e_shell_window_get_view (shell_window, view_name); + g_return_if_fail (shell_view != NULL); + action = e_shell_view_get_action (shell_view); gtk_action_activate (action); @@ -613,7 +601,7 @@ e_shell_window_set_current_view (EShellWindow *shell_window, * switch to the shell view whose corresponding radio action is * already active. Fortunately we can detect that and force * the switch. */ - if (shell_window->priv->current_view == NULL) + if (shell_window->priv->active_view == NULL) e_shell_window_switch_to_view (shell_window, view_name); } diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index 4044a49337..002c37914e 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -74,9 +74,9 @@ GtkActionGroup *e_shell_window_get_action_group (EShellWindow *shell_window, GtkWidget * e_shell_window_get_managed_widget (EShellWindow *shell_window, const gchar *widget_path); -const gchar * e_shell_window_get_current_view (EShellWindow *shell_window); -void e_shell_window_set_current_view (EShellWindow *shell_window, - const gchar *name_or_alias); +const gchar * e_shell_window_get_active_view (EShellWindow *shell_window); +void e_shell_window_set_active_view (EShellWindow *shell_window, + const gchar *view_name); gboolean e_shell_window_get_safe_mode (EShellWindow *shell_window); void e_shell_window_set_safe_mode (EShellWindow *shell_window, gboolean safe_mode); diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c index be2a747354..d9d627acbd 100644 --- a/shell/test/e-test-shell-view.c +++ b/shell/test/e-test-shell-view.c @@ -20,6 +20,9 @@ #include "e-test-shell-view.h" +#include <e-shell-content.h> +#include <e-shell-sidebar.h> + #define E_TEST_SHELL_VIEW_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellViewPrivate)) @@ -34,12 +37,12 @@ static gpointer parent_class; static void test_shell_view_changed (EShellView *shell_view) { - gboolean is_selected; - const gchar *selected; + gboolean is_active; + const gchar *active; - is_selected = e_shell_view_is_selected (shell_view); - selected = is_selected ? "selected" : "not selected"; - g_debug ("%s (%s)", G_STRFUNC, selected); + is_active = e_shell_view_is_active (shell_view); + active = is_active ? "active" : "inactive"; + g_debug ("%s (now %s)", G_STRFUNC, active); } static void @@ -54,8 +57,8 @@ test_shell_view_constructed (GObject *object) G_OBJECT_CLASS (parent_class)->constructed (object); shell_view = E_SHELL_VIEW (object); - shell_content = e_shell_view_get_content (shell_view); - shell_sidebar = e_shell_view_get_sidebar (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); widget = gtk_label_new ("Content Widget"); gtk_container_add (GTK_CONTAINER (shell_content), widget); |