aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-sidebar.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/e-sidebar.c')
-rw-r--r--shell/e-sidebar.c76
1 files changed, 52 insertions, 24 deletions
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c
index ca94de9a9a..5636716b32 100644
--- a/shell/e-sidebar.c
+++ b/shell/e-sidebar.c
@@ -62,6 +62,49 @@ static unsigned int signals[NUM_SIGNALS] = { 0 };
#define PADDING 6
+/* Utility functions. */
+
+static Button *
+button_new (GtkWidget *button_widget,
+ int id)
+{
+ Button *button = g_new (Button, 1);
+
+ button->button_widget = button_widget;
+ button->id = id;
+
+ g_object_ref (button_widget);
+
+ return button;
+}
+
+static void
+button_free (Button *button)
+{
+ g_object_unref (button->button_widget);
+ g_free (button);
+}
+
+static void
+update_buttons (ESidebar *sidebar, int new_selected_id)
+{
+ GSList *p;
+
+ sidebar->priv->in_toggle = TRUE;
+
+ for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
+ Button *button = p->data;
+
+ if (button->id == new_selected_id)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), TRUE);
+ else
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), FALSE);
+ }
+
+ sidebar->priv->in_toggle = FALSE;
+}
+
+
/* Callbacks. */
static void
@@ -93,30 +136,6 @@ button_toggled_callback (GtkToggleButton *toggle_button,
}
-/* Utility functions. */
-
-static Button *
-button_new (GtkWidget *button_widget,
- int id)
-{
- Button *button = g_new (Button, 1);
-
- button->button_widget = button_widget;
- button->id = id;
-
- g_object_ref (button_widget);
-
- return button;
-}
-
-static void
-button_free (Button *button)
-{
- g_object_unref (button->button_widget);
- g_free (button);
-}
-
-
/* Layout. */
static void
@@ -422,4 +441,13 @@ e_sidebar_add_button (ESidebar *sidebar,
}
+void
+e_sidebar_select_button (ESidebar *sidebar, int id)
+{
+ update_buttons (sidebar, id);
+
+ g_signal_emit (sidebar, signals[BUTTON_SELECTED], 0, id);
+}
+
+
E_MAKE_TYPE (e_sidebar, "ESidebar", ESidebar, class_init, init, PARENT_TYPE)