Commit 97c03823 authored by Frank Worsley's avatar Frank Worsley Committed by Frank Worsley
Browse files

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
parent 8e5c3794
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
2002-06-10 Rajeev Karale <rajeev.karale@wipro.com> 2002-06-10 Rajeev Karale <rajeev.karale@wipro.com>
* libnautilus-private/nautilus-volume-monitor.c:finish_creating_volume() zip disk mount path fix for solaris. * libnautilus-private/nautilus-volume-monitor.c:finish_creating_volume() zip disk mount path fix for solaris.
......
...@@ -641,6 +641,57 @@ nautilus_window_delete_event_callback (GtkWidget *widget, ...@@ -641,6 +641,57 @@ nautilus_window_delete_event_callback (GtkWidget *widget,
return TRUE; 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 * NautilusWindow *
nautilus_application_create_window (NautilusApplication *application) nautilus_application_create_window (NautilusApplication *application)
{ {
...@@ -658,6 +709,12 @@ nautilus_application_create_window (NautilusApplication *application) ...@@ -658,6 +709,12 @@ nautilus_application_create_window (NautilusApplication *application)
g_signal_connect_object (window, "destroy", g_signal_connect_object (window, "destroy",
G_CALLBACK (nautilus_application_destroyed_window), application, 0); 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); 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 /* Do not yet show the window. It will be shown later on if it can
......
...@@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object) ...@@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static void void
nautilus_window_save_geometry (NautilusWindow *window) nautilus_window_save_geometry (NautilusWindow *window)
{ {
char *geometry_string; char *geometry_string;
g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (NAUTILUS_IS_WINDOW (window));
g_assert (GTK_WIDGET_VISIBLE (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_file_set_metadata (window->details->viewed_file,
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
...@@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window) ...@@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
void void
nautilus_window_close (NautilusWindow *window) nautilus_window_close (NautilusWindow *window)
{ {
g_return_if_fail (NAUTILUS_IS_WINDOW (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);
}
gtk_widget_destroy (GTK_WIDGET (window)); gtk_widget_destroy (GTK_WIDGET (window));
} }
......
...@@ -82,7 +82,8 @@ struct NautilusWindow { ...@@ -82,7 +82,8 @@ struct NautilusWindow {
GtkWidget *navigation_bar; GtkWidget *navigation_bar;
guint status_bar_clear_id; guint status_bar_clear_id;
guint save_geometry_idle_id;
/** CORBA-related elements **/ /** CORBA-related elements **/
NautilusApplication *application; NautilusApplication *application;
...@@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window); ...@@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window);
void nautilus_window_hide_status_bar (NautilusWindow *window); void nautilus_window_hide_status_bar (NautilusWindow *window);
void nautilus_window_show_status_bar (NautilusWindow *window); void nautilus_window_show_status_bar (NautilusWindow *window);
gboolean nautilus_window_status_bar_showing (NautilusWindow *window); gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
void nautilus_window_save_geometry (NautilusWindow *window);
#endif #endif
...@@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object) ...@@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static void void
nautilus_window_save_geometry (NautilusWindow *window) nautilus_window_save_geometry (NautilusWindow *window)
{ {
char *geometry_string; char *geometry_string;
g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (NAUTILUS_IS_WINDOW (window));
g_assert (GTK_WIDGET_VISIBLE (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_file_set_metadata (window->details->viewed_file,
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
...@@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window) ...@@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
void void
nautilus_window_close (NautilusWindow *window) nautilus_window_close (NautilusWindow *window)
{ {
g_return_if_fail (NAUTILUS_IS_WINDOW (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);
}
gtk_widget_destroy (GTK_WIDGET (window)); gtk_widget_destroy (GTK_WIDGET (window));
} }
......
...@@ -82,7 +82,8 @@ struct NautilusWindow { ...@@ -82,7 +82,8 @@ struct NautilusWindow {
GtkWidget *navigation_bar; GtkWidget *navigation_bar;
guint status_bar_clear_id; guint status_bar_clear_id;
guint save_geometry_idle_id;
/** CORBA-related elements **/ /** CORBA-related elements **/
NautilusApplication *application; NautilusApplication *application;
...@@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window); ...@@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window);
void nautilus_window_hide_status_bar (NautilusWindow *window); void nautilus_window_hide_status_bar (NautilusWindow *window);
void nautilus_window_show_status_bar (NautilusWindow *window); void nautilus_window_show_status_bar (NautilusWindow *window);
gboolean nautilus_window_status_bar_showing (NautilusWindow *window); gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
void nautilus_window_save_geometry (NautilusWindow *window);
#endif #endif
...@@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object) ...@@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static void void
nautilus_window_save_geometry (NautilusWindow *window) nautilus_window_save_geometry (NautilusWindow *window)
{ {
char *geometry_string; char *geometry_string;
g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (NAUTILUS_IS_WINDOW (window));
g_assert (GTK_WIDGET_VISIBLE (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_file_set_metadata (window->details->viewed_file,
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
...@@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window) ...@@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
void void
nautilus_window_close (NautilusWindow *window) nautilus_window_close (NautilusWindow *window)
{ {
g_return_if_fail (NAUTILUS_IS_WINDOW (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);
}
gtk_widget_destroy (GTK_WIDGET (window)); gtk_widget_destroy (GTK_WIDGET (window));
} }
......
...@@ -82,7 +82,8 @@ struct NautilusWindow { ...@@ -82,7 +82,8 @@ struct NautilusWindow {
GtkWidget *navigation_bar; GtkWidget *navigation_bar;
guint status_bar_clear_id; guint status_bar_clear_id;
guint save_geometry_idle_id;
/** CORBA-related elements **/ /** CORBA-related elements **/
NautilusApplication *application; NautilusApplication *application;
...@@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window); ...@@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window);
void nautilus_window_hide_status_bar (NautilusWindow *window); void nautilus_window_hide_status_bar (NautilusWindow *window);
void nautilus_window_show_status_bar (NautilusWindow *window); void nautilus_window_show_status_bar (NautilusWindow *window);
gboolean nautilus_window_status_bar_showing (NautilusWindow *window); gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
void nautilus_window_save_geometry (NautilusWindow *window);
#endif #endif
...@@ -608,12 +608,6 @@ ref_now_unref_at_idle_time (GObject *object) ...@@ -608,12 +608,6 @@ ref_now_unref_at_idle_time (GObject *object)
g_idle_add (unref_callback, 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. */ /* This is called when we have decided we can actually change to the new view/location situation. */
static void static void
location_has_really_changed (NautilusWindow *window) location_has_really_changed (NautilusWindow *window)
...@@ -658,8 +652,7 @@ 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 * metadata. Then tell the callback it needs to show the
* window * window
*/ */
if (!use_saved_window_positions () || if (window->show_state == NAUTILUS_WINDOW_POSITION_SET) {
window->show_state == NAUTILUS_WINDOW_POSITION_SET) {
gtk_widget_show (GTK_WIDGET (window)); gtk_widget_show (GTK_WIDGET (window));
} else { } else {
window->show_state = NAUTILUS_WINDOW_SHOULD_SHOW; window->show_state = NAUTILUS_WINDOW_SHOULD_SHOW;
...@@ -1124,18 +1117,17 @@ position_and_show_window_callback (NautilusFile *file, ...@@ -1124,18 +1117,17 @@ position_and_show_window_callback (NautilusFile *file,
window = NAUTILUS_WINDOW (callback_data); window = NAUTILUS_WINDOW (callback_data);
if (use_saved_window_positions ()) { /* load the saved window geometry */
geometry_string = nautilus_file_get_metadata geometry_string = nautilus_file_get_metadata
(file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL); (file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL);
if (geometry_string != NULL) { if (geometry_string != NULL) {
eel_gtk_window_set_initial_geometry_from_string eel_gtk_window_set_initial_geometry_from_string
(GTK_WINDOW (window), (GTK_WINDOW (window),
geometry_string, geometry_string,
NAUTILUS_WINDOW_MIN_WIDTH, NAUTILUS_WINDOW_MIN_WIDTH,
NAUTILUS_WINDOW_MIN_HEIGHT); NAUTILUS_WINDOW_MIN_HEIGHT);
}
g_free (geometry_string);
} }
g_free (geometry_string);
/* If we finished constructing the window by now we need /* If we finished constructing the window by now we need
* to show the window here. * to show the window here.
...@@ -1190,22 +1182,20 @@ determined_initial_view_callback (NautilusDetermineViewHandle *handle, ...@@ -1190,22 +1182,20 @@ determined_initial_view_callback (NautilusDetermineViewHandle *handle,
* windows), position and show it only after we've got the * windows), position and show it only after we've got the
* metadata (since position info is stored there). * metadata (since position info is stored there).
*/ */
if (use_saved_window_positions ()) { window->show_state = NAUTILUS_WINDOW_NOT_SHOWN;
window->show_state = NAUTILUS_WINDOW_NOT_SHOWN; if (!GTK_WIDGET_VISIBLE (window)) {
if (!GTK_WIDGET_VISIBLE (window)) { file = nautilus_file_get (location);
file = nautilus_file_get (location);
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA);
nautilus_file_call_when_ready (file, nautilus_file_call_when_ready (file,
attributes, attributes,
position_and_show_window_callback, position_and_show_window_callback,
window); window);
g_list_free (attributes); g_list_free (attributes);
} }
}
load_content_view (window, initial_view); load_content_view (window, initial_view);
return; return;
} }
/* Some sort of failure occurred. How 'bout we tell the user? */ /* Some sort of failure occurred. How 'bout we tell the user? */
......
...@@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object) ...@@ -864,15 +864,14 @@ nautilus_window_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static void void
nautilus_window_save_geometry (NautilusWindow *window) nautilus_window_save_geometry (NautilusWindow *window)
{ {
char *geometry_string; char *geometry_string;
g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (NAUTILUS_IS_WINDOW (window));
g_assert (GTK_WIDGET_VISIBLE (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_file_set_metadata (window->details->viewed_file,
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
...@@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window) ...@@ -884,15 +883,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
void void
nautilus_window_close (NautilusWindow *window) nautilus_window_close (NautilusWindow *window)
{ {
g_return_if_fail (NAUTILUS_IS_WINDOW (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);
}
gtk_widget_destroy (GTK_WIDGET (window)); gtk_widget_destroy (GTK_WIDGET (window));
} }
......
...@@ -82,7 +82,8 @@ struct NautilusWindow { ...@@ -82,7 +82,8 @@ struct NautilusWindow {
GtkWidget *navigation_bar; GtkWidget *navigation_bar;
guint status_bar_clear_id; guint status_bar_clear_id;
guint save_geometry_idle_id;
/** CORBA-related elements **/ /** CORBA-related elements **/
NautilusApplication *application; NautilusApplication *application;
...@@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window); ...@@ -153,5 +154,6 @@ gboolean nautilus_window_sidebar_showing (NautilusWindow *window);
void nautilus_window_hide_status_bar (NautilusWindow *window); void nautilus_window_hide_status_bar (NautilusWindow *window);
void nautilus_window_show_status_bar (NautilusWindow *window); void nautilus_window_show_status_bar (NautilusWindow *window);
gboolean nautilus_window_status_bar_showing (NautilusWindow *window); gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
void nautilus_window_save_geometry (NautilusWindow *window);
#endif #endif
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