scroll position saving
- From: James Willcox <jwillcox gnome org>
- To: nautilus-list gnome org
- Subject: scroll position saving
- Date: Sat, 27 Sep 2003 18:25:34 -0400
Hi,
Here's a patch which saves the scroll position in object windows. Njoy.
Thanks,
James
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5926.2.8
diff -u -r1.5926.2.8 ChangeLog
--- ChangeLog 24 Sep 2003 21:52:00 -0000 1.5926.2.8
+++ ChangeLog 27 Sep 2003 22:07:11 -0000
@@ -1,3 +1,17 @@
+2003-09-27 James Willcox <james ximian com>
+
+ * libnautilus-private/nautilus-metadata.h:
+ * src/nautilus-object-window.c: (nautilus_object_window_destroy),
+ (nautilus_object_window_save_scroll_position), (delete_event_cb),
+ (nautilus_object_window_instance_init):
+ * src/nautilus-object-window.h:
+ * src/nautilus-view-frame.c:
+ (nautilus_view_frame_get_first_visible_file):
+ * src/nautilus-window-manage-views.c:
+ (position_and_show_window_callback):
+
+ Save the scroll position in object windows.
+
2003-09-24 Dave Camp <dave ximian com>
* src/nautilus-desktop-window.c: (real_get_title),
Index: libnautilus-private/nautilus-metadata.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metadata.h,v
retrieving revision 1.26
diff -u -r1.26 nautilus-metadata.h
--- libnautilus-private/nautilus-metadata.h 3 May 2003 23:23:30 -0000 1.26
+++ libnautilus-private/nautilus-metadata.h 27 Sep 2003 22:07:12 -0000
@@ -60,6 +60,7 @@
#define NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED "list_view_sort_reversed"
#define NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY "window_geometry"
+#define NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION "window_scroll_position"
#define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR "sidebar_background_color"
#define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE "sidebar_background_tile_image"
Index: src/nautilus-object-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-object-window.c,v
retrieving revision 1.414.6.3
diff -u -r1.414.6.3 nautilus-object-window.c
--- src/nautilus-object-window.c 24 Sep 2003 21:52:05 -0000 1.414.6.3
+++ src/nautilus-object-window.c 27 Sep 2003 22:07:13 -0000
@@ -175,7 +175,7 @@
nautilus_object_window_destroy (GtkObject *object)
{
NautilusObjectWindow *window;
-
+
window = NAUTILUS_OBJECT_WINDOW (object);
window->details->content_box = NULL;
@@ -213,6 +213,21 @@
}
}
+void
+nautilus_object_window_save_scroll_position (NautilusObjectWindow *window)
+{
+ NautilusWindow *parent;
+ char *scroll_string;
+
+ parent = NAUTILUS_WINDOW(window);
+ scroll_string = nautilus_view_frame_get_first_visible_file (parent->content_view);
+ nautilus_file_set_metadata (parent->details->viewed_file,
+ NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION,
+ NULL,
+ scroll_string);
+ g_free (scroll_string);
+}
+
static void
nautilus_object_window_show (GtkWidget *widget)
{
@@ -280,6 +295,14 @@
GTK_WIDGET (new_view));
}
+static gboolean
+delete_event_cb (NautilusObjectWindow *window, gpointer user_data)
+{
+ nautilus_object_window_save_scroll_position (window);
+
+ return FALSE;
+}
+
static void
nautilus_object_window_instance_init (NautilusObjectWindow *window)
{
@@ -291,6 +314,10 @@
gtk_widget_show (window->details->content_box);
bonobo_window_set_contents (BONOBO_WINDOW (window),
window->details->content_box);
+
+ g_signal_connect_object (window, "delete_event",
+ G_CALLBACK(delete_event_cb),
+ NULL, 0);
}
static void
Index: src/nautilus-object-window.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-object-window.h,v
retrieving revision 1.108.6.2
diff -u -r1.108.6.2 nautilus-object-window.h
--- src/nautilus-object-window.h 21 Sep 2003 22:23:06 -0000 1.108.6.2
+++ src/nautilus-object-window.h 27 Sep 2003 22:07:13 -0000
@@ -61,5 +61,6 @@
GtkWidget *nautilus_object_window_get (const char *uri);
void nautilus_object_window_save_geometry (NautilusObjectWindow *window);
+void nautilus_object_window_save_scroll_position (NautilusObjectWindow *window);
#endif
Index: src/nautilus-view-frame.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame.c,v
retrieving revision 1.165.6.2
diff -u -r1.165.6.2 nautilus-view-frame.c
--- src/nautilus-view-frame.c 23 Sep 2003 20:59:27 -0000 1.165.6.2
+++ src/nautilus-view-frame.c 27 Sep 2003 22:07:13 -0000
@@ -1146,6 +1146,7 @@
CORBA_free (uri);
CORBA_exception_free (&ev);
}
+
return ret;
}
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.321.4.4
diff -u -r1.321.4.4 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c 24 Sep 2003 21:52:05 -0000 1.321.4.4
+++ src/nautilus-window-manage-views.c 27 Sep 2003 22:07:14 -0000
@@ -1201,6 +1201,7 @@
{
NautilusWindow *window;
char *geometry_string;
+ char *scroll_string;
window = NAUTILUS_WINDOW (callback_data);
@@ -1222,6 +1223,14 @@
pending_location_already_showing (window));
}
g_free (geometry_string);
+
+ /* load the saved scroll position */
+ scroll_string = nautilus_file_get_metadata
+ (file, NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION,
+ NULL);
+ if (scroll_string != NULL) {
+ window->details->pending_scroll_to = scroll_string;
+ }
}
#endif
/* If we finished constructing the window by now we need
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]