[evolution-patches] Patch for bug/bounty #127527




-- 
   .--= ULLA! =---------------------.   `We are not here to give users what
   \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
    `---= cactus cactus rulez org =---'
Esszé: írd le a világegyetemet legfeljebb 500 szóban. Adj meg két példát is!
Index: widgets/misc/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/ChangeLog,v
retrieving revision 1.246
diff -u -r1.246 ChangeLog
--- widgets/misc/ChangeLog	17 Nov 2003 13:31:52 -0000	1.246
+++ widgets/misc/ChangeLog	23 Nov 2003 14:31:42 -0000
@@ -1,3 +1,11 @@
+2003-11-23  ERDI Gergo  <cactus cactus rulez org>
+
+	* e-expander.c: Added the late eggexpander
+	
+	* e-expander.c (e_expander_button_release): Emit 'activate' signal when
+	appropriate
+	
+
 2003-11-17  Charles Zhang  <charles zhang sun com>
 
 	* e-search-bar.c(add_button): allow new lable with mnemonic
Index: widgets/misc/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/Makefile.am,v
retrieving revision 1.42
diff -u -r1.42 Makefile.am
--- widgets/misc/Makefile.am	14 Nov 2003 22:27:34 -0000	1.42
+++ widgets/misc/Makefile.am	23 Nov 2003 14:31:42 -0000
@@ -28,6 +28,7 @@
 	e-combo-button.h			\
 	e-dateedit.h				\
 	e-dropdown-button.h			\
+	e-expander.h				\
 	e-map.h					\
 	e-multi-config-dialog.h			\
 	e-search-bar.h				\
@@ -50,6 +51,7 @@
 	e-combo-button.c			\
 	e-dateedit.c				\
 	e-dropdown-button.c			\
+	e-expander.c				\
 	e-map.c					\
 	e-multi-config-dialog.c			\
 	e-search-bar.c				\
@@ -145,4 +147,4 @@
 	ChangeLog.pre-1-4
 
 dist-hook:
-	cd $(distdir); rm -f $(BUILT_SOURCES)
\ No newline at end of file
+	cd $(distdir); rm -f $(BUILT_SOURCES)
Index: widgets/misc/e-expander.c
===================================================================
RCS file: widgets/misc/e-expander.c
diff -N widgets/misc/e-expander.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ widgets/misc/e-expander.c	23 Nov 2003 14:31:45 -0000
@@ -0,0 +1,1354 @@
+/* GTK - The GIMP Toolkit
+ *
+ * Copyright (C) 2003 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *	Mark McLoughlin <mark skynet ie>
+ */
+
+#include <config.h>
+
+#include "e-expander.h"
+
+#include <gtk/gtklabel.h>
+#include <gtk/gtkcontainer.h>
+#include <gdk/gdkkeysyms.h>
+
+#define DEFAULT_EXPANDER_SIZE 10
+#define DEFAULT_EXPANDER_SPACING 2
+
+/* ESTUFF */
+#ifndef _
+#define _(x) (x)
+#endif
+#define E_EXPANDER_GET_PRIVATE(expander) ((EExpanderPrivate *)g_object_get_data (G_OBJECT (expander), "e-expander-priv"))
+
+enum {
+  PROP_0,
+  PROP_EXPANDED,
+  PROP_LABEL,
+  PROP_USE_UNDERLINE,
+  PROP_PADDING,
+  PROP_LABEL_WIDGET
+};
+
+typedef struct {
+  GtkWidget        *label_widget;
+  gint              spacing;
+
+  GtkExpanderStyle  expander_style;
+  guint             animation_timeout;
+
+  guint      expanded : 1;
+  guint      use_underline : 1;
+  guint      button_down : 1;
+} EExpanderPrivate;
+
+static void e_expander_class_init (EExpanderClass *klass);
+static void e_expander_init       (EExpander      *expander);
+
+static void e_expander_set_property (GObject          *object,
+				       guint             prop_id,
+				       const GValue     *value,
+				       GParamSpec       *pspec);
+static void e_expander_get_property (GObject          *object,
+				       guint             prop_id,
+				       GValue           *value,
+				       GParamSpec       *pspec);
+
+static void e_expander_destroy (GtkObject *object);
+
+static void     e_expander_realize        (GtkWidget        *widget);
+static void     e_expander_size_request   (GtkWidget        *widget,
+					     GtkRequisition   *requisition);
+static void     e_expander_size_allocate  (GtkWidget        *widget,
+					     GtkAllocation    *allocation);
+static void     e_expander_map            (GtkWidget        *widget);
+static gboolean e_expander_expose         (GtkWidget        *widget,
+					     GdkEventExpose   *event);
+static gboolean e_expander_button_press   (GtkWidget        *widget,
+					     GdkEventButton   *event);
+static gboolean e_expander_button_release (GtkWidget        *widget,
+					     GdkEventButton   *event);
+static gboolean e_expander_motion_notify  (GtkWidget        *widget,
+					     GdkEventMotion   *event);
+static gboolean e_expander_enter_notify   (GtkWidget        *widget,
+					     GdkEventCrossing *event);
+static gboolean e_expander_leave_notify   (GtkWidget        *widget,
+					     GdkEventCrossing *event);
+static gboolean e_expander_focus          (GtkWidget        *widget,
+					     GtkDirectionType  direction);
+
+static void e_expander_add    (GtkContainer *container,
+				 GtkWidget    *widget);
+static void e_expander_remove (GtkContainer *container,
+				 GtkWidget    *widget);
+static void e_expander_forall (GtkContainer *container,
+				 gboolean        include_internals,
+				 GtkCallback     callback,
+				 gpointer        callback_data);
+
+static void e_expander_activate (EExpander *expander);
+
+static GtkBinClass *parent_class = NULL;
+
+GType
+e_expander_get_type (void)
+{
+  static GType expander_type = 0;
+  
+  if (!expander_type)
+    {
+      static const GTypeInfo expander_info =
+      {
+	sizeof (EExpanderClass),
+	NULL,		/* base_init */
+	NULL,		/* base_finalize */
+	(GClassInitFunc) e_expander_class_init,
+	NULL,		/* class_finalize */
+	NULL,		/* class_data */
+	sizeof (EExpander),
+	0,		/* n_preallocs */
+	(GInstanceInitFunc) e_expander_init,
+      };
+      
+      expander_type = g_type_register_static (GTK_TYPE_BIN,
+					      "EExpander",
+					      &expander_info, 0);
+    }
+  
+  return expander_type;
+}
+
+static void
+e_expander_class_init (EExpanderClass *klass)
+{
+  GObjectClass *gobject_class;
+  GtkObjectClass *gtkobject_class;
+  GtkWidgetClass *widget_class;
+  GtkContainerClass *container_class;
+
+  parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class    = (GObjectClass *) klass;
+  gtkobject_class  = (GtkObjectClass *) klass;
+  widget_class    = (GtkWidgetClass *) klass;
+  container_class = (GtkContainerClass *) klass;
+
+  gobject_class->set_property = e_expander_set_property;
+  gobject_class->get_property = e_expander_get_property;
+
+  gtkobject_class->destroy = e_expander_destroy;
+
+  widget_class->realize              = e_expander_realize;
+  widget_class->size_request         = e_expander_size_request;
+  widget_class->size_allocate        = e_expander_size_allocate;
+  widget_class->map                  = e_expander_map;
+  widget_class->expose_event         = e_expander_expose;
+  widget_class->button_press_event   = e_expander_button_press;
+  widget_class->button_release_event = e_expander_button_release;
+  widget_class->motion_notify_event  = e_expander_motion_notify;
+  widget_class->enter_notify_event   = e_expander_enter_notify;
+  widget_class->leave_notify_event   = e_expander_leave_notify;
+  widget_class->focus                = e_expander_focus;
+
+  container_class->add    = e_expander_add;
+  container_class->remove = e_expander_remove;
+  container_class->forall = e_expander_forall;
+
+  klass->activate = e_expander_activate;
+
+  /* ESTUFF  g_type_class_add_private (klass, sizeof (EExpanderPrivate)); */
+
+  g_object_class_install_property (gobject_class,
+				   PROP_EXPANDED,
+				   g_param_spec_boolean ("expanded",
+							 _("Expanded"),
+							 _("Whether or not the expander is expanded"),
+							 FALSE,
+							 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+  g_object_class_install_property (gobject_class,
+				   PROP_LABEL,
+				   g_param_spec_string ("label",
+							_("Label"),
+							_("Text of the expander's label"),
+							NULL,
+							G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+  g_object_class_install_property (gobject_class,
+				   PROP_USE_UNDERLINE,
+				   g_param_spec_boolean ("use_underline",
+							 _("Use underline"),
+							 _("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"),
+							 FALSE,
+							 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+  g_object_class_install_property (gobject_class,
+				   PROP_PADDING,
+				   g_param_spec_int ("spacing",
+						     _("Spacing"),
+						     _("Space to put between the label and the child"),
+						     0,
+						     G_MAXINT,
+						     0,
+						     G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+				   PROP_LABEL_WIDGET,
+				   g_param_spec_object ("label_widget",
+							_("Label widget"),
+							_("A widget to display in place of the usual expander label"),
+							GTK_TYPE_WIDGET,
+							G_PARAM_READWRITE));
+
+  gtk_widget_class_install_style_property (widget_class,
+					   g_param_spec_int ("expander-size",
+							     _("Expander Size"),
+							     _("Size of the expander arrow"),
+							     0,
+							     G_MAXINT,
+							     DEFAULT_EXPANDER_SIZE,
+							     G_PARAM_READABLE));
+
+  gtk_widget_class_install_style_property (widget_class,
+					   g_param_spec_int ("expander-spacing",
+							     _("Indicator Spacing"),
+							     _("Spacing around expander arrow"),
+							     0,
+							     G_MAXINT,
+							     DEFAULT_EXPANDER_SPACING,
+							     G_PARAM_READABLE));
+
+  widget_class->activate_signal =
+    g_signal_new ("activate",
+		  G_TYPE_FROM_CLASS (gobject_class),
+		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+		  G_STRUCT_OFFSET (EExpanderClass, activate),
+		  NULL, NULL,
+		  g_cclosure_marshal_VOID__VOID,
+		  G_TYPE_NONE, 0);
+}
+
+static void
+e_expander_init (EExpander *expander)
+{
+  EExpanderPrivate *priv;
+
+  /* ESTUFF */
+  priv = g_new0 (EExpanderPrivate, 1);
+  g_object_set_data_full (G_OBJECT (expander), "e-expander-priv", priv, g_free);
+  
+  /* ESTUFF  priv = E_EXPANDER_GET_PRIVATE (expander); */
+
+  GTK_WIDGET_SET_FLAGS (expander, GTK_CAN_FOCUS);
+  GTK_WIDGET_UNSET_FLAGS (expander, GTK_NO_WINDOW);
+
+  priv->label_widget = 0;
+  priv->spacing = 0;
+
+  priv->expander_style = GTK_EXPANDER_COLLAPSED;
+  priv->animation_timeout = 0;
+
+  priv->expanded = FALSE;
+  priv->use_underline = FALSE;
+  priv->button_down = FALSE;
+
+}
+
+static void
+e_expander_set_property (GObject      *object,
+			   guint         prop_id,
+			   const GValue *value,
+			   GParamSpec   *pspec)
+{
+  EExpander *expander = E_EXPANDER (object);
+                                                                                                             
+  switch (prop_id)
+    {
+    case PROP_EXPANDED:
+      e_expander_set_expanded (expander, g_value_get_boolean (value));
+      break;
+    case PROP_LABEL:
+      e_expander_set_label (expander, g_value_get_string (value));
+      break;
+    case PROP_USE_UNDERLINE:
+      e_expander_set_use_underline (expander, g_value_get_boolean (value));
+      break;
+    case PROP_PADDING:
+      e_expander_set_spacing (expander, g_value_get_int (value));
+      break;
+    case PROP_LABEL_WIDGET:
+      e_expander_set_label_widget (expander, g_value_get_object (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+e_expander_get_property (GObject    *object,
+			   guint       prop_id,
+			   GValue     *value,
+			   GParamSpec *pspec)
+{
+  EExpander *expander = E_EXPANDER (object);
+  EExpanderPrivate *priv;
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+                                                                                                             
+  switch (prop_id)
+    {
+    case PROP_EXPANDED:
+      g_value_set_boolean (value, priv->expanded);
+      break;
+    case PROP_LABEL:
+      g_value_set_string (value, e_expander_get_label (expander));
+      break;
+    case PROP_USE_UNDERLINE:
+      g_value_set_boolean (value, priv->use_underline);
+      break;
+    case PROP_PADDING:
+      g_value_set_int (value, priv->spacing);
+      break;
+    case PROP_LABEL_WIDGET:
+      g_value_set_object (value,
+			  priv->label_widget ?
+			  G_OBJECT (priv->label_widget) : NULL);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+e_expander_destroy (GtkObject *object)
+{
+  EExpander *expander = E_EXPANDER (object);
+  EExpanderPrivate *priv;
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (priv->animation_timeout)
+    g_source_remove (priv->animation_timeout);
+  priv->animation_timeout = 0;
+
+  GTK_OBJECT_CLASS (parent_class)->destroy (object);
+}
+
+static void
+e_expander_realize (GtkWidget *widget)
+{
+  GdkWindowAttr attributes;
+  gint attributes_mask;
+  gint border_width;
+
+  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+  border_width = GTK_CONTAINER (widget)->border_width;
+                                                                                                             
+  attributes.x = widget->allocation.x + border_width;
+  attributes.y = widget->allocation.y + border_width;
+  attributes.width = widget->allocation.width - 2 * border_width;
+  attributes.height = widget->allocation.height - 2 * border_width;
+  attributes.window_type = GDK_WINDOW_CHILD;
+  attributes.wclass = GDK_INPUT_OUTPUT;
+  attributes.visual = gtk_widget_get_visual (widget);
+  attributes.colormap = gtk_widget_get_colormap (widget);
+  attributes.event_mask = gtk_widget_get_events (widget)     |
+				GDK_POINTER_MOTION_MASK      |
+				GDK_POINTER_MOTION_HINT_MASK |
+				GDK_BUTTON_PRESS_MASK        |
+				GDK_BUTTON_RELEASE_MASK      |
+				GDK_EXPOSURE_MASK            |
+				GDK_ENTER_NOTIFY_MASK        |
+				GDK_LEAVE_NOTIFY_MASK;
+
+  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+
+  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+				   &attributes, attributes_mask);
+  gdk_window_set_user_data (widget->window, widget);
+
+  widget->style = gtk_style_attach (widget->style, widget->window);
+  gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+}
+                                                                                                             
+static void
+e_expander_size_request (GtkWidget      *widget,
+			   GtkRequisition *requisition)
+{
+  EExpander *expander;
+  GtkBin *bin;
+  EExpanderPrivate *priv;
+  gint border_width;
+  gint expander_size;
+  gint expander_spacing;
+  gboolean interior_focus;
+  gint focus_width;
+  gint focus_pad;
+
+  expander = E_EXPANDER (widget);
+  bin = GTK_BIN (widget);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  border_width = GTK_CONTAINER (widget)->border_width;
+
+  gtk_widget_style_get (widget,
+			"interior-focus", &interior_focus,
+			"focus-line-width", &focus_width,
+			"focus-padding", &focus_pad,
+			"expander-size", &expander_size,
+			"expander-spacing", &expander_spacing,
+			NULL);
+
+  requisition->width = expander_size + 2 * expander_spacing +
+		       2 * focus_width + 2 * focus_pad;
+  requisition->height = interior_focus ? (2 * focus_width + 2 * focus_pad) : 0;
+
+  if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget))
+    {
+      GtkRequisition label_requisition;
+
+      gtk_widget_size_request (priv->label_widget, &label_requisition);
+
+      requisition->width  += label_requisition.width;
+      requisition->height += label_requisition.height;
+    }
+
+  requisition->height = MAX (expander_size + 2 * expander_spacing, requisition->height);
+
+  if (!interior_focus)
+    requisition->height += 2 * focus_width + 2 * focus_pad;
+
+  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+    {
+      GtkRequisition child_requisition;
+
+      gtk_widget_size_request (bin->child, &child_requisition);
+
+      if (!interior_focus)
+	child_requisition.width += 2 * focus_width + 2 * focus_pad;
+
+      requisition->width = MAX (requisition->width, child_requisition.width);
+      requisition->height += child_requisition.height + priv->spacing;
+    }
+
+  requisition->width  += 2 * border_width;
+  requisition->height += 2 * border_width + 2 * priv->spacing;
+}
+
+static void
+e_expander_size_allocate (GtkWidget     *widget,
+			    GtkAllocation *allocation)
+{
+  EExpander *expander;
+  GtkBin *bin;
+  EExpanderPrivate *priv;
+  GtkRequisition child_requisition;
+  gboolean child_visible = FALSE;
+  gint border_width;
+  gint expander_size;
+  gint expander_spacing;
+  gboolean interior_focus;
+  gint focus_width;
+  gint focus_pad;
+  gint label_height;
+
+  expander = E_EXPANDER (widget);
+  bin = GTK_BIN (widget);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  border_width = GTK_CONTAINER (widget)->border_width;
+
+  gtk_widget_style_get (widget,
+			"interior-focus", &interior_focus,
+			"focus-line-width", &focus_width,
+			"focus-padding", &focus_pad,
+			"expander-size", &expander_size,
+			"expander-spacing", &expander_spacing,
+			NULL);
+
+  child_requisition.width = 0;
+  child_requisition.height = 0;
+  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+    {
+      child_visible = TRUE;
+      gtk_widget_get_child_requisition (bin->child, &child_requisition);
+    }
+
+  widget->allocation = *allocation;
+
+  if (GTK_WIDGET_REALIZED (widget))
+    gdk_window_move_resize (widget->window,
+			    allocation->x + border_width,
+			    allocation->y + border_width,
+                            MAX (allocation->width - 2 * border_width, 0),
+                            MAX (allocation->height - 2 * border_width, 0));
+
+  if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget))
+    {
+      GtkAllocation label_allocation;
+      GtkRequisition label_requisition;
+      gboolean ltr;
+
+      gtk_widget_get_child_requisition (priv->label_widget, &label_requisition);
+
+      ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
+
+      label_allocation.x = focus_width + focus_pad;
+      if (ltr)
+	label_allocation.x += expander_size + 2 * expander_spacing;
+      label_allocation.y = priv->spacing + focus_width + focus_pad;
+
+      label_allocation.width = MIN (label_requisition.width,
+				    allocation->width - 2 * border_width -
+				    expander_size - 2 * expander_spacing -
+				    2 * focus_width - 2 * focus_pad);
+      label_allocation.width = MAX (label_allocation.width, 1);
+
+      label_allocation.height = MIN (label_requisition.height,
+				     allocation->height - 2 * border_width -
+				     2 * priv->spacing -
+				     2 * focus_width - 2 * focus_pad -
+				     child_requisition.height -
+				     (child_visible ? priv->spacing : 0));
+      label_allocation.height = MAX (label_allocation.height, 1);
+
+      gtk_widget_size_allocate (priv->label_widget, &label_allocation);
+
+      label_height = label_allocation.height;
+    }
+  else
+    {
+      label_height = 0;
+    }
+
+  if (child_visible)
+    {
+      GtkAllocation child_allocation;
+      gint top_height;
+
+      top_height = MAX (2 * expander_spacing + expander_size,
+			label_height +
+			(interior_focus ? 2 * focus_width + 2 * focus_pad : 0));
+
+      child_allocation.x = 0;
+      child_allocation.y = 2 * priv->spacing + top_height;
+
+      if (!interior_focus)
+	{
+	  child_allocation.x += focus_width + focus_pad;
+	  child_allocation.y += focus_width + focus_pad;
+	}
+
+      child_allocation.width = allocation->width - 2 * border_width -
+			       (!interior_focus ? 2 * focus_width + 2 * focus_pad : 0);
+      child_allocation.width = MAX (child_allocation.width, 1);
+
+      child_allocation.height = allocation->height - top_height -
+				2 * border_width -
+				3 * priv->spacing -
+				(!interior_focus ? 2 * focus_width + 2 * focus_pad : 0);
+      child_allocation.height = MAX (child_allocation.height, 1);
+
+      gtk_widget_size_allocate (bin->child, &child_allocation);
+    }
+}
+
+static void
+e_expander_map (GtkWidget *widget)
+{
+  EExpanderPrivate *priv;
+
+  priv = E_EXPANDER_GET_PRIVATE (widget);
+
+  if (priv->label_widget)
+    gtk_widget_map (priv->label_widget);
+
+  GTK_WIDGET_CLASS (parent_class)->map (widget);
+}
+
+static GdkRectangle
+get_expander_bounds (EExpander *expander)
+{
+  GtkWidget *widget;
+  GtkBin *bin;
+  EExpanderPrivate *priv;
+  GdkRectangle bounds;
+  gint border_width;
+  gint expander_size;
+  gint expander_spacing;
+  gboolean interior_focus;
+  gint focus_width;
+  gint focus_pad;
+  gboolean ltr;
+
+  widget = GTK_WIDGET (expander);
+  bin = GTK_BIN (expander);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  border_width = GTK_CONTAINER (expander)->border_width;
+
+  gtk_widget_style_get (widget,
+			"interior-focus", &interior_focus,
+			"focus-line-width", &focus_width,
+			"focus-padding", &focus_pad,
+			"expander-size", &expander_size,
+			"expander-spacing", &expander_spacing,
+			NULL);
+
+  ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
+
+
+  if (ltr)
+    bounds.x = expander_spacing;
+  else
+    bounds.x = widget->allocation.width - 2 * border_width -
+	       expander_spacing - expander_size;
+
+  if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget))
+    {
+      GtkAllocation label_allocation;
+
+      label_allocation = priv->label_widget->allocation;
+
+      if (expander_size < label_allocation.height)
+	bounds.y = label_allocation.y + (label_allocation.height - expander_size) / 2;
+      else
+	bounds.y = priv->spacing + expander_spacing;
+    }
+  else
+    {
+      bounds.y = priv->spacing + expander_spacing;
+    }
+
+  if (!interior_focus)
+    {
+      if (ltr)
+	bounds.x += focus_width + focus_pad;
+      else
+	bounds.x -= focus_width + focus_pad;
+      bounds.y += focus_width + focus_pad;
+    }
+
+  bounds.width = bounds.height = expander_size;
+
+  return bounds;
+}
+
+static void
+e_expander_paint (EExpander *expander)
+{
+  GtkWidget *widget;
+  EExpanderPrivate *priv;
+  gint x, y;
+  GtkStateType state;
+  GdkRectangle clip;
+
+  widget = GTK_WIDGET (expander);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  clip = get_expander_bounds (expander);
+
+  x = clip.x + clip.width / 2;
+  y = clip.y + clip.height / 2;
+
+  state = widget->state;
+  if (state != GTK_STATE_PRELIGHT)
+    state = GTK_STATE_NORMAL;
+
+  gtk_paint_expander (widget->style,
+		      widget->window,
+		      state,
+		      &clip,
+		      widget,
+		      "expander",
+		      x,
+		      y,
+		      priv->expander_style);
+}
+
+static void
+e_expander_paint_focus (EExpander  *expander,
+			  GdkRectangle *area)
+{
+  GtkWidget *widget;
+  EExpanderPrivate *priv;
+  gint x, y, width, height;
+  gboolean interior_focus;
+  gint focus_width;
+  gint focus_pad;
+  gint expander_size;
+  gint expander_spacing;
+  gboolean ltr;
+
+  widget = GTK_WIDGET (expander);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  gtk_widget_style_get (widget,
+			"interior-focus", &interior_focus,
+			"focus-line-width", &focus_width,
+			"focus-padding", &focus_pad,
+			"expander-size", &expander_size,
+			"expander-spacing", &expander_spacing,
+			NULL);
+
+  ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
+
+  if (interior_focus)
+    {
+      if (ltr)
+	x = expander_spacing * 2 + expander_size;
+      else
+	x = 0;
+      y = priv->spacing;
+
+      width = height = 2 * focus_pad + 2 * focus_width;
+
+      if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget))
+	{
+	  GtkAllocation label_allocation = priv->label_widget->allocation;
+
+	  width  += label_allocation.width;
+	  height += label_allocation.height;
+	}
+    }
+  else
+    {
+      x = y = 0;
+      width = widget->allocation.width - 2 * GTK_CONTAINER (widget)->border_width;
+      height = widget->allocation.height - 2 * GTK_CONTAINER (widget)->border_width;
+    }
+
+  gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
+		   area, widget, "expander",
+		   x, y, width, height);
+}
+
+static gboolean
+e_expander_expose (GtkWidget      *widget,
+		     GdkEventExpose *event)
+{
+  if (GTK_WIDGET_DRAWABLE (widget))
+    {
+      EExpander *expander = E_EXPANDER (widget);
+      EExpanderPrivate *priv;
+
+      priv = E_EXPANDER_GET_PRIVATE (expander);
+
+      e_expander_paint (expander);
+
+      if (GTK_WIDGET_HAS_FOCUS (expander))
+	e_expander_paint_focus (expander, &event->area);
+
+      if (priv->label_widget)
+	gtk_container_propagate_expose (GTK_CONTAINER (widget),
+					priv->label_widget,
+					event);
+
+      GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
+    }
+
+  return FALSE;
+}
+
+static gboolean
+is_in_expander_panel (EExpander *expander,
+		      GdkWindow   *window,
+		      gint         x,
+		      gint         y)
+{
+  GtkWidget *widget;
+  GtkBin *bin;
+  GdkRectangle area;
+  gint border_width;
+
+  widget = GTK_WIDGET (expander);
+  bin = GTK_BIN (expander);
+
+  border_width = GTK_CONTAINER (expander)->border_width;
+
+  area = get_expander_bounds (expander);
+
+  area.x = 0;
+  area.width = widget->allocation.width;
+
+  if (widget->window == window)
+    {
+      if (x >= area.x && x <= (area.x + area.width) &&
+	  y >= area.y && y <= (area.y + area.height))
+	return TRUE;
+    }
+
+  return FALSE;
+}
+
+static gboolean
+e_expander_button_press (GtkWidget      *widget,
+			   GdkEventButton *event)
+{
+  EExpander *expander = E_EXPANDER (widget);
+  EExpanderPrivate *priv;
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (event->button == 1 && !priv->button_down)
+    {
+      if (is_in_expander_panel (expander, event->window, event->x, event->y))
+	{
+	  priv->button_down = TRUE;
+	  return TRUE;
+	}
+    }
+
+  return FALSE;
+}
+
+static gboolean
+e_expander_button_release (GtkWidget      *widget,
+                           GdkEventButton *event)
+{
+  EExpander *expander = E_EXPANDER (widget);
+  EExpanderPrivate *priv;
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (event->button == 1 && priv->button_down)
+    {
+      g_signal_emit_by_name (expander, "activate");
+      
+      priv->button_down = FALSE;
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+static void
+e_expander_maybe_prelight (EExpander *expander)
+{
+  GtkWidget *widget;
+  EExpanderPrivate *priv;
+  GtkStateType state = GTK_STATE_NORMAL;
+
+  widget = GTK_WIDGET (expander);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (!priv->button_down)
+    {
+      gint x, y;
+
+      gdk_window_get_pointer (widget->window, &x, &y, NULL);
+
+      if (is_in_expander_panel (expander, widget->window, x, y))
+	state = GTK_STATE_PRELIGHT;
+    }
+
+  gtk_widget_set_state (widget, state);
+}
+
+static gboolean
+e_expander_motion_notify (GtkWidget      *widget,
+			    GdkEventMotion *event)
+{
+  e_expander_maybe_prelight (E_EXPANDER (widget));
+
+  return FALSE;
+}
+
+static gboolean
+e_expander_enter_notify (GtkWidget        *widget,
+			   GdkEventCrossing *event)
+{
+  e_expander_maybe_prelight (E_EXPANDER (widget));
+
+  return FALSE;
+}
+
+static gboolean
+e_expander_leave_notify (GtkWidget        *widget,
+			   GdkEventCrossing *event)
+{
+  gtk_widget_set_state (widget, GTK_STATE_NORMAL);
+
+  return FALSE;
+}
+
+static gboolean
+focus_child_in (GtkWidget        *widget,
+		GtkDirectionType  direction)
+{
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+
+  if (!child)
+    return FALSE;
+
+  return gtk_widget_child_focus (child, direction);
+}
+
+static gboolean
+e_expander_focus (GtkWidget        *widget,
+		    GtkDirectionType  direction)
+{
+  EExpanderPrivate *priv;
+  GtkWidget *old_focus_child;
+  gboolean widget_is_focus;
+  gboolean label_can_focus;
+
+  priv = E_EXPANDER_GET_PRIVATE (widget);
+
+  widget_is_focus = gtk_widget_is_focus (widget);
+  old_focus_child = GTK_CONTAINER (widget)->focus_child;
+  label_can_focus = priv->label_widget && GTK_WIDGET_CAN_FOCUS (priv->label_widget);
+
+  if (old_focus_child && old_focus_child == priv->label_widget)
+    {
+      switch (direction)
+	{
+	case GTK_DIR_TAB_BACKWARD:
+	case GTK_DIR_LEFT:
+	case GTK_DIR_UP:
+	  gtk_widget_grab_focus (widget);
+	  return TRUE;
+	case GTK_DIR_DOWN:
+	case GTK_DIR_TAB_FORWARD:
+	case GTK_DIR_RIGHT:
+	  return focus_child_in (widget, direction);
+	}
+    }
+  else if (old_focus_child)
+    {
+      if (gtk_widget_child_focus (old_focus_child, direction))
+	return TRUE;
+
+      switch (direction)
+	{
+	case GTK_DIR_TAB_BACKWARD:
+	case GTK_DIR_LEFT:
+	case GTK_DIR_UP:
+	  if (label_can_focus)
+	    gtk_widget_grab_focus (priv->label_widget);
+	  else
+	    gtk_widget_grab_focus (widget);
+	  return TRUE;
+	case GTK_DIR_DOWN:
+	case GTK_DIR_TAB_FORWARD:
+	case GTK_DIR_RIGHT:
+	  return FALSE;
+	}
+    }
+  else if (widget_is_focus)
+    {
+      switch (direction)
+	{
+	case GTK_DIR_TAB_BACKWARD:
+	case GTK_DIR_LEFT:
+	case GTK_DIR_UP:
+	  return FALSE;
+	case GTK_DIR_DOWN:
+	case GTK_DIR_TAB_FORWARD:
+	case GTK_DIR_RIGHT:
+	  if (label_can_focus)
+	    {
+	      gtk_widget_grab_focus (priv->label_widget);
+	      return TRUE;
+	    }
+
+	  return focus_child_in (widget, direction);
+	}
+    }
+  else
+    {
+      switch (direction)
+	{
+	case GTK_DIR_DOWN:
+	case GTK_DIR_TAB_FORWARD:
+	case GTK_DIR_TAB_BACKWARD:
+	  gtk_widget_grab_focus (widget);
+	  return TRUE;
+	case GTK_DIR_UP:
+	case GTK_DIR_LEFT:
+	case GTK_DIR_RIGHT:
+	  if (!focus_child_in (widget, direction))
+	    {
+	      gtk_widget_grab_focus (widget);
+	    }
+	  return TRUE;
+	}
+    }
+
+  g_assert_not_reached ();
+  return FALSE;
+}
+
+static void
+e_expander_add (GtkContainer *container,
+		  GtkWidget    *widget)
+{
+  GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
+
+  g_object_set (G_OBJECT (widget),
+		"visible", E_EXPANDER_GET_PRIVATE (container)->expanded,
+		NULL);
+}
+
+static void
+e_expander_remove (GtkContainer *container,
+		     GtkWidget    *widget)
+{
+  EExpander *expander = E_EXPANDER (container);
+
+  if (E_EXPANDER_GET_PRIVATE (expander)->label_widget == widget)
+    e_expander_set_label_widget (expander, NULL);
+  else
+    GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
+}
+
+static void
+e_expander_forall (GtkContainer *container,
+		     gboolean      include_internals,
+		     GtkCallback   callback,
+		     gpointer      callback_data)
+{
+  GtkBin *bin = GTK_BIN (container);
+  EExpanderPrivate *priv;
+
+  priv = E_EXPANDER_GET_PRIVATE (container);
+
+  if (bin->child)
+    (* callback) (bin->child, callback_data);
+
+  if (priv->label_widget)
+    (* callback) (priv->label_widget, callback_data);
+}
+
+static void
+e_expander_activate (EExpander *expander)
+{
+  e_expander_set_expanded (expander,
+			     !E_EXPANDER_GET_PRIVATE (expander)->expanded);
+}
+
+GtkWidget *
+e_expander_new (const gchar *label)
+{
+  return g_object_new (GTK_TYPE_EXPANDER, "label", label, NULL);
+}
+
+GtkWidget *
+e_expander_new_with_mnemonic (const gchar *label)
+{
+  return g_object_new (GTK_TYPE_EXPANDER,
+		       "label", label,
+		       "use_underline", TRUE,
+		       NULL);
+}
+
+static gboolean
+e_expander_animation_timeout (EExpander *expander)
+{
+  EExpanderPrivate *priv;
+  GdkRectangle area;
+  gboolean finish = FALSE;
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (GTK_WIDGET_REALIZED (expander))
+    {
+      area = get_expander_bounds (expander);
+      gdk_window_invalidate_rect (GTK_WIDGET (expander)->window, &area, TRUE);
+    }
+
+  if (priv->expanded)
+    {
+      if (priv->expander_style == GTK_EXPANDER_COLLAPSED)
+	{
+	  priv->expander_style = GTK_EXPANDER_SEMI_EXPANDED;
+	}
+      else
+	{
+	  priv->expander_style = GTK_EXPANDER_EXPANDED;
+	  finish = TRUE;
+	}
+    }
+  else
+    {
+      if (priv->expander_style == GTK_EXPANDER_EXPANDED)
+	{
+	  priv->expander_style = GTK_EXPANDER_SEMI_COLLAPSED;
+	}
+      else
+	{
+	  priv->expander_style = GTK_EXPANDER_COLLAPSED;
+	  finish = TRUE;
+	}
+    }
+
+  if (finish)
+    {
+      priv->animation_timeout = 0;
+      g_object_set (G_OBJECT (GTK_BIN (expander)->child),
+		    "visible", priv->expanded,
+		    NULL);
+    }
+
+  return !finish;
+}
+
+static void
+e_expander_start_animation (EExpander *expander)
+{
+  EExpanderPrivate *priv;
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (priv->animation_timeout)
+    g_source_remove (priv->animation_timeout);
+
+  priv->animation_timeout =
+		g_timeout_add (50,
+			       (GSourceFunc) e_expander_animation_timeout,
+			       expander);
+}
+
+void
+e_expander_set_expanded (EExpander *expander,
+			   gboolean     expanded)
+{
+  EExpanderPrivate *priv;
+
+  g_return_if_fail (GTK_IS_EXPANDER (expander));
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  expanded = expanded != FALSE;
+
+  if (priv->expanded != expanded)
+    {
+      priv->expanded = expanded;
+
+      if (GTK_WIDGET_VISIBLE (expander))
+	e_expander_start_animation (expander);
+
+      else if (GTK_BIN (expander)->child)
+	{
+	  priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED :
+					    GTK_EXPANDER_COLLAPSED;
+	  g_object_set (G_OBJECT (GTK_BIN (expander)->child),
+			"visible", priv->expanded,
+			NULL);
+	}
+
+      gtk_widget_queue_resize (GTK_WIDGET (expander));
+
+      g_object_notify (G_OBJECT (expander), "expanded");
+    }
+}
+
+gboolean
+e_expander_get_expanded (EExpander *expander)
+{
+  g_return_val_if_fail (GTK_IS_EXPANDER (expander), FALSE);
+
+  return E_EXPANDER_GET_PRIVATE (expander)->expanded;
+}
+
+void
+e_expander_set_spacing (EExpander *expander,
+			  gint         spacing)
+{
+  EExpanderPrivate *priv;
+
+  g_return_if_fail (GTK_IS_EXPANDER (expander));
+  g_return_if_fail (spacing >= 0);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (priv->spacing != spacing)
+    {
+      priv->spacing = spacing;
+
+      gtk_widget_queue_resize (GTK_WIDGET (expander));
+
+      g_object_notify (G_OBJECT (expander), "spacing");
+    }
+}
+
+gint
+e_expander_get_spacing (EExpander *expander)
+{
+  g_return_val_if_fail (GTK_IS_EXPANDER (expander), 0);
+
+  return E_EXPANDER_GET_PRIVATE (expander)->spacing;
+}
+
+void
+e_expander_set_label (EExpander *expander,
+			const gchar *label)
+{
+  g_return_if_fail (GTK_IS_EXPANDER (expander));
+
+  if (!label)
+    {
+      e_expander_set_label_widget (expander, NULL);
+    }
+  else
+    {
+      GtkWidget *child;
+
+      child = gtk_label_new (label);
+      gtk_label_set_use_underline (GTK_LABEL (child),
+				   E_EXPANDER_GET_PRIVATE (expander)->use_underline);
+      gtk_widget_show (child);
+
+      e_expander_set_label_widget (expander, child);
+    }
+
+  g_object_notify (G_OBJECT (expander), "label");
+}
+
+/**
+ * e_expander_get_label:
+ * @expander: a #EExpander
+ *
+ * If the expander's label widget is a #GtkLabel, return the
+ * text in the label widget. (The frame will have a #GtkLabel
+ * for the label widget if a non-%NULL argument was passed
+ * to e_expander_new().)
+ *
+ * Return value: the text in the label, or %NULL if there
+ *               was no label widget or the lable widget was not
+ *               a #GtkLabel. This string is owned by GTK+ and
+ *               must not be modified or freed.
+ **/
+G_CONST_RETURN char *
+e_expander_get_label (EExpander *expander)
+{
+  EExpanderPrivate *priv;
+
+  g_return_val_if_fail (GTK_IS_EXPANDER (expander), NULL);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (priv->label_widget && GTK_IS_LABEL (priv->label_widget))
+    return gtk_label_get_text (GTK_LABEL (priv->label_widget));
+  else
+    return NULL;
+}
+
+void
+e_expander_set_use_underline (EExpander *expander,
+				gboolean     use_underline)
+{
+  EExpanderPrivate *priv;
+
+  g_return_if_fail (GTK_IS_EXPANDER (expander));
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  use_underline = use_underline != FALSE;
+
+  if (priv->use_underline != use_underline)
+    {
+      priv->use_underline = use_underline;
+
+      if (priv->label_widget && GTK_IS_LABEL (priv->label_widget))
+	gtk_label_set_use_underline (GTK_LABEL (priv->label_widget), use_underline);
+
+      g_object_notify (G_OBJECT (expander), "use_underline");
+    }
+}
+
+gboolean
+e_expander_get_use_underline (EExpander *expander)
+{
+  g_return_val_if_fail (GTK_IS_EXPANDER (expander), FALSE);
+
+  return E_EXPANDER_GET_PRIVATE (expander)->use_underline;
+}
+
+/**
+ * e_expander_set_label_widget:
+ * @expander: a #EExpander
+ * @label_widget: the new label widget
+ *
+ * Set the label widget for the expander. This is the widget
+ * that will appear embedded alongside the expander arrow.
+ **/
+void
+e_expander_set_label_widget (EExpander *expander,
+			       GtkWidget   *label_widget)
+{
+  EExpanderPrivate *priv;
+  gboolean need_resize = FALSE;
+
+  g_return_if_fail (GTK_IS_EXPANDER (expander));
+  g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
+  g_return_if_fail (label_widget == NULL || label_widget->parent == NULL);
+
+  priv = E_EXPANDER_GET_PRIVATE (expander);
+
+  if (priv->label_widget == label_widget)
+    return;
+
+  if (priv->label_widget)
+    {
+      need_resize = GTK_WIDGET_VISIBLE (priv->label_widget);
+      gtk_widget_unparent (priv->label_widget);
+    }
+
+  priv->label_widget = label_widget;
+
+  if (label_widget)
+    {
+      priv->label_widget = label_widget;
+      gtk_widget_set_parent (label_widget, GTK_WIDGET (expander));
+      need_resize |= GTK_WIDGET_VISIBLE (label_widget);
+    }
+
+  if (GTK_WIDGET_VISIBLE (expander) && need_resize)
+    gtk_widget_queue_resize (GTK_WIDGET (expander));
+
+  g_object_notify (G_OBJECT (expander), "label_widget");
+}
+
+/**
+ * e_expander_get_label_widget:
+ * @expander: a #EExpander
+ *
+ * Retrieves the label widget for the frame. See
+ * e_expander_set_label_widget().
+ *
+ * Return value: the label widget, or %NULL if there is none.
+ **/
+GtkWidget *
+e_expander_get_label_widget (EExpander *expander)
+{
+  g_return_val_if_fail (GTK_IS_EXPANDER (expander), NULL);
+
+  return E_EXPANDER_GET_PRIVATE (expander)->label_widget;
+}
Index: widgets/misc/e-expander.h
===================================================================
RCS file: widgets/misc/e-expander.h
diff -N widgets/misc/e-expander.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ widgets/misc/e-expander.h	23 Nov 2003 14:31:45 -0000
@@ -0,0 +1,82 @@
+/* GTK - The GIMP Toolkit
+ *
+ * Copyright (C) 2003 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *	Mark McLoughlin <mark skynet ie>
+ */
+
+#ifndef _E_EXPANDER_H_
+#define _E_EXPANDER_H_
+
+#include <gtk/gtkbin.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_EXPANDER            (e_expander_get_type ())
+#define E_EXPANDER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EXPANDER, EExpander))
+#define E_EXPANDER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_EXPANDER, EExpanderClass))
+#define GTK_IS_EXPANDER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EXPANDER))
+#define GTK_IS_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_EXPANDER))
+#define E_EXPANDER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_EXPANDER, EExpanderClass))
+/* ESTUFF #define E_EXPANDER_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_EXPANDER, EExpanderPrivate)) */
+
+typedef struct _EExpander      EExpander;
+typedef struct _EExpanderClass EExpanderClass;
+
+struct _EExpander
+{
+  GtkBin bin;
+};
+
+struct _EExpanderClass
+{
+  GtkBinClass parent_class;
+
+  void (* activate) (EExpander *expander);
+};
+
+GType                 e_expander_get_type          (void);
+
+GtkWidget            *e_expander_new               (const gchar *label);
+GtkWidget            *e_expander_new_with_mnemonic (const gchar *label);
+
+void                  e_expander_set_expanded      (EExpander   *expander,
+                                                    gboolean     expanded);
+gboolean              e_expander_get_expanded      (EExpander   *expander);
+
+/* Spacing between the expander/label and the child */
+void                  e_expander_set_spacing       (EExpander   *expander,
+						      gint       spacing);
+gint                  e_expander_get_spacing       (EExpander   *expander);
+
+void                  e_expander_set_label         (EExpander   *expander,
+                                                    const gchar *label);
+G_CONST_RETURN gchar *e_expander_get_label         (EExpander   *expander);
+
+void                  e_expander_set_use_underline (EExpander   *expander,
+                                                    gboolean     use_underline);
+gboolean              e_expander_get_use_underline (EExpander   *expander);
+
+void                  e_expander_set_label_widget  (EExpander   *expander,
+                                                    GtkWidget   *label_widget);
+GtkWidget            *e_expander_get_label_widget  (EExpander   *expander);
+
+G_END_DECLS
+
+#endif /* _E_EXPANDER_H_ */
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.582
diff -u -r1.582 ChangeLog
--- composer/ChangeLog	5 Nov 2003 00:44:28 -0000	1.582
+++ composer/ChangeLog	23 Nov 2003 14:31:46 -0000
@@ -1,3 +1,7 @@
+2003-11-23  ERDI Gergo  <cactus cactus rulez org>
+
+	* e-msg-composer.c: Implemented #127527
+
 2003-11-03  Not Zed  <NotZed Ximian com>
 
 	* e-msg-composer.c (build_message): changed to use ciphercontext
Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.423
diff -u -r1.423 e-msg-composer.c
--- composer/e-msg-composer.c	5 Nov 2003 00:44:28 -0000	1.423
+++ composer/e-msg-composer.c	23 Nov 2003 14:31:53 -0000
@@ -81,6 +81,7 @@
 
 #include "e-util/e-dialog-utils.h"
 #include "widgets/misc/e-charset-picker.h"
+#include "widgets/misc/e-expander.h"
 
 #include <camel/camel-session.h>
 #include <camel/camel-charset-map.h>
@@ -104,6 +105,8 @@
 
 #include "evolution-shell-component-utils.h"
 
+#include "art/attachment.xpm"
+
 #include "Editor.h"
 #include "listener.h"
 
@@ -1109,20 +1112,7 @@
 show_attachments (EMsgComposer *composer,
 		  gboolean show)
 {
-	if (show) {
-		gtk_widget_show (composer->attachment_scrolled_window);
-		gtk_widget_show (composer->attachment_bar);
-	} else {
-		gtk_widget_hide (composer->attachment_scrolled_window);
-		gtk_widget_hide (composer->attachment_bar);
-	}
-	
-	composer->attachment_bar_visible = show;
-	
-	/* Update the GUI.  */
-	bonobo_ui_component_set_prop (
-		composer->uic, "/commands/ViewAttach",
-		"state", show ? "1" : "0", NULL);
+	e_expander_set_expanded (E_EXPANDER (composer->attachment_expander), show);
 }
 
 static void
@@ -2194,15 +2184,26 @@
 attachment_bar_changed_cb (EMsgComposerAttachmentBar *bar,
 			   void *data)
 {
-	EMsgComposer *composer;
-	gboolean show = FALSE;
-	
-	composer = E_MSG_COMPOSER (data);
-	
-	if (e_msg_composer_attachment_bar_get_num_attachments (bar) > 0)
-		show = TRUE;
+	EMsgComposer *composer = E_MSG_COMPOSER (data);
+
+	guint attachment_num = e_msg_composer_attachment_bar_get_num_attachments (
+		E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar));
+	if (attachment_num)
+	{
+		gchar *num_text = g_strdup_printf (
+			ngettext ("<b>%d</b> File Attached", "<b>%d</b> Files Attached", attachment_num),
+			attachment_num);
+		gtk_label_set_markup (GTK_LABEL (composer->attachment_expander_num),
+				      num_text);
+		g_free (num_text);
+
+		gtk_widget_show (composer->attachment_expander_icon);
+		
+	} else {
+		gtk_label_set_text (GTK_LABEL (composer->attachment_expander_num), "");
+		gtk_widget_hide (composer->attachment_expander_icon);
+	}
 	
-	e_msg_composer_show_attachments (composer, show);
 	
 	/* Mark the composer as changed so it prompts about unsaved
            changes on close */
@@ -2210,6 +2211,27 @@
 }
 
 static void
+attachment_expander_activate_cb (EExpander *expander,
+				 void      *data)
+{
+	EMsgComposer *composer = E_MSG_COMPOSER (data);
+	gboolean show = e_expander_get_expanded (expander);
+	
+	/* Update the expander label */
+	if (show)
+		gtk_label_set_text_with_mnemonic (GTK_LABEL (composer->attachment_expander_label),
+						  _("Hide _Attachment Bar (drop attachments here)"));
+	else
+		gtk_label_set_text_with_mnemonic (GTK_LABEL (composer->attachment_expander_label),
+						  _("Show _Attachment Bar (drop attachments here)"));
+	
+	/* Update the GUI.  */
+	bonobo_ui_component_set_prop (
+		composer->uic, "/commands/ViewAttach",
+		"state", show ? "1" : "0", NULL);
+}
+
+static void
 subject_changed_cb (EMsgComposerHdrs *hdrs,
 		    gchar *subject,
 		    void *data)
@@ -2908,12 +2930,13 @@
 create_composer (int visible_mask)
 {
 	EMsgComposer *composer;
-	GtkWidget *vbox;
+	GtkWidget *vbox, *expander_hbox;
 	Bonobo_Unknown editor_server;
 	CORBA_Environment ev;
 	GConfClient *gconf;
 	int vis;
 	BonoboControlFrame *control_frame;
+	GdkPixbuf *attachment_pixbuf;
 	
 	composer = g_object_new (E_TYPE_MSG_COMPOSER, "win_name", _("Compose a message"), NULL);
 	gtk_window_set_title ((GtkWindow *) composer, _("Compose a message"));
@@ -3014,8 +3037,8 @@
 	
 	gtk_box_pack_start (GTK_BOX (vbox), composer->editor, TRUE, TRUE, 0);
 	
-	/* Attachment editor, wrapped into an EScrollFrame.  We don't
-           show it for now.  */
+	/* Attachment editor, wrapped into an EScrollFrame.  It's
+           hidden in an EExpander. */
 	
 	composer->attachment_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
 	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (composer->attachment_scrolled_window),
@@ -3027,12 +3050,43 @@
 	GTK_WIDGET_SET_FLAGS (composer->attachment_bar, GTK_CAN_FOCUS);
 	gtk_container_add (GTK_CONTAINER (composer->attachment_scrolled_window),
 			   composer->attachment_bar);
-	gtk_box_pack_start (GTK_BOX (vbox),
-			    composer->attachment_scrolled_window,
-			    FALSE, FALSE, GNOME_PAD_SMALL);
-	
+	gtk_widget_show (composer->attachment_bar);
 	g_signal_connect (composer->attachment_bar, "changed",
 			  G_CALLBACK (attachment_bar_changed_cb), composer);
+
+	composer->attachment_expander_label =
+		gtk_label_new_with_mnemonic (_("Show _Attachment Bar (drop attachments here)"));
+	composer->attachment_expander_num = gtk_label_new ("");
+	gtk_label_set_use_markup (GTK_LABEL (composer->attachment_expander_num), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (composer->attachment_expander_label), 0.0, 0.5);
+	gtk_misc_set_alignment (GTK_MISC (composer->attachment_expander_num), 1.0, 0.5);
+	expander_hbox = gtk_hbox_new (FALSE, 0);
+
+	attachment_pixbuf = gdk_pixbuf_new_from_xpm_data (attachment_xpm);
+	composer->attachment_expander_icon = gtk_image_new_from_pixbuf (attachment_pixbuf);
+	gtk_misc_set_alignment (GTK_MISC (composer->attachment_expander_icon), 1, 0.5);
+	gtk_widget_set_size_request (composer->attachment_expander_icon, 100, -1);
+	gdk_pixbuf_unref (attachment_pixbuf);	
+
+	gtk_box_pack_start (GTK_BOX (expander_hbox), composer->attachment_expander_label,
+			    TRUE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (expander_hbox), composer->attachment_expander_icon,
+			    TRUE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (expander_hbox), composer->attachment_expander_num,
+			    TRUE, TRUE, 0);
+	gtk_widget_show_all (expander_hbox);
+	gtk_widget_hide (composer->attachment_expander_icon);
+
+	composer->attachment_expander = e_expander_new ("");	
+	e_expander_set_label_widget (E_EXPANDER (composer->attachment_expander), expander_hbox);
+	
+	gtk_container_add (GTK_CONTAINER (composer->attachment_expander),
+			   composer->attachment_scrolled_window);
+	gtk_box_pack_start (GTK_BOX (vbox), composer->attachment_expander,
+			    FALSE, FALSE, GNOME_PAD_SMALL);
+	gtk_widget_show (composer->attachment_expander);
+	g_signal_connect_after (composer->attachment_expander, "activate",
+				G_CALLBACK (attachment_expander_activate_cb), composer);
 	
 	bonobo_window_set_contents (BONOBO_WINDOW (composer), vbox);
 	gtk_widget_show (vbox);
Index: composer/e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.85
diff -u -r1.85 e-msg-composer.h
--- composer/e-msg-composer.h	21 Oct 2003 18:51:16 -0000	1.85
+++ composer/e-msg-composer.h	23 Nov 2003 14:31:53 -0000
@@ -69,6 +69,10 @@
 	
 	GtkWidget *attachment_bar;
 	GtkWidget *attachment_scrolled_window;
+	GtkWidget *attachment_expander;
+	GtkWidget *attachment_expander_label;
+	GtkWidget *attachment_expander_icon;
+	GtkWidget *attachment_expander_num;
 	
 	GtkWidget *address_dialog;
 	


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]