grim/glibre

1b357a556d35
Parents 5c3313eedd26
Children 27386da497db
remember and restore the main window's size

fixes #25
  • +16 -0
    glibre.c
  • --- a/glibre.c Sat Jul 24 14:29:09 2010 -0500
    +++ b/glibre.c Sat Jul 24 14:50:29 2010 -0500
    @@ -213,6 +213,7 @@
    glibre_load_config(void) {
    GKeyFile *key_file = NULL;
    gchar *conf_file = NULL, *layout_file = NULL;
    + gint width, height;
    conf_file = glibre_config_file("glibre.conf");
    @@ -243,6 +244,15 @@
    return;
    }
    + /* main window */
    + width = g_key_file_get_integer(key_file, "window", "width", NULL);
    + height = g_key_file_get_integer(key_file, "window", "height", NULL);
    +
    + width = (width > 0) ? width : -1;
    + height = (height > 0) ? height : -1;
    +
    + gtk_window_set_default_size(GTK_WINDOW(window.window), width, height);
    +
    /* entries */
    glibre_load_entry(GLIBRE_ENTRIES_GROUP, GLIBRE_REGEX, window.regex_entry);
    glibre_load_entry(GLIBRE_ENTRIES_GROUP, GLIBRE_REPLACE_WITH, window.replace_entry);
    @@ -319,6 +329,7 @@
    GKeyFile *key_file = NULL;
    gchar *data = NULL;
    gchar *conf_dir = NULL, *conf_file = NULL, *layout_file = NULL;
    + gint width, height;
    conf_dir = glibre_config_file(NULL);
    if(g_mkdir_with_parents(conf_dir, 0755) != 0) {
    @@ -345,6 +356,11 @@
    key_file = g_key_file_new();
    + /* main window */
    + gtk_window_get_size(GTK_WINDOW(window.window), &width, &height);
    + g_key_file_set_integer(key_file, "window", "width", width);
    + g_key_file_set_integer(key_file, "window", "height", height);
    +
    /* entries */
    glibre_save_entry(GLIBRE_ENTRIES_GROUP, GLIBRE_REGEX, window.regex_entry);
    glibre_save_entry(GLIBRE_ENTRIES_GROUP, GLIBRE_REPLACE_WITH, window.replace_entry);