Make geomtry save methods per slot, rather than per window. The active

2008-07-22  Christian Neumair  <cneumair@gnome.org>

	* src/nautilus-spatial-window.c (save_window_geometry_timeout),
	(nautilus_spatial_window_unrealize),
	(nautilus_spatial_window_save_geometry),
	(nautilus_spatial_window_save_scroll_position),
	(nautilus_spatial_window_save_show_hidden_files_mode),
	(real_close_slot), (nautilus_spatial_window_class_init):
	* src/nautilus-spatial-window.h:
	Make geomtry save methods per slot, rather than per window. The active
	slot is set to NULL before they are closed. Fixes #542656.
	Thanks to Frederic Peters.

svn path=/trunk/; revision=14402
This commit is contained in:
Christian Neumair 2008-07-22 13:01:15 +00:00 committed by Christian Neumair
parent dbf7af666c
commit d2a2e27658
3 changed files with 42 additions and 32 deletions

View file

@ -1,3 +1,16 @@
2008-07-22 Christian Neumair <cneumair@gnome.org>
* src/nautilus-spatial-window.c (save_window_geometry_timeout),
(nautilus_spatial_window_unrealize),
(nautilus_spatial_window_save_geometry),
(nautilus_spatial_window_save_scroll_position),
(nautilus_spatial_window_save_show_hidden_files_mode),
(real_close_slot), (nautilus_spatial_window_class_init):
* src/nautilus-spatial-window.h:
Make geomtry save methods per slot, rather than per window. The active
slot is set to NULL before they are closed. Fixes #542656.
Thanks to Frederic Peters.
2008-07-21 Christian Neumair <cneumair@gnome.org> 2008-07-21 Christian Neumair <cneumair@gnome.org>
* src/nautilus-places-sidebar.c (enable_tabs_changed_callback), * src/nautilus-places-sidebar.c (enable_tabs_changed_callback),

View file

@ -93,14 +93,20 @@ static const GtkTargetEntry location_button_drag_types[] = {
G_DEFINE_TYPE(NautilusSpatialWindow, nautilus_spatial_window, NAUTILUS_TYPE_WINDOW) G_DEFINE_TYPE(NautilusSpatialWindow, nautilus_spatial_window, NAUTILUS_TYPE_WINDOW)
#define parent_class nautilus_spatial_window_parent_class #define parent_class nautilus_spatial_window_parent_class
static void nautilus_spatial_window_save_geometry (NautilusWindowSlot *slot);
static gboolean static gboolean
save_window_geometry_timeout (gpointer callback_data) save_window_geometry_timeout (gpointer callback_data)
{ {
NautilusSpatialWindow *window; NautilusSpatialWindow *window;
NautilusWindowSlot *slot;
window = NAUTILUS_SPATIAL_WINDOW (callback_data); window = NAUTILUS_SPATIAL_WINDOW (callback_data);
slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
nautilus_spatial_window_save_geometry (window); if (slot != NULL) {
nautilus_spatial_window_save_geometry (slot);
}
window->details->save_geometry_timeout_id = 0; window->details->save_geometry_timeout_id = 0;
@ -157,15 +163,20 @@ static void
nautilus_spatial_window_unrealize (GtkWidget *widget) nautilus_spatial_window_unrealize (GtkWidget *widget)
{ {
NautilusSpatialWindow *window; NautilusSpatialWindow *window;
NautilusWindowSlot *slot;
window = NAUTILUS_SPATIAL_WINDOW (widget); window = NAUTILUS_SPATIAL_WINDOW (widget);
slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
GTK_WIDGET_CLASS (nautilus_spatial_window_parent_class)->unrealize (widget); GTK_WIDGET_CLASS (nautilus_spatial_window_parent_class)->unrealize (widget);
if (window->details->save_geometry_timeout_id != 0) { if (window->details->save_geometry_timeout_id != 0) {
g_source_remove (window->details->save_geometry_timeout_id); g_source_remove (window->details->save_geometry_timeout_id);
window->details->save_geometry_timeout_id = 0; window->details->save_geometry_timeout_id = 0;
nautilus_spatial_window_save_geometry (window);
if (slot != NULL) {
nautilus_spatial_window_save_geometry (slot);
}
} }
} }
@ -242,17 +253,15 @@ nautilus_spatial_window_finalize (GObject *object)
G_OBJECT_CLASS (nautilus_spatial_window_parent_class)->finalize (object); G_OBJECT_CLASS (nautilus_spatial_window_parent_class)->finalize (object);
} }
void static void
nautilus_spatial_window_save_geometry (NautilusSpatialWindow *spatial_window) nautilus_spatial_window_save_geometry (NautilusWindowSlot *slot)
{ {
NautilusWindow *window; NautilusWindow *window;
NautilusWindowSlot *slot;
NautilusFile *viewed_file; NautilusFile *viewed_file;
char *geometry_string; char *geometry_string;
window = NAUTILUS_WINDOW (spatial_window); window = NAUTILUS_WINDOW (slot->window);
slot = window->details->active_slot;
viewed_file = slot->viewed_file; viewed_file = slot->viewed_file;
if (viewed_file == NULL) { if (viewed_file == NULL) {
@ -273,15 +282,13 @@ nautilus_spatial_window_save_geometry (NautilusSpatialWindow *spatial_window)
} }
} }
void static void
nautilus_spatial_window_save_scroll_position (NautilusSpatialWindow *window) nautilus_spatial_window_save_scroll_position (NautilusWindowSlot *slot)
{ {
NautilusWindow *nautilus_window; NautilusWindow *window;
NautilusWindowSlot *slot;
char *scroll_string; char *scroll_string;
nautilus_window = NAUTILUS_WINDOW (window); window = NAUTILUS_WINDOW (slot->window);
slot = nautilus_window_get_active_slot (nautilus_window);
if (slot->content_view == NULL) { if (slot->content_view == NULL) {
return; return;
@ -295,14 +302,14 @@ nautilus_spatial_window_save_scroll_position (NautilusSpatialWindow *window)
g_free (scroll_string); g_free (scroll_string);
} }
void static void
nautilus_spatial_window_save_show_hidden_files_mode (NautilusSpatialWindow *window) nautilus_spatial_window_save_show_hidden_files_mode (NautilusWindowSlot *slot)
{ {
NautilusWindowSlot *slot; NautilusWindow *window;
char *show_hidden_file_setting; char *show_hidden_file_setting;
NautilusWindowShowHiddenFilesMode mode; NautilusWindowShowHiddenFilesMode mode;
slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window)); window = NAUTILUS_WINDOW (slot->window);
mode = NAUTILUS_WINDOW (window)->details->show_hidden_files_mode; mode = NAUTILUS_WINDOW (window)->details->show_hidden_files_mode;
if (mode != NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { if (mode != NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) {
@ -398,14 +405,6 @@ real_sync_title (NautilusWindow *window,
sync_window_title (window); sync_window_title (window);
} }
static void
real_window_close (NautilusWindow *window)
{
nautilus_spatial_window_save_geometry (NAUTILUS_SPATIAL_WINDOW (window));
nautilus_spatial_window_save_scroll_position (NAUTILUS_SPATIAL_WINDOW (window));
nautilus_spatial_window_save_show_hidden_files_mode (NAUTILUS_SPATIAL_WINDOW (window));
}
static void static void
real_get_default_size (NautilusWindow *window, real_get_default_size (NautilusWindow *window,
guint *default_width, guint *default_height) guint *default_width, guint *default_height)
@ -466,7 +465,10 @@ real_close_slot (NautilusWindow *window,
{ {
g_assert (g_list_length (window->details->slots) == 1); g_assert (g_list_length (window->details->slots) == 1);
/* nothing to do */ nautilus_spatial_window_save_geometry (slot);
nautilus_spatial_window_save_scroll_position (slot);
nautilus_spatial_window_save_show_hidden_files_mode (slot);
EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
close_slot, (window, slot)); close_slot, (window, slot));
} }
@ -1029,8 +1031,6 @@ nautilus_spatial_window_class_init (NautilusSpatialWindowClass *class)
real_get_icon; real_get_icon;
NAUTILUS_WINDOW_CLASS (class)->sync_title = NAUTILUS_WINDOW_CLASS (class)->sync_title =
real_sync_title; real_sync_title;
NAUTILUS_WINDOW_CLASS (class)->close =
real_window_close;
NAUTILUS_WINDOW_CLASS(class)->get_default_size = real_get_default_size; NAUTILUS_WINDOW_CLASS(class)->get_default_size = real_get_default_size;
NAUTILUS_WINDOW_CLASS(class)->sync_allow_stop = NAUTILUS_WINDOW_CLASS(class)->sync_allow_stop =

View file

@ -57,9 +57,6 @@ struct _NautilusSpatialWindowClass {
GType nautilus_spatial_window_get_type (void); GType nautilus_spatial_window_get_type (void);
void nautilus_spatial_window_save_geometry (NautilusSpatialWindow *window);
void nautilus_spatial_window_save_scroll_position (NautilusSpatialWindow *window);
void nautilus_spatial_window_save_show_hidden_files_mode (NautilusSpatialWindow *window);
void nautilus_spatial_window_set_location_button (NautilusSpatialWindow *window, void nautilus_spatial_window_set_location_button (NautilusSpatialWindow *window,
GFile *location); GFile *location);