summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2004-10-26 16:12:02 +0000
committerAlexander Larsson <alexl@src.gnome.org>2004-10-26 16:12:02 +0000
commitc1103d9f354dfc9479a6d9c4f8b75f09af6d5b30 (patch)
treee7b6ef0e1aaa52704a8a552c86b7f061794b3e33
parent4debd0a59ea148c1a2bc2a6782fa739bd970612d (diff)
downloadnautilus-c1103d9f354dfc9479a6d9c4f8b75f09af6d5b30.tar.gz
Add saved geometry pref
2004-10-26 Alexander Larsson <alexl@redhat.com> * libnautilus-private/nautilus-global-preferences.[ch]: Add saved geometry pref * src/nautilus-navigation-window.c: (nautilus_navigation_window_save_geometry), (real_window_close), (nautilus_navigation_window_class_init): Save geometry on window close * src/nautilus-window-manage-views.c: (another_navigation_window_already_showing), (load_directory_metadata_callback): load geometry on open
-rw-r--r--ChangeLog15
-rw-r--r--libnautilus-private/nautilus-global-preferences.c4
-rw-r--r--libnautilus-private/nautilus-global-preferences.h1
-rw-r--r--src/nautilus-navigation-window.c29
-rw-r--r--src/nautilus-window-manage-views.c35
5 files changed, 83 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d688aa4de..7bbac0ad7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2004-10-26 Alexander Larsson <alexl@redhat.com>
+ * libnautilus-private/nautilus-global-preferences.[ch]:
+ Add saved geometry pref
+
+ * src/nautilus-navigation-window.c:
+ (nautilus_navigation_window_save_geometry), (real_window_close),
+ (nautilus_navigation_window_class_init):
+ Save geometry on window close
+
+ * src/nautilus-window-manage-views.c:
+ (another_navigation_window_already_showing),
+ (load_directory_metadata_callback):
+ load geometry on open
+
+2004-10-26 Alexander Larsson <alexl@redhat.com>
+
* src/file-manager/fm-tree-model.[ch]:
Handle volumes for root nodes
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 50d8943d5..c7ee693df 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -407,6 +407,10 @@ static const PreferenceDefault preference_defaults[] = {
PREFERENCE_BOOLEAN,
GINT_TO_POINTER (TRUE)
},
+ { NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY,
+ PREFERENCE_STRING,
+ NULL
+ },
{ NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
PREFERENCE_BOOLEAN,
GINT_TO_POINTER (TRUE)
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index a94b9eab4..5e8d628b0 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -89,6 +89,7 @@ typedef enum
#define NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR "preferences/start_with_status_bar"
#define NAUTILUS_PREFERENCES_START_WITH_SIDEBAR "preferences/start_with_sidebar"
#define NAUTILUS_PREFERENCES_SIDE_PANE_VIEW "preferences/side_pane_view"
+#define NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY "preferences/navigation_window_saved_geometry"
/* Sorting order */
#define NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST "preferences/sort_directories_first"
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 5eb5cf55f..7d3fc26b3 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -1451,6 +1451,34 @@ nautilus_navigation_window_show (GtkWidget *widget)
GTK_WIDGET_CLASS (parent_class)->show (widget);
}
+static void
+nautilus_navigation_window_save_geometry (NautilusNavigationWindow *window)
+{
+ char *geometry_string;
+
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ if (GTK_WIDGET(window)->window &&
+ !(gdk_window_get_state (GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_MAXIMIZED)) {
+ geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
+
+ if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY)) {
+ eel_preferences_set
+ (NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY,
+ geometry_string);
+ }
+ g_free (geometry_string);
+ }
+}
+
+
+
+static void
+real_window_close (NautilusWindow *window)
+{
+ nautilus_navigation_window_save_geometry (NAUTILUS_NAVIGATION_WINDOW (window));
+}
+
static void
real_get_default_size(NautilusWindow *window, guint *default_width, guint *default_height)
{
@@ -1481,4 +1509,5 @@ nautilus_navigation_window_class_init (NautilusNavigationWindowClass *class)
NAUTILUS_WINDOW_CLASS (class)->prompt_for_location = real_prompt_for_location;
NAUTILUS_WINDOW_CLASS (class)->set_title = real_set_title;
NAUTILUS_WINDOW_CLASS(class)->get_default_size = real_get_default_size;
+ NAUTILUS_WINDOW_CLASS (class)->close = real_window_close;
}
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 57ff9b773..979c15c0e 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -1153,7 +1153,6 @@ cancel_location_change (NautilusWindow *window)
end_location_change (window);
}
-
static gboolean
pending_location_already_showing (NautilusWindow *window)
{
@@ -1180,6 +1179,23 @@ pending_location_already_showing (NautilusWindow *window)
return FALSE;
}
+static gboolean
+another_navigation_window_already_showing (NautilusWindow *the_window)
+{
+ GList *list, *item;
+
+ list = nautilus_application_get_window_list ();
+ for (item = list; item != NULL; item = item->next) {
+ if (item->data != the_window &&
+ NAUTILUS_IS_NAVIGATION_WINDOW (item->data)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
static void
load_directory_metadata_callback (NautilusFile *file,
gpointer callback_data)
@@ -1248,6 +1264,23 @@ load_directory_metadata_callback (NautilusFile *file,
}
}
#endif
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ geometry_string = eel_preferences_get
+ (NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY);
+ if (geometry_string != NULL) {
+ /* Ignore saved window position if a window with the same
+ * location is already showing. That way the two windows
+ * wont appear at the exact same location on the screen.
+ */
+ eel_gtk_window_set_initial_geometry_from_string
+ (GTK_WINDOW (window),
+ geometry_string,
+ NAUTILUS_WINDOW_MIN_WIDTH,
+ NAUTILUS_WINDOW_MIN_HEIGHT,
+ another_navigation_window_already_showing (window));
+ }
+ g_free (geometry_string);
+ }
/* finish loading the view */