[gedit] Fix escape bug with the search and replace completion
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Fix escape bug with the search and replace completion
- Date: Wed, 28 Aug 2013 09:58:26 +0000 (UTC)
commit 4a89841fa133125c2b14183580830755ddd792ce
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Aug 24 15:25:20 2013 +0200
Fix escape bug with the search and replace completion
The completion contents was unescaped before inserting it, and escaped
after retrieving it. But the unescape/escape functions are not
reciprocal. So it's easier to always deal with the original text.
As a consequence, the gedit_history_entry_set_escape_func() function is
no longer needed.
Little problem: there will be bugs with old completion entries, when
upgrading the gedit version.
gedit/gedit-history-entry.c | 51 ------------------------------------------
gedit/gedit-history-entry.h | 4 ---
gedit/gedit-replace-dialog.c | 18 +-------------
3 files changed, 2 insertions(+), 71 deletions(-)
---
diff --git a/gedit/gedit-history-entry.c b/gedit/gedit-history-entry.c
index 08b28da..a95eaaa 100644
--- a/gedit/gedit-history-entry.c
+++ b/gedit/gedit-history-entry.c
@@ -528,55 +528,4 @@ gedit_history_entry_get_entry (GeditHistoryEntry *entry)
return gtk_bin_get_child (GTK_BIN (entry));
}
-static void
-escape_cell_data_func (GtkTreeViewColumn *col,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- GeditHistoryEntryEscapeFunc escape_func)
-{
- gchar *str;
- gchar *escaped;
-
- gtk_tree_model_get (model, iter, 0, &str, -1);
- escaped = escape_func (str);
- g_object_set (renderer, "text", escaped, NULL);
-
- g_free (str);
- g_free (escaped);
-}
-
-void
-gedit_history_entry_set_escape_func (GeditHistoryEntry *entry,
- GeditHistoryEntryEscapeFunc escape_func)
-{
- GList *cells;
-
- g_return_if_fail (GEDIT_IS_HISTORY_ENTRY (entry));
-
- cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (entry));
-
- /* We only have one cell renderer */
- g_return_if_fail (cells->data != NULL && cells->next == NULL);
-
- if (escape_func != NULL)
- {
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
- GTK_CELL_RENDERER (cells->data),
- (GtkCellLayoutDataFunc) escape_cell_data_func,
- escape_func,
- NULL);
- }
- else
- {
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
- GTK_CELL_RENDERER (cells->data),
- NULL,
- NULL,
- NULL);
- }
-
- g_list_free (cells);
-}
-
/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-history-entry.h b/gedit/gedit-history-entry.h
index e67a458..981cdf7 100644
--- a/gedit/gedit-history-entry.h
+++ b/gedit/gedit-history-entry.h
@@ -85,10 +85,6 @@ gboolean gedit_history_entry_get_enable_completion
GtkWidget *gedit_history_entry_get_entry (GeditHistoryEntry *entry);
-typedef gchar * (* GeditHistoryEntryEscapeFunc) (const gchar *str);
-void gedit_history_entry_set_escape_func (GeditHistoryEntry *entry,
- GeditHistoryEntryEscapeFunc escape_func);
-
G_END_DECLS
#endif /* __GEDIT_HISTORY_ENTRY_H__ */
diff --git a/gedit/gedit-replace-dialog.c b/gedit/gedit-replace-dialog.c
index 000421c..9b740d1 100644
--- a/gedit/gedit-replace-dialog.c
+++ b/gedit/gedit-replace-dialog.c
@@ -90,28 +90,18 @@ gedit_replace_dialog_response (GtkDialog *dialog,
str = gtk_entry_get_text (GTK_ENTRY (dlg->priv->replace_text_entry));
if (*str != '\0')
{
- gchar *text;
-
- text = gtk_source_utils_unescape_search_text (str);
gedit_history_entry_prepend_text
(GEDIT_HISTORY_ENTRY (dlg->priv->replace_entry),
- text);
-
- g_free (text);
+ str);
}
/* fall through, so that we also save the find entry */
case GEDIT_REPLACE_DIALOG_FIND_RESPONSE:
str = gtk_entry_get_text (GTK_ENTRY (dlg->priv->search_text_entry));
if (*str != '\0')
{
- gchar *text;
-
- text = gtk_source_utils_unescape_search_text (str);
gedit_history_entry_prepend_text
(GEDIT_HISTORY_ENTRY (dlg->priv->search_entry),
- text);
-
- g_free (text);
+ str);
}
}
}
@@ -202,8 +192,6 @@ gedit_replace_dialog_init (GeditReplaceDialog *dlg)
dlg->priv->search_entry = gedit_history_entry_new ("search-for-entry", TRUE);
gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
- gedit_history_entry_set_escape_func (GEDIT_HISTORY_ENTRY (dlg->priv->search_entry),
- (GeditHistoryEntryEscapeFunc)
gtk_source_utils_escape_search_text);
gtk_widget_set_hexpand (GTK_WIDGET (dlg->priv->search_entry), TRUE);
dlg->priv->search_text_entry = gedit_history_entry_get_entry (GEDIT_HISTORY_ENTRY
(dlg->priv->search_entry));
gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->search_text_entry), TRUE);
@@ -213,8 +201,6 @@ gedit_replace_dialog_init (GeditReplaceDialog *dlg)
GTK_POS_RIGHT, 1, 1);
dlg->priv->replace_entry = gedit_history_entry_new ("replace-with-entry", TRUE);
- gedit_history_entry_set_escape_func (GEDIT_HISTORY_ENTRY (dlg->priv->replace_entry),
- (GeditHistoryEntryEscapeFunc)
gtk_source_utils_escape_search_text);
gtk_widget_set_hexpand (GTK_WIDGET (dlg->priv->replace_entry), TRUE);
dlg->priv->replace_text_entry = gedit_history_entry_get_entry (GEDIT_HISTORY_ENTRY
(dlg->priv->replace_entry));
gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->replace_text_entry), TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]