diff options
author | Alexander Larsson <alexl@redhat.com> | 2004-10-26 16:12:02 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2004-10-26 16:12:02 +0000 |
commit | c1103d9f354dfc9479a6d9c4f8b75f09af6d5b30 (patch) | |
tree | e7b6ef0e1aaa52704a8a552c86b7f061794b3e33 /src | |
parent | 4debd0a59ea148c1a2bc2a6782fa739bd970612d (diff) | |
download | nautilus-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
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-navigation-window.c | 29 | ||||
-rw-r--r-- | src/nautilus-window-manage-views.c | 35 |
2 files changed, 63 insertions, 1 deletions
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 */ |