aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/misc/ChangeLog6
-rw-r--r--widgets/misc/Makefile.am4
-rw-r--r--widgets/misc/e-cell-renderer-combo.c180
-rw-r--r--widgets/misc/e-cell-renderer-combo.h58
-rw-r--r--widgets/misc/e-combo-cell-editable.c423
-rw-r--r--widgets/misc/e-combo-cell-editable.h67
6 files changed, 738 insertions, 0 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 6f7aa62527..ddf64a7889 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,9 @@
+2003-09-30 Mike Kestner <mkestner@ximian.com>
+
+ * e-cell-renderer-combo.* : new, treeview renderer for combo cells
+ * e-combo-cell-editable.* : new, GtkCellEditable for combo cells
+ * Makefile.am : build the new files
+
2003-07-23 Dan Winship <danw@ximian.com>
* Makefile.am: use EVO_MARSHAL_RULE
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 072a785162..7efeebb86f 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -20,8 +20,10 @@ widgetsinclude_HEADERS = \
e-calendar-item.h \
e-cell-date-edit.h \
e-cell-percent.h \
+ e-cell-renderer-combo.h \
e-charset-picker.h \
e-clipped-label.h \
+ e-combo-cell-editable.h \
e-config-page.h \
e-combo-button.h \
e-dateedit.h \
@@ -38,8 +40,10 @@ libemiscwidgets_la_SOURCES = \
e-calendar-item.c \
e-cell-date-edit.c \
e-cell-percent.c \
+ e-cell-renderer-combo.c \
e-charset-picker.c \
e-clipped-label.c \
+ e-combo-cell-editable.c \
e-config-page.c \
e-combo-button.c \
e-dateedit.c \
diff --git a/widgets/misc/e-cell-renderer-combo.c b/widgets/misc/e-cell-renderer-combo.c
new file mode 100644
index 0000000000..8b4134fdce
--- /dev/null
+++ b/widgets/misc/e-cell-renderer-combo.c
@@ -0,0 +1,180 @@
+/*
+ * e-cell-renderer-combo.c
+ *
+ * Author: Mike Kestner <mkestner@ximian.com>
+ *
+ * Copyright (C) 2003 Ximian Inc.
+ *
+ * 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.
+ */
+
+#include <config.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtkarrow.h>
+#include <gtk/gtkbutton.h>
+#include <gal/util/e-util.h>
+
+#include "e-combo-cell-editable.h"
+#include "e-cell-renderer-combo.h"
+
+enum {
+ PROP_0,
+ PROP_LIST
+};
+
+struct _ECellRendererComboPriv {
+ EComboCellEditable *editable;
+ gchar *path;
+ GList *list;
+};
+
+static GtkCellRendererTextClass *parent_class;
+
+static void
+ecrc_editing_done (GtkCellEditable *editable, ECellRendererCombo *cell)
+{
+ const gchar *new_text;
+
+ if (e_combo_cell_editable_cancelled (E_COMBO_CELL_EDITABLE (editable)))
+ return;
+
+ new_text = e_combo_cell_editable_get_text (E_COMBO_CELL_EDITABLE (editable));
+
+ g_signal_emit_by_name (cell, "edited", cell->priv->path, new_text);
+ g_free (cell->priv->path);
+ cell->priv->path = NULL;
+}
+
+static GtkCellEditable *
+ecrc_start_editing (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path,
+ GdkRectangle *bg_area, GdkRectangle *cell_area, GtkCellRendererState flags)
+{
+ ECellRendererCombo *combo_cell = E_CELL_RENDERER_COMBO (cell);
+ GtkCellRendererText *text_cell = GTK_CELL_RENDERER_TEXT (cell);
+ EComboCellEditable *editable;
+
+ if (!text_cell->editable)
+ return NULL;
+
+ editable = E_COMBO_CELL_EDITABLE (e_combo_cell_editable_new ());
+ e_combo_cell_editable_set_text (editable, text_cell->text);
+ e_combo_cell_editable_set_list (editable, combo_cell->priv->list);
+ gtk_widget_show (GTK_WIDGET (editable));
+
+ g_signal_connect (editable, "editing-done", G_CALLBACK (ecrc_editing_done), combo_cell);
+
+ combo_cell->priv->editable = g_object_ref (editable);
+ combo_cell->priv->path = g_strdup (path);
+
+ return GTK_CELL_EDITABLE (editable);
+}
+
+static void
+ecrc_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area,
+ gint *x_offset, gint *y_offset, gint *width, gint *height)
+{
+ GtkWidget *btn;
+ GtkRequisition req;
+
+ if (GTK_CELL_RENDERER_CLASS (parent_class)->get_size)
+ GTK_CELL_RENDERER_CLASS (parent_class)->get_size (cell, widget, cell_area, x_offset, y_offset, width, height);
+
+ btn = gtk_button_new ();
+ gtk_container_add (GTK_CONTAINER (btn), gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT));
+ gtk_widget_size_request (btn, &req);
+ *width += req.width;
+ gtk_widget_destroy (btn);
+}
+
+static void
+ecrc_get_prop (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ ECellRendererCombo *ecrc = E_CELL_RENDERER_COMBO (object);
+
+ switch (prop_id) {
+ case PROP_LIST:
+ g_value_set_pointer (value, ecrc->priv->list);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+ecrc_set_prop (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ ECellRendererCombo *ecrc = E_CELL_RENDERER_COMBO (object);
+
+ switch (prop_id) {
+ case PROP_LIST:
+ ecrc->priv->list = g_value_get_pointer (value);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+ecrc_finalize (GObject *obj)
+{
+ ECellRendererCombo *cell = (ECellRendererCombo *) obj;
+
+ if (cell->priv->editable)
+ g_object_unref (cell->priv->editable);
+ cell->priv->editable = NULL;
+
+ if (cell->priv->path)
+ g_free (cell->priv->path);
+ cell->priv->path = NULL;
+
+ g_free (cell->priv);
+
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+ecrc_init (ECellRendererCombo *cell)
+{
+ cell->priv = g_new0 (ECellRendererComboPriv, 1);
+}
+
+static void
+ecrc_class_init (ECellRendererComboClass *class)
+{
+ GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
+ GObjectClass *obj_class = G_OBJECT_CLASS (class);
+
+ parent_class = GTK_CELL_RENDERER_TEXT_CLASS (g_type_class_peek_parent (class));
+
+ obj_class->get_property = ecrc_get_prop;
+ obj_class->set_property = ecrc_set_prop;
+ obj_class->finalize = ecrc_finalize;
+
+ cell_class->start_editing = ecrc_start_editing;
+ cell_class->get_size = ecrc_get_size;
+
+ g_object_class_install_property (obj_class, PROP_LIST,
+ g_param_spec_pointer ("list", "List", "List of items to popup.", G_PARAM_READWRITE));
+}
+
+E_MAKE_TYPE (e_cell_renderer_combo, "ECellRendererCombo", ECellRendererCombo, ecrc_class_init, ecrc_init, GTK_TYPE_CELL_RENDERER_TEXT)
+
+GtkCellRenderer *
+e_cell_renderer_combo_new (void)
+{
+ return GTK_CELL_RENDERER (g_object_new (E_TYPE_CELL_RENDERER_COMBO, NULL));
+}
+
diff --git a/widgets/misc/e-cell-renderer-combo.h b/widgets/misc/e-cell-renderer-combo.h
new file mode 100644
index 0000000000..bed1d34a09
--- /dev/null
+++ b/widgets/misc/e-cell-renderer-combo.h
@@ -0,0 +1,58 @@
+/*
+ * e-cell-renderer-combo.h
+ *
+ * Author: Mike Kestner <mkestner@ximian.com>
+ *
+ * Copyright (C) 2003 Ximian Inc.
+ *
+ * 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.
+ */
+
+#ifndef __E_CELL_RENDERER_COMBO_H__
+#define __E_CELL_RENDERER_COMBO_H__
+
+#include <gtk/gtkcellrenderertext.h>
+
+G_BEGIN_DECLS
+
+#define E_TYPE_CELL_RENDERER_COMBO (e_cell_renderer_combo_get_type ())
+#define E_CELL_RENDERER_COMBO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_CELL_RENDERER_COMBO, ECellRendererCombo))
+#define E_CELL_RENDERER_COMBO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_CELL_RENDERER_COMBO, ECellRendererComboClass))
+#define E_IS_CELL_RENDERER_COMBO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_CELL_RENDERER_COMBO))
+#define E_IS_CELL_RENDERER_COMBO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((o), E_TYPE_CELL_RENDERER_COMBO))
+#define E_CELL_RENDERER_COMBO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_TYPE_CELL_RENDERER_COMBO, ECellRendererComboClass))
+
+typedef struct _ECellRendererCombo ECellRendererCombo;
+typedef struct _ECellRendererComboClass ECellRendererComboClass;
+typedef struct _ECellRendererComboPriv ECellRendererComboPriv;
+
+struct _ECellRendererCombo
+{
+ GtkCellRendererText parent;
+
+ ECellRendererComboPriv *priv;
+};
+
+struct _ECellRendererComboClass
+{
+ GtkCellRendererTextClass parent_class;
+};
+
+GType e_cell_renderer_combo_get_type (void);
+GtkCellRenderer *e_cell_renderer_combo_new (void);
+
+G_END_DECLS
+
+#endif /* __E_CELL_RENDERER_COMBO_H__ */
diff --git a/widgets/misc/e-combo-cell-editable.c b/widgets/misc/e-combo-cell-editable.c
new file mode 100644
index 0000000000..f8de7c9ebc
--- /dev/null
+++ b/widgets/misc/e-combo-cell-editable.c
@@ -0,0 +1,423 @@
+/*
+ * e-combo-cell-editable.c
+ *
+ * Author: Mike Kestner <mkestner@ximian.com>
+ *
+ * Copyright (C) 2003 Ximian Inc.
+ *
+ * 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.
+ */
+
+#include <config.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkarrow.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkcelleditable.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkframe.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkliststore.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtktreeselection.h>
+#include <gtk/gtktreeview.h>
+#include <gtk/gtkwindow.h>
+
+#include "e-combo-cell-editable.h"
+
+struct _EComboCellEditablePriv {
+ GtkEntry *entry;
+ GtkWidget *popup;
+ GtkTreeView *tree_view;
+ gboolean cancelled;
+ GList *list;
+};
+
+#define GRAB_MASK (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK)
+
+static GtkEventBoxClass *parent_class;
+
+static void
+kill_popup (EComboCellEditable *ecce)
+{
+ gtk_grab_remove (GTK_WIDGET (ecce->priv->tree_view));
+ gtk_widget_destroy (ecce->priv->popup);
+
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (ecce));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (ecce));
+}
+
+static gboolean
+popup_key_press_cb (GtkWidget *widget, GdkEventKey *event, EComboCellEditable *ecce)
+{
+ switch (event->keyval) {
+ case GDK_Escape:
+ ecce->priv->cancelled = TRUE;
+ kill_popup (ecce);
+ break;
+
+ case GDK_Return:
+ case GDK_KP_Enter:
+ ecce->priv->cancelled = FALSE;
+ kill_popup (ecce);
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+popup_button_press_cb (GtkWidget *widget, GdkEventButton *event, EComboCellEditable *ecce)
+{
+ GtkAllocation alloc;
+ gdouble rel_x, rel_y;
+ gint win_x, win_y;
+
+ if (event->button != 1)
+ return FALSE;
+
+ gdk_window_get_root_origin (widget->window, &win_x, &win_y);
+ alloc = ecce->priv->popup->allocation;
+
+ rel_x = event->x_root - win_x - alloc.x;
+ rel_y = event->y_root - win_y - alloc.y;
+
+ if (rel_x > 0 && rel_x < alloc.width && rel_y > 0 && rel_y < alloc.height)
+ return FALSE;
+
+ ecce->priv->cancelled = TRUE;
+ kill_popup (ecce);
+
+ return FALSE;
+}
+
+static gboolean
+tree_button_release_cb (GtkWidget *widget, GdkEventButton *event, EComboCellEditable *ecce)
+{
+ kill_popup (ecce);
+ return TRUE;
+}
+
+static void
+selection_changed_cb (GtkTreeSelection *selection, EComboCellEditable *ecce)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *text;
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter, 0, &text, -1);
+ e_combo_cell_editable_set_text (ecce, text);
+ g_free (text);
+}
+
+static void
+build_popup (EComboCellEditable *ecce)
+{
+ GtkWidget *frame;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GList *l;
+
+ ecce->priv->popup = gtk_window_new (GTK_WINDOW_POPUP);
+
+ g_signal_connect (ecce->priv->popup, "button-press-event", G_CALLBACK (popup_button_press_cb), ecce);
+ g_signal_connect (ecce->priv->popup, "key-press-event", G_CALLBACK (popup_key_press_cb), ecce);
+
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+ gtk_widget_show (frame);
+ gtk_container_add (GTK_CONTAINER (ecce->priv->popup), frame);
+
+ ecce->priv->tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
+ model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
+
+ for (l = ecce->priv->list; l; l = l->next) {
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, l->data, -1);
+ }
+
+ gtk_tree_view_set_model (ecce->priv->tree_view, model);
+ g_object_unref (model);
+ gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (ecce->priv->tree_view));
+
+ gtk_tree_view_set_headers_visible (ecce->priv->tree_view, FALSE);
+
+ gtk_tree_view_insert_column_with_attributes (ecce->priv->tree_view, 0, NULL,
+ gtk_cell_renderer_text_new (),
+ "text", 0,
+ NULL);
+
+ g_signal_connect (ecce->priv->tree_view, "button-release-event", G_CALLBACK (tree_button_release_cb), ecce);
+
+ selection = gtk_tree_view_get_selection (ecce->priv->tree_view);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ g_signal_connect (selection, "changed", G_CALLBACK (selection_changed_cb), ecce);
+
+ gtk_widget_show (GTK_WIDGET (ecce->priv->tree_view));
+}
+
+static gint
+lookup_row (GList *list, const gchar *text)
+{
+ GList *l;
+ gint result = 0;
+
+ for (l = list; l; l = l->next, result++)
+ if (!g_utf8_collate (text, (char *) l->data))
+ break;
+
+ return result;
+}
+
+static void
+set_cursor (GtkTreeView *tree_view, gint index)
+{
+ GtkTreePath *path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, index);
+
+ gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE);
+
+ gtk_tree_path_free (path);
+}
+
+static void
+grab_popup (GdkWindow *popup)
+{
+ gdk_pointer_grab (popup, TRUE, GRAB_MASK, NULL, NULL, gtk_get_current_event_time ());
+ gdk_keyboard_grab (popup, TRUE, gtk_get_current_event_time ());
+}
+
+static void
+position_popup (EComboCellEditable *ecce, gint x, gint y, gint offset)
+{
+ GtkRequisition req;
+
+ gtk_widget_realize (ecce->priv->popup);
+ gtk_widget_size_request (ecce->priv->popup, &req);
+
+ if (req.height > gdk_screen_height () - y) {
+ y -= (offset + req.height);
+ if (y < 0)
+ y = 0;
+ }
+
+ gtk_window_move (GTK_WINDOW (ecce->priv->popup), x, y);
+ gtk_widget_show (ecce->priv->popup);
+}
+
+static void
+show_popup (EComboCellEditable *ecce, gint x, gint y, gint offset)
+{
+ gint row;
+
+ if (!ecce->priv->list)
+ return;
+
+ build_popup (ecce);
+ row = lookup_row (ecce->priv->list, e_combo_cell_editable_get_text (ecce));
+ set_cursor (ecce->priv->tree_view, row);
+
+ position_popup (ecce, x, y, offset);
+
+ gtk_grab_add (GTK_WIDGET (ecce->priv->popup));
+ gtk_widget_grab_focus (GTK_WIDGET (ecce->priv->tree_view));
+ grab_popup (GTK_WIDGET (ecce->priv->popup)->window);
+}
+
+static void
+button_clicked_cb (GtkButton *btn, EComboCellEditable *ecce)
+{
+ GtkAllocation alloc;
+ gint x, y;
+
+ if (ecce->priv->popup) {
+ kill_popup (ecce);
+ return;
+ }
+
+ gtk_editable_select_region (GTK_EDITABLE (ecce->priv->entry), 0, 0);
+
+ gdk_window_get_origin (GTK_WIDGET (ecce)->window, &x, &y);
+
+ alloc = GTK_WIDGET (ecce)->allocation;
+
+ show_popup (ecce, x, y + alloc.height, alloc.height);
+}
+
+static void
+entry_activated_cb (GtkEntry *entry, EComboCellEditable *widget)
+{
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget));
+}
+
+static gboolean
+entry_key_press_event_cb (GtkEntry *entry, GdkEventKey *key_event, EComboCellEditable *ecce)
+{
+ if (key_event->keyval == GDK_Escape) {
+ ecce->priv->cancelled = TRUE;
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (ecce));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (ecce));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+ecce_start_editing (GtkCellEditable *cell_editable, GdkEvent *event)
+{
+ EComboCellEditable *ecce = E_COMBO_CELL_EDITABLE (cell_editable);
+
+ gtk_editable_select_region (GTK_EDITABLE (ecce->priv->entry), 0, -1);
+}
+
+static void
+ecce_cell_editable_init (GtkCellEditableIface *iface)
+{
+ iface->start_editing = ecce_start_editing;
+}
+
+static void
+ecce_finalize (GObject *obj)
+{
+ EComboCellEditable *ecce = (EComboCellEditable *) obj;
+
+ g_free (ecce->priv);
+
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+ecce_init (EComboCellEditable *ecce)
+{
+ GtkWidget *entry, *btn, *box;
+
+ box = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (box);
+ gtk_container_add (GTK_CONTAINER (ecce), box);
+
+ ecce->priv = g_new0 (EComboCellEditablePriv, 1);
+
+ entry = gtk_entry_new ();
+ ecce->priv->entry = GTK_ENTRY (entry);
+ gtk_entry_set_has_frame (ecce->priv->entry, FALSE);
+ gtk_entry_set_editable (ecce->priv->entry, FALSE);
+ g_signal_connect (entry, "activate", G_CALLBACK (entry_activated_cb), ecce);
+ g_signal_connect (entry, "key_press_event", G_CALLBACK (entry_key_press_event_cb), ecce);
+ gtk_widget_show (entry);
+ gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 0);
+
+ btn = gtk_button_new ();
+ gtk_container_add (GTK_CONTAINER (btn), gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT));
+ g_signal_connect (btn, "clicked", (GCallback) button_clicked_cb, ecce);
+ gtk_widget_show_all (btn);
+ gtk_box_pack_start (GTK_BOX (box), btn, FALSE, TRUE, 0);
+}
+
+static void
+ecce_class_init (GObjectClass *klass)
+{
+ klass->finalize = ecce_finalize;
+
+ parent_class = GTK_EVENT_BOX_CLASS (g_type_class_peek_parent (klass));
+}
+
+GType
+e_combo_cell_editable_get_type (void)
+{
+ static GType ecce_type = 0;
+
+ if (!ecce_type) {
+ static const GTypeInfo ecce_info = {
+ sizeof (EComboCellEditableClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) ecce_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (EComboCellEditable),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) ecce_init,
+ };
+
+ static const GInterfaceInfo cell_editable_info = {
+ (GInterfaceInitFunc) ecce_cell_editable_init,
+ NULL,
+ NULL
+ };
+
+ ecce_type = g_type_register_static (GTK_TYPE_EVENT_BOX, "EComboCellEditable", &ecce_info, 0);
+
+ g_type_add_interface_static (ecce_type, GTK_TYPE_CELL_EDITABLE, &cell_editable_info);
+ }
+
+ return ecce_type;
+}
+
+GtkCellEditable *
+e_combo_cell_editable_new ()
+{
+ return GTK_CELL_EDITABLE (g_object_new (E_TYPE_COMBO_CELL_EDITABLE, NULL));
+}
+
+const GList *
+e_combo_cell_editable_get_list (EComboCellEditable *ecce)
+{
+ g_return_val_if_fail (E_COMBO_CELL_EDITABLE (ecce), NULL);
+
+ return ecce->priv->list;
+}
+
+void
+e_combo_cell_editable_set_list (EComboCellEditable *ecce, GList *list)
+{
+ g_return_if_fail (E_IS_COMBO_CELL_EDITABLE (ecce));
+
+ ecce->priv->list = list;
+}
+
+const gchar *
+e_combo_cell_editable_get_text (EComboCellEditable *ecce)
+{
+ g_return_val_if_fail (E_COMBO_CELL_EDITABLE (ecce), NULL);
+
+ return gtk_entry_get_text (ecce->priv->entry);
+}
+
+void
+e_combo_cell_editable_set_text (EComboCellEditable *ecce, const gchar *text)
+{
+ g_return_if_fail (E_IS_COMBO_CELL_EDITABLE (ecce));
+
+ gtk_entry_set_text (ecce->priv->entry, text ? text : "");
+}
+
+gboolean
+e_combo_cell_editable_cancelled (EComboCellEditable *ecce)
+{
+ g_return_val_if_fail (E_IS_COMBO_CELL_EDITABLE (ecce), FALSE);
+
+ return ecce->priv->cancelled;
+}
+
diff --git a/widgets/misc/e-combo-cell-editable.h b/widgets/misc/e-combo-cell-editable.h
new file mode 100644
index 0000000000..aa9100d829
--- /dev/null
+++ b/widgets/misc/e-combo-cell-editable.h
@@ -0,0 +1,67 @@
+/*
+ * e-combo-cell-editable.h
+ *
+ * Author: Mike Kestner <mkestner@ximian.com>
+ *
+ * Copyright (C) 2003 Ximian Inc.
+ *
+ * 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.
+ */
+
+#ifndef __E_COMBO_CELL_EDITABLE_H__
+#define __E_COMBO_CELL_EDITABLE_H__
+
+#include <gtk/gtkeventbox.h>
+
+G_BEGIN_DECLS
+
+#define E_TYPE_COMBO_CELL_EDITABLE (e_combo_cell_editable_get_type ())
+#define E_COMBO_CELL_EDITABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_COMBO_CELL_EDITABLE, EComboCellEditable))
+#define E_COMBO_CELL_EDITABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_COMBO_CELL_EDITABLE, EComboCellEditableClass))
+#define E_IS_COMBO_CELL_EDITABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_COMBO_CELL_EDITABLE))
+#define E_IS_COMBO_CELL_EDITABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((o), E_TYPE_COMBO_CELL_EDITABLE))
+#define E_COMBO_CELL_EDITABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_TYPE_COMBO_CELL_EDITABLE, EComboCellEditableClass))
+
+typedef struct _EComboCellEditable EComboCellEditable;
+typedef struct _EComboCellEditableClass EComboCellEditableClass;
+typedef struct _EComboCellEditablePriv EComboCellEditablePriv;
+
+struct _EComboCellEditable
+{
+ GtkEventBox parent;
+
+ EComboCellEditablePriv *priv;
+};
+
+struct _EComboCellEditableClass
+{
+ GtkEventBoxClass parent_class;
+};
+
+GType e_combo_cell_editable_get_type (void);
+
+GtkCellEditable *e_combo_cell_editable_new (void);
+
+const GList *e_combo_cell_editable_get_list (EComboCellEditable *editable);
+void e_combo_cell_editable_set_list (EComboCellEditable *editable, GList *list);
+
+const gchar *e_combo_cell_editable_get_text (EComboCellEditable *editable);
+void e_combo_cell_editable_set_text (EComboCellEditable *editable, const gchar *text);
+
+gboolean e_combo_cell_editable_cancelled (EComboCellEditable *editable);
+
+G_END_DECLS
+
+#endif /* __E_COMBO_CELL_EDITABLE_H__ */