aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2003-10-23 01:14:05 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2003-10-23 01:14:05 +0800
commit3dbe4a3ce12ddbfdb789a3a3856d830f06d4c1a9 (patch)
treed4b71643d0d5237f9521ff5eb671432469cc4582
parentf34b946559d0ee15ad790156e9cc7adbd39a8c9e (diff)
downloadgsoc2013-evolution-3dbe4a3ce12ddbfdb789a3a3856d830f06d4c1a9.tar.gz
gsoc2013-evolution-3dbe4a3ce12ddbfdb789a3a3856d830f06d4c1a9.tar.zst
gsoc2013-evolution-3dbe4a3ce12ddbfdb789a3a3856d830f06d4c1a9.zip
Add an "evolution:button_label" property on the component for use in the
* gui/component/GNOME_Evolution_Addressbook.server.in.in: Add an "evolution:button_label" property on the component for use in the shell. * gui/GNOME_Evolution_Calendar.server.in.in: Add an "evolution:button_label" property on the component for use in the shell. * GNOME_Evolution_Mail.server.in.in: Add an "evolution:button_label" attribute to the Component for use in the shell. * e-shell-window.c (struct _ComponentView): New member button_id. (struct _EShellWindowPrivate): New member sidebar. (component_new_new): Get a button_id arg. (component_button_clicked_callback): Removed. (sidebar_button_selected_callback): New. (create_component_button): Removed. (setup_widget): Set up the sidebar using ESidebar and hook up its "button_selected" signal. Also get the component name from a property on the server info. (e_shell_window_new): Use BASE_VERSION for the version in the app name instead of hardcoding "1.5". * e-sidebar.c: New. * e-sidebar.h: New. svn path=/trunk/; revision=22988
-rw-r--r--addressbook/ChangeLog6
-rw-r--r--addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in2
-rw-r--r--calendar/ChangeLog6
-rw-r--r--calendar/gui/GNOME_Evolution_Calendar.server.in.in2
-rw-r--r--mail/ChangeLog6
-rw-r--r--mail/GNOME_Evolution_Mail.server.in.in2
-rw-r--r--shell/ChangeLog17
-rw-r--r--shell/e-shell-window.c104
-rw-r--r--shell/e-sidebar.c397
-rw-r--r--shell/e-sidebar.h64
10 files changed, 547 insertions, 59 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 881c16f422..2e9b191f0a 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-22 Ettore Perazzoli <ettore@ximian.com>
+
+ * gui/component/GNOME_Evolution_Addressbook.server.in.in: Add an
+ "evolution:button_label" property on the component for use in the
+ shell.
+
2003-10-20 Dan Winship <danw@ximian.com>
* backend/pas/pas-book-view.c: Queue up removes and modifies as
diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in
index 6b3b252377..a348c9a7cb 100644
--- a/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in
+++ b/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in
@@ -57,6 +57,8 @@
<oaf_attribute name="name" type="string"
_value="Evolution Addressbook component"/>
+ <oaf_attribute name="evolution:button_label" type="string" _value="Contacts"/>
+
</oaf_server>
<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_AddressWidget"
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 0269bf842f..b2515d7a43 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-22 Ettore Perazzoli <ettore@ximian.com>
+
+ * gui/GNOME_Evolution_Calendar.server.in.in: Add an
+ "evolution:button_label" property on the component for use in the
+ shell.
+
2003-10-21 Rodney Dawes <dobey@ximian.com>
* cal-client/Makefile.am: Fix typo in libcal_client_la_SOURCES
diff --git a/calendar/gui/GNOME_Evolution_Calendar.server.in.in b/calendar/gui/GNOME_Evolution_Calendar.server.in.in
index 09f424f69a..c840f9b27c 100644
--- a/calendar/gui/GNOME_Evolution_Calendar.server.in.in
+++ b/calendar/gui/GNOME_Evolution_Calendar.server.in.in
@@ -40,6 +40,8 @@
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="Evolution's Calendar component"/>
+
+ <oaf_attribute name="evolution:button_label" type="string" _value="Calendars"/>
</oaf_server>
<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_Control"
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 85189ae5a3..43876b1e41 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-22 Ettore Perazzoli <ettore@ximian.com>
+
+ * GNOME_Evolution_Mail.server.in.in: Add an
+ "evolution:button_label" attribute to the Component for use in the
+ shell.
+
2003-10-22 Not Zed <NotZed@Ximian.com>
* mail-component.c (em_copy_folders): handle destination of ""
diff --git a/mail/GNOME_Evolution_Mail.server.in.in b/mail/GNOME_Evolution_Mail.server.in.in
index 30fcd5b070..31e0df9007 100644
--- a/mail/GNOME_Evolution_Mail.server.in.in
+++ b/mail/GNOME_Evolution_Mail.server.in.in
@@ -41,6 +41,8 @@
<oaf_attribute name="name" type="string" _value="Evolution Mail component"/>
+ <oaf_attribute name="evolution:button_label" type="string" _value="Mail"/>
+
<oaf_attribute name="evolution:component_icon" type="string" value="evolution-inbox.png"/>
<oaf_attribute name="evolution:component_display_order" type="number" value="1"/>
</oaf_server>
diff --git a/shell/ChangeLog b/shell/ChangeLog
index d8e81c61e1..375b7133ee 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,22 @@
2003-10-22 Ettore Perazzoli <ettore@ximian.com>
+ * e-shell-window.c (struct _ComponentView): New member button_id.
+ (struct _EShellWindowPrivate): New member sidebar.
+ (component_new_new): Get a button_id arg.
+ (component_button_clicked_callback): Removed.
+ (sidebar_button_selected_callback): New.
+ (create_component_button): Removed.
+ (setup_widget): Set up the sidebar using ESidebar and hook up its
+ "button_selected" signal. Also get the component name from a
+ property on the server info.
+ (e_shell_window_new): Use BASE_VERSION for the version in the app
+ name instead of hardcoding "1.5".
+
+ * e-sidebar.c: New.
+ * e-sidebar.h: New.
+
+2003-10-22 Ettore Perazzoli <ettore@ximian.com>
+
* GNOME_Evolution_Shell.server.in.in: Append a _2 to all the IIDs.
* e-shell.h (E_SHELL_OAFIID): Change to "GNOME_Evolution_Shell_2"
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 2853374b98..9cf807e858 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -20,19 +20,15 @@
* Author: Ettore Perazzoli <ettore@ximian.com>
*/
-/* TODO
-
- - e_shell_component_maybe_crashed() replacement.
-
-*/
-
#include <config.h>
#include "e-shell-window.h"
#include "Evolution.h"
-
#include "e-shell-window-commands.h"
+#include "e-sidebar.h"
+
+#include "e-util/e-lang-utils.h"
#include <gal/util/e-util.h>
@@ -58,6 +54,7 @@ static GtkWindowClass *parent_class = NULL;
to -1. When the views are created the first time, the widget pointers as
well as the notebook page value get set. */
struct _ComponentView {
+ int button_id;
char *component_id;
GNOME_Evolution_Component component_iface;
@@ -76,6 +73,9 @@ struct _EShellWindowPrivate {
/* All the ComponentViews. */
GSList *component_views;
+ /* The sidebar. */
+ GtkWidget *sidebar;
+
/* Notebooks used to switch between components. */
GtkWidget *sidebar_notebook;
GtkWidget *view_notebook;
@@ -91,11 +91,12 @@ struct _EShellWindowPrivate {
/* ComponentView handling. */
static ComponentView *
-component_view_new (const char *id)
+component_view_new (const char *id, int button_id)
{
ComponentView *view = g_new0 (ComponentView, 1);
view->component_id = g_strdup (id);
+ view->button_id = button_id;
view->notebook_page_num = -1;
return view;
@@ -231,13 +232,25 @@ init_view (EShellWindow *window,
/* Callbacks. */
static void
-component_button_clicked_callback (GtkButton *button,
- EShellWindow *window)
+sidebar_button_selected_callback (ESidebar *sidebar,
+ int button_id,
+ EShellWindow *window)
{
- ComponentView *component_view = g_object_get_data (G_OBJECT (button), "ComponentView");
EShellWindowPrivate *priv = window->priv;
+ ComponentView *component_view;
+ GSList *p;
+
+ for (p = priv->component_views; p != NULL; p = p->next) {
+ if (((ComponentView *) p->data)->button_id == button_id) {
+ component_view = p->data;
+ break;
+ }
+ }
- g_assert (component_view != NULL);
+ if (component_view == NULL) {
+ g_warning ("Unknown component id %d", button_id);
+ return;
+ }
if (component_view->sidebar_widget == NULL) {
init_view (window, component_view);
@@ -255,70 +268,36 @@ component_button_clicked_callback (GtkButton *button,
/* Widget layout. */
-static GtkWidget *
-create_component_button (EShellWindow *window,
- ComponentView *component_view)
-{
- GtkWidget *button;
- const char *id = component_view->component_id;
- const char *p, *q;
- char *label;
-
- /* FIXME: Need a "name" property on the component or somesuch. */
-
- p = strrchr (id, '_');
- if (p == NULL || p == id) {
- label = g_strdup (id);
- } else {
- for (q = p - 1; q != id; q--) {
- if (*q == '_')
- break;
- }
-
- if (*q != '_') {
- label = g_strdup (id);
- } else {
- label = g_strndup (q + 1, p - q - 1);
- }
- }
-
- button = gtk_button_new_with_label (label);
-
- g_object_set_data (G_OBJECT (button), "ComponentView", component_view);
- g_signal_connect (button, "clicked", G_CALLBACK (component_button_clicked_callback), window);
-
- g_free (label);
-
- return button;
-}
-
static void
setup_widgets (EShellWindow *window)
{
EShellWindowPrivate *priv = window->priv;
+ GList *language_list;
Bonobo_ServerInfoList *info_list;
CORBA_Environment ev;
GtkWidget *paned;
- GtkWidget *sidebar_vbox;
GtkWidget *button_box;
int i;
paned = gtk_hpaned_new ();
bonobo_window_set_contents (BONOBO_WINDOW (window), paned);
- sidebar_vbox = gtk_vbox_new (FALSE, 6);
- gtk_paned_pack1 (GTK_PANED (paned), sidebar_vbox, FALSE, FALSE);
+ priv->sidebar = e_sidebar_new ();
+ g_signal_connect (priv->sidebar, "button_selected",
+ G_CALLBACK (sidebar_button_selected_callback), window);
+ gtk_paned_pack1 (GTK_PANED (paned), priv->sidebar, TRUE, FALSE);
priv->sidebar_notebook = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->sidebar_notebook), FALSE);
- gtk_box_pack_start (GTK_BOX (sidebar_vbox), priv->sidebar_notebook, TRUE, TRUE, 0);
+ e_sidebar_set_selection_widget (E_SIDEBAR (priv->sidebar), priv->sidebar_notebook);
priv->view_notebook = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->view_notebook), FALSE);
- gtk_paned_pack2 (GTK_PANED (paned), priv->view_notebook, TRUE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (paned), priv->view_notebook, FALSE, TRUE);
+
+ gtk_paned_set_position (GTK_PANED (paned), 200);
button_box = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (sidebar_vbox), button_box, FALSE, FALSE, 0);
CORBA_exception_init (&ev);
@@ -333,19 +312,26 @@ setup_widgets (EShellWindow *window)
return;
}
+ language_list = e_get_language_list ();
+
for (i = 0; i < info_list->_length; i++) {
- ComponentView *component_view = component_view_new (info_list->_buffer[i].iid);
- GtkWidget *component_button = create_component_button (window, component_view);
+ ComponentView *component_view = component_view_new (info_list->_buffer[i].iid, i);
+ const char *label = bonobo_server_info_prop_lookup (& info_list->_buffer[i],
+ "evolution:button_label",
+ language_list);
+ g_print ("component %s\n", info_list->_buffer[i].iid);
priv->component_views = g_slist_prepend (priv->component_views, component_view);
- gtk_box_pack_start (GTK_BOX (button_box), component_button, FALSE, FALSE, 0);
+ e_sidebar_add_button (E_SIDEBAR (priv->sidebar), label, NULL, component_view->button_id);
}
CORBA_free (info_list);
CORBA_exception_free (&ev);
gtk_widget_show_all (paned);
+
+ e_free_language_list (language_list);
}
@@ -437,7 +423,7 @@ e_shell_window_new (EShell *shell)
bonobo_ui_util_set_ui (priv->ui_component,
PREFIX,
EVOLUTION_UIDIR "/evolution.xml",
- "evolution-1.5", NULL);
+ "evolution-" BASE_VERSION, NULL);
e_shell_window_commands_setup (window);
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c
new file mode 100644
index 0000000000..1f6df8c451
--- /dev/null
+++ b/shell/e-sidebar.c
@@ -0,0 +1,397 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-sidebar.c
+ *
+ * Copyright (C) 2003 Ettore Perazzoli
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli <ettore@ximian.com>
+ */
+
+#include <config.h>
+
+#include "e-sidebar.h"
+
+#include "e-shell-marshal.h"
+
+#include <gal/util/e-util.h>
+
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkimage.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtktogglebutton.h>
+
+
+#define PARENT_TYPE gtk_container_get_type ()
+static GtkContainerClass *parent_class = NULL;
+
+
+typedef struct {
+ GtkWidget *button_widget;
+ int id;
+} Button;
+
+struct _ESidebarPrivate {
+ GtkWidget *selection_widget;
+ GSList *buttons;
+
+ gboolean in_toggle;
+};
+
+
+enum {
+ BUTTON_SELECTED,
+ NUM_SIGNALS
+};
+
+static unsigned int signals[NUM_SIGNALS] = { 0 };
+
+
+#define PADDING 3
+
+
+/* Callbacks. */
+
+static void
+button_toggled_callback (GtkToggleButton *toggle_button,
+ ESidebar *sidebar)
+{
+ int id = 0;
+ GSList *p;
+
+ if (sidebar->priv->in_toggle)
+ return;
+
+ sidebar->priv->in_toggle = TRUE;
+
+ for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
+ Button *button = p->data;
+
+ if (button->button_widget != toggle_button) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), FALSE);
+ } else {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), TRUE);
+ id = button->id;
+ }
+ }
+
+ sidebar->priv->in_toggle = FALSE;
+
+ g_signal_emit (sidebar, signals[BUTTON_SELECTED], 0, id);
+}
+
+
+/* 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
+do_layout (ESidebar *sidebar)
+{
+ GtkAllocation *allocation = & GTK_WIDGET (sidebar)->allocation;
+ GSList *rows [g_slist_length (sidebar->priv->buttons)];
+ GSList *p;
+ int row_number;
+ int row_width;
+ int row_last;
+ int x, y;
+ int i;
+
+ /* (Yes, this code calls gtk_widget_size_request() an ungodly number of times, but it's not
+ like we care about performance here, and this makes the code simpler.) */
+
+ /* 1. Split the buttons into rows, depending on their width. */
+
+ row_number = 0;
+ rows [0] = NULL;
+ row_width = PADDING;
+ for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
+ Button *button = p->data;
+ GtkRequisition requisition;
+
+ gtk_widget_size_request (GTK_WIDGET (button->button_widget), &requisition);
+
+ if (row_width + requisition.width + PADDING >= allocation->width
+ && rows [row_number] != NULL) {
+ row_number ++;
+ rows [row_number] = NULL;
+ row_width = PADDING;
+ }
+
+ row_width += requisition.width + PADDING;
+ rows [row_number] = g_slist_append (rows [row_number], button->button_widget);
+ }
+
+ row_last = row_number;
+
+ /* 2. Layout the buttons. */
+
+ y = allocation->y + allocation->height - PADDING - 1;
+ for (i = row_last; i >= 0; i --) {
+ int row_height = 0;
+
+ for (p = rows [i]; p != NULL; p = p->next) {
+ GtkRequisition requisition;
+
+ gtk_widget_size_request (GTK_WIDGET (p->data), &requisition);
+ row_height = MAX (row_height, requisition.height);
+ }
+
+ y -= row_height;
+ x = PADDING;
+ for (p = rows [i]; p != NULL; p = p->next) {
+ GtkRequisition requisition;
+ GtkAllocation child_allocation;
+
+ gtk_widget_size_request (GTK_WIDGET (p->data), &requisition);
+
+ child_allocation.x = x;
+ child_allocation.y = y;
+ child_allocation.width = requisition.width;
+ child_allocation.height = requisition.height;
+
+ gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation);
+
+ x += requisition.width + PADDING;
+ }
+
+ y -= PADDING;
+ }
+
+
+ /* 3. Place the selection widget. */
+
+ {
+ GtkAllocation child_allocation;
+
+ child_allocation.x = allocation->x + PADDING;
+ child_allocation.y = allocation->y + PADDING;
+ child_allocation.width = allocation->width - PADDING * 2;
+ child_allocation.height = y - allocation->y;
+
+ gtk_widget_size_allocate (sidebar->priv->selection_widget, & child_allocation);
+ }
+
+
+ /* 4. Free stuff */
+
+ for (i = 0; i <= row_last; i ++)
+ g_slist_free (rows [i]);
+}
+
+
+/* GtkContainer methods. */
+
+static void
+impl_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ void *callback_data)
+{
+ ESidebar *sidebar = E_SIDEBAR (container);
+ GSList *p;
+
+ if (sidebar->priv->selection_widget != NULL)
+ (* callback) (sidebar->priv->selection_widget, callback_data);
+
+ for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
+ GtkWidget *widget = ((Button *) p->data)->button_widget;
+ (* callback) (widget, callback_data);
+ }
+}
+
+
+/* GtkWidget methods. */
+
+static void
+impl_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ ESidebar *sidebar = E_SIDEBAR (widget);
+ GSList *p;
+
+ if (sidebar->priv->selection_widget == NULL) {
+ requisition->width = 2 * PADDING;
+ requisition->height = 2 * PADDING;
+ } else {
+ gtk_widget_size_request (sidebar->priv->selection_widget, requisition);
+ requisition->width += 2 * PADDING;
+ requisition->height += 2 * PADDING;
+ }
+
+ for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
+ Button *button = p->data;
+ GtkRequisition button_requisition;
+
+ gtk_widget_size_request (button->button_widget, &button_requisition);
+
+ requisition->width = MAX (requisition->width, button_requisition.width + 2 * PADDING);
+ requisition->height += button_requisition.height + PADDING;
+ }
+}
+
+static void
+impl_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ widget->allocation = *allocation;
+
+ do_layout (E_SIDEBAR (widget));
+}
+
+
+/* GObject methods. */
+
+static void
+impl_dispose (GObject *object)
+{
+ ESidebarPrivate *priv = E_SIDEBAR (object)->priv;
+
+ g_slist_foreach (priv->buttons, (GFunc) button_free, NULL);
+ g_slist_free (priv->buttons);
+ priv->buttons = NULL;
+
+ (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+}
+
+static void
+impl_finalize (GObject *object)
+{
+ ESidebarPrivate *priv = E_SIDEBAR (object)->priv;
+
+ g_free (priv);
+
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+
+/* Initialization. */
+
+static void
+class_init (ESidebarClass *class)
+{
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ container_class->forall = impl_forall;
+
+ widget_class->size_request = impl_size_request;
+ widget_class->size_allocate = impl_size_allocate;
+
+ object_class->dispose = impl_dispose;
+ object_class->finalize = impl_finalize;
+
+ parent_class = g_type_class_peek_parent (class);
+
+
+ signals[BUTTON_SELECTED]
+ = g_signal_new ("button_selected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (ESidebarClass, button_selected),
+ NULL, NULL,
+ e_shell_marshal_NONE__INT,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+}
+
+static void
+init (ESidebar *sidebar)
+{
+ ESidebarPrivate *priv;
+
+ GTK_WIDGET_SET_FLAGS (sidebar, GTK_NO_WINDOW);
+
+ priv = g_new0 (ESidebarPrivate, 1);
+ sidebar->priv = priv;
+}
+
+
+GtkWidget *
+e_sidebar_new (void)
+{
+ ESidebar *sidebar = g_object_new (e_sidebar_get_type (), NULL);
+
+ return GTK_WIDGET (sidebar);
+}
+
+
+void
+e_sidebar_set_selection_widget (ESidebar *sidebar, GtkWidget *widget)
+{
+ if (sidebar->priv->selection_widget != NULL)
+ gtk_widget_unparent (sidebar->priv->selection_widget);
+
+ sidebar->priv->selection_widget = widget;
+ gtk_widget_set_parent (widget, GTK_WIDGET (sidebar));
+
+ gtk_widget_queue_resize (GTK_WIDGET (sidebar));
+}
+
+
+void
+e_sidebar_add_button (ESidebar *sidebar,
+ const char *label,
+ GdkPixbuf *icon,
+ int id)
+{
+ GtkWidget *button_widget;
+ GtkWidget *hbox;
+ GtkWidget *icon_widget;
+ GtkWidget *label_widget;
+
+ button_widget = gtk_toggle_button_new ();
+ sidebar->priv->buttons = g_slist_append (sidebar->priv->buttons, button_new (button_widget, id));
+ gtk_widget_set_parent (button_widget, GTK_WIDGET (sidebar));
+
+ g_signal_connect (button_widget, "toggled", G_CALLBACK (button_toggled_callback), sidebar);
+
+ hbox = gtk_hbox_new (FALSE, 3);
+ icon_widget = gtk_image_new_from_pixbuf (icon);
+ label_widget = gtk_label_new (label);
+ gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (button_widget), hbox);
+
+ gtk_widget_show_all (button_widget);
+
+ gtk_widget_queue_resize (GTK_WIDGET (sidebar));
+}
+
+
+E_MAKE_TYPE (e_sidebar, "ESidebar", ESidebar, class_init, init, PARENT_TYPE)
diff --git a/shell/e-sidebar.h b/shell/e-sidebar.h
new file mode 100644
index 0000000000..d77a7c91b7
--- /dev/null
+++ b/shell/e-sidebar.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-sidebar.h
+ *
+ * Copyright (C) 2003 Ettore Perazzoli
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli <ettore@ximian.com>
+ */
+
+#ifndef _E_SIDEBAR_H_
+#define _E_SIDEBAR_H_
+
+#include <gtk/gtkcontainer.h>
+
+#define E_TYPE_SIDEBAR (e_sidebar_get_type ())
+#define E_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIDEBAR, ESidebar))
+#define E_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIDEBAR, ESidebarClass))
+#define E_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIDEBAR))
+#define E_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SIDEBAR))
+
+
+typedef struct _ESidebar ESidebar;
+typedef struct _ESidebarPrivate ESidebarPrivate;
+typedef struct _ESidebarClass ESidebarClass;
+
+struct _ESidebar {
+ GtkContainer parent;
+
+ ESidebarPrivate *priv;
+};
+
+struct _ESidebarClass {
+ GtkContainerClass parent_class;
+
+ void (* button_selected) (ESidebar *sidebar, int id);
+};
+
+
+GType e_sidebar_get_type (void);
+GtkWidget *e_sidebar_new (void);
+
+void e_sidebar_set_selection_widget (ESidebar *sidebar,
+ GtkWidget *widget);
+
+void e_sidebar_add_button (ESidebar *sidebar,
+ const char *label,
+ GdkPixbuf *icon,
+ int id);
+
+
+#endif /* _E_SIDEBAR_H_ */