Added an option to save/reload either window position or

size, but optionally not both.
This commit is contained in:
delt 2017-03-31 00:24:52 -04:00 committed by Matthew Brush
parent 745f424b77
commit 38147b2590
5 changed files with 56 additions and 23 deletions

View File

@ -941,12 +941,12 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="check_save_win_pos">
<property name="label" translatable="yes">Save window position and geometry</property>
<object class="GtkCheckButton" id="check_save_win_geom">
<property name="label" translatable="yes">Save window size</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Saves the window position and geometry and restores it at the start</property>
<property name="tooltip_text" translatable="yes">Saves the window size and restores it at the start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
@ -956,6 +956,22 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_save_win_pos">
<property name="label" translatable="yes">Save window position</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Saves the window position and restores it at the start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_ask_for_quit">
<property name="label" translatable="yes">Confirm exit</property>
@ -969,7 +985,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>

View File

@ -422,7 +422,8 @@ static void save_dialog_prefs(GKeyFile *config)
g_key_file_set_boolean(config, PACKAGE, "pref_main_load_session", prefs.load_session);
g_key_file_set_boolean(config, PACKAGE, "pref_main_project_session", project_prefs.project_session);
g_key_file_set_boolean(config, PACKAGE, "pref_main_project_file_in_basedir", project_prefs.project_file_in_basedir);
g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", prefs.save_winpos);
g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", prefs.save_winpos);
g_key_file_set_boolean(config, PACKAGE, "pref_main_save_wingeom", prefs.save_wingeom);
g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", prefs.confirm_exit);
g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_status_messages", prefs.suppress_status_messages);
g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_to_status);
@ -576,7 +577,7 @@ static void save_ui_prefs(GKeyFile *config)
g_key_file_set_integer(config, PACKAGE, "scribble_pos", scribble_pos);
}
if (prefs.save_winpos)
if (prefs.save_winpos || prefs.save_wingeom)
{
GdkWindowState wstate;
@ -758,7 +759,8 @@ static void load_dialog_prefs(GKeyFile *config)
prefs.load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE);
project_prefs.project_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_session", TRUE);
project_prefs.project_file_in_basedir = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_file_in_basedir", FALSE);
prefs.save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
prefs.save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
prefs.save_wingeom = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_wingeom", TRUE);
prefs.beep_on_errors = utils_get_setting_boolean(config, PACKAGE, "beep_on_errors", TRUE);
prefs.switch_to_status = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE);
prefs.auto_focus = utils_get_setting_boolean(config, PACKAGE, "auto_focus", FALSE);

View File

@ -148,19 +148,27 @@ static GOptionEntry entries[] =
static void setup_window_position(void)
{
/* interprets the saved window geometry */
if (!prefs.save_winpos)
return;
if (prefs.save_wingeom)
{
if (ui_prefs.geometry[2] != -1 && ui_prefs.geometry[3] != -1)
{
gtk_window_set_default_size(GTK_WINDOW(main_widgets.window),
ui_prefs.geometry[2], ui_prefs.geometry[3]);
}
}
if (ui_prefs.geometry[0] != -1 && ui_prefs.geometry[1] != -1)
gtk_window_move(GTK_WINDOW(main_widgets.window),
ui_prefs.geometry[0], ui_prefs.geometry[1]);
if (ui_prefs.geometry[2] != -1 && ui_prefs.geometry[3] != -1)
gtk_window_set_default_size(GTK_WINDOW(main_widgets.window),
ui_prefs.geometry[2], ui_prefs.geometry[3]);
if (ui_prefs.geometry[4] == 1)
gtk_window_maximize(GTK_WINDOW(main_widgets.window));
if (prefs.save_winpos)
{
if (ui_prefs.geometry[0] != -1 && ui_prefs.geometry[1] != -1)
{
gtk_window_move(GTK_WINDOW(main_widgets.window),
ui_prefs.geometry[0], ui_prefs.geometry[1]);
}
if (ui_prefs.geometry[4] == 1)
{
gtk_window_maximize(GTK_WINDOW(main_widgets.window));
}
}
}

View File

@ -417,8 +417,11 @@ static void prefs_init_dialog(void)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_project_file_in_basedir");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), project_prefs.project_file_in_basedir);
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_save_win_pos");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.save_winpos);
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_save_win_pos");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.save_winpos);
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_save_win_geom");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.save_wingeom);
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_ask_for_quit");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.confirm_exit);
@ -897,8 +900,11 @@ on_prefs_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_project_file_in_basedir");
project_prefs.project_file_in_basedir = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_save_win_pos");
prefs.save_winpos = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_save_win_pos");
prefs.save_winpos = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_save_win_geom");
prefs.save_wingeom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_ask_for_quit");
prefs.confirm_exit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

View File

@ -39,6 +39,7 @@ typedef struct GeanyPrefs
gboolean auto_focus;
gchar *default_open_path; /**< Default path to look for files when no other path is appropriate. */
gchar *custom_plugin_path;
gboolean save_wingeom;
}
GeanyPrefs;