Improve pane position saving code

We should test for being in PANE_THREE mode in save_pane_position() and
replace the if()'s testing against window geometry. This eliminates some
code duplication and, more importantly, save_pane_position() is also
called from save_window_geometry() whose calling pattern is not obvious.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2013-03-04 09:15:46 +01:00 committed by Dirk Hohndel
parent a5a3e0a72e
commit c13a10986e

View file

@ -330,13 +330,11 @@ void save_pane_position()
{
gint vpane_position = gtk_paned_get_position(GTK_PANED(vpane));
gint hpane_position = gtk_paned_get_position(GTK_PANED(hpane));
int window_width, window_height;
gtk_window_get_size(GTK_WINDOW (main_window), &window_width, &window_height);
if (vpane_position && vpane_position < window_height - 12)
if (pane_conf == PANE_THREE){
subsurface_set_conf_int("vpane_position", vpane_position);
if (hpane_position && hpane_position < window_width - 6 )
subsurface_set_conf_int("hpane_position", hpane_position);
}
}
void save_window_geometry(void)
@ -1176,16 +1174,14 @@ static void show_user_manual(GtkWidget *w, gpointer data)
static void view_list(GtkWidget *w, gpointer data)
{
if (pane_conf == PANE_THREE)
save_pane_position();
save_pane_position();
gtk_paned_set_position(GTK_PANED(vpane), 0);
pane_conf = PANE_LIST;
}
static void view_profile(GtkWidget *w, gpointer data)
{
if (pane_conf == PANE_THREE)
save_pane_position();
save_pane_position();
gtk_paned_set_position(GTK_PANED(hpane), 0);
gtk_paned_set_position(GTK_PANED(vpane), 65535);
pane_conf = PANE_PROFILE;
@ -1193,8 +1189,8 @@ static void view_profile(GtkWidget *w, gpointer data)
static void view_info(GtkWidget *w, gpointer data)
{
if (pane_conf == PANE_THREE)
save_pane_position();
save_pane_position();
gtk_paned_set_position(GTK_PANED(vpane), 65535);
gtk_paned_set_position(GTK_PANED(hpane), 65535);
pane_conf = PANE_INFO;