aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-content.c3
-rw-r--r--shell/e-shell-sidebar.c188
-rw-r--r--shell/e-shell-view.c23
3 files changed, 90 insertions, 124 deletions
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index 9e28bc8075..0d787749f8 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -587,6 +587,9 @@ shell_content_destroy (GtkObject *gtk_object)
priv = E_SHELL_CONTENT_GET_PRIVATE (gtk_object);
+ /* Unparent the widget before destroying it to avoid
+ * writing a custom GtkContainer::remove() method. */
+
if (priv->search_bar != NULL) {
gtk_widget_unparent (priv->search_bar);
gtk_widget_destroy (priv->search_bar);
diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c
index 7763e64918..4fb01e358d 100644
--- a/shell/e-shell-sidebar.c
+++ b/shell/e-shell-sidebar.c
@@ -21,7 +21,8 @@
#include "e-shell-sidebar.h"
-#include <e-shell-view.h>
+#include <e-util/e-binding.h>
+#include <shell/e-shell-view.h>
#define E_SHELL_SIDEBAR_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -32,9 +33,8 @@ struct _EShellSidebarPrivate {
gpointer shell_view; /* weak pointer */
GtkWidget *event_box;
- GtkWidget *image;
- GtkWidget *primary_label;
- GtkWidget *secondary_label;
+
+ gchar *icon_name;
gchar *primary_text;
gchar *secondary_text;
};
@@ -145,26 +145,6 @@ shell_sidebar_dispose (GObject *object)
priv->shell_view = NULL;
}
- if (priv->image != NULL) {
- g_object_unref (priv->image);
- priv->image = NULL;
- }
-
- if (priv->event_box != NULL) {
- g_object_unref (priv->event_box);
- priv->event_box = NULL;
- }
-
- if (priv->primary_label != NULL) {
- g_object_unref (priv->primary_label);
- priv->primary_label = NULL;
- }
-
- if (priv->secondary_label != NULL) {
- g_object_unref (priv->secondary_label);
- priv->secondary_label = NULL;
- }
-
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -176,6 +156,7 @@ shell_sidebar_finalize (GObject *object)
priv = E_SHELL_SIDEBAR_GET_PRIVATE (object);
+ g_free (priv->icon_name);
g_free (priv->primary_text);
g_free (priv->secondary_text);
@@ -190,7 +171,6 @@ shell_sidebar_constructed (GObject *object)
EShellSidebar *shell_sidebar;
GtkSizeGroup *size_group;
GtkAction *action;
- GtkWidget *container;
GtkWidget *widget;
gchar *label;
gchar *icon_name;
@@ -203,33 +183,6 @@ shell_sidebar_constructed (GObject *object)
widget = shell_sidebar->priv->event_box;
gtk_size_group_add_widget (size_group, 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);
- shell_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);
- shell_sidebar->priv->primary_label = g_object_ref (widget);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- shell_sidebar->priv->secondary_label = g_object_ref (widget);
- gtk_widget_show (widget);
-
g_object_get (action, "icon-name", &icon_name, NULL);
e_shell_sidebar_set_icon_name (shell_sidebar, icon_name);
g_free (icon_name);
@@ -240,6 +193,27 @@ shell_sidebar_constructed (GObject *object)
}
static void
+shell_sidebar_destroy (GtkObject *gtk_object)
+{
+ EShellSidebarPrivate *priv;
+
+ priv = E_SHELL_SIDEBAR_GET_PRIVATE (gtk_object);
+
+ /* Unparent the widget before destroying it to avoid
+ * writing a custom GtkContainer::remove() method. */
+
+ if (priv->event_box != NULL) {
+ gtk_widget_unparent (priv->event_box);
+ gtk_widget_destroy (priv->event_box);
+ g_object_unref (priv->event_box);
+ priv->event_box = NULL;
+ }
+
+ /* Chain up to parent's destroy() method. */
+ GTK_OBJECT_CLASS (parent_class)->destroy (gtk_object);
+}
+
+static void
shell_sidebar_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
@@ -294,26 +268,6 @@ shell_sidebar_size_allocate (GtkWidget *widget,
}
static void
-shell_sidebar_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- EShellSidebarPrivate *priv;
-
- priv = E_SHELL_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;
- }
-
- /* Chain up to parent's remove() method. */
- GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
-}
-
-static void
shell_sidebar_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
@@ -335,6 +289,7 @@ static void
shell_sidebar_class_init (EShellSidebarClass *class)
{
GObjectClass *object_class;
+ GtkObjectClass *gtk_object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
@@ -348,12 +303,14 @@ shell_sidebar_class_init (EShellSidebarClass *class)
object_class->finalize = shell_sidebar_finalize;
object_class->constructed = shell_sidebar_constructed;
+ gtk_object_class = GTK_OBJECT_CLASS (class);
+ gtk_object_class->destroy = shell_sidebar_destroy;
+
widget_class = GTK_WIDGET_CLASS (class);
widget_class->size_request = shell_sidebar_size_request;
widget_class->size_allocate = shell_sidebar_size_allocate;
container_class = GTK_CONTAINER_CLASS (class);
- container_class->remove = shell_sidebar_remove;
container_class->forall = shell_sidebar_forall;
/**
@@ -424,7 +381,11 @@ shell_sidebar_init (EShellSidebar *shell_sidebar)
{
GtkStyle *style;
GtkWidget *widget;
+ GtkWidget *container;
+ PangoAttribute *attribute;
+ PangoAttrList *attribute_list;
const GdkColor *color;
+ const gchar *icon_name;
shell_sidebar->priv = E_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
@@ -438,7 +399,50 @@ shell_sidebar_init (EShellSidebar *shell_sidebar)
shell_sidebar->priv->event_box = g_object_ref (widget);
gtk_widget_show (widget);
- /* Finish initialization once we have a shell view. */
+ 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;
+
+ /* Pick a bogus icon name just to get the storage type set. */
+ icon_name = "evolution";
+ e_shell_sidebar_set_icon_name (shell_sidebar, icon_name);
+ widget = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ e_binding_new (shell_sidebar, "icon-name", widget, "icon-name");
+
+ 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);
+ gtk_widget_show (widget);
+
+ attribute_list = pango_attr_list_new ();
+ attribute = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+ pango_attr_list_insert (attribute_list, attribute);
+ gtk_label_set_attributes (GTK_LABEL (widget), attribute_list);
+ pango_attr_list_unref (attribute_list);
+
+ e_binding_new (shell_sidebar, "primary-text", widget, "label");
+
+ widget = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ attribute_list = pango_attr_list_new ();
+ attribute = pango_attr_scale_new (PANGO_SCALE_SMALL);
+ pango_attr_list_insert (attribute_list, attribute);
+ gtk_label_set_attributes (GTK_LABEL (widget), attribute_list);
+ pango_attr_list_unref (attribute_list);
+
+ e_binding_new (shell_sidebar, "secondary-text", widget, "label");
}
GType
@@ -538,15 +542,9 @@ e_shell_sidebar_get_shell_view (EShellSidebar *shell_sidebar)
const gchar *
e_shell_sidebar_get_icon_name (EShellSidebar *shell_sidebar)
{
- GtkImage *image;
- const gchar *icon_name;
-
g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), NULL);
- image = GTK_IMAGE (shell_sidebar->priv->image);
- gtk_image_get_icon_name (image, &icon_name, NULL);
-
- return icon_name;
+ return shell_sidebar->priv->icon_name;
}
/**
@@ -560,12 +558,10 @@ void
e_shell_sidebar_set_icon_name (EShellSidebar *shell_sidebar,
const gchar *icon_name)
{
- GtkImage *image;
-
g_return_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar));
- image = GTK_IMAGE (shell_sidebar->priv->image);
- gtk_image_set_from_icon_name (image, icon_name, GTK_ICON_SIZE_MENU);
+ g_free (shell_sidebar->priv->icon_name);
+ shell_sidebar->priv->icon_name = g_strdup (icon_name);
g_object_notify (G_OBJECT (shell_sidebar), "icon-name");
}
@@ -605,22 +601,11 @@ void
e_shell_sidebar_set_primary_text (EShellSidebar *shell_sidebar,
const gchar *primary_text)
{
- GtkLabel *label;
- gchar *markup;
-
g_return_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar));
g_free (shell_sidebar->priv->primary_text);
shell_sidebar->priv->primary_text = g_strdup (primary_text);
- if (primary_text == NULL)
- primary_text = "";
-
- label = GTK_LABEL (shell_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 (shell_sidebar));
g_object_notify (G_OBJECT (shell_sidebar), "primary-text");
}
@@ -662,22 +647,11 @@ void
e_shell_sidebar_set_secondary_text (EShellSidebar *shell_sidebar,
const gchar *secondary_text)
{
- GtkLabel *label;
- gchar *markup;
-
g_return_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar));
g_free (shell_sidebar->priv->secondary_text);
shell_sidebar->priv->secondary_text = g_strdup (secondary_text);
- if (secondary_text == NULL)
- secondary_text = "";
-
- label = GTK_LABEL (shell_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 (shell_sidebar));
g_object_notify (G_OBJECT (shell_sidebar), "secondary-text");
}
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 2d50300183..f580b1aa4e 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -352,23 +352,6 @@ shell_view_dispose (GObject *object)
priv->shell_window = NULL;
}
- if (priv->size_group != NULL) {
- GSList *list;
-
- /* Remove all widgets from the size group. */
- list = gtk_size_group_get_widgets (priv->size_group);
- list = g_slist_copy (list);
-
- while (list != NULL) {
- gtk_size_group_remove_widget (
- priv->size_group, list->data);
- list = g_slist_delete_link (list, list);
- }
-
- g_object_unref (priv->size_group);
- priv->size_group = NULL;
- }
-
if (priv->shell_content != NULL) {
g_object_unref (priv->shell_content);
priv->shell_content = NULL;
@@ -429,6 +412,10 @@ shell_view_constructed (GObject *object)
widget = shell_view_class->new_shell_taskbar (shell_view);
shell_view->priv->shell_taskbar = g_object_ref_sink (widget);
gtk_widget_show (widget);
+
+ /* Size group should be safe to unreference now. */
+ g_object_unref (shell_view->priv->size_group);
+ shell_view->priv->size_group = NULL;
}
static void
@@ -957,6 +944,8 @@ e_shell_view_set_page_num (EShellView *shell_view,
* to keep the search bar and sidebar banner vertically aligned. The
* rest of the application should have no need for this.
*
+ * Note, this is only available during #EShellView construction.
+ *
* Returns: a #GtkSizeGroup for internal use
**/
GtkSizeGroup *