[Xfce4-commits] <xfce4-weather-plugin:master> Move code to create and get cache directory into its own function.
Harald Judt
noreply at xfce.org
Sun Dec 9 23:44:04 CET 2012
Updating branch refs/heads/master
to ceb132572312e560e00923379c1abc2556897151 (commit)
from dd32a6346f87b14874ad0de07e174c4467fe8463 (commit)
commit ceb132572312e560e00923379c1abc2556897151
Author: Harald Judt <h.judt at gmx.at>
Date: Sun Dec 9 19:24:04 2012 +0100
Move code to create and get cache directory into its own function.
panel-plugin/weather-summary.c | 16 +++++++---------
panel-plugin/weather.c | 15 +++++++++++++++
panel-plugin/weather.h | 4 +++-
3 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index 785c2ac..b916b29 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -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;
}
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 95b4cb3..2c16e41 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -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)
{
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index 87ce68e..042ec54 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -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
More information about the Xfce4-commits
mailing list