gtk+ r20206 - in trunk: . gtk



Author: kristian
Date: Wed May 28 11:49:20 2008
New Revision: 20206
URL: http://svn.gnome.org/viewvc/gtk+?rev=20206&view=rev

Log:
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.



Modified:
   trunk/ChangeLog
   trunk/gtk/gtkcellrenderercombo.c
   trunk/gtk/gtkmarshalers.list

Modified: trunk/gtk/gtkcellrenderercombo.c
==============================================================================
--- trunk/gtk/gtkcellrenderercombo.c	(original)
+++ trunk/gtk/gtkcellrenderercombo.c	Wed May 28 11:49:20 2008
@@ -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 @@
   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 @@
 							 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 @@
 }
 
 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 @@
   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),

Modified: trunk/gtk/gtkmarshalers.list
==============================================================================
--- trunk/gtk/gtkmarshalers.list	(original)
+++ trunk/gtk/gtkmarshalers.list	Wed May 28 11:49:20 2008
@@ -101,6 +101,7 @@
 VOID:POINTER,POINTER,POINTER
 VOID:POINTER,UINT
 VOID:STRING
+VOID:STRING,BOXED
 VOID:STRING,STRING
 VOID:STRING,INT,POINTER
 VOID:STRING,UINT,FLAGS



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