aboutsummaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-08-01 13:33:42 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-08-01 13:33:42 +0200
commit72ec802e0387953f19520cace2f63e6db919323b (patch)
tree735129dc77e6ad4e4d8eb4e653dec569f9e729a7 /src/config.c
parent6f6f19847c045271ae2d39f330576d92a88c1667 (diff)
downloadgtk-vlc-player-72ec802e0387953f19520cace2f63e6db919323b.tar.gz
save/restore window positions
* use X-style geometry strings * glade-configured default window sizes serve as configuration defaults * don't let glade show the windows since after they are shown, gtk_window_parse_geometry() cannot set the default size * prevent (main) window deletion from destroying the window widget so we can still query window properties (like position and size) * explicitly destroy window widgets (currently broken) * saving/restoring window position can be disabled via config file since some window managers can restore positions on their own (KDE...)
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 9c0927d..20f8260 100644
--- a/src/config.c
+++ b/src/config.c
@@ -36,7 +36,11 @@
static inline void set_default_string(const gchar *group_name, const gchar *key,
const gchar *string);
+static inline void set_default_boolean(const gchar *group_name, const gchar *key,
+ gboolean boolean);
+
static const gchar *get_group_by_actor(const gchar *actor);
+static const gchar *get_group_by_window(const gchar *window);
static GKeyFile *keyfile;
static gchar *filename = NULL;
@@ -55,6 +59,8 @@ config_init_key_file(void)
CONFIG_KEY_FILE, NULL);
/* initialize defaults */
+ set_default_boolean("Global", "Save-Window-Properties", TRUE);
+
set_default_string("Directories", "Quick-Open", DEFAULT_QUICKOPEN_DIR);
set_default_string("Directories", "Formats", DEFAULT_FORMATS_DIR);
@@ -86,6 +92,51 @@ set_default_string(const gchar *group_name, const gchar *key,
g_key_file_set_string(keyfile, group_name, key, string);
}
+static inline void
+set_default_boolean(const gchar *group_name, const gchar *key,
+ gboolean boolean)
+{
+ if (!g_key_file_has_key(keyfile, group_name, key, NULL))
+ g_key_file_set_boolean(keyfile, group_name, key, boolean);
+}
+
+void
+config_set_save_window_properties(gboolean enabled)
+{
+ g_key_file_set_boolean(keyfile, "Global",
+ "Save-Window-Properties", enabled);
+}
+
+gboolean
+config_get_save_window_properties(void)
+{
+ return g_key_file_get_boolean(keyfile, "Global",
+ "Save-Window-Properties", NULL);
+}
+
+static const gchar *
+get_group_by_window(const gchar *window)
+{
+ static gchar group[255];
+
+ g_snprintf(group, sizeof(group), "%s Window", window);
+ return group;
+}
+
+void
+config_set_window_geometry(const gchar *window, const gchar *geometry)
+{
+ g_key_file_set_string(keyfile, get_group_by_window(window),
+ "Geometry", geometry);
+}
+
+gchar *
+config_get_window_geometry(const gchar *window)
+{
+ return g_key_file_get_string(keyfile, get_group_by_window(window),
+ "Geometry", NULL);
+}
+
void
config_set_quickopen_directory(const gchar *dir)
{