diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-08-30 06:32:46 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-08-30 06:32:46 +0800 |
commit | e0c501b7018f12d37b10e32923f95b7a01c7982c (patch) | |
tree | 0114cbe9529000ec06dbe4ebe927e8c6cafbf0ba /shell/e-shell-view.c | |
parent | 02a9eb68308537fe712e757017ae4bb372863a8c (diff) | |
download | gsoc2013-evolution-e0c501b7018f12d37b10e32923f95b7a01c7982c.tar.gz gsoc2013-evolution-e0c501b7018f12d37b10e32923f95b7a01c7982c.tar.zst gsoc2013-evolution-e0c501b7018f12d37b10e32923f95b7a01c7982c.zip |
Progress update:
- Contacts module partially working!
- Implement UI merging. Also merge EInfoLabel into ESidebar.
The shell window now manages the icon and labels and keeps
them up-to-date via EShellView properties.
svn path=/branches/kill-bonobo/; revision=36214
Diffstat (limited to 'shell/e-shell-view.c')
-rw-r--r-- | shell/e-shell-view.c | 200 |
1 files changed, 200 insertions, 0 deletions
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index af2e9eeb0a..02d53e0696 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -31,6 +31,9 @@ ((obj), E_TYPE_SHELL_VIEW, EShellViewPrivate)) struct _EShellViewPrivate { + gchar *icon_name; + gchar *primary_text; + gchar *secondary_text; gchar *title; gint page_num; gpointer window; /* weak pointer */ @@ -38,12 +41,21 @@ struct _EShellViewPrivate { enum { PROP_0, + PROP_ICON_NAME, PROP_PAGE_NUM, + PROP_PRIMARY_TEXT, + PROP_SECONDARY_TEXT, PROP_TITLE, PROP_WINDOW }; +enum { + CHANGED, + LAST_SIGNAL +}; + static gpointer parent_class; +static gulong signals[LAST_SIGNAL]; static void shell_view_set_page_num (EShellView *shell_view, @@ -71,12 +83,30 @@ shell_view_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_ICON_NAME: + e_shell_view_set_icon_name ( + E_SHELL_VIEW (object), + g_value_get_string (value)); + return; + case PROP_PAGE_NUM: shell_view_set_page_num ( E_SHELL_VIEW (object), g_value_get_int (value)); return; + case PROP_PRIMARY_TEXT: + e_shell_view_set_primary_text ( + E_SHELL_VIEW (object), + g_value_get_string (value)); + return; + + case PROP_SECONDARY_TEXT: + e_shell_view_set_secondary_text ( + E_SHELL_VIEW (object), + g_value_get_string (value)); + return; + case PROP_TITLE: e_shell_view_set_title ( E_SHELL_VIEW (object), @@ -100,12 +130,30 @@ shell_view_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_ICON_NAME: + g_value_set_string ( + value, e_shell_view_get_icon_name ( + E_SHELL_VIEW (object))); + return; + case PROP_PAGE_NUM: g_value_set_int ( value, e_shell_view_get_page_num ( E_SHELL_VIEW (object))); return; + case PROP_PRIMARY_TEXT: + g_value_set_string ( + value, e_shell_view_get_primary_text ( + E_SHELL_VIEW (object))); + return; + + case PROP_SECONDARY_TEXT: + g_value_set_string ( + value, e_shell_view_get_secondary_text ( + E_SHELL_VIEW (object))); + return; + case PROP_TITLE: g_value_set_string ( value, e_shell_view_get_title ( @@ -146,6 +194,9 @@ shell_view_finalize (GObject *object) priv = E_SHELL_VIEW_GET_PRIVATE (object); + g_free (priv->icon_name); + g_free (priv->primary_text); + g_free (priv->secondary_text); g_free (priv->title); /* Chain up to parent's finalize() method. */ @@ -153,6 +204,16 @@ shell_view_finalize (GObject *object) } static void +shell_view_constructed (GObject *object) +{ + /* 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 */ +} + +static void shell_view_class_init (EShellViewClass *class) { GObjectClass *object_class; @@ -165,6 +226,18 @@ shell_view_class_init (EShellViewClass *class) object_class->get_property = shell_view_get_property; object_class->dispose = shell_view_dispose; object_class->finalize = shell_view_finalize; + object_class->constructed = shell_view_constructed; + + g_object_class_install_property ( + object_class, + PROP_ICON_NAME, + g_param_spec_string ( + "icon-name", + _("Icon Name"), + _("The icon name for the sidebar header"), + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); g_object_class_install_property ( object_class, @@ -181,6 +254,28 @@ shell_view_class_init (EShellViewClass *class) g_object_class_install_property ( object_class, + PROP_PRIMARY_TEXT, + g_param_spec_string ( + "primary-text", + _("Primary Text"), + _("The primary text for the sidebar header"), + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); + + g_object_class_install_property ( + object_class, + PROP_SECONDARY_TEXT, + g_param_spec_string ( + "secondary-text", + _("Secondary Text"), + _("The secondary text for the sidebar header"), + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); + + g_object_class_install_property ( + object_class, PROP_TITLE, g_param_spec_string ( "title", @@ -200,6 +295,16 @@ shell_view_class_init (EShellViewClass *class) GTK_TYPE_WINDOW, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + signals[CHANGED] = g_signal_new ( + "changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EShellViewClass, changed), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, + G_TYPE_BOOLEAN); } static void @@ -253,6 +358,83 @@ e_shell_view_get_name (EShellView *shell_view) } const gchar * +e_shell_view_get_icon_name (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return shell_view->priv->icon_name; +} + +void +e_shell_view_set_icon_name (EShellView *shell_view, + const gchar *icon_name) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + + if (icon_name == NULL) { + EShellViewClass *class; + + /* Fall back to the switcher icon. */ + class = E_SHELL_VIEW_GET_CLASS (shell_view); + icon_name = class->icon_name; + } + + g_free (shell_view->priv->icon_name); + shell_view->priv->icon_name = g_strdup (icon_name); + + g_object_notify (G_OBJECT (shell_view), "icon-name"); +} + +const gchar * +e_shell_view_get_primary_text (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return shell_view->priv->primary_text; +} + +void +e_shell_view_set_primary_text (EShellView *shell_view, + const gchar *primary_text) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + + if (primary_text == NULL) { + EShellViewClass *class; + + /* Fall back to the switcher label. */ + class = E_SHELL_VIEW_GET_CLASS (shell_view); + primary_text = class->label; + } + + g_free (shell_view->priv->primary_text); + shell_view->priv->primary_text = g_strdup (primary_text); + + g_object_notify (G_OBJECT (shell_view), "primary-text"); +} + +const gchar * +e_shell_view_get_secondary_text (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return shell_view->priv->secondary_text; +} + +void +e_shell_view_set_secondary_text (EShellView *shell_view, + const gchar *secondary_text) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + + g_free (shell_view->priv->secondary_text); + shell_view->priv->secondary_text = g_strdup (secondary_text); + g_debug ("%s: %s", G_STRFUNC, secondary_text); + + g_object_notify (G_OBJECT (shell_view), "secondary-text"); +} + +const gchar * e_shell_view_get_title (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); @@ -345,3 +527,21 @@ e_shell_view_get_status_widget (EShellView *shell_view) return class->get_status_widget (shell_view); } + +void +e_shell_view_changed (EShellView *shell_view) +{ + EShellWindow *shell_window; + EShellView *current_view; + const gchar *view_name; + gboolean visible; + + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + + shell_window = e_shell_view_get_window (shell_view); + view_name = e_shell_window_get_current_view (shell_window); + current_view = e_shell_window_get_view (shell_window, view_name); + visible = (current_view == shell_view); + + g_signal_emit (shell_view, signals[CHANGED], 0, visible); +} |