diff options
author | waker <wakeroid@gmail.com> | 2011-10-08 13:30:01 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-10-08 13:30:01 +0200 |
commit | cb1c025f945fe46dab39b70712cbe4378ae24970 (patch) | |
tree | 05d617aa620119d6c424abd23fd2c0da3ab54ed5 | |
parent | 1f411a09c45a3dec70162b916688a8d7e6c16b75 (diff) |
port to GTK3 (WIP)
-rw-r--r-- | plugins/gtkui/callbacks.c | 68 | ||||
-rw-r--r-- | plugins/gtkui/ddbcellrenderertextmultiline.c | 1 | ||||
-rw-r--r-- | plugins/gtkui/ddbequalizer.c | 362 | ||||
-rw-r--r-- | plugins/gtkui/ddblistview.c | 476 | ||||
-rw-r--r-- | plugins/gtkui/ddblistview.h | 4 | ||||
-rw-r--r-- | plugins/gtkui/ddbseekbar.c | 43 | ||||
-rw-r--r-- | plugins/gtkui/ddbtabstrip.c | 258 | ||||
-rw-r--r-- | plugins/gtkui/ddbvolumebar.c | 81 | ||||
-rw-r--r-- | plugins/gtkui/drawing.h | 12 | ||||
-rw-r--r-- | plugins/gtkui/eq.c | 10 | ||||
-rw-r--r-- | plugins/gtkui/gdkdrawing.c | 56 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 26 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.h | 2 | ||||
-rw-r--r-- | plugins/gtkui/mainplaylist.c | 4 | ||||
-rw-r--r-- | plugins/gtkui/plcommon.c | 34 | ||||
-rw-r--r-- | plugins/gtkui/plcommon.h | 2 | ||||
-rw-r--r-- | plugins/gtkui/pluginconf.c | 8 | ||||
-rw-r--r-- | plugins/gtkui/prefwin.c | 14 | ||||
-rw-r--r-- | plugins/gtkui/support.c | 5 | ||||
-rw-r--r-- | plugins/gtkui/wingeom.c | 2 | ||||
-rwxr-xr-x | scripts/quickinstall.sh | 1 |
21 files changed, 783 insertions, 686 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index dfde0279..b871ee1e 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -510,24 +510,21 @@ int seekbar_moving = 0; int seekbar_move_x = 0; void -seekbar_draw (GtkWidget *widget) { +seekbar_draw (GtkWidget *widget, cairo_t *cr) { if (!widget) { return; } -// gdk_draw_rectangle (seekbar_backbuf, widget->style->bg_gc[0], TRUE, 0, 0, widget->allocation.width, widget->allocation.height); - cairo_t *cr; - cr = gdk_cairo_create (gtk_widget_get_window (widget)); - if (!cr) { - return; - } GdkColor clr_selection, clr_back; gtkui_get_bar_foreground_color (&clr_selection); gtkui_get_bar_background_color (&clr_back); - int ax = widget->allocation.x; - int ay = widget->allocation.y; - int aw = widget->allocation.width; - int ah = widget->allocation.height; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + + int ax = a.x; + int ay = a.y; + int aw = a.width; + int ah = a.height; DB_playItem_t *trk = deadbeef->streamer_get_playing_track (); if (!trk || deadbeef->pl_get_item_duration (trk) < 0) { @@ -535,11 +532,10 @@ seekbar_draw (GtkWidget *widget) { deadbeef->pl_item_unref (trk); } // empty seekbar, just a frame - clearlooks_rounded_rectangle (cr, 2+ax, widget->allocation.height/2-4+ay, aw-4, 8, 4, 0xff); + 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); - cairo_destroy (cr); return; } float pos = 0; @@ -548,15 +544,15 @@ seekbar_draw (GtkWidget *widget) { if (x < 0) { x = 0; } - if (x > widget->allocation.width-1) { - x = widget->allocation.width-1; + if (x > a.width-1) { + x = a.width-1; } pos = x; } else { if (deadbeef->pl_get_item_duration (trk) > 0) { pos = deadbeef->streamer_get_playpos () / deadbeef->pl_get_item_duration (trk); - pos *= widget->allocation.width; + pos *= a.width; } } // left @@ -577,7 +573,6 @@ seekbar_draw (GtkWidget *widget) { cairo_fill (cr); cairo_reset_clip (cr); - cairo_destroy (cr); if (trk) { deadbeef->pl_item_unref (trk); } @@ -609,7 +604,9 @@ on_seekbar_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { if (seekbar_moving) { - seekbar_move_x = event->x - widget->allocation.x; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + seekbar_move_x = event->x - a.x; gtk_widget_queue_draw (widget); } return FALSE; @@ -623,7 +620,9 @@ on_seekbar_button_press_event (GtkWidget *widget, return FALSE; } seekbar_moving = 1; - seekbar_move_x = event->x - widget->allocation.x; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + seekbar_move_x = event->x - a.x; gtk_widget_queue_draw (widget); return FALSE; } @@ -636,7 +635,9 @@ on_seekbar_button_release_event (GtkWidget *widget, seekbar_moving = 0; DB_playItem_t *trk = deadbeef->streamer_get_playing_track (); if (trk) { - float time = (event->x - widget->allocation.x) * deadbeef->pl_get_item_duration (trk) / (widget->allocation.width); + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + float time = (event->x - a.x) * deadbeef->pl_get_item_duration (trk) / (a.width); if (time < 0) { time = 0; } @@ -1029,18 +1030,21 @@ on_mainwin_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - if (event->window != mainwin->window) { + if (event->window != gtk_widget_get_window (mainwin)) { return FALSE; } GtkWidget *volumebar = lookup_widget (mainwin, "volumebar"); GtkWidget *seekbar = lookup_widget (mainwin, "seekbar"); - if (event->x >= volumebar->allocation.x && event->x < volumebar->allocation.x + volumebar->allocation.width - && event->y >= volumebar->allocation.y && event->y < volumebar->allocation.y + volumebar->allocation.height) { + GtkAllocation a, b; + gtk_widget_get_allocation (volumebar, &a); + gtk_widget_get_allocation (seekbar, &b); + if (event->x >= a.x && event->x < a.x + a.width + && event->y >= a.y && event->y < a.y + a.height) { capture = volumebar; return gtk_widget_event (volumebar, (GdkEvent *)event); } - else if (event->x >= seekbar->allocation.x && event->x < seekbar->allocation.x + seekbar->allocation.width - && event->y >= seekbar->allocation.y && event->y < seekbar->allocation.y + seekbar->allocation.height) { + else if (event->x >= b.x && event->x < b.x + b.width + && event->y >= b.y && event->y < b.y + b.height) { capture = seekbar; return gtk_widget_event (seekbar, (GdkEvent *)event); } @@ -1070,17 +1074,21 @@ on_mainwin_scroll_event (GtkWidget *widget, gpointer user_data) { GdkEventScroll *event = (GdkEventScroll *)ev; - if (event->window != mainwin->window) { + if (event->window != gtk_widget_get_window (mainwin)) { return FALSE; } GtkWidget *volumebar = lookup_widget (mainwin, "volumebar"); GtkWidget *seekbar = lookup_widget (mainwin, "seekbar"); - if (event->x >= volumebar->allocation.x && event->x < volumebar->allocation.x + volumebar->allocation.width - && event->y >= volumebar->allocation.y && event->y < volumebar->allocation.y + volumebar->allocation.height) { + GtkAllocation a; + gtk_widget_get_allocation (volumebar, &a); + GtkAllocation b; + gtk_widget_get_allocation (seekbar, &b); + if (event->x >= a.x && event->x < a.x + a.width + && event->y >= a.y && event->y < a.y + a.height) { return gtk_widget_event (volumebar, (GdkEvent *)event); } - else if (event->x >= seekbar->allocation.x && event->x < seekbar->allocation.x + seekbar->allocation.width - && event->y >= seekbar->allocation.y && event->y < seekbar->allocation.y + seekbar->allocation.height) { + else if (event->x >= b.x && event->x < b.x + b.width + && event->y >= b.y && event->y < b.y + b.height) { return gtk_widget_event (seekbar, (GdkEvent *)event); } return FALSE; diff --git a/plugins/gtkui/ddbcellrenderertextmultiline.c b/plugins/gtkui/ddbcellrenderertextmultiline.c index cb139ca3..1ecb9fc0 100644 --- a/plugins/gtkui/ddbcellrenderertextmultiline.c +++ b/plugins/gtkui/ddbcellrenderertextmultiline.c @@ -27,6 +27,7 @@ #include <string.h> #include <gdk/gdk.h> #include <gdk/gdkkeysyms.h> +#include <gdk/gdkkeysyms-compat.h> #define DDB_TYPE_CELL_EDITABLE_TEXT_VIEW (ddb_cell_editable_text_view_get_type ()) diff --git a/plugins/gtkui/ddbequalizer.c b/plugins/gtkui/ddbequalizer.c index a4d88e23..ea31a742 100644 --- a/plugins/gtkui/ddbequalizer.c +++ b/plugins/gtkui/ddbequalizer.c @@ -85,7 +85,9 @@ enum { #define DDB_EQUALIZER_spot_size 3 static gboolean ddb_equalizer_real_configure_event (GtkWidget* base, GdkEventConfigure* event); static void ddb_equalizer_real_realize (GtkWidget* base); +#if !GTK_CHECK_VERSION(3,0,0) static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event); +#endif static inline gdouble ddb_equalizer_scale (DdbEqualizer* self, gdouble val); static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, gdouble x, gdouble y); static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, gdouble x, gdouble y); @@ -128,7 +130,7 @@ static gpointer _g_object_ref0 (gpointer self) { } -static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event) { +static gboolean ddb_equalizer_real_draw (GtkWidget *base, cairo_t *cr) { DdbEqualizer * self; gboolean result = FALSE; GdkColor _tmp0_ = {0}; @@ -163,22 +165,14 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gint _tmp23_; gint height; GdkWindow* _tmp24_ = NULL; - cairo_t* _tmp25_ = NULL; - cairo_t* ctx; - cairo_t* _tmp26_; - cairo_t* _tmp27_; - cairo_t* _tmp28_; GdkColor _tmp29_; guint16 _tmp30_; GdkColor _tmp31_; guint16 _tmp32_; GdkColor _tmp33_; guint16 _tmp34_; - cairo_t* _tmp35_; gint _tmp36_; gint _tmp37_; - cairo_t* _tmp38_; - cairo_t* _tmp39_; GdkColor _tmp40_; guint16 _tmp41_; GdkColor _tmp42_; @@ -192,41 +186,21 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gint _tmp62_; gint _tmp63_; gdouble vstep; - cairo_t* _tmp78_; - cairo_t* _tmp79_; GdkColor _tmp80_; guint16 _tmp81_; GdkColor _tmp82_; guint16 _tmp83_; GdkColor _tmp84_; guint16 _tmp85_; - cairo_t* _tmp86_; - PangoLayout* _tmp87_ = NULL; PangoLayout* l; - PangoLayout* _tmp88_; - PangoContext* _tmp89_ = NULL; - PangoContext* _tmp90_; PangoContext* pctx; GtkStyle* _tmp91_ = NULL; - const PangoFontDescription* _tmp92_; - PangoFontDescription* _tmp93_ = NULL; PangoFontDescription* fd; - const PangoFontDescription* _tmp94_; GtkStyle* _tmp95_ = NULL; - const PangoFontDescription* _tmp96_; gint _tmp97_ = 0; - PangoContext* _tmp98_; - const PangoFontDescription* _tmp99_; - const PangoFontDescription* _tmp129_; GtkStyle* _tmp130_ = NULL; - const PangoFontDescription* _tmp131_; gint _tmp132_ = 0; - PangoContext* _tmp133_; - const PangoFontDescription* _tmp134_; - PangoLayout* _tmp135_; gint _tmp136_; - PangoLayout* _tmp137_; - const PangoFontDescription* _tmp138_; gint _tmp139_ = 0; gdouble _tmp140_ = 0.0; GdkScreen* _tmp141_ = NULL; @@ -235,7 +209,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gboolean _tmp143_ = FALSE; gint _tmp144_; gboolean _tmp148_; - cairo_t* _tmp170_; gchar* tmp = NULL; gdouble _tmp171_ = 0.0; gdouble val; @@ -244,70 +217,41 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose const gchar* _tmp174_; gdouble _tmp175_; gchar* _tmp176_ = NULL; - PangoLayout* _tmp177_; const gchar* _tmp178_; const gchar* _tmp179_; gint _tmp180_; gint _tmp181_; - cairo_t* _tmp182_; gint _tmp183_; gint _tmp184_; gint _tmp185_; gint _tmp186_; - cairo_t* _tmp187_; - PangoLayout* _tmp188_; - cairo_t* _tmp189_; - cairo_t* _tmp190_; gdouble _tmp191_ = 0.0; const gchar* _tmp192_ = NULL; gdouble _tmp193_; const gchar* _tmp194_; gdouble _tmp195_; gchar* _tmp196_ = NULL; - PangoLayout* _tmp197_; const gchar* _tmp198_; const gchar* _tmp199_; gint _tmp200_; gint _tmp201_; - cairo_t* _tmp202_; gint _tmp203_; - cairo_t* _tmp204_; - PangoLayout* _tmp205_; - cairo_t* _tmp206_; - cairo_t* _tmp207_; - PangoLayout* _tmp208_; - cairo_t* _tmp209_; gint _tmp210_; gdouble _tmp211_; gint _tmp212_; gint _tmp213_; gint _tmp214_; - cairo_t* _tmp215_; - PangoLayout* _tmp216_; - cairo_t* _tmp217_; - cairo_t* _tmp218_; - PangoLayout* _tmp219_; - PangoLayout* _tmp220_; - cairo_t* _tmp221_; gint _tmp222_; gint _tmp223_; - cairo_t* _tmp224_; - PangoLayout* _tmp225_; - cairo_t* _tmp226_; - cairo_t* _tmp227_; gint _tmp228_; gint _tmp229_; gint _tmp230_; gint _tmp231_; gint _tmp232_; - cairo_t* _tmp233_; - cairo_t* _tmp234_; gdouble _tmp235_; gint _tmp236_; gint _tmp237_; gint _tmp238_; - cairo_t* _tmp239_; - cairo_t* _tmp240_; GdkColor _tmp241_; guint16 _tmp242_; GdkColor _tmp243_; @@ -317,25 +261,17 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gint _tmp247_; gint _tmp248_; gint count; - cairo_t* _tmp258_; - cairo_t* _tmp259_; gint bar_w; gdouble _tmp260_; gint _tmp261_; - cairo_t* _tmp300_; - cairo_t* _tmp301_; gdouble* _tmp302_ = NULL; gdouble* _tmp303_; gint _tmp303__length1; - cairo_t* _tmp304_; gint _tmp305_; gint _tmp306_; - cairo_t* _tmp307_; gint _tmp308_; gint _tmp309_; - cairo_t* _tmp310_; self = (DdbEqualizer*) base; - g_return_val_if_fail (event != NULL, FALSE); gtkui_get_bar_foreground_color (&_tmp0_); fore_bright_color = _tmp0_; _tmp1_ = fore_bright_color; @@ -371,34 +307,26 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose _tmp23_ = _tmp22_.height; height = _tmp23_; _tmp24_ = gtk_widget_get_window ((GtkWidget*) self); - _tmp25_ = gdk_cairo_create ((GdkDrawable*) _tmp24_); - ctx = _tmp25_; - _tmp26_ = ctx; - cairo_set_antialias (_tmp26_, CAIRO_ANTIALIAS_NONE); - _tmp27_ = ctx; - cairo_set_line_width (_tmp27_, 1.0); - _tmp28_ = ctx; + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + cairo_set_line_width (cr, 1.0); _tmp29_ = c2; _tmp30_ = _tmp29_.red; _tmp31_ = c2; _tmp32_ = _tmp31_.green; _tmp33_ = c2; _tmp34_ = _tmp33_.blue; - cairo_set_source_rgba (_tmp28_, _tmp30_ / 65535.0, _tmp32_ / 65535.0, _tmp34_ / 65535.0, (gdouble) 1); - _tmp35_ = ctx; + cairo_set_source_rgba (cr, _tmp30_ / 65535.0, _tmp32_ / 65535.0, _tmp34_ / 65535.0, (gdouble) 1); _tmp36_ = width; _tmp37_ = height; - cairo_rectangle (_tmp35_, (gdouble) 0, (gdouble) 0, (gdouble) _tmp36_, (gdouble) _tmp37_); - _tmp38_ = ctx; - cairo_fill (_tmp38_); - _tmp39_ = ctx; + cairo_rectangle (cr, (gdouble) 0, (gdouble) 0, (gdouble) _tmp36_, (gdouble) _tmp37_); + cairo_fill (cr); _tmp40_ = fore_dark_color; _tmp41_ = _tmp40_.red; _tmp42_ = fore_dark_color; _tmp43_ = _tmp42_.green; _tmp44_ = fore_dark_color; _tmp45_ = _tmp44_.blue; - cairo_set_source_rgba (_tmp39_, _tmp41_ / 65535.0, _tmp43_ / 65535.0, _tmp45_ / 65535.0, (gdouble) 1); + cairo_set_source_rgba (cr, _tmp41_ / 65535.0, _tmp43_ / 65535.0, _tmp45_ / 65535.0, (gdouble) 1); _tmp46_ = width; _tmp47_ = self->priv->eq_margin_left; step = ((gdouble) (_tmp46_ - _tmp47_)) / ((gdouble) (DDB_EQUALIZER_bands + 1)); @@ -409,11 +337,9 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose while (TRUE) { gboolean _tmp49_; gint _tmp51_; - cairo_t* _tmp52_; gint _tmp53_; gdouble _tmp54_; gint _tmp55_; - cairo_t* _tmp56_; gint _tmp57_; gdouble _tmp58_; gint _tmp59_; @@ -430,18 +356,16 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose if (!(_tmp51_ < DDB_EQUALIZER_bands)) { break; } - _tmp52_ = ctx; _tmp53_ = i; _tmp54_ = step; _tmp55_ = self->priv->eq_margin_left; - cairo_move_to (_tmp52_, (gdouble) (((gint) ((_tmp53_ + 1) * _tmp54_)) + _tmp55_), (gdouble) 0); - _tmp56_ = ctx; + cairo_move_to (cr, (gdouble) (((gint) ((_tmp53_ + 1) * _tmp54_)) + _tmp55_), (gdouble) 0); _tmp57_ = i; _tmp58_ = step; _tmp59_ = self->priv->eq_margin_left; _tmp60_ = height; _tmp61_ = self->priv->eq_margin_bottom; - cairo_line_to (_tmp56_, (gdouble) (((gint) ((_tmp57_ + 1) * _tmp58_)) + _tmp59_), (gdouble) (_tmp60_ - _tmp61_)); + cairo_line_to (cr, (gdouble) (((gint) ((_tmp57_ + 1) * _tmp58_)) + _tmp59_), (gdouble) (_tmp60_ - _tmp61_)); } } _tmp62_ = height; @@ -456,12 +380,10 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose while (TRUE) { gboolean _tmp65_; gdouble _tmp67_; - cairo_t* _tmp68_; gint _tmp69_; gdouble _tmp70_; gdouble _tmp71_; gdouble _tmp72_; - cairo_t* _tmp73_; gint _tmp74_; gdouble _tmp75_; gdouble _tmp76_; @@ -477,50 +399,34 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose if (!(_tmp67_ < ((gdouble) 2))) { break; } - _tmp68_ = ctx; _tmp69_ = self->priv->eq_margin_left; _tmp70_ = di; _tmp71_ = self->priv->preamp; _tmp72_ = vstep; - cairo_move_to (_tmp68_, (gdouble) _tmp69_, (gdouble) ((gint) ((_tmp70_ - _tmp71_) * _tmp72_))); - _tmp73_ = ctx; + cairo_move_to (cr, (gdouble) _tmp69_, (gdouble) ((gint) ((_tmp70_ - _tmp71_) * _tmp72_))); _tmp74_ = width; _tmp75_ = di; _tmp76_ = self->priv->preamp; _tmp77_ = vstep; - cairo_line_to (_tmp73_, (gdouble) _tmp74_, (gdouble) ((gint) ((_tmp75_ - _tmp76_) * _tmp77_))); + cairo_line_to (cr, (gdouble) _tmp74_, (gdouble) ((gint) ((_tmp75_ - _tmp76_) * _tmp77_))); } } } - _tmp78_ = ctx; - cairo_stroke (_tmp78_); - _tmp79_ = ctx; + cairo_stroke (cr); _tmp80_ = fore_bright_color; _tmp81_ = _tmp80_.red; _tmp82_ = fore_bright_color; _tmp83_ = _tmp82_.green; _tmp84_ = fore_bright_color; _tmp85_ = _tmp84_.blue; - cairo_set_source_rgba (_tmp79_, _tmp81_ / 65535.0, _tmp83_ / 65535.0, _tmp85_ / 65535.0, (gdouble) 1); - _tmp86_ = ctx; - _tmp87_ = pango_cairo_create_layout (_tmp86_); - l = _tmp87_; - _tmp88_ = l; - _tmp89_ = pango_layout_get_context (_tmp88_); - _tmp90_ = _g_object_ref0 (_tmp89_); - pctx = _tmp90_; - _tmp91_ = gtk_widget_get_style ((GtkWidget*) self); - _tmp92_ = _tmp91_->font_desc; - _tmp93_ = pango_font_description_copy (_tmp92_); - fd = _tmp93_; - _tmp94_ = fd; + cairo_set_source_rgba (cr, _tmp81_ / 65535.0, _tmp83_ / 65535.0, _tmp85_ / 65535.0, (gdouble) 1); + l = pango_cairo_create_layout (cr); + pctx = pango_layout_get_context (l); + fd = pango_font_description_copy (gtk_widget_get_style ((GtkWidget*) self)->font_desc); _tmp95_ = gtk_widget_get_style ((GtkWidget*) self); - _tmp96_ = _tmp95_->font_desc; - _tmp97_ = pango_font_description_get_size (_tmp96_); - pango_font_description_set_size (_tmp94_, (gint) (_tmp97_ * 0.7)); - _tmp98_ = pctx; - _tmp99_ = fd; - pango_context_set_font_description (_tmp98_, _tmp99_); + _tmp97_ = pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc); + pango_font_description_set_size (fd, (gint) (_tmp97_ * 0.7)); + pango_context_set_font_description (pctx, fd); { gboolean _tmp100_; i = 0; @@ -528,8 +434,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose while (TRUE) { gboolean _tmp101_; gint _tmp103_; - cairo_t* _tmp104_; - PangoLayout* _tmp105_; gint _tmp106_; const gchar* _tmp107_; gint _tmp108_; @@ -538,12 +442,10 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gint _tmp111_; PangoRectangle ink = {0}; PangoRectangle log = {0}; - PangoLayout* _tmp112_; PangoRectangle _tmp113_ = {0}; PangoRectangle _tmp114_ = {0}; gint offs; gint _tmp115_; - cairo_t* _tmp117_; gint _tmp118_; gdouble _tmp119_; gint _tmp120_; @@ -552,9 +454,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gint _tmp123_; gint _tmp124_; gint _tmp125_; - cairo_t* _tmp126_; - PangoLayout* _tmp127_; - cairo_t* _tmp128_; _tmp101_ = _tmp100_; if (!_tmp101_) { gint _tmp102_; @@ -566,18 +465,15 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose if (!(_tmp103_ < DDB_EQUALIZER_bands)) { break; } - _tmp104_ = ctx; - cairo_save (_tmp104_); - _tmp105_ = l; + cairo_save (cr); _tmp106_ = i; _tmp107_ = freqs[_tmp106_]; _tmp108_ = i; _tmp109_ = freqs[_tmp108_]; _tmp110_ = strlen (_tmp109_); _tmp111_ = _tmp110_; - pango_layout_set_text (_tmp105_, _tmp107_, (gint) _tmp111_); - _tmp112_ = l; - pango_layout_get_pixel_extents (_tmp112_, &_tmp113_, &_tmp114_); + pango_layout_set_text (l, _tmp107_, (gint) _tmp111_); + pango_layout_get_pixel_extents (l, &_tmp113_, &_tmp114_); ink = _tmp113_; log = _tmp114_; offs = 2; @@ -587,7 +483,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose _tmp116_ = offs; offs = _tmp116_ + 2; } - _tmp117_ = ctx; _tmp118_ = i; _tmp119_ = step; _tmp120_ = self->priv->eq_margin_left; @@ -596,29 +491,19 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose _tmp123_ = height; _tmp124_ = self->priv->eq_margin_bottom; _tmp125_ = offs; - cairo_move_to (_tmp117_, (gdouble) ((((gint) ((_tmp118_ + 1) * _tmp119_)) + _tmp120_) - (_tmp122_ / 2)), (gdouble) ((_tmp123_ - _tmp124_) + _tmp125_)); - _tmp126_ = ctx; - _tmp127_ = l; - pango_cairo_show_layout (_tmp126_, _tmp127_); - _tmp128_ = ctx; - cairo_restore (_tmp128_); + cairo_move_to (cr, (gdouble) ((((gint) ((_tmp118_ + 1) * _tmp119_)) + _tmp120_) - (_tmp122_ / 2)), (gdouble) ((_tmp123_ - _tmp124_) + _tmp125_)); + pango_cairo_show_layout (cr, l); + cairo_restore (cr); } } - _tmp129_ = fd; _tmp130_ = gtk_widget_get_style ((GtkWidget*) self); - _tmp131_ = _tmp130_->font_desc; - _tmp132_ = pango_font_description_get_size (_tmp131_); - pango_font_description_set_size (_tmp129_, (gint) _tmp132_); - _tmp133_ = pctx; - _tmp134_ = fd; - pango_context_set_font_description (_tmp133_, _tmp134_); - _tmp135_ = l; + _tmp132_ = pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc); + pango_font_description_set_size (fd, (gint) _tmp132_); + pango_context_set_font_description (pctx, fd); _tmp136_ = self->priv->eq_margin_left; - pango_layout_set_width (_tmp135_, _tmp136_ - 1); - _tmp137_ = l; - pango_layout_set_alignment (_tmp137_, PANGO_ALIGN_RIGHT); - _tmp138_ = fd; - _tmp139_ = pango_font_description_get_size (_tmp138_); + pango_layout_set_width (l, _tmp136_ - 1); + pango_layout_set_alignment (l, PANGO_ALIGN_RIGHT); + _tmp139_ = pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc); _tmp140_ = pango_units_to_double (_tmp139_); _tmp141_ = gdk_screen_get_default (); _tmp142_ = gdk_screen_get_resolution (_tmp141_); @@ -637,7 +522,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose } _tmp148_ = _tmp143_; if (_tmp148_) { - cairo_t* _tmp149_; gint _tmp150_; gint _tmp151_; gint _tmp152_; @@ -649,19 +533,13 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gdouble _tmp157_; gchar* _tmp158_ = NULL; gchar* tmp; - PangoLayout* _tmp159_; const gchar* _tmp160_; const gchar* _tmp161_; gint _tmp162_; gint _tmp163_; - cairo_t* _tmp164_; gint _tmp165_; gint _tmp166_; - cairo_t* _tmp167_; - PangoLayout* _tmp168_; - cairo_t* _tmp169_; - _tmp149_ = ctx; - cairo_save (_tmp149_); + cairo_save (cr); _tmp150_ = self->priv->mouse_y; _tmp151_ = height; _tmp152_ = self->priv->eq_margin_bottom; @@ -677,25 +555,19 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose _tmp157_ = db; _tmp158_ = g_strdup_printf ("%s%.1fdB", _tmp156_, _tmp157_); tmp = _tmp158_; - _tmp159_ = l; _tmp160_ = tmp; _tmp161_ = tmp; _tmp162_ = strlen (_tmp161_); _tmp163_ = _tmp162_; - pango_layout_set_text (_tmp159_, _tmp160_, (gint) _tmp163_); - _tmp164_ = ctx; + pango_layout_set_text (l, _tmp160_, (gint) _tmp163_); _tmp165_ = self->priv->eq_margin_left; _tmp166_ = self->priv->mouse_y; - cairo_move_to (_tmp164_, (gdouble) (_tmp165_ - 1), (gdouble) (_tmp166_ - 3)); - _tmp167_ = ctx; - _tmp168_ = l; - pango_cairo_show_layout (_tmp167_, _tmp168_); - _tmp169_ = ctx; - cairo_restore (_tmp169_); + cairo_move_to (cr, (gdouble) (_tmp165_ - 1), (gdouble) (_tmp166_ - 3)); + pango_cairo_show_layout (cr, l); + cairo_restore (cr); _g_free0 (tmp); } - _tmp170_ = ctx; - cairo_save (_tmp170_); + cairo_save (cr); _tmp171_ = ddb_equalizer_scale (self, (gdouble) 1); val = _tmp171_; _tmp173_ = val; @@ -709,25 +581,19 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose _tmp176_ = g_strdup_printf ("%s%.1fdB", _tmp174_, _tmp175_); _g_free0 (tmp); tmp = _tmp176_; - _tmp177_ = l; _tmp178_ = tmp; _tmp179_ = tmp; _tmp180_ = strlen (_tmp179_); _tmp181_ = _tmp180_; - pango_layout_set_text (_tmp177_, _tmp178_, (gint) _tmp181_); - _tmp182_ = ctx; + pango_layout_set_text (l, _tmp178_, (gint) _tmp181_); _tmp183_ = self->priv->eq_margin_left; _tmp184_ = height; _tmp185_ = self->priv->eq_margin_bottom; _tmp186_ = fontsize; - cairo_move_to (_tmp182_, (gdouble) (_tmp183_ - 1), (gdouble) ((_tmp184_ - _tmp185_) - _tmp186_)); - _tmp187_ = ctx; - _tmp188_ = l; - pango_cairo_show_layout (_tmp187_, _tmp188_); - _tmp189_ = ctx; - cairo_restore (_tmp189_); - _tmp190_ = ctx; - cairo_save (_tmp190_); + cairo_move_to (cr, (gdouble) (_tmp183_ - 1), (gdouble) ((_tmp184_ - _tmp185_) - _tmp186_)); + pango_cairo_show_layout (cr, l); + cairo_restore (cr); + cairo_save (cr); _tmp191_ = ddb_equalizer_scale (self, (gdouble) 0); val = _tmp191_; _tmp193_ = val; @@ -741,76 +607,53 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose _tmp196_ = g_strdup_printf ("%s%.1fdB", _tmp194_, _tmp195_); _g_free0 (tmp); tmp = _tmp196_; - _tmp197_ = l; _tmp198_ = tmp; _tmp199_ = tmp; _tmp200_ = strlen (_tmp199_); _tmp201_ = _tmp200_; - pango_layout_set_text (_tmp197_, _tmp198_, (gint) _tmp201_); - _tmp202_ = ctx; + pango_layout_set_text (l, _tmp198_, (gint) _tmp201_); _tmp203_ = self->priv->eq_margin_left; - cairo_move_to (_tmp202_, (gdouble) (_tmp203_ - 1), (gdouble) 1); - _tmp204_ = ctx; - _tmp205_ = l; - pango_cairo_show_layout (_tmp204_, _tmp205_); - _tmp206_ = ctx; - cairo_restore (_tmp206_); - _tmp207_ = ctx; - cairo_save (_tmp207_); - _tmp208_ = l; - pango_layout_set_text (_tmp208_, "+0dB", 4); - _tmp209_ = ctx; + cairo_move_to (cr, (gdouble) (_tmp203_ - 1), (gdouble) 1); + pango_cairo_show_layout (cr, l); + cairo_restore (cr); + cairo_save (cr); + pango_layout_set_text (l, "+0dB", 4); _tmp210_ = self->priv->eq_margin_left; _tmp211_ = self->priv->preamp; _tmp212_ = height; _tmp213_ = self->priv->eq_margin_bottom; _tmp214_ = fontsize; - cairo_move_to (_tmp209_, (gdouble) (_tmp210_ - 1), (gdouble) (((gint) ((1 - _tmp211_) * (_tmp212_ - _tmp213_))) - (_tmp214_ / 2))); - _tmp215_ = ctx; - _tmp216_ = l; - pango_cairo_show_layout (_tmp215_, _tmp216_); - _tmp217_ = ctx; - cairo_restore (_tmp217_); - _tmp218_ = ctx; - cairo_save (_tmp218_); - _tmp219_ = l; - pango_layout_set_text (_tmp219_, "preamp", 6); - _tmp220_ = l; - pango_layout_set_alignment (_tmp220_, PANGO_ALIGN_LEFT); - _tmp221_ = ctx; + cairo_move_to (cr, (gdouble) (_tmp210_ - 1), (gdouble) (((gint) ((1 - _tmp211_) * (_tmp212_ - _tmp213_))) - (_tmp214_ / 2))); + pango_cairo_show_layout (cr, l); + cairo_restore (cr); + cairo_save (cr); + pango_layout_set_text (l, "preamp", 6); + pango_layout_set_alignment (l, PANGO_ALIGN_LEFT); _tmp222_ = height; _tmp223_ = self->priv->eq_margin_bottom; - cairo_move_to (_tmp221_, (gdouble) 1, (gdouble) ((_tmp222_ - _tmp223_) + 2)); - _tmp224_ = ctx; - _tmp225_ = l; - pango_cairo_show_layout (_tmp224_, _tmp225_); - _tmp226_ = ctx; - cairo_restore (_tmp226_); - _tmp227_ = ctx; + cairo_move_to (cr, (gdouble) 1, (gdouble) ((_tmp222_ - _tmp223_) + 2)); + pango_cairo_show_layout (cr, l); + cairo_restore (cr); _tmp228_ = self->priv->eq_margin_left; _tmp229_ = width; _tmp230_ = self->priv->eq_margin_left; _tmp231_ = height; _tmp232_ = self->priv->eq_margin_bottom; - cairo_rectangle (_tmp227_, (gdouble) _tmp228_, (gdouble) 0, (gdouble) ((_tmp229_ - _tmp230_) - 1), (gdouble) ((_tmp231_ - _tmp232_) - 1)); - _tmp233_ = ctx; - cairo_stroke (_tmp233_); - _tmp234_ = ctx; + cairo_rectangle (cr, (gdouble) _tmp228_, (gdouble) 0, (gdouble) ((_tmp229_ - _tmp230_) - 1), (gdouble) ((_tmp231_ - _tmp232_) - 1)); + cairo_stroke (cr); _tmp235_ = self->priv->preamp; _tmp236_ = height; _tmp237_ = self->priv->eq_margin_bottom; _tmp238_ = height; - cairo_rectangle (_tmp234_, (gdouble) 0, (gdouble) ((gint) (_tmp235_ * (_tmp236_ - _tmp237_))), (gdouble) 11, (gdouble) _tmp238_); - _tmp239_ = ctx; - cairo_clip (_tmp239_); - _tmp240_ = ctx; + cairo_rectangle (cr, (gdouble) 0, (gdouble) ((gint) (_tmp235_ * (_tmp236_ - _tmp237_))), (gdouble) 11, (gdouble) _tmp238_); + cairo_clip (cr); _tmp241_ = fore_bright_color; _tmp242_ = _tmp241_.red; _tmp243_ = fore_bright_color; _tmp244_ = _tmp243_.green; _tmp245_ = fore_bright_color; _tmp246_ = _tmp245_.blue; - cairo_set_source_rgba (_tmp240_, _tmp242_ / 65535.0, _tmp244_ / 65535.0, _tmp246_ / 65535.0, 1.0); + cairo_set_source_rgba (cr, _tmp242_ / 65535.0, _tmp244_ / 65535.0, _tmp246_ / 65535.0, 1.0); _tmp247_ = height; _tmp248_ = self->priv->eq_margin_bottom; count = ((gint) ((_tmp247_ - _tmp248_) / 6)) + 1; @@ -824,7 +667,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gboolean _tmp250_; gint _tmp252_; gint _tmp253_; - cairo_t* _tmp254_; gint _tmp255_; gint _tmp256_; gint _tmp257_; @@ -840,18 +682,15 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose if (!(_tmp252_ < _tmp253_)) { break; } - _tmp254_ = ctx; _tmp255_ = height; _tmp256_ = self->priv->eq_margin_bottom; _tmp257_ = j; - cairo_rectangle (_tmp254_, (gdouble) 1, (gdouble) (((_tmp255_ - _tmp256_) - (_tmp257_ * 6)) - 6), (gdouble) 11, (gdouble) 4); + cairo_rectangle (cr, (gdouble) 1, (gdouble) (((_tmp255_ - _tmp256_) - (_tmp257_ * 6)) - 6), (gdouble) 11, (gdouble) 4); } } } - _tmp258_ = ctx; - cairo_fill (_tmp258_); - _tmp259_ = ctx; - cairo_reset_clip (_tmp259_); + cairo_fill (cr); + cairo_reset_clip (cr); bar_w = 11; _tmp260_ = step; _tmp261_ = bar_w; @@ -867,8 +706,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose while (TRUE) { gboolean _tmp264_; gint _tmp266_; - cairo_t* _tmp267_; - cairo_t* _tmp268_; gint _tmp269_; gdouble _tmp270_; gint _tmp271_; @@ -880,14 +717,12 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gint _tmp276_; gint _tmp277_; gint _tmp278_; - cairo_t* _tmp279_; gint _tmp280_; gint _tmp281_; gdouble* _tmp282_; gint _tmp282__length1; gint _tmp283_; gdouble _tmp284_; - cairo_t* _tmp299_; _tmp264_ = _tmp263_; if (!_tmp264_) { gint _tmp265_; @@ -899,9 +734,7 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose if (!(_tmp266_ < DDB_EQUALIZER_bands)) { break; } - _tmp267_ = ctx; - cairo_reset_clip (_tmp267_); - _tmp268_ = ctx; + cairo_reset_clip (cr); _tmp269_ = i; _tmp270_ = step; _tmp271_ = self->priv->eq_margin_left; @@ -913,9 +746,8 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose _tmp276_ = height; _tmp277_ = self->priv->eq_margin_bottom; _tmp278_ = height; - cairo_rectangle (_tmp268_, (gdouble) ((((gint) ((_tmp269_ + 1) * _tmp270_)) + _tmp271_) - (_tmp272_ / 2)), (gdouble) ((gint) (_tmp275_ * (_tmp276_ - _tmp277_))), (gdouble) 11, (gdouble) _tmp278_); - _tmp279_ = ctx; - cairo_clip (_tmp279_); + cairo_rectangle (cr, (gdouble) ((((gint) ((_tmp269_ + 1) * _tmp270_)) + _tmp271_) - (_tmp272_ / 2)), (gdouble) ((gint) (_tmp275_ * (_tmp276_ - _tmp277_))), (gdouble) 11, (gdouble) _tmp278_); + cairo_clip (cr); _tmp280_ = height; _tmp281_ = self->priv->eq_margin_bottom; _tmp282_ = self->priv->values; @@ -933,7 +765,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose gboolean _tmp286_; gint _tmp288_; gint _tmp289_; - cairo_t* _tmp290_; gint _tmp291_; gdouble _tmp292_; gint _tmp293_; @@ -954,7 +785,6 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose if (!(_tmp288_ < _tmp289_)) { break; } - _tmp290_ = ctx; _tmp291_ = i; _tmp292_ = step; _tmp293_ = self->priv->eq_margin_left; @@ -963,42 +793,45 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose _tmp296_ = self->priv->eq_margin_bottom; _tmp297_ = j; _tmp298_ = bar_w; - cairo_rectangle (_tmp290_, (gdouble) ((((gint) ((_tmp291_ + 1) * _tmp292_)) + _tmp293_) - (_tmp294_ / 2)), (gdouble) (((_tmp295_ - _tmp296_) - (_tmp297_ * 6)) - 6), (gdouble) _tmp298_, (gdouble) 4); + cairo_rectangle (cr, (gdouble) ((((gint) ((_tmp291_ + 1) * _tmp292_)) + _tmp293_) - (_tmp294_ / 2)), (gdouble) (((_tmp295_ - _tmp296_) - (_tmp297_ * 6)) - 6), (gdouble) _tmp298_, (gdouble) 4); } } } - _tmp299_ = ctx; - cairo_fill (_tmp299_); + cairo_fill (cr); } } - _tmp300_ = ctx; - cairo_reset_clip (_tmp300_); - _tmp301_ = ctx; + cairo_reset_clip (cr); _tmp302_ = g_new0 (gdouble, 2); _tmp302_[0] = (gdouble) 4; _tmp302_[1] = (gdouble) 4; _tmp303_ = _tmp302_; _tmp303__length1 = 2; - cairo_set_dash (_tmp301_, _tmp303_, 2, (gdouble) 0); + cairo_set_dash (cr, _tmp303_, 2, (gdouble) 0); _tmp303_ = (g_free (_tmp303_), NULL); - _tmp304_ = ctx; _tmp305_ = self->priv->eq_margin_left; _tmp306_ = self->priv->mouse_y; - cairo_move_to (_tmp304_, (gdouble) (_tmp305_ + 1), (gdouble) _tmp306_); - _tmp307_ = ctx; + cairo_move_to (cr, (gdouble) (_tmp305_ + 1), (gdouble) _tmp306_); _tmp308_ = width; _tmp309_ = self->priv->mouse_y; - cairo_line_to (_tmp307_, (gdouble) _tmp308_, (gdouble) _tmp309_); - _tmp310_ = ctx; - cairo_stroke (_tmp310_); + cairo_line_to (cr, (gdouble) _tmp308_, (gdouble) _tmp309_); + cairo_stroke (cr); result = FALSE; _g_free0 (tmp); _pango_font_description_free0 (fd); - _g_object_unref0 (pctx); _g_object_unref0 (l); + + return FALSE; +} + +#if !GTK_CHECK_VERSION(3,0,0) +static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event) { + g_return_val_if_fail (event != NULL, FALSE); + cairo_t *ctx= gdk_cairo_create ((GdkDrawable*) gtk_widget_get_window (base)); + ddb_equalizer_real_draw (base, cr); _cairo_destroy0 (ctx); return result; } +#endif static inline gdouble ddb_equalizer_scale (DdbEqualizer* self, gdouble val) { @@ -1030,12 +863,12 @@ static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, gdouble x, gdou g_return_val_if_fail (self != NULL, FALSE); _tmp3_ = x; _tmp4_ = self->priv->eq_margin_left; + GtkAllocation _tmp6_; + gtk_widget_get_allocation ((GtkWidget*) self, &_tmp6_); if (_tmp3_ > ((gdouble) _tmp4_)) { gdouble _tmp5_; - GtkAllocation _tmp6_; gint _tmp7_; _tmp5_ = x; - _tmp6_ = ((GtkWidget*) self)->allocation; _tmp7_ = _tmp6_.width; _tmp2_ = _tmp5_ < ((gdouble) (_tmp7_ - 1)); } else { @@ -1056,8 +889,7 @@ static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, gdouble x, gdou gint _tmp13_; gint _tmp14_; _tmp11_ = y; - _tmp12_ = ((GtkWidget*) self)->allocation; - _tmp13_ = _tmp12_.height; + _tmp13_ = _tmp6_.height; _tmp14_ = self->priv->eq_margin_bottom; _tmp0_ = _tmp11_ < ((gdouble) (_tmp13_ - _tmp14_)); } else { @@ -1085,7 +917,7 @@ static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, gdouble x, gdouble gint _tmp11_; gboolean _tmp13_; g_return_if_fail (self != NULL); - _tmp0_ = ((GtkWidget*) self)->allocation; + gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_); _tmp1_ = _tmp0_.width; _tmp2_ = self->priv->eq_margin_left; band_width = ((gdouble) (_tmp1_ - _tmp2_)) / ((gdouble) (DDB_EQUALIZER_bands + 1)); @@ -1130,7 +962,7 @@ static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, gdouble x, gdouble _tmp14__length1 = self->priv->values_length1; _tmp15_ = band; _tmp16_ = y; - _tmp17_ = ((GtkWidget*) self)->allocation; + gtk_widget_get_allocation ((GtkWidget*) self, &_tmp17_); _tmp18_ = _tmp17_.height; _tmp19_ = self->priv->eq_margin_bottom; _tmp14_[_tmp15_] = _tmp16_ / ((gdouble) (_tmp18_ - _tmp19_)); @@ -1238,7 +1070,7 @@ static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEvent gint _tmp23_; _tmp19_ = *event; _tmp20_ = _tmp19_.y; - _tmp21_ = ((GtkWidget*) self)->allocation; + gtk_widget_get_allocation ((GtkWidget*) self, &_tmp21_); _tmp22_ = _tmp21_.height; _tmp23_ = self->priv->eq_margin_bottom; _tmp12_ = _tmp20_ <= ((gdouble) (_tmp22_ - _tmp23_)); @@ -1266,7 +1098,7 @@ static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEvent gdouble _tmp34_; _tmp28_ = *event; _tmp29_ = _tmp28_.y; - _tmp30_ = ((GtkWidget*) self)->allocation; + gtk_widget_get_allocation ((GtkWidget*) self, &_tmp30_); _tmp31_ = _tmp30_.height; _tmp32_ = self->priv->eq_margin_bottom; self->priv->preamp = _tmp29_ / ((gdouble) (_tmp31_ - _tmp32_)); @@ -1333,7 +1165,7 @@ static gboolean ddb_equalizer_real_motion_notify_event (GtkWidget* base, GdkEven g_return_val_if_fail (event != NULL, FALSE); _tmp0_ = *event; _tmp1_ = _tmp0_.y; - _tmp2_ = ((GtkWidget*) self)->allocation; + gtk_widget_get_allocation ((GtkWidget*) self, &_tmp2_); _tmp3_ = _tmp2_.height; _tmp4_ = self->priv->eq_margin_bottom; y = _tmp1_ / ((gdouble) (_tmp3_ - _tmp4_)); @@ -1486,7 +1318,11 @@ static void ddb_equalizer_class_init (DdbEqualizerClass * klass) { g_type_class_add_private (klass, sizeof (DdbEqualizerPrivate)); GTK_WIDGET_CLASS (klass)->configure_event = ddb_equalizer_real_configure_event; GTK_WIDGET_CLASS (klass)->realize = ddb_equalizer_real_realize; +#if GTK_CHECK_VERSION(3,0,0) + GTK_WIDGET_CLASS (klass)->draw = ddb_equalizer_real_draw; +#else GTK_WIDGET_CLASS (klass)->expose_event = ddb_equalizer_real_expose_event; +#endif GTK_WIDGET_CLASS (klass)->button_press_event = ddb_equalizer_real_button_press_event; GTK_WIDGET_CLASS (klass)->button_release_event = ddb_equalizer_real_button_release_event; GTK_WIDGET_CLASS (klass)->leave_notify_event = ddb_equalizer_real_leave_notify_event; diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index b6140456..a89f2039 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -21,6 +21,7 @@ #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#include <gdk/gdkkeysyms-compat.h> #include <math.h> #include <stdlib.h> #include <time.h> @@ -80,7 +81,7 @@ static void ddb_listview_init(DdbListview *listview); //static void ddb_listview_size_allocate(GtkWidget *widget, GtkAllocation *allocation); //static void ddb_listview_realize(GtkWidget *widget); //static void ddb_listview_paint(GtkWidget *widget); -static void ddb_listview_destroy(GtkObject *object); +static void ddb_listview_destroy(GObject *object); static void ddb_listview_build_groups (DdbListview *listview); @@ -94,13 +95,11 @@ ddb_listview_free_groups (DdbListview *listview); ////// list functions //// void -ddb_listview_list_render (DdbListview *ps, int x, int y, int w, int h); +ddb_listview_list_render (DdbListview *ps, cairo_t *cr, int x, int y, int w, int h); void -ddb_listview_list_render_row_background (DdbListview *ps, DdbListviewIter it, int even, int cursor, int x, int y, int w, int h); +ddb_listview_list_render_row_background (DdbListview *ps, cairo_t *cr, DdbListviewIter it, int even, int cursor, int x, int y, int w, int h); void -ddb_listview_list_render_row_foreground (DdbListview *ps, DdbListviewIter it, DdbListviewIter group_it, int even, int cursor, int group_y, int x, int y, int w, int h); -//void -//ddb_listview_list_render_row (DdbListview *ps, int row, DdbListviewIter it); +ddb_listview_list_render_row_foreground (DdbListview *ps, cairo_t *cr, DdbListviewIter it, DdbListviewIter group_it, int even, int cursor, int group_y, int x, int y, int w, int h); void ddb_listview_list_track_dragdrop (DdbListview *ps, int y); int @@ -120,7 +119,7 @@ ddb_listview_get_row_pos (DdbListview *listview, int pos); ////// header functions //// void -ddb_listview_header_render (DdbListview *ps); +ddb_listview_header_render (DdbListview *ps, cairo_t *cr); ////// column management functions //// void @@ -148,9 +147,16 @@ ddb_listview_list_drag_data_received (GtkWidget *widget, gpointer user_data); gboolean +ddb_listview_header_draw (GtkWidget *widget, + cairo_t *cr, + gpointer user_data); +#if !GTK_CHECK_VERSION(3,0,0) + +gboolean ddb_listview_header_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); +#endif gboolean ddb_listview_header_configure_event (GtkWidget *widget, @@ -186,6 +192,11 @@ ddb_listview_list_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); +gboolean +ddb_listview_list_draw (GtkWidget *widget, + cairo_t *cr, + gpointer user_data); + void ddb_listview_list_realize (GtkWidget *widget, gpointer user_data); @@ -270,16 +281,16 @@ static void ddb_listview_class_init(DdbListviewClass *class) { GtkTableClass *widget_class = (GtkTableClass *) class; - GtkObjectClass *object_class = (GtkObjectClass *) class; + GObjectClass *object_class = (GObjectClass *) class; // FIXME!!! - object_class->destroy = ddb_listview_destroy; + //object_class->destroy = ddb_listview_destroy; } static void ddb_listview_init(DdbListview *listview) { // init instance - create all subwidgets, and insert into table - draw_init_font (GTK_WIDGET(listview)->style); + draw_init_font (gtk_widget_get_style (GTK_WIDGET(listview))); listview->rowheight = draw_get_listview_rowheight (); @@ -372,9 +383,15 @@ ddb_listview_init(DdbListview *listview) g_signal_connect ((gpointer) listview->scrollbar, "value_changed", G_CALLBACK (ddb_listview_vscroll_value_changed), NULL); +#if !GTK_CHECK_VERSION(3,0,0) g_signal_connect ((gpointer) listview->header, "expose_event", G_CALLBACK (ddb_listview_header_expose_event), NULL); +#else + g_signal_connect ((gpointer) listview->header, "draw", + G_CALLBACK (ddb_listview_header_draw), + NULL); +#endif g_signal_connect ((gpointer) listview->header, "configure_event", G_CALLBACK (ddb_listview_header_configure_event), NULL); @@ -390,9 +407,15 @@ ddb_listview_init(DdbListview *listview) g_signal_connect ((gpointer) listview->header, "button_release_event", G_CALLBACK (ddb_listview_header_button_release_event), NULL); +#if !GTK_CHECK_VERSION(3,0,0) g_signal_connect ((gpointer) listview->list, "expose_event", G_CALLBACK (ddb_listview_list_expose_event), NULL); +#else + g_signal_connect ((gpointer) listview->list, "draw", + G_CALLBACK (ddb_listview_list_draw), + NULL); +#endif g_signal_connect ((gpointer) listview->list, "realize", G_CALLBACK (ddb_listview_list_realize), NULL); @@ -443,7 +466,7 @@ GtkWidget * ddb_listview_new() } static void -ddb_listview_destroy(GtkObject *object) +ddb_listview_destroy(GObject *object) { DdbListview *listview; @@ -511,7 +534,7 @@ ddb_listview_list_configure_event (GtkWidget *widget, { DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); - draw_init_font (widget->style); + draw_init_font (gtk_widget_get_style (widget)); int height = draw_get_listview_rowheight (); if (height != ps->rowheight) { ps->rowheight = height; @@ -596,11 +619,15 @@ ddb_listview_list_pickpoint_y (DdbListview *listview, int y, DdbListviewGroup ** } void -ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) { +ddb_listview_list_render (DdbListview *listview, cairo_t *cr, int x, int y, int w, int h) { GtkWidget *treeview = theme_treeview; - if (treeview->style->depth == -1) { + +#if !GTK_CHECK_VERSION(3,0,0) +// FIXME? + if (gtk_widget_get_style (treeview)->depth == -1) { return; // drawing was called too early } +#endif int idx = 0; int abs_idx = 0; deadbeef->pl_lock (); @@ -614,7 +641,8 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) { abs_idx += grp->num_items; grp = grp->next; } - draw_begin ((uintptr_t)listview->list->window); + + draw_begin (cr); int ii = 0; while (grp && grp_y < y + h + listview->scrollpos) { @@ -626,9 +654,9 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) { } listview->binding->ref (it); if (grp_y + listview->grouptitle_height >= y + listview->scrollpos && grp_y < y + h + listview->scrollpos) { - ddb_listview_list_render_row_background (listview, NULL, idx & 1, 0, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, listview->grouptitle_height); + ddb_listview_list_render_row_background (listview, cr, NULL, idx & 1, 0, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, listview->grouptitle_height); if (listview->binding->draw_group_title && listview->grouptitle_height > 0) { - listview->binding->draw_group_title (listview, listview->list->window, it, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, listview->grouptitle_height); + listview->binding->draw_group_title (listview, cr, it, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, listview->grouptitle_height); } } for (int i = 0; i < grp->num_items; i++) { @@ -641,9 +669,12 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) { } if (grp_y + listview->grouptitle_height + (i+1) * listview->rowheight >= y + listview->scrollpos && grp_y + listview->grouptitle_height + i * listview->rowheight < y + h + listview->scrollpos) { - gdk_draw_rectangle (listview->list->window, listview->list->style->bg_gc[GTK_STATE_NORMAL], TRUE, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight); - ddb_listview_list_render_row_background (listview, it, (idx + 1 + i) & 1, (abs_idx+i) == listview->binding->cursor () ? 1 : 0, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight); - ddb_listview_list_render_row_foreground (listview, it, grp->head, (idx + 1 + i) & 1, (idx+i) == listview->binding->cursor () ? 1 : 0, i * listview->rowheight, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight); + GtkStyle *st = gtk_widget_get_style (listview->list); + cairo_set_source_rgb (cr, st->bg[GTK_STATE_NORMAL].red/65535.f, st->bg[GTK_STATE_NORMAL].green/65535.f, st->bg[GTK_STATE_NORMAL].blue/65535.f); + cairo_rectangle (cr, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight); + cairo_fill (cr); + ddb_listview_list_render_row_background (listview, cr, it, (idx + 1 + i) & 1, (abs_idx+i) == listview->binding->cursor () ? 1 : 0, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight); + ddb_listview_list_render_row_foreground (listview, cr, it, grp->head, (idx + 1 + i) & 1, (idx+i) == listview->binding->cursor () ? 1 : 0, i * listview->rowheight, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight); } DdbListviewIter next = listview->binding->next (it); listview->binding->unref (it); @@ -662,18 +693,23 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) { if (filler > 0) { int theming = !gtkui_override_listview_colors (); if (theming) { - gtk_paint_flat_box (treeview->style, listview->list->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, "cell_even_ruled", x, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, w, filler); +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_flat_box (gtk_widget_get_style (treeview), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, treeview, "cell_even_ruled", x, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, w, filler); +#else + gtk_paint_flat_box (gtk_widget_get_style (treeview), gtk_widget_get_window (treeview), GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, "cell_even_ruled", x, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, w, filler); +#endif } else { GdkColor clr; - GdkGC *gc = gdk_gc_new (listview->list->window); - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_listview_even_row_color (&clr), &clr)); - gdk_draw_rectangle (listview->list->window, gc, TRUE, x, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, w, filler); - g_object_unref (gc); + gtkui_get_listview_even_row_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + + cairo_rectangle (cr, x, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, w, filler); + cairo_fill (cr); } - ddb_listview_list_render_row_foreground (listview, NULL, grp->head, 0, 0, grp->num_items * listview->rowheight, -listview->hscrollpos, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, listview->totalwidth, filler); + ddb_listview_list_render_row_foreground (listview, cr, NULL, grp->head, 0, 0, grp->num_items * listview->rowheight, -listview->hscrollpos, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, listview->totalwidth, filler); } grp_y += grpheight; @@ -684,14 +720,18 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) { // gdk_draw_rectangle (listview->list->window, listview->list->style->bg_gc[GTK_STATE_NORMAL], TRUE, x, grp_y - listview->scrollpos, w, hh); int theming = !gtkui_override_listview_colors (); if (theming) { - gtk_paint_flat_box (treeview->style, listview->list->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, "cell_even_ruled", x, grp_y - listview->scrollpos, w, hh); +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_flat_box (gtk_widget_get_style (treeview), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, treeview, "cell_even_ruled", x, grp_y - listview->scrollpos, w, hh); +#else + gtk_paint_flat_box (gtk_widget_get_style (treeview), listview->list->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, "cell_even_ruled", x, grp_y - listview->scrollpos, w, hh); +#endif } else { GdkColor clr; - GdkGC *gc = gdk_gc_new (listview->list->window); - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_listview_even_row_color (&clr), &clr)); - gdk_draw_rectangle (listview->list->window, gc, TRUE, x, grp_y - listview->scrollpos, w, hh); - g_object_unref (gc); + gtkui_get_listview_even_row_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_rectangle (cr, x, grp_y - listview->scrollpos, w, hh); + cairo_fill (cr); } } deadbeef->pl_unlock (); @@ -699,24 +739,45 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) { } static void -ddb_listview_draw_dnd_marker (DdbListview *ps) { +ddb_listview_draw_dnd_marker (DdbListview *ps, cairo_t *cr) { if (ps->drag_motion_y < 0) { return; } int drag_motion_y = ps->drag_motion_y - ps->scrollpos; GtkWidget *widget = ps->list; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); GdkColor clr; gtkui_get_listview_cursor_color (&clr); - GdkGC *gc = gdk_gc_new (widget->window); - gdk_gc_set_rgb_fg_color (gc, &clr); - gdk_draw_rectangle (widget->window, gc, TRUE, 0, drag_motion_y-1, widget->allocation.width, 3); - gdk_draw_rectangle (widget->window, gc, TRUE, 0, drag_motion_y-3, 3, 7); - gdk_draw_rectangle (widget->window, gc, TRUE, widget->allocation.width-3, drag_motion_y-3, 3, 7); - g_object_unref (gc); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.0); + cairo_rectangle (cr, 0, drag_motion_y-1, a.width, 3); + cairo_fill (cr); + cairo_rectangle (cr, 0, drag_motion_y-3, 3, 7); + cairo_fill (cr); + cairo_rectangle (cr, a.width-3, drag_motion_y-3, 3, 7); + cairo_fill (cr); } +#if GTK_CHECK_VERSION(3,0,0) +gboolean +ddb_listview_list_draw (GtkWidget *widget, + cairo_t *cr, + gpointer user_data) +{ + DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); + widget = ps->list; + cairo_set_line_width (cr, 1); + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + // FIXME: clip region + ddb_listview_list_render (ps, cr, 0, 0, gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); + if (ps->drag_motion_y >= 0/* && ps->drag_motion_y-ps->scrollpos-3 < event->area.y+event->area.height && ps->drag_motion_y-ps->scrollpos+3 >= event->area.y*/) { + ddb_listview_draw_dnd_marker (ps, cr); + } + return FALSE; +} +#else gboolean ddb_listview_list_expose_event (GtkWidget *widget, GdkEventExpose *event, @@ -724,14 +785,15 @@ ddb_listview_list_expose_event (GtkWidget *widget, { DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); widget = ps->list; - if (widget->window) { - ddb_listview_list_render (ps, event->area.x, event->area.y, event->area.width, event->area.height); - } + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); + ddb_listview_list_render (ps, cr, event->area.x, event->area.y, event->area.width, event->area.height); if (ps->drag_motion_y >= 0 && ps->drag_motion_y-ps->scrollpos-3 < event->area.y+event->area.height && ps->drag_motion_y-ps->scrollpos+3 >= event->area.y) { - ddb_listview_draw_dnd_marker (ps); + ddb_listview_draw_dnd_marker (ps, cr); } + cairo_destroy (cr); return FALSE; } +#endif gboolean ddb_listview_vscroll_event (GtkWidget *widget, @@ -772,34 +834,42 @@ ddb_listview_vscroll_value_changed (GtkRange *widget, GtkWidget *widget = ps->list; int di = newscroll - ps->scrollpos; int d = abs (di); - int height = ps->list->allocation.height; + GtkAllocation a; + gtk_widget_get_allocation (ps->list, &a); + int height = a.height; if (d < height) { if (di > 0) { // scroll down // copy scrolled part of buffer - gdk_draw_drawable (ps->list->window, widget->style->black_gc, ps->list->window, 0, d, 0, 0, widget->allocation.width, widget->allocation.height-d); -// draw_drawable (ps->list->window, widget->style->black_gc, ps->list->window, 0, d, 0, 0, widget->allocation.width, widget->allocation.height-d); +#if !GTK_CHECK_VERSION(3,0,0) + // FIXME + gdk_draw_drawable (ps->list->window, widget->style->black_gc, ps->list->window, 0, d, 0, 0, a.width, a.height-d); +#else +// cairo_region_copy (); +#endif // redraw other part int start = height-d-1; ps->scrollpos = newscroll; - gtk_widget_queue_draw_area (ps->list, 0, start, ps->list->allocation.width, widget->allocation.height-start); -// ddb_listview_list_render (ps, 0, start, ps->list->allocation.width, widget->allocation.height-start); + // FIXME gtk_widget_queue_draw_area (ps->list, 0, start, ps->list->allocation.width, widget->allocation.height-start); } else { // scroll up // copy scrolled part of buffer +#if !GTK_CHECK_VERSION(3,0,0) + // FIXME gdk_draw_drawable (ps->list->window, widget->style->black_gc, ps->list->window, 0, 0, 0, d, widget->allocation.width, widget->allocation.height-d); - //draw_drawable (ps->list->window, widget->style->black_gc, ps->list->window, 0, 0, 0, d, widget->allocation.width, widget->allocation.height-d); +#else +// cairo_region_copy (); +#endif // redraw other part ps->scrollpos = newscroll; - gtk_widget_queue_draw_area (ps->list, 0, 0, ps->list->allocation.width, d+1); - //ddb_listview_list_render (ps, 0, 0, ps->list->allocation.width, d+1); + // FIXME gtk_widget_queue_draw_area (ps->list, 0, 0, ps->list->allocation.width, d+1); } } else { // scrolled more than view height, redraw everything ps->scrollpos = newscroll; - ddb_listview_list_render (ps, 0, 0, widget->allocation.width, widget->allocation.height); + // FIXME gtk_widget_queue_draw (ps->list); } gtk_widget_queue_draw (ps->list); // draw_drawable (widget->window, widget->style->black_gc, ps->list->window, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); @@ -825,10 +895,11 @@ ddb_listview_list_drag_motion (GtkWidget *widget, { DdbListview *pl = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); ddb_listview_list_track_dragdrop (pl, y); - int cnt = g_list_length (drag_context->targets); + GList *targets = gdk_drag_context_list_targets (drag_context); + int cnt = g_list_length (targets); int i; for (i = 0; i < cnt; i++) { - GdkAtom a = GDK_POINTER_TO_ATOM (g_list_nth_data (drag_context->targets, i)); + GdkAtom a = GDK_POINTER_TO_ATOM (g_list_nth_data (targets, i)); gchar *nm = gdk_atom_name (a); if (!strcmp (nm, "text/uri-list")) { g_free (nm); @@ -898,7 +969,8 @@ 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+1) * sizeof (uint32_t)); + GdkAtom target = gtk_selection_data_get_target (selection_data); + gtk_selection_data_set (selection_data, target, sizeof (uint32_t) * 8, (gchar *)ptr, (nsel+1) * sizeof (uint32_t)); free (ptr); } break; @@ -936,23 +1008,24 @@ ddb_listview_list_drag_data_received (GtkWidget *widget, if (sel != -1) { it = ps->binding->get_for_idx (sel); } - gchar *ptr=(char*)data->data; + gchar *ptr=(char*)gtk_selection_data_get_data (data); + gint len = gtk_selection_data_get_length (data); if (target_type == 0) { // uris // this happens when dropped from file manager - char *mem = malloc (data->length+1); - memcpy (mem, ptr, data->length); - mem[data->length] = 0; + char *mem = malloc (len+1); + memcpy (mem, ptr, len); + mem[len] = 0; // we don't pass control structure, but there's only one drag-drop view currently - ps->binding->external_drag_n_drop (it, mem, data->length); + ps->binding->external_drag_n_drop (it, mem, len); if (it) { UNREF (it); } } - else if (target_type == 1 && data->format == 32) { // list of 32bit ints, DDB_URI_LIST target + else if (target_type == 1 && gtk_selection_data_get_format(data) == 32) { // list of 32bit ints, DDB_URI_LIST target uint32_t *d= (uint32_t *)ptr; int plt = *d; d++; - int length = (data->length/4)-1; + int length = (len/4)-1; DdbListviewIter drop_before = it; // find last selected while (drop_before && ps->binding->is_selected (drop_before)) { @@ -962,7 +1035,8 @@ ddb_listview_list_drag_data_received (GtkWidget *widget, } ddb_playlist_t *p = deadbeef->plt_get_for_idx (plt); if (p) { - ps->binding->drag_n_drop (drop_before, p, d, length, drag_context->action == GDK_ACTION_COPY ? 1 : 0); + // FIXME + ps->binding->drag_n_drop (drop_before, p, d, length, gdk_drag_context_get_selected_action (drag_context) == GDK_ACTION_COPY ? 1 : 0); deadbeef->plt_unref (p); } if (drop_before) { @@ -1095,7 +1169,9 @@ ddb_listview_list_setup_vscroll (DdbListview *ps) { GtkWidget *list = ps->list; GtkWidget *scroll = ps->scrollbar; int vheight = ps->fullheight; - if (ps->fullheight <= ps->list->allocation.height) { + GtkAllocation a; + gtk_widget_get_allocation (ps->list, &a); + if (ps->fullheight <= a.height) { gtk_widget_hide (scroll); ps->scrollpos = 0; gtk_widget_queue_draw (ps->list); @@ -1106,7 +1182,7 @@ ddb_listview_list_setup_vscroll (DdbListview *ps) { ps->scrollpos = vheight-1; } } - int h = list->allocation.height; + int h = a.height; GtkAdjustment *adj = (GtkAdjustment*)gtk_adjustment_new (gtk_range_get_value (GTK_RANGE (scroll)), 0, vheight, SCROLL_STEP, h/2, h); gtk_range_set_adjustment (GTK_RANGE (scroll), adj); gtk_range_set_value (GTK_RANGE (scroll), ps->scrollpos); @@ -1115,15 +1191,17 @@ ddb_listview_list_setup_vscroll (DdbListview *ps) { void ddb_listview_list_setup_hscroll (DdbListview *ps) { GtkWidget *list = ps->list; - int w = list->allocation.width; + GtkAllocation a; + gtk_widget_get_allocation (ps->list, &a); + int w = a.width; int size = 0; DdbListviewColumn *c; for (c = ps->columns; c; c = c->next) { size += c->width; } ps->totalwidth = size; - if (ps->totalwidth < ps->list->allocation.width) { - ps->totalwidth = ps->list->allocation.width; + if (ps->totalwidth < a.width) { + ps->totalwidth = a.width; } if (w >= size) { size = 0; @@ -1178,35 +1256,6 @@ ddb_listview_list_get_drawinfo (DdbListview *listview, int row, DdbListviewGroup return -1; } -#if 0 -void -ddb_listview_list_render_row (DdbListview *listview, int row, DdbListviewIter it) { - DdbListviewGroup *grp; - int even; - int cursor; - int x, y, w, h; - int group_y; - if (ddb_listview_list_get_drawinfo (listview, row, &grp, &even, &cursor, &group_y, &x, &y, &w, &h) == -1) { - return; - } - - if (y + h <= 0) { - return; - } - - if (y > GTK_WIDGET (listview)->allocation.height) { - return; - } - - draw_begin ((uintptr_t)listview->list->window); - ddb_listview_list_render_row_background (listview, it, even, cursor, x, y, w, h); - if (it) { - ddb_listview_list_render_row_foreground (listview, it, grp->head, even, cursor, group_y, x, y, w, h); - } - draw_end (); -} -#endif - void ddb_listview_draw_row (DdbListview *listview, int row, DdbListviewIter it) { DdbListviewGroup *grp; @@ -1222,51 +1271,64 @@ ddb_listview_draw_row (DdbListview *listview, int row, DdbListviewIter it) { return; } - if (y > GTK_WIDGET (listview)->allocation.height) { + GtkAllocation a; + gtk_widget_get_allocation (GTK_WIDGET (listview->list), &a); + + if (y > a.height) { return; } - gtk_widget_queue_draw_area (listview->list, 0, y, listview->list->allocation.width, h); + gtk_widget_queue_draw_area (listview->list, 0, y, a.width, h); } // coords passed are window-relative void -ddb_listview_list_render_row_background (DdbListview *ps, DdbListviewIter it, int even, int cursor, int x, int y, int w, int h) { +ddb_listview_list_render_row_background (DdbListview *ps, cairo_t *cr, DdbListviewIter it, int even, int cursor, int x, int y, int w, int h) { // draw background GtkWidget *treeview = theme_treeview; int theming = !gtkui_override_listview_colors (); if (theming) { - if (treeview->style->depth == -1) { +#if !GTK_CHECK_VERSION(3,0,0) + // FIXME + if (gtk_widget_get_style (treeview)->depth == -1) { return; // drawing was called too early } GTK_WIDGET_SET_FLAGS (GTK_WIDGET (treeview), GTK_HAS_FOCUS); - //G_OBJECT_FLAGS (treeview) |= GTK_HAS_FOCUS; +#endif } 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->list->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_flat_box (gtk_widget_get_style (treeview), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); +#else + gtk_paint_flat_box (gtk_widget_get_style (treeview), ps->list->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); +#endif } else { GdkColor clr; - GdkGC *gc = gdk_gc_new (ps->list->window); - gdk_gc_set_rgb_fg_color (gc, even ? (gtkui_get_listview_even_row_color (&clr), &clr) : (gtkui_get_listview_odd_row_color (&clr), &clr)); - gdk_draw_rectangle (ps->list->window, gc, TRUE, x, y, w, h); - g_object_unref (gc); + gtkui_get_listview_even_row_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_rectangle (cr, x, y, w, h); + cairo_fill (cr); } } if (sel) { if (theming) { - gtk_paint_flat_box (treeview->style, ps->list->window, GTK_STATE_SELECTED, GTK_SHADOW_NONE, NULL, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_flat_box (gtk_widget_get_style (treeview), cr, GTK_STATE_SELECTED, GTK_SHADOW_NONE, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); +#else + gtk_paint_flat_box (gtk_widget_get_style (treeview), ps->list->window, GTK_STATE_SELECTED, GTK_SHADOW_NONE, NULL, treeview, even ? "cell_even_ruled" : "cell_odd_ruled", x, y, w, h); +#endif } else { GdkColor clr; - GdkGC *gc = gdk_gc_new (ps->list->window); - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_listview_selection_color (&clr), &clr)); - gdk_draw_rectangle (ps->list->window, gc, TRUE, x, y, w, h); - g_object_unref (gc); + gtkui_get_listview_selection_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_rectangle (cr, x, y, w, h); + cairo_fill (cr); } } if (cursor) { @@ -1274,24 +1336,27 @@ ddb_listview_list_render_row_background (DdbListview *ps, DdbListviewIter it, in // but we want it anyway //treeview->style->fg_gc[GTK_STATE_NORMAL] GdkColor clr; - GdkGC *gc = gdk_gc_new (ps->list->window); - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_listview_cursor_color (&clr), &clr)); - gdk_draw_rectangle (ps->list->window, gc, FALSE, x, y, w-1, h-1); - g_object_unref (gc); + gtkui_get_listview_cursor_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_rectangle (cr, x, y, w-1, h-1); + cairo_stroke (cr); } } void -ddb_listview_list_render_row_foreground (DdbListview *ps, DdbListviewIter it, DdbListviewIter group_it, int even, int cursor, int group_y, int x, int y, int w, int h) { +ddb_listview_list_render_row_foreground (DdbListview *ps, cairo_t *cr, DdbListviewIter it, DdbListviewIter group_it, int even, int cursor, int group_y, int x, int y, int w, int h) { int width, height; - draw_get_canvas_size ((uintptr_t)ps->list->window, &width, &height); + GtkAllocation a; + gtk_widget_get_allocation (ps->list, &a); + width = a.width; + height = a.height; if (it && ps->binding->is_selected (it)) { - GdkColor *clr = &theme_treeview->style->fg[GTK_STATE_SELECTED]; + GdkColor *clr = >k_widget_get_style (theme_treeview)->fg[GTK_STATE_SELECTED]; float rgb[3] = { clr->red/65535.f, clr->green/65535.f, clr->blue/65535.f }; draw_set_fg_color (rgb); } else { - GdkColor *clr = &theme_treeview->style->fg[GTK_STATE_NORMAL]; + GdkColor *clr = >k_widget_get_style (theme_treeview)->fg[GTK_STATE_NORMAL]; float rgb[3] = { clr->red/65535.f, clr->green/65535.f, clr->blue/65535.f }; draw_set_fg_color (rgb); } @@ -1299,15 +1364,15 @@ ddb_listview_list_render_row_foreground (DdbListview *ps, DdbListviewIter it, Dd int cidx = 0; for (c = ps->columns; c; c = c->next, cidx++) { int cw = c->width; - ps->binding->draw_column_data (ps, ps->list->window, it, ps->grouptitle_height > 0 ? group_it : NULL, cidx, group_y, x, y, cw, h); + ps->binding->draw_column_data (ps, cr, it, ps->grouptitle_height > 0 ? group_it : NULL, cidx, group_y, x, y, cw, h); x += cw; } } void -ddb_listview_header_expose (DdbListview *ps, int x, int y, int w, int h) { - ddb_listview_header_render (ps); +ddb_listview_header_expose (DdbListview *ps, cairo_t *cr, int x, int y, int w, int h) { + ddb_listview_header_render (ps, cr); } void @@ -1804,6 +1869,9 @@ ddb_listview_list_mousemove (DdbListview *ps, GdkEventMotion *ev, int ex, int ey } } + GtkAllocation a; + gtk_widget_get_allocation (ps->list, &a); + if (ey < 10) { ps->scroll_mode = 0; ps->scroll_pointer_y = ey; @@ -1815,7 +1883,7 @@ ddb_listview_list_mousemove (DdbListview *ps, GdkEventMotion *ev, int ex, int ey g_idle_add (ddb_listview_list_scroll_cb, ps); } } - else if (ey > ps->list->allocation.height-10) { + else if (ey > a.height-10) { ps->scroll_mode = 0; ps->scroll_pointer_y = ey; // start scrolling down @@ -1870,7 +1938,7 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { cursor++; } else { - gtk_range_set_value (GTK_RANGE (range), adj->upper); + gtk_range_set_value (GTK_RANGE (range), gtk_adjustment_get_upper (adj)); } } else if (keyval == GDK_Up) { @@ -1878,7 +1946,7 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { cursor--; } else { - gtk_range_set_value (GTK_RANGE (range), adj->lower); + gtk_range_set_value (GTK_RANGE (range), gtk_adjustment_get_lower (adj)); if (cursor < 0 && ps->binding->count () > 0) { cursor = 0; } @@ -1892,14 +1960,14 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { } } else { - gtk_range_set_value (GTK_RANGE (range), adj->upper); + gtk_range_set_value (GTK_RANGE (range), gtk_adjustment_get_upper (adj)); } } else if (keyval == GDK_Page_Up) { if (cursor > 0) { cursor -= 10; if (cursor < 0) { - gtk_range_set_value (GTK_RANGE (range), adj->lower); + gtk_range_set_value (GTK_RANGE (range), gtk_adjustment_get_upper (adj)); cursor = 0; } } @@ -1907,16 +1975,16 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { if (cursor < 0 && ps->binding->count () > 0) { cursor = 0; } - gtk_range_set_value (GTK_RANGE (range), adj->lower); + gtk_range_set_value (GTK_RANGE (range), gtk_adjustment_get_lower (adj)); } } else if (keyval == GDK_End) { cursor = ps->binding->count () - 1; - gtk_range_set_value (GTK_RANGE (range), adj->upper); + gtk_range_set_value (GTK_RANGE (range), gtk_adjustment_get_upper (adj)); } else if (keyval == GDK_Home) { cursor = 0; - gtk_range_set_value (GTK_RANGE (range), adj->lower); + gtk_range_set_value (GTK_RANGE (range), gtk_adjustment_get_lower (adj)); } else if (keyval == GDK_Delete) { ps->binding->delete_selected (); @@ -1927,14 +1995,16 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { } if (state & GDK_SHIFT_MASK) { + GtkAllocation a; + gtk_widget_get_allocation (ps->list, &a); if (cursor != prev) { int newscroll = ps->scrollpos; int cursor_scroll = ddb_listview_get_row_pos (ps, cursor); if (cursor_scroll < ps->scrollpos) { newscroll = cursor_scroll; } - else if (cursor_scroll >= ps->scrollpos + ps->list->allocation.height) { - newscroll = cursor_scroll - ps->list->allocation.height + 1; + else if (cursor_scroll >= ps->scrollpos + a.height) { + newscroll = cursor_scroll - a.height + 1; if (newscroll < 0) { newscroll = 0; } @@ -2020,9 +2090,11 @@ ddb_listview_dragdrop_get_row_from_coord (DdbListview *listview, int y) { void ddb_listview_list_track_dragdrop (DdbListview *ps, int y) { GtkWidget *widget = ps->list; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); if (ps->drag_motion_y != -1) { // erase previous track - gtk_widget_queue_draw_area (ps->list, 0, ps->drag_motion_y-ps->scrollpos-3, widget->allocation.width, 7); + gtk_widget_queue_draw_area (ps->list, 0, ps->drag_motion_y-ps->scrollpos-3, a.width, 7); } if (y == -1) { @@ -2045,7 +2117,10 @@ ddb_listview_list_track_dragdrop (DdbListview *ps, int y) { ps->drag_motion_y = ddb_listview_get_row_pos (ps, sel); } - ddb_listview_draw_dnd_marker (ps); +#if !GTK_CHECK_VERSION(3,0,0) + // FIXME + ddb_listview_draw_dnd_marker (ps, cr); +#endif if (y < 10) { ps->scroll_pointer_y = y; @@ -2058,7 +2133,7 @@ ddb_listview_list_track_dragdrop (DdbListview *ps, int y) { g_idle_add (ddb_listview_list_scroll_cb, ps); } } - else if (y > ps->list->allocation.height-10) { + else if (y > a.height-10) { ps->scroll_mode = 1; ps->scroll_pointer_y = y; // start scrolling up @@ -2089,26 +2164,40 @@ ddb_listview_list_drag_end (GtkWidget *widget, // #define HEADERS_GTKTHEME void -ddb_listview_header_render (DdbListview *ps) { +ddb_listview_header_render (DdbListview *ps, cairo_t *cr) { GtkWidget *widget = ps->header; int x = -ps->hscrollpos; int w = 100; - int h = widget->allocation.height; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + int h = a.height; const char *detail = "button"; // fill background and draw bottom line #if !HEADERS_GTKTHEME - GdkGC *gc = gdk_gc_new (ps->header->window); GdkColor clr; - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_tabstrip_base_color (&clr), &clr)); - gdk_draw_rectangle (ps->header->window, gc, TRUE, 0, 0, widget->allocation.width, widget->allocation.height); - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_tabstrip_dark_color (&clr), &clr)); - gdk_draw_line (ps->header->window, gc, 0, widget->allocation.height-1, widget->allocation.width, widget->allocation.height-1); + gtkui_get_tabstrip_base_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_rectangle (cr, 0, 0, a.width, a.height); + cairo_fill (cr); + gtkui_get_tabstrip_dark_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_move_to (cr, 0, a.height-1); + cairo_line_to (cr, a.width, a.height-1); + cairo_stroke (cr); +#else +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_box (gtk_widget_get_style (theme_button), cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT, widget, detail, -10, -10, a.width+20, a.height+20); #else - gtk_paint_box (theme_button->style, ps->header->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, detail, -10, -10, widget->allocation.width+20, widget->allocation.height+20); - gdk_draw_line (ps->header->window, widget->style->mid_gc[GTK_STATE_NORMAL], 0, widget->allocation.height-1, widget->allocation.width, widget->allocation.height-1); + gtk_paint_box (theme_button->style, ps->header->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, detail, -10, -10, a.width+20, a.height+20); +#endif + clr = gtk_widget_get_style (widget)->mid[GTK_STATE_NORMAL] + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_move_to (cr, 0, a.height-1); + cairo_line_to (cr, a.width, a.height-1); + cairo_stroke (cr); #endif - draw_begin ((uintptr_t)ps->header->window); + draw_begin (cr); x = -ps->hscrollpos; DdbListviewColumn *c; int need_draw_moving = 0; @@ -2127,21 +2216,33 @@ ddb_listview_header_render (DdbListview *ps) { } #endif if (ps->header_dragging < 0 || idx != ps->header_dragging) { - if (xx >= widget->allocation.width) { + if (xx >= a.width) { continue; } int arrow_sz = 10; int sort = c->sort_order; if (w > 0) { #if !HEADERS_GTKTHEME - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_tabstrip_dark_color (&clr), &clr)); - gdk_draw_line (ps->header->window, gc, xx+w - 2, 2, xx+w - 2, h-4); - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_tabstrip_light_color (&clr), &clr)); - gdk_draw_line (ps->header->window, gc, xx+w - 1, 2, xx+w - 1, h-4); + gtkui_get_tabstrip_dark_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_move_to (cr, xx+w - 2, 2); + cairo_line_to (cr, xx+w - 2, h-4); + cairo_stroke (cr); + + gtkui_get_tabstrip_light_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + + cairo_move_to (cr, xx+w - 1, 2); + cairo_line_to (cr, xx+w - 1, h-4); + cairo_stroke (cr); +#else +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_vline (gtk_widget_get_style (widget), cr, GTK_STATE_NORMAL, widget, NULL, 2, h-4, xx+w - 2); #else gtk_paint_vline (widget->style, ps->header->window, GTK_STATE_NORMAL, NULL, widget, NULL, 2, h-4, xx+w - 2); #endif - GdkColor *gdkfg = &theme_button->style->fg[0]; +#endif + GdkColor *gdkfg = >k_widget_get_style (theme_button)->fg[0]; float fg[3] = {(float)gdkfg->red/0xffff, (float)gdkfg->green/0xffff, (float)gdkfg->blue/0xffff}; draw_set_fg_color (fg); int ww = w-10; @@ -2155,7 +2256,11 @@ ddb_listview_header_render (DdbListview *ps) { } if (sort) { int dir = sort == 1 ? GTK_ARROW_DOWN : GTK_ARROW_UP; - gtk_paint_arrow (widget->style, ps->header->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, NULL, dir, TRUE, xx + w-arrow_sz-5, widget->allocation.height/2-arrow_sz/2, arrow_sz, arrow_sz); +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_arrow (gtk_widget_get_style (widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, widget, NULL, dir, TRUE, xx + w-arrow_sz-5, a.height/2-arrow_sz/2, arrow_sz, arrow_sz); +#else + gtk_paint_arrow (widget->style, ps->header->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, NULL, dir, TRUE, xx + w-arrow_sz-5, a.height/2-arrow_sz/2, arrow_sz, arrow_sz); +#endif } } else { @@ -2180,16 +2285,24 @@ ddb_listview_header_render (DdbListview *ps) { } #endif // draw empty slot - if (x < widget->allocation.width) { + if (x < a.width) { +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_box (gtk_widget_get_style (theme_button), cr, GTK_STATE_ACTIVE, GTK_SHADOW_ETCHED_IN, widget, "button", x, 0, w, h); +#else gtk_paint_box (theme_button->style, ps->header->window, GTK_STATE_ACTIVE, GTK_SHADOW_ETCHED_IN, NULL, widget, "button", x, 0, w, h); +#endif } x = ps->col_movepos - ps->hscrollpos; - if (x >= widget->allocation.width) { + if (x >= a.width) { break; } if (w > 0) { +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_box (gtk_widget_get_style (theme_button), cr, GTK_STATE_SELECTED, GTK_SHADOW_OUT, widget, "button", x, 0, w, h); +#else gtk_paint_box (theme_button->style, ps->header->window, GTK_STATE_SELECTED, GTK_SHADOW_OUT, NULL, widget, "button", x, 0, w, h); - GdkColor *gdkfg = &theme_button->style->fg[GTK_STATE_SELECTED]; +#endif + GdkColor *gdkfg = >k_widget_get_style (theme_button)->fg[GTK_STATE_SELECTED]; float fg[3] = {(float)gdkfg->red/0xffff, (float)gdkfg->green/0xffff, (float)gdkfg->blue/0xffff}; draw_set_fg_color (fg); draw_text (x + 5, 3, c->width-10, 0, c->title); @@ -2200,21 +2313,34 @@ ddb_listview_header_render (DdbListview *ps) { } } draw_end (); +} -#if !HEADERS_GTKTHEME - g_object_unref (gc); -#endif +gboolean +ddb_listview_header_draw (GtkWidget *widget, + cairo_t *cr, + gpointer user_data) { + DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); + // FIXME: clip region + cairo_set_line_width (cr, 1); + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + ddb_listview_header_expose (ps, cr, 0, 0, gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); + return FALSE; } + +#if !GTK_CHECK_VERSION(3,0,0) gboolean ddb_listview_header_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); - ddb_listview_header_expose (ps, event->area.x, event->area.y, event->area.width, event->area.height); + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); + ddb_listview_header_expose (ps, cr, event->area.x, event->area.y, event->area.width, event->area.height); + cairo_destroy (cr); return FALSE; } +#endif gboolean @@ -2223,9 +2349,11 @@ ddb_listview_header_configure_event (GtkWidget *widget, gpointer user_data) { DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); - draw_init_font (widget->style); + draw_init_font (gtk_widget_get_style (widget)); int height = draw_get_listview_rowheight (); - if (height != widget->allocation.height) { + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + if (height != a.height) { gtk_widget_set_size_request (widget, -1, height); } return FALSE; @@ -2276,7 +2404,7 @@ ddb_listview_header_motion_notify_event (GtkWidget *widget, } } if (!ps->header_prepare && ps->header_dragging >= 0) { - gdk_window_set_cursor (widget->window, ps->cursor_drag); + gdk_window_set_cursor (gtk_widget_get_window (widget), ps->cursor_drag); DdbListviewColumn *c; int i; for (i = 0, c = ps->columns; i < ps->header_dragging && c; c = c->next, i++); @@ -2314,7 +2442,7 @@ ddb_listview_header_motion_notify_event (GtkWidget *widget, else if (ps->header_sizing >= 0) { ps->last_header_motion_ev = event->time; ps->prev_header_x = ev_x; - gdk_window_set_cursor (widget->window, ps->cursor_sz); + gdk_window_set_cursor (gtk_widget_get_window (widget), ps->cursor_sz); // get column start pos int x = -ps->hscrollpos; int i = 0; @@ -2343,15 +2471,15 @@ ddb_listview_header_motion_notify_event (GtkWidget *widget, int w = c->width; if (w > 0) { // ignore collapsed columns (hack for search window) if (ev_x >= x + w - 2 && ev_x <= x + w) { - gdk_window_set_cursor (widget->window, ps->cursor_sz); + gdk_window_set_cursor (gtk_widget_get_window (widget), ps->cursor_sz); break; } else { - gdk_window_set_cursor (widget->window, NULL); + gdk_window_set_cursor (gtk_widget_get_window (widget), NULL); } } else { - gdk_window_set_cursor (widget->window, NULL); + gdk_window_set_cursor (gtk_widget_get_window (widget), NULL); } x += w; } @@ -2464,11 +2592,11 @@ ddb_listview_header_button_release_event (GtkWidget *widget, for (c = ps->columns; c; c = c->next) { int w = c->width; if (event->x >= x + w - 2 && event->x <= x + w) { - gdk_window_set_cursor (widget->window, ps->cursor_sz); + gdk_window_set_cursor (gtk_widget_get_window (widget), ps->cursor_sz); break; } else { - gdk_window_set_cursor (widget->window, NULL); + gdk_window_set_cursor (gtk_widget_get_window (widget), NULL); } x += w; } @@ -2517,11 +2645,13 @@ ddb_listview_set_cursor_cb (gpointer data) { int cursor_scroll = ddb_listview_get_row_pos (sc->pl, sc->cursor); int newscroll = sc->pl->scrollpos; + GtkAllocation a; + gtk_widget_get_allocation (sc->pl->list, &a); if (cursor_scroll < sc->pl->scrollpos) { newscroll = cursor_scroll; } - else if (cursor_scroll + sc->pl->rowheight >= sc->pl->scrollpos + sc->pl->list->allocation.height) { - newscroll = cursor_scroll + sc->pl->rowheight - sc->pl->list->allocation.height + 1; + else if (cursor_scroll + sc->pl->rowheight >= sc->pl->scrollpos + a.height) { + newscroll = cursor_scroll + sc->pl->rowheight - a.height + 1; if (newscroll < 0) { newscroll = 0; } @@ -2657,8 +2787,10 @@ ddb_listview_get_iter_from_coord (DdbListview *listview, int x, int y) { void ddb_listview_scroll_to (DdbListview *listview, int pos) { pos = ddb_listview_get_row_pos (listview, pos); - if (pos < listview->scrollpos || pos >= listview->scrollpos + listview->list->allocation.height) { - gtk_range_set_value (GTK_RANGE (listview->scrollbar), pos - listview->list->allocation.height/2); + GtkAllocation a; + gtk_widget_get_allocation (listview->list, &a); + if (pos < listview->scrollpos || pos >= listview->scrollpos + a.height) { + gtk_range_set_value (GTK_RANGE (listview->scrollbar), pos - a.height/2); } } int diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h index b22469ed..f3f9121c 100644 --- a/plugins/gtkui/ddblistview.h +++ b/plugins/gtkui/ddblistview.h @@ -73,8 +73,8 @@ typedef struct { void (*external_drag_n_drop) (DdbListviewIter before, char *mem, int length); // callbacks - void (*draw_group_title) (DdbListview *listview, GdkDrawable *drawable, DdbListviewIter iter, int x, int y, int width, int height); - void (*draw_column_data) (DdbListview *listview, GdkDrawable *drawable, DdbListviewIter iter, DdbListviewIter group_iter, int column, int group_y, int x, int y, int width, int height); + void (*draw_group_title) (DdbListview *listview, cairo_t *drawable, DdbListviewIter iter, int x, int y, int width, int height); + void (*draw_column_data) (DdbListview *listview, cairo_t *drawable, DdbListviewIter iter, DdbListviewIter group_iter, int column, int group_y, int x, int y, int width, int height); void (*list_context_menu) (DdbListview *listview, DdbListviewIter iter, int idx); void (*header_context_menu) (DdbListview *listview, int col); void (*handle_doubleclick) (DdbListview *listview, DdbListviewIter iter, int idx); diff --git a/plugins/gtkui/ddbseekbar.c b/plugins/gtkui/ddbseekbar.c index e07e15d5..bdfb7845 100644 --- a/plugins/gtkui/ddbseekbar.c +++ b/plugins/gtkui/ddbseekbar.c @@ -57,8 +57,13 @@ enum { }; static void ddb_seekbar_real_realize (GtkWidget* base); static void ddb_seekbar_real_unrealize (GtkWidget* base); +#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); +#endif static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requisition); static gboolean ddb_seekbar_real_expose_event (GtkWidget* base, GdkEventExpose* event); +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); @@ -82,6 +87,23 @@ static void ddb_seekbar_real_unrealize (GtkWidget* base) { GTK_WIDGET_CLASS (ddb_seekbar_parent_class)->unrealize (GTK_WIDGET (self)); } +#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); + + *minimal_width = *natural_width = requisition.width; +} + +static void ddb_seekbar_get_preferred_height (GtkWidget* widget, gint *minimal_height, gint *natural_height) { + GtkRequisition requisition; + + ddb_seekbar_real_size_request (widget, &requisition); + + *minimal_height = *natural_height = requisition.height; +} +#endif static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requisition) { DdbSeekbar * self; @@ -92,15 +114,16 @@ static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requ } } +static gboolean ddb_seekbar_real_draw (GtkWidget* base, cairo_t *cr) { + seekbar_draw (base, cr); + return TRUE; +} static gboolean ddb_seekbar_real_expose_event (GtkWidget* base, GdkEventExpose* event) { - DdbSeekbar * self; - gboolean result = FALSE; - self = (DdbSeekbar*) base; - g_return_val_if_fail (event != NULL, FALSE); - seekbar_draw (GTK_WIDGET (self)); - result = TRUE; - return result; + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (base)); + ddb_seekbar_real_draw (base, cr); + cairo_destroy (cr); + return TRUE; } @@ -184,8 +207,14 @@ static void ddb_seekbar_class_init (DdbSeekbarClass * klass) { ddb_seekbar_parent_class = g_type_class_peek_parent (klass); GTK_WIDGET_CLASS (klass)->realize = ddb_seekbar_real_realize; GTK_WIDGET_CLASS (klass)->unrealize = ddb_seekbar_real_unrealize; +#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; +#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; diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c index b21e58ef..093d5fbb 100644 --- a/plugins/gtkui/ddbtabstrip.c +++ b/plugins/gtkui/ddbtabstrip.c @@ -64,12 +64,15 @@ ddb_tabstrip_send_configure (DdbTabStrip *darea) widget = GTK_WIDGET (darea); - event->configure.window = g_object_ref (widget->window); + event->configure.window = g_object_ref (gtk_widget_get_window(widget)); 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; + + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + event->configure.x = a.x; + event->configure.y = a.y; + event->configure.width = a.width; + event->configure.height = a.height; gtk_widget_event (widget, event); gdk_event_free (event); @@ -81,33 +84,39 @@ ddb_tabstrip_realize (GtkWidget *widget) { GdkWindowAttr attributes; gint attributes_mask; - if (GTK_WIDGET_FLAGS (widget)>K_NO_WINDOW/*GTK_WIDGET_NO_WINDOW (widget)*/) + if (!gtk_widget_get_has_window (widget)) { GTK_WIDGET_CLASS (ddb_tabstrip_parent_class)->realize (widget); } else { - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + gtk_widget_set_realized (widget, TRUE); 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; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + attributes.x = a.x; + attributes.y = a.y; + attributes.width = a.width; + attributes.height = a.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); +#if !GTK_CHECK_VERSION(3,0,0) attributes.colormap = gtk_widget_get_colormap (widget); +#endif 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; + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; +#if !GTK_CHECK_VERSION(3,0,0) + attributes_mask |= GDK_WA_COLORMAP; +#endif - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, darea); + gtk_widget_set_window(widget, gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask)); + gdk_window_set_user_data (gtk_widget_get_window(widget), darea); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_widget_set_style (widget, gtk_style_attach (gtk_widget_get_style (widget), gtk_widget_get_window(widget))); + gtk_style_set_background (gtk_widget_get_style (widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL); } ddb_tabstrip_send_configure (DDB_TABSTRIP (widget)); @@ -128,12 +137,12 @@ ddb_tabstrip_size_allocate (GtkWidget *widget, g_return_if_fail (DDB_IS_TABSTRIP (widget)); g_return_if_fail (allocation != NULL); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); - if (GTK_WIDGET_FLAGS(widget)>K_REALIZED/*GTK_WIDGET_REALIZED (widget)*/) + if (gtk_widget_get_realized (widget)) { - if (!(GTK_WIDGET_FLAGS (widget)>K_NO_WINDOW)/*GTK_WIDGET_NO_WINDOW (widget)*/) - gdk_window_move_resize (widget->window, + if (gtk_widget_get_has_window (widget)) + gdk_window_move_resize (gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -159,6 +168,11 @@ on_tabstrip_configure_event (GtkWidget *widget, GdkEventConfigure *event); gboolean +on_tabstrip_draw (GtkWidget *widget, + cairo_t *cr); + + +gboolean on_tabstrip_expose_event (GtkWidget *widget, GdkEventExpose *event); @@ -202,7 +216,7 @@ static int get_tab_under_cursor (DdbTabStrip *ts, int x); static void -ddb_tabstrip_destroy(GtkObject *object) +ddb_tabstrip_destroy(GObject *object) { DdbTabStrip *tabstrip; @@ -216,10 +230,14 @@ static void ddb_tabstrip_class_init(DdbTabStripClass *class) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - GtkObjectClass *object_class = (GtkObjectClass *) class; +#if !GTK_CHECK_VERSION(3,0,0) +// FIXME? + widget_class->expose_event = on_tabstrip_expose_event; +#else + widget_class->draw = on_tabstrip_draw; +#endif widget_class->realize = ddb_tabstrip_realize; widget_class->size_allocate = ddb_tabstrip_size_allocate; - widget_class->expose_event = on_tabstrip_expose_event; widget_class->button_press_event = on_tabstrip_button_press_event; widget_class->button_release_event = on_tabstrip_button_release_event; widget_class->configure_event = on_tabstrip_configure_event; @@ -231,7 +249,7 @@ ddb_tabstrip_class_init(DdbTabStripClass *class) widget_class->drag_data_received = on_tabstrip_drag_data_received; widget_class->drag_leave = on_tabstrip_drag_leave; - object_class->destroy = ddb_tabstrip_destroy; +// FIXME? object_class->destroy = ddb_tabstrip_destroy; } gboolean @@ -255,23 +273,24 @@ on_tabstrip_drag_data_received (GtkWidget *widget, { DdbListview *ps = DDB_LISTVIEW (lookup_widget (mainwin, "playlist")); - gchar *ptr=(char*)data->data; + gchar *ptr=(char*)gtk_selection_data_get_data (data); + int len = gtk_selection_data_get_length (data); if (target_type == 0) { // uris // this happens when dropped from file manager - char *mem = malloc (data->length+1); - memcpy (mem, ptr, data->length); - mem[data->length] = 0; + char *mem = malloc (len+1); + memcpy (mem, ptr, len); + mem[len] = 0; // we don't pass control structure, but there's only one drag-drop view currently - ps->binding->external_drag_n_drop (NULL, mem, data->length); + ps->binding->external_drag_n_drop (NULL, mem, len); } else if (target_type == 1) { uint32_t *d= (uint32_t *)ptr; int plt = *d; d++; - int length = (data->length/4)-1; + int length = (len/4)-1; ddb_playlist_t *p = deadbeef->plt_get_for_idx (plt); if (p) { - ps->binding->drag_n_drop (NULL, p, d, length, drag_context->action == GDK_ACTION_COPY ? 1 : 0); + ps->binding->drag_n_drop (NULL, p, d, length, gdk_drag_context_get_selected_action (drag_context) == GDK_ACTION_COPY ? 1 : 0); deadbeef->plt_unref (p); } } @@ -321,8 +340,18 @@ static int min_tab_size = 80; static int tab_moved = 0; +static void +cairo_draw_lines (cairo_t *cr, GdkPoint *pts, int cnt) { + cairo_new_path (cr); + cairo_move_to (cr, pts[0].x, pts[0].y); + for (int i = 1; i < cnt; i++) { + cairo_line_to (cr, pts[i].x, pts[i].y); + } + cairo_close_path (cr); +} + void -ddb_tabstrip_draw_tab (GtkWidget *widget, GdkDrawable *drawable, int idx, int selected, int x, int y, int w, int h) { +ddb_tabstrip_draw_tab (GtkWidget *widget, cairo_t *cr, int idx, int selected, int x, int y, int w, int h) { GdkPoint points_filled[] = { { x+2, y + h }, { x+2, y + 2 }, @@ -349,11 +378,10 @@ ddb_tabstrip_draw_tab (GtkWidget *widget, GdkDrawable *drawable, int idx, int se { x + w-3, y + h - 2 }, { 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 = gdk_gc_new (drawable); - GdkGC *outer_frame = gdk_gc_new (drawable); - GdkGC *inner_frame = gdk_gc_new (drawable); - GdkColor clr; + //gdk_draw_rectangle (gtk_widget_get_window(widget), widget->style->black_gc, FALSE, x-1, y-1, w+2, h+2); + GdkColor clr_bg; + GdkColor clr_outer_frame; + GdkColor clr_inner_frame; int fallback = 1; deadbeef->pl_lock (); ddb_playlist_t *plt = deadbeef->plt_get_for_idx (idx); @@ -363,35 +391,36 @@ ddb_tabstrip_draw_tab (GtkWidget *widget, GdkDrawable *drawable, int idx, int se int r, g, b; if (3 == sscanf (bgclr, "%02x%02x%02x", &r, &g, &b)) { fallback = 0; - clr.red = r * 0x101; - clr.green = g * 0x101; - clr.blue = b * 0x101; + clr_bg.red = r * 0x101; + clr_bg.green = g * 0x101; + clr_bg.blue = b * 0x101; } } deadbeef->pl_unlock (); if (selected) { if (fallback) { - gtkui_get_tabstrip_base_color (&clr); + gtkui_get_tabstrip_base_color (&clr_bg); } - gdk_gc_set_rgb_fg_color (bg, &clr); - gdk_gc_set_rgb_fg_color (outer_frame, (gtkui_get_tabstrip_dark_color (&clr), &clr)); - gdk_gc_set_rgb_fg_color (inner_frame, (gtkui_get_tabstrip_light_color (&clr), &clr)); + gtkui_get_tabstrip_dark_color (&clr_outer_frame); + gtkui_get_tabstrip_light_color (&clr_inner_frame); } else { if (fallback) { - gtkui_get_tabstrip_mid_color (&clr); + gtkui_get_tabstrip_mid_color (&clr_bg); } - gdk_gc_set_rgb_fg_color (bg, &clr); - gdk_gc_set_rgb_fg_color (outer_frame, (gtkui_get_tabstrip_dark_color (&clr), &clr)); - gdk_gc_set_rgb_fg_color (inner_frame, (gtkui_get_tabstrip_mid_color (&clr), &clr)); + gtkui_get_tabstrip_dark_color (&clr_outer_frame); + gtkui_get_tabstrip_mid_color (&clr_inner_frame); } - 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); + cairo_set_source_rgb (cr, clr_bg.red/65535.f, clr_bg.green/65535.f, clr_bg.blue/65535.0); + cairo_draw_lines (cr, points_filled, 4); + cairo_fill (cr); + cairo_set_source_rgb (cr, clr_outer_frame.red/65535.f, clr_outer_frame.green/65535.f, clr_outer_frame.blue/65535.0); + cairo_draw_lines (cr, points_frame1, 9); + cairo_stroke (cr); + cairo_set_source_rgb (cr, clr_inner_frame.red/65535.f, clr_inner_frame.green/65535.f, clr_inner_frame.blue/65535.0); + cairo_draw_lines (cr, points_frame2, 7); + cairo_stroke (cr); } int @@ -413,14 +442,16 @@ tabstrip_need_arrows (DdbTabStrip *ts) { GtkWidget *widget = GTK_WIDGET (ts); int cnt = deadbeef->plt_get_count (); int w = 0; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); for (int idx = 0; idx < cnt; idx++) { w += ddb_tabstrip_get_tab_width (ts, idx) - tab_overlap_size; - if (w >= widget->allocation.width) { + if (w >= a.width) { return 1; } } w += tab_overlap_size + 3; - if (w >= widget->allocation.width) { + if (w >= a.width) { return 1; } return 0; @@ -431,7 +462,9 @@ tabstrip_scroll_to_tab_int (DdbTabStrip *ts, int tab, int redraw) { GtkWidget *widget = GTK_WIDGET (ts); int w = 0; int cnt = deadbeef->plt_get_count (); - int boundary = widget->allocation.width - arrow_widget_width*2 + ts->hscrollpos; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + int boundary = a.width - arrow_widget_width*2 + ts->hscrollpos; for (int idx = 0; idx < cnt; idx++) { int tab_w = ddb_tabstrip_get_tab_width (ts, idx); if (idx == cnt-1) { @@ -470,14 +503,16 @@ tabstrip_adjust_hscroll (DdbTabStrip *ts) { if (deadbeef->plt_get_count () > 0) { int need_arrows = tabstrip_need_arrows (ts); if (need_arrows) { + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); int w = 0; int cnt = deadbeef->plt_get_count (); for (int idx = 0; idx < cnt; idx++) { w += ddb_tabstrip_get_tab_width (ts, idx) - tab_overlap_size; } w += tab_overlap_size + 3; - if (ts->hscrollpos > w - (widget->allocation.width - arrow_widget_width*2)) { - ts->hscrollpos = w - (widget->allocation.width - arrow_widget_width*2); + if (ts->hscrollpos > w - (a.width - arrow_widget_width*2)) { + ts->hscrollpos = w - (a.width - arrow_widget_width*2); deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos); } tabstrip_scroll_to_tab_int (ts, deadbeef->plt_get_curr_idx (), 0); @@ -517,11 +552,14 @@ set_tab_text_color (int idx, int selected) { } void -tabstrip_render (DdbTabStrip *ts) { +tabstrip_render (DdbTabStrip *ts, cairo_t *cr) { GtkWidget *widget = GTK_WIDGET (ts); - GdkDrawable *backbuf = gtk_widget_get_window (widget); + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); tabstrip_adjust_hscroll (ts); + cairo_set_line_width (cr, 1); + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); int cnt = deadbeef->plt_get_count (); int hscroll = ts->hscrollpos; @@ -534,7 +572,7 @@ tabstrip_render (DdbTabStrip *ts) { int x = -hscroll; int w = 0; int h = draw_get_font_size (); - h = widget->allocation.height; + h = a.height; tab_overlap_size = (h-4)/2; text_right_padding = h - 3; @@ -544,17 +582,22 @@ tabstrip_render (DdbTabStrip *ts) { return; } - GdkGC *gc = gdk_gc_new (backbuf); - // fill background GdkColor clr; - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_tabstrip_mid_color (&clr), &clr)); - 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 (&clr), &clr)); - gdk_draw_line (backbuf, gc, 0, 0, widget->allocation.width, 0); + gtkui_get_tabstrip_mid_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.0); + cairo_rectangle (cr, 0, 0, a.width, a.height); + cairo_fill (cr); + + gtkui_get_tabstrip_dark_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.0); + cairo_move_to (cr, 0, 0); + cairo_line_to (cr, a.width, 0); + cairo_stroke (cr); + int y = 4; - h = widget->allocation.height - 4; - draw_begin ((uintptr_t)backbuf); + h = a.height - 4; + draw_begin (cr); int need_draw_moving = 0; int idx; int widths[cnt]; @@ -579,7 +622,7 @@ tabstrip_render (DdbTabStrip *ts) { area.width = w; area.height = 24; if (idx != tab_selected) { - ddb_tabstrip_draw_tab (widget, backbuf, idx, idx == tab_selected, x, y, w, h); + ddb_tabstrip_draw_tab (widget, cr, idx, idx == tab_selected, x, y, w, h); char tab_title[100]; plt_get_title_wrapper (idx, tab_title, sizeof (tab_title)); @@ -588,8 +631,16 @@ tabstrip_render (DdbTabStrip *ts) { } x += w - tab_overlap_size; } - gdk_draw_line (backbuf, widget->style->dark_gc[GTK_STATE_NORMAL], 0, widget->allocation.height-2, widget->allocation.width, widget->allocation.height-2); - gdk_draw_line (backbuf, widget->style->light_gc[GTK_STATE_NORMAL], 0, widget->allocation.height-1, widget->allocation.width, widget->allocation.height-1); + GdkColor *pclr = >k_widget_get_style (widget)->dark[GTK_STATE_NORMAL]; + cairo_set_source_rgb (cr, pclr->red/65535.f, pclr->green/65535.f, pclr->blue/65535.0); + cairo_move_to (cr, 0, a.height-2); + cairo_line_to (cr, a.width, a.height-2); + cairo_stroke (cr); + pclr = >k_widget_get_style (widget)->light[GTK_STATE_NORMAL]; + cairo_set_source_rgb (cr, pclr->red/65535.f, pclr->green/65535.f, pclr->blue/65535.0); + cairo_move_to (cr, 0, a.height-1); + cairo_line_to (cr, a.width, a.height-1); + cairo_stroke (cr); // calc position for drawin selected tab x = -hscroll; for (idx = 0; idx < tab_selected; idx++) { @@ -605,7 +656,7 @@ tabstrip_render (DdbTabStrip *ts) { area.y = 0; area.width = w; area.height = 24; - ddb_tabstrip_draw_tab (widget, backbuf, idx, 1, x, y, w, h); + ddb_tabstrip_draw_tab (widget, cr, idx, 1, x, y, w, h); char tab_title[100]; plt_get_title_wrapper (idx, tab_title, sizeof (tab_title)); set_tab_text_color (idx, tab_selected); @@ -620,11 +671,11 @@ tabstrip_render (DdbTabStrip *ts) { w = widths[idx]; if (idx == ts->dragging) { x = ts->movepos; - if (x >= widget->allocation.width) { + if (x >= a.width) { break; } if (w > 0) { - ddb_tabstrip_draw_tab (widget, backbuf, idx, 1, x, y, w, h); + ddb_tabstrip_draw_tab (widget, cr, idx, 1, x, y, w, h); char tab_title[100]; plt_get_title_wrapper (idx, tab_title, sizeof (tab_title)); set_tab_text_color (idx, tab_selected); @@ -637,17 +688,27 @@ tabstrip_render (DdbTabStrip *ts) { } if (need_arrows) { - int sz = widget->allocation.height-3; - GdkColor clr; - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_tabstrip_mid_color (&clr), &clr)); - gdk_draw_rectangle (backbuf, gc, TRUE, 0, 1, arrow_widget_width, sz); - gtk_paint_arrow (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, NULL, GTK_ARROW_LEFT, TRUE, 2, sz/2-arrow_sz/2, arrow_sz, arrow_sz); - gdk_draw_rectangle (backbuf, gc, TRUE, widget->allocation.width-arrow_widget_width, 1, arrow_widget_width, sz); - gtk_paint_arrow (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, NULL, GTK_ARROW_RIGHT, TRUE, widget->allocation.width-arrow_sz-2, 1+sz/2-arrow_sz/2, arrow_sz, arrow_sz); + int sz = a.height-3; + gtkui_get_tabstrip_mid_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.0); + cairo_rectangle (cr, 0, 1, arrow_widget_width, sz); + cairo_fill (cr); +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_arrow (gtk_widget_get_style (widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, widget, NULL, GTK_ARROW_LEFT, TRUE, 2, sz/2-arrow_sz/2, arrow_sz, arrow_sz); +#else + gtk_paint_arrow (gtk_widget_get_style (widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, NULL, GTK_ARROW_LEFT, TRUE, 2, sz/2-arrow_sz/2, arrow_sz, arrow_sz); +#endif + + cairo_rectangle (cr, a.width-arrow_widget_width, 1, arrow_widget_width, sz); + cairo_fill (cr); +#if GTK_CHECK_VERSION(3,0,0) + gtk_paint_arrow (gtk_widget_get_style (widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, widget, NULL, GTK_ARROW_RIGHT, TRUE, a.width-arrow_sz-2, 1+sz/2-arrow_sz/2, arrow_sz, arrow_sz); +#else + gtk_paint_arrow (gtk_widget_get_style (widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, NULL, GTK_ARROW_RIGHT, TRUE, a.width-arrow_sz-2, 1+sz/2-arrow_sz/2, arrow_sz, arrow_sz); +#endif } draw_end (); - g_object_unref (gc); } static int @@ -845,6 +906,8 @@ on_tabstrip_button_press_event(GtkWidget *widget, { int need_arrows = tabstrip_need_arrows (ts); if (need_arrows) { + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); if (event->x < arrow_widget_width) { if (event->type == GDK_BUTTON_PRESS) { tabstrip_scroll_left (ts); @@ -853,7 +916,7 @@ on_tabstrip_button_press_event(GtkWidget *widget, } return FALSE; } - else if (event->x >= widget->allocation.width - arrow_widget_width) { + else if (event->x >= a.width - arrow_widget_width) { if (event->type == GDK_BUTTON_PRESS) { tabstrip_scroll_right (ts); ts->scroll_direction = 1; @@ -951,22 +1014,31 @@ gboolean on_tabstrip_configure_event (GtkWidget *widget, GdkEventConfigure *event) { - draw_init_font (widget->style); + draw_init_font (gtk_widget_get_style (widget)); DdbTabStrip *ts = DDB_TABSTRIP (widget); tabstrip_adjust_hscroll (ts); int height = draw_get_listview_rowheight () + 4; - if (height != widget->allocation.height) { + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + if (height != a.height) { gtk_widget_set_size_request (widget, -1, height); } return FALSE; } +gboolean +on_tabstrip_draw (GtkWidget *widget, cairo_t *cr) { + tabstrip_render (DDB_TABSTRIP (widget), cr); + return FALSE; +} gboolean on_tabstrip_expose_event (GtkWidget *widget, GdkEventExpose *event) { - tabstrip_render (DDB_TABSTRIP (widget)); + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); + on_tabstrip_draw (widget, cr); + cairo_destroy (cr); return FALSE; } @@ -989,7 +1061,7 @@ on_tabstrip_motion_notify_event (GtkWidget *widget, } } if (!ts->prepare && ts->dragging >= 0) { -// gdk_window_set_cursor (widget->window, cursor_drag); +// gdk_window_set_cursor (gtk_widget_get_window(widget), cursor_drag); ts->movepos = ev_x - ts->dragpt[0]; // find closest tab to the left @@ -1057,11 +1129,11 @@ on_tabstrip_drag_motion_event (GtkWidget *widget, } GtkWidget *pl = lookup_widget (mainwin, "playlist"); - - int cnt = g_list_length (drag_context->targets); + GList *targets = gdk_drag_context_list_targets (drag_context); + int cnt = g_list_length (targets); int i; for (i = 0; i < cnt; i++) { - GdkAtom a = GDK_POINTER_TO_ATOM (g_list_nth_data (drag_context->targets, i)); + GdkAtom a = GDK_POINTER_TO_ATOM (g_list_nth_data (targets, i)); gchar *nm = gdk_atom_name (a); if (!strcmp (nm, "text/uri-list")) { g_free (nm); diff --git a/plugins/gtkui/ddbvolumebar.c b/plugins/gtkui/ddbvolumebar.c index b0df2c9a..c0f28d15 100644 --- a/plugins/gtkui/ddbvolumebar.c +++ b/plugins/gtkui/ddbvolumebar.c @@ -35,12 +35,14 @@ ddb_volumebar_send_configure (DdbVolumeBar *darea) widget = GTK_WIDGET (darea); - event->configure.window = g_object_ref (widget->window); + event->configure.window = g_object_ref (gtk_widget_get_window(widget)); 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; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + event->configure.x = a.x; + event->configure.y = a.y; + event->configure.width = a.width; + event->configure.height = a.height; gtk_widget_event (widget, event); gdk_event_free (event); @@ -77,12 +79,12 @@ ddb_volumebar_realize (GtkWidget *widget) { 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), + gtk_widget_get_window(widget) = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, darea); + gdk_window_set_user_data (gtk_widget_get_window(widget), darea); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + widget->style = gtk_style_attach (widget->style, gtk_widget_get_window(widget)); + gtk_style_set_background (widget->style, gtk_widget_get_window(widget), GTK_STATE_NORMAL); } ddb_volumebar_send_configure (DDB_VOLUMEBAR (widget)); @@ -96,12 +98,12 @@ ddb_volumebar_size_allocate (GtkWidget *widget, g_return_if_fail (DDB_IS_VOLUMEBAR (widget)); g_return_if_fail (allocation != NULL); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) { if (gtk_widget_get_has_window (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -110,6 +112,9 @@ ddb_volumebar_size_allocate (GtkWidget *widget, } gboolean +on_volumebar_draw (GtkWidget *widget, cairo_t *cr); + +gboolean on_volumebar_expose_event (GtkWidget *widget, GdkEventExpose *event); @@ -138,7 +143,11 @@ ddb_volumebar_class_init(DdbVolumeBarClass *class) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); widget_class->realize = ddb_volumebar_realize; widget_class->size_allocate = ddb_volumebar_size_allocate; +#if GTK_CHECK_VERSION(3,0,0) + widget_class->draw = on_volumebar_draw; +#else widget_class->expose_event = on_volumebar_expose_event; +#endif widget_class->button_press_event = on_volumebar_button_press_event; widget_class->button_release_event = on_volumebar_button_release_event; widget_class->motion_notify_event = on_volumebar_motion_notify_event; @@ -160,40 +169,43 @@ ddb_volumebar_init(DdbVolumeBar *volumebar) } void -volumebar_draw (GtkWidget *widget) { +volumebar_draw (GtkWidget *widget, cairo_t *cr) { if (!widget) { return; } - GdkDrawable *volumebar_backbuf = GDK_DRAWABLE (widget->window); float range = -deadbeef->volume_get_min_db (); - int n = widget->allocation.width / 4; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + int n = a.width / 4; float vol = (range + deadbeef->volume_get_db ()) / range * n; float h = 17; - GdkGC *back_gc = gdk_gc_new (widget->window); - GdkColor clr; - gdk_gc_set_rgb_fg_color (back_gc, (gtkui_get_bar_background_color (&clr), &clr)); - - GdkGC *front_gc = gdk_gc_new (widget->window); - gdk_gc_set_rgb_fg_color (front_gc, (gtkui_get_bar_foreground_color (&clr), &clr)); + GdkColor clr_fg; + GdkColor clr_bg; + gtkui_get_bar_background_color (&clr_fg); + gtkui_get_bar_foreground_color (&clr_bg); for (int i = 0; i < n; i++) { float iy = (float)i + 3; int _x = i * 4; int _h = h * iy / n; - int _y = widget->allocation.height/2-h/2; + int _y = a.height/2-h/2; _y += (h - _h); int _w = 3; if (i < vol) { - gdk_draw_rectangle (volumebar_backbuf, front_gc, TRUE, _x + widget->allocation.x, _y + widget->allocation.y, _w, _h); + cairo_set_source_rgb (cr, clr_fg.red/65535.f, clr_fg.green/65535.f, clr_fg.blue/65535.f); + cairo_rectangle (cr, _x + a.x, _y + a.y, _w, _h); + cairo_fill (cr); } else { - gdk_draw_rectangle (volumebar_backbuf, back_gc, TRUE, _x + widget->allocation.x, _y + widget->allocation.y, _w, _h); + cairo_set_source_rgb (cr, clr_bg.red/65535.f, clr_bg.green/65535.f, clr_bg.blue/65535.f); + cairo_rectangle (cr, _x + a.x, _y + a.y, _w, _h); + cairo_fill (cr); } } #if 0 if (DDB_VOLUMEBAR (widget)->show_dbs) { - draw_begin ((uintptr_t)widget->window); + draw_begin ((uintptr_t)gtk_widget_get_window(widget)); draw_init_font (widget->style); char s[100]; int db = deadbeef->volume_get_db (); @@ -204,25 +216,34 @@ volumebar_draw (GtkWidget *widget) { draw_end (); } #endif - g_object_unref (back_gc); - g_object_unref (front_gc); } gboolean +on_volumebar_draw (GtkWidget *widget, cairo_t *cr) { + volumebar_draw (widget, cr); +} + +#if !GTK_CHECK_VERSION(3,0,0) +gboolean on_volumebar_expose_event (GtkWidget *widget, GdkEventExpose *event) { - volumebar_draw (widget); + cairo_t *cr = gdk_cairo_create (widget); + on_volumebar_draw (widget, cr); + gdk_cairo_destroy (cr); return FALSE; } +#endif gboolean on_volumebar_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); if (event->state & GDK_BUTTON1_MASK) { float range = -deadbeef->volume_get_min_db (); - float volume = (event->x - widget->allocation.x) / widget->allocation.width * range - range; + float volume = (event->x - a.x) / a.width * range - range; if (volume > 0) { volume = 0; } @@ -244,9 +265,11 @@ gboolean on_volumebar_button_press_event (GtkWidget *widget, GdkEventButton *event) { + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); if (event->button == 1) { float range = -deadbeef->volume_get_min_db (); - float volume = (event->x - widget->allocation.x)/ widget->allocation.width * range - range; + float volume = (event->x - a.x)/ a.width * range - range; if (volume < -range) { volume = -range; } diff --git a/plugins/gtkui/drawing.h b/plugins/gtkui/drawing.h index b73c9f97..fe3850f9 100644 --- a/plugins/gtkui/drawing.h +++ b/plugins/gtkui/drawing.h @@ -30,27 +30,21 @@ void draw_free (void); void -draw_begin (uintptr_t canvas); +draw_begin (cairo_t *cr); void draw_end (void); void -draw_get_canvas_size (uintptr_t canvas, int *w, int *h); +draw_copy (cairo_t *dest_canvas, cairo_t *src_canvas, int dx, int dy, int sx, int sy, int w, int h); void -draw_copy (uintptr_t dest_canvas, uintptr_t src_canvas, int dx, int dy, int sx, int sy, int w, int h); - -void -draw_pixbuf (uintptr_t dest_canvas, uintptr_t pixbuf, int dx, int dy, int sx, int sy, int w, int h); +draw_pixbuf (cairo_t *dest_canvas, uintptr_t pixbuf, int dx, int dy, int sx, int sy, int w, int h); void draw_set_fg_color (float *rgb); void -draw_set_bg_color (float *rgb); - -void draw_line (float x1, float y1, float x2, float y2); void diff --git a/plugins/gtkui/eq.c b/plugins/gtkui/eq.c index f2012bba..c534dfb6 100644 --- a/plugins/gtkui/eq.c +++ b/plugins/gtkui/eq.c @@ -97,7 +97,7 @@ on_zero_all_clicked (GtkButton *button, // set dsp set_param (eq, i+1, 0); } - gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); + gtk_widget_queue_draw (eqwin); } } } @@ -110,7 +110,7 @@ on_zero_preamp_clicked (GtkButton *button, if (eq) { set_param (eq, 0, 0); ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), 0); - gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); + gtk_widget_queue_draw (eqwin); } } } @@ -125,7 +125,7 @@ on_zero_bands_clicked (GtkButton *button, ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, 0); set_param (eq, i+1, 0); } - gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); + gtk_widget_queue_draw (eqwin); } } } @@ -227,7 +227,7 @@ on_load_preset_clicked (GtkMenuItem *menuitem, ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, vals[i]); set_param (eq, i+1, vals[i]); } - gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); + gtk_widget_queue_draw (eqwin); deadbeef->conf_save (); } } @@ -293,7 +293,7 @@ on_import_fb2k_preset_clicked (GtkButton *button, ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, vals[i]); set_param (eq, i+1, vals[i]); } - gdk_window_invalidate_rect (eqwin->window, NULL, FALSE); + gtk_widget_queue_draw (eqwin); deadbeef->conf_save (); } } diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c index cb795ccb..7c610af8 100644 --- a/plugins/gtkui/gdkdrawing.c +++ b/plugins/gtkui/gdkdrawing.c @@ -27,8 +27,8 @@ #include "support.h" #include "gtkui.h" -static GdkDrawable *drawable; -static GdkGC *gc; +static cairo_t *drawable; +//static GdkGC *gc; static GdkColor clrfg; static GdkColor clrbg; static int pango_ready; @@ -36,59 +36,41 @@ static PangoContext *pangoctx; static PangoLayout *pangolayout; void -draw_begin (uintptr_t canvas) { - drawable = GDK_DRAWABLE (canvas); - gc = gdk_gc_new (drawable); +draw_begin (cairo_t *cr) { + drawable = cr; } void draw_end (void) { drawable = NULL; - if (gc) { - g_object_unref (gc); - gc = NULL; - } -} - -void -draw_copy (uintptr_t dest_canvas, uintptr_t src_canvas, int dx, int dy, int sx, int sy, int w, int h) { - gdk_draw_drawable (GDK_DRAWABLE (dest_canvas), gc, GDK_DRAWABLE (src_canvas), dx, dy, sx, sy, w, h); } void -draw_pixbuf (uintptr_t dest_canvas, uintptr_t pixbuf, int dx, int dy, int sx, int sy, int w, int h) { - gdk_draw_pixbuf (GDK_DRAWABLE (dest_canvas), gc, GDK_PIXBUF (pixbuf), sx, sy, dx, dy, w, h, GDK_RGB_DITHER_NONE, 0, 0); +draw_copy (cairo_t *dest_canvas, cairo_t *src_canvas, int dx, int dy, int sx, int sy, int w, int h) { +// FIXME gdk_draw_drawable (GDK_DRAWABLE (dest_canvas), gc, GDK_DRAWABLE (src_canvas), dx, dy, sx, sy, w, h); } void -draw_get_canvas_size (uintptr_t canvas, int *w, int *h) { - gdk_drawable_get_size (GDK_DRAWABLE (canvas), w, h); +draw_pixbuf (cairo_t *dest_canvas, uintptr_t pixbuf, int dx, int dy, int sx, int sy, int w, int h) { +// FIXME gdk_draw_pixbuf (GDK_DRAWABLE (dest_canvas), gc, GDK_PIXBUF (pixbuf), sx, sy, dx, dy, w, h, GDK_RGB_DITHER_NONE, 0, 0); } void draw_set_fg_color (float *rgb) { - clrfg.red = rgb[0] * 0xffff; - clrfg.green = rgb[1] * 0xffff; - clrfg.blue = rgb[2] * 0xffff; - gdk_gc_set_rgb_fg_color (gc, &clrfg); -} - -void -draw_set_bg_color (float *rgb) { - clrbg.red = rgb[0] * 0xffff; - clrbg.green = rgb[1] * 0xffff; - clrbg.blue = rgb[2] * 0xffff; - gdk_gc_set_rgb_bg_color (gc, &clrbg); + cairo_set_source_rgb (drawable, rgb[0], rgb[1], rgb[2]); } void draw_line (float x1, float y1, float x2, float y2) { - gdk_draw_line (drawable, gc, x1, y1, x2, y2); + cairo_move_to (drawable, x1, y1); + cairo_move_to (drawable, x2, y2); + cairo_stroke (drawable); } void draw_rect (float x, float y, float w, float h, int fill) { - gdk_draw_rectangle (drawable, gc, fill, x, y, w, h); + cairo_rectangle (drawable, x, y, w, h); + fill ? cairo_fill (drawable) : cairo_stroke (drawable); } static GtkStyle *font_style = NULL; @@ -165,7 +147,8 @@ draw_text (float x, float y, int width, int align, const char *text) { 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); - gdk_draw_layout (drawable, gc, x, y, pangolayout); + cairo_move_to (drawable, x, y); + pango_cairo_show_layout (drawable, pangolayout); } void @@ -174,7 +157,10 @@ draw_text_with_colors (float x, float y, int width, int align, const char *text) 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); - gdk_draw_layout_with_colors (drawable, gc, x, y, pangolayout, &clrfg, &clrbg); +// gdk_draw_layout_with_colors (drawable, gc, x, y, pangolayout, &clrfg, &clrbg); + cairo_move_to (drawable, x, y); + pango_cairo_show_layout (drawable, pangolayout); + } void @@ -233,7 +219,7 @@ gtkui_init_theme_colors (void) { override_tabstrip_colors = deadbeef->conf_get_int ("gtkui.override_tabstrip_colors", 0); extern GtkWidget *mainwin; - GtkStyle *style = mainwin->style; + GtkStyle *style = gtk_widget_get_style (mainwin); char color_text[100]; const char *clr; diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index c915558d..51fd3c52 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -77,7 +77,7 @@ int gtkui_embolden_current_track; void gtkpl_init (void) { theme_treeview = gtk_tree_view_new (); - GTK_WIDGET_UNSET_FLAGS (theme_treeview, GTK_CAN_FOCUS); + gtk_widget_set_can_focus (theme_treeview, FALSE); gtk_widget_show (theme_treeview); GtkWidget *vbox1 = lookup_widget (mainwin, "vbox1"); gtk_box_pack_start (GTK_BOX (vbox1), theme_treeview, FALSE, FALSE, 0); @@ -115,7 +115,7 @@ static struct timeval last_br_update; static gboolean update_songinfo (gpointer ctx) { - int iconified = gdk_window_get_state(mainwin->window) & GDK_WINDOW_STATE_ICONIFIED; + int iconified = gdk_window_get_state(gtk_widget_get_window(mainwin)) & GDK_WINDOW_STATE_ICONIFIED; if (!gtk_widget_get_visible (mainwin) || iconified) { return FALSE; } @@ -216,7 +216,9 @@ update_songinfo (gpointer ctx) { GtkWidget *widget = lookup_widget (mainwin, "seekbar"); // translate volume to seekbar pixels songpos /= duration; - songpos *= widget->allocation.width; + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + songpos *= a.width; if (fabs (songpos - last_songpos) > 0.01) { gtk_widget_queue_draw (widget); last_songpos = songpos; @@ -287,7 +289,7 @@ on_trayicon_scroll_event (GtkWidget *widget, void mainwin_toggle_visible (void) { - int iconified = gdk_window_get_state(mainwin->window) & GDK_WINDOW_STATE_ICONIFIED; + int iconified = gdk_window_get_state(gtk_widget_get_window(mainwin)) & GDK_WINDOW_STATE_ICONIFIED; if (gtk_widget_get_visible (mainwin) && !iconified) { gtk_widget_hide (mainwin); } @@ -364,7 +366,7 @@ redraw_queued_tracks (DdbListview *pl, int list) { static gboolean redraw_queued_tracks_cb (gpointer nothing) { - int iconified = gdk_window_get_state(mainwin->window) & GDK_WINDOW_STATE_ICONIFIED; + int iconified = gdk_window_get_state(gtk_widget_get_window(mainwin)) & GDK_WINDOW_STATE_ICONIFIED; if (!gtk_widget_get_visible (mainwin) || iconified) { return FALSE; } @@ -517,7 +519,7 @@ gtkui_on_frameupdate (gpointer data) { static gboolean gtkui_volumechanged_cb (gpointer ctx) { GtkWidget *volumebar = lookup_widget (mainwin, "volumebar"); - gdk_window_invalidate_rect (volumebar->window, NULL, FALSE); + gdk_window_invalidate_rect (gtk_widget_get_window (volumebar), NULL, FALSE); return FALSE; } @@ -905,7 +907,7 @@ update_win_title_idle (gpointer data) { static gboolean redraw_seekbar_cb (gpointer nothing) { - int iconified = gdk_window_get_state(mainwin->window) & GDK_WINDOW_STATE_ICONIFIED; + int iconified = gdk_window_get_state(gtk_widget_get_window(mainwin)) & GDK_WINDOW_STATE_ICONIFIED; if (!gtk_widget_get_visible (mainwin) || iconified) { return FALSE; } @@ -948,7 +950,7 @@ gtkui_add_new_playlist (void) { void volumebar_redraw (void) { GtkWidget *volumebar = lookup_widget (mainwin, "volumebar"); - gdk_window_invalidate_rect (volumebar->window, NULL, FALSE); + gdk_window_invalidate_rect (gtk_widget_get_window (volumebar), NULL, FALSE); } void @@ -1331,11 +1333,19 @@ gtkui_get_mainwin (void) { return mainwin; } +#if !GTK_CHECK_VERSION(3,0,0) DB_plugin_t * ddb_gui_GTK2_load (DB_functions_t *api) { deadbeef = api; return DB_PLUGIN (&plugin); } +#else +DB_plugin_t * +ddb_gui_GTK3_load (DB_functions_t *api) { + deadbeef = api; + return DB_PLUGIN (&plugin); +} +#endif static const char settings_dlg[] = "property \"Ask confirmation to delete files from disk\" checkbox gtkui.delete_files_ask 1;\n" diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index e2ed8dbf..fc9efaff 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -116,7 +116,7 @@ void seekbar_redraw (void); void -seekbar_draw (GtkWidget *widget); +seekbar_draw (GtkWidget *widget, cairo_t *cr); gboolean on_seekbar_button_press_event (GtkWidget *widget, diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c index f22bb5aa..7cf9a2f4 100644 --- a/plugins/gtkui/mainplaylist.c +++ b/plugins/gtkui/mainplaylist.c @@ -161,13 +161,13 @@ void main_selection_changed (DdbListviewIter it, int idx) { } } -void main_draw_group_title (DdbListview *listview, GdkDrawable *drawable, DdbListviewIter it, int x, int y, int width, int height) { +void main_draw_group_title (DdbListview *listview, cairo_t *drawable, DdbListviewIter it, int x, int y, int width, int height) { if (group_by_str && group_by_str[0]) { char str[1024]; deadbeef->pl_format_title ((DB_playItem_t *)it, -1, str, sizeof (str), -1, group_by_str); int theming = !gtkui_override_listview_colors (); if (theming) { - GdkColor *clr = &theme_treeview->style->fg[GTK_STATE_NORMAL]; + GdkColor *clr = >k_widget_get_style(theme_treeview)->fg[GTK_STATE_NORMAL]; float rgb[] = {clr->red/65535.f, clr->green/65535.f, clr->blue/65535.f}; draw_set_fg_color (rgb); } diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c index c7b04e6d..7ba89804 100644 --- a/plugins/gtkui/plcommon.c +++ b/plugins/gtkui/plcommon.c @@ -74,7 +74,7 @@ rewrite_column_config (DdbListview *listview, const char *name) { #define ART_PADDING_HORZ 8 #define ART_PADDING_VERT 0 -void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListviewIter it, DdbListviewIter group_it, int column, int group_y, int x, int y, int width, int height) { +void draw_column_data (DdbListview *listview, cairo_t *cr, DdbListviewIter it, DdbListviewIter group_it, int column, int group_y, int x, int y, int width, int height) { const char *ctitle; int cwidth; int calign_right; @@ -89,20 +89,27 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview if (cinf->id == DB_COLUMN_ALBUM_ART) { if (theming) { +#if GTK_CHECK_VERSION(3,0,0) + cairo_rectangle (cr, x, y, width, height); + cairo_clip (cr); + gtk_paint_flat_box (gtk_widget_get_style (theme_treeview), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, theme_treeview, "cell_even_ruled", x-1, y, width+2, height); + cairo_reset_clip (cr); +#else GdkRectangle clip = { .x = x, .y = y, .width = width, .height = height, }; - gtk_paint_flat_box (theme_treeview->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE, &clip, theme_treeview, "cell_even_ruled", x-1, y, width+2, height); + gtk_paint_flat_box (gtk_widget_get_style (theme_treeview), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, &clip, theme_treeview, "cell_even_ruled", x-1, y, width+2, height); +#endif } else { - GdkGC *gc = gdk_gc_new (drawable); GdkColor clr; - gdk_gc_set_rgb_fg_color (gc, (gtkui_get_listview_even_row_color (&clr), &clr)); - gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height); - g_object_unref (gc); + gtkui_get_listview_even_row_color (&clr); + cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); + cairo_rectangle (cr, x, y, width, height); + cairo_fill (cr); } int art_width = width - ART_PADDING_HORZ * 2; int art_y = y; // dest y @@ -135,8 +142,7 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview pw = min (art_width, pw); ph -= sy; ph = min (ph, h); - gdk_draw_pixbuf (drawable, GTK_WIDGET (listview)->style->white_gc, pixbuf, 0, sy, x + ART_PADDING_HORZ, art_y, pw, ph, GDK_RGB_DITHER_NONE, 0, 0); -// gdk_draw_rectangle (drawable, GTK_WIDGET (listview)->style->black_gc, FALSE, x + ART_PADDING_HORZ, art_y, pw, ph); + // FIXME gdk_draw_pixbuf (drawable, GTK_WIDGET (listview)->style->white_gc, pixbuf, 0, sy, x + ART_PADDING_HORZ, art_y, pw, ph, GDK_RGB_DITHER_NONE, 0, 0); } g_object_unref (pixbuf); } @@ -156,7 +162,7 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview else { pixbuf = buffering16_pixbuf; } - gdk_draw_pixbuf (drawable, GTK_WIDGET (listview)->style->black_gc, pixbuf, 0, 0, x + cwidth/2 - 8, y + height/2 - 8, 16, 16, GDK_RGB_DITHER_NONE, 0, 0); + // FIXME gdk_draw_pixbuf (drawable, GTK_WIDGET (listview)->style->black_gc, pixbuf, 0, 0, x + cwidth/2 - 8, y + height/2 - 8, 16, 16, GDK_RGB_DITHER_NONE, 0, 0); } else if (it) { char text[1024]; @@ -164,10 +170,10 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview GdkColor *color = NULL; if (theming) { if (deadbeef->pl_is_selected (it)) { - color = &theme_treeview->style->text[GTK_STATE_SELECTED]; + color = >k_widget_get_style (theme_treeview)->text[GTK_STATE_SELECTED]; } else { - color = &theme_treeview->style->text[GTK_STATE_NORMAL]; + color = >k_widget_get_style (theme_treeview)->text[GTK_STATE_NORMAL]; } } else { @@ -182,7 +188,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); + draw_init_font (gtk_widget_get_style (GTK_WIDGET (listview))); if (gtkui_embolden_current_track && it && it == playing_track) { draw_init_font_bold (); } @@ -390,7 +396,7 @@ actionitem_activate (GtkMenuItem *menuitem, #define HOOKUP_OBJECT(component,widget,name) \ g_object_set_data_full (G_OBJECT (component), name, \ - gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + g_object_ref (widget), (GDestroyNotify) g_object_unref) static GtkWidget* @@ -404,7 +410,7 @@ find_popup (GtkWidget *widget, if (GTK_IS_MENU (widget)) parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); else - parent = widget->parent; + parent = gtk_widget_get_parent (widget); if (!parent) parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); if (parent == NULL) diff --git a/plugins/gtkui/plcommon.h b/plugins/gtkui/plcommon.h index 6a3114c1..b747b0d1 100644 --- a/plugins/gtkui/plcommon.h +++ b/plugins/gtkui/plcommon.h @@ -35,7 +35,7 @@ write_column_config (const char *name, int idx, const char *title, int width, in void rewrite_column_config (DdbListview *listview, const char *name); -void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListviewIter it, DdbListviewIter group_it, int column, int group_y, int x, int y, int width, int height); +void draw_column_data (DdbListview *listview, cairo_t *drawable, DdbListviewIter it, DdbListviewIter group_it, int column, int group_y, int x, int y, int width, int height); void list_context_menu (DdbListview *listview, DdbListviewIter it, int idx); diff --git a/plugins/gtkui/pluginconf.c b/plugins/gtkui/pluginconf.c index 04f73084..42070d4d 100644 --- a/plugins/gtkui/pluginconf.c +++ b/plugins/gtkui/pluginconf.c @@ -252,9 +252,9 @@ gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons, in int pack[100] = {0}; int ncurr = 0; - widgets[ncurr] = GTK_DIALOG (win)->vbox; + widgets[ncurr] = gtk_dialog_get_content_area (GTK_DIALOG (win)); gtk_box_set_spacing (GTK_BOX (widgets[ncurr]), 8); - GtkWidget *action_area = GTK_DIALOG (win)->action_area; + GtkWidget *action_area = gtk_dialog_get_action_area (GTK_DIALOG (win)); gtk_widget_show (action_area); gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END); @@ -421,7 +421,7 @@ gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons, in label = gtk_label_new (_(labeltext)); gtk_widget_show (label); - prop = gtk_combo_box_new_text (); + prop = gtk_combo_box_text_new (); gtk_widget_show (prop); for (int i = 0; i < n; i++) { @@ -431,7 +431,7 @@ gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons, in break; } - gtk_combo_box_append_text (GTK_COMBO_BOX (prop), entry); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (prop), entry); } if (!script) { break; diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c index 3c0e0932..5ea69196 100644 --- a/plugins/gtkui/prefwin.c +++ b/plugins/gtkui/prefwin.c @@ -57,7 +57,7 @@ gtk_enum_sound_callback (const char *name, const char *desc, void *userdata) { return; } GtkComboBox *combobox = GTK_COMBO_BOX (userdata); - gtk_combo_box_append_text (combobox, desc); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), desc); deadbeef->conf_lock (); if (!strcmp (deadbeef->conf_get_str_fast ("alsa_soundcard", "default"), name)) { @@ -79,7 +79,7 @@ preferences_fill_soundcards (void) { GtkTreeModel *mdl = gtk_combo_box_get_model (combobox); gtk_list_store_clear (GTK_LIST_STORE (mdl)); - gtk_combo_box_append_text (combobox, _("Default Audio Device")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), _("Default Audio Device")); deadbeef->conf_lock (); const char *s = deadbeef->conf_get_str_fast ("alsa_soundcard", "default"); @@ -318,12 +318,12 @@ prefwin_add_hotkeys_tab (GtkWidget *prefwin) { addhotkey = gtk_button_new_with_mnemonic (_("Add")); gtk_widget_show (addhotkey); gtk_container_add (GTK_CONTAINER (hbuttonbox3), addhotkey); - GTK_WIDGET_SET_FLAGS (addhotkey, GTK_CAN_DEFAULT); + gtk_widget_set_can_default (addhotkey, TRUE); removehotkey = gtk_button_new_with_mnemonic (_("Remove")); gtk_widget_show (removehotkey); gtk_container_add (GTK_CONTAINER (hbuttonbox3), removehotkey); - GTK_WIDGET_SET_FLAGS (removehotkey, GTK_CAN_DEFAULT); + gtk_widget_set_can_default (removehotkey, TRUE); label66 = gtk_label_new (_("Global Hotkeys")); gtk_widget_show (label66); @@ -473,7 +473,7 @@ on_preferences_activate (GtkMenuItem *menuitem, const char *outplugname = deadbeef->conf_get_str_fast ("output_plugin", "ALSA output plugin"); DB_output_t **out_plugs = deadbeef->plug_get_output_list (); for (int i = 0; out_plugs[i]; i++) { - gtk_combo_box_append_text (combobox, out_plugs[i]->plugin.name); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), out_plugs[i]->plugin.name); if (!strcmp (outplugname, out_plugs[i]->plugin.name)) { gtk_combo_box_set_active (combobox, i); } @@ -550,7 +550,7 @@ on_preferences_activate (GtkMenuItem *menuitem, combobox = GTK_COMBO_BOX (lookup_widget (w, "gui_plugin")); const char **names = deadbeef->plug_get_gui_names (); for (int i = 0; names[i]; i++) { - gtk_combo_box_append_text (combobox, names[i]); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), names[i]); if (!strcmp (names[i], deadbeef->conf_get_str_fast ("gui_plugin", "GTK2"))) { gtk_combo_box_set_active (combobox, i); } @@ -1331,7 +1331,7 @@ void on_gui_plugin_changed (GtkComboBox *combobox, gpointer user_data) { - gchar *txt = gtk_combo_box_get_active_text (combobox); + gchar *txt = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combobox)); if (txt) { deadbeef->conf_set_str ("gui_plugin", txt); g_free (txt); diff --git a/plugins/gtkui/support.c b/plugins/gtkui/support.c index e237bc99..ae0b71d5 100644 --- a/plugins/gtkui/support.c +++ b/plugins/gtkui/support.c @@ -27,7 +27,7 @@ lookup_widget (GtkWidget *widget, if (GTK_IS_MENU (widget)) parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); else - parent = widget->parent; + parent = gtk_widget_get_parent (widget); if (!parent) parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); if (parent == NULL) @@ -145,8 +145,7 @@ glade_set_atk_action_description (AtkAction *action, #if GTK_CHECK_VERSION(3,0,0) GtkWidget * gtk_combo_box_entry_new_text(void) { - GtkWidget *w = gtk_combo_box_text_new (); - gtk_combo_box_text_set_has_entry (GTK_COMBO_BOX_TEXT (w), TRUE); + GtkWidget *w = gtk_combo_box_text_new_with_entry (); } void gtk_dialog_set_has_separator (GtkDialog *dlg, gboolean has) { diff --git a/plugins/gtkui/wingeom.c b/plugins/gtkui/wingeom.c index 28e60c31..47b6f960 100644 --- a/plugins/gtkui/wingeom.c +++ b/plugins/gtkui/wingeom.c @@ -27,7 +27,7 @@ void wingeom_save (GtkWidget *widget, const char *name) { #if GTK_CHECK_VERSION(2,2,0) - GdkWindowState window_state = gdk_window_get_state (GDK_WINDOW (widget->window)); + GdkWindowState window_state = gdk_window_get_state (gtk_widget_get_window (widget)); #else GdkWindowState window_state = gdk_window_get_state (G_OBJECT (widget)); #endif diff --git a/scripts/quickinstall.sh b/scripts/quickinstall.sh index 20b89482..a7e54c7d 100755 --- a/scripts/quickinstall.sh +++ b/scripts/quickinstall.sh @@ -18,6 +18,7 @@ cp ./plugins/lastfm/.libs/lastfm.so /usr/local/lib/deadbeef/ cp ./plugins/sid/.libs/sid.so /usr/local/lib/deadbeef/ cp ./plugins/adplug/.libs/adplug.so /usr/local/lib/deadbeef/ cp ./plugins/gtkui/.libs/ddb_gui_GTK2.so /usr/local/lib/deadbeef/ +cp ./plugins/gtkui/.libs/ddb_gui_GTK3.so /usr/local/lib/deadbeef/ cp ./plugins/sndfile/.libs/sndfile.so /usr/local/lib/deadbeef/ cp ./plugins/pulse/.libs/pulse.so /usr/local/lib/deadbeef/ cp ./plugins/artwork/.libs/artwork.so /usr/local/lib/deadbeef/ |