diff options
author | Frank Worsley <fworsley@shaw.ca> | 2002-06-11 03:42:25 +0000 |
---|---|---|
committer | Frank Worsley <fworsley@src.gnome.org> | 2002-06-11 03:42:25 +0000 |
commit | 97c0382309b55475f5277cf026e7b8898e38f0e2 (patch) | |
tree | 79bc5d241b949bc5a771b103067455d7abdfe9f2 /src | |
parent | 8e5c3794d48554eaefc231da24db3a3c862eb1bf (diff) | |
download | nautilus-97c0382309b55475f5277cf026e7b8898e38f0e2.tar.gz |
always load the saved window geometry and save the geometry whenever a
2002-06-10 Frank Worsley <fworsley@shaw.ca>
* src/nautilus-application.c:
* src/nautilus-window-manage-views.c:
* src/nautilus-window.c:
* src/nautilus-window.h:
always load the saved window geometry and save the geometry
whenever a window is resized
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-application.c | 57 | ||||
-rw-r--r-- | src/nautilus-navigation-window.c | 17 | ||||
-rw-r--r-- | src/nautilus-navigation-window.h | 4 | ||||
-rw-r--r-- | src/nautilus-object-window.c | 17 | ||||
-rw-r--r-- | src/nautilus-object-window.h | 4 | ||||
-rw-r--r-- | src/nautilus-spatial-window.c | 17 | ||||
-rw-r--r-- | src/nautilus-spatial-window.h | 4 | ||||
-rw-r--r-- | src/nautilus-window-manage-views.c | 54 | ||||
-rw-r--r-- | src/nautilus-window.c | 17 | ||||
-rw-r--r-- | src/nautilus-window.h | 4 |
10 files changed, 107 insertions, 88 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c index eb1b5c312..4c5b63a00 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -641,6 +641,57 @@ nautilus_window_delete_event_callback (GtkWidget *widget, return TRUE; } +static gboolean +save_window_geometry_idle (gpointer callback_data) +{ + NautilusWindow *window; + + window = NAUTILUS_WINDOW (callback_data); + + nautilus_window_save_geometry (window); + + window->save_geometry_idle_id = 0; + return FALSE; +} + +static gboolean +nautilus_window_configure_event_callback (GtkWidget *widget, + GdkEventConfigure *event, + gpointer callback_data) +{ + NautilusWindow *window; + + window = NAUTILUS_WINDOW (widget); + + /* Only save the geometry when we are idle, + * since we receive configure events all the time. + */ + if (window->save_geometry_idle_id == 0) { + window->save_geometry_idle_id = + g_idle_add (save_window_geometry_idle, window); + } + + return FALSE; +} + +static gboolean +nautilus_window_unrealize_event_callback (GtkWidget *widget, + GdkEvent *event, + gpointer callback_data) +{ + NautilusWindow *window; + + 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; + nautilus_window_save_geometry (window); + } + + return FALSE; +} + NautilusWindow * nautilus_application_create_window (NautilusApplication *application) { @@ -658,6 +709,12 @@ nautilus_application_create_window (NautilusApplication *application) g_signal_connect_object (window, "destroy", G_CALLBACK (nautilus_application_destroyed_window), application, 0); + g_signal_connect (window, "configure_event", + G_CALLBACK (nautilus_window_configure_event_callback), NULL); + + g_signal_connect (window, "unrealize", + G_CALLBACK (nautilus_window_unrealize_event_callback), NULL); + nautilus_application_window_list = g_list_prepend (nautilus_application_window_list, window); /* Do not yet show the window. It will be shown later on if it can diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 3aae0577b..483c4d8ce 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static void +void nautilus_window_save_geometry (NautilusWindow *window) { char *geometry_string; - g_assert (NAUTILUS_IS_WINDOW (window)); - g_assert (GTK_WIDGET_VISIBLE (window)); + g_assert (NAUTILUS_IS_WINDOW (window)); - geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); + geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); nautilus_file_set_metadata (window->details->viewed_file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, @@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window) void nautilus_window_close (NautilusWindow *window) { - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - - /* Save the window position in the directory's metadata only if - * we're in every-location-in-its-own-window mode. Otherwise it - * would be too apparently random when the stored positions change. - */ - if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) { - nautilus_window_save_geometry (window); - } + g_return_if_fail (NAUTILUS_IS_WINDOW (window)); gtk_widget_destroy (GTK_WIDGET (window)); } diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h index 8039b94c6..19cb9b8d4 100644 --- a/src/nautilus-navigation-window.h +++ b/src/nautilus-navigation-window.h @@ -82,7 +82,8 @@ struct NautilusWindow { GtkWidget *navigation_bar; guint status_bar_clear_id; - + guint save_geometry_idle_id; + /** CORBA-related elements **/ NautilusApplication *application; @@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window); void nautilus_window_hide_status_bar (NautilusWindow *window); void nautilus_window_show_status_bar (NautilusWindow *window); gboolean nautilus_window_status_bar_showing (NautilusWindow *window); +void nautilus_window_save_geometry (NautilusWindow *window); #endif diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index 3aae0577b..483c4d8ce 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static void +void nautilus_window_save_geometry (NautilusWindow *window) { char *geometry_string; - g_assert (NAUTILUS_IS_WINDOW (window)); - g_assert (GTK_WIDGET_VISIBLE (window)); + g_assert (NAUTILUS_IS_WINDOW (window)); - geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); + geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); nautilus_file_set_metadata (window->details->viewed_file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, @@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window) void nautilus_window_close (NautilusWindow *window) { - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - - /* Save the window position in the directory's metadata only if - * we're in every-location-in-its-own-window mode. Otherwise it - * would be too apparently random when the stored positions change. - */ - if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) { - nautilus_window_save_geometry (window); - } + g_return_if_fail (NAUTILUS_IS_WINDOW (window)); gtk_widget_destroy (GTK_WIDGET (window)); } diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h index 8039b94c6..19cb9b8d4 100644 --- a/src/nautilus-object-window.h +++ b/src/nautilus-object-window.h @@ -82,7 +82,8 @@ struct NautilusWindow { GtkWidget *navigation_bar; guint status_bar_clear_id; - + guint save_geometry_idle_id; + /** CORBA-related elements **/ NautilusApplication *application; @@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window); void nautilus_window_hide_status_bar (NautilusWindow *window); void nautilus_window_show_status_bar (NautilusWindow *window); gboolean nautilus_window_status_bar_showing (NautilusWindow *window); +void nautilus_window_save_geometry (NautilusWindow *window); #endif diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 3aae0577b..483c4d8ce 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static void +void nautilus_window_save_geometry (NautilusWindow *window) { char *geometry_string; - g_assert (NAUTILUS_IS_WINDOW (window)); - g_assert (GTK_WIDGET_VISIBLE (window)); + g_assert (NAUTILUS_IS_WINDOW (window)); - geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); + geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); nautilus_file_set_metadata (window->details->viewed_file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, @@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window) void nautilus_window_close (NautilusWindow *window) { - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - - /* Save the window position in the directory's metadata only if - * we're in every-location-in-its-own-window mode. Otherwise it - * would be too apparently random when the stored positions change. - */ - if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) { - nautilus_window_save_geometry (window); - } + g_return_if_fail (NAUTILUS_IS_WINDOW (window)); gtk_widget_destroy (GTK_WIDGET (window)); } diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h index 8039b94c6..19cb9b8d4 100644 --- a/src/nautilus-spatial-window.h +++ b/src/nautilus-spatial-window.h @@ -82,7 +82,8 @@ struct NautilusWindow { GtkWidget *navigation_bar; guint status_bar_clear_id; - + guint save_geometry_idle_id; + /** CORBA-related elements **/ NautilusApplication *application; @@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window); void nautilus_window_hide_status_bar (NautilusWindow *window); void nautilus_window_show_status_bar (NautilusWindow *window); gboolean nautilus_window_status_bar_showing (NautilusWindow *window); +void nautilus_window_save_geometry (NautilusWindow *window); #endif diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index b87b31f1f..c6d65a106 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -608,12 +608,6 @@ ref_now_unref_at_idle_time (GObject *object) g_idle_add (unref_callback, object); } -static gboolean -use_saved_window_positions (void) -{ - return eel_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW); -} - /* This is called when we have decided we can actually change to the new view/location situation. */ static void location_has_really_changed (NautilusWindow *window) @@ -658,8 +652,7 @@ location_has_really_changed (NautilusWindow *window) * metadata. Then tell the callback it needs to show the * window */ - if (!use_saved_window_positions () || - window->show_state == NAUTILUS_WINDOW_POSITION_SET) { + if (window->show_state == NAUTILUS_WINDOW_POSITION_SET) { gtk_widget_show (GTK_WIDGET (window)); } else { window->show_state = NAUTILUS_WINDOW_SHOULD_SHOW; @@ -1124,18 +1117,17 @@ position_and_show_window_callback (NautilusFile *file, window = NAUTILUS_WINDOW (callback_data); - if (use_saved_window_positions ()) { - geometry_string = nautilus_file_get_metadata + /* load the saved window geometry */ + geometry_string = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL); - if (geometry_string != NULL) { - eel_gtk_window_set_initial_geometry_from_string - (GTK_WINDOW (window), - geometry_string, - NAUTILUS_WINDOW_MIN_WIDTH, - NAUTILUS_WINDOW_MIN_HEIGHT); - } - g_free (geometry_string); + if (geometry_string != NULL) { + eel_gtk_window_set_initial_geometry_from_string + (GTK_WINDOW (window), + geometry_string, + NAUTILUS_WINDOW_MIN_WIDTH, + NAUTILUS_WINDOW_MIN_HEIGHT); } + g_free (geometry_string); /* If we finished constructing the window by now we need * to show the window here. @@ -1190,22 +1182,20 @@ determined_initial_view_callback (NautilusDetermineViewHandle *handle, * windows), position and show it only after we've got the * metadata (since position info is stored there). */ - if (use_saved_window_positions ()) { - window->show_state = NAUTILUS_WINDOW_NOT_SHOWN; - if (!GTK_WIDGET_VISIBLE (window)) { - file = nautilus_file_get (location); + window->show_state = NAUTILUS_WINDOW_NOT_SHOWN; + if (!GTK_WIDGET_VISIBLE (window)) { + file = nautilus_file_get (location); - attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); - nautilus_file_call_when_ready (file, - attributes, - position_and_show_window_callback, - window); - g_list_free (attributes); - } - } + attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); + nautilus_file_call_when_ready (file, + attributes, + position_and_show_window_callback, + window); + g_list_free (attributes); + } - load_content_view (window, initial_view); - return; + load_content_view (window, initial_view); + return; } /* Some sort of failure occurred. How 'bout we tell the user? */ diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 3aae0577b..483c4d8ce 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static void +void nautilus_window_save_geometry (NautilusWindow *window) { char *geometry_string; - g_assert (NAUTILUS_IS_WINDOW (window)); - g_assert (GTK_WIDGET_VISIBLE (window)); + g_assert (NAUTILUS_IS_WINDOW (window)); - geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); + geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); nautilus_file_set_metadata (window->details->viewed_file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, @@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window) void nautilus_window_close (NautilusWindow *window) { - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - - /* Save the window position in the directory's metadata only if - * we're in every-location-in-its-own-window mode. Otherwise it - * would be too apparently random when the stored positions change. - */ - if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) { - nautilus_window_save_geometry (window); - } + g_return_if_fail (NAUTILUS_IS_WINDOW (window)); gtk_widget_destroy (GTK_WIDGET (window)); } diff --git a/src/nautilus-window.h b/src/nautilus-window.h index 8039b94c6..19cb9b8d4 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -82,7 +82,8 @@ struct NautilusWindow { GtkWidget *navigation_bar; guint status_bar_clear_id; - + guint save_geometry_idle_id; + /** CORBA-related elements **/ NautilusApplication *application; @@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window); void nautilus_window_hide_status_bar (NautilusWindow *window); void nautilus_window_show_status_bar (NautilusWindow *window); gboolean nautilus_window_status_bar_showing (NautilusWindow *window); +void nautilus_window_save_geometry (NautilusWindow *window); #endif |