Commit c1103d9f authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

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
parent 4debd0a5
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]:
......
......@@ -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)
......
......@@ -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"
......
......@@ -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;
}
......@@ -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 */
......
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