summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/ddbtabstrip.c56
-rw-r--r--plugins/gtkui/fileman.c5
-rw-r--r--plugins/gtkui/gtkui.c5
3 files changed, 49 insertions, 17 deletions
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c
index 325f7a25..503368c3 100644
--- a/plugins/gtkui/ddbtabstrip.c
+++ b/plugins/gtkui/ddbtabstrip.c
@@ -43,7 +43,14 @@ extern GtkWidget *theme_button;
void
plt_get_title_wrapper (int plt, char *buffer, int len) {
- deadbeef->plt_get_title (plt, buffer, len);
+ if (plt == -1) {
+ strcpy (buffer, "");
+ return;
+ }
+ deadbeef->plt_lock ();
+ void *p = deadbeef->plt_get_handle (plt);
+ deadbeef->plt_get_title (p, buffer, len);
+ deadbeef->plt_unlock ();
char *end;
if (!g_utf8_validate (buffer, -1, (const gchar **)&end)) {
*end = 0;
@@ -458,6 +465,32 @@ tabstrip_adjust_hscroll (DdbTabStrip *ts) {
}
void
+set_tab_text_color (int idx) {
+ if (idx == -1) {
+ return;
+ }
+ deadbeef->plt_lock ();
+ void *plt = deadbeef->plt_get_handle (idx);
+ const char *clr = deadbeef->plt_find_meta (plt, "gui.color");
+ int fallback = 1;
+ if (clr) {
+ int r, g, b;
+ if (3 == sscanf (clr, "%02x%02x%02x", &r, &g, &b)) {
+ fallback = 0;
+ float fg[3] = {(float)r/0xff, (float)g/0xff, (float)b/0xff};
+ draw_set_fg_color (fg);
+ }
+ }
+ if (fallback) {
+ GdkColor color;
+ gtkui_get_tabstrip_text_color (&color);
+ float fg[3] = {(float)color.red/0xffff, (float)color.green/0xffff, (float)color.blue/0xffff};
+ draw_set_fg_color (fg);
+ }
+ deadbeef->plt_unlock ();
+}
+
+void
tabstrip_render (DdbTabStrip *ts) {
GtkWidget *widget = GTK_WIDGET (ts);
GdkDrawable *backbuf = gtk_widget_get_window (widget);
@@ -520,10 +553,8 @@ tabstrip_render (DdbTabStrip *ts) {
ddb_tabstrip_draw_tab (widget, backbuf, idx == tab_selected, x, y, w, h);
char tab_title[100];
plt_get_title_wrapper (idx, tab_title, sizeof (tab_title));
- GdkColor color;
- gtkui_get_tabstrip_text_color (&color);
- float fg[3] = {(float)color.red/0xffff, (float)color.green/0xffff, (float)color.blue/0xffff};
- draw_set_fg_color (fg);
+
+ set_tab_text_color (idx);
draw_text (x + text_left_padding, y + h/2 - draw_get_font_size()/2 + text_vert_offset, w, 0, tab_title);
}
x += w - tab_overlap_size;
@@ -548,10 +579,7 @@ tabstrip_render (DdbTabStrip *ts) {
ddb_tabstrip_draw_tab (widget, backbuf, 1, x, y, w, h);
char tab_title[100];
plt_get_title_wrapper (idx, tab_title, sizeof (tab_title));
- GdkColor color;
- gtkui_get_tabstrip_text_color (&color);
- float fg[3] = {(float)color.red/0xffff, (float)color.green/0xffff, (float)color.blue/0xffff};
- draw_set_fg_color (fg);
+ set_tab_text_color (idx);
draw_text (x + text_left_padding, y + h/2 - draw_get_font_size()/2 + text_vert_offset, w, 0, tab_title);
}
else {
@@ -570,10 +598,7 @@ tabstrip_render (DdbTabStrip *ts) {
ddb_tabstrip_draw_tab (widget, backbuf, 1, x, y, w, h);
char tab_title[100];
plt_get_title_wrapper (idx, tab_title, sizeof (tab_title));
- GdkColor color;
- gtkui_get_tabstrip_text_color (&color);
- float fg[3] = {(float)color.red/0xffff, (float)color.green/0xffff, (float)color.blue/0xffff};
- draw_set_fg_color (fg);
+ set_tab_text_color (idx);
draw_text (x + text_left_padding, y + h/2 - draw_get_font_size()/2 + text_vert_offset, w, 0, tab_title);
}
break;
@@ -643,7 +668,10 @@ on_rename_playlist1_activate (GtkMenuItem *menuitem,
int res = gtk_dialog_run (GTK_DIALOG (dlg));
if (res == GTK_RESPONSE_OK) {
const char *text = gtk_entry_get_text (GTK_ENTRY (e));
- deadbeef->plt_set_title (tab_clicked, text);
+ deadbeef->plt_lock ();
+ void *p = deadbeef->plt_get_handle (tab_clicked);
+ deadbeef->plt_set_title (p, text);
+ deadbeef->plt_unlock ();
}
gtk_widget_destroy (dlg);
}
diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c
index d4ffb518..d33764c0 100644
--- a/plugins/gtkui/fileman.c
+++ b/plugins/gtkui/fileman.c
@@ -28,15 +28,16 @@ gtkpl_add_dirs (GSList *lst) {
&& deadbeef->conf_get_int ("gtkui.name_playlist_from_folder", 0)) {
int plt = deadbeef->plt_get_curr ();
if (plt != -1) {
+ void *p = deadbeef->plt_get_handle (plt);
char t[1000];
- if (!deadbeef->plt_get_title (plt, t, sizeof (t))) {
+ if (!deadbeef->plt_get_title (p, t, sizeof (t))) {
char *def = _("New Playlist");
if (!strncmp (t, def, strlen (def))) {
const char *folder = strrchr ((char*)lst->data, '/');
if (!folder) {
folder = lst->data;
}
- deadbeef->plt_set_title (plt, folder+1);
+ deadbeef->plt_set_title (p, folder+1);
}
}
}
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index f2c6d30d..7700e20f 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -904,13 +904,16 @@ gtkui_add_new_playlist (void) {
else {
snprintf (name, sizeof (name), _("New Playlist (%d)"), idx);
}
+ deadbeef->plt_lock ();
for (i = 0; i < cnt; i++) {
char t[100];
- deadbeef->plt_get_title (i, t, sizeof (t));
+ void *plt = deadbeef->plt_get_handle (i);
+ deadbeef->plt_get_title (plt, t, sizeof (t));
if (!strcasecmp (t, name)) {
break;
}
}
+ deadbeef->plt_unlock ();
if (i == cnt) {
return deadbeef->plt_add (cnt, name);
}