From 788bec83843059493bd6f3adac26cf8e2f323559 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 9 Dec 2004 17:55:58 +0000 Subject: [PATCH] Fix #145463, reported by Michael Natterer. 2004-12-09 Matthias Clasen Fix #145463, reported by Michael Natterer. * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an editing flag to keep track of when editing is done. * gtk/gtkcellrenderer.h: * gtk/gtkcellrenderer.c (gtk_cell_renderer_stop_editing): New function to replace gtk_cell_renderer_editing_canceled(). Deprecate gtk_cell_renderer_editing_canceled(). * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): * gtk/gtkcellrenderercombo.c (gtk_cell_renderer_combo_editing_done): * gtk/gtktreeview.c (gtk_tree_view_stop_editing): Use gtk_cell_renderer_stop_editing(). --- ChangeLog | 17 +++++++++++++++ ChangeLog.pre-2-10 | 17 +++++++++++++++ ChangeLog.pre-2-6 | 17 +++++++++++++++ ChangeLog.pre-2-8 | 17 +++++++++++++++ docs/reference/ChangeLog | 1 + docs/reference/gtk/gtk-sections.txt | 1 + gtk/gtkcellrenderer.c | 34 +++++++++++++++++++++++++++-- gtk/gtkcellrenderer.h | 5 +++++ gtk/gtkcellrenderercombo.c | 12 +++++----- gtk/gtkcellrenderertext.c | 7 +++--- gtk/gtktreeview.c | 6 ++++- 11 files changed, 121 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6024a1e921..e5e3fe2e3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2004-12-09 Matthias Clasen + + Fix #145463, reported by Michael Natterer. + + * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an + editing flag to keep track of when editing is done. + + * gtk/gtkcellrenderer.h: + * gtk/gtkcellrenderer.c (gtk_cell_renderer_stop_editing): New + function to replace gtk_cell_renderer_editing_canceled(). + Deprecate gtk_cell_renderer_editing_canceled(). + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + * gtk/gtkcellrenderercombo.c (gtk_cell_renderer_combo_editing_done): + * gtk/gtktreeview.c (gtk_tree_view_stop_editing): + Use gtk_cell_renderer_stop_editing(). + 2004-12-09 Matthias Clasen * gtk/gtkliststore.h: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 6024a1e921..e5e3fe2e3f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,20 @@ +2004-12-09 Matthias Clasen + + Fix #145463, reported by Michael Natterer. + + * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an + editing flag to keep track of when editing is done. + + * gtk/gtkcellrenderer.h: + * gtk/gtkcellrenderer.c (gtk_cell_renderer_stop_editing): New + function to replace gtk_cell_renderer_editing_canceled(). + Deprecate gtk_cell_renderer_editing_canceled(). + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + * gtk/gtkcellrenderercombo.c (gtk_cell_renderer_combo_editing_done): + * gtk/gtktreeview.c (gtk_tree_view_stop_editing): + Use gtk_cell_renderer_stop_editing(). + 2004-12-09 Matthias Clasen * gtk/gtkliststore.h: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 6024a1e921..e5e3fe2e3f 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,20 @@ +2004-12-09 Matthias Clasen + + Fix #145463, reported by Michael Natterer. + + * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an + editing flag to keep track of when editing is done. + + * gtk/gtkcellrenderer.h: + * gtk/gtkcellrenderer.c (gtk_cell_renderer_stop_editing): New + function to replace gtk_cell_renderer_editing_canceled(). + Deprecate gtk_cell_renderer_editing_canceled(). + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + * gtk/gtkcellrenderercombo.c (gtk_cell_renderer_combo_editing_done): + * gtk/gtktreeview.c (gtk_tree_view_stop_editing): + Use gtk_cell_renderer_stop_editing(). + 2004-12-09 Matthias Clasen * gtk/gtkliststore.h: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 6024a1e921..e5e3fe2e3f 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,20 @@ +2004-12-09 Matthias Clasen + + Fix #145463, reported by Michael Natterer. + + * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an + editing flag to keep track of when editing is done. + + * gtk/gtkcellrenderer.h: + * gtk/gtkcellrenderer.c (gtk_cell_renderer_stop_editing): New + function to replace gtk_cell_renderer_editing_canceled(). + Deprecate gtk_cell_renderer_editing_canceled(). + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + * gtk/gtkcellrenderercombo.c (gtk_cell_renderer_combo_editing_done): + * gtk/gtktreeview.c (gtk_tree_view_stop_editing): + Use gtk_cell_renderer_stop_editing(). + 2004-12-09 Matthias Clasen * gtk/gtkliststore.h: diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 6753a66810..96c4b10d35 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,6 +1,7 @@ 2004-12-09 Matthias Clasen * gtk/gtk-sections.txt: Add new list store methods. + Add gtk_cell_renderer_stop_editing. 2004-12-08 Matthias Clasen diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index ec00deba4f..01419875f8 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -4136,6 +4136,7 @@ gtk_cell_renderer_render gtk_cell_renderer_activate gtk_cell_renderer_start_editing gtk_cell_renderer_editing_canceled +gtk_cell_renderer_stop_editing gtk_cell_renderer_get_fixed_size gtk_cell_renderer_set_fixed_size diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c index da73c36cbf..71abf47090 100644 --- a/gtk/gtkcellrenderer.c +++ b/gtk/gtkcellrenderer.c @@ -117,6 +117,7 @@ gtk_cell_renderer_init (GtkCellRenderer *cell) cell->sensitive = TRUE; cell->is_expander = FALSE; cell->is_expanded = FALSE; + cell->editing = FALSE; } static void @@ -687,7 +688,6 @@ gtk_cell_renderer_start_editing (GtkCellRenderer *cell, if (GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing == NULL) return NULL; - editable = GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing (cell, event, widget, @@ -700,6 +700,8 @@ gtk_cell_renderer_start_editing (GtkCellRenderer *cell, cell_renderer_signals[EDITING_STARTED], 0, editable, path); + cell->editing = TRUE; + return editable; } @@ -770,11 +772,39 @@ gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell, * changes were not committed. * * Since: 2.4 + * Deprecated: Use gtk_cell_renderer_stop_editing() instead **/ void gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell) { g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - g_signal_emit (cell, cell_renderer_signals[EDITING_CANCELED], 0); + gtk_cell_renderer_stop_editing (cell, TRUE); } + +/** + * gtk_cell_renderer_stop_editing: + * @cell: A #GtkCellRenderer + * @canceled: %TRUE if the editing has been canceled + * + * Informs the cell renderer that the editing is stopped. + * If @canceled is %TRUE, the cell renderer will emit the "editing-canceled" + * signal. This function should be called by cell renderer implementations + * in response to the "editing-done" signal of #GtkCellEditable. + * + * Since: 2.6 + **/ +void +gtk_cell_renderer_stop_editing (GtkCellRenderer *cell, + gboolean canceled) +{ + g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); + + if (cell->editing) + { + cell->editing = FALSE; + if (canceled) + g_signal_emit (cell, cell_renderer_signals[EDITING_CANCELED], 0); + } +} + diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h index 01e882419a..375106acf4 100644 --- a/gtk/gtkcellrenderer.h +++ b/gtk/gtkcellrenderer.h @@ -72,6 +72,7 @@ struct _GtkCellRenderer guint is_expanded : 1; guint cell_background_set : 1; guint sensitive : 1; + guint editing : 1; }; struct _GtkCellRendererClass @@ -157,7 +158,11 @@ void gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell, gint *height); /* For use by cell renderer implementations only */ +#ifndef GTK_DISABLE_DEPRECATED void gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell); +#endif +void gtk_cell_renderer_stop_editing (GtkCellRenderer *cell, + gboolean canceled); G_END_DECLS diff --git a/gtk/gtkcellrenderercombo.c b/gtk/gtkcellrenderercombo.c index 8b26a8d555..1f027468d0 100644 --- a/gtk/gtkcellrenderercombo.c +++ b/gtk/gtkcellrenderercombo.c @@ -254,6 +254,7 @@ gtk_cell_renderer_combo_editing_done (GtkCellEditable *combo, GtkTreeIter iter; GtkCellRendererCombo *cell; GtkEntry *entry; + gboolean canceled; cell = GTK_CELL_RENDERER_COMBO (data); @@ -262,12 +263,11 @@ gtk_cell_renderer_combo_editing_done (GtkCellEditable *combo, g_signal_handler_disconnect (combo, cell->focus_out_id); cell->focus_out_id = 0; } - - if (_gtk_combo_box_editing_canceled (GTK_COMBO_BOX (combo))) - { - gtk_cell_renderer_editing_canceled (GTK_CELL_RENDERER (data)); - return; - } + + canceled = _gtk_combo_box_editing_canceled (GTK_COMBO_BOX (combo)); + gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), canceled); + if (canceled) + return; if (GTK_IS_COMBO_BOX_ENTRY (combo)) { diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index 1fff846203..3ea7101398 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -1572,11 +1572,10 @@ 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) - { - gtk_cell_renderer_editing_canceled (GTK_CELL_RENDERER (data)); - return; - } + return; path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH); new_text = gtk_entry_get_text (GTK_ENTRY (entry)); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index c6d727e4b4..df546df2ec 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -12870,6 +12870,7 @@ gtk_tree_view_stop_editing (GtkTreeView *tree_view, gboolean cancel_editing) { GtkTreeViewColumn *column; + GtkCellRenderer *cell; if (tree_view->priv->edited_column == NULL) return; @@ -12887,7 +12888,10 @@ gtk_tree_view_stop_editing (GtkTreeView *tree_view, column = tree_view->priv->edited_column; tree_view->priv->edited_column = NULL; - if (! cancel_editing) + cell = _gtk_tree_view_column_get_edited_cell (column); + gtk_cell_renderer_stop_editing (cell, cancel_editing); + + if (!cancel_editing) gtk_cell_editable_editing_done (column->editable_widget); tree_view->priv->edited_column = column;