From 859c1b6fff05fd631da00be389654b3aa0248608 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 11 Jun 2009 22:36:45 +0000 Subject: [PATCH] (trunk gtk) #2201: transmission doesn't remember maximized state --- gtk/conf.c | 1 + gtk/main.c | 10 ++++++++++ gtk/tr-prefs.h | 1 + gtk/tr-window.c | 4 +++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gtk/conf.c b/gtk/conf.c index db83e4e03..b458c9c9a 100644 --- a/gtk/conf.c +++ b/gtk/conf.c @@ -180,6 +180,7 @@ tr_prefs_init_defaults( tr_benc * d ) tr_bencDictAddBool( d, PREF_KEY_OPTIONS_PROMPT, TRUE ); + tr_bencDictAddBool( d, PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED, FALSE ); tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_HEIGHT, 500 ); tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_WIDTH, 300 ); tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_X, 50 ); diff --git a/gtk/main.c b/gtk/main.c index 869dd9b53..d330d0c06 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -247,6 +247,8 @@ onMainWindowSizeAllocated( GtkWidget * window, && ( gdk_window_get_state( window->window ) & GDK_WINDOW_STATE_MAXIMIZED ); + pref_int_set( PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED, isMaximized ); + if( !isMaximized ) { int x, y, w, h; @@ -711,6 +713,14 @@ wannaquit( void * vdata ) /* clear the UI */ gtk_list_store_clear( GTK_LIST_STORE( tr_core_model( cbdata->core ) ) ); + /* ensure the window is in its previous position & size. + * this seems to be necessary because changing the main window's + * child seems to unset the size */ + gtk_window_resize( cbdata->wind, pref_int_get( PREF_KEY_MAIN_WINDOW_WIDTH ), + pref_int_get( PREF_KEY_MAIN_WINDOW_HEIGHT ) ); + gtk_window_move( cbdata->wind, pref_int_get( PREF_KEY_MAIN_WINDOW_X ), + pref_int_get( PREF_KEY_MAIN_WINDOW_Y ) ); + /* shut down libT */ g_thread_create( quitThreadFunc, vdata, TRUE, NULL ); } diff --git a/gtk/tr-prefs.h b/gtk/tr-prefs.h index 67d5110e8..75e81e869 100644 --- a/gtk/tr-prefs.h +++ b/gtk/tr-prefs.h @@ -45,5 +45,6 @@ GtkWidget * tr_prefs_dialog_new( GObject * core, #define PREF_KEY_MAIN_WINDOW_WIDTH "main-window-width" #define PREF_KEY_MAIN_WINDOW_X "main-window-x" #define PREF_KEY_MAIN_WINDOW_Y "main-window-y" +#define PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED "main-window-is-maximized" #endif diff --git a/gtk/tr-window.c b/gtk/tr-window.c index 97a8ea5ad..89f8cae27 100644 --- a/gtk/tr-window.c +++ b/gtk/tr-window.c @@ -832,7 +832,9 @@ tr_window_new( GtkUIManager * ui_mgr, TrCore * core ) pref_int_get( PREF_KEY_MAIN_WINDOW_WIDTH ), pref_int_get( PREF_KEY_MAIN_WINDOW_HEIGHT ) ); gtk_window_move( win, pref_int_get( PREF_KEY_MAIN_WINDOW_X ), - pref_int_get( PREF_KEY_MAIN_WINDOW_Y ) ); + pref_int_get( PREF_KEY_MAIN_WINDOW_Y ) ); + if( pref_flag_get( PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED ) ) + gtk_window_maximize( win ); gtk_window_add_accel_group( win, gtk_ui_manager_get_accel_group( ui_mgr ) ); /* window's main container */