diff options
author | Stefano Karapetsas <[email protected]> | 2014-01-27 11:52:36 +0100 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2014-01-27 11:52:36 +0100 |
commit | f4012ecd2751f3bb280604087de71f6a4009a9a9 (patch) | |
tree | 61b6193e292d8d8c539deace0d3db4cc76f1b441 /capplets | |
parent | 3ca08cb10bd7650d771da98c457460556cc43db5 (diff) | |
download | mate-control-center-f4012ecd2751f3bb280604087de71f6a4009a9a9.tar.bz2 mate-control-center-f4012ecd2751f3bb280604087de71f6a4009a9a9.tar.xz |
appearance: Add support for 'artist' tag in xml backgrounds files
This feature was already implemented in Linux Mint and Cinnamon, so
we are going to implement it in MATE too.
Diffstat (limited to 'capplets')
-rw-r--r-- | capplets/appearance/mate-wp-item.c | 21 | ||||
-rw-r--r-- | capplets/appearance/mate-wp-item.h | 3 | ||||
-rw-r--r-- | capplets/appearance/mate-wp-xml.c | 16 |
3 files changed, 35 insertions, 5 deletions
diff --git a/capplets/appearance/mate-wp-item.c b/capplets/appearance/mate-wp-item.c index d11fa896..96e7d67a 100644 --- a/capplets/appearance/mate-wp-item.c +++ b/capplets/appearance/mate-wp-item.c @@ -279,10 +279,16 @@ void mate_wp_item_update_description (MateWPItem * item) { const gchar *description; gchar *size; gchar *dirname = g_path_get_dirname (item->filename); + gchar *artist; description = NULL; size = NULL; + if (!item->artist || item->artist[0] == 0 || !g_strcmp0(item->artist, "(none)")) + artist = g_strdup (_("unknown")); + else + artist = g_strdup (item->artist); + if (strcmp (item->fileinfo->mime_type, "application/xml") == 0) { if (mate_bg_changes_with_time (item->bg)) @@ -308,28 +314,35 @@ void mate_wp_item_update_description (MateWPItem * item) { /* translators: <b>wallpaper name</b> * mime type, size * Folder: /path/to/file + * Artist: wallpaper author */ item->description = g_markup_printf_escaped (_("<b>%s</b>\n" "%s, %s\n" - "Folder: %s"), + "Folder: %s\n" + "Artist: %s"), item->name, description, size, - dirname); + dirname, + artist); } else { /* translators: <b>wallpaper name</b> * Image missing * Folder: /path/to/file + * Artist: wallpaper author */ item->description = g_markup_printf_escaped (_("<b>%s</b>\n" "%s\n" - "Folder: %s"), + "Folder: %s\n" + "Artist: %s"), item->name, _("Image missing"), - dirname); + dirname, + artist); } g_free (size); g_free (dirname); + g_free (artist); } } diff --git a/capplets/appearance/mate-wp-item.h b/capplets/appearance/mate-wp-item.h index a6e13f24..5e336d53 100644 --- a/capplets/appearance/mate-wp-item.h +++ b/capplets/appearance/mate-wp-item.h @@ -53,6 +53,9 @@ struct _MateWPItem { /* Did the user remove us? */ gboolean deleted; + /* Wallpaper author, if present */ + gchar *artist; + /* Width and Height of the original image */ gint width; gint height; diff --git a/capplets/appearance/mate-wp-xml.c b/capplets/appearance/mate-wp-xml.c index d6b0c71d..11e19235 100644 --- a/capplets/appearance/mate-wp-xml.c +++ b/capplets/appearance/mate-wp-xml.c @@ -145,7 +145,7 @@ static void mate_wp_xml_load_xml(AppearanceData* data, const char* filename) { MateWPItem * wp; char *pcolor = NULL, *scolor = NULL; - gboolean have_scale = FALSE, have_shade = FALSE; + gboolean have_scale = FALSE, have_shade = FALSE, have_artist = FALSE; wp = g_new0(MateWPItem, 1); @@ -242,6 +242,14 @@ static void mate_wp_xml_load_xml(AppearanceData* data, const char* filename) scolor = g_strdup(g_strstrip ((char *)wpa->last->content)); } } + else if (!strcmp ((char*) wpa->name, "artist")) + { + if (wpa->last != NULL) + { + wp->artist = g_strdup (g_strstrip ((char *)wpa->last->content)); + have_artist = TRUE; + } + } else if (!strcmp ((char*) wpa->name, "text")) { /* Do nothing here, libxml2 is being weird */ @@ -283,6 +291,11 @@ static void mate_wp_xml_load_xml(AppearanceData* data, const char* filename) scolor = g_settings_get_string (data->wp_settings, WP_SCOLOR_KEY); } + if (!have_artist) + { + wp->artist = g_strdup ("(none)"); + } + gdk_color_parse(pcolor, &color1); gdk_color_parse(scolor, &color2); g_free(pcolor); @@ -541,6 +554,7 @@ void mate_wp_xml_save_list(AppearanceData* data) xmlNewTextChild(wallpaper, NULL, (xmlChar*) "shade_type", (xmlChar*) shade); xmlNewTextChild(wallpaper, NULL, (xmlChar*) "pcolor", (xmlChar*) pcolor); xmlNewTextChild(wallpaper, NULL, (xmlChar*) "scolor", (xmlChar*) scolor); + xmlNewTextChild(wallpaper, NULL, (xmlChar*) "artist", (xmlChar*) wpitem->artist); g_free(pcolor); g_free(scolor); |