Commit 4552eb2e authored by Frank Worsley's avatar Frank Worsley Committed by Frank Worsley

improve saving of geometry. only save it if we really resize a window, not

2002-07-17  Frank Worsley  <fworsley@shaw.ca>

	* src/nautilus-application.c: (save_window_geometry_timeout),
	(nautilus_window_configure_event_callback),
	(nautilus_window_unrealize_event_callback):
	improve saving of geometry. only save it if we really resize
	a window, not when a window is first shown or viewport change

	* src/nautilus-shell.c: (open_window):
	* src/nautilus-bookmarks-window.c:
	(nautilus_bookmarks_window_restore_geometry):
	update for changed eel function


	* src/nautilus-window-manage-views.c:
	(pending_location_already_showing): added new
	(position_and_show_window_callback):
	ignore saved window position if same window already showing

	* src/nautilus-window.c: (nautilus_window_instance_init),
	(nautilus_window_save_geometry):
	* src/nautilus-window.h:
	updated for new eel function and changes described above
parent e501c9f9
2002-07-17 Frank Worsley <fworsley@shaw.ca>
* src/nautilus-application.c: (save_window_geometry_timeout),
(nautilus_window_configure_event_callback),
(nautilus_window_unrealize_event_callback):
improve saving of geometry. only save it if we really resize
a window, not when a window is first shown or viewport change
* src/nautilus-shell.c: (open_window):
* src/nautilus-bookmarks-window.c:
(nautilus_bookmarks_window_restore_geometry):
update for changed eel function
* src/nautilus-window-manage-views.c:
(pending_location_already_showing): added new
(position_and_show_window_callback):
ignore saved window position if same window already showing
* src/nautilus-window.c: (nautilus_window_instance_init),
(nautilus_window_save_geometry):
* src/nautilus-window.h:
updated for new eel function and changes described above
2002-07-17 jacob berkman <jacob@ximian.com>
* components/adapter/Makefile.am (EXTRA_DIST): fixup
......
......@@ -45,6 +45,7 @@
#include <eel/eel-string-list.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-config.h>
#include <libgnome/gnome-i18n.h>
......@@ -643,15 +644,15 @@ nautilus_window_delete_event_callback (GtkWidget *widget,
}
static gboolean
save_window_geometry_idle (gpointer callback_data)
save_window_geometry_timeout (gpointer callback_data)
{
NautilusWindow *window;
window = NAUTILUS_WINDOW (callback_data);
nautilus_window_save_geometry (window);
window->save_geometry_idle_id = 0;
window->save_geometry_timeout_id = 0;
return FALSE;
}
......@@ -661,15 +662,40 @@ nautilus_window_configure_event_callback (GtkWidget *widget,
gpointer callback_data)
{
NautilusWindow *window;
char *geometry_string;
window = NAUTILUS_WINDOW (widget);
/* Only save the geometry when we are idle,
* since we receive configure events all the time.
/* Only save the geometry if the user hasn't resized the window
* for half a second. Otherwise delay the callback another half second.
*/
if (window->save_geometry_idle_id == 0) {
window->save_geometry_idle_id =
g_idle_add (save_window_geometry_idle, window);
if (window->save_geometry_timeout_id != 0) {
g_source_remove (window->save_geometry_timeout_id);
}
if (GTK_WIDGET_VISIBLE (GTK_WIDGET (window)) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) {
geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
/* If the last geometry is NULL the window must have just
* been shown. No need to save geometry to disk since it
* must be the same.
*/
if (window->last_geometry == NULL) {
window->last_geometry = geometry_string;
return FALSE;
}
/* Don't save geometry if it's the same as before. */
if (!strcmp (window->last_geometry, geometry_string)) {
g_free (geometry_string);
return FALSE;
}
g_free (window->last_geometry);
window->last_geometry = geometry_string;
window->save_geometry_timeout_id =
g_timeout_add (500, save_window_geometry_timeout, window);
}
return FALSE;
......@@ -684,9 +710,9 @@ nautilus_window_unrealize_event_callback (GtkWidget *widget,
window = NAUTILUS_WINDOW (widget);
if (window->save_geometry_idle_id != 0) {
g_source_remove (window->save_geometry_idle_id);
window->save_geometry_idle_id = 0;
if (window->save_geometry_timeout_id != 0) {
g_source_remove (window->save_geometry_timeout_id);
window->save_geometry_timeout_id = 0;
nautilus_window_save_geometry (window);
}
......
......@@ -396,7 +396,7 @@ nautilus_bookmarks_window_restore_geometry (GtkWidget *window)
if (window_geometry != NULL) {
eel_gtk_window_set_initial_geometry_from_string
(GTK_WINDOW (window), window_geometry,
BOOKMARKS_WINDOW_MIN_WIDTH, BOOKMARKS_WINDOW_MIN_HEIGHT);
BOOKMARKS_WINDOW_MIN_WIDTH, BOOKMARKS_WINDOW_MIN_HEIGHT, FALSE);
} else {
/* use default since there was no stored geometry */
......
......@@ -179,6 +179,9 @@ nautilus_window_instance_init (NautilusWindow *window)
g_object_ref (G_OBJECT (window->details->tooltips));
gtk_object_sink (GTK_OBJECT (window->details->tooltips));
/* Set last geometry to NULL */
window->last_geometry = NULL;
/* Set initial window title */
gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
......@@ -876,6 +879,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
NULL,
geometry_string);
g_free (geometry_string);
}
......
......@@ -81,8 +81,10 @@ struct NautilusWindow {
GtkWidget *view_as_option_menu;
GtkWidget *navigation_bar;
char *last_geometry;
guint status_bar_clear_id;
guint save_geometry_idle_id;
guint save_geometry_timeout_id;
/** CORBA-related elements **/
NautilusApplication *application;
......
......@@ -179,6 +179,9 @@ nautilus_window_instance_init (NautilusWindow *window)
g_object_ref (G_OBJECT (window->details->tooltips));
gtk_object_sink (GTK_OBJECT (window->details->tooltips));
/* Set last geometry to NULL */
window->last_geometry = NULL;
/* Set initial window title */
gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
......@@ -876,6 +879,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
NULL,
geometry_string);
g_free (geometry_string);
}
......
......@@ -81,8 +81,10 @@ struct NautilusWindow {
GtkWidget *view_as_option_menu;
GtkWidget *navigation_bar;
char *last_geometry;
guint status_bar_clear_id;
guint save_geometry_idle_id;
guint save_geometry_timeout_id;
/** CORBA-related elements **/
NautilusApplication *application;
......
......@@ -130,7 +130,8 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry)
eel_gtk_window_set_initial_geometry_from_string (GTK_WINDOW (window),
geometry,
APPLICATION_WINDOW_MIN_WIDTH,
APPLICATION_WINDOW_MIN_HEIGHT);
APPLICATION_WINDOW_MIN_HEIGHT,
FALSE);
}
if (uri == NULL) {
......
......@@ -179,6 +179,9 @@ nautilus_window_instance_init (NautilusWindow *window)
g_object_ref (G_OBJECT (window->details->tooltips));
gtk_object_sink (GTK_OBJECT (window->details->tooltips));
/* Set last geometry to NULL */
window->last_geometry = NULL;
/* Set initial window title */
gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
......@@ -876,6 +879,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
NULL,
geometry_string);
g_free (geometry_string);
}
......
......@@ -81,8 +81,10 @@ struct NautilusWindow {
GtkWidget *view_as_option_menu;
GtkWidget *navigation_bar;
char *last_geometry;
guint status_bar_clear_id;
guint save_geometry_idle_id;
guint save_geometry_timeout_id;
/** CORBA-related elements **/
NautilusApplication *application;
......
......@@ -45,6 +45,7 @@
#include <eel/eel-vfs-extensions.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <gdk/gdkx.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-dialog-util.h>
#include <libgnomevfs/gnome-vfs-async-ops.h>
......@@ -1113,13 +1114,41 @@ cancel_location_change (NautilusWindow *window)
end_location_change (window);
}
static gboolean
pending_location_already_showing (NautilusWindow *window)
{
char *temp;
char *location;
GList *list, *item;
temp = window->details->pending_location;
list = nautilus_application_get_window_list ();
for (item = list; item != NULL; item = item->next) {
location = nautilus_window_get_location (NAUTILUS_WINDOW (item->data));
if (!NAUTILUS_IS_DESKTOP_WINDOW (item->data)
&& location != NULL
&& item->data != window
&& !strcmp (temp, location)) {
g_free (location);
return TRUE;
}
g_free (location);
}
return FALSE;
}
static void
position_and_show_window_callback (NautilusFile *file,
gpointer callback_data)
{
NautilusWindow *window;
char *geometry_string;
window = NAUTILUS_WINDOW (callback_data);
if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
......@@ -1127,11 +1156,16 @@ position_and_show_window_callback (NautilusFile *file,
geometry_string = nautilus_file_get_metadata
(file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL);
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);
NAUTILUS_WINDOW_MIN_HEIGHT,
pending_location_already_showing (window));
}
g_free (geometry_string);
}
......
......@@ -179,6 +179,9 @@ nautilus_window_instance_init (NautilusWindow *window)
g_object_ref (G_OBJECT (window->details->tooltips));
gtk_object_sink (GTK_OBJECT (window->details->tooltips));
/* Set last geometry to NULL */
window->last_geometry = NULL;
/* Set initial window title */
gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
......@@ -876,6 +879,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
NULL,
geometry_string);
g_free (geometry_string);
}
......
......@@ -81,8 +81,10 @@ struct NautilusWindow {
GtkWidget *view_as_option_menu;
GtkWidget *navigation_bar;
char *last_geometry;
guint status_bar_clear_id;
guint save_geometry_idle_id;
guint save_geometry_timeout_id;
/** CORBA-related elements **/
NautilusApplication *application;
......
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