From 4303c5b23db34eb1ba1604e6578e324937a7c196 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 11 Apr 2012 10:55:12 -0400 Subject: [PATCH] all: use g_object_add/remove_weak_pointer() Instead of the eel helpers. --- .../nautilus-file-operations.c | 27 +++++++++++++++---- src/nautilus-list-view.c | 11 +++++--- src/nautilus-places-sidebar.c | 15 ++++++++--- src/nautilus-query-editor.c | 8 ++++-- src/nautilus-view.c | 19 ++++++++++--- src/nautilus-window-slot.c | 5 ++-- 6 files changed, 64 insertions(+), 21 deletions(-) diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c index 4c4ac877f..460fa9a58 100644 --- a/libnautilus-private/nautilus-file-operations.c +++ b/libnautilus-private/nautilus-file-operations.c @@ -923,7 +923,9 @@ init_common (gsize job_size, if (parent_window) { common->parent_window = parent_window; - eel_add_weak_pointer (&common->parent_window); + g_object_add_weak_pointer (G_OBJECT (common->parent_window), + (gpointer *) &common->parent_window); + } common->progress = nautilus_progress_info_new (); common->cancellable = nautilus_progress_info_get_cancellable (common->progress); @@ -949,7 +951,12 @@ finalize_common (CommonJob *common) common->inhibit_cookie = -1; g_timer_destroy (common->time); - eel_remove_weak_pointer (&common->parent_window); + + if (common->parent_window) { + g_object_remove_weak_pointer (G_OBJECT (common->parent_window), + (gpointer *) &common->parent_window); + } + if (common->skip_files) { g_hash_table_destroy (common->skip_files); } @@ -2058,7 +2065,11 @@ unmount_mount_callback (GObject *source_object, g_error_free (error); } - eel_remove_weak_pointer (&data->parent_window); + if (data->parent_window) { + g_object_remove_weak_pointer (G_OBJECT (data->parent_window), + (gpointer *) &data->parent_window); + } + g_object_unref (data->mount); g_free (data); } @@ -2253,7 +2264,8 @@ nautilus_file_operations_unmount_mount_full (GtkWindow *par data->callback_data = callback_data; if (parent_window) { data->parent_window = parent_window; - eel_add_weak_pointer (&data->parent_window); + g_object_add_weak_pointer (G_OBJECT (data->parent_window), + (gpointer *) &data->parent_window); } data->eject = eject; @@ -2280,7 +2292,12 @@ nautilus_file_operations_unmount_mount_full (GtkWindow *par if (callback) { callback (callback_data); } - eel_remove_weak_pointer (&data->parent_window); + + if (data->parent_window) { + g_object_remove_weak_pointer (G_OBJECT (data->parent_window), + (gpointer *) &data->parent_window); + } + g_object_unref (data->mount); g_free (data); return; diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index e91324570..ca245891a 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -943,9 +943,10 @@ unload_file_timeout (gpointer data) } gtk_tree_path_free (path); } - } - eel_remove_weak_pointer (&unload_data->view); + g_object_remove_weak_pointer (G_OBJECT (unload_data->view), + (gpointer *) &unload_data->view); + } if (unload_data->directory) { nautilus_directory_unref (unload_data->directory); @@ -990,7 +991,8 @@ row_collapsed_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *p unload_data->file = file; unload_data->directory = directory; - eel_add_weak_pointer (&unload_data->view); + g_object_add_weak_pointer (G_OBJECT (unload_data->view), + (gpointer *) &unload_data->view); g_timeout_add_seconds (COLLAPSE_TO_UNLOAD_DELAY, unload_file_timeout, @@ -2601,7 +2603,8 @@ action_visible_columns_callback (GtkAction *action, gtk_window_present (GTK_WINDOW (list_view->details->column_editor)); } else { list_view->details->column_editor = create_column_editor (list_view); - eel_add_weak_pointer (&list_view->details->column_editor); + g_object_add_weak_pointer (G_OBJECT (list_view->details->column_editor), + (gpointer *) &list_view->details->column_editor); gtk_widget_show (list_view->details->column_editor); } diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c index 61f365848..f4b0bf4f7 100644 --- a/src/nautilus-places-sidebar.c +++ b/src/nautilus-places-sidebar.c @@ -1812,8 +1812,10 @@ volume_mounted_cb (GVolume *volume, g_object_unref (G_OBJECT (mount)); } - - eel_remove_weak_pointer (&(sidebar->go_to_after_mount_slot)); + if (sidebar->go_to_after_mount_slot) { + g_object_remove_weak_pointer (G_OBJECT (sidebar->go_to_after_mount_slot), + (gpointer *) &sidebar->go_to_after_mount_slot); + } } static void @@ -1893,7 +1895,8 @@ open_selected_bookmark (NautilusPlacesSidebar *sidebar, slot = nautilus_window_get_active_slot (sidebar->window); sidebar->go_to_after_mount_slot = slot; - eel_add_weak_pointer (&(sidebar->go_to_after_mount_slot)); + g_object_add_weak_pointer (G_OBJECT (sidebar->go_to_after_mount_slot), + (gpointer *) &sidebar->go_to_after_mount_slot); sidebar->go_to_after_mount_flags = flags; @@ -3442,7 +3445,11 @@ nautilus_places_sidebar_dispose (GObject *object) g_clear_object (&sidebar->store); g_clear_object (&sidebar->bookmarks); - eel_remove_weak_pointer (&(sidebar->go_to_after_mount_slot)); + if (sidebar->go_to_after_mount_slot) { + g_object_remove_weak_pointer (G_OBJECT (sidebar->go_to_after_mount_slot), + (gpointer *) &sidebar->go_to_after_mount_slot); + sidebar->go_to_after_mount_slot = NULL; + } g_signal_handlers_disconnect_by_func (nautilus_preferences, desktop_setting_changed_callback, diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c index efcf54e44..cc9596bef 100644 --- a/src/nautilus-query-editor.c +++ b/src/nautilus-query-editor.c @@ -146,7 +146,10 @@ nautilus_query_editor_dispose (GObject *object) editor); nautilus_search_bar_return_entry (editor->details->bar); - eel_remove_weak_pointer (&editor->details->bar); + + g_object_remove_weak_pointer (G_OBJECT (editor->details->bar), + (gpointer *) &editor->details->bar); + editor->details->bar = NULL; } G_OBJECT_CLASS (nautilus_query_editor_parent_class)->dispose (object); @@ -1278,7 +1281,8 @@ nautilus_query_editor_new_with_bar (gboolean start_hidden, nautilus_query_editor_set_visible (editor, !start_hidden); editor->details->bar = bar; - eel_add_weak_pointer (&editor->details->bar); + g_object_add_weak_pointer (G_OBJECT (editor->details->bar), + (gpointer *) &editor->details->bar); editor->details->slot = slot; diff --git a/src/nautilus-view.c b/src/nautilus-view.c index a0531411c..ea70aa4d1 100644 --- a/src/nautilus-view.c +++ b/src/nautilus-view.c @@ -1868,7 +1868,12 @@ new_folder_done (GFile *new_folder, fail: g_hash_table_destroy (data->added_locations); - eel_remove_weak_pointer (&data->directory_view); + + if (data->directory_view != NULL) { + g_object_remove_weak_pointer (G_OBJECT (data->directory_view), + (gpointer *) &data->directory_view); + } + g_free (data); } @@ -1882,7 +1887,8 @@ new_folder_data_new (NautilusView *directory_view) data->directory_view = directory_view; data->added_locations = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL); - eel_add_weak_pointer (&data->directory_view); + g_object_add_weak_pointer (G_OBJECT (data->directory_view), + (gpointer *) &data->directory_view); return data; } @@ -3089,7 +3095,11 @@ copy_move_done_data_free (CopyMoveDoneData *data) { g_assert (data != NULL); - eel_remove_weak_pointer (&data->directory_view); + if (data->directory_view != NULL) { + g_object_remove_weak_pointer (G_OBJECT (data->directory_view), + (gpointer *) &data->directory_view); + } + nautilus_file_list_free (data->added_files); g_free (data); } @@ -3117,7 +3127,8 @@ pre_copy_move (NautilusView *directory_view) copy_move_done_data = g_new0 (CopyMoveDoneData, 1); copy_move_done_data->directory_view = directory_view; - eel_add_weak_pointer (©_move_done_data->directory_view); + g_object_add_weak_pointer (G_OBJECT (copy_move_done_data->directory_view), + (gpointer *) ©_move_done_data->directory_view); /* We need to run after the default handler adds the folder we want to * operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index b8635f95c..8c310565f 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -115,6 +115,9 @@ real_update_query_editor (NautilusWindowSlot *slot) nautilus_window_slot_add_extra_location_widget (slot, query_editor); gtk_widget_show (query_editor); nautilus_query_editor_grab_focus (NAUTILUS_QUERY_EDITOR (query_editor)); + + g_object_add_weak_pointer (G_OBJECT (slot->query_editor), + (gpointer *) &slot->query_editor); } nautilus_directory_unref (directory); @@ -588,8 +591,6 @@ nautilus_window_slot_update_query_editor (NautilusWindowSlot *slot) } real_update_query_editor (slot); - - eel_add_weak_pointer (&slot->query_editor); } static void