From 45a4e4eff36a7e5f2670bfb2280ee1563fd86319 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Thu, 24 Apr 2014 17:23:33 +0200 Subject: gtkui: added option to render play state as unicode chars instead of pixbuf, for better looks on HDPI screens --- plugins/gtkui/gtkui.c | 6 ++++++ plugins/gtkui/gtkui.h | 1 + plugins/gtkui/mainplaylist.c | 2 +- plugins/gtkui/plcommon.c | 35 +++++++++++++++++++++++++---------- 4 files changed, 33 insertions(+), 11 deletions(-) (limited to 'plugins/gtkui') diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 02d5310f..4a57ca65 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -101,6 +101,8 @@ int gtkui_groups_pinned; int gtkui_is_retina = 0; #endif +int gtkui_unicode_playstate = 0; + #define TRAY_ICON "deadbeef_tray_icon" // that must be called before gtk_init @@ -599,6 +601,9 @@ gtkui_on_configchanged (void *data) { // pin groups gtkui_groups_pinned = deadbeef->conf_get_int ("playlist.pin.groups", 0); + // play state images + gtkui_unicode_playstate = deadbeef->conf_get_int ("gtkui.unicode_playstate", 0); + // tray icon gtkui_update_status_icon (NULL); @@ -1573,6 +1578,7 @@ static const char settings_dlg[] = "property \"Custom status icon\" entry gtkui.custom_tray_icon \"" TRAY_ICON "\" ;\n" "property \"Run gtk_init with --sync (debug mode)\" checkbox gtkui.sync 0;\n" "property \"Add separators between plugin context menu items\" checkbox gtkui.action_separators 0;\n" + "property \"Use unicode chars instead of images for track state\" checkbox gtkui.unicode_playstate 0;\n" ; // define plugin interface diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index bf60c7d3..0d4bb007 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -36,6 +36,7 @@ extern GtkWidget *mainwin; extern GtkWidget *searchwin; extern int gtkui_embolden_current_track; extern int gtkui_is_retina; +extern int gtkui_unicode_playstate; struct _GSList; diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c index cf656d4e..ae828a30 100644 --- a/plugins/gtkui/mainplaylist.c +++ b/plugins/gtkui/mainplaylist.c @@ -345,7 +345,7 @@ main_playlist_init (GtkWidget *widget) { DB_conf_item_t *col = deadbeef->conf_find ("playlist.column.", NULL); if (!col) { // create default set of columns - add_column_helper (listview, _("Playing"), 50, DB_COLUMN_PLAYING, NULL, 0); + add_column_helper (listview, "♫", 50, DB_COLUMN_PLAYING, NULL, 0); add_column_helper (listview, _("Artist / Album"), 150, -1, "%a - %b", 0); add_column_helper (listview, _("Track No"), 50, -1, "%n", 1); add_column_helper (listview, _("Title"), 150, -1, "%t", 0); diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c index 9e3e3cdc..12229d0b 100644 --- a/plugins/gtkui/plcommon.c +++ b/plugins/gtkui/plcommon.c @@ -278,7 +278,7 @@ void draw_column_data (DdbListview *listview, cairo_t *cr, DdbListviewIter it, D } } } - else if (it && it == playing_track && cinf->id == DB_COLUMN_PLAYING) { + else if (!gtkui_unicode_playstate && it && it == playing_track && cinf->id == DB_COLUMN_PLAYING) { int paused = deadbeef->get_output ()->state () == OUTPUT_STATE_PAUSED; int buffering = !deadbeef->streamer_ok_to_read (-1); GdkPixbuf *pixbuf; @@ -296,15 +296,30 @@ void draw_column_data (DdbListview *listview, cairo_t *cr, DdbListviewIter it, D cairo_fill (cr); } else if (it) { - char text[1024]; - deadbeef->pl_format_title (it, -1, text, sizeof (text), cinf->id, cinf->format); - char *lb = strchr (text, '\r'); - if (lb) { - *lb = 0; + char text[1024] = ""; + if (it == playing_track && cinf->id == DB_COLUMN_PLAYING) { + int paused = deadbeef->get_output ()->state () == OUTPUT_STATE_PAUSED; + int buffering = !deadbeef->streamer_ok_to_read (-1); + if (paused) { + strcpy (text, "||"); + } + else if (!buffering) { + strcpy (text, "►"); + } + else { + strcpy (text, "⋯⋯⋯"); + } } - lb = strchr (text, '\n'); - if (lb) { - *lb = 0; + else { + deadbeef->pl_format_title (it, -1, text, sizeof (text), cinf->id, cinf->format); + char *lb = strchr (text, '\r'); + if (lb) { + *lb = 0; + } + lb = strchr (text, '\n'); + if (lb) { + *lb = 0; + } } GdkColor *color = NULL; if (theming) { @@ -332,7 +347,7 @@ void draw_column_data (DdbListview *listview, cairo_t *cr, DdbListviewIter it, D draw_init_font_bold (&listview->listctx); } if (calign_right) { - draw_text (&listview->listctx, x+5, y + 3, cwidth-10, 1, text); + draw_text (&listview->listctx, x + 5, y + 3, cwidth-10, 1, text); } else { draw_text (&listview->listctx, x + 5, y + 3, cwidth-10, 0, text); -- cgit v1.2.3