qulogic/libgnt

2007ef7638dc
Parents 9df035598c9c
Children 09106094b6af
cross-win32: finch: keep your files in config dir
  • +11 -0
    gnt.h
  • +1 -1
    gntinternal.h
  • +22 -1
    gntmain.c
  • +2 -2
    gntwm.c
  • --- a/gnt.h Wed Apr 23 01:55:42 2014 +0200
    +++ b/gnt.h Wed Apr 23 12:35:57 2014 +0200
    @@ -57,6 +57,17 @@
    void gnt_init(void);
    /**
    + * gnt_set_config_dir:
    + * @config_dir: the path to a configuration directory, may be %NULL.
    + *
    + * Change directory to store gnt configuration files (default is ~).
    + *
    + * You have to call this before #gnt_init. You might want to call this
    + * with %NULL, to free the resources, but not before a call to #gnt_quit.
    + */
    +void gnt_set_config_dir(const gchar *config_dir);
    +
    +/**
    * gnt_main:
    *
    * Start running the mainloop for gnt.
    --- a/gntinternal.h Wed Apr 23 01:55:42 2014 +0200
    +++ b/gntinternal.h Wed Apr 23 12:35:57 2014 +0200
    @@ -44,4 +44,4 @@
    extern int gnt_need_conversation_to_locale;
    extern const char *C_(const char *x);
    -
    +const gchar *gnt_get_config_dir(void);
    --- a/gntmain.c Wed Apr 23 01:55:42 2014 +0200
    +++ b/gntmain.c Wed Apr 23 12:35:57 2014 +0200
    @@ -93,6 +93,8 @@
    int gnt_need_conversation_to_locale;
    +static gchar *custom_config_dir = NULL;
    +
    #define HOLDING_ESCAPE (escape_stuff.timer != 0)
    static struct {
    @@ -107,6 +109,25 @@
    return FALSE;
    }
    +void
    +gnt_set_config_dir(const gchar *config_dir)
    +{
    + if (channel) {
    + gnt_warning("gnt_set_config_dir failed: %s",
    + "gnt already initialized");
    + }
    + free(custom_config_dir);
    + custom_config_dir = g_strdup(config_dir);
    +}
    +
    +const gchar *
    +gnt_get_config_dir(void)
    +{
    + if (custom_config_dir)
    + return custom_config_dir;
    + return g_get_home_dir();
    +}
    +
    #ifndef _WIN32
    /**
    * detect_mouse_action:
    @@ -613,7 +634,7 @@
    gnt_init_keys();
    gnt_init_styles();
    - filename = g_build_filename(g_get_home_dir(), ".gntrc", NULL);
    + filename = g_build_filename(gnt_get_config_dir(), ".gntrc", NULL);
    gnt_style_read_configure_file(filename);
    g_free(filename);
    --- a/gntwm.c Wed Apr 23 01:55:42 2014 +0200
    +++ b/gntwm.c Wed Apr 23 12:35:57 2014 +0200
    @@ -331,7 +331,7 @@
    read_window_positions(GntWM *wm)
    {
    GKeyFile *gfile = g_key_file_new();
    - char *filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL);
    + char *filename = g_build_filename(gnt_get_config_dir(), ".gntpositions", NULL);
    GError *error = NULL;
    char **keys;
    gsize nk;
    @@ -2120,7 +2120,7 @@
    FILE *file;
    char *filename;
    - filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL);
    + filename = g_build_filename(gnt_get_config_dir(), ".gntpositions", NULL);
    file = fopen(filename, "wb");
    if (file == NULL) {