[gedit] use g_(s)list_free_full where appropriate
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] use g_(s)list_free_full where appropriate
- Date: Sat, 30 Oct 2010 11:47:16 +0000 (UTC)
commit 4ccf119c296f239f2315b6734ac79caa06318edf
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Oct 30 13:47:55 2010 +0200
use g_(s)list_free_full where appropriate
gedit/gedit-command-line.c | 15 ++++------
gedit/gedit-commands-file.c | 4 +--
gedit/gedit-message-bus.c | 8 +----
gedit/gedit-osx-delegate.m | 3 +-
gedit/gedit-window.c | 8 +----
plugins/filebrowser/gedit-file-bookmarks-store.c | 9 ++----
plugins/filebrowser/gedit-file-browser-store.c | 7 +---
plugins/filebrowser/gedit-file-browser-view.c | 8 +++--
plugins/filebrowser/gedit-file-browser-widget.c | 18 ++++--------
plugins/spell/gedit-spell-checker-dialog.c | 33 ++++++++-------------
10 files changed, 41 insertions(+), 72 deletions(-)
---
diff --git a/gedit/gedit-command-line.c b/gedit/gedit-command-line.c
index 3134403..d488043 100644
--- a/gedit/gedit-command-line.c
+++ b/gedit/gedit-command-line.c
@@ -67,16 +67,13 @@ G_DEFINE_TYPE (GeditCommandLine, gedit_command_line, G_TYPE_INITIALLY_UNOWNED)
static void
gedit_command_line_finalize (GObject *object)
{
- GeditCommandLine *command_line = GEDIT_COMMAND_LINE (object);
+ GeditCommandLinePrivate *priv = GEDIT_COMMAND_LINE (object)->priv;
- g_free (command_line->priv->encoding_charset);
- g_free (command_line->priv->line_column_position);
- g_strfreev (command_line->priv->remaining_args);
-
- g_free (command_line->priv->geometry);
-
- g_slist_foreach (command_line->priv->file_list, (GFunc)g_object_unref, NULL);
- g_slist_free (command_line->priv->file_list);
+ g_free (priv->encoding_charset);
+ g_free (priv->line_column_position);
+ g_strfreev (priv->remaining_args);
+ g_free (priv->geometry);
+ g_slist_free_full (priv->file_list, g_object_unref);
G_OBJECT_CLASS (gedit_command_line_parent_class)->finalize (object);
}
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index 62e679a..a600b2f 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -419,9 +419,7 @@ open_dialog_response_cb (GeditFileChooserDialog *dialog,
0);
g_slist_free (loaded);
-
- g_slist_foreach (files, (GFunc) g_object_unref, NULL);
- g_slist_free (files);
+ g_slist_free_full (files, g_object_unref);
}
void
diff --git a/gedit/gedit-message-bus.c b/gedit/gedit-message-bus.c
index c086d2b..1aeda34 100644
--- a/gedit/gedit-message-bus.c
+++ b/gedit/gedit-message-bus.c
@@ -184,18 +184,14 @@ message_free (Message *message)
{
g_free (message->method);
g_free (message->object_path);
-
- g_list_foreach (message->listeners, (GFunc)listener_free, NULL);
- g_list_free (message->listeners);
-
+ g_list_free_full (message->listeners, (GDestroyNotify) listener_free);
g_free (message);
}
static void
message_queue_free (GList *queue)
{
- g_list_foreach (queue, (GFunc)g_object_unref, NULL);
- g_list_free (queue);
+ g_list_free_full (queue, g_object_unref);
}
static void
diff --git a/gedit/gedit-osx-delegate.m b/gedit/gedit-osx-delegate.m
index 09d2017..8870632 100644
--- a/gedit/gedit-osx-delegate.m
+++ b/gedit/gedit-osx-delegate.m
@@ -98,8 +98,7 @@ get_window(NSAppleEventDescriptor *event)
GeditWindow *window = get_window (event);
gedit_commands_load_uris (window, uris, NULL, 0);
- g_slist_foreach (uris, (GFunc)g_free, NULL);
- g_slist_free (uris);
+ g_slist_free_full (uris, g_free);
}
}
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 3107104..b9e4860 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -1447,9 +1447,7 @@ update_recent_files_menu (GeditWindow *window)
}
g_list_free (filtered_items);
-
- g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
- g_list_free (items);
+ g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
}
static void
@@ -3014,9 +3012,7 @@ load_uris_from_drop (GeditWindow *window,
0);
g_slist_free (loaded);
-
- g_slist_foreach (locations, (GFunc) g_object_unref, NULL);
- g_slist_free (locations);
+ g_slist_free_full (locations, g_object_unref);
}
/* Handle drops on the GeditWindow */
diff --git a/plugins/filebrowser/gedit-file-bookmarks-store.c b/plugins/filebrowser/gedit-file-bookmarks-store.c
index 6a42feb..85b9398 100644
--- a/plugins/filebrowser/gedit-file-bookmarks-store.c
+++ b/plugins/filebrowser/gedit-file-bookmarks-store.c
@@ -375,8 +375,7 @@ init_drives (GeditFileBookmarksStore *model)
drives = g_volume_monitor_get_connected_drives (model->priv->volume_monitor);
g_list_foreach (drives, (GFunc)process_drive_cb, model);
- g_list_foreach (drives, (GFunc)g_object_unref, NULL);
- g_list_free (drives);
+ g_list_free_full (drives, g_object_unref);
}
static void
@@ -404,8 +403,7 @@ init_volumes (GeditFileBookmarksStore *model)
volumes = g_volume_monitor_get_volumes (model->priv->volume_monitor);
g_list_foreach (volumes, (GFunc)process_volume_nodrive_cb, model);
- g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
- g_list_free (volumes);
+ g_list_free_full (volumes, g_object_unref);
}
static void
@@ -435,8 +433,7 @@ init_mounts (GeditFileBookmarksStore *model)
mounts = g_volume_monitor_get_mounts (model->priv->volume_monitor);
g_list_foreach (mounts, (GFunc)process_mount_novolume_cb, model);
- g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
- g_list_free (mounts);
+ g_list_free_full (mounts, g_object_unref);
}
static void
diff --git a/plugins/filebrowser/gedit-file-browser-store.c b/plugins/filebrowser/gedit-file-browser-store.c
index 139424c..43c8ec8 100644
--- a/plugins/filebrowser/gedit-file-browser-store.c
+++ b/plugins/filebrowser/gedit-file-browser-store.c
@@ -3477,9 +3477,7 @@ static void
async_data_free (AsyncData *data)
{
g_object_unref (data->cancellable);
-
- g_list_foreach (data->files, (GFunc)g_object_unref, NULL);
- g_list_free (data->files);
+ g_list_free_full (data->files, g_object_unref);
if (!data->removed)
data->model->priv->async_handles = g_slist_remove (data->model->priv->async_handles, data);
@@ -3660,8 +3658,7 @@ gedit_file_browser_store_delete (GeditFileBrowserStore *model,
rows = g_list_append(NULL, gedit_file_browser_store_get_path_real (model, node));
result = gedit_file_browser_store_delete_all (model, rows, trash);
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
return result;
}
diff --git a/plugins/filebrowser/gedit-file-browser-view.c b/plugins/filebrowser/gedit-file-browser-view.c
index 83d3e06..81fc5e1 100644
--- a/plugins/filebrowser/gedit-file-browser-view.c
+++ b/plugins/filebrowser/gedit-file-browser-view.c
@@ -376,11 +376,13 @@ activate_selected_files (GeditFileBrowserView *view)
g_signal_emit (view, signals[FILE_ACTIVATED], 0, &iter);
}
- if (directory != NULL && gtk_tree_model_get_iter (view->priv->model, &iter, directory))
+ if (directory != NULL &&
+ gtk_tree_model_get_iter (view->priv->model, &iter, directory))
+ {
g_signal_emit (view, signals[DIRECTORY_ACTIVATED], 0, &iter);
+ }
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
}
static void
diff --git a/plugins/filebrowser/gedit-file-browser-widget.c b/plugins/filebrowser/gedit-file-browser-widget.c
index f6dda90..5084d78 100644
--- a/plugins/filebrowser/gedit-file-browser-widget.c
+++ b/plugins/filebrowser/gedit-file-browser-widget.c
@@ -351,8 +351,7 @@ gedit_file_browser_widget_finalize (GObject *object)
g_object_unref (obj->priv->bookmarks_store);
g_object_unref (obj->priv->combo_model);
- g_slist_foreach (obj->priv->filter_funcs, (GFunc)filter_func_free, NULL);
- g_slist_free (obj->priv->filter_funcs);
+ g_slist_free_full (obj->priv->filter_funcs, (GDestroyNotify) filter_func_free);
for (loc = obj->priv->locations; loc; loc = loc->next)
location_free ((Location *) (loc->data));
@@ -1357,8 +1356,7 @@ gedit_file_browser_widget_get_first_selected (GeditFileBrowserWidget *obj,
result = gtk_tree_model_get_iter (model, iter, (GtkTreePath *)(rows->data));
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
return result;
}
@@ -1498,8 +1496,7 @@ get_deletable_files (GeditFileBrowserWidget *obj) {
paths = g_list_append (paths, gtk_tree_path_copy (path));
}
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
return paths;
}
@@ -1534,8 +1531,7 @@ delete_selected_files (GeditFileBrowserWidget *obj,
result = gedit_file_browser_store_delete_all (GEDIT_FILE_BROWSER_STORE (model),
rows, trash);
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
return result == GEDIT_FILE_BROWSER_STORE_RESULT_OK;
}
@@ -2112,8 +2108,7 @@ gedit_file_browser_widget_get_num_selected_files_or_directories (GeditFileBrowse
}
}
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
return result;
}
@@ -2231,8 +2226,7 @@ try_activate_drive (GeditFileBrowserWidget *widget,
try_mount_volume (widget, volume);
}
- g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
- g_list_free (volumes);
+ g_list_free_full (volumes, g_object_unref);
}
static void
diff --git a/plugins/spell/gedit-spell-checker-dialog.c b/plugins/spell/gedit-spell-checker-dialog.c
index 30bca62..b5158d4 100644
--- a/plugins/spell/gedit-spell-checker-dialog.c
+++ b/plugins/spell/gedit-spell-checker-dialog.c
@@ -400,38 +400,33 @@ gedit_spell_checker_dialog_set_misspelled_word (GeditSpellCheckerDialog *dlg,
{
gchar *tmp;
GSList *sug;
-
+
g_return_if_fail (GEDIT_IS_SPELL_CHECKER_DIALOG (dlg));
g_return_if_fail (word != NULL);
g_return_if_fail (dlg->spell_checker != NULL);
g_return_if_fail (!gedit_spell_checker_check_word (dlg->spell_checker, word, -1));
- /* build_suggestions_list */
- if (dlg->misspelled_word != NULL)
- g_free (dlg->misspelled_word);
-
+ g_free (dlg->misspelled_word);
dlg->misspelled_word = g_strdup (word);
-
+
tmp = g_strdup_printf("<b>%s</b>", word);
gtk_label_set_label (GTK_LABEL (dlg->misspelled_word_label), tmp);
g_free (tmp);
sug = gedit_spell_checker_get_suggestions (dlg->spell_checker,
- dlg->misspelled_word,
- -1);
-
+ dlg->misspelled_word,
+ -1);
+
update_suggestions_list_model (dlg, sug);
- /* free the suggestion list */
- g_slist_foreach (sug, (GFunc)g_free, NULL);
- g_slist_free (sug);
+ g_slist_free_full (sug, g_free);
gtk_widget_set_sensitive (dlg->ignore_button, TRUE);
gtk_widget_set_sensitive (dlg->ignore_all_button, TRUE);
- gtk_widget_set_sensitive (dlg->add_word_button, TRUE);
+ gtk_widget_set_sensitive (dlg->add_word_button, TRUE);
}
-
+
static void
update_suggestions_list_model (GeditSpellCheckerDialog *dlg, GSList *suggestions)
{
@@ -542,18 +537,18 @@ check_word_button_clicked_handler (GtkButton *button, GeditSpellCheckerDialog *d
{
const gchar *word;
gssize len;
-
+
g_return_if_fail (GEDIT_IS_SPELL_CHECKER_DIALOG (dlg));
word = gtk_entry_get_text (GTK_ENTRY (dlg->word_entry));
len = strlen (word);
g_return_if_fail (len > 0);
-
+
if (gedit_spell_checker_check_word (dlg->spell_checker, word, len))
{
GtkListStore *store;
GtkTreeIter iter;
-
+
store = GTK_LIST_STORE (dlg->suggestions_list_model);
gtk_list_store_clear (store);
@@ -575,9 +570,7 @@ check_word_button_clicked_handler (GtkButton *button, GeditSpellCheckerDialog *d
update_suggestions_list_model (dlg, sug);
- /* free the suggestion list */
- g_slist_foreach (sug, (GFunc)g_free, NULL);
- g_slist_free (sug);
+ g_slist_free_full (sug, g_free);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]