aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-view.c200
-rw-r--r--shell/e-shell-view.h15
-rw-r--r--shell/e-shell-window.c74
-rw-r--r--shell/e-sidebar.c301
-rw-r--r--shell/e-sidebar.h9
-rw-r--r--shell/test/e-test-shell-view.c8
6 files changed, 585 insertions, 22 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);
+}
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 0c98e32eb4..b474c0aa36 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -68,10 +68,24 @@ struct _EShellViewClass {
GtkWidget * (*get_content_widget) (EShellView *shell_view);
GtkWidget * (*get_sidebar_widget) (EShellView *shell_view);
GtkWidget * (*get_status_widget) (EShellView *shell_view);
+
+ /* Signals */
+
+ void (*changed) (EShellView *shell_view,
+ gboolean visible);
};
GType e_shell_view_get_type (void);
const gchar * e_shell_view_get_name (EShellView *shell_view);
+const gchar * e_shell_view_get_icon_name (EShellView *shell_view);
+void e_shell_view_set_icon_name (EShellView *shell_view,
+ const gchar *icon_name);
+const gchar * e_shell_view_get_primary_text (EShellView *shell_view);
+void e_shell_view_set_primary_text (EShellView *shell_view,
+ const gchar *primary_text);
+const gchar * e_shell_view_get_secondary_text (EShellView *shell_view);
+void e_shell_view_set_secondary_text (EShellView *shell_view,
+ const gchar *secondary_text);
const gchar * e_shell_view_get_title (EShellView *shell_view);
void e_shell_view_set_title (EShellView *shell_view,
const gchar *title);
@@ -81,6 +95,7 @@ gint e_shell_view_get_page_num (EShellView *shell_view);
GtkWidget * e_shell_view_get_content_widget (EShellView *shell_view);
GtkWidget * e_shell_view_get_sidebar_widget (EShellView *shell_view);
GtkWidget * e_shell_view_get_status_widget (EShellView *shell_view);
+void e_shell_view_changed (EShellView *shell_view);
G_END_DECLS
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 063b0ff8e8..312307c2f7 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -41,6 +41,31 @@ enum {
static gpointer parent_class;
+static void
+shell_window_update_sidebar (EShellWindow *shell_window)
+{
+ ESidebar *sidebar;
+ EShellView *shell_view;
+ const gchar *view_name;
+ const gchar *icon_name;
+ const gchar *primary_text;
+ const gchar *secondary_text;
+
+ sidebar = E_SIDEBAR (shell_window->priv->sidebar);
+ view_name = e_shell_window_get_current_view (shell_window);
+ shell_view = e_shell_window_get_view (shell_window, view_name);
+
+ /* Update the sidebar header. */
+
+ icon_name = e_shell_view_get_icon_name (shell_view);
+ primary_text = e_shell_view_get_primary_text (shell_view);
+ secondary_text = e_shell_view_get_secondary_text (shell_view);
+
+ e_sidebar_set_icon_name (sidebar, icon_name);
+ e_sidebar_set_primary_text (sidebar, primary_text);
+ e_sidebar_set_secondary_text (sidebar, secondary_text);
+}
+
static EShellView *
shell_window_new_view (EShellWindow *shell_window,
GType shell_view_type,
@@ -51,6 +76,7 @@ shell_window_new_view (EShellWindow *shell_window,
GtkNotebook *notebook;
GtkWidget *widget;
const gchar *name;
+ gulong handler_id;
gint page_num;
/* Determine the page number for the new shell view. */
@@ -79,6 +105,13 @@ shell_window_new_view (EShellWindow *shell_window,
widget = e_shell_view_get_status_widget (shell_view);
gtk_notebook_append_page (notebook, widget, NULL);
+ handler_id = g_signal_connect_swapped (
+ shell_view, "notify",
+ G_CALLBACK (shell_window_update_sidebar), shell_window);
+
+ /* This will be unblocked when the shell view is selected. */
+ g_signal_handler_block (shell_view, handler_id);
+
return shell_view;
}
@@ -327,8 +360,6 @@ e_shell_window_get_view (EShellWindow *shell_window,
continue;
}
- g_debug ("Comparing %s to %s (%s)", view_name, class->type_module->name, g_type_name (shell_view_type));
-
if (strcmp (view_name, class->type_module->name) == 0)
shell_view = shell_window_new_view (
shell_window, shell_view_type, class->label);
@@ -444,23 +475,31 @@ e_shell_window_set_current_view (EShellWindow *shell_window,
{
GtkNotebook *notebook;
EShellView *shell_view;
- const gchar *current_view;
+ GList *list;
+ const gchar *view_name;
gint page_num;
g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
- current_view = name_or_alias;
+ if (shell_window->priv->current_view != NULL) {
+ view_name = e_shell_window_get_current_view (shell_window);
+ shell_view = e_shell_window_get_view (shell_window, view_name);
+
+ g_signal_handlers_block_by_func (
+ shell_view, shell_window_update_sidebar, shell_window);
+ }
+
+ view_name = name_or_alias;
- if (current_view != NULL)
- current_view =
- e_shell_registry_get_canonical_name (current_view);
+ if (view_name != NULL)
+ view_name = e_shell_registry_get_canonical_name (view_name);
- if (current_view == NULL)
- current_view = shell_window->priv->default_view;
+ if (view_name == NULL)
+ view_name = shell_window->priv->default_view;
- g_return_if_fail (current_view != NULL);
+ g_return_if_fail (view_name != NULL);
- shell_view = e_shell_window_get_view (shell_window, current_view);
+ shell_view = e_shell_window_get_view (shell_window, view_name);
page_num = e_shell_view_get_page_num (shell_view);
g_return_if_fail (page_num >= 0);
@@ -473,9 +512,18 @@ e_shell_window_set_current_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 = current_view;
-
+ shell_window->priv->current_view = view_name;
g_object_notify (G_OBJECT (shell_window), "current-view");
+
+ g_signal_handlers_unblock_by_func (
+ shell_view, shell_window_update_sidebar, shell_window);
+
+ shell_window_update_sidebar (shell_window);
+
+ /* Notify all loaded views. */
+ list = g_hash_table_get_values (shell_window->priv->loaded_views);
+ g_list_foreach (list, (GFunc) e_shell_view_changed, NULL);
+ g_list_free (list);
}
gboolean
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c
index 6c773a76de..977196187e 100644
--- a/shell/e-sidebar.c
+++ b/shell/e-sidebar.c
@@ -28,6 +28,16 @@
#define V_PADDING 6
struct _ESidebarPrivate {
+
+ /* Header */
+ GtkWidget *event_box;
+ GtkWidget *image;
+ GtkWidget *primary_label;
+ GtkWidget *secondary_label;
+ gchar *primary_text;
+ gchar *secondary_text;
+
+ /* Switcher */
GList *proxies;
gboolean actions_visible;
gboolean style_set;
@@ -39,6 +49,9 @@ struct _ESidebarPrivate {
enum {
PROP_0,
PROP_ACTIONS_VISIBLE,
+ PROP_ICON_NAME,
+ PROP_PRIMARY_TEXT,
+ PROP_SECONDARY_TEXT,
PROP_TOOLBAR_STYLE
};
@@ -63,7 +76,6 @@ sidebar_layout_actions (ESidebar *sidebar)
int x, y;
int i;
- /*y = allocation->y + allocation->height - V_PADDING - 1;*/
y = allocation->y + allocation->height - 1;
if (num_btns == 0)
@@ -172,6 +184,24 @@ sidebar_set_property (GObject *object,
g_value_get_boolean (value));
return;
+ case PROP_ICON_NAME:
+ e_sidebar_set_icon_name (
+ E_SIDEBAR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_PRIMARY_TEXT:
+ e_sidebar_set_primary_text (
+ E_SIDEBAR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SECONDARY_TEXT:
+ e_sidebar_set_secondary_text (
+ E_SIDEBAR (object),
+ g_value_get_string (value));
+ return;
+
case PROP_TOOLBAR_STYLE:
e_sidebar_set_style (
E_SIDEBAR (object),
@@ -195,6 +225,24 @@ sidebar_get_property (GObject *object,
E_SIDEBAR (object)));
return;
+ case PROP_ICON_NAME:
+ g_value_set_string (
+ value, e_sidebar_get_icon_name (
+ E_SIDEBAR (object)));
+ return;
+
+ case PROP_PRIMARY_TEXT:
+ g_value_set_string (
+ value, e_sidebar_get_primary_text (
+ E_SIDEBAR (object)));
+ return;
+
+ case PROP_SECONDARY_TEXT:
+ g_value_set_string (
+ value, e_sidebar_get_secondary_text (
+ E_SIDEBAR (object)));
+ return;
+
case PROP_TOOLBAR_STYLE:
g_value_set_enum (
value, e_sidebar_get_style (
@@ -208,7 +256,29 @@ sidebar_get_property (GObject *object,
static void
sidebar_dispose (GObject *object)
{
- ESidebarPrivate *priv = E_SIDEBAR (object)->priv;
+ ESidebarPrivate *priv;
+
+ priv = E_SIDEBAR_GET_PRIVATE (object);
+
+ if (priv->event_box != NULL) {
+ g_object_unref (priv->event_box);
+ priv->event_box = NULL;
+ }
+
+ if (priv->image != NULL) {
+ g_object_unref (priv->image);
+ priv->image = NULL;
+ }
+
+ if (priv->primary_label != NULL) {
+ g_object_unref (priv->primary_label);
+ priv->image = NULL;
+ }
+
+ if (priv->secondary_label != NULL) {
+ g_object_unref (priv->secondary_label);
+ priv->secondary_label = NULL;
+ }
while (priv->proxies != NULL) {
GtkWidget *widget = priv->proxies->data;
@@ -220,10 +290,25 @@ sidebar_dispose (GObject *object)
}
static void
+sidebar_finalize (GObject *object)
+{
+ ESidebarPrivate *priv;
+
+ priv = E_SIDEBAR_GET_PRIVATE (object);
+
+ g_free (priv->primary_text);
+ g_free (priv->secondary_text);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
sidebar_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
ESidebarPrivate *priv;
+ GtkRequisition child_requisition;
GtkWidget *child;
GList *iter;
@@ -237,6 +322,11 @@ sidebar_size_request (GtkWidget *widget,
gtk_widget_size_request (child, requisition);
}
+ child = priv->event_box;
+ gtk_widget_size_request (child, &child_requisition);
+ requisition->width = MAX (requisition->width, child_requisition.width);
+ requisition->height += child_requisition.height;
+
if (!priv->actions_visible)
return;
@@ -260,6 +350,8 @@ sidebar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
ESidebarPrivate *priv;
+ GtkAllocation child_allocation;
+ GtkRequisition child_requisition;
GtkWidget *child;
gint y;
@@ -267,6 +359,18 @@ sidebar_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
+ child = priv->event_box;
+ gtk_widget_size_request (child, &child_requisition);
+
+ child_allocation.x = allocation->x;
+ child_allocation.y = allocation->y;
+ child_allocation.width = allocation->width;
+ child_allocation.height = child_requisition.height;
+
+ gtk_widget_size_allocate (child, &child_allocation);
+
+ allocation->y += child_requisition.height;
+
if (priv->actions_visible)
y = sidebar_layout_actions (E_SIDEBAR (widget));
else
@@ -275,8 +379,6 @@ sidebar_size_allocate (GtkWidget *widget,
child = gtk_bin_get_child (GTK_BIN (widget));
if (child != NULL) {
- GtkAllocation child_allocation;
-
child_allocation.x = allocation->x;
child_allocation.y = allocation->y;
child_allocation.width = allocation->width;
@@ -330,6 +432,13 @@ sidebar_remove (GtkContainer *container,
priv = E_SIDEBAR_GET_PRIVATE (container);
/* Look in the internal widgets first. */
+
+ if (widget == priv->event_box) {
+ gtk_widget_unparent (priv->event_box);
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+ return;
+ }
+
link = g_list_find (priv->proxies, widget);
if (link != NULL) {
GtkWidget *widget = link->data;
@@ -354,9 +463,11 @@ sidebar_forall (GtkContainer *container,
priv = E_SIDEBAR_GET_PRIVATE (container);
- if (include_internals)
+ if (include_internals) {
+ callback (priv->event_box, callback_data);
g_list_foreach (
priv->proxies, (GFunc) callback, callback_data);
+ }
/* Chain up to parent's forall() method. */
GTK_CONTAINER_CLASS (parent_class)->forall (
@@ -418,6 +529,7 @@ sidebar_class_init (ESidebarClass *class)
object_class->set_property = sidebar_set_property;
object_class->get_property = sidebar_get_property;
object_class->dispose = sidebar_dispose;
+ object_class->finalize = sidebar_finalize;
widget_class = GTK_WIDGET_CLASS (class);
widget_class->size_request = sidebar_size_request;
@@ -438,8 +550,41 @@ sidebar_class_init (ESidebarClass *class)
NULL,
NULL,
TRUE,
- G_PARAM_CONSTRUCT |
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_ICON_NAME,
+ g_param_spec_string (
+ "icon-name",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_PRIMARY_TEXT,
+ g_param_spec_string (
+ "primary-text",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SECONDARY_TEXT,
+ g_param_spec_string (
+ "secondary-text",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
g_object_class_install_property (
object_class,
@@ -450,8 +595,8 @@ sidebar_class_init (ESidebarClass *class)
NULL,
GTK_TYPE_TOOLBAR_STYLE,
E_SIDEBAR_DEFAULT_TOOLBAR_STYLE,
- G_PARAM_CONSTRUCT |
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
signals[STYLE_CHANGED] = g_signal_new (
"style-changed",
@@ -467,9 +612,51 @@ sidebar_class_init (ESidebarClass *class)
static void
sidebar_init (ESidebar *sidebar)
{
+ GtkStyle *style;
+ GtkWidget *container;
+ GtkWidget *widget;
+ const GdkColor *color;
+
sidebar->priv = E_SIDEBAR_GET_PRIVATE (sidebar);
GTK_WIDGET_SET_FLAGS (sidebar, GTK_NO_WINDOW);
+
+ widget = gtk_event_box_new ();
+ style = gtk_widget_get_style (widget);
+ color = &style->bg[GTK_STATE_ACTIVE];
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 1);
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color);
+ gtk_widget_set_parent (widget, GTK_WIDGET (sidebar));
+ sidebar->priv->event_box = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = gtk_hbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ sidebar->priv->image = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ sidebar->priv->primary_label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_MIDDLE);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ sidebar->priv->secondary_label = g_object_ref (widget);
+ gtk_widget_show (widget);
}
static void
@@ -570,6 +757,102 @@ e_sidebar_set_actions_visible (ESidebar *sidebar,
g_object_notify (G_OBJECT (sidebar), "actions-visible");
}
+const gchar *
+e_sidebar_get_icon_name (ESidebar *sidebar)
+{
+ GtkImage *image;
+ const gchar *icon_name;
+
+ g_return_val_if_fail (E_IS_SIDEBAR (sidebar), NULL);
+
+ image = GTK_IMAGE (sidebar->priv->image);
+ gtk_image_get_icon_name (image, &icon_name, NULL);
+
+ return icon_name;
+}
+
+void
+e_sidebar_set_icon_name (ESidebar *sidebar,
+ const gchar *icon_name)
+{
+ GtkImage *image;
+
+ g_return_if_fail (E_IS_SIDEBAR (sidebar));
+
+ if (icon_name == NULL)
+ icon_name = "image-missing";
+
+ image = GTK_IMAGE (sidebar->priv->image);
+ gtk_image_set_from_icon_name (image, icon_name, GTK_ICON_SIZE_MENU);
+
+ gtk_widget_queue_resize (GTK_WIDGET (sidebar));
+ g_object_notify (G_OBJECT (sidebar), "icon-name");
+}
+
+const gchar *
+e_sidebar_get_primary_text (ESidebar *sidebar)
+{
+ g_return_val_if_fail (E_IS_SIDEBAR (sidebar), NULL);
+
+ return sidebar->priv->primary_text;
+}
+
+void
+e_sidebar_set_primary_text (ESidebar *sidebar,
+ const gchar *primary_text)
+{
+ GtkLabel *label;
+ gchar *markup;
+
+ g_return_if_fail (E_IS_SIDEBAR (sidebar));
+
+ g_free (sidebar->priv->primary_text);
+ sidebar->priv->primary_text = g_strdup (primary_text);
+
+ if (primary_text == NULL)
+ primary_text = "";
+
+ label = GTK_LABEL (sidebar->priv->primary_label);
+ markup = g_markup_printf_escaped ("<b>%s</b>", primary_text);
+ gtk_label_set_markup (label, markup);
+ g_free (markup);
+
+ gtk_widget_queue_resize (GTK_WIDGET (sidebar));
+ g_object_notify (G_OBJECT (sidebar), "primary-text");
+}
+
+const gchar *
+e_sidebar_get_secondary_text (ESidebar *sidebar)
+{
+ g_return_val_if_fail (E_IS_SIDEBAR (sidebar), NULL);
+
+ return sidebar->priv->secondary_text;
+}
+
+void
+e_sidebar_set_secondary_text (ESidebar *sidebar,
+ const gchar *secondary_text)
+{
+ GtkLabel *label;
+ gchar *markup;
+
+ g_return_if_fail (E_IS_SIDEBAR (sidebar));
+
+ g_free (sidebar->priv->secondary_text);
+ sidebar->priv->secondary_text = g_strdup (secondary_text);
+
+ if (secondary_text == NULL)
+ secondary_text = "";
+
+ label = GTK_LABEL (sidebar->priv->secondary_label);
+ markup = g_markup_printf_escaped ("<small>%s</small>", secondary_text);
+ gtk_label_set_markup (label, markup);
+ g_free (markup);
+
+ gtk_widget_queue_resize (GTK_WIDGET (sidebar));
+ g_object_notify (G_OBJECT (sidebar), "secondary-text");
+}
+
GtkToolbarStyle
e_sidebar_get_style (ESidebar *sidebar)
{
diff --git a/shell/e-sidebar.h b/shell/e-sidebar.h
index b2cefbca4a..0386a431bc 100644
--- a/shell/e-sidebar.h
+++ b/shell/e-sidebar.h
@@ -69,6 +69,15 @@ void e_sidebar_add_action (ESidebar *sidebar,
gboolean e_sidebar_get_actions_visible (ESidebar *sidebar);
void e_sidebar_set_actions_visible (ESidebar *sidebar,
gboolean visible);
+const gchar * e_sidebar_get_icon_name (ESidebar *sidebar);
+void e_sidebar_set_icon_name (ESidebar *sidebar,
+ const gchar *icon_name);
+const gchar * e_sidebar_get_primary_text (ESidebar *sidebar);
+void e_sidebar_set_primary_text (ESidebar *sidebar,
+ const gchar *primary_text);
+const gchar * e_sidebar_get_secondary_text (ESidebar *sidebar);
+void e_sidebar_set_secondary_text (ESidebar *sidebar,
+ const gchar *secondary_text);
GtkToolbarStyle e_sidebar_get_style (ESidebar *sidebar);
void e_sidebar_set_style (ESidebar *sidebar,
GtkToolbarStyle style);
diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c
index 05d19c13f1..e2514ec236 100644
--- a/shell/test/e-test-shell-view.c
+++ b/shell/test/e-test-shell-view.c
@@ -90,6 +90,13 @@ test_shell_view_get_status_widget (EShellView *shell_view)
}
static void
+test_shell_view_changed (EShellView *shell_view,
+ gboolean visible)
+{
+ g_debug ("%s (visible=%d)", G_STRFUNC, visible);
+}
+
+static void
test_shell_view_class_init (ETestShellViewClass *class,
GTypeModule *type_module)
{
@@ -102,6 +109,7 @@ test_shell_view_class_init (ETestShellViewClass *class,
shell_view_class->label = "Test";
shell_view_class->icon_name = "face-monkey";
shell_view_class->type_module = type_module;
+ shell_view_class->changed = test_shell_view_changed;
shell_view_class->get_content_widget =
test_shell_view_get_content_widget;