[gtk+] Use GtkCellEditable::editing-canceled



commit 325bd9299aaf05f18138c7e5f490a9bf9e1ce00a
Author: Javier Jardón <jjardon gnome org>
Date:   Fri Dec 4 02:15:00 2009 +0100

    Use GtkCellEditable::editing-canceled
    
    GtkCellEditable::editing-canceled property was added in 2.19 cycle,
    so we should make the code that currently uses entry->editing_canceled
    directly go through the property
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=599213

 gtk/gtkcellrenderercombo.c |    6 ++++--
 gtk/gtkcellrendererspin.c  |    4 +++-
 gtk/gtkcellrenderertext.c  |   14 ++++++++++----
 gtk/gtkcombobox.c          |   21 +++++++++------------
 gtk/gtkcombobox.h          |    2 --
 5 files changed, 26 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtkcellrenderercombo.c b/gtk/gtkcellrenderercombo.c
index 1ad0b22..ba5fabb 100644
--- a/gtk/gtkcellrenderercombo.c
+++ b/gtk/gtkcellrenderercombo.c
@@ -331,8 +331,10 @@ gtk_cell_renderer_combo_editing_done (GtkCellEditable *combo,
       g_signal_handler_disconnect (combo, cell->focus_out_id);
       cell->focus_out_id = 0;
     }
-  
-  canceled = _gtk_combo_box_editing_canceled (GTK_COMBO_BOX (combo));
+
+  g_object_get (combo,
+                "editing-canceled", &canceled,
+                NULL);
   gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), canceled);
   if (canceled)
     {
diff --git a/gtk/gtkcellrendererspin.c b/gtk/gtkcellrendererspin.c
index ebd08e2..2a3961b 100644
--- a/gtk/gtkcellrendererspin.c
+++ b/gtk/gtkcellrendererspin.c
@@ -230,7 +230,9 @@ gtk_cell_renderer_spin_focus_out_event (GtkWidget *widget,
   const gchar *new_text;
   gboolean canceled;
 
-  canceled = GTK_ENTRY (widget)->editing_canceled;
+  g_object_get (widget,
+                "editing-canceled", &canceled,
+                NULL);
 
   g_signal_handlers_disconnect_by_func (widget,
 					gtk_cell_renderer_spin_focus_out_event,
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index 3e47c91..bbdd21b 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -1701,6 +1701,7 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry,
 {
   const gchar *path;
   const gchar *new_text;
+  gboolean canceled;
   GtkCellRendererTextPrivate *priv;
 
   priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data);
@@ -1725,9 +1726,12 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry,
       priv->entry_menu_popdown_timeout = 0;
     }
 
-  gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), 
-				  GTK_ENTRY (entry)->editing_canceled);
-  if (GTK_ENTRY (entry)->editing_canceled)
+  g_object_get (entry,
+                "editing-canceled", &canceled,
+                NULL);
+  gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), canceled);
+
+  if (canceled)
     return;
 
   path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH);
@@ -1801,7 +1805,9 @@ gtk_cell_renderer_text_focus_out_event (GtkWidget *entry,
   if (priv->in_entry_menu)
     return FALSE;
 
-  GTK_ENTRY (entry)->editing_canceled = TRUE;
+  g_object_set (entry,
+                "editing-canceled", TRUE,
+                NULL);
   gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
   gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
 
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index ebe90d9..666cb7f 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -3198,7 +3198,9 @@ gtk_combo_box_menu_item_activate (GtkWidget *item,
 
   gtk_tree_path_free (path);
 
-  combo_box->priv->editing_canceled = FALSE;
+  g_object_set (combo_box,
+                "editing-canceled", FALSE,
+                NULL);
 }
 
 static void
@@ -5510,8 +5512,9 @@ gtk_cell_editable_key_press (GtkWidget   *widget,
 
   if (event->keyval == GDK_Escape)
     {
-      combo_box->priv->editing_canceled = TRUE;
-
+      g_object_set (combo_box,
+                    "editing-canceled", TRUE,
+                    NULL);
       gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
       gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
       
@@ -5566,7 +5569,9 @@ popup_idle (gpointer data)
 			     combo_box, 0);
   
   /* we unset this if a menu item is activated */
-  combo_box->priv->editing_canceled = TRUE;
+  g_object_set (combo_box,
+                "editing-canceled", TRUE,
+                NULL);
   gtk_combo_box_popup (combo_box);
 
   combo_box->priv->popup_idle_id = 0;
@@ -5727,14 +5732,6 @@ gtk_combo_box_set_title (GtkComboBox *combo_box,
     }
 }
 
-gboolean
-_gtk_combo_box_editing_canceled (GtkComboBox *combo_box)
-{
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), TRUE);
-
-  return combo_box->priv->editing_canceled;
-}
-
 /**
  * gtk_combo_box_get_popup_accessible:
  * @combo_box: a #GtkComboBox
diff --git a/gtk/gtkcombobox.h b/gtk/gtkcombobox.h
index 1da1562..963e4b4 100644
--- a/gtk/gtkcombobox.h
+++ b/gtk/gtkcombobox.h
@@ -136,8 +136,6 @@ void          gtk_combo_box_popup            (GtkComboBox     *combo_box);
 void          gtk_combo_box_popdown          (GtkComboBox     *combo_box);
 AtkObject*    gtk_combo_box_get_popup_accessible (GtkComboBox *combo_box);
 
-/* private */
-gboolean     _gtk_combo_box_editing_canceled (GtkComboBox     *combo_box);
 
 G_END_DECLS
 



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