From b59bfddfa661a67b621b7bc24ae9aefa89fc2abf Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sat, 3 Apr 2010 20:21:57 +0200 Subject: custom widget color settings --- plugins/gtkui/callbacks.c | 11 +- plugins/gtkui/callbacks.h | 60 +++++ plugins/gtkui/ddblistview.c | 34 ++- plugins/gtkui/ddbtabstrip.c | 36 ++- plugins/gtkui/ddbvolumebar.c | 4 +- plugins/gtkui/deadbeef.glade | 556 +++++++++++++++++++++++++++++-------------- plugins/gtkui/drawing.h | 37 ++- plugins/gtkui/gdkdrawing.c | 177 +++++++++----- plugins/gtkui/gtkui.c | 32 ++- plugins/gtkui/gtkui.h | 12 +- plugins/gtkui/interface.c | 394 +++++++++++++++++------------- plugins/gtkui/plcommon.c | 28 ++- plugins/gtkui/prefwin.c | 183 ++++++++++---- 13 files changed, 1072 insertions(+), 492 deletions(-) (limited to 'plugins/gtkui') diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index d8a71714..cacba4b0 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -491,8 +491,8 @@ seekbar_draw (GtkWidget *widget) { if (!cr) { return; } - GdkColor *clr_selection = gtkui_get_selection_color (); - GdkColor *clr_back = gtkui_get_back_color (); + GdkColor *clr_selection = gtkui_get_bar_foreground_color (); + GdkColor *clr_back = gtkui_get_bar_background_color (); DB_playItem_t *trk = deadbeef->streamer_get_playing_track (); if (!trk || deadbeef->pl_get_item_duration (trk) < 0) { @@ -624,6 +624,13 @@ on_seekbar_button_release_event (GtkWidget *widget, return FALSE; } +void +seekbar_redraw (void) { + GtkWidget *widget = lookup_widget (mainwin, "seekbar"); + seekbar_draw (widget); + seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height); +} + gboolean on_mainwin_delete_event (GtkWidget *widget, GdkEvent *event, diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h index 530bed31..876bfa2f 100644 --- a/plugins/gtkui/callbacks.h +++ b/plugins/gtkui/callbacks.h @@ -853,3 +853,63 @@ on_mmb_delete_playlist_toggled (GtkToggleButton *togglebutton, void on_new_playlist1_activate (GtkMenuItem *menuitem, gpointer user_data); + +void +on_override_bar_colors_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + +void +on_bar_foreground_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_bar_background_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_tabstrip_mid_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_tabstrip_light_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_tabstrip_dark_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_tabstrip_base_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_override_tabstrip_colors_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + +void +on_override_listview_colors_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + +void +on_listview_even_row_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_listview_odd_row_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_listview_selected_row_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_listview_text_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_listview_selected_text_color_set (GtkColorButton *colorbutton, + gpointer user_data); + +void +on_listview_cursor_color_set (GtkColorButton *colorbutton, + gpointer user_data); diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index c802b75b..8a417ce6 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -1127,7 +1127,7 @@ void ddb_listview_list_render_row_background (DdbListview *ps, DdbListviewIter it, int even, int cursor, int x, int y, int w, int h) { // draw background GtkWidget *treeview = theme_treeview; - int theming = !gtkui_listview_theming_disabled (); + int theming = !gtkui_override_listview_colors (); if (theming) { if (treeview->style->depth == -1) { @@ -1135,23 +1135,39 @@ ddb_listview_list_render_row_background (DdbListview *ps, DdbListviewIter it, in } GTK_OBJECT_FLAGS (treeview) |= GTK_HAS_FOCUS; } - if (it && ps->binding->is_selected(it)) { + int sel = it && ps->binding->is_selected (it); + if (theming || !sel) { if (theming) { // draw background for selection -- workaround for New Wave theme (translucency) gtk_paint_flat_box (treeview->style, ps->backbuf, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); } + else { + GdkGC *gc = gdk_gc_new (ps->backbuf); + gdk_gc_set_rgb_fg_color (gc, even ? gtkui_get_listview_even_row_color () : gtkui_get_listview_odd_row_color ()); + gdk_draw_rectangle (ps->backbuf, gc, TRUE, x, y, w, h); + g_object_unref (gc); + } } - if (theming) { - gtk_paint_flat_box (treeview->style, ps->backbuf, (it && ps->binding->is_selected(it)) ? GTK_STATE_SELECTED : GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); + + if (sel) { + if (theming) { + gtk_paint_flat_box (treeview->style, ps->backbuf, GTK_STATE_SELECTED, GTK_SHADOW_NONE, NULL, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); + } + else { + GdkGC *gc = gdk_gc_new (ps->backbuf); + gdk_gc_set_rgb_fg_color (gc, gtkui_get_listview_selection_color ()); + gdk_draw_rectangle (ps->backbuf, gc, TRUE, x, y, w, h); + g_object_unref (gc); + } } -// else { -// GdkColor *clr_ -// gtk_draw_rectangle (ps->backbuf, gc); -// } if (cursor) { // not all gtk engines/themes render focus rectangle in treeviews // but we want it anyway - gdk_draw_rectangle (ps->backbuf, treeview->style->fg_gc[GTK_STATE_NORMAL], FALSE, x, y, w-1, h-1); + //treeview->style->fg_gc[GTK_STATE_NORMAL] + GdkGC *gc = gdk_gc_new (ps->backbuf); + gdk_gc_set_rgb_fg_color (gc, gtkui_get_listview_cursor_color ()); + gdk_draw_rectangle (ps->backbuf, gc, FALSE, x, y, w-1, h-1); + g_object_unref (gc); } } diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c index b9b17cd5..af04abc7 100644 --- a/plugins/gtkui/ddbtabstrip.c +++ b/plugins/gtkui/ddbtabstrip.c @@ -214,22 +214,31 @@ ddb_tabstrip_draw_tab (GtkWidget *widget, GdkDrawable *drawable, int selected, i { x + w-2, y + h - 2 }, }; //gdk_draw_rectangle (widget->window, widget->style->black_gc, FALSE, x-1, y-1, w+2, h+2); - GdkGC *bg; - GdkGC *outer_frame; - GdkGC *inner_frame; + GdkGC *bg = gdk_gc_new (drawable); + GdkGC *outer_frame = gdk_gc_new (drawable); + GdkGC *inner_frame = gdk_gc_new (drawable); if (selected) { - bg = widget->style->bg_gc[GTK_STATE_NORMAL]; - outer_frame = widget->style->dark_gc[GTK_STATE_NORMAL]; - inner_frame = widget->style->light_gc[GTK_STATE_NORMAL]; + gdk_gc_set_rgb_fg_color (bg, gtkui_get_tabstrip_base_color ());//&widget->style->bg[GTK_STATE_NORMAL]); // FIXME: need base color + gdk_gc_set_rgb_fg_color (outer_frame, gtkui_get_tabstrip_dark_color ()); + gdk_gc_set_rgb_fg_color (inner_frame, gtkui_get_tabstrip_light_color ()); +// bg = widget->style->bg_gc[GTK_STATE_NORMAL]; +// outer_frame = widget->style->dark_gc[GTK_STATE_NORMAL]; +// inner_frame = widget->style->light_gc[GTK_STATE_NORMAL]; } else { - bg = widget->style->mid_gc[GTK_STATE_NORMAL]; - outer_frame = widget->style->dark_gc[GTK_STATE_NORMAL]; - inner_frame = widget->style->mid_gc[GTK_STATE_NORMAL]; + gdk_gc_set_rgb_fg_color (bg, gtkui_get_tabstrip_mid_color ()); + gdk_gc_set_rgb_fg_color (outer_frame, gtkui_get_tabstrip_dark_color ()); + gdk_gc_set_rgb_fg_color (inner_frame, gtkui_get_tabstrip_mid_color ()); +// bg = widget->style->mid_gc[GTK_STATE_NORMAL]; +// outer_frame = widget->style->dark_gc[GTK_STATE_NORMAL]; +// inner_frame = widget->style->mid_gc[GTK_STATE_NORMAL]; } gdk_draw_polygon (drawable, bg, TRUE, points_filled, 4); gdk_draw_lines (drawable, outer_frame, points_frame1, 9); gdk_draw_lines (drawable, inner_frame, points_frame2, 7); + g_object_unref (bg); + g_object_unref (outer_frame); + g_object_unref (inner_frame); } int @@ -262,9 +271,13 @@ tabstrip_render (DdbTabStrip *ts) { int cnt = deadbeef->plt_get_count (); int tab_selected = deadbeef->plt_get_curr (); + GdkGC *gc = gdk_gc_new (backbuf); + // fill background - gdk_draw_rectangle (backbuf, widget->style->mid_gc[GTK_STATE_NORMAL], TRUE, 0, 0, widget->allocation.width, widget->allocation.height); - gdk_draw_line (backbuf, widget->style->dark_gc[GTK_STATE_NORMAL], 0, 0, widget->allocation.width, 0); + gdk_gc_set_rgb_fg_color (gc, gtkui_get_tabstrip_mid_color ()); + gdk_draw_rectangle (backbuf, gc, TRUE, 0, 0, widget->allocation.width, widget->allocation.height); + gdk_gc_set_rgb_fg_color (gc, gtkui_get_tabstrip_dark_color ()); + gdk_draw_line (backbuf, gc, 0, 0, widget->allocation.width, 0); int y = 4; h = widget->allocation.height - 4; draw_begin ((uintptr_t)backbuf); @@ -366,6 +379,7 @@ tabstrip_render (DdbTabStrip *ts) { } } draw_end (); + g_object_unref (gc); } void diff --git a/plugins/gtkui/ddbvolumebar.c b/plugins/gtkui/ddbvolumebar.c index 4d2654a0..3b48cf95 100644 --- a/plugins/gtkui/ddbvolumebar.c +++ b/plugins/gtkui/ddbvolumebar.c @@ -182,10 +182,10 @@ volumebar_draw (GtkWidget *widget) { float h = 17; GdkGC *back_gc = gdk_gc_new (widget->window); - gdk_gc_set_rgb_fg_color (back_gc, gtkui_get_back_color ()); + gdk_gc_set_rgb_fg_color (back_gc, gtkui_get_bar_background_color ()); GdkGC *front_gc = gdk_gc_new (widget->window); - gdk_gc_set_rgb_fg_color (front_gc, gtkui_get_selection_color ()); + gdk_gc_set_rgb_fg_color (front_gc, gtkui_get_bar_foreground_color ()); for (int i = 0; i < n; i++) { float iy = (float)i + 3; diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index 7afb12ef..89f682ab 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -2268,81 +2268,118 @@ Album - + True - 0 - 0.5 - GTK_SHADOW_IN + True + True + True + GTK_POS_TOP + False + False - + + 12 True - 0.5 - 0.5 - 1 - 1 - 0 - 0 - 12 - 0 + False + 8 - - 12 + + True + True + Override + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + + + + True 2 - 5 + 2 True 0 8 - + True - True - False - True - + Foreground + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - 3 - 4 - 1 - 2 + 0 + 1 + 0 + 1 expand - + True - True - False - True - + Background + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - 2 - 3 - 1 - 2 + 1 + 2 + 0 + 1 expand - + True True False True - + - 1 - 2 + 0 + 1 1 2 expand @@ -2351,27 +2388,99 @@ Album - + True True False True - + - 0 - 1 + 1 + 2 1 2 expand + + + 0 + True + True + + + + + False + True + + + + + + True + Seekbar/Volumebar colors + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 12 + True + False + 8 + + + + True + True + Override + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + + + + + True + 2 + 4 + True + 0 + 8 - + True - Selection + Middle False False GTK_JUSTIFY_LEFT @@ -2397,9 +2506,9 @@ Album - + True - Dark + Light False False GTK_JUSTIFY_LEFT @@ -2425,9 +2534,9 @@ Album - + True - Middle + Dark False False GTK_JUSTIFY_LEFT @@ -2453,44 +2562,34 @@ Album - + True - Light - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + True + False + True + - 3 - 4 - 0 - 1 + 0 + 1 + 1 + 2 expand - + True True False True - + - 4 - 5 + 1 + 2 1 2 expand @@ -2499,9 +2598,45 @@ Album - + + True + True + False + True + + + + 2 + 3 + 1 + 2 + expand + + + + + + + True + True + False + True + + + + 3 + 4 + 1 + 2 + expand + + + + + + True - Inactive background + Base False False GTK_JUSTIFY_LEFT @@ -2517,8 +2652,8 @@ Album 0 - 4 - 5 + 3 + 4 0 1 expand @@ -2526,60 +2661,74 @@ Album + + 0 + True + True + + + False + True + - + True - True - Override GTK+ theme colors in volume control and seek bar widgets - True - GTK_RELIEF_NORMAL - True - False - False - True - + Tabstrip colors + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - label_item + tab - - - 0 - False - True - - - - - - True - 0 - 0.5 - GTK_SHADOW_IN - + + 12 True - 0.5 - 0.5 - 1 - 1 - 0 - 0 - 12 - 0 + False + 8 - - 12 + + True + True + Override (looses GTK treeview theming, but speeds up rendering) + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + + + + True 2 - 5 + 6 True 0 8 @@ -2641,37 +2790,45 @@ Album - + True - Text - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + True + False + True + - 2 - 3 - 0 - 1 + 0 + 1 + 1 + 2 expand - + True - Selected text + True + False + True + + + + 1 + 2 + 1 + 2 + expand + + + + + + + True + Text False False GTK_JUSTIFY_LEFT @@ -2697,9 +2854,9 @@ Album - + True - Cursor + Selected row False False GTK_JUSTIFY_LEFT @@ -2715,8 +2872,8 @@ Album 0 - 4 - 5 + 2 + 3 0 1 expand @@ -2725,16 +2882,16 @@ Album - + True True False True - + - 0 - 1 + 2 + 3 1 2 expand @@ -2743,16 +2900,16 @@ Album - + True True False True - + - 1 - 2 + 3 + 4 1 2 expand @@ -2761,34 +2918,44 @@ Album - + True - True - False - True - + Selected text + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - 2 - 3 - 1 - 2 + 4 + 5 + 0 + 1 expand - + True True False True - + - 3 - 4 + 4 + 5 1 2 expand @@ -2797,15 +2964,44 @@ Album - + + True + Cursor + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + 6 + 0 + 1 + expand + + + + + + True True False True + - 4 - 5 + 5 + 6 1 2 expand @@ -2813,31 +3009,45 @@ Album + + 0 + True + True + + + False + True + - + True - True - Disable playlist theming (speeds up rendering) - True - GTK_RELIEF_NORMAL - True - False - False - True - + Playlist colors + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - label_item + tab 0 - False + True True diff --git a/plugins/gtkui/drawing.h b/plugins/gtkui/drawing.h index deed2b2d..16f2c211 100644 --- a/plugins/gtkui/drawing.h +++ b/plugins/gtkui/drawing.h @@ -68,34 +68,53 @@ draw_text_with_colors (float x, float y, int width, int align, const char *text) void draw_get_text_extents (const char *text, int len, int *w, int *h); + +GdkColor * +gtkui_get_bar_foreground_color (void); + +GdkColor * +gtkui_get_bar_background_color (void); + GdkColor * -gtkui_get_back_color (void); +gtkui_get_tabstrip_dark_color (void); GdkColor * -gtkui_get_selection_color (void); +gtkui_get_tabstrip_mid_color (void); GdkColor * -gtkui_get_dark_color (void); +gtkui_get_tabstrip_light_color (void); GdkColor * -gtkui_get_mid_color (void); +gtkui_get_tabstrip_base_color (void); GdkColor * -gtkui_get_light_color (void); +gtkui_get_listview_even_row_color (void); GdkColor * -gtkui_get_even_row_color (void); +gtkui_get_listview_odd_row_color (void); GdkColor * -gtkui_get_odd_row_color (void); +gtkui_get_listview_selection_color (void); GdkColor * -gtkui_get_text_color (void); +gtkui_get_listview_text_color (void); GdkColor * -gtkui_get_selected_text_color (void); +gtkui_get_listview_selected_text_color (void); + +GdkColor * +gtkui_get_listview_cursor_color (void); void gtkui_init_theme_colors (void); +int +gtkui_override_listview_colors (void); + +int +gtkui_override_bar_colors (void); + +int +gtkui_override_tabstrip_colors (void); + #endif // __DRAWING_H diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c index 207575ea..84b07d29 100644 --- a/plugins/gtkui/gdkdrawing.c +++ b/plugins/gtkui/gdkdrawing.c @@ -149,116 +149,181 @@ draw_get_text_extents (const char *text, int len, int *w, int *h) { *h = ink.height; } -static GdkColor gtkui_back_color; -static GdkColor gtkui_selection_color; -static GdkColor gtkui_dark_color; -static GdkColor gtkui_mid_color; -static GdkColor gtkui_light_color; -static GdkColor gtkui_even_row_color; -static GdkColor gtkui_odd_row_color; -static GdkColor gtkui_text_color; -static GdkColor gtkui_selected_text_color; +static GdkColor gtkui_bar_foreground_color; +static GdkColor gtkui_bar_background_color; + +static GdkColor gtkui_tabstrip_dark_color; +static GdkColor gtkui_tabstrip_mid_color; +static GdkColor gtkui_tabstrip_light_color; +static GdkColor gtkui_tabstrip_base_color; + +static GdkColor gtkui_listview_even_row_color; +static GdkColor gtkui_listview_odd_row_color; +static GdkColor gtkui_listview_selection_color; +static GdkColor gtkui_listview_text_color; +static GdkColor gtkui_listview_selected_text_color; +static GdkColor gtkui_listview_cursor_color; + +static int override_listview_colors = 0; +static int override_bar_colors = 0; +static int override_tabstrip_colors = 0; + +int +gtkui_override_listview_colors (void) { + return override_listview_colors; +} + +int +gtkui_override_bar_colors (void) { + return override_bar_colors; +} + +int +gtkui_override_tabstrip_colors (void) { + return override_tabstrip_colors; +} void gtkui_init_theme_colors (void) { - int override = deadbeef->conf_get_int ("gtkui.override_theme_colors", 0); + override_listview_colors= deadbeef->conf_get_int ("gtkui.override_listview_colors", 0); + override_bar_colors = deadbeef->conf_get_int ("gtkui.override_bar_colors", 0); + override_tabstrip_colors = deadbeef->conf_get_int ("gtkui.override_tabstrip_colors", 0); extern GtkWidget *mainwin; GtkStyle *style = mainwin->style; char color_text[100]; const char *clr; - if (!override) { - memcpy (>kui_selection_color, &style->base[GTK_STATE_SELECTED], sizeof (GdkColor)); - memcpy (>kui_back_color, &style->fg[GTK_STATE_NORMAL], sizeof (GdkColor)); - memcpy (>kui_dark_color, &style->dark[GTK_STATE_NORMAL], sizeof (GdkColor)); - memcpy (>kui_mid_color, &style->mid[GTK_STATE_NORMAL], sizeof (GdkColor)); - memcpy (>kui_light_color, &style->light[GTK_STATE_NORMAL], sizeof (GdkColor)); - memcpy (>kui_even_row_color, &style->light[GTK_STATE_NORMAL], sizeof (GdkColor)); - memcpy (>kui_odd_row_color, &style->mid[GTK_STATE_NORMAL], sizeof (GdkColor)); - memcpy (>kui_text_color, &style->fg[GTK_STATE_NORMAL], sizeof (GdkColor)); - memcpy (>kui_selected_text_color, &style->fg[GTK_STATE_SELECTED], sizeof (GdkColor)); + if (!override_bar_colors) { + memcpy (>kui_bar_foreground_color, &style->base[GTK_STATE_SELECTED], sizeof (GdkColor)); + memcpy (>kui_bar_background_color, &style->fg[GTK_STATE_NORMAL], sizeof (GdkColor)); } else { snprintf (color_text, sizeof (color_text), "%d %d %d", style->base[GTK_STATE_SELECTED].red, style->base[GTK_STATE_SELECTED].green, style->base[GTK_STATE_SELECTED].blue); - clr = deadbeef->conf_get_str ("gtkui.color.selection", color_text); - sscanf (clr, "%d %d %d", >kui_selection_color.red, >kui_selection_color.green, >kui_selection_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.bar_foreground", color_text); + sscanf (clr, "%d %d %d", >kui_bar_foreground_color.red, >kui_bar_foreground_color.green, >kui_bar_foreground_color.blue); snprintf (color_text, sizeof (color_text), "%d %d %d", style->fg[GTK_STATE_NORMAL].red, style->fg[GTK_STATE_NORMAL].green, style->fg[GTK_STATE_NORMAL].blue); - clr = deadbeef->conf_get_str ("gtkui.color.back", color_text); - sscanf (clr, "%d %d %d", >kui_back_color.red, >kui_back_color.green, >kui_back_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.bar_background", color_text); + sscanf (clr, "%d %d %d", >kui_bar_background_color.red, >kui_bar_background_color.green, >kui_bar_background_color.blue); + + } + if (!override_tabstrip_colors) { + memcpy (>kui_tabstrip_dark_color, &style->dark[GTK_STATE_NORMAL], sizeof (GdkColor)); + memcpy (>kui_tabstrip_mid_color, &style->mid[GTK_STATE_NORMAL], sizeof (GdkColor)); + memcpy (>kui_tabstrip_light_color, &style->light[GTK_STATE_NORMAL], sizeof (GdkColor)); + memcpy (>kui_tabstrip_base_color, &style->bg[GTK_STATE_NORMAL], sizeof (GdkColor)); + } + else { snprintf (color_text, sizeof (color_text), "%d %d %d", style->dark[GTK_STATE_NORMAL].red, style->dark[GTK_STATE_NORMAL].green, style->dark[GTK_STATE_NORMAL].blue); - clr = deadbeef->conf_get_str ("gtkui.color.dark", color_text); - sscanf (clr, "%d %d %d", >kui_dark_color.red, >kui_dark_color.green, >kui_dark_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.tabstrip_dark", color_text); + sscanf (clr, "%d %d %d", >kui_tabstrip_dark_color.red, >kui_tabstrip_dark_color.green, >kui_tabstrip_dark_color.blue); snprintf (color_text, sizeof (color_text), "%d %d %d", style->mid[GTK_STATE_NORMAL].red, style->mid[GTK_STATE_NORMAL].green, style->mid[GTK_STATE_NORMAL].blue); - clr = deadbeef->conf_get_str ("gtkui.color.mid", color_text); - sscanf (clr, "%d %d %d", >kui_mid_color.red, >kui_mid_color.green, >kui_mid_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.tabstrip_mid", color_text); + sscanf (clr, "%d %d %d", >kui_tabstrip_mid_color.red, >kui_tabstrip_mid_color.green, >kui_tabstrip_mid_color.blue); snprintf (color_text, sizeof (color_text), "%d %d %d", style->light[GTK_STATE_NORMAL].red, style->light[GTK_STATE_NORMAL].green, style->light[GTK_STATE_NORMAL].blue); - clr = deadbeef->conf_get_str ("gtkui.color.light", color_text); - sscanf (clr, "%d %d %d", >kui_light_color.red, >kui_light_color.green, >kui_light_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.tabstrip_light", color_text); + sscanf (clr, "%d %d %d", >kui_tabstrip_light_color.red, >kui_tabstrip_light_color.green, >kui_tabstrip_light_color.blue); + + snprintf (color_text, sizeof (color_text), "%d %d %d", style->bg[GTK_STATE_NORMAL].red, style->bg[GTK_STATE_NORMAL].green, style->bg[GTK_STATE_NORMAL].blue); + clr = deadbeef->conf_get_str ("gtkui.color.tabstrip_base", color_text); + sscanf (clr, "%d %d %d", >kui_tabstrip_base_color.red, >kui_tabstrip_base_color.green, >kui_tabstrip_base_color.blue); + } + if (!override_listview_colors) { + memcpy (>kui_listview_even_row_color, &style->light[GTK_STATE_NORMAL], sizeof (GdkColor)); + memcpy (>kui_listview_odd_row_color, &style->mid[GTK_STATE_NORMAL], sizeof (GdkColor)); + memcpy (>kui_listview_selection_color, &style->bg[GTK_STATE_SELECTED], sizeof (GdkColor)); + memcpy (>kui_listview_text_color, &style->fg[GTK_STATE_NORMAL], sizeof (GdkColor)); + memcpy (>kui_listview_selected_text_color, &style->fg[GTK_STATE_SELECTED], sizeof (GdkColor)); + memcpy (>kui_listview_cursor_color, &style->fg[GTK_STATE_NORMAL], sizeof (GdkColor)); + } + else { snprintf (color_text, sizeof (color_text), "%d %d %d", style->light[GTK_STATE_NORMAL].red, style->light[GTK_STATE_NORMAL].green, style->light[GTK_STATE_NORMAL].blue); - clr = deadbeef->conf_get_str ("gtkui.color.even_row", color_text); - sscanf (clr, "%d %d %d", >kui_even_row_color.red, >kui_even_row_color.green, >kui_even_row_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.listview_even_row", color_text); + sscanf (clr, "%d %d %d", >kui_listview_even_row_color.red, >kui_listview_even_row_color.green, >kui_listview_even_row_color.blue); snprintf (color_text, sizeof (color_text), "%d %d %d", style->mid[GTK_STATE_NORMAL].red, style->mid[GTK_STATE_NORMAL].green, style->mid[GTK_STATE_NORMAL].blue); - clr = deadbeef->conf_get_str ("gtkui.color.odd_row", color_text); - sscanf (clr, "%d %d %d", >kui_odd_row_color.red, >kui_odd_row_color.green, >kui_odd_row_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.listview_odd_row", color_text); + sscanf (clr, "%d %d %d", >kui_listview_odd_row_color.red, >kui_listview_odd_row_color.green, >kui_listview_odd_row_color.blue); + + snprintf (color_text, sizeof (color_text), "%d %d %d", style->mid[GTK_STATE_NORMAL].red, style->mid[GTK_STATE_NORMAL].green, style->mid[GTK_STATE_NORMAL].blue); + clr = deadbeef->conf_get_str ("gtkui.color.listview_selection", color_text); + sscanf (clr, "%d %d %d", >kui_listview_selection_color.red, >kui_listview_selection_color.green, >kui_listview_selection_color.blue); snprintf (color_text, sizeof (color_text), "%d %d %d", style->fg[GTK_STATE_NORMAL].red, style->fg[GTK_STATE_NORMAL].green, style->fg[GTK_STATE_NORMAL].blue); - clr = deadbeef->conf_get_str ("gtkui.color.text", color_text); - sscanf (clr, "%d %d %d", >kui_text_color.red, >kui_text_color.green, >kui_text_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.listview_text", color_text); + sscanf (clr, "%d %d %d", >kui_listview_text_color.red, >kui_listview_text_color.green, >kui_listview_text_color.blue); + + snprintf (color_text, sizeof (color_text), "%d %d %d", style->fg[GTK_STATE_SELECTED].red, style->fg[GTK_STATE_SELECTED].green, style->fg[GTK_STATE_SELECTED].blue); + clr = deadbeef->conf_get_str ("gtkui.color.listview_selected_text", color_text); + sscanf (clr, "%d %d %d", >kui_listview_selected_text_color.red, >kui_listview_selected_text_color.green, >kui_listview_selected_text_color.blue); snprintf (color_text, sizeof (color_text), "%d %d %d", style->fg[GTK_STATE_SELECTED].red, style->fg[GTK_STATE_SELECTED].green, style->fg[GTK_STATE_SELECTED].blue); - clr = deadbeef->conf_get_str ("gtkui.color.selected_text", color_text); - sscanf (clr, "%d %d %d", >kui_selected_text_color.red, >kui_selected_text_color.green, >kui_selected_text_color.blue); + clr = deadbeef->conf_get_str ("gtkui.color.listview_cursor", color_text); + sscanf (clr, "%d %d %d", >kui_listview_cursor_color.red, >kui_listview_cursor_color.green, >kui_listview_cursor_color.blue); } } GdkColor * -gtkui_get_back_color (void) { - return >kui_back_color; +gtkui_get_bar_foreground_color (void) { + return >kui_bar_foreground_color; +} + +GdkColor * +gtkui_get_bar_background_color (void) { + return >kui_bar_background_color; +} + +GdkColor * +gtkui_get_tabstrip_dark_color (void) { + return >kui_tabstrip_dark_color; +} + +GdkColor * +gtkui_get_tabstrip_mid_color (void) { + return >kui_tabstrip_mid_color; } GdkColor * -gtkui_get_selection_color (void) { - return >kui_selection_color; +gtkui_get_tabstrip_light_color (void) { + return >kui_tabstrip_light_color; } GdkColor * -gtkui_get_dark_color (void) { - return >kui_dark_color; +gtkui_get_tabstrip_base_color (void) { + return >kui_tabstrip_base_color; } GdkColor * -gtkui_get_mid_color (void) { - return >kui_mid_color; +gtkui_get_listview_even_row_color (void) { + return >kui_listview_even_row_color; } GdkColor * -gtkui_get_light_color (void) { - return >kui_light_color; +gtkui_get_listview_odd_row_color (void) { + return >kui_listview_odd_row_color; } GdkColor * -gtkui_get_even_row_color (void) { - return >kui_even_row_color; +gtkui_get_listview_selection_color (void) { + return >kui_listview_selection_color; } GdkColor * -gtkui_get_odd_row_color (void) { - return >kui_odd_row_color; +gtkui_get_listview_text_color (void) { + return >kui_listview_text_color; } GdkColor * -gtkui_get_text_color (void) { - return >kui_text_color; +gtkui_get_listview_selected_text_color (void) { + return >kui_listview_selected_text_color; } GdkColor * -gtkui_get_selected_text_color (void) { - return >kui_selected_text_color; +gtkui_get_listview_cursor_color (void) { + return >kui_listview_cursor_color; } diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index b72ab6ba..ab26084f 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -66,7 +66,6 @@ GtkWidget *traymenu; // playlist theming GtkWidget *theme_treeview; GtkWidget *theme_button; -int disable_listview_theming = 0; // that must be called before gtk_init void @@ -233,8 +232,7 @@ on_trayicon_scroll_event (GtkWidget *widget, vol = -60; } deadbeef->volume_set_db (vol); - GtkWidget *volumebar = lookup_widget (mainwin, "volumebar"); - gdk_window_invalidate_rect (volumebar->window, NULL, FALSE); + volumebar_redraw (); return FALSE; } @@ -501,18 +499,9 @@ gtkui_on_configchanged (DB_event_t *ev, uintptr_t data) { int stop_after_current = deadbeef->conf_get_int ("playlist.stop_after_current", 0); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, "stop_after_current")), stop_after_current ? TRUE : FALSE); - // theme colors - gtkui_init_theme_colors (); - - disable_listview_theming = deadbeef->conf_get_int ("gtkui.disable_playlist_theming", 0); return 0; } -int -gtkui_listview_theming_disabled (void) { - return disable_listview_theming; -} - static gboolean outputchanged_cb (gpointer nothing) { preferences_fill_soundcards (); @@ -667,11 +656,7 @@ update_win_title_idle (gpointer data) { static gboolean redraw_seekbar_cb (gpointer nothing) { - void seekbar_draw (GtkWidget *widget); - void seekbar_expose (GtkWidget *widget, int x, int y, int w, int h); - GtkWidget *widget = lookup_widget (mainwin, "seekbar"); - seekbar_draw (widget); - seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height); + seekbar_redraw (); return FALSE; } @@ -703,6 +688,18 @@ gtkui_add_new_playlist (void) { return -1; } +void +volumebar_redraw (void) { + GtkWidget *volumebar = lookup_widget (mainwin, "volumebar"); + gdk_window_invalidate_rect (volumebar->window, NULL, FALSE); +} + +void +tabstrip_redraw (void) { + GtkWidget *ts = lookup_widget (mainwin, "tabstrip"); + ddb_tabstrip_refresh (DDB_TABSTRIP (ts)); +} + static int gtk_initialized = 0; void @@ -763,6 +760,7 @@ gtkui_thread (void *ctx) { } gtkui_on_configchanged (NULL, 0); + gtkui_init_theme_colors (); // visibility of statusbar and headers GtkWidget *header_mi = lookup_widget (mainwin, "view_headers"); diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index a128cb3a..ef8cf9a3 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -86,10 +86,16 @@ playlist_refresh (void); void search_refresh (void); -int -gtkui_listview_theming_disabled (void); - int gtkui_add_new_playlist (void); +void +seekbar_redraw (void); + +void +volumebar_redraw (void); + +void +tabstrip_redraw (void); + #endif diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index 6f06eb46..2812289c 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -1393,34 +1393,43 @@ create_prefwin (void) GtkWidget *vbox9; GtkWidget *pref_close_send_to_tray; GtkWidget *mmb_delete_playlist; - GtkWidget *frame3; - GtkWidget *alignment1; - GtkWidget *colors_table; - GtkWidget *color_light; - GtkWidget *color_mid; - GtkWidget *color_dark; - GtkWidget *color_selection; + GtkWidget *notebook4; + GtkWidget *vbox21; + GtkWidget *override_bar_colors; + GtkWidget *bar_colors_group; GtkWidget *label43; - GtkWidget *label44; + GtkWidget *label47; + GtkWidget *bar_foreground; + GtkWidget *bar_background; + GtkWidget *label73; + GtkWidget *vbox22; + GtkWidget *override_tabstrip_colors; + GtkWidget *tabstrip_colors_group; GtkWidget *label45; GtkWidget *label46; - GtkWidget *color_back; - GtkWidget *label47; - GtkWidget *override_theme_colors; - GtkWidget *frame4; - GtkWidget *alignment2; - GtkWidget *listview_colors_table; + GtkWidget *label44; + GtkWidget *tabstrip_mid; + GtkWidget *tabstrip_light; + GtkWidget *tabstrip_dark; + GtkWidget *tabstrip_base; + GtkWidget *label76; + GtkWidget *label74; + GtkWidget *vbox23; + GtkWidget *override_listview_colors; + GtkWidget *listview_colors_group; GtkWidget *label58; GtkWidget *label59; - GtkWidget *label60; + GtkWidget *listview_even_row; + GtkWidget *listview_odd_row; + GtkWidget *label77; + GtkWidget *label78; + GtkWidget *listview_selected_row; + GtkWidget *listview_text; GtkWidget *label61; + GtkWidget *listview_selected_text; GtkWidget *label62; - GtkWidget *color_even_row; - GtkWidget *color_odd_row; - GtkWidget *color_text; - GtkWidget *color_selected_text; - GtkWidget *color_cursor; - GtkWidget *disable_playlist_theming; + GtkWidget *listview_cursor; + GtkWidget *label75; GtkWidget *label2; GtkWidget *vbox11; GtkWidget *pref_network_enableproxy; @@ -1609,175 +1618,219 @@ create_prefwin (void) gtk_widget_show (mmb_delete_playlist); gtk_box_pack_start (GTK_BOX (vbox9), mmb_delete_playlist, FALSE, FALSE, 0); - frame3 = gtk_frame_new (NULL); - gtk_widget_show (frame3); - gtk_box_pack_start (GTK_BOX (vbox9), frame3, FALSE, TRUE, 0); - gtk_frame_set_shadow_type (GTK_FRAME (frame3), GTK_SHADOW_IN); - - alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_widget_show (alignment1); - gtk_container_add (GTK_CONTAINER (frame3), alignment1); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1), 0, 0, 12, 0); - - colors_table = gtk_table_new (2, 5, TRUE); - gtk_widget_show (colors_table); - gtk_container_add (GTK_CONTAINER (alignment1), colors_table); - gtk_container_set_border_width (GTK_CONTAINER (colors_table), 12); - gtk_table_set_col_spacings (GTK_TABLE (colors_table), 8); - - color_light = gtk_color_button_new (); - gtk_widget_show (color_light); - gtk_table_attach (GTK_TABLE (colors_table), color_light, 3, 4, 1, 2, + notebook4 = gtk_notebook_new (); + gtk_widget_show (notebook4); + gtk_box_pack_start (GTK_BOX (vbox9), notebook4, TRUE, TRUE, 0); + + vbox21 = gtk_vbox_new (FALSE, 8); + gtk_widget_show (vbox21); + gtk_container_add (GTK_CONTAINER (notebook4), vbox21); + gtk_container_set_border_width (GTK_CONTAINER (vbox21), 12); + + override_bar_colors = gtk_check_button_new_with_mnemonic ("Override"); + gtk_widget_show (override_bar_colors); + gtk_box_pack_start (GTK_BOX (vbox21), override_bar_colors, FALSE, FALSE, 0); + + bar_colors_group = gtk_table_new (2, 2, TRUE); + gtk_widget_show (bar_colors_group); + gtk_box_pack_start (GTK_BOX (vbox21), bar_colors_group, TRUE, TRUE, 0); + gtk_table_set_col_spacings (GTK_TABLE (bar_colors_group), 8); + + label43 = gtk_label_new ("Foreground"); + gtk_widget_show (label43); + gtk_table_attach (GTK_TABLE (bar_colors_group), label43, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label43), 0, 0.5); - color_mid = gtk_color_button_new (); - gtk_widget_show (color_mid); - gtk_table_attach (GTK_TABLE (colors_table), color_mid, 2, 3, 1, 2, + label47 = gtk_label_new ("Background"); + gtk_widget_show (label47); + gtk_table_attach (GTK_TABLE (bar_colors_group), label47, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label47), 0, 0.5); - color_dark = gtk_color_button_new (); - gtk_widget_show (color_dark); - gtk_table_attach (GTK_TABLE (colors_table), color_dark, 1, 2, 1, 2, + bar_foreground = gtk_color_button_new (); + gtk_widget_show (bar_foreground); + gtk_table_attach (GTK_TABLE (bar_colors_group), bar_foreground, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - color_selection = gtk_color_button_new (); - gtk_widget_show (color_selection); - gtk_table_attach (GTK_TABLE (colors_table), color_selection, 0, 1, 1, 2, + bar_background = gtk_color_button_new (); + gtk_widget_show (bar_background); + gtk_table_attach (GTK_TABLE (bar_colors_group), bar_background, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - label43 = gtk_label_new ("Selection"); - gtk_widget_show (label43); - gtk_table_attach (GTK_TABLE (colors_table), label43, 0, 1, 0, 1, + label73 = gtk_label_new ("Seekbar/Volumebar colors"); + gtk_widget_show (label73); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook4), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook4), 0), label73); + + vbox22 = gtk_vbox_new (FALSE, 8); + gtk_widget_show (vbox22); + gtk_container_add (GTK_CONTAINER (notebook4), vbox22); + gtk_container_set_border_width (GTK_CONTAINER (vbox22), 12); + + override_tabstrip_colors = gtk_check_button_new_with_mnemonic ("Override"); + gtk_widget_show (override_tabstrip_colors); + gtk_box_pack_start (GTK_BOX (vbox22), override_tabstrip_colors, FALSE, FALSE, 0); + + tabstrip_colors_group = gtk_table_new (2, 4, TRUE); + gtk_widget_show (tabstrip_colors_group); + gtk_box_pack_start (GTK_BOX (vbox22), tabstrip_colors_group, TRUE, TRUE, 0); + gtk_table_set_col_spacings (GTK_TABLE (tabstrip_colors_group), 8); + + label45 = gtk_label_new ("Middle"); + gtk_widget_show (label45); + gtk_table_attach (GTK_TABLE (tabstrip_colors_group), label45, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label43), 0, 0.5); + gtk_misc_set_alignment (GTK_MISC (label45), 0, 0.5); + + label46 = gtk_label_new ("Light"); + gtk_widget_show (label46); + gtk_table_attach (GTK_TABLE (tabstrip_colors_group), label46, 1, 2, 0, 1, + (GtkAttachOptions) (GTK_EXPAND), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label46), 0, 0.5); label44 = gtk_label_new ("Dark"); gtk_widget_show (label44); - gtk_table_attach (GTK_TABLE (colors_table), label44, 1, 2, 0, 1, + gtk_table_attach (GTK_TABLE (tabstrip_colors_group), label44, 2, 3, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label44), 0, 0.5); - label45 = gtk_label_new ("Middle"); - gtk_widget_show (label45); - gtk_table_attach (GTK_TABLE (colors_table), label45, 2, 3, 0, 1, + tabstrip_mid = gtk_color_button_new (); + gtk_widget_show (tabstrip_mid); + gtk_table_attach (GTK_TABLE (tabstrip_colors_group), tabstrip_mid, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label45), 0, 0.5); - label46 = gtk_label_new ("Light"); - gtk_widget_show (label46); - gtk_table_attach (GTK_TABLE (colors_table), label46, 3, 4, 0, 1, + tabstrip_light = gtk_color_button_new (); + gtk_widget_show (tabstrip_light); + gtk_table_attach (GTK_TABLE (tabstrip_colors_group), tabstrip_light, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label46), 0, 0.5); - color_back = gtk_color_button_new (); - gtk_widget_show (color_back); - gtk_table_attach (GTK_TABLE (colors_table), color_back, 4, 5, 1, 2, + tabstrip_dark = gtk_color_button_new (); + gtk_widget_show (tabstrip_dark); + gtk_table_attach (GTK_TABLE (tabstrip_colors_group), tabstrip_dark, 2, 3, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - label47 = gtk_label_new ("Inactive background"); - gtk_widget_show (label47); - gtk_table_attach (GTK_TABLE (colors_table), label47, 4, 5, 0, 1, + tabstrip_base = gtk_color_button_new (); + gtk_widget_show (tabstrip_base); + gtk_table_attach (GTK_TABLE (tabstrip_colors_group), tabstrip_base, 3, 4, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label47), 0, 0.5); - override_theme_colors = gtk_check_button_new_with_mnemonic ("Override GTK+ theme colors in volume control and seek bar widgets"); - gtk_widget_show (override_theme_colors); - gtk_frame_set_label_widget (GTK_FRAME (frame3), override_theme_colors); + label76 = gtk_label_new ("Base"); + gtk_widget_show (label76); + gtk_table_attach (GTK_TABLE (tabstrip_colors_group), label76, 3, 4, 0, 1, + (GtkAttachOptions) (GTK_EXPAND), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label76), 0, 0.5); + + label74 = gtk_label_new ("Tabstrip colors"); + gtk_widget_show (label74); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook4), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook4), 1), label74); - frame4 = gtk_frame_new (NULL); - gtk_widget_show (frame4); - gtk_box_pack_start (GTK_BOX (vbox9), frame4, FALSE, TRUE, 0); - gtk_frame_set_shadow_type (GTK_FRAME (frame4), GTK_SHADOW_IN); + vbox23 = gtk_vbox_new (FALSE, 8); + gtk_widget_show (vbox23); + gtk_container_add (GTK_CONTAINER (notebook4), vbox23); + gtk_container_set_border_width (GTK_CONTAINER (vbox23), 12); - alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_widget_show (alignment2); - gtk_container_add (GTK_CONTAINER (frame4), alignment2); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2), 0, 0, 12, 0); + override_listview_colors = gtk_check_button_new_with_mnemonic ("Override (looses GTK treeview theming, but speeds up rendering)"); + gtk_widget_show (override_listview_colors); + gtk_box_pack_start (GTK_BOX (vbox23), override_listview_colors, FALSE, FALSE, 0); - listview_colors_table = gtk_table_new (2, 5, TRUE); - gtk_widget_show (listview_colors_table); - gtk_container_add (GTK_CONTAINER (alignment2), listview_colors_table); - gtk_container_set_border_width (GTK_CONTAINER (listview_colors_table), 12); - gtk_table_set_col_spacings (GTK_TABLE (listview_colors_table), 8); + listview_colors_group = gtk_table_new (2, 6, TRUE); + gtk_widget_show (listview_colors_group); + gtk_box_pack_start (GTK_BOX (vbox23), listview_colors_group, TRUE, TRUE, 0); + gtk_table_set_col_spacings (GTK_TABLE (listview_colors_group), 8); label58 = gtk_label_new ("Even row"); gtk_widget_show (label58); - gtk_table_attach (GTK_TABLE (listview_colors_table), label58, 0, 1, 0, 1, + gtk_table_attach (GTK_TABLE (listview_colors_group), label58, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label58), 0, 0.5); label59 = gtk_label_new ("Odd row"); gtk_widget_show (label59); - gtk_table_attach (GTK_TABLE (listview_colors_table), label59, 1, 2, 0, 1, + gtk_table_attach (GTK_TABLE (listview_colors_group), label59, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label59), 0, 0.5); - label60 = gtk_label_new ("Text"); - gtk_widget_show (label60); - gtk_table_attach (GTK_TABLE (listview_colors_table), label60, 2, 3, 0, 1, + listview_even_row = gtk_color_button_new (); + gtk_widget_show (listview_even_row); + gtk_table_attach (GTK_TABLE (listview_colors_group), listview_even_row, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label60), 0, 0.5); - label61 = gtk_label_new ("Selected text"); - gtk_widget_show (label61); - gtk_table_attach (GTK_TABLE (listview_colors_table), label61, 3, 4, 0, 1, + listview_odd_row = gtk_color_button_new (); + gtk_widget_show (listview_odd_row); + gtk_table_attach (GTK_TABLE (listview_colors_group), listview_odd_row, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label61), 0, 0.5); - label62 = gtk_label_new ("Cursor"); - gtk_widget_show (label62); - gtk_table_attach (GTK_TABLE (listview_colors_table), label62, 4, 5, 0, 1, + label77 = gtk_label_new ("Text"); + gtk_widget_show (label77); + gtk_table_attach (GTK_TABLE (listview_colors_group), label77, 3, 4, 0, 1, + (GtkAttachOptions) (GTK_EXPAND), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label77), 0, 0.5); + + label78 = gtk_label_new ("Selected row"); + gtk_widget_show (label78); + gtk_table_attach (GTK_TABLE (listview_colors_group), label78, 2, 3, 0, 1, + (GtkAttachOptions) (GTK_EXPAND), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label78), 0, 0.5); + + listview_selected_row = gtk_color_button_new (); + gtk_widget_show (listview_selected_row); + gtk_table_attach (GTK_TABLE (listview_colors_group), listview_selected_row, 2, 3, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label62), 0, 0.5); - color_even_row = gtk_color_button_new (); - gtk_widget_show (color_even_row); - gtk_table_attach (GTK_TABLE (listview_colors_table), color_even_row, 0, 1, 1, 2, + listview_text = gtk_color_button_new (); + gtk_widget_show (listview_text); + gtk_table_attach (GTK_TABLE (listview_colors_group), listview_text, 3, 4, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - color_odd_row = gtk_color_button_new (); - gtk_widget_show (color_odd_row); - gtk_table_attach (GTK_TABLE (listview_colors_table), color_odd_row, 1, 2, 1, 2, + label61 = gtk_label_new ("Selected text"); + gtk_widget_show (label61); + gtk_table_attach (GTK_TABLE (listview_colors_group), label61, 4, 5, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label61), 0, 0.5); - color_text = gtk_color_button_new (); - gtk_widget_show (color_text); - gtk_table_attach (GTK_TABLE (listview_colors_table), color_text, 2, 3, 1, 2, + listview_selected_text = gtk_color_button_new (); + gtk_widget_show (listview_selected_text); + gtk_table_attach (GTK_TABLE (listview_colors_group), listview_selected_text, 4, 5, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - color_selected_text = gtk_color_button_new (); - gtk_widget_show (color_selected_text); - gtk_table_attach (GTK_TABLE (listview_colors_table), color_selected_text, 3, 4, 1, 2, + label62 = gtk_label_new ("Cursor"); + gtk_widget_show (label62); + gtk_table_attach (GTK_TABLE (listview_colors_group), label62, 5, 6, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label62), 0, 0.5); - color_cursor = gtk_color_button_new (); - gtk_widget_show (color_cursor); - gtk_table_attach (GTK_TABLE (listview_colors_table), color_cursor, 4, 5, 1, 2, + listview_cursor = gtk_color_button_new (); + gtk_widget_show (listview_cursor); + gtk_table_attach (GTK_TABLE (listview_colors_group), listview_cursor, 5, 6, 1, 2, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); - disable_playlist_theming = gtk_check_button_new_with_mnemonic ("Disable playlist theming (speeds up rendering)"); - gtk_widget_show (disable_playlist_theming); - gtk_frame_set_label_widget (GTK_FRAME (frame4), disable_playlist_theming); + label75 = gtk_label_new ("Playlist colors"); + gtk_widget_show (label75); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook4), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook4), 2), label75); label2 = gtk_label_new ("GUI"); gtk_widget_show (label2); @@ -2138,38 +2191,50 @@ create_prefwin (void) g_signal_connect ((gpointer) mmb_delete_playlist, "toggled", G_CALLBACK (on_mmb_delete_playlist_toggled), NULL); - g_signal_connect ((gpointer) color_light, "color_set", - G_CALLBACK (on_color_light_color_set), + g_signal_connect ((gpointer) override_bar_colors, "toggled", + G_CALLBACK (on_override_bar_colors_toggled), NULL); - g_signal_connect ((gpointer) color_mid, "color_set", - G_CALLBACK (on_color_mid_color_set), + g_signal_connect ((gpointer) bar_foreground, "color_set", + G_CALLBACK (on_bar_foreground_color_set), NULL); - g_signal_connect ((gpointer) color_dark, "color_set", - G_CALLBACK (on_color_dark_color_set), + g_signal_connect ((gpointer) bar_background, "color_set", + G_CALLBACK (on_bar_background_color_set), NULL); - g_signal_connect ((gpointer) color_selection, "color_set", - G_CALLBACK (on_color_selection_color_set), + g_signal_connect ((gpointer) override_tabstrip_colors, "toggled", + G_CALLBACK (on_override_tabstrip_colors_toggled), NULL); - g_signal_connect ((gpointer) color_back, "color_set", - G_CALLBACK (on_color_back_color_set), + g_signal_connect ((gpointer) tabstrip_mid, "color_set", + G_CALLBACK (on_tabstrip_mid_color_set), NULL); - g_signal_connect ((gpointer) override_theme_colors, "toggled", - G_CALLBACK (on_override_gtk_colors_toggled), + g_signal_connect ((gpointer) tabstrip_light, "color_set", + G_CALLBACK (on_tabstrip_light_color_set), NULL); - g_signal_connect ((gpointer) color_even_row, "color_set", - G_CALLBACK (on_color_even_row_color_set), + g_signal_connect ((gpointer) tabstrip_dark, "color_set", + G_CALLBACK (on_tabstrip_dark_color_set), NULL); - g_signal_connect ((gpointer) color_odd_row, "color_set", - G_CALLBACK (on_color_odd_row_color_set), + g_signal_connect ((gpointer) tabstrip_base, "color_set", + G_CALLBACK (on_tabstrip_base_color_set), NULL); - g_signal_connect ((gpointer) color_text, "color_set", - G_CALLBACK (on_color_text_color_set), + g_signal_connect ((gpointer) override_listview_colors, "toggled", + G_CALLBACK (on_override_listview_colors_toggled), NULL); - g_signal_connect ((gpointer) color_selected_text, "color_set", - G_CALLBACK (on_color_selected_text_color_set), + g_signal_connect ((gpointer) listview_even_row, "color_set", + G_CALLBACK (on_listview_even_row_color_set), NULL); - g_signal_connect ((gpointer) disable_playlist_theming, "toggled", - G_CALLBACK (on_disable_playlist_theming_toggled), + g_signal_connect ((gpointer) listview_odd_row, "color_set", + G_CALLBACK (on_listview_odd_row_color_set), + NULL); + g_signal_connect ((gpointer) listview_selected_row, "color_set", + G_CALLBACK (on_listview_selected_row_color_set), + NULL); + g_signal_connect ((gpointer) listview_text, "color_set", + G_CALLBACK (on_listview_text_color_set), + NULL); + g_signal_connect ((gpointer) listview_selected_text, "color_set", + G_CALLBACK (on_listview_selected_text_color_set), + NULL); + g_signal_connect ((gpointer) listview_cursor, "color_set", + G_CALLBACK (on_listview_cursor_color_set), NULL); g_signal_connect ((gpointer) pref_network_enableproxy, "clicked", G_CALLBACK (on_pref_network_enableproxy_clicked), @@ -2251,34 +2316,43 @@ create_prefwin (void) GLADE_HOOKUP_OBJECT (prefwin, vbox9, "vbox9"); GLADE_HOOKUP_OBJECT (prefwin, pref_close_send_to_tray, "pref_close_send_to_tray"); GLADE_HOOKUP_OBJECT (prefwin, mmb_delete_playlist, "mmb_delete_playlist"); - GLADE_HOOKUP_OBJECT (prefwin, frame3, "frame3"); - GLADE_HOOKUP_OBJECT (prefwin, alignment1, "alignment1"); - GLADE_HOOKUP_OBJECT (prefwin, colors_table, "colors_table"); - GLADE_HOOKUP_OBJECT (prefwin, color_light, "color_light"); - GLADE_HOOKUP_OBJECT (prefwin, color_mid, "color_mid"); - GLADE_HOOKUP_OBJECT (prefwin, color_dark, "color_dark"); - GLADE_HOOKUP_OBJECT (prefwin, color_selection, "color_selection"); + GLADE_HOOKUP_OBJECT (prefwin, notebook4, "notebook4"); + GLADE_HOOKUP_OBJECT (prefwin, vbox21, "vbox21"); + GLADE_HOOKUP_OBJECT (prefwin, override_bar_colors, "override_bar_colors"); + GLADE_HOOKUP_OBJECT (prefwin, bar_colors_group, "bar_colors_group"); GLADE_HOOKUP_OBJECT (prefwin, label43, "label43"); - GLADE_HOOKUP_OBJECT (prefwin, label44, "label44"); + GLADE_HOOKUP_OBJECT (prefwin, label47, "label47"); + GLADE_HOOKUP_OBJECT (prefwin, bar_foreground, "bar_foreground"); + GLADE_HOOKUP_OBJECT (prefwin, bar_background, "bar_background"); + GLADE_HOOKUP_OBJECT (prefwin, label73, "label73"); + GLADE_HOOKUP_OBJECT (prefwin, vbox22, "vbox22"); + GLADE_HOOKUP_OBJECT (prefwin, override_tabstrip_colors, "override_tabstrip_colors"); + GLADE_HOOKUP_OBJECT (prefwin, tabstrip_colors_group, "tabstrip_colors_group"); GLADE_HOOKUP_OBJECT (prefwin, label45, "label45"); GLADE_HOOKUP_OBJECT (prefwin, label46, "label46"); - GLADE_HOOKUP_OBJECT (prefwin, color_back, "color_back"); - GLADE_HOOKUP_OBJECT (prefwin, label47, "label47"); - GLADE_HOOKUP_OBJECT (prefwin, override_theme_colors, "override_theme_colors"); - GLADE_HOOKUP_OBJECT (prefwin, frame4, "frame4"); - GLADE_HOOKUP_OBJECT (prefwin, alignment2, "alignment2"); - GLADE_HOOKUP_OBJECT (prefwin, listview_colors_table, "listview_colors_table"); + GLADE_HOOKUP_OBJECT (prefwin, label44, "label44"); + GLADE_HOOKUP_OBJECT (prefwin, tabstrip_mid, "tabstrip_mid"); + GLADE_HOOKUP_OBJECT (prefwin, tabstrip_light, "tabstrip_light"); + GLADE_HOOKUP_OBJECT (prefwin, tabstrip_dark, "tabstrip_dark"); + GLADE_HOOKUP_OBJECT (prefwin, tabstrip_base, "tabstrip_base"); + GLADE_HOOKUP_OBJECT (prefwin, label76, "label76"); + GLADE_HOOKUP_OBJECT (prefwin, label74, "label74"); + GLADE_HOOKUP_OBJECT (prefwin, vbox23, "vbox23"); + GLADE_HOOKUP_OBJECT (prefwin, override_listview_colors, "override_listview_colors"); + GLADE_HOOKUP_OBJECT (prefwin, listview_colors_group, "listview_colors_group"); GLADE_HOOKUP_OBJECT (prefwin, label58, "label58"); GLADE_HOOKUP_OBJECT (prefwin, label59, "label59"); - GLADE_HOOKUP_OBJECT (prefwin, label60, "label60"); + GLADE_HOOKUP_OBJECT (prefwin, listview_even_row, "listview_even_row"); + GLADE_HOOKUP_OBJECT (prefwin, listview_odd_row, "listview_odd_row"); + GLADE_HOOKUP_OBJECT (prefwin, label77, "label77"); + GLADE_HOOKUP_OBJECT (prefwin, label78, "label78"); + GLADE_HOOKUP_OBJECT (prefwin, listview_selected_row, "listview_selected_row"); + GLADE_HOOKUP_OBJECT (prefwin, listview_text, "listview_text"); GLADE_HOOKUP_OBJECT (prefwin, label61, "label61"); + GLADE_HOOKUP_OBJECT (prefwin, listview_selected_text, "listview_selected_text"); GLADE_HOOKUP_OBJECT (prefwin, label62, "label62"); - GLADE_HOOKUP_OBJECT (prefwin, color_even_row, "color_even_row"); - GLADE_HOOKUP_OBJECT (prefwin, color_odd_row, "color_odd_row"); - GLADE_HOOKUP_OBJECT (prefwin, color_text, "color_text"); - GLADE_HOOKUP_OBJECT (prefwin, color_selected_text, "color_selected_text"); - GLADE_HOOKUP_OBJECT (prefwin, color_cursor, "color_cursor"); - GLADE_HOOKUP_OBJECT (prefwin, disable_playlist_theming, "disable_playlist_theming"); + GLADE_HOOKUP_OBJECT (prefwin, listview_cursor, "listview_cursor"); + GLADE_HOOKUP_OBJECT (prefwin, label75, "label75"); GLADE_HOOKUP_OBJECT (prefwin, label2, "label2"); GLADE_HOOKUP_OBJECT (prefwin, vbox11, "vbox11"); GLADE_HOOKUP_OBJECT (prefwin, pref_network_enableproxy, "pref_network_enableproxy"); diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c index 937948d9..24cf6c0c 100644 --- a/plugins/gtkui/plcommon.c +++ b/plugins/gtkui/plcommon.c @@ -78,8 +78,18 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview return; } DB_playItem_t *playing_track = deadbeef->streamer_get_playing_track (); + int theming = !gtkui_override_listview_colors (); + if (cinf->id == DB_COLUMN_ALBUM_ART) { - gtk_paint_flat_box (theme_treeview->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, theme_treeview, "cell_even_ruled", x, y, width, height); + if (theming) { + gtk_paint_flat_box (theme_treeview->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, theme_treeview, "cell_even_ruled", x, y, width, height); + } + else { + GdkGC *gc = gdk_gc_new (drawable); + gdk_gc_set_rgb_fg_color (gc, gtkui_get_listview_even_row_color ()); + gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height); + g_object_unref (gc); + } int art_width = width - ART_PADDING_HORZ * 2; int art_y = y; // dest y int art_h = height; @@ -135,11 +145,21 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview char text[1024]; deadbeef->pl_format_title (it, -1, text, sizeof (text), cinf->id, cinf->format); GdkColor *color = NULL; - if (deadbeef->pl_is_selected (it)) { - color = &theme_treeview->style->text[GTK_STATE_SELECTED]; + if (theming) { + if (deadbeef->pl_is_selected (it)) { + color = &theme_treeview->style->text[GTK_STATE_SELECTED]; + } + else { + color = &theme_treeview->style->text[GTK_STATE_NORMAL]; + } } else { - color = &theme_treeview->style->text[GTK_STATE_NORMAL]; + if (deadbeef->pl_is_selected (it)) { + color = gtkui_get_listview_selected_text_color (); + } + else { + color = gtkui_get_listview_text_color (); + } } float fg[3] = {(float)color->red/0xffff, (float)color->green/0xffff, (float)color->blue/0xffff}; draw_set_fg_color (fg); diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c index 716e8da5..55a50f41 100644 --- a/plugins/gtkui/prefwin.c +++ b/plugins/gtkui/prefwin.c @@ -208,6 +208,23 @@ on_applyhotkeys_clicked (GtkButton *button, gpointer user_da } } +void +prefwin_init_theme_colors (void) { + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "bar_background")), gtkui_get_bar_background_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "bar_foreground")), gtkui_get_bar_foreground_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "tabstrip_dark")), gtkui_get_tabstrip_dark_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "tabstrip_mid")), gtkui_get_tabstrip_mid_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "tabstrip_light")), gtkui_get_tabstrip_light_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "tabstrip_base")), gtkui_get_tabstrip_base_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "listview_even_row")), gtkui_get_listview_even_row_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "listview_odd_row")), gtkui_get_listview_odd_row_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "listview_selected_row")), gtkui_get_listview_selection_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "listview_text")), gtkui_get_listview_text_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "listview_selected_text")), gtkui_get_listview_selected_text_color ()); + gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "listview_cursor")), gtkui_get_listview_cursor_color ()); + +} + void on_preferences_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -263,29 +280,23 @@ on_preferences_activate (GtkMenuItem *menuitem, // mmb_delete_playlist gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "mmb_delete_playlist")), deadbeef->conf_get_int ("gtkui.mmb_delete_playlist", 0)); - // override colors - int override = deadbeef->conf_get_int ("gtkui.override_theme_colors", 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (prefwin, "override_theme_colors")), override); - gtk_widget_set_sensitive (lookup_widget (prefwin, "colors_table"), override); - - // colors - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_selection")), gtkui_get_selection_color ()); - - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_dark")), gtkui_get_dark_color ()); + // override bar colors + int override = deadbeef->conf_get_int ("gtkui.override_bar_colors", 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (prefwin, "override_bar_colors")), override); + gtk_widget_set_sensitive (lookup_widget (prefwin, "bar_colors_group"), override); - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_mid")), gtkui_get_mid_color ()); + // override tabstrip colors + override = deadbeef->conf_get_int ("gtkui.override_tabstrip_colors", 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (prefwin, "override_tabstrip_colors")), override); + gtk_widget_set_sensitive (lookup_widget (prefwin, "tabstrip_colors_group"), override); - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_light")), gtkui_get_light_color ()); + // override listview colors + override = deadbeef->conf_get_int ("gtkui.override_listview_colors", 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (prefwin, "override_listview_colors")), override); + gtk_widget_set_sensitive (lookup_widget (prefwin, "listview_colors_group"), override); - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_back")), gtkui_get_back_color ()); - - override = deadbeef->conf_get_int ("gtkui.disable_playlist_theming", 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (prefwin, "disable_playlist_theming")), override); - gtk_widget_set_sensitive (lookup_widget (prefwin, "listview_colors_table"), override); - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_even_row")), gtkui_get_even_row_color ()); - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_odd_row")), gtkui_get_odd_row_color ()); - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_text")), gtkui_get_text_color ()); - gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "color_selected_text")), gtkui_get_selected_text_color ()); + // colors + prefwin_init_theme_colors (); // network gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "pref_network_enableproxy")), deadbeef->conf_get_int ("network.proxy", 0)); @@ -623,140 +634,220 @@ on_configure_plugin_clicked (GtkButton *button, } void -on_color_light_color_set (GtkColorButton *colorbutton, +on_tabstrip_light_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.light", str); + deadbeef->conf_set_str ("gtkui.color.tabstrip_light", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + tabstrip_redraw (); } void -on_color_mid_color_set (GtkColorButton *colorbutton, +on_tabstrip_mid_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.mid", str); + deadbeef->conf_set_str ("gtkui.color.tabstrip_mid", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + tabstrip_redraw (); } void -on_color_dark_color_set (GtkColorButton *colorbutton, +on_tabstrip_dark_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.dark", str); + deadbeef->conf_set_str ("gtkui.color.tabstrip_dark", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + tabstrip_redraw (); } - void -on_color_selection_color_set (GtkColorButton *colorbutton, +on_tabstrip_base_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.selection", str); + deadbeef->conf_set_str ("gtkui.color.tabstrip_base", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); - + gtkui_init_theme_colors (); + tabstrip_redraw (); } void -on_color_back_color_set (GtkColorButton *colorbutton, +on_bar_foreground_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.back", str); + deadbeef->conf_set_str ("gtkui.color.bar_foreground", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + seekbar_redraw (); + volumebar_redraw (); } void -on_color_even_row_color_set (GtkColorButton *colorbutton, +on_bar_background_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.even_row", str); + deadbeef->conf_set_str ("gtkui.color.bar_background", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + seekbar_redraw (); + volumebar_redraw (); +} + +void +on_override_listview_colors_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + int active = gtk_toggle_button_get_active (togglebutton); + deadbeef->conf_set_int ("gtkui.override_listview_colors", active); + gtk_widget_set_sensitive (lookup_widget (prefwin, "listview_colors_group"), active); + deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + playlist_refresh (); } void -on_color_odd_row_color_set (GtkColorButton *colorbutton, +on_listview_even_row_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.odd_row", str); + deadbeef->conf_set_str ("gtkui.color.listview_even_row", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + playlist_refresh (); } +void +on_listview_odd_row_color_set (GtkColorButton *colorbutton, + gpointer user_data) +{ + GdkColor clr; + gtk_color_button_get_color (colorbutton, &clr); + char str[100]; + snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); + deadbeef->conf_set_str ("gtkui.color.listview_odd_row", str); + deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + playlist_refresh (); +} + +void +on_listview_selected_row_color_set (GtkColorButton *colorbutton, + gpointer user_data) +{ + GdkColor clr; + gtk_color_button_get_color (colorbutton, &clr); + char str[100]; + snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); + deadbeef->conf_set_str ("gtkui.color.listview_selection", str); + deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + playlist_refresh (); +} void -on_color_text_color_set (GtkColorButton *colorbutton, +on_listview_text_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.text", str); + deadbeef->conf_set_str ("gtkui.color.listview_text", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + playlist_refresh (); } void -on_color_selected_text_color_set (GtkColorButton *colorbutton, +on_listview_selected_text_color_set (GtkColorButton *colorbutton, gpointer user_data) { GdkColor clr; gtk_color_button_get_color (colorbutton, &clr); char str[100]; snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); - deadbeef->conf_set_str ("gtkui.color.selected_text", str); + deadbeef->conf_set_str ("gtkui.color.listview_selected_text", str); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + playlist_refresh (); } void -on_override_gtk_colors_toggled (GtkToggleButton *togglebutton, +on_listview_cursor_color_set (GtkColorButton *colorbutton, + gpointer user_data) +{ + GdkColor clr; + gtk_color_button_get_color (colorbutton, &clr); + char str[100]; + snprintf (str, sizeof (str), "%d %d %d", clr.red, clr.green, clr.blue); + deadbeef->conf_set_str ("gtkui.color.listview_cursor", str); + deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + playlist_refresh (); +} + + +void +on_override_bar_colors_toggled (GtkToggleButton *togglebutton, gpointer user_data) { int active = gtk_toggle_button_get_active (togglebutton); - deadbeef->conf_set_int ("gtkui.override_theme_colors", active); - gtk_widget_set_sensitive (lookup_widget (prefwin, "colors_table"), active); + deadbeef->conf_set_int ("gtkui.override_bar_colors", active); + gtk_widget_set_sensitive (lookup_widget (prefwin, "bar_colors_group"), active); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + prefwin_init_theme_colors (); + seekbar_redraw (); + volumebar_redraw (); } + void -on_disable_playlist_theming_toggled (GtkToggleButton *togglebutton, +on_override_tabstrip_colors_toggled (GtkToggleButton *togglebutton, gpointer user_data) { int active = gtk_toggle_button_get_active (togglebutton); - deadbeef->conf_set_int ("gtkui.disable_playlist_theming", active); - gtk_widget_set_sensitive (lookup_widget (prefwin, "listview_colors_table"), active); + deadbeef->conf_set_int ("gtkui.override_tabstrip_colors", active); + gtk_widget_set_sensitive (lookup_widget (prefwin, "tabstrip_colors_group"), active); deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0); + gtkui_init_theme_colors (); + prefwin_init_theme_colors (); + tabstrip_redraw (); } void -- cgit v1.2.3 From f896a3e7d10bc3d5cf6a9eb292159b676ef66ac5 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sat, 3 Apr 2010 21:51:58 +0200 Subject: handle on the fly theme/font changing in custom widgets --- plugins/gtkui/ddblistview.c | 13 +++++++++++++ plugins/gtkui/ddbtabstrip.c | 7 ++++++- plugins/gtkui/drawing.h | 3 +++ plugins/gtkui/gdkdrawing.c | 37 ++++++++++++++++++++++--------------- plugins/gtkui/plcommon.c | 1 + 5 files changed, 45 insertions(+), 16 deletions(-) (limited to 'plugins/gtkui') diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index 8a417ce6..46b3684b 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -534,6 +534,14 @@ ddb_listview_list_configure_event (GtkWidget *widget, gpointer user_data) { DdbListview *ps = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (widget), "owner")); + + draw_init_font (widget->style); + int height = draw_get_font_size () + 12; + if (height != ps->rowheight) { + ps->rowheight = height; + ddb_listview_build_groups (ps); + } + ddb_listview_list_setup_vscroll (ps); ddb_listview_list_setup_hscroll (ps); widget = ps->list; @@ -2040,6 +2048,11 @@ ddb_listview_header_configure_event (GtkWidget *widget, gpointer user_data) { DdbListview *ps = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (widget), "owner")); + draw_init_font (widget->style); + int height = draw_get_font_size () + 12; + if (height != widget->allocation.height) { + gtk_widget_set_size_request (widget, -1, height); + } if (ps->backbuf_header) { g_object_unref (ps->backbuf_header); ps->backbuf_header = NULL; diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c index af04abc7..de5a3231 100644 --- a/plugins/gtkui/ddbtabstrip.c +++ b/plugins/gtkui/ddbtabstrip.c @@ -262,7 +262,7 @@ tabstrip_render (DdbTabStrip *ts) { int x = -ts->hscrollpos; int w = 0; int h = draw_get_font_size (); - gtk_widget_set_size_request (widget, -1, h + 9 + 4); +// gtk_widget_set_size_request (widget, -1, h + 9 + 4); h = widget->allocation.height; tab_overlap_size = (h-4)/2; text_right_padding = h - 3; @@ -475,6 +475,11 @@ gboolean on_tabstrip_configure_event (GtkWidget *widget, GdkEventConfigure *event) { + draw_init_font (widget->style); + int height = draw_get_font_size () + 13; + if (height != widget->allocation.height) { + gtk_widget_set_size_request (widget, -1, height); + } DdbTabStrip *ts = DDB_TABSTRIP (widget); if (ts->backbuf) { g_object_unref (ts->backbuf); diff --git a/plugins/gtkui/drawing.h b/plugins/gtkui/drawing.h index 16f2c211..40196441 100644 --- a/plugins/gtkui/drawing.h +++ b/plugins/gtkui/drawing.h @@ -59,6 +59,9 @@ draw_rect (float x, float y, float w, float h, int fill); float draw_get_font_size (void); +void +draw_init_font (GtkStyle *style); + void draw_text (float x, float y, int width, int align, const char *text); diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c index 84b07d29..b8e38b83 100644 --- a/plugins/gtkui/gdkdrawing.c +++ b/plugins/gtkui/gdkdrawing.c @@ -43,11 +43,6 @@ draw_begin (uintptr_t canvas) { void draw_end (void) { -// if (pango_ready) { -// g_object_unref (pangolayout); -// g_object_unref (pangoctx); -// pango_ready = 0; -// } drawable = NULL; if (gc) { g_object_unref (gc); @@ -96,14 +91,26 @@ draw_rect (float x, float y, float w, float h, int fill) { gdk_draw_rectangle (drawable, gc, fill, x, y, w, h); } -static inline void -draw_init_font (void) { - if (!pango_ready) { +static GtkStyle *font_style = NULL; + +void +draw_init_font (GtkStyle *new_font_style) { + if (!pango_ready || (new_font_style && font_style != new_font_style)) { + if (pangoctx) { + g_object_unref (pangoctx); + pangoctx = NULL; + } + if (pangolayout) { + g_object_unref (pangolayout); + pangolayout = NULL; + } + + font_style = new_font_style ? new_font_style : gtk_widget_get_default_style (); + pangoctx = gdk_pango_context_get (); pangolayout = pango_layout_new (pangoctx); pango_layout_set_ellipsize (pangolayout, PANGO_ELLIPSIZE_END); - GtkStyle *style = gtk_widget_get_default_style (); - PangoFontDescription *desc = style->font_desc; + PangoFontDescription *desc = font_style->font_desc; pango_layout_set_font_description (pangolayout, desc); pango_ready = 1; } @@ -111,16 +118,16 @@ draw_init_font (void) { float draw_get_font_size (void) { + draw_init_font (NULL); GdkScreen *screen = gdk_screen_get_default (); float dpi = gdk_screen_get_resolution (screen); - GtkStyle *style = gtk_widget_get_default_style (); - PangoFontDescription *desc = style->font_desc; + PangoFontDescription *desc = font_style->font_desc; return (float)(pango_font_description_get_size (desc) / PANGO_SCALE * dpi / 72); } void draw_text (float x, float y, int width, int align, const char *text) { - draw_init_font (); + draw_init_font (NULL); pango_layout_set_width (pangolayout, width*PANGO_SCALE); pango_layout_set_alignment (pangolayout, align ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT); pango_layout_set_text (pangolayout, text, -1); @@ -129,7 +136,7 @@ draw_text (float x, float y, int width, int align, const char *text) { void draw_text_with_colors (float x, float y, int width, int align, const char *text) { - draw_init_font (); + draw_init_font (NULL); pango_layout_set_width (pangolayout, width*PANGO_SCALE); pango_layout_set_alignment (pangolayout, align ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT); pango_layout_set_text (pangolayout, text, -1); @@ -138,7 +145,7 @@ draw_text_with_colors (float x, float y, int width, int align, const char *text) void draw_get_text_extents (const char *text, int len, int *w, int *h) { - draw_init_font (); + draw_init_font (NULL); pango_layout_set_width (pangolayout, 1000 * PANGO_SCALE); pango_layout_set_alignment (pangolayout, PANGO_ALIGN_LEFT); pango_layout_set_text (pangolayout, text, len); diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c index 24cf6c0c..006234c8 100644 --- a/plugins/gtkui/plcommon.c +++ b/plugins/gtkui/plcommon.c @@ -164,6 +164,7 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview float fg[3] = {(float)color->red/0xffff, (float)color->green/0xffff, (float)color->blue/0xffff}; draw_set_fg_color (fg); + draw_init_font (GTK_WIDGET (listview)->style); if (calign_right) { draw_text (x+5, y + height/2 - draw_get_font_size ()/2 - 2, cwidth-10, 1, text); } -- cgit v1.2.3 From 040bb51a271bfb766711b4bd2e2b4342a22132b3 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sat, 3 Apr 2010 22:04:21 +0200 Subject: changed tabstrip to tab strip in pref window --- plugins/gtkui/deadbeef.glade | 2 +- plugins/gtkui/interface.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/gtkui') diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index 89f682ab..bd0ec65d 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -2677,7 +2677,7 @@ Album True - Tabstrip colors + Tab strip colors False False GTK_JUSTIFY_LEFT diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index 2812289c..ef00fa83 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -1732,7 +1732,7 @@ create_prefwin (void) (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label76), 0, 0.5); - label74 = gtk_label_new ("Tabstrip colors"); + label74 = gtk_label_new ("Tab strip colors"); gtk_widget_show (label74); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook4), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook4), 1), label74); -- cgit v1.2.3 From e780b00c954190e49086163cb59d9354a7f7a435 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sat, 3 Apr 2010 22:20:18 +0200 Subject: fixed segfault/memleak in dragndrop --- plugins/gtkui/fileman.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins/gtkui') diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c index b1fa28af..1ae8b4aa 100644 --- a/plugins/gtkui/fileman.c +++ b/plugins/gtkui/fileman.c @@ -197,6 +197,7 @@ gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) { deadbeef->pl_item_unref (after); } after = inserted; + deadbeef->pl_item_ref (after); } } p = pe; @@ -205,6 +206,9 @@ gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) { p++; } } + if (after) { + deadbeef->pl_item_unref (after); + } free (ptr); g_idle_add (progress_hide_idle, NULL); -- cgit v1.2.3 From 1af02622022d9100b302c7dd7e8bc08793bead38 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 4 Apr 2010 11:20:44 +0200 Subject: fixed ref-leak in dragndrop --- plugins/gtkui/ddblistview.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins/gtkui') diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index 46b3684b..9ac6e561 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -903,6 +903,9 @@ ddb_listview_list_drag_data_received (GtkWidget *widget, drop_before = next; } ps->binding->drag_n_drop (drop_before, d, length); + if (drop_before) { + UNREF (drop_before); + } } gtk_drag_finish (drag_context, TRUE, FALSE, time); } -- cgit v1.2.3 From 3e353f8d1a41585b4715eaf0dfeed057b8a23b15 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 4 Apr 2010 13:32:15 +0200 Subject: implemented dragndrop between different playlists --- deadbeef.h | 5 ++ playlist.c | 71 ++++++++++++++++++++++++++ playlist.h | 9 ++++ plugins.c | 5 ++ plugins/gtkui/ddblistview.c | 18 ++++--- plugins/gtkui/ddblistview.h | 3 +- plugins/gtkui/ddbtabstrip.c | 115 +++++++++++++++++++++++++++---------------- plugins/gtkui/mainplaylist.c | 12 ++++- 8 files changed, 186 insertions(+), 52 deletions(-) (limited to 'plugins/gtkui') diff --git a/deadbeef.h b/deadbeef.h index eaf9f076..a0053cdd 100644 --- a/deadbeef.h +++ b/deadbeef.h @@ -319,6 +319,8 @@ typedef struct { int (*cond_broadcast) (uintptr_t cond); // playlist management int (*plt_get_count) (void); + DB_playItem_t * (*plt_get_head) (int plt); + int (*plt_get_sel_count) (int plt); int (*plt_add) (int before, const char *title); void (*plt_remove) (int plt); void (*plt_free) (void); @@ -330,6 +332,8 @@ typedef struct { // playlist control void (*pl_lock) (void); void (*pl_unlock) (void); + void (*plt_lock) (void); + void (*plt_unlock) (void); // playlist tracks access DB_playItem_t * (*pl_item_alloc) (void); void (*pl_item_ref) (DB_playItem_t *it); @@ -389,6 +393,7 @@ typedef struct { // DB_playItem_t* (*pl_get_head) (void); // DB_playItem_t* (*pl_get_tail) (void); void (*pl_move_items) (int iter, DB_playItem_t *drop_before, uint32_t *indexes, int count); + void (*pl_copy_items) (int iter, int plt_from, DB_playItem_t *before, uint32_t *indices, int cnt); void (*pl_search_reset) (void); void (*pl_search_process) (const char *text); // metainfo diff --git a/playlist.c b/playlist.c index f556a3ef..09e656f0 100644 --- a/playlist.c +++ b/playlist.c @@ -198,6 +198,39 @@ plt_get_count (void) { return playlists_count; } +playItem_t * +plt_get_head (int plt) { + playlist_t *p = playlists_head; + for (int i = 0; p && i <= plt; i++, p = p->next) { + if (i == plt) { + if (p->head[PL_MAIN]) { + pl_item_ref (p->head[PL_MAIN]); + } + return p->head[PL_MAIN]; + } + } + return NULL; +} + +int +plt_get_sel_count (int plt) { + playlist_t *p = playlists_head; + for (int i = 0; p && i <= plt; i++, p = p->next) { + if (i == plt) { + int cnt = 0; + LOCK; + for (playItem_t *it = p->head[PL_MAIN]; it; it = it->next[PL_MAIN]) { + if (it->selected) { + cnt++; + } + } + UNLOCK; + return cnt; + } + } + return 0; +} + int plt_add (int before, const char *title) { trace ("plt_add\n"); @@ -2548,6 +2581,44 @@ pl_move_items (int iter, playItem_t *drop_before, uint32_t *indexes, int count) GLOBAL_UNLOCK; } +void +pl_copy_items (int iter, int plt_from, playItem_t *before, uint32_t *indices, int cnt) { + pl_lock (); + playlist_t *from = playlists_head; + playlist_t *to = plt_get_curr_ptr (); + + int i; + for (i = 0; i < plt_from; i++) { + from = from->next; + } + + if (!from || !to) { + pl_unlock (); + return; + } + + for (i = 0; i < cnt; i++) { + playItem_t *it = from->head[iter]; + int idx = 0; + while (it && idx < indices[i]) { + it = it->next[iter]; + idx++; + } + if (!it) { + trace ("pl_copy_items: warning: item %d not found in source playlist\n", indices[i]); + continue; + } + playItem_t *it_new = pl_item_alloc (); + pl_item_copy (it_new, it); + + playItem_t *after = before ? before->prev[iter] : to->tail[iter]; + pl_insert_item (after, it_new); + pl_item_unref (it_new); + + } + pl_unlock (); +} + void pl_search_reset (void) { GLOBAL_LOCK; diff --git a/playlist.h b/playlist.h index 9651e148..b6c8403f 100644 --- a/playlist.h +++ b/playlist.h @@ -93,6 +93,12 @@ plt_get_curr_ptr (void); int plt_get_count (void); +playItem_t * +plt_get_head (int plt); + +int +plt_get_sel_count (int plt); + int plt_add (int before, const char *title); @@ -265,6 +271,9 @@ pl_set_cursor (int iter, int cursor); void pl_move_items (int iter, playItem_t *drop_before, uint32_t *indexes, int count); +void +pl_copy_items (int iter, int plt_from, playItem_t *before, uint32_t *indices, int cnt); + void pl_search_reset (void); diff --git a/plugins.c b/plugins.c index 64845e0d..429fac61 100644 --- a/plugins.c +++ b/plugins.c @@ -106,6 +106,8 @@ static DB_functions_t deadbeef_api = { .cond_broadcast = cond_broadcast, // playlist management .plt_get_count = plt_get_count, + .plt_get_head = (DB_playItem_t * (*) (int plt))plt_get_head, + .plt_get_sel_count = plt_get_sel_count, .plt_add = plt_add, .plt_remove = plt_remove, .plt_free = plt_free, @@ -117,6 +119,8 @@ static DB_functions_t deadbeef_api = { // playlist access .pl_lock = pl_lock, .pl_unlock = pl_unlock, + .plt_lock = plt_lock, + .plt_unlock = plt_unlock, .pl_item_alloc = (DB_playItem_t* (*)(void))pl_item_alloc, .pl_item_ref = (void (*)(DB_playItem_t *))pl_item_ref, .pl_item_unref = (void (*)(DB_playItem_t *))pl_item_unref, @@ -153,6 +157,7 @@ static DB_functions_t deadbeef_api = { .pl_format_title = (int (*) (DB_playItem_t *it, int idx, char *s, int size, int id, const char *fmt))pl_format_title, .pl_format_item_display_name = (void (*) (DB_playItem_t *it, char *str, int len))pl_format_item_display_name, .pl_move_items = (void (*) (int iter, DB_playItem_t *drop_before, uint32_t *indexes, int count))pl_move_items, + .pl_copy_items = (void (*) (int iter, int plt_from, DB_playItem_t *before, uint32_t *indices, int cnt))pl_copy_items, .pl_search_reset = pl_search_reset, .pl_search_process = pl_search_process, // metainfo diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index 9ac6e561..441e126b 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -828,14 +828,15 @@ ddb_listview_list_drag_data_get (GtkWidget *widget, case TARGET_SAMEWIDGET: { // format as "STRING" consisting of array of pointers - int nsel = ps->binding->sel_count (); + int nsel = deadbeef->plt_get_sel_count (ps->drag_source_playlist); if (!nsel) { break; // something wrong happened } - uint32_t *ptr = malloc (nsel * sizeof (uint32_t)); + uint32_t *ptr = malloc ((nsel+1) * sizeof (uint32_t)); + *ptr = ps->drag_source_playlist; int idx = 0; - int i = 0; - DdbListviewIter it = ps->binding->head (); + int i = 1; + DdbListviewIter it = deadbeef->plt_get_head (ps->drag_source_playlist); for (; it; idx++) { if (ps->binding->is_selected (it)) { ptr[i] = idx; @@ -845,7 +846,7 @@ ddb_listview_list_drag_data_get (GtkWidget *widget, ps->binding->unref (it); it = next; } - gtk_selection_data_set (selection_data, selection_data->target, sizeof (uint32_t) * 8, (gchar *)ptr, nsel * sizeof (uint32_t)); + gtk_selection_data_set (selection_data, selection_data->target, sizeof (uint32_t) * 8, (gchar *)ptr, (nsel+1) * sizeof (uint32_t)); free (ptr); } break; @@ -894,7 +895,9 @@ ddb_listview_list_drag_data_received (GtkWidget *widget, } else if (target_type == 1) { uint32_t *d= (uint32_t *)ptr; - int length = data->length/4; + int plt = *d; + d++; + int length = (data->length/4)-1; DdbListviewIter drop_before = it; // find last selected while (drop_before && ps->binding->is_selected (drop_before)) { @@ -902,7 +905,7 @@ ddb_listview_list_drag_data_received (GtkWidget *widget, UNREF (drop_before); drop_before = next; } - ps->binding->drag_n_drop (drop_before, d, length); + ps->binding->drag_n_drop (drop_before, plt, d, length); if (drop_before) { UNREF (drop_before); } @@ -1561,6 +1564,7 @@ ddb_listview_list_mousemove (DdbListview *ps, GdkEventMotion *ev, int ex, int ey GtkWidget *widget = ps->list; if (gtk_drag_check_threshold (widget, ps->lastpos[0], ex, ps->lastpos[1], ey)) { ps->dragwait = 0; + ps->drag_source_playlist = deadbeef->plt_get_curr (); GtkTargetEntry entry = { .target = "STRING", .flags = GTK_TARGET_SAME_WIDGET, diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h index eb103354..cdf7517f 100644 --- a/plugins/gtkui/ddblistview.h +++ b/plugins/gtkui/ddblistview.h @@ -68,7 +68,7 @@ typedef struct { int (*get_group) (DdbListviewIter it, char *str, int size); // drag-n-drop - void (*drag_n_drop) (DdbListviewIter before, uint32_t *indices, int length); + void (*drag_n_drop) (DdbListviewIter before, int playlist, uint32_t *indices, int length); void (*external_drag_n_drop) (DdbListviewIter before, char *mem, int length); // callbacks @@ -128,6 +128,7 @@ struct _DdbListview { int areaselect; // boolean, whether area selection is active (1), or not (0) int areaselect_y; // pixel-coordinate of anchor click relative to playlist origin int dragwait; + int drag_source_playlist; int shift_sel_anchor; // header diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c index de5a3231..8d9b6675 100644 --- a/plugins/gtkui/ddbtabstrip.c +++ b/plugins/gtkui/ddbtabstrip.c @@ -16,6 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include "ddbtabstrip.h" #include "drawing.h" @@ -28,58 +29,65 @@ G_DEFINE_TYPE (DdbTabStrip, ddb_tabstrip, GTK_TYPE_WIDGET); static void ddb_tabstrip_send_configure (DdbTabStrip *darea) { - GtkWidget *widget; - GdkEvent *event = gdk_event_new (GDK_CONFIGURE); - - widget = GTK_WIDGET (darea); - - event->configure.window = g_object_ref (widget->window); - event->configure.send_event = TRUE; - event->configure.x = widget->allocation.x; - event->configure.y = widget->allocation.y; - event->configure.width = widget->allocation.width; - event->configure.height = widget->allocation.height; - - gtk_widget_event (widget, event); - gdk_event_free (event); + GtkWidget *widget; + GdkEvent *event = gdk_event_new (GDK_CONFIGURE); + + widget = GTK_WIDGET (darea); + + event->configure.window = g_object_ref (widget->window); + event->configure.send_event = TRUE; + event->configure.x = widget->allocation.x; + event->configure.y = widget->allocation.y; + event->configure.width = widget->allocation.width; + event->configure.height = widget->allocation.height; + + gtk_widget_event (widget, event); + gdk_event_free (event); } static void ddb_tabstrip_realize (GtkWidget *widget) { - DdbTabStrip *darea = DDB_TABSTRIP (widget); - GdkWindowAttr attributes; - gint attributes_mask; + DdbTabStrip *darea = DDB_TABSTRIP (widget); + GdkWindowAttr attributes; + gint attributes_mask; - if (GTK_WIDGET_NO_WINDOW (widget)) + if (GTK_WIDGET_NO_WINDOW (widget)) { - GTK_WIDGET_CLASS (ddb_tabstrip_parent_class)->realize (widget); + GTK_WIDGET_CLASS (ddb_tabstrip_parent_class)->realize (widget); } - else + else { - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, darea); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + + attributes.window_type = GDK_WINDOW_CHILD; + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.visual = gtk_widget_get_visual (widget); + attributes.colormap = gtk_widget_get_colormap (widget); + attributes.event_mask = gtk_widget_get_events (widget); + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gdk_window_set_user_data (widget->window, darea); + + widget->style = gtk_style_attach (widget->style, widget->window); + gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); } - ddb_tabstrip_send_configure (DDB_TABSTRIP (widget)); + ddb_tabstrip_send_configure (DDB_TABSTRIP (widget)); + GtkTargetEntry entry = { + .target = "STRING", + .flags = GTK_TARGET_SAME_WIDGET | GTK_TARGET_OTHER_APP, + 0 + }; + gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY); + gtk_drag_dest_set_track_motion (widget, TRUE); } static void @@ -122,6 +130,13 @@ gboolean on_tabstrip_motion_notify_event (GtkWidget *widget, GdkEventMotion *event); +gboolean +on_tabstrip_drag_motion_event (GtkWidget *widget, + GdkDragContext *drag_context, + gint x, + gint y, + guint time); + static void ddb_tabstrip_destroy(GtkObject *object) { @@ -156,6 +171,7 @@ ddb_tabstrip_class_init(DdbTabStripClass *class) widget_class->button_release_event = on_tabstrip_button_release_event; widget_class->configure_event = on_tabstrip_configure_event; widget_class->motion_notify_event = on_tabstrip_motion_notify_event; + widget_class->drag_motion = on_tabstrip_drag_motion_event; object_class->destroy = ddb_tabstrip_destroy; } @@ -553,6 +569,21 @@ on_tabstrip_motion_notify_event (GtkWidget *widget, return FALSE; } +gboolean +on_tabstrip_drag_motion_event (GtkWidget *widget, + GdkDragContext *drag_context, + gint x, + gint y, + guint time) +{ + int tab = get_tab_under_cursor (x); + if (tab != -1) { + deadbeef->plt_set_curr (tab); + deadbeef->conf_set_int ("playlist.current", tab); + } + return FALSE; +} + void on_rename_playlist1_activate (GtkMenuItem *menuitem, gpointer user_data) diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c index 1815d0aa..4e8ddd93 100644 --- a/plugins/gtkui/mainplaylist.c +++ b/plugins/gtkui/mainplaylist.c @@ -98,8 +98,16 @@ int main_get_idx (DdbListviewIter it) { return idx; } -void main_drag_n_drop (DdbListviewIter before, uint32_t *indices, int length) { - deadbeef->pl_move_items (PL_MAIN, (DB_playItem_t *)before, indices, length); +void main_drag_n_drop (DdbListviewIter before, int playlist, uint32_t *indices, int length) { + deadbeef->plt_lock (); + int curr = deadbeef->plt_get_curr (); + if (playlist == curr) { + deadbeef->pl_move_items (PL_MAIN, (DB_playItem_t *)before, indices, length); + } + else { + deadbeef->pl_copy_items (PL_MAIN, playlist, (DB_playItem_t *)before, indices, length); + } + deadbeef->plt_unlock (); } void main_external_drag_n_drop (DdbListviewIter before, char *mem, int length) { -- cgit v1.2.3 From 251bfdb90e02170019366eacf8eb295350a4bdc4 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 4 Apr 2010 15:58:18 +0200 Subject: added fetching artwork from id3v2 tags --- plugins/artwork/artwork.c | 184 ++++++++++++++++++++++++++++++++++++++-------- plugins/gtkui/plcommon.c | 3 + 2 files changed, 155 insertions(+), 32 deletions(-) (limited to 'plugins/gtkui') diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c index 2a288cbc..b11df44e 100644 --- a/plugins/artwork/artwork.c +++ b/plugins/artwork/artwork.c @@ -269,6 +269,46 @@ filter_jpg (const struct dirent *f) return 0; } +static int +is_local_file (const char *fname) { + if (!strncasecmp (fname, "file://", 7)) { + return 1; + } + for (; *fname; fname++) { + if (!strncmp (fname, "://", 3)) { + return 0; + } + } + + return 1; +} + +static uint8_t * +id3v2_skip_str (int enc, uint8_t *ptr, uint8_t *end) { + if (enc == 0 || enc == 3) { + while (ptr < end && *ptr) { + ptr++; + } + ptr++; + if (ptr >= end) { + return NULL; + } + return ptr; + } + else { + while (ptr < end-1 && (ptr[0] || ptr[1])) { + ptr++; + } + ptr += 2; + if (ptr >= end) { + return NULL; + } + return ptr; + } + return NULL; +} + + static void fetcher_thread (void *none) { @@ -292,39 +332,116 @@ fetcher_thread (void *none) } trace ("fetching cover for %s %s\n", param->album, param->artist); - /* Searching in track directory */ - strncpy (path, param->fname, sizeof (path)); - char *slash = strrchr (path, '/'); - if (slash) { - *slash = 0; // assuming at least one slash exist - } - trace ("scanning directory: %s\n", path); - files_count = scandir (path, &files, filter_jpg, alphasort); - - if (files_count > 0) { - trace ("found cover for %s - %s in local folder\n", param->artist, param->album); - if (check_dir (path, 0755)) { - strcat (path, "/"); - strcat (path, files[0]->d_name); - char cache_path[1024]; - char tmp_path[1024]; - make_cache_path (cache_path, sizeof (cache_path), param->album, param->artist); - snprintf (tmp_path, sizeof (tmp_path), "%s.part", cache_path); - copy_file (path, tmp_path); - int err = rename (tmp_path, cache_path); - if (err != 0) { - trace ("Failed not move %s to %s: %s\n", tmp_path, cache_path, strerror (err)); - unlink (tmp_path); + + // try to load embedded from id3v2 + if (is_local_file (param->fname)) { + trace ("trying to load artwork from id3v2 tag for %s\n", param->fname); + DB_id3v2_tag_t tag; + memset (&tag, 0, sizeof (tag)); + DB_FILE *fp = deadbeef->fopen (param->fname); + int got_id3v2_pic = 0; + if (fp) { + int res = deadbeef->junk_id3v2_read_full (NULL, &tag, fp); + if (!res) { + for (DB_id3v2_frame_t *f = tag.frames; f; f = f->next) { + if (!strcmp (f->id, "APIC")) { + + if (f->size < 20) { + trace ("artwork: id3v2 APIC frame is too small\n"); + continue; + } + uint8_t *data = f->data; + uint8_t *end = f->data + f->size; + int enc = *data; + data++; // enc + data = id3v2_skip_str (enc, data, end); // mime-type + if (!data) { + trace ("artwork: corrupted id3v2 APIC frame\n"); + continue; + } + data++; // picture type + data = id3v2_skip_str (enc, data, end); // description + if (!data) { + trace ("artwork: corrupted id3v2 APIC frame\n"); + continue; + } + int sz = f->size - (data - f->data); + + char tmp_path[1024]; + char cache_path[1024]; + make_cache_path (cache_path, sizeof (cache_path), param->album, param->artist); + trace ("will write id3v2 APIC into %s\n", cache_path); + snprintf (tmp_path, sizeof (tmp_path), "%s.part", cache_path); + FILE *out = fopen (tmp_path, "w+b"); + if (!out) { + trace ("artwork: failed to open %s for writing\n", tmp_path); + break; + } + if (fwrite (data, 1, sz, out) != sz) { + trace ("artwork: failed to write id3v2 picture into %s\n", tmp_path); + fclose (out); + unlink (tmp_path); + break; + } + fclose (out); + int err = rename (tmp_path, cache_path); + if (err != 0) { + trace ("Failed not move %s to %s: %s\n", tmp_path, cache_path, strerror (err)); + unlink (tmp_path); + break; + } + unlink (tmp_path); + got_id3v2_pic = 1; + break; + } + } } - int i; - for (i = 0; i < files_count; i++) { - free (files [i]); + + if (got_id3v2_pic) { + if (param->callback) { + param->callback (param->fname, param->artist, param->album, param->user_data); + } + queue_pop (); + continue; } - if (param->callback) { - param->callback (param->fname, param->artist, param->album, param->user_data); + deadbeef->junk_id3v2_free (&tag); + deadbeef->fclose (fp); + } + + /* Searching in track directory */ + strncpy (path, param->fname, sizeof (path)); + char *slash = strrchr (path, '/'); + if (slash) { + *slash = 0; // assuming at least one slash exist + } + trace ("scanning directory: %s\n", path); + files_count = scandir (path, &files, filter_jpg, alphasort); + + if (files_count > 0) { + trace ("found cover for %s - %s in local folder\n", param->artist, param->album); + if (check_dir (path, 0755)) { + strcat (path, "/"); + strcat (path, files[0]->d_name); + char cache_path[1024]; + char tmp_path[1024]; + make_cache_path (cache_path, sizeof (cache_path), param->album, param->artist); + snprintf (tmp_path, sizeof (tmp_path), "%s.part", cache_path); + copy_file (path, tmp_path); + int err = rename (tmp_path, cache_path); + if (err != 0) { + trace ("Failed not move %s to %s: %s\n", tmp_path, cache_path, strerror (err)); + unlink (tmp_path); + } + int i; + for (i = 0; i < files_count; i++) { + free (files [i]); + } + if (param->callback) { + param->callback (param->fname, param->artist, param->album, param->user_data); + } + queue_pop (); + continue; } - queue_pop (); - continue; } } @@ -371,6 +488,7 @@ fetcher_thread (void *none) char* get_album_art (const char *fname, const char *artist, const char *album, artwork_callback callback, void *user_data) { + trace ("get_album_art: %s (%s - %s)\n", fname, artist, album); char path [1024]; if (!album) { @@ -379,15 +497,17 @@ get_album_art (const char *fname, const char *artist, const char *album, artwork if (!artist) { artist = ""; } -// trace ("looking for %s - %s\n", artist, album); - /* Searching in cache */ if (!*artist || !*album) { //give up return strdup (DEFAULT_COVER_PATH); } + if (!is_local_file (fname)) { + return strdup (DEFAULT_COVER_PATH); + } + make_cache_path (path, sizeof (path), album, artist); struct stat stat_buf; if (0 == stat (path, &stat_buf)) { diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c index 006234c8..79ca1994 100644 --- a/plugins/gtkui/plcommon.c +++ b/plugins/gtkui/plcommon.c @@ -109,6 +109,9 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview // gdk_draw_rectangle (drawable, GTK_WIDGET (listview)->style->white_gc, TRUE, x, y, width, h); const char *album = deadbeef->pl_find_meta (group_it, "album"); const char *artist = deadbeef->pl_find_meta (group_it, "artist"); + if (!album || !*album) { + album = deadbeef->pl_find_meta (group_it, "title"); + } GdkPixbuf *pixbuf = get_cover_art (((DB_playItem_t *)group_it)->fname, artist, album, art_width); if (pixbuf) { int pw = gdk_pixbuf_get_width (pixbuf); -- cgit v1.2.3