summaryrefslogtreecommitdiff
path: root/gtk/gtkcellrenderercombo.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@imendio.com>2008-05-28 11:49:20 +0000
committerKristian Rietveld <kristian@src.gnome.org>2008-05-28 11:49:20 +0000
commit3ed120ebf865124c68498ce49d71b3bfb33735fe (patch)
tree5674a80a371418475ae5b34470588ff0410e8160 /gtk/gtkcellrenderercombo.c
parent1fa5cda0a9eba602de9fa5f27f7bfad05418bd70 (diff)
downloadgtk+-3ed120ebf865124c68498ce49d71b3bfb33735fe.tar.gz
Bug 324282 - add selected signal to cell renderer combo.
2006-05-28 Kristian Rietveld <kris@imendio.com> Bug 324282 - add selected signal to cell renderer combo. * gtk/gtkcellrenderercombo.c (gtk_cell_renderer_combo_class_init), (gtk_cell_renderer_combo_changed), (gtk_cell_renderer_combo_start_editing): add a new "changed" signal that will be emitted as soon as the combo box emitted changed and has an active iterator. (Modified patch based on work by James Pelletier). * gtk/gtkmarshalers.list: add marshaler. svn path=/trunk/; revision=20206
Diffstat (limited to 'gtk/gtkcellrenderercombo.c')
-rw-r--r--gtk/gtkcellrenderercombo.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/gtk/gtkcellrenderercombo.c b/gtk/gtkcellrenderercombo.c
index cfe7d2394f..6411ef2618 100644
--- a/gtk/gtkcellrenderercombo.c
+++ b/gtk/gtkcellrenderercombo.c
@@ -28,6 +28,7 @@
#include "gtkcellrenderertext.h"
#include "gtkcombobox.h"
#include "gtkcomboboxentry.h"
+#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtkalias.h"
@@ -59,6 +60,13 @@ enum {
PROP_HAS_ENTRY
};
+enum {
+ CHANGED,
+ LAST_SIGNAL
+};
+
+static guint cell_renderer_combo_signals[LAST_SIGNAL] = { 0, };
+
#define GTK_CELL_RENDERER_COMBO_PATH "gtk-cell-renderer-combo-path"
G_DEFINE_TYPE (GtkCellRendererCombo, gtk_cell_renderer_combo, GTK_TYPE_CELL_RENDERER_TEXT)
@@ -132,6 +140,39 @@ gtk_cell_renderer_combo_class_init (GtkCellRendererComboClass *klass)
TRUE,
GTK_PARAM_READWRITE));
+
+ /**
+ * GtkCellRendererCombo::changed:
+ * @combo: the object on which the signal is emitted
+ * @path_string: a string of the path identifying the edited cell
+ * (relative to the tree view model)
+ * @new_iter: the new iter selected in the combo box
+ * (relative to the combo box model)
+ *
+ * This signal is emitted each time after the user selected an item in
+ * the combo box, either by using the mouse or the arrow keys. Contrary
+ * to GtkComboBox, GtkCellRendererCombo::changed is not emitted for
+ * changes made to a selected item in the entry. The argument @new_iter
+ * corresponds to the newly selected item in the combo box and it is relative
+ * to the GtkTreeModel set via the model property on GtkCellRendererCombo.
+ *
+ * Note that as soon as you change the model displayed in the tree view,
+ * the tree view will immediately cease the editing operating. This
+ * means that you most probably want to refrain from changing the model
+ * until the combo cell renderer emits the edited or editing_canceled signal.
+ *
+ * Since: 2.14
+ */
+ cell_renderer_combo_signals[CHANGED] =
+ g_signal_new (I_("changed"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ _gtk_marshal_VOID__STRING_BOXED,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ GTK_TYPE_TREE_ITER);
}
static void
@@ -242,6 +283,25 @@ gtk_cell_renderer_combo_set_property (GObject *object,
}
static void
+gtk_cell_renderer_combo_changed (GtkComboBox *combo,
+ gpointer data)
+{
+ GtkTreeIter iter;
+ GtkCellRendererCombo *cell;
+
+ cell = GTK_CELL_RENDERER_COMBO (data);
+
+ if (gtk_combo_box_get_active_iter (combo, &iter))
+ {
+ const char *path;
+
+ path = g_object_get_data (G_OBJECT (combo), GTK_CELL_RENDERER_COMBO_PATH);
+ g_signal_emit (cell, cell_renderer_combo_signals[CHANGED], 0,
+ path, &iter);
+ }
+}
+
+static void
gtk_cell_renderer_combo_editing_done (GtkCellEditable *combo,
gpointer data)
{
@@ -382,6 +442,9 @@ gtk_cell_renderer_combo_start_editing (GtkCellRenderer *cell,
g_signal_connect (GTK_CELL_EDITABLE (combo), "editing_done",
G_CALLBACK (gtk_cell_renderer_combo_editing_done),
cell_combo);
+ g_signal_connect (GTK_CELL_EDITABLE (combo), "changed",
+ G_CALLBACK (gtk_cell_renderer_combo_changed),
+ cell_combo);
cell_combo->focus_out_id =
g_signal_connect (combo, "focus_out_event",
G_CALLBACK (gtk_cell_renderer_combo_focus_out_event),