diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-09-13 12:02:09 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-09-13 12:02:09 +0800 |
commit | 7ee6ef65f1019389c172478a80b8f0aa73a1453e (patch) | |
tree | e50bcb96372f1fbbe5b53fc64b8200932ef7659d /shell | |
parent | df6a8262a141e0bec824149e7f65568d2187c5c2 (diff) | |
download | gsoc2013-evolution-7ee6ef65f1019389c172478a80b8f0aa73a1453e.tar gsoc2013-evolution-7ee6ef65f1019389c172478a80b8f0aa73a1453e.tar.gz gsoc2013-evolution-7ee6ef65f1019389c172478a80b8f0aa73a1453e.tar.bz2 gsoc2013-evolution-7ee6ef65f1019389c172478a80b8f0aa73a1453e.tar.lz gsoc2013-evolution-7ee6ef65f1019389c172478a80b8f0aa73a1453e.tar.xz gsoc2013-evolution-7ee6ef65f1019389c172478a80b8f0aa73a1453e.tar.zst gsoc2013-evolution-7ee6ef65f1019389c172478a80b8f0aa73a1453e.zip |
Allow EShellContent, EShellSidebar, and EShellTaskbar to be subclassed,
and begin doing so for Calendars, Memos and Tasks. Makes the code cleaner.
svn path=/branches/kill-bonobo/; revision=36317
Diffstat (limited to 'shell')
-rw-r--r-- | shell/e-shell-sidebar.c | 3 | ||||
-rw-r--r-- | shell/e-shell-sidebar.h | 5 | ||||
-rw-r--r-- | shell/e-shell-view.c | 122 | ||||
-rw-r--r-- | shell/e-shell-view.h | 13 | ||||
-rw-r--r-- | shell/e-shell-window-actions.c | 4 | ||||
-rw-r--r-- | shell/e-shell-window.c | 6 |
6 files changed, 105 insertions, 48 deletions
diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c index 13385d18b7..b67dc5b5e1 100644 --- a/shell/e-shell-sidebar.c +++ b/shell/e-shell-sidebar.c @@ -405,7 +405,8 @@ e_shell_sidebar_new (EShellView *shell_view) g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); return g_object_new ( - E_TYPE_SHELL_SIDEBAR, "shell-view", shell_view, NULL); + E_TYPE_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); } EShellView * diff --git a/shell/e-shell-sidebar.h b/shell/e-shell-sidebar.h index 498f48c7f4..a6a67a40cc 100644 --- a/shell/e-shell-sidebar.h +++ b/shell/e-shell-sidebar.h @@ -42,8 +42,6 @@ (G_TYPE_INSTANCE_GET_CLASS \ ((obj), E_TYPE_SHELL_SIDEBAR, EShellSidebarClass)) -#define E_SHELL_SIDEBAR_DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH_HORIZ - G_BEGIN_DECLS /* Avoid including <e-shell-view.h> */ @@ -66,9 +64,6 @@ GType e_shell_sidebar_get_type (void); GtkWidget * e_shell_sidebar_new (struct _EShellView *shell_view); struct _EShellView * e_shell_sidebar_get_shell_view (EShellSidebar *shell_sidebar); -const gchar * e_shell_sidebar_get_icon_name (EShellSidebar *shell_sidebar); -void e_shell_sidebar_set_icon_name (EShellSidebar *shell_sidebar, - const gchar *icon_name); const gchar * e_shell_sidebar_get_primary_text(EShellSidebar *shell_sidebar); void e_shell_sidebar_set_primary_text(EShellSidebar *shell_sidebar, const gchar *primary_text); diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 5d14834721..15e658cd68 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -41,9 +41,9 @@ struct _EShellViewPrivate { gint page_num; GtkAction *action; - GtkWidget *content; - GtkWidget *sidebar; - GtkWidget *taskbar; + GtkWidget *shell_content; + GtkWidget *shell_sidebar; + GtkWidget *shell_taskbar; GalViewInstance *view_instance; }; @@ -53,6 +53,9 @@ enum { PROP_ACTION, PROP_PAGE_NUM, PROP_TITLE, + PROP_SHELL_CONTENT, + PROP_SHELL_SIDEBAR, + PROP_SHELL_TASKBAR, PROP_SHELL_WINDOW, PROP_VIEW_INSTANCE }; @@ -166,6 +169,24 @@ shell_view_get_property (GObject *object, E_SHELL_VIEW (object))); return; + case PROP_SHELL_CONTENT: + g_value_set_object ( + value, e_shell_view_get_shell_content ( + E_SHELL_VIEW (object))); + return; + + case PROP_SHELL_SIDEBAR: + g_value_set_object ( + value, e_shell_view_get_shell_sidebar ( + E_SHELL_VIEW (object))); + return; + + case PROP_SHELL_TASKBAR: + g_value_set_object ( + value, e_shell_view_get_shell_taskbar ( + E_SHELL_VIEW (object))); + return; + case PROP_SHELL_WINDOW: g_value_set_object ( value, e_shell_view_get_shell_window ( @@ -195,19 +216,19 @@ shell_view_dispose (GObject *object) priv->shell_window = NULL; } - if (priv->content != NULL) { - g_object_unref (priv->content); - priv->content = NULL; + if (priv->shell_content != NULL) { + g_object_unref (priv->shell_content); + priv->shell_content = NULL; } - if (priv->sidebar != NULL) { - g_object_unref (priv->sidebar); - priv->sidebar = NULL; + if (priv->shell_sidebar != NULL) { + g_object_unref (priv->shell_sidebar); + priv->shell_sidebar = NULL; } - if (priv->taskbar != NULL) { - g_object_unref (priv->taskbar); - priv->taskbar = NULL; + if (priv->shell_taskbar != NULL) { + g_object_unref (priv->shell_taskbar); + priv->shell_taskbar = NULL; } if (priv->view_instance != NULL) { @@ -236,27 +257,25 @@ static void shell_view_constructed (GObject *object) { EShellView *shell_view; + EShellViewClass *class; GtkWidget *widget; shell_view = E_SHELL_VIEW (object); + class = E_SHELL_VIEW_GET_CLASS (object); - widget = e_shell_content_new (shell_view); - shell_view->priv->content = g_object_ref_sink (widget); - gtk_widget_show (widget); + /* Invoke factory methods. */ - widget = e_shell_sidebar_new (shell_view); - shell_view->priv->sidebar = g_object_ref_sink (widget); + widget = class->new_shell_content (shell_view); + shell_view->priv->shell_content = g_object_ref_sink (widget); gtk_widget_show (widget); - widget = e_shell_taskbar_new (shell_view); - shell_view->priv->taskbar = g_object_ref_sink (widget); + widget = class->new_shell_sidebar (shell_view); + shell_view->priv->shell_sidebar = g_object_ref_sink (widget); gtk_widget_show (widget); - /* XXX GObjectClass doesn't implement constructed(), so we will. - * Then subclasses won't have to check the function pointer - * before chaining up. - * - * http://bugzilla.gnome.org/show_bug?id=546593 */ + widget = class->new_shell_taskbar (shell_view); + shell_view->priv->shell_taskbar = g_object_ref_sink (widget); + gtk_widget_show (widget); } static void @@ -274,6 +293,11 @@ shell_view_class_init (EShellViewClass *class) object_class->finalize = shell_view_finalize; object_class->constructed = shell_view_constructed; + /* Default Factories */ + class->new_shell_content = e_shell_content_new; + class->new_shell_sidebar = e_shell_sidebar_new; + class->new_shell_taskbar = e_shell_taskbar_new; + g_object_class_install_property ( object_class, PROP_ACTION, @@ -310,6 +334,39 @@ shell_view_class_init (EShellViewClass *class) g_object_class_install_property ( object_class, + PROP_SHELL_CONTENT, + g_param_spec_object ( + "shell-content", + _("Shell Content Widget"), + _("The content widget appears in " + "a shell window's right pane"), + E_TYPE_SHELL_CONTENT, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, + PROP_SHELL_SIDEBAR, + g_param_spec_object ( + "shell-sidebar", + _("Shell Sidebar Widget"), + _("The sidebar widget appears in " + "a shell window's left pane"), + E_TYPE_SHELL_SIDEBAR, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, + PROP_SHELL_TASKBAR, + g_param_spec_object ( + "shell-taskbar", + _("Shell Taskbar Widget"), + _("The taskbar widget appears at " + "the bottom of a shell window"), + E_TYPE_SHELL_TASKBAR, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, PROP_SHELL_WINDOW, g_param_spec_object ( "shell-window", @@ -379,11 +436,10 @@ e_shell_view_get_name (EShellView *shell_view) g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - /* Switcher actions have a secret "view-name" data value. - * This gets set in e_shell_window_create_switcher_actions(). */ - action = e_shell_view_get_action (shell_view); + /* Switcher actions have a secret "view-name" data value. + * This gets set in e_shell_window_create_switcher_actions(). */ return g_object_get_data (G_OBJECT (action), "view-name"); } @@ -482,27 +538,27 @@ e_shell_view_get_page_num (EShellView *shell_view) } EShellContent * -e_shell_view_get_content (EShellView *shell_view) +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->content); + return E_SHELL_CONTENT (shell_view->priv->shell_content); } EShellSidebar * -e_shell_view_get_sidebar (EShellView *shell_view) +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->sidebar); + return E_SHELL_SIDEBAR (shell_view->priv->shell_sidebar); } EShellTaskbar * -e_shell_view_get_taskbar (EShellView *shell_view) +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->taskbar); + return E_SHELL_TASKBAR (shell_view->priv->shell_taskbar); } void diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 34f2625e22..a30abf5e6c 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -72,6 +72,11 @@ struct _EShellViewClass { * the GTypeInfo they pass to g_type_module_register_type(). */ GTypeModule *type_module; + /* Factory Methods */ + GtkWidget * (*new_shell_content) (EShellView *shell_view); + GtkWidget * (*new_shell_sidebar) (EShellView *shell_view); + GtkWidget * (*new_shell_taskbar) (EShellView *shell_view); + /* Signals */ void (*changed) (EShellView *shell_view); }; @@ -86,12 +91,12 @@ GalViewInstance * e_shell_view_get_view_instance (EShellView *shell_view); void e_shell_view_set_view_instance (EShellView *shell_view, GalViewInstance *instance); -EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view); gboolean e_shell_view_is_selected (EShellView *shell_view); gint e_shell_view_get_page_num (EShellView *shell_view); -EShellContent * e_shell_view_get_content (EShellView *shell_view); -EShellSidebar * e_shell_view_get_sidebar (EShellView *shell_view); -EShellTaskbar * e_shell_view_get_taskbar (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); +EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view); void e_shell_view_changed (EShellView *shell_view); G_END_DECLS diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index 090bee4025..917c6fce3b 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -871,7 +871,7 @@ action_search_clear_cb (GtkAction *action, view_name = e_shell_window_get_current_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); - shell_content = e_shell_view_get_content (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); e_shell_content_set_search_text (shell_content, ""); } @@ -888,7 +888,7 @@ action_search_edit_cb (GtkAction *action, view_name = e_shell_window_get_current_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); - shell_content = e_shell_view_get_content (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); context = e_shell_content_get_search_context (shell_content); g_return_if_fail (context != NULL); diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 78c6a31836..b1a7e4b6b1 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -73,15 +73,15 @@ shell_window_new_view (EShellWindow *shell_window, /* Add pages to the various shell window notebooks. */ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook); - widget = GTK_WIDGET (e_shell_view_get_content (shell_view)); + widget = GTK_WIDGET (e_shell_view_get_shell_content (shell_view)); gtk_notebook_append_page (notebook, widget, NULL); notebook = GTK_NOTEBOOK (shell_window->priv->sidebar_notebook); - widget = GTK_WIDGET (e_shell_view_get_sidebar (shell_view)); + widget = GTK_WIDGET (e_shell_view_get_shell_sidebar (shell_view)); gtk_notebook_append_page (notebook, widget, NULL); notebook = GTK_NOTEBOOK (shell_window->priv->status_notebook); - widget = GTK_WIDGET (e_shell_view_get_taskbar (shell_view)); + widget = GTK_WIDGET (e_shell_view_get_shell_taskbar (shell_view)); gtk_notebook_append_page (notebook, widget, NULL); /* Listen for changes that affect the shell window. */ |