Commit c94e1063 authored by Darin Adler's avatar Darin Adler

Record the idle ID so we can cancel it properly. New.

	* components/tree/nautilus-tree-model.c:
	(schedule_destroy_unneeded_children): Record the idle ID so we can
	cancel it properly.
	* components/tree/nautilus-tree-view.c: (sort_model_iter_to_file):
	New.
	(sort_model_path_to_file): Renamed from path_to_file to clarify
	which kid of path.
	(selection_changed_callback): Replaces the old row_activated_callback.
	Switch to the selected directory when you click on a row.
	(create_tree): Connect the "changed" to the selection object.

	* src/file-manager/fm-directory-view.c: Formatting tweaks.
	(update_directory_in_scripts_menu): Fix storage leak.

	* src/file-manager/fm-icon-view.c: (renaming_icon_callback): Enable
	a bit of GNOME2_CONVERSION_COMPLETE code.
	(create_icon_container): Formatting tweaks.
parent 3772c3da
2002-02-12 Darin Adler <darin@bentspoon.com>
* components/tree/nautilus-tree-model.c:
(schedule_destroy_unneeded_children): Record the idle ID so we can
cancel it properly.
* components/tree/nautilus-tree-view.c: (sort_model_iter_to_file):
New.
(sort_model_path_to_file): Renamed from path_to_file to clarify
which kid of path.
(selection_changed_callback): Replaces the old row_activated_callback.
Switch to the selected directory when you click on a row.
(create_tree): Connect the "changed" to the selection object.
* src/file-manager/fm-directory-view.c: Formatting tweaks.
(update_directory_in_scripts_menu): Fix storage leak.
* src/file-manager/fm-icon-view.c: (renaming_icon_callback): Enable
a bit of GNOME2_CONVERSION_COMPLETE code.
(create_icon_container): Formatting tweaks.
2002-02-12 Darin Adler <darin@bentspoon.com>
* src/file-manager/fm-directory-view.c:
......
......@@ -1190,7 +1190,8 @@ static void
schedule_destroy_unneeded_children (NautilusTreeModel *model)
{
if (model->details->destroy_unneeded_children_idle_id == 0) {
g_idle_add (destroy_unneeded_children_idle_callback, model);
model->details->destroy_unneeded_children_idle_id =
g_idle_add (destroy_unneeded_children_idle_callback, model);
}
}
......
......@@ -40,6 +40,7 @@
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtktreemodelsort.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtktreeview.h>
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libnautilus-private/nautilus-global-preferences.h>
......@@ -85,17 +86,26 @@ load_expansion_state (NautilusTreeView *view)
}
static NautilusFile *
path_to_file (NautilusTreeView *view, GtkTreePath *path)
sort_model_iter_to_file (NautilusTreeView *view, GtkTreeIter *iter)
{
GtkTreeIter copy;
copy = *iter;
#if SORT_MODEL_WORKS
gtk_tree_model_sort_convert_iter_to_child_iter (view->details->sort_model, &copy, &copy);
#endif
return nautilus_tree_model_iter_get_file (view->details->child_model, &copy);
}
static NautilusFile *
sort_model_path_to_file (NautilusTreeView *view, GtkTreePath *path)
{
GtkTreeIter iter;
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (view->details->sort_model), &iter, path)) {
return NULL;
}
#if SORT_MODEL_WORKS
gtk_tree_model_sort_convert_iter_to_child_iter (view->details->sort_model, &iter, &iter);
#endif
return nautilus_tree_model_iter_get_file (view->details->child_model, &iter);
return sort_model_iter_to_file (view, &iter);
}
static void
......@@ -107,7 +117,7 @@ prepend_one_uri (GtkTreeView *tree_view,
NautilusFile *file;
p = callback_data;
file = path_to_file (p->view, path);
file = sort_model_path_to_file (p->view, path);
if (file == NULL) {
return;
}
......@@ -191,20 +201,26 @@ cancel_activation (NautilusTreeView *view)
}
static void
row_activated_callback (GtkTreeView *tree_widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
NautilusTreeView *view)
selection_changed_callback (GtkTreeSelection *selection,
NautilusTreeView *view)
{
GList *attrs;
GtkTreeIter iter;
cancel_activation (view);
view->details->activation_file = path_to_file (view, path);
if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
return;
}
attrs = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
nautilus_file_call_when_ready (view->details->activation_file, attrs,
got_activation_uri_callback, view);
view->details->activation_file = sort_model_iter_to_file (view, &iter);
if (view->details->activation_file == NULL) {
return;
}
attrs = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
nautilus_file_call_when_ready (view->details->activation_file, attrs,
got_activation_uri_callback, view);
g_list_free (attrs);
}
......@@ -299,8 +315,10 @@ create_tree (NautilusTreeView *view)
G_CALLBACK (schedule_save_expansion_state_callback), view);
g_signal_connect_swapped (view->details->tree_widget, "row_collapsed",
G_CALLBACK (schedule_save_expansion_state_callback), view);
g_signal_connect (view->details->tree_widget, "row_activated",
G_CALLBACK (row_activated_callback), view);
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (view->details->tree_widget)),
"changed",
G_CALLBACK (selection_changed_callback), view);
}
static void
......
......@@ -1137,15 +1137,11 @@ add_scripts_directory (FMDirectoryView *view,
g_list_free (attributes);
g_signal_connect (directory,
"files_added",
G_CALLBACK (scripts_added_or_changed_callback),
view);
g_signal_connect (directory, "files_added",
G_CALLBACK (scripts_added_or_changed_callback), view);
g_signal_connect (directory,
"files_changed",
G_CALLBACK (scripts_added_or_changed_callback),
view);
g_signal_connect (directory, "files_changed",
G_CALLBACK (scripts_added_or_changed_callback), view);
view->details->scripts_directory_list = g_list_prepend
(view->details->scripts_directory_list, directory);
......@@ -1204,49 +1200,31 @@ fm_directory_view_init (FMDirectoryView *view)
view->details->sort_directories_first =
eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
g_signal_connect (view->details->nautilus_view,
"stop_loading",
G_CALLBACK (stop_loading_callback),
view);
g_signal_connect (view->details->nautilus_view,
"load_location",
G_CALLBACK (load_location_callback),
view);
g_signal_connect (view->details->nautilus_view, "stop_loading",
G_CALLBACK (stop_loading_callback), view);
g_signal_connect (view->details->nautilus_view, "load_location",
G_CALLBACK (load_location_callback), view);
nautilus_view_set_listener_mask (
NAUTILUS_VIEW (view->details->nautilus_view),
NAUTILUS_VIEW_LISTEN_SELECTION);
g_signal_connect (view->details->nautilus_view,
"selection_changed",
G_CALLBACK (selection_changed_callback),
view);
g_signal_connect (fm_directory_view_get_bonobo_control (view),
"activate",
G_CALLBACK (bonobo_control_activate_callback),
view);
g_signal_connect (view->details->zoomable,
"zoom_in",
G_CALLBACK (zoomable_zoom_in_callback),
view);
g_signal_connect (view->details->zoomable,
"zoom_out",
G_CALLBACK (zoomable_zoom_out_callback),
view);
g_signal_connect (view->details->zoomable,
"set_zoom_level",
G_CALLBACK (zoomable_set_zoom_level_callback),
view);
g_signal_connect (view->details->zoomable,
"zoom_to_fit",
G_CALLBACK (zoomable_zoom_to_fit_callback),
view);
gtk_signal_connect_while_alive (GTK_OBJECT (nautilus_trash_monitor_get ()),
"trash_state_changed",
G_CALLBACK (fm_directory_view_trash_state_changed_callback),
view,
g_signal_connect (view->details->nautilus_view, "selection_changed",
G_CALLBACK (selection_changed_callback), view);
g_signal_connect (fm_directory_view_get_bonobo_control (view), "activate",
G_CALLBACK (bonobo_control_activate_callback), view);
g_signal_connect (view->details->zoomable, "zoom_in",
G_CALLBACK (zoomable_zoom_in_callback), view);
g_signal_connect (view->details->zoomable, "zoom_out",
G_CALLBACK (zoomable_zoom_out_callback), view);
g_signal_connect (view->details->zoomable, "set_zoom_level",
G_CALLBACK (zoomable_set_zoom_level_callback), view);
g_signal_connect (view->details->zoomable, "zoom_to_fit",
G_CALLBACK (zoomable_zoom_to_fit_callback), view);
gtk_signal_connect_while_alive (GTK_OBJECT (nautilus_trash_monitor_get ()), "trash_state_changed",
G_CALLBACK (fm_directory_view_trash_state_changed_callback), view,
GTK_OBJECT (view));
gtk_widget_show (GTK_WIDGET (view));
......@@ -1254,32 +1232,23 @@ fm_directory_view_init (FMDirectoryView *view)
filtering_changed_callback (view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
schedule_update_menus_callback,
view);
schedule_update_menus_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
filtering_changed_callback,
view);
filtering_changed_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
filtering_changed_callback,
view);
filtering_changed_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
schedule_update_menus_callback,
view);
schedule_update_menus_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_ENABLE_DELETE,
schedule_update_menus_callback,
view);
schedule_update_menus_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
text_attribute_names_changed_callback,
view);
text_attribute_names_changed_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
image_display_policy_changed_callback,
view);
image_display_policy_changed_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
view);
click_policy_changed_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST,
sort_directories_first_changed_callback,
view);
sort_directories_first_changed_callback, view);
}
static void
......@@ -1338,26 +1307,19 @@ fm_directory_view_finalize (GObject *object)
fm_directory_view_ignore_hidden_file_preferences (view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
schedule_update_menus_callback,
view);
schedule_update_menus_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
schedule_update_menus_callback,
view);
schedule_update_menus_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_ENABLE_DELETE,
schedule_update_menus_callback,
view);
schedule_update_menus_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
text_attribute_names_changed_callback,
view);
text_attribute_names_changed_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
image_display_policy_changed_callback,
view);
image_display_policy_changed_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
view);
click_policy_changed_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST,
sort_directories_first_changed_callback,
view);
sort_directories_first_changed_callback, view);
forget_clipboard_contents (view);
......@@ -3779,7 +3741,7 @@ update_directory_in_scripts_menu (FMDirectoryView *view, NautilusDirectory *dire
{
char *directory_uri;
char *menu_path, *popup_path;
GList *file_list, *node;
GList *file_list, *filtered, *node;
gboolean any_scripts;
int i;
NautilusFile *file;
......@@ -3793,9 +3755,11 @@ update_directory_in_scripts_menu (FMDirectoryView *view, NautilusDirectory *dire
NULL);
g_free (directory_uri);
file_list = nautilus_file_list_sort_by_display_name
(nautilus_file_list_filter_hidden_and_backup
(nautilus_directory_get_file_list (directory), FALSE, FALSE));
file_list = nautilus_directory_get_file_list (directory);
filtered = nautilus_file_list_filter_hidden_and_backup (file_list, FALSE, FALSE);
nautilus_file_list_free (file_list);
file_list = nautilus_file_list_sort_by_display_name (filtered);
any_scripts = FALSE;
i = 0;
......
......@@ -1748,18 +1748,16 @@ icon_container_preview_callback (NautilusIconContainer *container,
static void
renaming_icon_callback (NautilusIconContainer *container,
GtkEditable *editable,
GtkWidget *widget,
gpointer callback_data)
{
FMDirectoryView *directory_view;
directory_view = FM_DIRECTORY_VIEW (callback_data);
#ifdef GNOME2_CONVERSION_COMPLETE
nautilus_clipboard_set_up_editable_in_control
(editable,
(GTK_EDITABLE (widget),
fm_directory_view_get_bonobo_control (directory_view),
TRUE);
#endif
}
static int
......@@ -2506,14 +2504,10 @@ create_icon_container (FMIconView *icon_view)
"layout_changed",
G_CALLBACK (layout_changed_callback),
directory_view);
g_signal_connect (icon_container,
"preview",
G_CALLBACK (icon_container_preview_callback),
icon_view);
g_signal_connect (icon_container,
"renaming_icon",
G_CALLBACK (renaming_icon_callback),
directory_view);
g_signal_connect (icon_container, "preview",
G_CALLBACK (icon_container_preview_callback), icon_view);
g_signal_connect (icon_container, "renaming_icon",
G_CALLBACK (renaming_icon_callback), directory_view);
gtk_signal_connect_object (GTK_OBJECT (icon_container),
"icon_stretch_started",
G_CALLBACK (fm_directory_view_update_menus),
......
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