Commit 9f4a011f authored by Christian Neumair's avatar Christian Neumair Committed by Christian Neumair

Ref/unref view before/after receiving clipboard data, and check whether it

2008-03-23  Christian Neumair  <cneumair@gnome.org>

	* src/file-manager/fm-directory-view.c
	(directory_list_lookup_file), (fm_directory_view_new_folder),
	(paste_clipboard_received_callback),
	(paste_into_clipboard_received_callback),
	(action_paste_files_callback), (action_paste_files_into_callback):
	Ref/unref view before/after receiving clipboard data, and check
	whether it has been disposed. Should fix most of the clipboard crashers.

	* src/file-manager/fm-tree-view.c
	(clipboard_contents_received_callback), (button_pressed_callback),
	(create_popup_menu), (fm_tree_view_init), (fm_tree_view_dispose),
	(fm_tree_view_finalize):
	Cancel activation and destroy popup in dispose() and not in finalize().
	Create popup menu on demand.
	Unref popup file in dispose() instead of leaking a reference.
	Use eel_preferences_add_callback_while_alive() for preferences
	callbacks.
	Also ref/unref before/after requesting clipboard data, and check for
	previous disposal in callback. Should fix rest of clipboard crashers.

svn path=/trunk/; revision=13980
parent 00eceb43
2008-03-23 Christian Neumair <cneumair@gnome.org>
* src/file-manager/fm-directory-view.c
(directory_list_lookup_file), (fm_directory_view_new_folder),
(paste_clipboard_received_callback),
(paste_into_clipboard_received_callback),
(action_paste_files_callback), (action_paste_files_into_callback):
Ref/unref view before/after receiving clipboard data, and check
whether it has been disposed. Should fix most of the clipboard crashers.
* src/file-manager/fm-tree-view.c
(clipboard_contents_received_callback), (button_pressed_callback),
(create_popup_menu), (fm_tree_view_init), (fm_tree_view_dispose),
(fm_tree_view_finalize):
Cancel activation and destroy popup in dispose() and not in finalize().
Create popup menu on demand.
Unref popup file in dispose() instead of leaking a reference.
Use eel_preferences_add_callback_while_alive() for preferences
callbacks.
Also ref/unref before/after requesting clipboard data, and check for
previous disposal in callback. Should fix rest of clipboard crashers.
2008-03-23 Christian Neumair <cneumair@gnome.org>
* src/file-manager/fm-icon-view.c (play_file):
......
......@@ -5697,9 +5697,13 @@ paste_clipboard_received_callback (GtkClipboard *clipboard,
view_uri = fm_directory_view_get_backing_uri (view);
paste_clipboard_data (view, selection_data, view_uri);
if (view->details->window != NULL) {
paste_clipboard_data (view, selection_data, view_uri);
}
g_free (view_uri);
g_object_unref (view);
}
static void
......@@ -5713,14 +5717,18 @@ paste_into_clipboard_received_callback (GtkClipboard *clipboard,
view = FM_DIRECTORY_VIEW (data);
selection = fm_directory_view_get_selection (view);
if (view->details->window != NULL) {
selection = fm_directory_view_get_selection (view);
directory_uri = nautilus_file_get_activation_uri (NAUTILUS_FILE (selection->data));
directory_uri = nautilus_file_get_activation_uri (NAUTILUS_FILE (selection->data));
paste_clipboard_data (view, selection_data, directory_uri);
paste_clipboard_data (view, selection_data, directory_uri);
g_free (directory_uri);
nautilus_file_list_free (selection);
g_free (directory_uri);
nautilus_file_list_free (selection);
}
g_object_unref (view);
}
static void
......@@ -5731,6 +5739,7 @@ action_paste_files_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
g_object_ref (view);
gtk_clipboard_request_contents (get_clipboard (view),
copied_files_atom,
paste_clipboard_received_callback,
......@@ -5745,6 +5754,7 @@ action_paste_files_into_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
g_object_ref (view);
gtk_clipboard_request_contents (get_clipboard (view),
copied_files_atom,
paste_into_clipboard_received_callback,
......
......@@ -138,6 +138,8 @@ static void fm_tree_view_iface_init (NautilusSidebarIface *iface
static void sidebar_provider_iface_init (NautilusSidebarProviderIface *iface);
static GType fm_tree_view_provider_get_type (void);
static void create_popup_menu (FMTreeView *view);
G_DEFINE_TYPE_WITH_CODE (FMTreeView, fm_tree_view, GTK_TYPE_SCROLLED_WINDOW,
G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_SIDEBAR,
fm_tree_view_iface_init));
......@@ -637,9 +639,12 @@ clipboard_contents_received_callback (GtkClipboard *clipboard,
view = FM_TREE_VIEW (data);
if (selection_data->type == copied_files_atom
&& selection_data->length > 0) {
&& selection_data->length > 0 &&
view->details->popup != NULL) {
gtk_widget_set_sensitive (view->details->popup_paste, TRUE);
}
g_object_unref (view);
}
static GtkClipboard *
......@@ -697,7 +702,9 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
gtk_tree_view_get_cursor (view->details->tree_widget, &cursor_path, NULL);
gtk_tree_view_set_cursor (view->details->tree_widget, path, NULL, FALSE);
gtk_tree_path_free (path);
create_popup_menu (view);
gtk_widget_set_sensitive (view->details->popup_open_in_new_window,
nautilus_file_is_directory (view->details->popup_file));
gtk_widget_set_sensitive (view->details->popup_create_folder,
......@@ -708,7 +715,7 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
nautilus_file_can_write (view->details->popup_file)) {
gtk_clipboard_request_contents (get_clipboard (GTK_WIDGET (view->details->tree_widget)),
copied_files_atom,
clipboard_contents_received_callback, view);
clipboard_contents_received_callback, g_object_ref (view));
}
can_move_file_to_trash = nautilus_file_can_trash (view->details->popup_file);
gtk_widget_set_sensitive (view->details->popup_trash, can_move_file_to_trash);
......@@ -1093,6 +1100,11 @@ static void
create_popup_menu (FMTreeView *view)
{
GtkWidget *popup, *menu_item, *menu_image;
if (view->details->popup != NULL) {
/* already created */
return;
}
popup = gtk_menu_new ();
......@@ -1408,15 +1420,14 @@ fm_tree_view_init (FMTreeView *view)
view->details->selecting = FALSE;
eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
filtering_changed_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
filtering_changed_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
filtering_changed_callback, view);
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
filtering_changed_callback, view, G_OBJECT (view));
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
filtering_changed_callback, view, G_OBJECT (view));
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
filtering_changed_callback, view, G_OBJECT (view));
view->details->popup_file = NULL;
create_popup_menu (view);
}
static void
......@@ -1441,6 +1452,30 @@ fm_tree_view_dispose (GObject *object)
view->details->show_selection_idle_id = 0;
}
cancel_activation (view);
if (view->details->popup != NULL) {
gtk_widget_destroy (view->details->popup);
view->details->popup = NULL;
}
if (view->details->popup_file != NULL) {
nautilus_file_unref (view->details->popup_file);
view->details->popup_file = NULL;
}
if (view->details->selection_location != NULL) {
g_free (view->details->selection_location);
view->details->selection_location = NULL;
}
if (view->details->volume_monitor != NULL) {
g_object_unref (view->details->volume_monitor);
view->details->volume_monitor = NULL;
}
view->details->window = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
......@@ -1451,22 +1486,6 @@ fm_tree_view_finalize (GObject *object)
view = FM_TREE_VIEW (object);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
filtering_changed_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
filtering_changed_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
filtering_changed_callback, view);
cancel_activation (view);
gtk_widget_destroy (view->details->popup);
if (view->details->selection_location != NULL) {
g_free (view->details->selection_location);
}
g_object_unref (view->details->volume_monitor);
g_free (view->details);
G_OBJECT_CLASS (parent_class)->finalize (object);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment