Commit ceb13257 authored by Harald Judt's avatar Harald Judt

Move code to create and get cache directory into its own function.

parent dd32a634
......@@ -213,15 +213,13 @@ view_size_allocate_cb(GtkWidget *widget,
static gchar *
get_logo_path(void)
{
gchar *dir = g_strconcat(g_get_user_cache_dir(), G_DIR_SEPARATOR_S,
"xfce4", G_DIR_SEPARATOR_S, "weather-plugin",
NULL);
g_mkdir_with_parents(dir, 0755);
g_free(dir);
return g_strconcat(g_get_user_cache_dir(), G_DIR_SEPARATOR_S,
"xfce4", G_DIR_SEPARATOR_S, "weather-plugin",
G_DIR_SEPARATOR_S, "weather_logo.gif", NULL);
gchar *cache_dir, *logo_path;
cache_dir = get_cache_directory();
logo_path = g_strconcat(cache_dir, G_DIR_SEPARATOR_S,
"weather_logo.gif", NULL);
g_free(cache_dir);
return logo_path;
}
......
......@@ -161,6 +161,21 @@ make_label(const xfceweather_data *data,
}
/*
* Return the weather plugin cache directory, creating it if
* necessary. The string returned does not contain a trailing slash.
*/
gchar *
get_cache_directory(void)
{
gchar *dir = g_strconcat(g_get_user_cache_dir(), G_DIR_SEPARATOR_S,
"xfce4", G_DIR_SEPARATOR_S, "weather-plugin",
NULL);
g_mkdir_with_parents(dir, 0755);
return dir;
}
void
update_icon(xfceweather_data *data)
{
......
......@@ -111,13 +111,15 @@ void scrollbox_set_visible(xfceweather_data *data);
void forecast_click(GtkWidget *widget,
gpointer user_data);
gchar *get_cache_directory(void);
void update_icon(xfceweather_data *data);
void update_scrollbox(xfceweather_data *data);
void update_weatherdata_with_reset(xfceweather_data *data);
GArray* labels_clear(GArray *array);
GArray *labels_clear(GArray *array);
G_END_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment