[gnac/devel] Improved the trayicon's tooltips
- From: Benoît Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Improved the trayicon's tooltips
- Date: Sun, 9 May 2010 20:51:19 +0000 (UTC)
commit 1a619a5c25eda37666e5a99bb66f7185672002ba
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date: Sun May 9 21:50:04 2010 +0100
Improved the trayicon's tooltips
libgnac/libgnac-output.c | 10 +++++-----
src/gnac-ui.c | 33 +++++++++++++++++++++++----------
2 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/libgnac/libgnac-output.c b/libgnac/libgnac-output.c
index 2e3bc95..f5a98e2 100644
--- a/libgnac/libgnac-output.c
+++ b/libgnac/libgnac-output.c
@@ -204,7 +204,7 @@ libgnac_output_replace_pattern(LibgnacRenamePattern *pattern,
if (libgnac_metadata_tag_exists(tags, GST_TAG_ARTIST))
{
val = LIBGNAC_METADATA_TAG_ARTIST(tags);
- return g_strdup(g_value_get_string(val));
+ return g_value_dup_string(val);
}
return RENAME_PATTERN_DEFAULT_ARTIST;
}
@@ -213,7 +213,7 @@ libgnac_output_replace_pattern(LibgnacRenamePattern *pattern,
if (libgnac_metadata_tag_exists(tags, GST_TAG_ALBUM))
{
val = LIBGNAC_METADATA_TAG_ALBUM(tags);
- return g_strdup(g_value_get_string(val));
+ return g_value_dup_string(val);
}
return RENAME_PATTERN_DEFAULT_ALBUM;
}
@@ -240,7 +240,7 @@ libgnac_output_replace_pattern(LibgnacRenamePattern *pattern,
if (libgnac_metadata_tag_exists(tags, GST_TAG_COMMENT))
{
val = LIBGNAC_METADATA_TAG_COMMENT(tags);
- return g_strdup(g_value_get_string(val));
+ return g_value_dup_string(val);
}
return RENAME_PATTERN_DEFAULT_COMMENT;
}
@@ -267,7 +267,7 @@ libgnac_output_replace_pattern(LibgnacRenamePattern *pattern,
if (libgnac_metadata_tag_exists(tags, GST_TAG_GENRE))
{
val = LIBGNAC_METADATA_TAG_GENRE(tags);
- return g_strdup(g_value_get_string(val));
+ return g_value_dup_string(val);
}
return RENAME_PATTERN_DEFAULT_GENRE;
}
@@ -276,7 +276,7 @@ libgnac_output_replace_pattern(LibgnacRenamePattern *pattern,
if (libgnac_metadata_tag_exists(tags, GST_TAG_TITLE))
{
val = LIBGNAC_METADATA_TAG_TITLE(tags);
- return g_strdup(g_value_get_string(val));
+ return g_value_dup_string(val);
}
return RENAME_PATTERN_DEFAULT_TITLE;
}
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index c232bb6..5a7e561 100644
--- a/src/gnac-ui.c
+++ b/src/gnac-ui.c
@@ -318,6 +318,10 @@ gnac_ui_destroy(void)
if (trayicon) {
g_object_unref(trayicon);
trayicon = NULL;
+ if (tooltip_path) {
+ g_free(tooltip_path);
+ tooltip_path = NULL;
+ }
}
gnac_file_list_destroy();
@@ -346,20 +350,29 @@ gnac_ui_query_tooltip_cb(GtkStatusIcon *status_icon,
LibgnacTags *tags;
GFile *tooltip_file;
gchar *text;
+ const gchar *album;
+ const gchar *artist;
+ const gchar *title;
tooltip_file = g_file_new_for_uri(tooltip_path);
tags = libgnac_metadata_extract(metadata, tooltip_file, NULL);
- if (libgnac_metadata_tags_exist(tags,
- GST_TAG_ARTIST, GST_TAG_ALBUM, GST_TAG_TITLE, NULL))
+ album = libgnac_metadata_tag_exists(tags, GST_TAG_ALBUM) ?
+ g_value_get_string(LIBGNAC_METADATA_TAG_ALBUM(tags)) : NULL;
+ artist = libgnac_metadata_tag_exists(tags, GST_TAG_ARTIST) ?
+ g_value_get_string(LIBGNAC_METADATA_TAG_ARTIST(tags)) : NULL;
+ title = libgnac_metadata_tag_exists(tags, GST_TAG_TITLE) ?
+ g_value_get_string(LIBGNAC_METADATA_TAG_TITLE(tags)) : NULL;
+
+ if (title)
{
text = g_markup_printf_escaped(" <b>%s</b>\n"
" <span color=\"#888\">%s</span> %s "
"<span color=\"#888\">%s</span> %s ",
- g_value_get_string(LIBGNAC_METADATA_TAG_TITLE(tags)),
+ title,
/* To translators: title by artist from album */
- _("by"), g_value_get_string(LIBGNAC_METADATA_TAG_ARTIST(tags)),
- _("from"), g_value_get_string(LIBGNAC_METADATA_TAG_ALBUM(tags)));
+ _("by"), artist ? artist : _("Unknown Artist"),
+ _("from"), album ? album : _("Unknown Album"));
}
else
{
@@ -500,16 +513,16 @@ gnac_ui_on_trayicon_popup(GtkStatusIcon *trayicon,
void
gnac_ui_trayicon_tooltip_update(const gchar *tooltip)
{
- /* TODO check this
- gchar *tmp = NULL;
GdkDisplay *display;
- tmp = tooltip_path;
+ if (tooltip_path) {
+ g_free(tooltip_path);
+ tooltip_path = NULL;
+ }
+
tooltip_path = g_strdup(tooltip);
display = gdk_display_get_default();
if (display) gtk_tooltip_trigger_tooltip_query(display);
- g_free(tmp);
- */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]