diff --git a/plugins/gtkui/ddbseekbar.c b/plugins/gtkui/ddbseekbar.c index 79d86ca8c6..fdd23d791b 100644 --- a/plugins/gtkui/ddbseekbar.c +++ b/plugins/gtkui/ddbseekbar.c @@ -40,28 +40,38 @@ static gpointer ddb_seekbar_parent_class = NULL; -GType ddb_seekbar_get_type (void); -enum { - DDB_SEEKBAR_DUMMY_PROPERTY -}; -#if GTK_CHECK_VERSION(3,0,0) -static void ddb_seekbar_get_preferred_width (GtkWidget* base, gint *minimal_width, gint *natural_width); -static void ddb_seekbar_get_preferred_height (GtkWidget* base, gint *minimal_height, gint *natural_height); +GType +ddb_seekbar_get_type (void); +enum { DDB_SEEKBAR_DUMMY_PROPERTY }; +#if GTK_CHECK_VERSION(3, 0, 0) +static void +ddb_seekbar_get_preferred_width (GtkWidget *base, gint *minimal_width, gint *natural_width); +static void +ddb_seekbar_get_preferred_height (GtkWidget *base, gint *minimal_height, gint *natural_height); #else -static gboolean ddb_seekbar_real_expose_event (GtkWidget* base, GdkEventExpose* event); +static gboolean +ddb_seekbar_real_expose_event (GtkWidget *base, GdkEventExpose *event); #endif -static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requisition); -static gboolean ddb_seekbar_real_draw (GtkWidget* base, cairo_t *cr); -static gboolean ddb_seekbar_real_button_press_event (GtkWidget* base, GdkEventButton* event); -static gboolean ddb_seekbar_real_button_release_event (GtkWidget* base, GdkEventButton* event); -static gboolean ddb_seekbar_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event); -static gboolean ddb_seekbar_real_configure_event (GtkWidget* base, GdkEventConfigure* event); -DdbSeekbar* ddb_seekbar_construct (GType object_type); -static GObject * ddb_seekbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); - - -#if GTK_CHECK_VERSION(3,0,0) -static void ddb_seekbar_get_preferred_width (GtkWidget* widget, gint *minimal_width, gint *natural_width) { +static void +ddb_seekbar_real_size_request (GtkWidget *base, GtkRequisition *requisition); +static gboolean +ddb_seekbar_real_draw (GtkWidget *base, cairo_t *cr); +static gboolean +ddb_seekbar_real_button_press_event (GtkWidget *base, GdkEventButton *event); +static gboolean +ddb_seekbar_real_button_release_event (GtkWidget *base, GdkEventButton *event); +static gboolean +ddb_seekbar_real_motion_notify_event (GtkWidget *base, GdkEventMotion *event); +static gboolean +ddb_seekbar_real_configure_event (GtkWidget *base, GdkEventConfigure *event); +DdbSeekbar * +ddb_seekbar_construct (GType object_type); +static GObject * +ddb_seekbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties); + +#if GTK_CHECK_VERSION(3, 0, 0) +static void +ddb_seekbar_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width) { GtkRequisition requisition; ddb_seekbar_real_size_request (widget, &requisition); @@ -69,7 +79,8 @@ static void ddb_seekbar_get_preferred_width (GtkWidget* widget, gint *minimal_wi *minimal_width = *natural_width = requisition.width; } -static void ddb_seekbar_get_preferred_height (GtkWidget* widget, gint *minimal_height, gint *natural_height) { +static void +ddb_seekbar_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height) { GtkRequisition requisition; ddb_seekbar_real_size_request (widget, &requisition); @@ -78,75 +89,79 @@ static void ddb_seekbar_get_preferred_height (GtkWidget* widget, gint *minimal_h } #endif -static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requisition) { - GtkRequisition _vala_requisition = {0}; - if (requisition) { - *requisition = _vala_requisition; - } +static void +ddb_seekbar_real_size_request (GtkWidget *base, GtkRequisition *requisition) { + GtkRequisition _vala_requisition = { 0 }; + if (requisition) { + *requisition = _vala_requisition; + } } -static gboolean ddb_seekbar_real_draw (GtkWidget* base, cairo_t *cr) { - seekbar_draw (base, cr); - return FALSE; +static gboolean +ddb_seekbar_real_draw (GtkWidget *base, cairo_t *cr) { + seekbar_draw (base, cr); + return FALSE; } -#if !GTK_CHECK_VERSION(3,0,0) -static gboolean ddb_seekbar_real_expose_event (GtkWidget* base, GdkEventExpose* event) { +#if !GTK_CHECK_VERSION(3, 0, 0) +static gboolean +ddb_seekbar_real_expose_event (GtkWidget *base, GdkEventExpose *event) { cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (base)); ddb_seekbar_real_draw (base, cr); cairo_destroy (cr); - return FALSE; + return FALSE; } #endif -static gboolean ddb_seekbar_real_button_press_event (GtkWidget* base, GdkEventButton* event) { - DdbSeekbar * self; - gboolean result = FALSE; - GdkEventButton _tmp0_; - gboolean _tmp1_ = FALSE; - self = (DdbSeekbar*) base; - g_return_val_if_fail (event != NULL, FALSE); - _tmp0_ = *event; - _tmp1_ = on_seekbar_button_press_event ((GtkWidget*) self, &_tmp0_); - result = _tmp1_; - return result; +static gboolean +ddb_seekbar_real_button_press_event (GtkWidget *base, GdkEventButton *event) { + DdbSeekbar *self; + gboolean result = FALSE; + GdkEventButton _tmp0_; + gboolean _tmp1_ = FALSE; + self = (DdbSeekbar *)base; + g_return_val_if_fail (event != NULL, FALSE); + _tmp0_ = *event; + _tmp1_ = on_seekbar_button_press_event ((GtkWidget *)self, &_tmp0_); + result = _tmp1_; + return result; } - -static gboolean ddb_seekbar_real_button_release_event (GtkWidget* base, GdkEventButton* event) { - DdbSeekbar * self; - gboolean result = FALSE; - GdkEventButton _tmp0_; - gboolean _tmp1_ = FALSE; - self = (DdbSeekbar*) base; - g_return_val_if_fail (event != NULL, FALSE); - _tmp0_ = *event; - _tmp1_ = on_seekbar_button_release_event ((GtkWidget*) self, &_tmp0_); - result = _tmp1_; - return result; +static gboolean +ddb_seekbar_real_button_release_event (GtkWidget *base, GdkEventButton *event) { + DdbSeekbar *self; + gboolean result = FALSE; + GdkEventButton _tmp0_; + gboolean _tmp1_ = FALSE; + self = (DdbSeekbar *)base; + g_return_val_if_fail (event != NULL, FALSE); + _tmp0_ = *event; + _tmp1_ = on_seekbar_button_release_event ((GtkWidget *)self, &_tmp0_); + result = _tmp1_; + return result; } - -static gboolean ddb_seekbar_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) { - DdbSeekbar * self; - gboolean result = FALSE; - GdkEventMotion _tmp0_; - gboolean _tmp1_ = FALSE; - self = (DdbSeekbar*) base; - g_return_val_if_fail (event != NULL, FALSE); - _tmp0_ = *event; - _tmp1_ = on_seekbar_motion_notify_event ((GtkWidget*) self, &_tmp0_); - result = _tmp1_; - return result; +static gboolean +ddb_seekbar_real_motion_notify_event (GtkWidget *base, GdkEventMotion *event) { + DdbSeekbar *self; + gboolean result = FALSE; + GdkEventMotion _tmp0_; + gboolean _tmp1_ = FALSE; + self = (DdbSeekbar *)base; + g_return_val_if_fail (event != NULL, FALSE); + _tmp0_ = *event; + _tmp1_ = on_seekbar_motion_notify_event ((GtkWidget *)self, &_tmp0_); + result = _tmp1_; + return result; } - -static gboolean ddb_seekbar_real_configure_event (GtkWidget* base, GdkEventConfigure* event) { - gboolean result = FALSE; - g_return_val_if_fail (event != NULL, FALSE); - gtkui_init_theme_colors (); - result = FALSE; - return result; +static gboolean +ddb_seekbar_real_configure_event (GtkWidget *base, GdkEventConfigure *event) { + gboolean result = FALSE; + g_return_val_if_fail (event != NULL, FALSE); + gtkui_init_theme_colors (); + result = FALSE; + return result; } static int @@ -157,7 +172,8 @@ seek_sec (float sec) { return 0; } -static gboolean ddb_seekbar_scroll_event(GtkWidget *widget, GdkEventScroll *event) { +static gboolean +ddb_seekbar_scroll_event (GtkWidget *widget, GdkEventScroll *event) { if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_RIGHT) { seek_sec (5.0f); @@ -169,85 +185,109 @@ static gboolean ddb_seekbar_scroll_event(GtkWidget *widget, GdkEventScroll *even return FALSE; } -DdbSeekbar* ddb_seekbar_construct (GType object_type) { - DdbSeekbar * self; - self = g_object_newv (object_type, 0, NULL); - return self; +DdbSeekbar * +ddb_seekbar_construct (GType object_type) { + DdbSeekbar *self; + self = g_object_newv (object_type, 0, NULL); + return self; } +GtkWidget * +ddb_seekbar_new (void) { + return GTK_WIDGET (ddb_seekbar_construct (DDB_TYPE_SEEKBAR)); +} -GtkWidget* ddb_seekbar_new (void) { - return GTK_WIDGET (ddb_seekbar_construct (DDB_TYPE_SEEKBAR)); +static GObject * +ddb_seekbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { + GObject *obj; + GObjectClass *parent_class; + parent_class = G_OBJECT_CLASS (ddb_seekbar_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + return obj; } +static void +ddb_seekbar_realize (GtkWidget *w) { + GTK_WIDGET_CLASS (ddb_seekbar_parent_class)->realize (w); -static GObject * ddb_seekbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { - GObject * obj; - GObjectClass * parent_class; - parent_class = G_OBJECT_CLASS (ddb_seekbar_parent_class); - obj = parent_class->constructor (type, n_construct_properties, construct_properties); - return obj; + DdbSeekbar *self = DDB_SEEKBAR (w); + drawctx_init (&self->drawctx); + draw_init_font (&self->drawctx, DDB_SEEKBAR_FONT, 0); } +static void +ddb_seekbar_unrealize (GtkWidget *w) { + GTK_WIDGET_CLASS (ddb_seekbar_parent_class)->unrealize (w); + DdbSeekbar *self = DDB_SEEKBAR (w); + draw_free (&self->drawctx); +} -static void ddb_seekbar_class_init (DdbSeekbarClass * klass) { - ddb_seekbar_parent_class = g_type_class_peek_parent (klass); -#if GTK_CHECK_VERSION(3,0,0) - GTK_WIDGET_CLASS (klass)->get_preferred_width = ddb_seekbar_get_preferred_width; - GTK_WIDGET_CLASS (klass)->get_preferred_height = ddb_seekbar_get_preferred_height; - GTK_WIDGET_CLASS (klass)->draw = ddb_seekbar_real_draw; +static void +ddb_seekbar_class_init (DdbSeekbarClass *klass) { + ddb_seekbar_parent_class = g_type_class_peek_parent (klass); +#if GTK_CHECK_VERSION(3, 0, 0) + GTK_WIDGET_CLASS (klass)->get_preferred_width = ddb_seekbar_get_preferred_width; + GTK_WIDGET_CLASS (klass)->get_preferred_height = ddb_seekbar_get_preferred_height; + GTK_WIDGET_CLASS (klass)->draw = ddb_seekbar_real_draw; #else - GTK_WIDGET_CLASS (klass)->size_request = ddb_seekbar_real_size_request; - GTK_WIDGET_CLASS (klass)->expose_event = ddb_seekbar_real_expose_event; + GTK_WIDGET_CLASS (klass)->size_request = ddb_seekbar_real_size_request; + GTK_WIDGET_CLASS (klass)->expose_event = ddb_seekbar_real_expose_event; #endif - GTK_WIDGET_CLASS (klass)->button_press_event = ddb_seekbar_real_button_press_event; - GTK_WIDGET_CLASS (klass)->button_release_event = ddb_seekbar_real_button_release_event; - GTK_WIDGET_CLASS (klass)->motion_notify_event = ddb_seekbar_real_motion_notify_event; - GTK_WIDGET_CLASS (klass)->configure_event = ddb_seekbar_real_configure_event; + GTK_WIDGET_CLASS (klass)->realize = ddb_seekbar_realize; + GTK_WIDGET_CLASS (klass)->unrealize = ddb_seekbar_unrealize; + GTK_WIDGET_CLASS (klass)->button_press_event = ddb_seekbar_real_button_press_event; + GTK_WIDGET_CLASS (klass)->button_release_event = ddb_seekbar_real_button_release_event; + GTK_WIDGET_CLASS (klass)->motion_notify_event = ddb_seekbar_real_motion_notify_event; + GTK_WIDGET_CLASS (klass)->configure_event = ddb_seekbar_real_configure_event; GTK_WIDGET_CLASS (klass)->scroll_event = ddb_seekbar_scroll_event; - G_OBJECT_CLASS (klass)->constructor = ddb_seekbar_constructor; + G_OBJECT_CLASS (klass)->constructor = ddb_seekbar_constructor; } - -static void ddb_seekbar_instance_init (DdbSeekbar * self) { - gtk_widget_set_has_window ((GtkWidget*) self, FALSE); - gtk_widget_set_has_tooltip ((GtkWidget*) self, TRUE); - self->seekbar_moving = 0; +static void +ddb_seekbar_instance_init (DdbSeekbar *self) { + gtk_widget_set_has_window ((GtkWidget *)self, FALSE); + gtk_widget_set_has_tooltip ((GtkWidget *)self, TRUE); + self->seekbar_moving = 0; self->seekbar_move_x = 0; } - -GType ddb_seekbar_get_type (void) { - static volatile gsize ddb_seekbar_type_id__volatile = 0; - if (g_once_init_enter ((gsize *)(&ddb_seekbar_type_id__volatile))) { - static const GTypeInfo g_define_type_info = { sizeof (DdbSeekbarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ddb_seekbar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DdbSeekbar), 0, (GInstanceInitFunc) ddb_seekbar_instance_init, NULL }; - GType ddb_seekbar_type_id; - ddb_seekbar_type_id = g_type_register_static (GTK_TYPE_WIDGET, "DdbSeekbar", &g_define_type_info, 0); - g_once_init_leave (&ddb_seekbar_type_id__volatile, ddb_seekbar_type_id); - } - return ddb_seekbar_type_id__volatile; +GType +ddb_seekbar_get_type (void) { + static volatile gsize ddb_seekbar_type_id__volatile = 0; + if (g_once_init_enter ((gsize *)(&ddb_seekbar_type_id__volatile))) { + static const GTypeInfo g_define_type_info = { sizeof (DdbSeekbarClass), + (GBaseInitFunc)NULL, + (GBaseFinalizeFunc)NULL, + (GClassInitFunc)ddb_seekbar_class_init, + (GClassFinalizeFunc)NULL, + NULL, + sizeof (DdbSeekbar), + 0, + (GInstanceInitFunc)ddb_seekbar_instance_init, + NULL }; + GType ddb_seekbar_type_id; + ddb_seekbar_type_id = g_type_register_static (GTK_TYPE_WIDGET, "DdbSeekbar", &g_define_type_info, 0); + g_once_init_leave (&ddb_seekbar_type_id__volatile, ddb_seekbar_type_id); + } + return ddb_seekbar_type_id__volatile; } -enum -{ - CORNER_NONE = 0, - CORNER_TOPLEFT = 1, - CORNER_TOPRIGHT = 2, - CORNER_BOTTOMLEFT = 4, - CORNER_BOTTOMRIGHT = 8, - CORNER_ALL = 15 +enum { + CORNER_NONE = 0, + CORNER_TOPLEFT = 1, + CORNER_TOPRIGHT = 2, + CORNER_BOTTOMLEFT = 4, + CORNER_BOTTOMRIGHT = 8, + CORNER_ALL = 15 }; static void -clearlooks_rounded_rectangle (cairo_t * cr, - double x, double y, double w, double h, - double radius, uint8_t corners) -{ +clearlooks_rounded_rectangle (cairo_t *cr, double x, double y, double w, double h, double radius, uint8_t corners) { if (radius < 0.01 || (corners == CORNER_NONE)) { cairo_rectangle (cr, x, y, w, h); return; } - + if (corners & CORNER_TOPLEFT) cairo_move_to (cr, x + radius, y); else @@ -272,7 +312,6 @@ clearlooks_rounded_rectangle (cairo_t * cr, cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5); else cairo_line_to (cr, x, y); - } void @@ -283,7 +322,7 @@ seekbar_draw (GtkWidget *widget, cairo_t *cr) { DdbSeekbar *self = DDB_SEEKBAR (widget); -#if GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3, 0, 0) GtkAllocation allocation; gtk_widget_get_allocation (widget, &allocation); cairo_translate (cr, -allocation.x, -allocation.y); @@ -310,8 +349,8 @@ seekbar_draw (GtkWidget *widget, cairo_t *cr) { if (x < 0) { x = 0; } - if (x > a.width-1) { - x = a.width-1; + if (x > a.width - 1) { + x = a.width - 1; } pos = x; } @@ -323,18 +362,22 @@ seekbar_draw (GtkWidget *widget, cairo_t *cr) { } // left if (pos > 0) { - cairo_set_source_rgb (cr, clr_selection.red/65535.f, clr_selection.green/65535.f, clr_selection.blue/65535.f ); - cairo_rectangle (cr, ax, ah/2-4+ay, pos, 8); + cairo_set_source_rgb ( + cr, + clr_selection.red / 65535.f, + clr_selection.green / 65535.f, + clr_selection.blue / 65535.f); + cairo_rectangle (cr, ax, ah / 2 - 4 + ay, pos, 8); cairo_clip (cr); - clearlooks_rounded_rectangle (cr, 2+ax, ah/2-4+ay, aw-4, 8, 4, 0xff); + clearlooks_rounded_rectangle (cr, 2 + ax, ah / 2 - 4 + ay, aw - 4, 8, 4, 0xff); cairo_fill (cr); cairo_reset_clip (cr); } } // empty seekbar, just a frame, always visible - clearlooks_rounded_rectangle (cr, 2+ax, a.height/2-4+ay, aw-4, 8, 4, 0xff); - cairo_set_source_rgb (cr, clr_selection.red/65535.f, clr_selection.green/65535.f, clr_selection.blue/65535.f ); + clearlooks_rounded_rectangle (cr, 2 + ax, a.height / 2 - 4 + ay, aw - 4, 8, 4, 0xff); + cairo_set_source_rgb (cr, clr_selection.red / 65535.f, clr_selection.green / 65535.f, clr_selection.blue / 65535.f); cairo_set_line_width (cr, 2); cairo_stroke (cr); @@ -358,31 +401,55 @@ seekbar_draw (GtkWidget *widget, cairo_t *cr) { time = dur; } char s[1000]; - int hr = time/3600; - int mn = (time-hr*3600)/60; - int sc = time-hr*3600-mn*60; + int hr = time / 3600; + int mn = (time - hr * 3600) / 60; + int sc = time - hr * 3600 - mn * 60; snprintf (s, sizeof (s), "%02d:%02d:%02d", hr, mn, sc); - cairo_set_source_rgba (cr, clr_selection.red/65535.f, clr_selection.green/65535.f, clr_selection.blue/65535.f, self->seektime_alpha); - cairo_save (cr); - cairo_set_font_size (cr, 20); + draw_begin (&self->drawctx, cr); + + // overlay extent + + int ew, eh; + draw_get_text_extents (&self->drawctx, s, (int)strlen (s), &ew, &eh); - cairo_text_extents_t ex; - cairo_text_extents (cr, s, &ex); if (self->textpos == -1) { - self->textpos = ax + aw/2 - ex.width/2; - self->textwidth = ex.width + 20; + self->textpos = ax + aw / 2 - ew / 2; + self->textwidth = ew + 20; } - clearlooks_rounded_rectangle (cr, ax + aw/2 - self->textwidth/2, ay+4, self->textwidth, ah-8, 3, 0xff); + // overlay background + + cairo_set_source_rgba ( + cr, + clr_selection.red / 65535.f, + clr_selection.green / 65535.f, + clr_selection.blue / 65535.f, + self->seektime_alpha); + cairo_save (cr); + + clearlooks_rounded_rectangle ( + cr, + ax + aw / 2 - self->textwidth / 2, + ay + 4, + self->textwidth, + ah - 8, + 3, + 0xff); cairo_fill (cr); + cairo_restore (cr); + + // overlay foreground - cairo_move_to (cr, self->textpos, ay+ah/2+ex.height/2); GdkColor clr; gtkui_get_listview_selected_text_color (&clr); - cairo_set_source_rgba (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f, self->seektime_alpha); - cairo_show_text (cr, s); - cairo_restore (cr); + + float text_color[3] = { (float)clr.red / 0xffff, (float)clr.green / 0xffff, (float)clr.blue / 0xffff }; + + draw_set_fg_color (&self->drawctx, text_color); + draw_text_custom (&self->drawctx, self->textpos, ay + ah / 2 - eh / 2, ew, 0, 0, 0, 0, s); + + draw_end (&self->drawctx); int fps = deadbeef->conf_get_int ("gtkui.refresh_rate", 10); if (fps < 1) { @@ -392,7 +459,7 @@ seekbar_draw (GtkWidget *widget, cairo_t *cr) { fps = 30; } if (self->seekbar_moved >= 0.0) { - self->seekbar_moved -= 1.0/fps; + self->seekbar_moved -= 1.0 / fps; } else { self->seekbar_moved = 0.0; @@ -406,9 +473,7 @@ seekbar_draw (GtkWidget *widget, cairo_t *cr) { } gboolean -on_seekbar_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event) -{ +on_seekbar_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { DdbSeekbar *self = DDB_SEEKBAR (widget); if (self->seekbar_moving) { GtkAllocation a; @@ -420,9 +485,7 @@ on_seekbar_motion_notify_event (GtkWidget *widget, } gboolean -on_seekbar_button_press_event (GtkWidget *widget, - GdkEventButton *event) -{ +on_seekbar_button_press_event (GtkWidget *widget, GdkEventButton *event) { DdbSeekbar *self = DDB_SEEKBAR (widget); if (deadbeef->get_output ()->state () == DDB_PLAYBACK_STATE_STOPPED) { return FALSE; @@ -439,11 +502,8 @@ on_seekbar_button_press_event (GtkWidget *widget, return FALSE; } - gboolean -on_seekbar_button_release_event (GtkWidget *widget, - GdkEventButton *event) -{ +on_seekbar_button_release_event (GtkWidget *widget, GdkEventButton *event) { DdbSeekbar *self = DDB_SEEKBAR (widget); self->seekbar_moving = 0; self->seekbar_moved = 1.0; @@ -465,49 +525,29 @@ on_seekbar_button_release_event (GtkWidget *widget, } static gboolean -on_evbox_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ +on_evbox_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { return gtk_widget_event (GTK_WIDGET (user_data), (GdkEvent *)event); } static gboolean -on_evbox_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ +on_evbox_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { return gtk_widget_event (GTK_WIDGET (user_data), (GdkEvent *)event); } static gboolean -on_evbox_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event, - gpointer user_data) -{ +on_evbox_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { return gtk_widget_event (GTK_WIDGET (user_data), (GdkEvent *)event); } static gboolean -on_evbox_scroll_event (GtkWidget *widget, - GdkEvent *event, - gpointer user_data) { +on_evbox_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { return gtk_widget_event (GTK_WIDGET (user_data), (GdkEvent *)event); } void ddb_seekbar_init_signals (DdbSeekbar *sb, GtkWidget *evbox) { - g_signal_connect ((gpointer) evbox, "button_press_event", - G_CALLBACK (on_evbox_button_press_event), - sb); - g_signal_connect ((gpointer) evbox, "button_release_event", - G_CALLBACK (on_evbox_button_release_event), - sb); - g_signal_connect ((gpointer) evbox, "scroll_event", - G_CALLBACK (on_evbox_scroll_event), - sb); - g_signal_connect ((gpointer) evbox, "motion_notify_event", - G_CALLBACK (on_evbox_motion_notify_event), - sb); + g_signal_connect ((gpointer)evbox, "button_press_event", G_CALLBACK (on_evbox_button_press_event), sb); + g_signal_connect ((gpointer)evbox, "button_release_event", G_CALLBACK (on_evbox_button_release_event), sb); + g_signal_connect ((gpointer)evbox, "scroll_event", G_CALLBACK (on_evbox_scroll_event), sb); + g_signal_connect ((gpointer)evbox, "motion_notify_event", G_CALLBACK (on_evbox_motion_notify_event), sb); } - diff --git a/plugins/gtkui/ddbseekbar.h b/plugins/gtkui/ddbseekbar.h index 8b385e0b3e..af4388810c 100644 --- a/plugins/gtkui/ddbseekbar.h +++ b/plugins/gtkui/ddbseekbar.h @@ -26,10 +26,10 @@ #include #include +#include "drawing.h" G_BEGIN_DECLS - #define DDB_TYPE_SEEKBAR (ddb_seekbar_get_type ()) #define DDB_SEEKBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDB_TYPE_SEEKBAR, DdbSeekbar)) #define DDB_SEEKBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DDB_TYPE_SEEKBAR, DdbSeekbarClass)) @@ -42,25 +42,25 @@ typedef struct _DdbSeekbarClass DdbSeekbarClass; typedef struct _DdbSeekbarPrivate DdbSeekbarPrivate; struct _DdbSeekbar { - GtkWidget parent_instance; - DdbSeekbarPrivate * priv; + GtkWidget parent_instance; + DdbSeekbarPrivate *priv; int seekbar_moving; float seekbar_moved; float seektime_alpha; int seekbar_move_x; int textpos; int textwidth; + drawctx_t drawctx; }; struct _DdbSeekbarClass { - GtkWidgetClass parent_class; + GtkWidgetClass parent_class; }; - GType ddb_seekbar_get_type (void); -GtkWidget* +GtkWidget * ddb_seekbar_new (void); void diff --git a/plugins/gtkui/drawing.h b/plugins/gtkui/drawing.h index 6726eab6c0..27a1bd480a 100644 --- a/plugins/gtkui/drawing.h +++ b/plugins/gtkui/drawing.h @@ -45,65 +45,71 @@ enum { DDB_GROUP_FONT = 1, DDB_TABSTRIP_FONT = 2, DDB_COLUMN_FONT = 3, + DDB_SEEKBAR_FONT = 4, }; - void -drawctx_init (drawctx_t * const ctx); +drawctx_init (drawctx_t *const ctx); void -draw_begin (drawctx_t * const ctx, cairo_t *cr); +draw_begin (drawctx_t *const ctx, cairo_t *cr); void -draw_end (drawctx_t * const ctx); +draw_end (drawctx_t *const ctx); void -draw_free (drawctx_t * const ctx); +draw_free (drawctx_t *const ctx); void -draw_set_fg_color (drawctx_t * const ctx, float *rgb); +draw_set_fg_color (drawctx_t *const ctx, float *rgb); void -draw_line (drawctx_t * const ctx, float x1, float y1, float x2, float y2); +draw_line (drawctx_t *const ctx, float x1, float y1, float x2, float y2); void -draw_rect (drawctx_t * const ctx, float x, float y, float w, float h, int fill); +draw_rect (drawctx_t *const ctx, float x, float y, float w, float h, int fill); float -draw_get_font_size (drawctx_t * const ctx); - -void -draw_init_font (drawctx_t * const ctx, int type, int reset); +draw_get_font_size (drawctx_t *const ctx); void -draw_init_font_style (drawctx_t * const ctx, int bold, int italic, int type); +draw_init_font (drawctx_t *const ctx, int type, int reset); void -draw_init_font_normal (drawctx_t * const ctx); +draw_init_font_style (drawctx_t *const ctx, int bold, int italic, int type); void -draw_text (drawctx_t * const ctx, float x, float y, int width, int align, const char *text); +draw_init_font_normal (drawctx_t *const ctx); void -draw_text_custom (drawctx_t * const ctx, float x, float y, int width, int align, int type, int bold, int italic, const char *text); +draw_text_custom ( + drawctx_t *const ctx, + float x, + float y, + int width, + int align, + int type, + int bold, + int italic, + const char *text); void -draw_text_with_colors (drawctx_t * const ctx, float x, float y, int width, int align, const char *text); +draw_text_with_colors (drawctx_t *const ctx, float x, float y, int width, int align, const char *text); void -draw_get_layout_extents (drawctx_t * const ctx, int *w, int *h); +draw_get_layout_extents (drawctx_t *const ctx, int *w, int *h); void -draw_get_text_extents (drawctx_t * const ctx, const char *text, int len, int *w, int *h); +draw_get_text_extents (drawctx_t *const ctx, const char *text, int len, int *w, int *h); int -draw_is_ellipsized (drawctx_t * const ctx); +draw_is_ellipsized (drawctx_t *const ctx); const char * -draw_get_text (drawctx_t * const ctx); +draw_get_text (drawctx_t *const ctx); int -draw_get_listview_rowheight (drawctx_t * const ctx); +draw_get_listview_rowheight (drawctx_t *const ctx); int gtkui_listview_override_conf (const char *conf_str); @@ -198,7 +204,7 @@ gtkui_get_listview_column_text_color (GdkColor *clr); void gtkui_get_listview_cursor_color (GdkColor *clr); -const char* +const char * gtkui_get_listview_text_font (void); const char * @@ -220,6 +226,6 @@ int gtkui_override_tabstrip_colors (void); const char * -gtkui_get_tabstrip_text_font (void); +gtkui_get_tabstrip_text_font (void); #endif // __DRAWING_H diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c index 58d209b04c..c69e3e135c 100644 --- a/plugins/gtkui/gdkdrawing.c +++ b/plugins/gtkui/gdkdrawing.c @@ -22,7 +22,7 @@ */ #ifdef HAVE_CONFIG_H -# include +# include #endif #include @@ -36,83 +36,85 @@ static char gtkui_listview_text_font[1000]; static char gtkui_listview_group_text_font[1000]; static char gtkui_listview_column_text_font[1000]; static char gtkui_tabstrip_text_font[1000]; +static char gtkui_seekbar_text_font[1000]; static GtkWidget *theme_entry; static PangoFontDescription * -get_new_font_description_from_type (int type) -{ +get_new_font_description_from_type (int type) { PangoFontDescription *desc; switch (type) { - case DDB_LIST_FONT: - desc = pango_font_description_from_string (gtkui_listview_text_font); - break; - case DDB_GROUP_FONT: - desc = pango_font_description_from_string (gtkui_listview_group_text_font); - break; - case DDB_TABSTRIP_FONT: - desc = pango_font_description_from_string (gtkui_tabstrip_text_font); - break; - case DDB_COLUMN_FONT: - desc = pango_font_description_from_string (gtkui_listview_column_text_font); - break; - default: - desc = NULL; + case DDB_LIST_FONT: + desc = pango_font_description_from_string (gtkui_listview_text_font); + break; + case DDB_GROUP_FONT: + desc = pango_font_description_from_string (gtkui_listview_group_text_font); + break; + case DDB_TABSTRIP_FONT: + desc = pango_font_description_from_string (gtkui_tabstrip_text_font); + break; + case DDB_COLUMN_FONT: + desc = pango_font_description_from_string (gtkui_listview_column_text_font); + break; + case DDB_SEEKBAR_FONT: + desc = pango_font_description_from_string (gtkui_seekbar_text_font); + break; + default: + desc = NULL; } return desc; } static int -get_pango_alignment (int align) -{ +get_pango_alignment (int align) { int alignment = 0; switch (align) { - case 0: - alignment = PANGO_ALIGN_LEFT; - break; - case 1: - alignment = PANGO_ALIGN_RIGHT; - break; - case 2: - alignment = PANGO_ALIGN_CENTER; - break; - default: - alignment = PANGO_ALIGN_LEFT; - break; + case 0: + alignment = PANGO_ALIGN_LEFT; + break; + case 1: + alignment = PANGO_ALIGN_RIGHT; + break; + case 2: + alignment = PANGO_ALIGN_CENTER; + break; + default: + alignment = PANGO_ALIGN_LEFT; + break; } return alignment; } void -draw_begin (drawctx_t * const ctx, cairo_t *cr) { +draw_begin (drawctx_t *const ctx, cairo_t *cr) { ctx->drawable = cr; } void -draw_end (drawctx_t * const ctx) { +draw_end (drawctx_t *const ctx) { ctx->drawable = NULL; } void -draw_set_fg_color (drawctx_t * const ctx, float *rgb) { +draw_set_fg_color (drawctx_t *const ctx, float *rgb) { cairo_set_source_rgb (ctx->drawable, rgb[0], rgb[1], rgb[2]); } void -draw_line (drawctx_t * const ctx, float x1, float y1, float x2, float y2) { +draw_line (drawctx_t *const ctx, float x1, float y1, float x2, float y2) { cairo_move_to (ctx->drawable, x1, y1); cairo_line_to (ctx->drawable, x2, y2); cairo_stroke (ctx->drawable); } void -draw_rect (drawctx_t * const ctx, float x, float y, float w, float h, int fill) { +draw_rect (drawctx_t *const ctx, float x, float y, float w, float h, int fill) { cairo_rectangle (ctx->drawable, x, y, w, h); fill ? cairo_fill (ctx->drawable) : cairo_stroke (ctx->drawable); } void -draw_free (drawctx_t * const ctx) { +draw_free (drawctx_t *const ctx) { draw_end (ctx); if (ctx->pangoctx) { g_object_unref (ctx->pangoctx); @@ -129,7 +131,7 @@ draw_free (drawctx_t * const ctx) { } void -draw_init_font (drawctx_t * const ctx, int type, int reset) { +draw_init_font (drawctx_t *const ctx, int type, int reset) { if (reset || !ctx->pango_ready) { if (ctx->pangoctx) { g_object_unref (ctx->pangoctx); @@ -165,7 +167,7 @@ draw_init_font (drawctx_t * const ctx, int type, int reset) { } void -draw_init_font_style (drawctx_t * const ctx, int bold, int italic, int type) { +draw_init_font_style (drawctx_t *const ctx, int bold, int italic, int type) { PangoFontDescription *desc_default = ctx->font_style->font_desc; if (desc_default != NULL) { pango_layout_set_font_description (ctx->pangolayout, desc_default); @@ -182,13 +184,13 @@ draw_init_font_style (drawctx_t * const ctx, int bold, int italic, int type) { } void -draw_init_font_normal (drawctx_t * const ctx) { +draw_init_font_normal (drawctx_t *const ctx) { pango_font_description_set_weight (ctx->font_style->font_desc, ctx->font_weight); pango_layout_set_font_description (ctx->pangolayout, ctx->font_style->font_desc); } float -draw_get_font_size (drawctx_t * const ctx) { +draw_get_font_size (drawctx_t *const ctx) { draw_init_font (ctx, 0, 0); GdkScreen *screen = gdk_screen_get_default (); float dpi = gdk_screen_get_resolution (screen); @@ -197,22 +199,21 @@ draw_get_font_size (drawctx_t * const ctx) { } void -draw_text (drawctx_t * const ctx, float x, float y, int width, int align, const char *text) { - draw_init_font (ctx, 0, 0); - pango_layout_set_width (ctx->pangolayout, width*PANGO_SCALE); - pango_layout_set_alignment (ctx->pangolayout, get_pango_alignment (align)); - pango_layout_set_text (ctx->pangolayout, text, -1); - cairo_move_to (ctx->drawable, x, y); - pango_cairo_show_layout (ctx->drawable, ctx->pangolayout); -} - -void -draw_text_custom (drawctx_t * const ctx, float x, float y, int width, int align, int type, int bold, int italic, const char *text) { +draw_text_custom ( + drawctx_t *const ctx, + float x, + float y, + int width, + int align, + int type, + int bold, + int italic, + const char *text) { draw_init_font (ctx, type, 0); if (bold || italic) { draw_init_font_style (ctx, bold, italic, type); } - pango_layout_set_width (ctx->pangolayout, width*PANGO_SCALE); + pango_layout_set_width (ctx->pangolayout, width * PANGO_SCALE); pango_layout_set_alignment (ctx->pangolayout, get_pango_alignment (align)); pango_layout_set_text (ctx->pangolayout, text, -1); cairo_move_to (ctx->drawable, x, y); @@ -220,18 +221,19 @@ draw_text_custom (drawctx_t * const ctx, float x, float y, int width, int align, } void -draw_text_with_colors (drawctx_t * const ctx, float x, float y, int width, int align, const char *text) { +draw_text_with_colors (drawctx_t *const ctx, float x, float y, int width, int align, const char *text) { draw_init_font (ctx, 0, 0); - pango_layout_set_width (ctx->pangolayout, width*PANGO_SCALE); + pango_layout_set_width (ctx->pangolayout, width * PANGO_SCALE); pango_layout_set_alignment (ctx->pangolayout, get_pango_alignment (align)); pango_layout_set_text (ctx->pangolayout, text, -1); -// gdk_draw_layout_with_colors (ctx->drawable, gc, x, y, ctx->pangolayout, &clrfg, &clrbg); + // gdk_draw_layout_with_colors (ctx->drawable, gc, x, y, ctx->pangolayout, &clrfg, &clrbg); + cairo_move_to (ctx->drawable, x, y); cairo_move_to (ctx->drawable, x, y); pango_cairo_show_layout (ctx->drawable, ctx->pangolayout); } void -draw_get_layout_extents (drawctx_t * const ctx, int *w, int *h) { +draw_get_layout_extents (drawctx_t *const ctx, int *w, int *h) { PangoRectangle log; pango_layout_get_pixel_extents (ctx->pangolayout, NULL, &log); if (w) { @@ -243,7 +245,7 @@ draw_get_layout_extents (drawctx_t * const ctx, int *w, int *h) { } void -draw_get_text_extents (drawctx_t * const ctx, const char *text, int len, int *w, int *h) { +draw_get_text_extents (drawctx_t *const ctx, const char *text, int len, int *w, int *h) { draw_init_font (ctx, 0, 0); pango_layout_set_width (ctx->pangolayout, -1); pango_layout_set_alignment (ctx->pangolayout, PANGO_ALIGN_LEFT); @@ -252,30 +254,29 @@ draw_get_text_extents (drawctx_t * const ctx, const char *text, int len, int *w, } int -draw_is_ellipsized (drawctx_t * const ctx) { +draw_is_ellipsized (drawctx_t *const ctx) { return pango_layout_is_ellipsized (ctx->pangolayout); } const char * -draw_get_text (drawctx_t * const ctx) { +draw_get_text (drawctx_t *const ctx) { return pango_layout_get_text (ctx->pangolayout); } int -draw_get_listview_rowheight (drawctx_t * const ctx) { - PangoFontDescription *font_desc = pango_font_description_copy (pango_layout_get_font_description (ctx->pangolayout)); - PangoFontMetrics *metrics = pango_context_get_metrics (ctx->pangoctx, - font_desc, - pango_context_get_language (ctx->pangoctx)); - int row_height = (pango_font_metrics_get_ascent (metrics) + - pango_font_metrics_get_descent (metrics)); +draw_get_listview_rowheight (drawctx_t *const ctx) { + PangoFontDescription *font_desc = + pango_font_description_copy (pango_layout_get_font_description (ctx->pangolayout)); + PangoFontMetrics *metrics = + pango_context_get_metrics (ctx->pangoctx, font_desc, pango_context_get_language (ctx->pangoctx)); + int row_height = (pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics)); pango_font_metrics_unref (metrics); pango_font_description_free (font_desc); - return PANGO_PIXELS(row_height)+6; + return PANGO_PIXELS (row_height) + 6; } void -drawctx_init (drawctx_t * const ctx) { +drawctx_init (drawctx_t *const ctx) { memset (ctx, 0, sizeof (drawctx_t)); ctx->font_weight = PANGO_WEIGHT_NORMAL; } @@ -312,52 +313,54 @@ static int use_custom_visualization_background_color = 0; int gtkui_listview_override_conf (const char *conf_str) { - return !strcmp(conf_str, "gtkui.override_listview_colors"); + return !strcmp (conf_str, "gtkui.override_listview_colors"); } int gtkui_listview_font_conf (const char *conf_str) { - return !strncmp(conf_str, "gtkui.font.listview", strlen("gtkui.font.listview")); + return !strncmp (conf_str, "gtkui.font.listview", strlen ("gtkui.font.listview")); } int gtkui_listview_font_style_conf (const char *conf_str) { - return !strncmp(conf_str, "gtkui.italic", strlen("gtkui.italic")) || !strncmp(conf_str, "gtkui.embolden", strlen("gtkui.embolden")); + return !strncmp (conf_str, "gtkui.italic", strlen ("gtkui.italic")) || + !strncmp (conf_str, "gtkui.embolden", strlen ("gtkui.embolden")); } int gtkui_listview_colors_conf (const char *conf_str) { - return !strncmp(conf_str, "gtkui.color.listview", strlen("gtkui.color.listview")); + return !strncmp (conf_str, "gtkui.color.listview", strlen ("gtkui.color.listview")); } int gtkui_tabstrip_override_conf (const char *conf_str) { - return !strcmp(conf_str, "gtkui.override_tabstrip_colors"); + return !strcmp (conf_str, "gtkui.override_tabstrip_colors"); } int gtkui_tabstrip_font_conf (const char *conf_str) { - return !strncmp(conf_str, "gtkui.font.tabstrip", strlen("gtkui.font.tabstrip")); + return !strncmp (conf_str, "gtkui.font.tabstrip", strlen ("gtkui.font.tabstrip")); } int gtkui_tabstrip_font_style_conf (const char *conf_str) { - return !strncmp(conf_str, "gtkui.tabstrip_italic", strlen("gtkui.tabstrip_italic")) || !strncmp(conf_str, "gtkui.tabstrip_embolden", strlen("gtkui.tabstrip_embolden")); + return !strncmp (conf_str, "gtkui.tabstrip_italic", strlen ("gtkui.tabstrip_italic")) || + !strncmp (conf_str, "gtkui.tabstrip_embolden", strlen ("gtkui.tabstrip_embolden")); } int gtkui_tabstrip_colors_conf (const char *conf_str) { - return !strncmp(conf_str, "gtkui.color.tabstrip", strlen("gtkui.color.tabstrip")); + return !strncmp (conf_str, "gtkui.color.tabstrip", strlen ("gtkui.color.tabstrip")); } int gtkui_bar_override_conf (const char *conf_str) { - return !strcmp(conf_str, "gtkui.override_bar_colors"); + return !strcmp (conf_str, "gtkui.override_bar_colors"); } int gtkui_bar_colors_conf (const char *conf_str) { - return !strncmp(conf_str, "gtkui.color.bar", strlen("gtkui.color.bar")); + return !strncmp (conf_str, "gtkui.color.bar", strlen ("gtkui.color.bar")); } int @@ -403,7 +406,7 @@ color_lerp (GdkColor from, GdkColor to, float factor) { #endif static void -_init_color_for_name(GdkColor *color, const char *name, const GdkColor *def) { +_init_color_for_name (GdkColor *color, const char *name, const GdkColor *def) { char color_text[100]; snprintf (color_text, sizeof (color_text), "%hd %hd %hd", def->red, def->green, def->blue); const char *clr = deadbeef->conf_get_str_fast (name, color_text); @@ -417,7 +420,7 @@ gtkui_init_theme_colors (void) { } deadbeef->conf_lock (); - override_listview_colors= deadbeef->conf_get_int ("gtkui.override_listview_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); use_custom_visualization_color = deadbeef->conf_get_int ("gtkui.vis.use_custom_base_color", 0); @@ -428,9 +431,23 @@ gtkui_init_theme_colors (void) { GtkStyle *entry_style = gtk_widget_get_style (theme_entry); char *font_name = pango_font_description_to_string (style->font_desc); + { + PangoFontDescription *desc = pango_font_description_from_string (font_name); + GdkScreen *screen = gdk_screen_get_default (); + float dpi = gdk_screen_get_resolution (screen); + pango_font_description_set_size (desc, 20 * PANGO_SCALE / dpi * 72); + char *desc_string = pango_font_description_to_string (desc); + + strncpy (gtkui_seekbar_text_font, desc_string, sizeof (gtkui_seekbar_text_font) - 1); + + free (desc_string); + pango_font_description_free (desc); + } + // HACK: if gtk says selected color is the same as background -- set it // to a shade of blue - int use_hardcoded_accent_color = memcmp (&style->bg[GTK_STATE_NORMAL], >kui_bar_foreground_color, sizeof (gtkui_bar_foreground_color)); + int use_hardcoded_accent_color = + memcmp (&style->bg[GTK_STATE_NORMAL], >kui_bar_foreground_color, sizeof (gtkui_bar_foreground_color)); GdkColor hardcoded_accent_color = { .red = 0x2b84, @@ -446,11 +463,17 @@ gtkui_init_theme_colors (void) { } if (use_custom_visualization_color) { - _init_color_for_name(>kui_visualization_base_color, "gtkui.vis.custom_base_color", >kui_visualization_base_color); + _init_color_for_name ( + >kui_visualization_base_color, + "gtkui.vis.custom_base_color", + >kui_visualization_base_color); } if (use_custom_visualization_background_color) { - _init_color_for_name(>kui_visualization_background_color, "gtkui.vis.custom_background_color", >kui_visualization_background_color); + _init_color_for_name ( + >kui_visualization_background_color, + "gtkui.vis.custom_background_color", + >kui_visualization_background_color); } else { memcpy (>kui_visualization_background_color, &style->black, sizeof (GdkColor)); @@ -467,8 +490,14 @@ gtkui_init_theme_colors (void) { } } else { - _init_color_for_name(>kui_bar_foreground_color, "gtkui.color.bar_foreground", &entry_style->base[GTK_STATE_SELECTED]); - _init_color_for_name(>kui_bar_background_color, "gtkui.color.bar_background", &entry_style->fg[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_bar_foreground_color, + "gtkui.color.bar_foreground", + &entry_style->base[GTK_STATE_SELECTED]); + _init_color_for_name ( + >kui_bar_background_color, + "gtkui.color.bar_background", + &entry_style->fg[GTK_STATE_NORMAL]); } if (!override_tabstrip_colors) { @@ -482,15 +511,27 @@ gtkui_init_theme_colors (void) { strncpy (gtkui_tabstrip_text_font, font_name, sizeof (gtkui_tabstrip_text_font)); } else { - _init_color_for_name(>kui_tabstrip_dark_color, "gtkui.color.tabstrip_dark", &style->dark[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_tabstrip_mid_color, "gtkui.color.tabstrip_mid", &style->mid[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_tabstrip_light_color, "gtkui.color.tabstrip_light", &style->light[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_tabstrip_base_color, "gtkui.color.tabstrip_base", &style->bg[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_tabstrip_text_color, "gtkui.color.tabstrip_text", &style->text[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_tabstrip_playing_text_color, "gtkui.color.tabstrip_playing_text", &style->text[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_tabstrip_selected_text_color, "gtkui.color.tabstrip_selected_text", &style->text[GTK_STATE_NORMAL]); - - strncpy (gtkui_tabstrip_text_font, deadbeef->conf_get_str_fast ("gtkui.font.tabstrip_text", font_name), sizeof (gtkui_tabstrip_text_font)); + _init_color_for_name (>kui_tabstrip_dark_color, "gtkui.color.tabstrip_dark", &style->dark[GTK_STATE_NORMAL]); + _init_color_for_name (>kui_tabstrip_mid_color, "gtkui.color.tabstrip_mid", &style->mid[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_tabstrip_light_color, + "gtkui.color.tabstrip_light", + &style->light[GTK_STATE_NORMAL]); + _init_color_for_name (>kui_tabstrip_base_color, "gtkui.color.tabstrip_base", &style->bg[GTK_STATE_NORMAL]); + _init_color_for_name (>kui_tabstrip_text_color, "gtkui.color.tabstrip_text", &style->text[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_tabstrip_playing_text_color, + "gtkui.color.tabstrip_playing_text", + &style->text[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_tabstrip_selected_text_color, + "gtkui.color.tabstrip_selected_text", + &style->text[GTK_STATE_NORMAL]); + + strncpy ( + gtkui_tabstrip_text_font, + deadbeef->conf_get_str_fast ("gtkui.font.tabstrip_text", font_name), + sizeof (gtkui_tabstrip_text_font)); } if (!override_listview_colors) { @@ -508,19 +549,52 @@ gtkui_init_theme_colors (void) { strncpy (gtkui_listview_column_text_font, font_name, sizeof (gtkui_listview_column_text_font)); } else { - _init_color_for_name(>kui_listview_even_row_color, "gtkui.color.listview_even_row", &style->light[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_listview_odd_row_color, "gtkui.color.listview_odd_row", &style->mid[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_listview_selection_color, "gtkui.color.listview_selection", &style->bg[GTK_STATE_SELECTED]); - _init_color_for_name(>kui_listview_text_color, "gtkui.color.listview_text", &style->fg[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_listview_selected_text_color, "gtkui.color.listview_selected_text", &style->fg[GTK_STATE_SELECTED]); - _init_color_for_name(>kui_listview_playing_text_color, "gtkui.color.listview_playing_text", &style->fg[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_listview_group_text_color, "gtkui.color.listview_group_text", &style->fg[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_listview_column_text_color, "gtkui.color.listview_column_text", &style->fg[GTK_STATE_NORMAL]); - _init_color_for_name(>kui_listview_cursor_color, "gtkui.color.listview_cursor", &style->fg[GTK_STATE_SELECTED]); - - strncpy (gtkui_listview_text_font, deadbeef->conf_get_str_fast ("gtkui.font.listview_text", font_name), sizeof (gtkui_listview_text_font)); - strncpy (gtkui_listview_group_text_font, deadbeef->conf_get_str_fast ("gtkui.font.listview_group_text", font_name), sizeof (gtkui_listview_group_text_font)); - strncpy (gtkui_listview_column_text_font, deadbeef->conf_get_str_fast ("gtkui.font.listview_column_text", font_name), sizeof (gtkui_listview_column_text_font)); + _init_color_for_name ( + >kui_listview_even_row_color, + "gtkui.color.listview_even_row", + &style->light[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_listview_odd_row_color, + "gtkui.color.listview_odd_row", + &style->mid[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_listview_selection_color, + "gtkui.color.listview_selection", + &style->bg[GTK_STATE_SELECTED]); + _init_color_for_name (>kui_listview_text_color, "gtkui.color.listview_text", &style->fg[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_listview_selected_text_color, + "gtkui.color.listview_selected_text", + &style->fg[GTK_STATE_SELECTED]); + _init_color_for_name ( + >kui_listview_playing_text_color, + "gtkui.color.listview_playing_text", + &style->fg[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_listview_group_text_color, + "gtkui.color.listview_group_text", + &style->fg[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_listview_column_text_color, + "gtkui.color.listview_column_text", + &style->fg[GTK_STATE_NORMAL]); + _init_color_for_name ( + >kui_listview_cursor_color, + "gtkui.color.listview_cursor", + &style->fg[GTK_STATE_SELECTED]); + + strncpy ( + gtkui_listview_text_font, + deadbeef->conf_get_str_fast ("gtkui.font.listview_text", font_name), + sizeof (gtkui_listview_text_font)); + strncpy ( + gtkui_listview_group_text_font, + deadbeef->conf_get_str_fast ("gtkui.font.listview_group_text", font_name), + sizeof (gtkui_listview_group_text_font)); + strncpy ( + gtkui_listview_column_text_font, + deadbeef->conf_get_str_fast ("gtkui.font.listview_column_text", font_name), + sizeof (gtkui_listview_column_text_font)); } free (font_name);