aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-01-11 05:22:22 +0800
committerMilan Crha <mcrha@redhat.com>2012-01-11 05:22:22 +0800
commitdd49067b2acfb72419f97a0348dc2524c3bbf56e (patch)
tree5109e71f41723545a5a5f9245947324f15635165
parent73fe6fb330ac9fab009d2bcb5766a2b908a201c7 (diff)
downloadgsoc2013-evolution-dd49067b2acfb72419f97a0348dc2524c3bbf56e.tar.gz
gsoc2013-evolution-dd49067b2acfb72419f97a0348dc2524c3bbf56e.tar.zst
gsoc2013-evolution-dd49067b2acfb72419f97a0348dc2524c3bbf56e.zip
Bug #667119 - Hard to change Attendee role in meeting editor
-rw-r--r--calendar/gui/e-meeting-list-view.c44
-rw-r--r--widgets/misc/Makefile.am4
-rw-r--r--widgets/misc/e-cell-renderer-combo.c202
-rw-r--r--widgets/misc/e-cell-renderer-combo.h59
-rw-r--r--widgets/misc/e-combo-cell-editable.c435
-rw-r--r--widgets/misc/e-combo-cell-editable.h68
6 files changed, 35 insertions, 777 deletions
diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c
index c27697b40f..cd2e7fbcfd 100644
--- a/calendar/gui/e-meeting-list-view.c
+++ b/calendar/gui/e-meeting-list-view.c
@@ -37,7 +37,6 @@
#include "calendar-config.h"
#include "e-meeting-list-view.h"
#include "itip-utils.h"
-#include <misc/e-cell-renderer-combo.h>
#include <libebook/e-destination.h>
#include "e-select-names-renderer.h"
@@ -557,6 +556,37 @@ editing_started_cb (GtkCellRenderer *renderer,
g_signal_connect (editable, "updated", G_CALLBACK(ense_update), NULL);
}
+static GtkCellRenderer *
+create_combo_cell_renderer (GList *strings)
+{
+ GList *li;
+ GtkTreeIter iter;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+ for (li = strings; li; li = li->next) {
+ const gchar *str = li->data;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, str, -1);
+ }
+
+ renderer = gtk_cell_renderer_combo_new ();
+
+ g_object_set (G_OBJECT (renderer),
+ "has-entry", FALSE,
+ "editable", TRUE,
+ "model", GTK_TREE_MODEL (store),
+ "text-column", 0,
+ NULL);
+
+ g_object_unref (store);
+ g_list_free (strings);
+
+ return renderer;
+}
+
static void
build_table (EMeetingListView *lview)
{
@@ -593,8 +623,7 @@ build_table (EMeetingListView *lview)
g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_ATTENDEE_COL), renderer);
- renderer = e_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (renderer), "list", get_type_strings (), "editable", TRUE, NULL);
+ renderer = create_combo_cell_renderer (get_type_strings ());
pos = gtk_tree_view_insert_column_with_attributes (view, -1, _("Type"), renderer,
"text", E_MEETING_STORE_TYPE_COL,
NULL);
@@ -605,8 +634,7 @@ build_table (EMeetingListView *lview)
g_signal_connect (renderer, "edited", G_CALLBACK (type_edited_cb), view);
g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_TYPE_COL), renderer);
- renderer = e_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (renderer), "list", get_role_strings (), "editable", TRUE, NULL);
+ renderer = create_combo_cell_renderer (get_role_strings ());
pos = gtk_tree_view_insert_column_with_attributes (view, -1, _("Role"), renderer,
"text", E_MEETING_STORE_ROLE_COL,
NULL);
@@ -617,8 +645,7 @@ build_table (EMeetingListView *lview)
g_signal_connect (renderer, "edited", G_CALLBACK (role_edited_cb), view);
g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_ROLE_COL), renderer);
- renderer = e_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (renderer), "list", get_rsvp_strings (), "editable", TRUE, NULL);
+ renderer = create_combo_cell_renderer (get_rsvp_strings ());
/* To translators: RSVP means "please reply" */
pos = gtk_tree_view_insert_column_with_attributes (view, -1, _("RSVP"), renderer,
"text", E_MEETING_STORE_RSVP_COL,
@@ -630,8 +657,7 @@ build_table (EMeetingListView *lview)
g_signal_connect (renderer, "edited", G_CALLBACK (rsvp_edited_cb), view);
g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_RSVP_COL), renderer);
- renderer = e_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (renderer), "list", get_status_strings (), "editable", TRUE, NULL);
+ renderer = create_combo_cell_renderer (get_status_strings ());
pos = gtk_tree_view_insert_column_with_attributes (view, -1, _("Status"), renderer,
"text", E_MEETING_STORE_STATUS_COL,
NULL);
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 71194d17ad..24495ed2cb 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -29,9 +29,7 @@ widgetsinclude_HEADERS = \
e-canvas-background.h \
e-canvas-utils.h \
e-canvas-vbox.h \
- e-cell-renderer-combo.h \
e-charset-combo-box.h \
- e-combo-cell-editable.h \
e-contact-map.h \
e-contact-map-window.h \
e-contact-marker.h \
@@ -112,9 +110,7 @@ libemiscwidgets_la_SOURCES = \
e-canvas-background.c \
e-canvas-utils.c \
e-canvas-vbox.c \
- e-cell-renderer-combo.c \
e-charset-combo-box.c \
- e-combo-cell-editable.c \
e-contact-map.c \
e-contact-map-window.c \
e-contact-marker.c \
diff --git a/widgets/misc/e-cell-renderer-combo.c b/widgets/misc/e-cell-renderer-combo.c
deleted file mode 100644
index 07382b9225..0000000000
--- a/widgets/misc/e-cell-renderer-combo.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Mike Kestner <mkestner@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#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;
-};
-
-G_DEFINE_TYPE (
- ECellRendererCombo,
- e_cell_renderer_combo,
- GTK_TYPE_CELL_RENDERER_TEXT)
-
-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,
- const GdkRectangle *bg_area,
- const GdkRectangle *cell_area,
- GtkCellRendererState flags)
-{
- ECellRendererCombo *combo_cell = E_CELL_RENDERER_COMBO (cell);
- GtkCellRendererText *text_cell = GTK_CELL_RENDERER_TEXT (cell);
- EComboCellEditable *editable;
- gboolean is_editable;
- gchar *text;
-
- g_object_get (text_cell, "editable", &is_editable, NULL);
-
- if (!is_editable)
- return NULL;
-
- g_object_get (text_cell, "text", &text, NULL);
-
- editable = E_COMBO_CELL_EDITABLE (e_combo_cell_editable_new ());
- e_combo_cell_editable_set_text (editable, text);
- e_combo_cell_editable_set_list (editable, combo_cell->priv->list);
- gtk_widget_show (GTK_WIDGET (editable));
-
- g_free (text);
-
- 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,
- const GdkRectangle *cell_area,
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height)
-{
- GtkWidget *btn;
- GtkRequisition req;
-
- if (GTK_CELL_RENDERER_CLASS (e_cell_renderer_combo_parent_class)->get_size)
- GTK_CELL_RENDERER_CLASS (e_cell_renderer_combo_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_NONE));
- gtk_widget_get_preferred_size (btn, &req, NULL);
- *width += req.width;
- gtk_widget_destroy (btn);
-}
-
-static void
-ecrc_get_prop (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ECellRendererCombo *ecrc = E_CELL_RENDERER_COMBO (object);
-
- switch (property_id) {
- case PROP_LIST:
- g_value_set_pointer (value, ecrc->priv->list);
- break;
- default:
- break;
- }
-}
-
-static void
-ecrc_set_prop (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- ECellRendererCombo *ecrc = E_CELL_RENDERER_COMBO (object);
-
- switch (property_id) {
- case PROP_LIST:
- ecrc->priv->list = g_value_get_pointer (value);
- break;
- default:
- break;
- }
-}
-
-static void
-ecrc_finalize (GObject *object)
-{
- ECellRendererCombo *cell = (ECellRendererCombo *) object;
-
- 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);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_cell_renderer_combo_parent_class)->finalize (object);
-}
-
-static void
-e_cell_renderer_combo_init (ECellRendererCombo *cell)
-{
- cell->priv = g_new0 (ECellRendererComboPriv, 1);
-}
-
-static void
-e_cell_renderer_combo_class_init (ECellRendererComboClass *class)
-{
- GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
- GObjectClass *obj_class = G_OBJECT_CLASS (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));
-}
-
-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
deleted file mode 100644
index 515ed75256..0000000000
--- a/widgets/misc/e-cell-renderer-combo.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Mike Kestner <mkestner@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __E_CELL_RENDERER_COMBO_H__
-#define __E_CELL_RENDERER_COMBO_H__
-
-#include <gtk/gtk.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
deleted file mode 100644
index 00a8382833..0000000000
--- a/widgets/misc/e-combo-cell-editable.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Mike Kestner <mkestner@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gdk/gdkkeysyms.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)
-
-/* Forward Declarations */
-static void e_combo_cell_editable_interface_init
- (GtkCellEditableIface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EComboCellEditable,
- e_combo_cell_editable,
- GTK_TYPE_EVENT_BOX,
- G_IMPLEMENT_INTERFACE (
- GTK_TYPE_CELL_EDITABLE,
- e_combo_cell_editable_interface_init))
-
-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_KEY_Escape:
- ecce->priv->cancelled = TRUE;
- kill_popup (ecce);
- break;
-
- case GDK_KEY_Return:
- case GDK_KEY_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;
- GdkWindow *window;
- gdouble rel_x, rel_y;
- gint win_x, win_y;
-
- if (event->button != 1)
- return FALSE;
-
- window = gtk_widget_get_window (widget);
- gdk_window_get_root_origin (window, &win_x, &win_y);
- gtk_widget_get_allocation (ecce->priv->popup, &alloc);
-
- 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);
- gtk_window_set_type_hint (GTK_WINDOW (ecce->priv->popup), GDK_WINDOW_TYPE_HINT_COMBO);
- 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, (gchar *) 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_get_preferred_size (ecce->priv->popup, &req, NULL);
-
- 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 row;
- GtkAllocation alloc;
- GdkWindow *window;
- gint x, y;
-
- 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);
-
- gtk_editable_select_region (GTK_EDITABLE (ecce->priv->entry), 0, 0);
-
- window = gtk_widget_get_window (GTK_WIDGET (ecce));
- gtk_widget_get_allocation (GTK_WIDGET (ecce), &alloc);
- gdk_window_get_origin (window, &x, &y);
-
- position_popup (ecce, x, y + alloc.height, alloc.height);
-
- gtk_grab_add (ecce->priv->popup);
- gtk_widget_grab_focus (GTK_WIDGET (ecce->priv->tree_view));
-
- window = gtk_widget_get_window (ecce->priv->popup);
- grab_popup (window);
-}
-
-static void
-button_clicked_cb (GtkButton *btn,
- EComboCellEditable *ecce)
-{
- if (ecce->priv->popup) {
- kill_popup (ecce);
- return;
- }
-
- show_popup (ecce);
-}
-
-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_KEY_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;
- }
-
- if (key_event->state & GDK_MOD1_MASK
- && key_event->keyval == GDK_KEY_Down) {
- if (!ecce->priv->popup)
- show_popup (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
-e_combo_cell_editable_interface_init (GtkCellEditableIface *interface)
-{
- interface->start_editing = ecce_start_editing;
-}
-
-static void
-ecce_finalize (GObject *object)
-{
- EComboCellEditable *ecce = (EComboCellEditable *) object;
-
- g_free (ecce->priv);
-
- G_OBJECT_CLASS (e_combo_cell_editable_parent_class)->finalize (object);
-}
-
-static void
-e_combo_cell_editable_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_editable_set_editable (GTK_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_grab_focus (GtkWidget *widget)
-{
- EComboCellEditable *ecce = E_COMBO_CELL_EDITABLE (widget);
-
- gtk_widget_grab_focus (GTK_WIDGET (ecce->priv->entry));
-}
-
-static void
-e_combo_cell_editable_class_init (EComboCellEditableClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = ecce_finalize;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->grab_focus = ecce_grab_focus;
-}
-
-GtkCellEditable *
-e_combo_cell_editable_new (void)
-{
- return 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
deleted file mode 100644
index c37e786f84..0000000000
--- a/widgets/misc/e-combo-cell-editable.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Mike Kestner <mkestner@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __E_COMBO_CELL_EDITABLE_H__
-#define __E_COMBO_CELL_EDITABLE_H__
-
-#include <gtk/gtk.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__ */