Skip to content

Commit

Permalink
Merge pull request #679 from eht16/geanyvc_commit_dialog_size
Browse files Browse the repository at this point in the history
GeanyVC: Remember the commit dialog size
  • Loading branch information
frlan authored Jan 20, 2018
2 parents 67ba90d + aead2f1 commit 44b12b5
Showing 1 changed file with 68 additions and 43 deletions.
111 changes: 68 additions & 43 deletions geanyvc/src/geanyvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ static gboolean set_maximize_commit_dialog;
static gboolean set_external_diff;
static gboolean set_editor_menu_entries;
static gboolean set_menubar_entry;
static gint commit_dialog_width = 0;
static gint commit_dialog_height = 0;

static gchar *config_file;

Expand Down Expand Up @@ -1598,6 +1600,8 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer
else
{
gtk_widget_set_size_request(commit, 700, 500);
gtk_window_set_default_size(GTK_WINDOW(commit),
commit_dialog_width, commit_dialog_height);
}

gtk_widget_show_now(commit);
Expand Down Expand Up @@ -1635,6 +1639,9 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer
}
g_free(message);
}
/* remember commit dialog widget size */
gtk_window_get_size(GTK_WINDOW(commit),
&commit_dialog_width, &commit_dialog_height);

gtk_widget_destroy(commit);
free_commit_list(lst);
Expand Down Expand Up @@ -1785,16 +1792,66 @@ static struct
}
widgets;

static void
save_config(void)
{
GKeyFile *config = g_key_file_new();
gchar *config_dir = g_path_get_dirname(config_file);

g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);

g_key_file_set_boolean(config, "VC", "set_changed_flag", set_changed_flag);
g_key_file_set_boolean(config, "VC", "set_add_confirmation", set_add_confirmation);
g_key_file_set_boolean(config, "VC", "set_external_diff", set_external_diff);
g_key_file_set_boolean(config, "VC", "set_maximize_commit_dialog",
set_maximize_commit_dialog);
g_key_file_set_boolean(config, "VC", "set_editor_menu_entries", set_editor_menu_entries);
g_key_file_set_boolean(config, "VC", "attach_to_menubar", set_menubar_entry);

g_key_file_set_boolean(config, "VC", "enable_cvs", enable_cvs);
g_key_file_set_boolean(config, "VC", "enable_git", enable_git);
g_key_file_set_boolean(config, "VC", "enable_svn", enable_svn);
g_key_file_set_boolean(config, "VC", "enable_svk", enable_svk);
g_key_file_set_boolean(config, "VC", "enable_bzr", enable_bzr);
g_key_file_set_boolean(config, "VC", "enable_hg", enable_hg);

#ifdef USE_GTKSPELL
g_key_file_set_string(config, "VC", "spellchecking_language", lang);
#endif

if (commit_dialog_width > 0 && commit_dialog_height > 0)
{
g_key_file_set_integer(config, "CommitDialog",
"commit_dialog_width", commit_dialog_width);
g_key_file_set_integer(config, "CommitDialog",
"commit_dialog_height", commit_dialog_height);
}

if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR)
&& utils_mkdir(config_dir, TRUE) != 0)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_
("Plugin configuration directory could not be created."));
}
else
{
/* write config to file */
gchar *data = g_key_file_to_data(config, NULL, NULL);
utils_write_file(config_file, data);
g_free(data);
}

g_free(config_dir);
g_key_file_free(config);
}

static void
on_configure_response(G_GNUC_UNUSED GtkDialog * dialog, gint response,
G_GNUC_UNUSED gpointer user_data)
{
if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
{
GKeyFile *config = g_key_file_new();
gchar *data;
gchar *config_dir = g_path_get_dirname(config_file);

set_changed_flag =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets.cb_changed_flag));
set_add_confirmation =
Expand Down Expand Up @@ -1822,51 +1879,13 @@ on_configure_response(G_GNUC_UNUSED GtkDialog * dialog, gint response,
lang = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.spellcheck_lang_textbox)));
#endif

g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);

g_key_file_set_boolean(config, "VC", "set_changed_flag", set_changed_flag);
g_key_file_set_boolean(config, "VC", "set_add_confirmation", set_add_confirmation);
g_key_file_set_boolean(config, "VC", "set_external_diff", set_external_diff);
g_key_file_set_boolean(config, "VC", "set_maximize_commit_dialog",
set_maximize_commit_dialog);
g_key_file_set_boolean(config, "VC", "set_editor_menu_entries", set_editor_menu_entries);
g_key_file_set_boolean(config, "VC", "attach_to_menubar", set_menubar_entry);

g_key_file_set_boolean(config, "VC", "enable_cvs", enable_cvs);
g_key_file_set_boolean(config, "VC", "enable_git", enable_git);
g_key_file_set_boolean(config, "VC", "enable_svn", enable_svn);
g_key_file_set_boolean(config, "VC", "enable_svk", enable_svk);
g_key_file_set_boolean(config, "VC", "enable_bzr", enable_bzr);
g_key_file_set_boolean(config, "VC", "enable_hg", enable_hg);

#ifdef USE_GTKSPELL
g_key_file_set_string(config, "VC", "spellchecking_language", lang);
#endif

if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR)
&& utils_mkdir(config_dir, TRUE) != 0)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_
("Plugin configuration directory could not be created."));
}
else
{
/* write config to file */
data = g_key_file_to_data(config, NULL, NULL);
utils_write_file(config_file, data);
g_free(data);
}
save_config();

if (set_editor_menu_entries == FALSE)
remove_menuitems_from_editor_menu();
else
add_menuitems_to_editor_menu();


g_free(config_dir);
g_key_file_free(config);

registrate();
}
}
Expand Down Expand Up @@ -2030,6 +2049,11 @@ load_config(void)
}
#endif

commit_dialog_width = utils_get_setting_integer(config, "CommitDialog",
"commit_dialog_width", 700);
commit_dialog_height = utils_get_setting_integer(config, "CommitDialog",
"commit_dialog_height", 500);

g_key_file_free(config);
}

Expand Down Expand Up @@ -2378,6 +2402,7 @@ plugin_init(G_GNUC_UNUSED GeanyData * data)
void
plugin_cleanup(void)
{
save_config();
external_diff_viewer_deinit();
remove_menuitems_from_editor_menu();
gtk_widget_destroy(menu_entry);
Expand Down

0 comments on commit 44b12b5

Please sign in to comment.