summaryrefslogtreecommitdiff
path: root/plugins/gtkui
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-10-23 11:50:41 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-23 11:50:41 +0200
commita9c813ddbda28a2d0beff104fe8cf80299292533 (patch)
tree5630dfd20c5e4484148dc4fde06fdb2a0e9aeefa /plugins/gtkui
parent2f2937a5554d4cdca177eb546a0e0c449b16c700 (diff)
parent50208fdf54d7afaf8b42abc511ddc675b9475184 (diff)
Merge branch 'master' into devel
Conflicts: deadbeef.h metacache.c playlist.c plugins.c plugins/gtkui/Makefile.am plugins/gtkui/ddbcellrenderertextmultiline.c plugins/gtkui/ddbcellrenderertextmultiline.h plugins/gtkui/ddbequalizer.c plugins/gtkui/ddbequalizer.h plugins/gtkui/ddbseekbar.c plugins/gtkui/ddbseekbar.h plugins/gtkui/ddbtabstrip.c plugins/gtkui/fileman.c plugins/gtkui/gtkui.c plugins/gtkui/interface.c plugins/gtkui/plcommon.c plugins/gtkui/trkproperties.c
Diffstat (limited to 'plugins/gtkui')
-rw-r--r--plugins/gtkui/Makefile.am47
-rw-r--r--plugins/gtkui/callbacks.c135
-rw-r--r--plugins/gtkui/callbacks.h8
-rw-r--r--plugins/gtkui/ddbcellrenderertextmultiline.c285
-rw-r--r--plugins/gtkui/ddbcellrenderertextmultiline.h5
-rw-r--r--plugins/gtkui/ddbcellrenderertextmultiline.vala2
-rw-r--r--plugins/gtkui/ddbequalizer.c890
-rw-r--r--plugins/gtkui/ddbequalizer.h13
-rw-r--r--plugins/gtkui/ddbequalizer.vala183
-rw-r--r--plugins/gtkui/ddblistview.c504
-rw-r--r--plugins/gtkui/ddblistview.h5
-rw-r--r--plugins/gtkui/ddbseekbar.c92
-rw-r--r--plugins/gtkui/ddbseekbar.h3
-rw-r--r--plugins/gtkui/ddbtabstrip.c284
-rw-r--r--plugins/gtkui/ddbvolumebar.c125
-rw-r--r--plugins/gtkui/deadbeef.glade229
-rw-r--r--plugins/gtkui/drawing.h14
-rw-r--r--plugins/gtkui/eq.c10
-rw-r--r--plugins/gtkui/fileman.c7
-rw-r--r--plugins/gtkui/gdkdrawing.c58
-rw-r--r--plugins/gtkui/gtkui.c43
-rw-r--r--plugins/gtkui/gtkui.h2
-rw-r--r--plugins/gtkui/gtkui.vapi3
-rw-r--r--plugins/gtkui/interface.c246
-rw-r--r--plugins/gtkui/mainplaylist.c6
-rw-r--r--plugins/gtkui/plcommon.c45
-rw-r--r--plugins/gtkui/plcommon.h2
-rw-r--r--plugins/gtkui/pluginconf.c8
-rw-r--r--plugins/gtkui/prefwin.c25
-rw-r--r--plugins/gtkui/support.c56
-rw-r--r--plugins/gtkui/support.h37
-rw-r--r--plugins/gtkui/trkproperties.c14
-rw-r--r--plugins/gtkui/wingeom.c3
33 files changed, 2136 insertions, 1253 deletions
diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am
index 7c82d4e5..8d5c8860 100644
--- a/plugins/gtkui/Makefile.am
+++ b/plugins/gtkui/Makefile.am
@@ -1,19 +1,5 @@
if HAVE_GTKUI
gtkuidir = $(libdir)/$(PACKAGE)
-gtkui_VALASOURCES = ddbequalizer.vala ddbseekbar.vala ddbcellrenderertextmultiline.vala
-gtkui_VALABUILTSOURCES = $(gtkui_VALASOURCES:.vala=.c) ddbequalizer.h ddbseekbar.h ddbcellrenderertextmultiline.h
-if MAINTAINER_MODE
-BUILT_SOURCES = vala.stamp
-vala.stamp: $(gtkui_VALASOURCES)
- $(VALAC) -C -H ddbcellrenderertextmultiline.h --library ddbcellrenderertextmultiline --pkg=gtk+-2.0 gdk-keysyms.vapi ddbcellrenderertextmultiline.vala
- $(VALAC) -C -H ddbequalizer.h --library ddbequalizer gtkui.vapi --pkg=gtk+-2.0 ddbequalizer.vala
- $(VALAC) -C -H ddbseekbar.h --library ddbseekbar gtkui.vapi --pkg=gtk+-2.0 ddbseekbar.vala
- touch $@
-
-CLEANFILES = \
- $(BUILT_SOURCES) \
- $(gtkui_VALABUILTSOURCES)
-endif
GTKUI_SOURCES = gtkui.c gtkui.h\
callbacks.c interface.c support.c callbacks.h interface.h support.h\
@@ -37,31 +23,50 @@ GTKUI_SOURCES = gtkui.c gtkui.h\
tagwritersettings.c tagwritersettings.h\
wingeom.c wingeom.h\
pluginconf.h\
- widgets.c widgets.h
+ widgets.c widgets.h\
+ ddbseekbar.h ddbequalizer.h ddbcellrenderertextmultiline.h\
+ ddbseekbar.c ddbequalizer.c ddbcellrenderertextmultiline.c
sdkdir = $(pkgincludedir)
sdk_HEADERS = gtkui_api.h
-EXTRA_DIST = $(gtkui_VALASOURCES) deadbeef.glade
+EXTRA_DIST = deadbeef.glade
if STATICLINK
pkglib_LTLIBRARIES = ddb_gui_GTK2.la ddb_gui_GTK2.fallback.la
else
+if HAVE_GTK2
+if HAVE_GTK3
+pkglib_LTLIBRARIES = ddb_gui_GTK2.la ddb_gui_GTK3.la
+else
pkglib_LTLIBRARIES = ddb_gui_GTK2.la
endif
+else
+if HAVE_GTK3
+pkglib_LTLIBRARIES = ddb_gui_GTK3.la
+endif
+endif
+endif
# normal lib
-ddb_gui_GTK2_la_SOURCES = $(gtkui_VALABUILTSOURCES) $(GTKUI_SOURCES)
+if HAVE_GTK2
+ddb_gui_GTK2_la_SOURCES = $(GTKUI_SOURCES)
ddb_gui_GTK2_la_LDFLAGS = -module
-ddb_gui_GTK2_la_LIBADD = $(LDADD) $(GTKUI_DEPS_LIBS)
-ddb_gui_GTK2_la_CFLAGS = -std=c99 $(GTKUI_DEPS_CFLAGS)
+ddb_gui_GTK2_la_LIBADD = $(LDADD) $(GTK2_DEPS_LIBS)
+ddb_gui_GTK2_la_CFLAGS = -std=c99 $(GTK2_DEPS_CFLAGS)
+endif
+if HAVE_GTK3
+ddb_gui_GTK3_la_SOURCES = $(GTKUI_SOURCES)
+ddb_gui_GTK3_la_LDFLAGS = -module
+ddb_gui_GTK3_la_LIBADD = $(LDADD) $(GTK3_DEPS_LIBS)
+ddb_gui_GTK3_la_CFLAGS = -std=c99 $(GTK3_DEPS_CFLAGS)
+endif
# fallback lib
if STATICLINK
GTK_ROOT=@top_srcdir@/$(LIB)/gtk-2.12.12/usr
-#../../../deadbeef-deps/gtk-debian/usr
-ddb_gui_GTK2_fallback_la_SOURCES = $(gtkui_VALABUILTSOURCES) $(GTKUI_SOURCES)
+ddb_gui_GTK2_fallback_la_SOURCES = $(GTKUI_SOURCES)
ddb_gui_GTK2_fallback_la_LDFLAGS = -module
ddb_gui_GTK2_fallback_la_LIBADD = $(LDADD) -L$(GTK_ROOT)/lib $(GTK_ROOT)/lib/libgtk-x11-2.0.la $(GTK_ROOT)/lib/libgdk-x11-2.0.la $(GTK_ROOT)/lib/libpangoft2-1.0.la $(GTK_ROOT)/lib/libpangocairo-1.0.la $(GTK_ROOT)/lib/libgdk_pixbuf-2.0.la -lm $(GTK_ROOT)/lib/libcairo.la $(GTK_ROOT)/lib/libpango-1.0.la $(GTK_ROOT)/lib/libgobject-2.0.la $(GTK_ROOT)/lib/libgmodule-2.0.la $(GTK_ROOT)/lib/libgthread-2.0.la -lrt $(GTK_ROOT)/lib/libglib-2.0.la
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index ffff9a5a..8d86f1ec 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -95,12 +95,14 @@ file_filter_func (const GtkFileFilterInfo *filter_info, gpointer data) {
}
}
}
+#if 0
if (!strcasecmp (p, "pls")) {
return TRUE;
}
if (!strcasecmp (p, "m3u")) {
return TRUE;
}
+#endif
// test container (vfs) formats
DB_vfs_t **vfsplugs = deadbeef->plug_get_vfs_list ();
@@ -130,7 +132,7 @@ set_file_filter (GtkWidget *dlg, const char *name) {
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dlg), flt);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dlg), flt);
flt = gtk_file_filter_new ();
- gtk_file_filter_set_name (flt, _("Other files (*)"));
+ gtk_file_filter_set_name (flt, _("All files (*)"));
gtk_file_filter_add_pattern (flt, "*");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dlg), flt);
return flt;
@@ -306,7 +308,34 @@ void
on_playbtn_clicked (GtkButton *button,
gpointer user_data)
{
- deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
+ DB_output_t *output = deadbeef->get_output ();
+ if (output->state () == OUTPUT_STATE_PAUSED) {
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ int cur = deadbeef->plt_get_cursor (plt, PL_MAIN);
+ if (cur != -1) {
+ ddb_playItem_t *it = deadbeef->plt_get_item_for_idx (plt, cur, PL_MAIN);
+ ddb_playItem_t *it_playing = deadbeef->streamer_get_playing_track ();
+ if (it) {
+ deadbeef->pl_item_unref (it);
+ }
+ if (it_playing) {
+ deadbeef->pl_item_unref (it_playing);
+ }
+ if (it != it_playing) {
+ deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, cur, 0);
+ }
+ else {
+ deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
+ }
+ }
+ else {
+ deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
+ }
+ deadbeef->plt_unref (plt);
+ }
+ else {
+ deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
+ }
}
@@ -478,24 +507,28 @@ 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;
- }
+
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (widget, &allocation);
+ cairo_translate (cr, -allocation.x, -allocation.y);
+#endif
+
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) {
@@ -503,11 +536,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;
@@ -516,15 +548,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
@@ -545,39 +577,19 @@ seekbar_draw (GtkWidget *widget) {
cairo_fill (cr);
cairo_reset_clip (cr);
- cairo_destroy (cr);
if (trk) {
deadbeef->pl_item_unref (trk);
}
}
-#if 0
-void
-seekbar_expose (GtkWidget *widget, int x, int y, int w, int h) {
- gdk_draw_drawable (widget->window, widget->style->black_gc, seekbar_backbuf, x, y, x, y, w, h);
-}
-
-gboolean
-on_seekbar_configure_event (GtkWidget *widget,
- GdkEventConfigure *event,
- gpointer user_data)
-{
- if (seekbar_backbuf) {
- g_object_unref (seekbar_backbuf);
- seekbar_backbuf = NULL;
- }
- seekbar_backbuf = gdk_pixmap_new (widget->window, widget->allocation.width, widget->allocation.height, -1);
- seekbar_draw (widget);
- return FALSE;
-}
-#endif
-
gboolean
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;
@@ -591,7 +603,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;
}
@@ -604,7 +618,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;
}
@@ -619,8 +635,6 @@ void
seekbar_redraw (void) {
GtkWidget *widget = lookup_widget (mainwin, "seekbar");
gtk_widget_queue_draw (widget);
- //seekbar_draw (widget);
- //seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height);
}
gboolean
@@ -828,6 +842,7 @@ on_toggle_status_bar_activate (GtkMenuItem *menuitem,
gtk_widget_show (sb);
}
}
+ deadbeef->conf_save ();
}
void
@@ -847,6 +862,7 @@ on_toggle_column_headers_activate (GtkMenuItem *menuitem,
ddb_listview_show_header (DDB_LISTVIEW (playlist), 1);
}
}
+ deadbeef->conf_save ();
}
void
@@ -912,6 +928,7 @@ on_toggle_tabs (GtkMenuItem *menuitem,
deadbeef->conf_set_int ("gtkui.tabs.visible", 1);
gtk_widget_show (ts);
}
+ deadbeef->conf_save ();
}
@@ -927,6 +944,7 @@ on_toggle_eq (GtkMenuItem *menuitem,
deadbeef->conf_set_int ("gtkui.eq.visible", 1);
eq_window_show ();
}
+ deadbeef->conf_save ();
}
@@ -995,18 +1013,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);
}
@@ -1036,17 +1057,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/callbacks.h b/plugins/gtkui/callbacks.h
index 1c407678..9af9a4bf 100644
--- a/plugins/gtkui/callbacks.h
+++ b/plugins/gtkui/callbacks.h
@@ -277,10 +277,6 @@ on_volumebar_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
gpointer user_data);
-void
-on_main_quit (GtkObject *object,
- gpointer user_data);
-
gboolean
on_mainwin_delete_event (GtkWidget *widget,
GdkEvent *event,
@@ -1105,6 +1101,10 @@ on_replaygain_preamp_value_changed (GtkRange *range,
gpointer user_data);
void
+on_global_preamp_value_changed (GtkRange *range,
+ gpointer user_data);
+
+void
on_tabstrip_text_color_set (GtkColorButton *colorbutton,
gpointer user_data);
diff --git a/plugins/gtkui/ddbcellrenderertextmultiline.c b/plugins/gtkui/ddbcellrenderertextmultiline.c
index aff449b5..5bd97a9a 100644
--- a/plugins/gtkui/ddbcellrenderertextmultiline.c
+++ b/plugins/gtkui/ddbcellrenderertextmultiline.c
@@ -1,6 +1,3 @@
-/* ddbcellrenderertextmultiline.c generated by valac, the Vala compiler
- * generated from ddbcellrenderertextmultiline.vala, do not modify */
-
/*
DeaDBeeF - ultimate music player for GNU/Linux systems with X11
Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net>
@@ -25,8 +22,8 @@
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
-#include <gdk/gdkkeysyms.h>
#include <gdk/gdk.h>
+#include "support.h"
#define DDB_TYPE_CELL_EDITABLE_TEXT_VIEW (ddb_cell_editable_text_view_get_type ())
@@ -58,7 +55,7 @@ struct _DdbCellEditableTextView {
GtkTextView parent_instance;
DdbCellEditableTextViewPrivate * priv;
gboolean editing_canceled;
- char* tree_path;
+ gchar* tree_path;
};
struct _DdbCellEditableTextViewClass {
@@ -89,7 +86,10 @@ enum {
DDB_CELL_EDITABLE_TEXT_VIEW_DUMMY_PROPERTY
};
static gboolean ddb_cell_editable_text_view_real_key_press_event (GtkWidget* base, GdkEventKey* event);
-void ddb_cell_editable_text_view_start_editing (DdbCellEditableTextView* self, GdkEvent* event);
+static void ddb_cell_editable_text_view_real_start_editing (GtkCellEditable* base, GdkEvent* event);
+#if GTK_CHECK_VERSION(2,20,0)
+static void ddb_cell_editable_text_view_real_editing_canceled (GtkCellRenderer*);
+#endif
DdbCellEditableTextView* ddb_cell_editable_text_view_new (void);
DdbCellEditableTextView* ddb_cell_editable_text_view_construct (GType object_type);
static void ddb_cell_editable_text_view_finalize (GObject* obj);
@@ -100,22 +100,34 @@ enum {
};
static void ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done (DdbCellEditableTextView* entry, DdbCellRendererTextMultiline* _self_);
static gboolean ddb_cell_renderer_text_multiline_gtk_cell_renderer_focus_out_event (DdbCellEditableTextView* entry, GdkEvent* event, DdbCellRendererTextMultiline* _self_);
-static GtkCellEditable* ddb_cell_renderer_text_multiline_real_start_editing (GtkCellRenderer* base, GdkEvent* event, GtkWidget* widget, const char* path, GdkRectangle* background_area, GdkRectangle* cell_area, GtkCellRendererState flags);
+static GtkCellEditable* ddb_cell_renderer_text_multiline_real_start_editing (GtkCellRenderer* base, GdkEvent* event, GtkWidget* widget, const gchar* path, GdkRectangle* background_area, GdkRectangle* cell_area, GtkCellRendererState flags);
DdbCellRendererTextMultiline* ddb_cell_renderer_text_multiline_new (void);
DdbCellRendererTextMultiline* ddb_cell_renderer_text_multiline_construct (GType object_type);
static void ddb_cell_renderer_text_multiline_finalize (GObject* obj);
-
static gboolean ddb_cell_editable_text_view_real_key_press_event (GtkWidget* base, GdkEventKey* event) {
DdbCellEditableTextView * self;
gboolean result = FALSE;
gboolean res;
+ GdkEventKey _tmp0_;
+ guint _tmp1_;
self = (DdbCellEditableTextView*) base;
+ g_return_val_if_fail (event != NULL, FALSE);
res = TRUE;
- if ((*event).keyval == GDK_Return) {
- if (((*event).state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0) {
- res = GTK_WIDGET_CLASS (ddb_cell_editable_text_view_parent_class)->key_press_event ((GtkWidget*) GTK_TEXT_VIEW (self), event);
+ _tmp0_ = *event;
+ _tmp1_ = _tmp0_.keyval;
+ if (_tmp1_ == ((guint) GDK_Return)) {
+ GdkEventKey _tmp2_;
+ GdkModifierType _tmp3_;
+ _tmp2_ = *event;
+ _tmp3_ = _tmp2_.state;
+ if ((_tmp3_ & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0) {
+ GdkEventKey _tmp4_;
+ gboolean _tmp5_ = FALSE;
+ _tmp4_ = *event;
+ _tmp5_ = GTK_WIDGET_CLASS (ddb_cell_editable_text_view_parent_class)->key_press_event ((GtkWidget*) GTK_TEXT_VIEW (self), &_tmp4_);
+ res = _tmp5_;
} else {
gtk_cell_editable_editing_done ((GtkCellEditable*) self);
gtk_cell_editable_remove_widget ((GtkCellEditable*) self);
@@ -123,30 +135,43 @@ static gboolean ddb_cell_editable_text_view_real_key_press_event (GtkWidget* bas
return result;
}
} else {
- if ((*event).keyval == GDK_Escape) {
+ GdkEventKey _tmp6_;
+ guint _tmp7_;
+ _tmp6_ = *event;
+ _tmp7_ = _tmp6_.keyval;
+ if (_tmp7_ == ((guint) GDK_Escape)) {
self->editing_canceled = TRUE;
gtk_cell_editable_editing_done ((GtkCellEditable*) self);
gtk_cell_editable_remove_widget ((GtkCellEditable*) self);
result = TRUE;
return result;
} else {
- res = GTK_WIDGET_CLASS (ddb_cell_editable_text_view_parent_class)->key_press_event ((GtkWidget*) GTK_TEXT_VIEW (self), event);
+ GdkEventKey _tmp8_;
+ gboolean _tmp9_ = FALSE;
+ _tmp8_ = *event;
+ _tmp9_ = GTK_WIDGET_CLASS (ddb_cell_editable_text_view_parent_class)->key_press_event ((GtkWidget*) GTK_TEXT_VIEW (self), &_tmp8_);
+ res = _tmp9_;
}
}
result = res;
return result;
}
-
-void ddb_cell_editable_text_view_start_editing (DdbCellEditableTextView* self, GdkEvent* event) {
- g_return_if_fail (self != NULL);
- g_return_if_fail (event != NULL);
+static void ddb_cell_editable_text_view_real_start_editing (GtkCellEditable* base, GdkEvent* event) {
+ DdbCellEditableTextView * self;
+ self = (DdbCellEditableTextView*) base;
+ g_return_if_fail (event != NULL);
}
+#if GTK_CHECK_VERSION(2,20,0)
+static void ddb_cell_editable_text_view_real_editing_canceled (GtkCellRenderer* base) {
+}
+#endif
+
DdbCellEditableTextView* ddb_cell_editable_text_view_construct (GType object_type) {
- DdbCellEditableTextView * self;
- self = g_object_newv (object_type, 0, NULL);
+ DdbCellEditableTextView * self = NULL;
+ self = (DdbCellEditableTextView*) g_object_new (object_type, NULL);
return self;
}
@@ -162,9 +187,14 @@ static void ddb_cell_editable_text_view_class_init (DdbCellEditableTextViewClass
G_OBJECT_CLASS (klass)->finalize = ddb_cell_editable_text_view_finalize;
}
+void ddb_cell_editable_text_view_start_editing (DdbCellEditableTextView* self, GdkEvent* event) {
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (event != NULL);
+}
static void ddb_cell_editable_text_view_gtk_cell_editable_interface_init (GtkCellEditableIface * iface) {
ddb_cell_editable_text_view_gtk_cell_editable_parent_iface = g_type_interface_peek_parent (iface);
+ iface->start_editing = (void (*)(GtkCellEditable*, GdkEvent*)) ddb_cell_editable_text_view_real_start_editing;
}
@@ -201,19 +231,54 @@ static gpointer _g_object_ref0 (gpointer self) {
static void ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done (DdbCellEditableTextView* entry, DdbCellRendererTextMultiline* _self_) {
+ DdbCellEditableTextView* _tmp0_;
+ DdbCellRendererTextMultiline* _tmp1_;
+ gulong _tmp2_;
+ DdbCellRendererTextMultiline* _tmp3_;
+ DdbCellEditableTextView* _tmp4_;
+ gboolean _tmp5_;
+ DdbCellEditableTextView* _tmp6_;
+ GtkTextBuffer* _tmp7_ = NULL;
+ GtkTextBuffer* _tmp8_;
GtkTextBuffer* buf;
GtkTextIter begin = {0};
GtkTextIter end = {0};
- char* new_text;
+ GtkTextIter _tmp9_ = {0};
+ GtkTextIter _tmp10_ = {0};
+ GtkTextIter _tmp11_;
+ GtkTextIter _tmp12_;
+ gchar* _tmp13_ = NULL;
+ gchar* new_text;
+ DdbCellRendererTextMultiline* _tmp14_;
+ DdbCellEditableTextView* _tmp15_;
+ const gchar* _tmp16_;
g_return_if_fail (entry != NULL);
g_return_if_fail (_self_ != NULL);
- g_signal_handler_disconnect ((GObject*) entry, _self_->priv->focus_out_id);
- gtk_cell_renderer_stop_editing ((GtkCellRenderer*) _self_, entry->editing_canceled);
- buf = _g_object_ref0 (gtk_text_view_get_buffer ((GtkTextView*) entry));
- gtk_text_buffer_get_iter_at_offset (buf, &begin, 0);
- gtk_text_buffer_get_iter_at_offset (buf, &end, -1);
- new_text = g_strdup (gtk_text_buffer_get_text (buf, &begin, &end, TRUE));
- g_signal_emit_by_name ((GtkCellRendererText*) _self_, "edited", entry->tree_path, new_text);
+ _tmp0_ = entry;
+ _tmp1_ = _self_;
+ _tmp2_ = _tmp1_->priv->focus_out_id;
+ g_signal_handler_disconnect ((GObject*) _tmp0_, _tmp2_);
+ _tmp3_ = _self_;
+ _tmp4_ = entry;
+ _tmp5_ = _tmp4_->editing_canceled;
+ gtk_cell_renderer_stop_editing ((GtkCellRenderer*) _tmp3_, _tmp5_);
+ _tmp6_ = entry;
+ _tmp7_ = gtk_text_view_get_buffer ((GtkTextView*) _tmp6_);
+ _tmp8_ = _g_object_ref0 (_tmp7_);
+ buf = _tmp8_;
+ gtk_text_buffer_get_iter_at_offset (buf, &_tmp9_, 0);
+ begin = _tmp9_;
+ gtk_text_buffer_get_iter_at_offset (buf, &_tmp10_, -1);
+ end = _tmp10_;
+ _tmp11_ = begin;
+ _tmp12_ = end;
+ _tmp13_ = gtk_text_buffer_get_text (buf, &_tmp11_, &_tmp12_, TRUE);
+ new_text = _tmp13_;
+ _tmp14_ = _self_;
+ _tmp15_ = entry;
+ _tmp16_ = _tmp15_->tree_path;
+ g_signal_emit_by_name ((GtkCellRendererText*) _tmp14_, "edited", _tmp16_, new_text);
+ _g_free0 (new_text);
_g_object_unref0 (buf);
_g_free0 (new_text);
}
@@ -221,67 +286,156 @@ static void ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done
static gboolean ddb_cell_renderer_text_multiline_gtk_cell_renderer_focus_out_event (DdbCellEditableTextView* entry, GdkEvent* event, DdbCellRendererTextMultiline* _self_) {
gboolean result = FALSE;
+ DdbCellEditableTextView* _tmp0_;
+ DdbCellEditableTextView* _tmp1_;
g_return_val_if_fail (entry != NULL, FALSE);
g_return_val_if_fail (event != NULL, FALSE);
g_return_val_if_fail (_self_ != NULL, FALSE);
- entry->editing_canceled = TRUE;
- gtk_cell_editable_remove_widget ((GtkCellEditable*) entry);
+ _tmp0_ = entry;
+ _tmp0_->editing_canceled = TRUE;
+ _tmp1_ = entry;
+ gtk_cell_editable_remove_widget ((GtkCellEditable*) _tmp1_);
result = FALSE;
return result;
}
-static GtkCellEditable* ddb_cell_renderer_text_multiline_real_start_editing (GtkCellRenderer* base, GdkEvent* event, GtkWidget* widget, const char* path, GdkRectangle* background_area, GdkRectangle* cell_area, GtkCellRendererState flags) {
+static GtkCellEditable* ddb_cell_renderer_text_multiline_real_start_editing (GtkCellRenderer* base, GdkEvent* event, GtkWidget* widget, const gchar* path, GdkRectangle* background_area, GdkRectangle* cell_area, GtkCellRendererState flags) {
DdbCellRendererTextMultiline * self;
GtkCellEditable* result = NULL;
- gboolean _tmp0_;
+ gboolean _tmp0_ = FALSE;
+ gboolean _tmp1_;
+ const gchar* _tmp2_;
+ GtkTreePath* _tmp3_;
GtkTreePath* p;
+ GtkWidget* _tmp4_;
+ GtkTreeView* _tmp5_;
GtkTreeView* tv;
+ GtkTreeView* _tmp6_;
+ GtkTreeModel* _tmp7_ = NULL;
+ GtkListStore* _tmp8_;
GtkListStore* store;
GtkTreeIter iter = {0};
+ GtkListStore* _tmp9_;
+ GtkTreePath* _tmp10_;
+ GtkTreeIter _tmp11_ = {0};
GValue v = {0};
- GValue _tmp2_;
- GValue _tmp1_ = {0};
+ GtkListStore* _tmp12_;
+ GtkTreeIter _tmp13_;
+ GValue _tmp14_ = {0};
+ gint _tmp15_ = 0;
gint mult;
- DdbCellEditableTextView* _tmp3_;
- char* _tmp4_;
+ DdbCellEditableTextView* _tmp16_;
+ DdbCellEditableTextView* _tmp17_;
+ gint _tmp18_;
+ DdbCellEditableTextView* _tmp19_;
+ const gchar* _tmp20_;
+ gchar* _tmp21_;
+ GtkTextBuffer* _tmp22_;
GtkTextBuffer* buf;
- char* _tmp6_;
- char* _tmp5_ = NULL;
- gboolean _tmp7_;
+ gchar* _tmp23_ = NULL;
+ gchar* _tmp24_;
+ gchar* _tmp25_;
+ gboolean _tmp26_;
+ DdbCellEditableTextView* _tmp31_;
+ GtkTextBuffer* _tmp32_;
+ DdbCellEditableTextView* _tmp33_;
+ DdbCellEditableTextView* _tmp34_;
+ gulong _tmp35_ = 0UL;
+ DdbCellEditableTextView* _tmp36_;
+ GdkRectangle _tmp37_;
+ gint _tmp38_;
+ GdkRectangle _tmp39_;
+ gint _tmp40_;
+ DdbCellEditableTextView* _tmp41_;
+ DdbCellEditableTextView* _tmp42_;
self = (DdbCellRendererTextMultiline*) base;
g_return_val_if_fail (event != NULL, NULL);
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
- if (!(g_object_get ((GtkCellRendererText*) self, "editable", &_tmp0_, NULL), _tmp0_)) {
+ g_return_val_if_fail (background_area != NULL, NULL);
+ g_return_val_if_fail (cell_area != NULL, NULL);
+ g_object_get ((GtkCellRendererText*) self, "editable", &_tmp0_, NULL);
+ _tmp1_ = _tmp0_;
+ if (!_tmp1_) {
result = GTK_CELL_EDITABLE (NULL);
return result;
}
- p = gtk_tree_path_new_from_string (path);
- tv = _g_object_ref0 (GTK_TREE_VIEW (widget));
- store = _g_object_ref0 (GTK_LIST_STORE (gtk_tree_view_get_model (tv)));
- gtk_tree_model_get_iter ((GtkTreeModel*) store, &iter, p);
- gtk_tree_model_get_value ((GtkTreeModel*) store, &iter, 3, &_tmp1_);
- v = (_tmp2_ = _tmp1_, G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL, _tmp2_);
- mult = g_value_get_int (&v);
- self->priv->entry = (_tmp3_ = g_object_ref_sink (ddb_cell_editable_text_view_new ()), _g_object_unref0 (self->priv->entry), _tmp3_);
- if (mult != 0) {
+ _tmp2_ = path;
+ _tmp3_ = gtk_tree_path_new_from_string (_tmp2_);
+ p = _tmp3_;
+ _tmp4_ = widget;
+ _tmp5_ = _g_object_ref0 (GTK_TREE_VIEW (_tmp4_));
+ tv = _tmp5_;
+ _tmp6_ = tv;
+ _tmp7_ = gtk_tree_view_get_model (_tmp6_);
+ _tmp8_ = _g_object_ref0 (GTK_LIST_STORE (_tmp7_));
+ store = _tmp8_;
+ _tmp9_ = store;
+ _tmp10_ = p;
+ gtk_tree_model_get_iter ((GtkTreeModel*) _tmp9_, &_tmp11_, _tmp10_);
+ iter = _tmp11_;
+ _tmp12_ = store;
+ _tmp13_ = iter;
+ gtk_tree_model_get_value ((GtkTreeModel*) _tmp12_, &_tmp13_, 3, &_tmp14_);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ v = _tmp14_;
+ _tmp15_ = g_value_get_int (&v);
+ mult = _tmp15_;
+ _tmp16_ = ddb_cell_editable_text_view_new ();
+ _tmp17_ = g_object_ref_sink (_tmp16_);
+ _g_object_unref0 (self->priv->entry);
+ self->priv->entry = _tmp17_;
+ _tmp18_ = mult;
+ if (_tmp18_ != 0) {
g_object_set ((GtkCellRendererText*) self, "text", "", NULL);
}
- self->priv->entry->tree_path = (_tmp4_ = g_strdup (path), _g_free0 (self->priv->entry->tree_path), _tmp4_);
- buf = gtk_text_buffer_new (NULL);
- if ((_tmp7_ = (_tmp6_ = (g_object_get ((GtkCellRendererText*) self, "text", &_tmp5_, NULL), _tmp5_)) != NULL, _g_free0 (_tmp6_), _tmp7_)) {
- char* _tmp9_;
- char* _tmp8_ = NULL;
- gtk_text_buffer_set_text (buf, _tmp9_ = (g_object_get ((GtkCellRendererText*) self, "text", &_tmp8_, NULL), _tmp8_), -1);
- _g_free0 (_tmp9_);
+ _tmp19_ = self->priv->entry;
+ _tmp20_ = path;
+ _tmp21_ = g_strdup (_tmp20_);
+ _g_free0 (_tmp19_->tree_path);
+ _tmp19_->tree_path = _tmp21_;
+ _tmp22_ = gtk_text_buffer_new (NULL);
+ buf = _tmp22_;
+ g_object_get ((GtkCellRendererText*) self, "text", &_tmp23_, NULL);
+ _tmp24_ = _tmp23_;
+ _tmp25_ = _tmp24_;
+ _tmp26_ = _tmp25_ != NULL;
+ _g_free0 (_tmp25_);
+ if (_tmp26_) {
+ GtkTextBuffer* _tmp27_;
+ gchar* _tmp28_ = NULL;
+ gchar* _tmp29_;
+ gchar* _tmp30_;
+ _tmp27_ = buf;
+ g_object_get ((GtkCellRendererText*) self, "text", &_tmp28_, NULL);
+ _tmp29_ = _tmp28_;
+ _tmp30_ = _tmp29_;
+ gtk_text_buffer_set_text (_tmp27_, _tmp30_, -1);
+ _g_free0 (_tmp30_);
}
- gtk_text_view_set_buffer ((GtkTextView*) self->priv->entry, buf);
- g_signal_connect (self->priv->entry, "editing-done", (GCallback) ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done, self);
- self->priv->focus_out_id = g_signal_connect_after (self->priv->entry, "focus-out-event", (GCallback) ddb_cell_renderer_text_multiline_gtk_cell_renderer_focus_out_event, self);
- gtk_widget_set_size_request ((GtkWidget*) self->priv->entry, (*cell_area).width, (*cell_area).height);
- gtk_widget_show ((GtkWidget*) self->priv->entry);
- result = GTK_CELL_EDITABLE (self->priv->entry);
+ _tmp31_ = self->priv->entry;
+ _tmp32_ = buf;
+ gtk_text_view_set_buffer ((GtkTextView*) _tmp31_, _tmp32_);
+ _tmp33_ = self->priv->entry;
+ g_signal_connect (_tmp33_, "editing-done", (GCallback) ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done, self);
+ _tmp34_ = self->priv->entry;
+ _tmp35_ = g_signal_connect_after (_tmp34_, "focus-out-event", (GCallback) ddb_cell_renderer_text_multiline_gtk_cell_renderer_focus_out_event, self);
+ self->priv->focus_out_id = _tmp35_;
+ _tmp36_ = self->priv->entry;
+ _tmp37_ = *cell_area;
+ _tmp38_ = _tmp37_.width;
+ _tmp39_ = *cell_area;
+ _tmp40_ = _tmp39_.height;
+ gtk_widget_set_size_request ((GtkWidget*) _tmp36_, _tmp38_, _tmp40_);
+ _tmp41_ = self->priv->entry;
+ gtk_widget_show ((GtkWidget*) _tmp41_);
+ _tmp42_ = self->priv->entry;
+ result = GTK_CELL_EDITABLE (_tmp42_);
+ _g_object_unref0 (buf);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ _g_object_unref0 (store);
+ _g_object_unref0 (tv);
_gtk_tree_path_free0 (p);
_g_object_unref0 (tv);
_g_object_unref0 (store);
@@ -292,8 +446,8 @@ static GtkCellEditable* ddb_cell_renderer_text_multiline_real_start_editing (Gtk
DdbCellRendererTextMultiline* ddb_cell_renderer_text_multiline_construct (GType object_type) {
- DdbCellRendererTextMultiline * self;
- self = g_object_newv (object_type, 0, NULL);
+ DdbCellRendererTextMultiline * self = NULL;
+ self = (DdbCellRendererTextMultiline*) g_object_new (object_type, NULL);
return self;
}
@@ -306,8 +460,10 @@ DdbCellRendererTextMultiline* ddb_cell_renderer_text_multiline_new (void) {
static void ddb_cell_renderer_text_multiline_class_init (DdbCellRendererTextMultilineClass * klass) {
ddb_cell_renderer_text_multiline_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (DdbCellRendererTextMultilinePrivate));
- GTK_CELL_RENDERER_CLASS (klass)->start_editing = ddb_cell_renderer_text_multiline_real_start_editing;
G_OBJECT_CLASS (klass)->finalize = ddb_cell_renderer_text_multiline_finalize;
+#if GTK_CHECK_VERSION(2,20,0)
+ GTK_CELL_RENDERER_CLASS (klass)->editing_canceled = (void (*)(GtkCellRenderer*)) ddb_cell_editable_text_view_real_editing_canceled;
+#endif
}
@@ -337,4 +493,3 @@ GType ddb_cell_renderer_text_multiline_get_type (void) {
-
diff --git a/plugins/gtkui/ddbcellrenderertextmultiline.h b/plugins/gtkui/ddbcellrenderertextmultiline.h
index 55d4a82c..ca461f34 100644
--- a/plugins/gtkui/ddbcellrenderertextmultiline.h
+++ b/plugins/gtkui/ddbcellrenderertextmultiline.h
@@ -1,6 +1,3 @@
-/* ddbcellrenderertextmultiline.h generated by valac, the Vala compiler, do not modify */
-
-
#ifndef __DDBCELLRENDERERTEXTMULTILINE_H__
#define __DDBCELLRENDERERTEXTMULTILINE_H__
@@ -39,7 +36,7 @@ struct _DdbCellEditableTextView {
GtkTextView parent_instance;
DdbCellEditableTextViewPrivate * priv;
gboolean editing_canceled;
- char* tree_path;
+ gchar* tree_path;
};
struct _DdbCellEditableTextViewClass {
diff --git a/plugins/gtkui/ddbcellrenderertextmultiline.vala b/plugins/gtkui/ddbcellrenderertextmultiline.vala
index 4587cff9..c23aed69 100644
--- a/plugins/gtkui/ddbcellrenderertextmultiline.vala
+++ b/plugins/gtkui/ddbcellrenderertextmultiline.vala
@@ -23,7 +23,7 @@ namespace Ddb {
public bool editing_canceled = false;
public string tree_path;
- private override bool key_press_event (Gdk.EventKey event) {
+ public override bool key_press_event (Gdk.EventKey event) {
bool res = true;
if (event.keyval == Gdk.KeySyms.Return) {
if ((event.state & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK)) != 0) {
diff --git a/plugins/gtkui/ddbequalizer.c b/plugins/gtkui/ddbequalizer.c
index cf1c10eb..8f69f073 100644
--- a/plugins/gtkui/ddbequalizer.c
+++ b/plugins/gtkui/ddbequalizer.c
@@ -1,6 +1,3 @@
-/* ddbequalizer.c generated by valac, the Vala compiler
- * generated from ddbequalizer.vala, do not modify */
-
/*
SuperEQ GTK Widget for for DeaDBeeF
Copyright (C) 2010 Viktor Semykin <thesame.ml@gmail.com>
@@ -28,8 +25,10 @@
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
-#include <gtkui.h>
#include <drawing.h>
+#include <gtkui.h>
+#include <cairo.h>
+#include <pango/pangocairo.h>
#include <pango/pango.h>
@@ -46,7 +45,7 @@ typedef struct _DdbEqualizerPrivate DdbEqualizerPrivate;
#define _gdk_cursor_unref0(var) ((var == NULL) ? NULL : (var = (gdk_cursor_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
-#define _pango_font_description_free0(var) ((var == NULL) ? NULL : (var = (pango_font_description_free (var), NULL)))
+#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
struct _DdbEqualizer {
GtkDrawingArea parent_instance;
@@ -58,15 +57,15 @@ struct _DdbEqualizerClass {
};
struct _DdbEqualizerPrivate {
- double* values;
+ gdouble* values;
gint values_length1;
gint _values_size_;
- double preamp;
+ gdouble preamp;
gint mouse_y;
gboolean curve_hook;
gboolean preamp_hook;
- gint margin_bottom;
- gint margin_left;
+ gint eq_margin_bottom;
+ gint eq_margin_left;
GdkCursor* pointer_cursor;
};
@@ -82,31 +81,51 @@ 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);
-static inline double ddb_equalizer_scale (DdbEqualizer* self, double val);
+#if !GTK_CHECK_VERSION(3,0,0)
static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event);
-static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, double x, double y);
-static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, double x, double y);
+#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);
static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEventButton* event);
static gboolean ddb_equalizer_real_button_release_event (GtkWidget* base, GdkEventButton* event);
static gboolean ddb_equalizer_real_leave_notify_event (GtkWidget* base, GdkEventCrossing* event);
static gboolean ddb_equalizer_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event);
-void ddb_equalizer_set_band (DdbEqualizer* self, gint band, double v);
-double ddb_equalizer_get_band (DdbEqualizer* self, gint band);
-void ddb_equalizer_set_preamp (DdbEqualizer* self, double v);
-double ddb_equalizer_get_preamp (DdbEqualizer* self);
+void ddb_equalizer_set_band (DdbEqualizer* self, gint band, gdouble v);
+gdouble ddb_equalizer_get_band (DdbEqualizer* self, gint band);
+void ddb_equalizer_set_preamp (DdbEqualizer* self, gdouble v);
+gdouble ddb_equalizer_get_preamp (DdbEqualizer* self);
DdbEqualizer* ddb_equalizer_new (void);
DdbEqualizer* ddb_equalizer_construct (GType object_type);
static GObject * ddb_equalizer_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void ddb_equalizer_finalize (GObject* obj);
-const char* freqs[18] = {"55 Hz", "77 Hz", "110 Hz", "156 Hz", "220 Hz", "311 Hz", "440 Hz", "622 Hz", "880 Hz", "1.2 kHz", "1.8 kHz", "2.5 kHz", "3.5 kHz", "5 kHz", "7 kHz", "10 kHz", "14 kHz", "20 kHz"};
-
+const gchar* freqs[18] = {"55 Hz", "77 Hz", "110 Hz", "156 Hz", "220 Hz", "311 Hz", "440 Hz", "622 Hz", "880 Hz", "1.2 kHz", "1.8 kHz", "2.5 kHz", "3.5 kHz", "5 kHz", "7 kHz", "10 kHz", "14 kHz", "20 kHz"};
static gboolean ddb_equalizer_real_configure_event (GtkWidget* base, GdkEventConfigure* event) {
DdbEqualizer * self;
gboolean result = FALSE;
self = (DdbEqualizer*) base;
+ g_return_val_if_fail (event != NULL, FALSE);
gtkui_init_theme_colors ();
+
+ GtkStyle* _tmp0_ = NULL;
+ const PangoFontDescription* _tmp1_;
+ gint _tmp2_ = 0;
+ gdouble _tmp3_ = 0.0;
+ GdkScreen* _tmp4_ = NULL;
+ gdouble _tmp5_ = 0.0;
+ gint _tmp6_;
+
+ _tmp0_ = gtk_widget_get_style ((GtkWidget*) self);
+ _tmp1_ = _tmp0_->font_desc;
+ _tmp2_ = pango_font_description_get_size (_tmp1_);
+ _tmp3_ = pango_units_to_double (_tmp2_);
+ _tmp4_ = gdk_screen_get_default ();
+ _tmp5_ = gdk_screen_get_resolution (_tmp4_);
+ self->priv->eq_margin_bottom = (gint) (((_tmp3_ * _tmp5_) / 72) + 4);
+ _tmp6_ = self->priv->eq_margin_bottom;
+ self->priv->eq_margin_left = _tmp6_ * 4;
result = FALSE;
return result;
}
@@ -125,317 +144,351 @@ static gpointer _g_object_ref0 (gpointer self) {
}
+static gboolean ddb_equalizer_real_draw (GtkWidget *widget, cairo_t *cr) {
+ DdbEqualizer *self = DDB_EQUALIZER (widget);
+ GdkColor fore_bright_color;
+ gtkui_get_bar_foreground_color (&fore_bright_color);
+ GdkColor c1 = fore_bright_color;
+ GdkColor c2;
+ gtkui_get_bar_background_color (&c2);
+ GdkColor fore_dark_color = c2;
+
+ fore_dark_color.red += (c1.red - c2.red) * 0.5;
+ fore_dark_color.green += (c1.green - c2.green) * 0.5;
+ fore_dark_color.blue += (c1.blue - c2.blue) * 0.5;
+
+ GtkAllocation alloc;
+ gtk_widget_get_allocation (widget, &alloc);
+
+ int width = alloc.width;
+ int height = alloc.height;
+
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+ cairo_set_line_width (cr, 1.0);
+ gdk_cairo_set_source_color (cr, &c2);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
+
+ gdk_cairo_set_source_color (cr, &fore_dark_color);
+
+ //drawing grid:
+ double step = (double)(width - self->priv->eq_margin_left) / (double)(DDB_EQUALIZER_bands+1);
+ int i;
+ for (i = 0; i < DDB_EQUALIZER_bands; i++)
+ {
+ //does anyone know why this method is static?
+ cairo_move_to (cr, (int)((i+1)*step)+self->priv->eq_margin_left, 0);
+ cairo_line_to (cr, (int)((i+1)*step)+self->priv->eq_margin_left, height - self->priv->eq_margin_bottom);
+ }
+
+ double vstep = (double)(height-self->priv->eq_margin_bottom);
+ for (double di=0; di < 2; di += 0.25)
+ {
+ cairo_move_to (cr, self->priv->eq_margin_left, (int)((di-self->priv->preamp)*vstep));
+ cairo_line_to (cr, width, (int)((di-self->priv->preamp)*vstep));
+ }
+ cairo_stroke (cr);
+
+ gdk_cairo_set_source_color (cr, &fore_bright_color);
+
+ //drawing freqs:
+
+ PangoLayout *l = pango_cairo_create_layout (cr);
+ PangoContext *pctx = pango_layout_get_context (l);
+
+ GtkStyle *st = gtk_widget_get_style (widget);
+
+ PangoFontDescription *fd = pango_font_description_copy (st->font_desc);
+
+ pango_font_description_set_size (fd, (int)(pango_font_description_get_size (st->font_desc) * 0.7));
+ pango_context_set_font_description (pctx, fd);
+ for (i = 0; i < DDB_EQUALIZER_bands; i++)
+ {
+ cairo_save (cr);
+ pango_layout_set_text (l, freqs[i], strlen (freqs[i]));
+ PangoRectangle ink, log;
+ pango_layout_get_pixel_extents (l, &ink, &log);
+ int offs = 2;
+ if ((i % 2) != 0) {
+ offs += 2;
+ }
+ cairo_move_to (cr, (int)((i+1)*step)+self->priv->eq_margin_left - ink.width/2, height-self->priv->eq_margin_bottom + offs);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+ }
+ pango_font_description_set_size (fd, (int)(pango_font_description_get_size (st->font_desc)));
+ pango_context_set_font_description (pctx, fd);
+
+ //drawing db's:
+ pango_layout_set_width (l, self->priv->eq_margin_left-1);
+ pango_layout_set_alignment (l, PANGO_ALIGN_RIGHT);
+
+ int fontsize = (int)(pango_units_to_double (pango_font_description_get_size (fd)) * gdk_screen_get_resolution (gdk_screen_get_default ()) / 72);
+
+ char tmp[100];
+
+ if ((self->priv->mouse_y >= 0) && (self->priv->mouse_y < height - self->priv->eq_margin_bottom))
+ {
+ cairo_save (cr);
+ double db = ddb_equalizer_scale(self, (double)(self->priv->mouse_y-1) / (double)(height - self->priv->eq_margin_bottom - 2));
+ snprintf (tmp, sizeof (tmp), "%s%.1fdB", db > 0 ? "+" : "", db);
+ pango_layout_set_text (l, tmp, strlen (tmp));
+ cairo_move_to (cr, self->priv->eq_margin_left-1, self->priv->mouse_y-3);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+ }
+
+ cairo_save (cr);
+ double val = ddb_equalizer_scale(self, 1);
+ snprintf (tmp, sizeof (tmp), "%s%.1fdB", val > 0 ? "+" : "", val);
+ pango_layout_set_text (l, tmp, strlen(tmp));
+ cairo_move_to (cr, self->priv->eq_margin_left-1, height-self->priv->eq_margin_bottom-fontsize);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ val = ddb_equalizer_scale(self, 0);
+ snprintf (tmp, sizeof (tmp), "%s%.1fdB", val > 0 ? "+" : "", val);
+ pango_layout_set_text (l, tmp, strlen (tmp));
+ cairo_move_to (cr, self->priv->eq_margin_left-1, 1);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ pango_layout_set_text (l, "+0dB", 4);
+ cairo_move_to (cr, self->priv->eq_margin_left-1, (int)((1-self->priv->preamp)*(height-self->priv->eq_margin_bottom))-fontsize/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);
+ cairo_move_to (cr, 1, height-self->priv->eq_margin_bottom+2);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+
+ // frame
+ cairo_rectangle (cr, self->priv->eq_margin_left, 0, width-self->priv->eq_margin_left, height-self->priv->eq_margin_bottom);
+ cairo_stroke (cr);
+
+ //draw preamp
+ cairo_rectangle (cr, 0, (int)(self->priv->preamp * (height-self->priv->eq_margin_bottom)), 11, height);
+ cairo_clip (cr);
+
+ gdk_cairo_set_source_color (cr, &fore_bright_color);
+ int count = (int)((height-self->priv->eq_margin_bottom) / 6)+1;
+ for (int j = 0; j < count; j++) {
+ cairo_rectangle (cr, 1, height-self->priv->eq_margin_bottom-j*6 - 6, 11, 4);
+ }
+ cairo_fill (cr);
+ cairo_reset_clip (cr);
+
+ //drawing bars:
+ int bar_w = 11;
+ if (step < bar_w)
+ bar_w = (int)step-1;
+
+
+ for (i = 0; i < DDB_EQUALIZER_bands; i++)
+ {
+ cairo_reset_clip (cr);
+ cairo_rectangle (cr, (int)((i+1)*step)+self->priv->eq_margin_left - bar_w/2, (int)(self->priv->values[i] * (height-self->priv->eq_margin_bottom)), 11, height);
+ cairo_clip (cr);
+ count = (int)((height-self->priv->eq_margin_bottom) * (1-self->priv->values[i]) / 6)+1;
+ for (int j = 0; j < count; j++) {
+ cairo_rectangle (cr, (int)((i+1)*step)+self->priv->eq_margin_left - bar_w/2, height-self->priv->eq_margin_bottom-j*6 - 6, bar_w, 4);
+ }
+ cairo_fill (cr);
+ }
+
+ //drawing mouse coordinates:
+ cairo_reset_clip (cr);
+ double dash[] = {4, 4};
+ cairo_set_dash (cr, dash, 2, 0);
+ cairo_move_to (cr, self->priv->eq_margin_left+1, self->priv->mouse_y);
+ cairo_line_to (cr, width, self->priv->mouse_y);
+ cairo_stroke (cr);
+
+ return FALSE;
+}
+
+#if !GTK_CHECK_VERSION(3,0,0)
static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event) {
- DdbEqualizer * self;
- gboolean result = FALSE;
- GdkColor _tmp0_ = {0};
- GdkColor fore_bright_color;
- GdkColor c1;
- GdkColor _tmp1_ = {0};
- GdkColor c2;
- GdkColor fore_dark_color;
- gint width;
- gint height;
- GdkDrawable* d;
- GdkGCValues _tmp3_;
- GdkGCValues _tmp2_ = {0};
- GdkGC* gc;
- double step;
- gint i = 0;
- double vstep;
- PangoLayout* l;
- PangoContext* ctx;
- PangoFontDescription* fd;
- gint fontsize;
- gboolean _tmp7_ = FALSE;
- char* tmp;
- double val;
- const char* _tmp9_;
- char* _tmp10_;
- const char* _tmp11_;
- char* _tmp12_;
- GdkRectangle _tmp14_;
- GdkRectangle _tmp13_ = {0};
- gint count;
- GdkRectangle _tmp17_;
- GdkRectangle _tmp16_ = {0};
- gint bar_w;
- GdkRectangle _tmp23_;
- GdkRectangle _tmp22_ = {0};
- self = (DdbEqualizer*) base;
- fore_bright_color = (gtkui_get_bar_foreground_color (&_tmp0_), _tmp0_);
- c1 = fore_bright_color;
- c2 = (gtkui_get_bar_background_color (&_tmp1_), _tmp1_);
- fore_dark_color = c2;
- fore_dark_color.red = fore_dark_color.red + ((guint16) ((gint16) ((c1.red - c2.red) * 0.5)));
- fore_dark_color.green = fore_dark_color.green + ((guint16) ((gint16) ((c1.green - c2.green) * 0.5)));
- fore_dark_color.blue = fore_dark_color.blue + ((guint16) ((gint16) ((c1.blue - c2.blue) * 0.5)));
- width = ((GtkWidget*) self)->allocation.width;
- height = ((GtkWidget*) self)->allocation.height;
- d = _g_object_ref0 ((GdkDrawable*) gtk_widget_get_window ((GtkWidget*) self));
- gc = _g_object_ref0 (GDK_DRAWABLE_GET_CLASS (d)->create_gc (d, (_tmp3_ = (memset (&_tmp2_, 0, sizeof (GdkGCValues)), _tmp2_), &_tmp3_), 0));
- gdk_gc_set_rgb_fg_color (gc, &c2);
- gdk_draw_rectangle (d, gc, TRUE, 0, 0, width, height);
- gdk_gc_set_rgb_fg_color (gc, &fore_dark_color);
- step = ((double) (width - self->priv->margin_left)) / ((double) (DDB_EQUALIZER_bands + 1));
- {
- gboolean _tmp4_;
- i = 0;
- _tmp4_ = TRUE;
- while (TRUE) {
- if (!_tmp4_) {
- i++;
- }
- _tmp4_ = FALSE;
- if (!(i < DDB_EQUALIZER_bands)) {
- break;
- }
- gdk_draw_line (d, gc, ((gint) ((i + 1) * step)) + self->priv->margin_left, 0, ((gint) ((i + 1) * step)) + self->priv->margin_left, height - self->priv->margin_bottom);
- }
- }
- vstep = (double) (height - self->priv->margin_bottom);
- {
- double di;
- di = (double) 0;
- {
- gboolean _tmp5_;
- _tmp5_ = TRUE;
- while (TRUE) {
- if (!_tmp5_) {
- di = di + 0.25;
- }
- _tmp5_ = FALSE;
- if (!(di < 2)) {
- break;
- }
- gdk_draw_line (d, gc, self->priv->margin_left, (gint) ((di - self->priv->preamp) * vstep), width, (gint) ((di - self->priv->preamp) * vstep));
- }
- }
- }
- gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
- l = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL);
- ctx = _g_object_ref0 (pango_layout_get_context (l));
- fd = pango_font_description_copy (gtk_widget_get_style ((GtkWidget*) self)->font_desc);
- pango_font_description_set_size (fd, (gint) (pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc) * 0.7));
- pango_context_set_font_description (ctx, fd);
- {
- gboolean _tmp6_;
- i = 0;
- _tmp6_ = TRUE;
- while (TRUE) {
- PangoRectangle ink = {0};
- PangoRectangle log = {0};
- gint offs;
- if (!_tmp6_) {
- i++;
- }
- _tmp6_ = FALSE;
- if (!(i < DDB_EQUALIZER_bands)) {
- break;
- }
- pango_layout_set_text (l, freqs[i], (gint) g_utf8_strlen (freqs[i], -1));
- pango_layout_get_pixel_extents (l, &ink, &log);
- offs = 2;
- if ((i % 2) != 0) {
- offs = offs + 2;
- }
- gdk_draw_layout (d, gc, (((gint) ((i + 1) * step)) + self->priv->margin_left) - (ink.width / 2), (height - self->priv->margin_bottom) + offs, l);
- }
- }
- pango_font_description_set_size (fd, (gint) pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc));
- pango_context_set_font_description (ctx, fd);
- pango_layout_set_width (l, self->priv->margin_left - 1);
- pango_layout_set_alignment (l, PANGO_ALIGN_RIGHT);
- fontsize = (gint) ((pango_units_to_double (pango_font_description_get_size (fd)) * gdk_screen_get_resolution (gdk_screen_get_default ())) / 72);
- if (self->priv->mouse_y >= 0) {
- _tmp7_ = self->priv->mouse_y < (height - self->priv->margin_bottom);
- } else {
- _tmp7_ = FALSE;
- }
- if (_tmp7_) {
- double db;
- const char* _tmp8_;
- char* tmp;
- db = ddb_equalizer_scale (self, ((double) (self->priv->mouse_y - 1)) / ((double) ((height - self->priv->margin_bottom) - 2)));
- _tmp8_ = NULL;
- if (db > 0) {
- _tmp8_ = "+";
- } else {
- _tmp8_ = "";
- }
- tmp = g_strdup_printf ("%s%.1fdB", _tmp8_, db);
- pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
- gdk_draw_layout (d, gc, self->priv->margin_left - 1, self->priv->mouse_y - 3, l);
- _g_free0 (tmp);
- }
- tmp = NULL;
- val = ddb_equalizer_scale (self, (double) 1);
- _tmp9_ = NULL;
- if (val > 0) {
- _tmp9_ = "+";
- } else {
- _tmp9_ = "";
- }
- tmp = (_tmp10_ = g_strdup_printf ("%s%.1fdB", _tmp9_, val), _g_free0 (tmp), _tmp10_);
- pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
- gdk_draw_layout (d, gc, self->priv->margin_left - 1, (height - self->priv->margin_bottom) - fontsize, l);
- val = ddb_equalizer_scale (self, (double) 0);
- _tmp11_ = NULL;
- if (val > 0) {
- _tmp11_ = "+";
- } else {
- _tmp11_ = "";
- }
- tmp = (_tmp12_ = g_strdup_printf ("%s%.1fdB", _tmp11_, val), _g_free0 (tmp), _tmp12_);
- pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
- gdk_draw_layout (d, gc, self->priv->margin_left - 1, 1, l);
- pango_layout_set_text (l, "+0dB", 4);
- gdk_draw_layout (d, gc, self->priv->margin_left - 1, ((gint) ((1 - self->priv->preamp) * (height - self->priv->margin_bottom))) - (fontsize / 2), l);
- pango_layout_set_text (l, "preamp", 6);
- pango_layout_set_alignment (l, PANGO_ALIGN_LEFT);
- gdk_draw_layout (d, gc, 1, (height - self->priv->margin_bottom) + 2, l);
- gdk_draw_rectangle (d, gc, FALSE, self->priv->margin_left, 0, (width - self->priv->margin_left) - 1, (height - self->priv->margin_bottom) - 1);
- gdk_gc_set_line_attributes (gc, 2, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
- gdk_gc_set_clip_rectangle (gc, (_tmp14_ = (_tmp13_.x = 0, _tmp13_.y = (gint) (self->priv->preamp * (height - self->priv->margin_bottom)), _tmp13_.width = 11, _tmp13_.height = height, _tmp13_), &_tmp14_));
- gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
- count = ((gint) ((height - self->priv->margin_bottom) / 6)) + 1;
- {
- gint j;
- j = 0;
- {
- gboolean _tmp15_;
- _tmp15_ = TRUE;
- while (TRUE) {
- if (!_tmp15_) {
- j++;
- }
- _tmp15_ = FALSE;
- if (!(j < count)) {
- break;
- }
- gdk_draw_rectangle (d, gc, TRUE, 1, ((height - self->priv->margin_bottom) - (j * 6)) - 6, 11, 4);
- }
- }
- }
- gdk_gc_set_clip_rectangle (gc, (_tmp17_ = (_tmp16_.x = self->priv->margin_left + 1, _tmp16_.y = 1, _tmp16_.width = (width - self->priv->margin_left) - 2, _tmp16_.height = (height - self->priv->margin_bottom) - 2, _tmp16_), &_tmp17_));
- gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
- bar_w = 11;
- if (step < bar_w) {
- bar_w = ((gint) step) - 1;
- }
- {
- gboolean _tmp18_;
- i = 0;
- _tmp18_ = TRUE;
- while (TRUE) {
- GdkRectangle _tmp20_;
- GdkRectangle _tmp19_ = {0};
- if (!_tmp18_) {
- i++;
- }
- _tmp18_ = FALSE;
- if (!(i < DDB_EQUALIZER_bands)) {
- break;
- }
- gdk_gc_set_clip_rectangle (gc, (_tmp20_ = (_tmp19_.x = (((gint) ((i + 1) * step)) + self->priv->margin_left) - (bar_w / 2), _tmp19_.y = (gint) (self->priv->values[i] * (height - self->priv->margin_bottom)), _tmp19_.width = 11, _tmp19_.height = height, _tmp19_), &_tmp20_));
- count = ((gint) (((height - self->priv->margin_bottom) * (1 - self->priv->values[i])) / 6)) + 1;
- {
- gint j;
- j = 0;
- {
- gboolean _tmp21_;
- _tmp21_ = TRUE;
- while (TRUE) {
- if (!_tmp21_) {
- j++;
- }
- _tmp21_ = FALSE;
- if (!(j < count)) {
- break;
- }
- gdk_draw_rectangle (d, gc, TRUE, (((gint) ((i + 1) * step)) + self->priv->margin_left) - (bar_w / 2), ((height - self->priv->margin_bottom) - (j * 6)) - 6, bar_w, 4);
- }
- }
- }
- }
- }
- gdk_gc_set_clip_rectangle (gc, (_tmp23_ = (_tmp22_.x = 0, _tmp22_.y = 0, _tmp22_.width = width, _tmp22_.height = height, _tmp22_), &_tmp23_));
- gdk_gc_set_line_attributes (gc, 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
- gdk_draw_line (d, gc, self->priv->margin_left + 1, self->priv->mouse_y, width, self->priv->mouse_y);
- result = FALSE;
- _g_object_unref0 (d);
- _g_object_unref0 (gc);
- _g_object_unref0 (l);
- _g_object_unref0 (ctx);
- _pango_font_description_free0 (fd);
- _g_free0 (tmp);
- return result;
+ g_return_val_if_fail (event != NULL, FALSE);
+ cairo_t *cr= gdk_cairo_create ((GdkDrawable*) gtk_widget_get_window (base));
+ ddb_equalizer_real_draw (base, cr);
+ _cairo_destroy0 (cr);
+ return FALSE;
}
+#endif
-static inline double ddb_equalizer_scale (DdbEqualizer* self, double val) {
- double result = 0.0;
- double k;
- double d;
+static inline gdouble ddb_equalizer_scale (DdbEqualizer* self, gdouble val) {
+ gdouble result = 0.0;
+ gdouble k;
+ gdouble d;
+ gdouble _tmp0_;
+ gdouble _tmp1_;
g_return_val_if_fail (self != NULL, 0.0);
- k = (double) (-40);
- d = (double) 20;
- result = (((val + self->priv->preamp) - 0.5) * k) + d;
+ k = (gdouble) (-40);
+ d = (gdouble) 20;
+ _tmp0_ = val;
+ _tmp1_ = self->priv->preamp;
+ result = (((_tmp0_ + _tmp1_) - 0.5) * k) + d;
return result;
}
-static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, double x, double y) {
+static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, gdouble x, gdouble y) {
gboolean result = FALSE;
gboolean _tmp0_ = FALSE;
gboolean _tmp1_ = FALSE;
gboolean _tmp2_ = FALSE;
+ gdouble _tmp3_;
+ gint _tmp4_;
+ gboolean _tmp8_;
+ gboolean _tmp10_;
+ gboolean _tmp15_;
g_return_val_if_fail (self != NULL, FALSE);
- if (x > self->priv->margin_left) {
- _tmp2_ = x < (((GtkWidget*) self)->allocation.width - 1);
+ _tmp3_ = x;
+ _tmp4_ = self->priv->eq_margin_left;
+ GtkAllocation _tmp6_;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp6_);
+ if (_tmp3_ > ((gdouble) _tmp4_)) {
+ gdouble _tmp5_;
+ gint _tmp7_;
+ _tmp5_ = x;
+ _tmp7_ = _tmp6_.width;
+ _tmp2_ = _tmp5_ < ((gdouble) (_tmp7_ - 1));
} else {
_tmp2_ = FALSE;
}
- if (_tmp2_) {
- _tmp1_ = y > 1;
+ _tmp8_ = _tmp2_;
+ if (_tmp8_) {
+ gdouble _tmp9_;
+ _tmp9_ = y;
+ _tmp1_ = _tmp9_ > ((gdouble) 1);
} else {
_tmp1_ = FALSE;
}
- if (_tmp1_) {
- _tmp0_ = y < (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom);
+ _tmp10_ = _tmp1_;
+ if (_tmp10_) {
+ gdouble _tmp11_;
+ GtkAllocation _tmp12_;
+ gint _tmp13_;
+ gint _tmp14_;
+ _tmp11_ = y;
+ _tmp13_ = _tmp6_.height;
+ _tmp14_ = self->priv->eq_margin_bottom;
+ _tmp0_ = _tmp11_ < ((gdouble) (_tmp13_ - _tmp14_));
} else {
_tmp0_ = FALSE;
}
- result = _tmp0_;
+ _tmp15_ = _tmp0_;
+ result = _tmp15_;
return result;
}
-static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, double x, double y) {
- double band_width;
+static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, gdouble x, gdouble y) {
+ GtkAllocation _tmp0_;
+ gint _tmp1_;
+ gint _tmp2_;
+ gdouble band_width;
+ gdouble _tmp3_;
+ gint _tmp4_;
+ gdouble _tmp5_;
+ gdouble _tmp6_ = 0.0;
gint band;
- gboolean _tmp0_ = FALSE;
+ gint _tmp7_;
+ gint _tmp8_;
+ gboolean _tmp10_ = FALSE;
+ gint _tmp11_;
+ gboolean _tmp13_;
g_return_if_fail (self != NULL);
- band_width = ((double) (((GtkWidget*) self)->allocation.width - self->priv->margin_left)) / ((double) (DDB_EQUALIZER_bands + 1));
- band = (gint) floor (((x - self->priv->margin_left) / band_width) - 0.5);
- if (band < 0) {
+ 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));
+ _tmp3_ = x;
+ _tmp4_ = self->priv->eq_margin_left;
+ _tmp5_ = band_width;
+ _tmp6_ = floor (((_tmp3_ - _tmp4_) / _tmp5_) - 0.5);
+ band = (gint) _tmp6_;
+ _tmp7_ = band;
+ if (_tmp7_ < 0) {
band = 0;
}
- if (band >= DDB_EQUALIZER_bands) {
- band = band - 1;
+ _tmp8_ = band;
+ if (_tmp8_ >= DDB_EQUALIZER_bands) {
+ gint _tmp9_;
+ _tmp9_ = band;
+ band = _tmp9_ - 1;
}
- if (band >= 0) {
- _tmp0_ = band < DDB_EQUALIZER_bands;
+ _tmp11_ = band;
+ if (_tmp11_ >= 0) {
+ gint _tmp12_;
+ _tmp12_ = band;
+ _tmp10_ = _tmp12_ < DDB_EQUALIZER_bands;
} else {
- _tmp0_ = FALSE;
+ _tmp10_ = FALSE;
}
- if (_tmp0_) {
- self->priv->values[band] = y / ((double) (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom));
- if (self->priv->values[band] > 1) {
- self->priv->values[band] = (double) 1;
+ _tmp13_ = _tmp10_;
+ if (_tmp13_) {
+ gdouble* _tmp14_;
+ gint _tmp14__length1;
+ gint _tmp15_;
+ gdouble _tmp16_;
+ GtkAllocation _tmp17_;
+ gint _tmp18_;
+ gint _tmp19_;
+ gdouble _tmp20_;
+ gdouble* _tmp21_;
+ gint _tmp21__length1;
+ gint _tmp22_;
+ gdouble _tmp23_;
+ _tmp14_ = self->priv->values;
+ _tmp14__length1 = self->priv->values_length1;
+ _tmp15_ = band;
+ _tmp16_ = y;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp17_);
+ _tmp18_ = _tmp17_.height;
+ _tmp19_ = self->priv->eq_margin_bottom;
+ _tmp14_[_tmp15_] = _tmp16_ / ((gdouble) (_tmp18_ - _tmp19_));
+ _tmp20_ = _tmp14_[_tmp15_];
+ _tmp21_ = self->priv->values;
+ _tmp21__length1 = self->priv->values_length1;
+ _tmp22_ = band;
+ _tmp23_ = _tmp21_[_tmp22_];
+ if (_tmp23_ > ((gdouble) 1)) {
+ gdouble* _tmp24_;
+ gint _tmp24__length1;
+ gint _tmp25_;
+ gdouble _tmp26_;
+ _tmp24_ = self->priv->values;
+ _tmp24__length1 = self->priv->values_length1;
+ _tmp25_ = band;
+ _tmp24_[_tmp25_] = (gdouble) 1;
+ _tmp26_ = _tmp24_[_tmp25_];
} else {
- if (self->priv->values[band] < 0) {
- self->priv->values[band] = (double) 0;
+ gdouble* _tmp27_;
+ gint _tmp27__length1;
+ gint _tmp28_;
+ gdouble _tmp29_;
+ _tmp27_ = self->priv->values;
+ _tmp27__length1 = self->priv->values_length1;
+ _tmp28_ = band;
+ _tmp29_ = _tmp27_[_tmp28_];
+ if (_tmp29_ < ((gdouble) 0)) {
+ gdouble* _tmp30_;
+ gint _tmp30__length1;
+ gint _tmp31_;
+ gdouble _tmp32_;
+ _tmp30_ = self->priv->values;
+ _tmp30__length1 = self->priv->values_length1;
+ _tmp31_ = band;
+ _tmp30_[_tmp31_] = (gdouble) 0;
+ _tmp32_ = _tmp30_[_tmp31_];
}
}
g_signal_emit_by_name (self, "on-changed");
@@ -446,38 +499,103 @@ static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, double x, double y
static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
DdbEqualizer * self;
gboolean result = FALSE;
- gboolean _tmp0_ = FALSE;
- gboolean _tmp1_ = FALSE;
- gboolean _tmp2_ = FALSE;
+ GdkEventButton _tmp0_;
+ gdouble _tmp1_;
+ GdkEventButton _tmp2_;
+ gdouble _tmp3_;
+ gboolean _tmp4_ = FALSE;
+ gboolean _tmp11_ = FALSE;
+ gboolean _tmp12_ = FALSE;
+ gboolean _tmp13_ = FALSE;
+ GdkEventButton _tmp14_;
+ gdouble _tmp15_;
+ gboolean _tmp18_;
+ gboolean _tmp24_;
+ gboolean _tmp27_;
self = (DdbEqualizer*) base;
- if (ddb_equalizer_in_curve_area (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y))) {
+ g_return_val_if_fail (event != NULL, FALSE);
+ _tmp0_ = *event;
+ _tmp1_ = _tmp0_.x;
+ _tmp2_ = *event;
+ _tmp3_ = _tmp2_.y;
+ _tmp4_ = ddb_equalizer_in_curve_area (self, (gdouble) ((gint) _tmp1_), (gdouble) ((gint) _tmp3_));
+ if (_tmp4_) {
+ GdkEventButton _tmp5_;
+ gdouble _tmp6_;
+ GdkEventButton _tmp7_;
+ gdouble _tmp8_;
+ GdkEventButton _tmp9_;
+ gdouble _tmp10_;
self->priv->curve_hook = TRUE;
- ddb_equalizer_update_eq_drag (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y));
- self->priv->mouse_y = (gint) (*event).y;
+ _tmp5_ = *event;
+ _tmp6_ = _tmp5_.x;
+ _tmp7_ = *event;
+ _tmp8_ = _tmp7_.y;
+ ddb_equalizer_update_eq_drag (self, (gdouble) ((gint) _tmp6_), (gdouble) ((gint) _tmp8_));
+ _tmp9_ = *event;
+ _tmp10_ = _tmp9_.y;
+ self->priv->mouse_y = (gint) _tmp10_;
gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
return result;
}
- if ((*event).x <= 11) {
- _tmp2_ = (*event).y > 1;
+ _tmp14_ = *event;
+ _tmp15_ = _tmp14_.x;
+ if (_tmp15_ <= ((gdouble) 11)) {
+ GdkEventButton _tmp16_;
+ gdouble _tmp17_;
+ _tmp16_ = *event;
+ _tmp17_ = _tmp16_.y;
+ _tmp13_ = _tmp17_ > ((gdouble) 1);
} else {
- _tmp2_ = FALSE;
+ _tmp13_ = FALSE;
}
- if (_tmp2_) {
- _tmp1_ = (*event).y <= (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom);
+ _tmp18_ = _tmp13_;
+ if (_tmp18_) {
+ GdkEventButton _tmp19_;
+ gdouble _tmp20_;
+ GtkAllocation _tmp21_;
+ gint _tmp22_;
+ gint _tmp23_;
+ _tmp19_ = *event;
+ _tmp20_ = _tmp19_.y;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp21_);
+ _tmp22_ = _tmp21_.height;
+ _tmp23_ = self->priv->eq_margin_bottom;
+ _tmp12_ = _tmp20_ <= ((gdouble) (_tmp22_ - _tmp23_));
} else {
- _tmp1_ = FALSE;
+ _tmp12_ = FALSE;
}
- if (_tmp1_) {
- _tmp0_ = (*event).button == 1;
+ _tmp24_ = _tmp12_;
+ if (_tmp24_) {
+ GdkEventButton _tmp25_;
+ guint _tmp26_;
+ _tmp25_ = *event;
+ _tmp26_ = _tmp25_.button;
+ _tmp11_ = _tmp26_ == ((guint) 1);
} else {
- _tmp0_ = FALSE;
+ _tmp11_ = FALSE;
}
- if (_tmp0_) {
- self->priv->preamp = (*event).y / ((double) (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom));
+ _tmp27_ = _tmp11_;
+ if (_tmp27_) {
+ GdkEventButton _tmp28_;
+ gdouble _tmp29_;
+ GtkAllocation _tmp30_;
+ gint _tmp31_;
+ gint _tmp32_;
+ GdkEventButton _tmp33_;
+ gdouble _tmp34_;
+ _tmp28_ = *event;
+ _tmp29_ = _tmp28_.y;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp30_);
+ _tmp31_ = _tmp30_.height;
+ _tmp32_ = self->priv->eq_margin_bottom;
+ self->priv->preamp = _tmp29_ / ((gdouble) (_tmp31_ - _tmp32_));
g_signal_emit_by_name (self, "on-changed");
self->priv->preamp_hook = TRUE;
- self->priv->mouse_y = (gint) (*event).y;
+ _tmp33_ = *event;
+ _tmp34_ = _tmp33_.y;
+ self->priv->mouse_y = (gint) _tmp34_;
gtk_widget_queue_draw ((GtkWidget*) self);
}
result = FALSE;
@@ -488,10 +606,15 @@ static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEvent
static gboolean ddb_equalizer_real_button_release_event (GtkWidget* base, GdkEventButton* event) {
DdbEqualizer * self;
gboolean result = FALSE;
+ GdkWindow* _tmp0_ = NULL;
+ GdkCursor* _tmp1_;
self = (DdbEqualizer*) base;
+ g_return_val_if_fail (event != NULL, FALSE);
self->priv->curve_hook = FALSE;
self->priv->preamp_hook = FALSE;
- gdk_window_set_cursor (gtk_widget_get_window ((GtkWidget*) self), self->priv->pointer_cursor);
+ _tmp0_ = gtk_widget_get_window ((GtkWidget*) self);
+ _tmp1_ = self->priv->pointer_cursor;
+ gdk_window_set_cursor (_tmp0_, _tmp1_);
result = FALSE;
return result;
}
@@ -501,6 +624,7 @@ static gboolean ddb_equalizer_real_leave_notify_event (GtkWidget* base, GdkEvent
DdbEqualizer * self;
gboolean result = FALSE;
self = (DdbEqualizer*) base;
+ g_return_val_if_fail (event != NULL, FALSE);
self->priv->mouse_y = -1;
gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
@@ -511,30 +635,77 @@ static gboolean ddb_equalizer_real_leave_notify_event (GtkWidget* base, GdkEvent
static gboolean ddb_equalizer_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) {
DdbEqualizer * self;
gboolean result = FALSE;
- double y;
+ GdkEventMotion _tmp0_;
+ gdouble _tmp1_;
+ GtkAllocation _tmp2_;
+ gint _tmp3_;
+ gint _tmp4_;
+ gdouble y;
+ gdouble _tmp5_;
+ gdouble _tmp6_;
+ gboolean _tmp7_;
+ GdkEventMotion _tmp9_;
+ gdouble _tmp10_;
+ GdkEventMotion _tmp11_;
+ gdouble _tmp12_;
+ gboolean _tmp13_ = FALSE;
+ gboolean _tmp16_;
self = (DdbEqualizer*) base;
- y = (*event).y / ((double) (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom));
- if (y < 0) {
- y = (double) 0;
+ g_return_val_if_fail (event != NULL, FALSE);
+ _tmp0_ = *event;
+ _tmp1_ = _tmp0_.y;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp2_);
+ _tmp3_ = _tmp2_.height;
+ _tmp4_ = self->priv->eq_margin_bottom;
+ y = _tmp1_ / ((gdouble) (_tmp3_ - _tmp4_));
+ _tmp5_ = y;
+ if (_tmp5_ < ((gdouble) 0)) {
+ y = (gdouble) 0;
}
- if (y > 1) {
- y = (double) 1;
+ _tmp6_ = y;
+ if (_tmp6_ > ((gdouble) 1)) {
+ y = (gdouble) 1;
}
- if (self->priv->preamp_hook) {
- self->priv->preamp = y;
+ _tmp7_ = self->priv->preamp_hook;
+ if (_tmp7_) {
+ gdouble _tmp8_;
+ _tmp8_ = y;
+ self->priv->preamp = _tmp8_;
g_signal_emit_by_name (self, "on-changed");
gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
return result;
}
- if (!ddb_equalizer_in_curve_area (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y))) {
+ _tmp9_ = *event;
+ _tmp10_ = _tmp9_.x;
+ _tmp11_ = *event;
+ _tmp12_ = _tmp11_.y;
+ _tmp13_ = ddb_equalizer_in_curve_area (self, (gdouble) ((gint) _tmp10_), (gdouble) ((gint) _tmp12_));
+ if (!_tmp13_) {
self->priv->mouse_y = -1;
} else {
- self->priv->mouse_y = (gint) (*event).y;
+ GdkEventMotion _tmp14_;
+ gdouble _tmp15_;
+ _tmp14_ = *event;
+ _tmp15_ = _tmp14_.y;
+ self->priv->mouse_y = (gint) _tmp15_;
}
- if (self->priv->curve_hook) {
- ddb_equalizer_update_eq_drag (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y));
- self->priv->mouse_y = (gint) (*event).y;
+ _tmp16_ = self->priv->curve_hook;
+ if (_tmp16_) {
+ GdkEventMotion _tmp17_;
+ gdouble _tmp18_;
+ GdkEventMotion _tmp19_;
+ gdouble _tmp20_;
+ GdkEventMotion _tmp21_;
+ gdouble _tmp22_;
+ _tmp17_ = *event;
+ _tmp18_ = _tmp17_.x;
+ _tmp19_ = *event;
+ _tmp20_ = _tmp19_.y;
+ ddb_equalizer_update_eq_drag (self, (gdouble) ((gint) _tmp18_), (gdouble) ((gint) _tmp20_));
+ _tmp21_ = *event;
+ _tmp22_ = _tmp21_.y;
+ self->priv->mouse_y = (gint) _tmp22_;
}
gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
@@ -542,37 +713,59 @@ static gboolean ddb_equalizer_real_motion_notify_event (GtkWidget* base, GdkEven
}
-void ddb_equalizer_set_band (DdbEqualizer* self, gint band, double v) {
+void ddb_equalizer_set_band (DdbEqualizer* self, gint band, gdouble v) {
+ gdouble* _tmp0_;
+ gint _tmp0__length1;
+ gint _tmp1_;
+ gdouble _tmp2_;
+ gdouble _tmp3_;
g_return_if_fail (self != NULL);
- self->priv->values[band] = 1 - ((v + 20.0) / 40.0);
+ _tmp0_ = self->priv->values;
+ _tmp0__length1 = self->priv->values_length1;
+ _tmp1_ = band;
+ _tmp2_ = v;
+ _tmp0_[_tmp1_] = 1 - ((_tmp2_ + 20.0) / 40.0);
+ _tmp3_ = _tmp0_[_tmp1_];
}
-double ddb_equalizer_get_band (DdbEqualizer* self, gint band) {
- double result = 0.0;
+gdouble ddb_equalizer_get_band (DdbEqualizer* self, gint band) {
+ gdouble result = 0.0;
+ gdouble* _tmp0_;
+ gint _tmp0__length1;
+ gint _tmp1_;
+ gdouble _tmp2_;
g_return_val_if_fail (self != NULL, 0.0);
- result = ((1 - self->priv->values[band]) * 40.0) - 20.0;
+ _tmp0_ = self->priv->values;
+ _tmp0__length1 = self->priv->values_length1;
+ _tmp1_ = band;
+ _tmp2_ = _tmp0_[_tmp1_];
+ result = ((1 - _tmp2_) * 40.0) - 20.0;
return result;
}
-void ddb_equalizer_set_preamp (DdbEqualizer* self, double v) {
+void ddb_equalizer_set_preamp (DdbEqualizer* self, gdouble v) {
+ gdouble _tmp0_;
g_return_if_fail (self != NULL);
- self->priv->preamp = 1 - ((v + 20.0) / 40.0);
+ _tmp0_ = v;
+ self->priv->preamp = 1 - ((_tmp0_ + 20.0) / 40.0);
}
-double ddb_equalizer_get_preamp (DdbEqualizer* self) {
- double result = 0.0;
+gdouble ddb_equalizer_get_preamp (DdbEqualizer* self) {
+ gdouble result = 0.0;
+ gdouble _tmp0_;
g_return_val_if_fail (self != NULL, 0.0);
- result = ((1 - self->priv->preamp) * 40.0) - 20.0;
+ _tmp0_ = self->priv->preamp;
+ result = ((1 - _tmp0_) * 40.0) - 20.0;
return result;
}
DdbEqualizer* ddb_equalizer_construct (GType object_type) {
- DdbEqualizer * self;
- self = g_object_newv (object_type, 0, NULL);
+ DdbEqualizer * self = NULL;
+ self = (DdbEqualizer*) g_object_new (object_type, NULL);
return self;
}
@@ -589,10 +782,6 @@ static GObject * ddb_equalizer_constructor (GType type, guint n_construct_proper
parent_class = G_OBJECT_CLASS (ddb_equalizer_parent_class);
obj = parent_class->constructor (type, n_construct_properties, construct_properties);
self = DDB_EQUALIZER (obj);
- {
- self->priv->margin_bottom = (gint) (((pango_units_to_double (pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc)) * gdk_screen_get_resolution (gdk_screen_get_default ())) / 72) + 4);
- self->priv->margin_left = self->priv->margin_bottom * 4;
- }
return obj;
}
@@ -602,7 +791,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;
@@ -614,17 +807,21 @@ static void ddb_equalizer_class_init (DdbEqualizerClass * klass) {
static void ddb_equalizer_instance_init (DdbEqualizer * self) {
+ gdouble* _tmp0_ = NULL;
+ GdkCursor* _tmp1_;
self->priv = DDB_EQUALIZER_GET_PRIVATE (self);
- self->priv->values = g_new0 (double, DDB_EQUALIZER_bands);
+ _tmp0_ = g_new0 (gdouble, DDB_EQUALIZER_bands);
+ self->priv->values = _tmp0_;
self->priv->values_length1 = DDB_EQUALIZER_bands;
self->priv->_values_size_ = self->priv->values_length1;
self->priv->preamp = 0.5;
self->priv->mouse_y = -1;
self->priv->curve_hook = FALSE;
self->priv->preamp_hook = FALSE;
- self->priv->margin_bottom = -1;
- self->priv->margin_left = -1;
- self->priv->pointer_cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ self->priv->eq_margin_bottom = -1;
+ self->priv->eq_margin_left = -1;
+ _tmp1_ = gdk_cursor_new (GDK_LEFT_PTR);
+ self->priv->pointer_cursor = _tmp1_;
}
@@ -650,4 +847,3 @@ GType ddb_equalizer_get_type (void) {
-
diff --git a/plugins/gtkui/ddbequalizer.h b/plugins/gtkui/ddbequalizer.h
index b0493d52..02df70af 100644
--- a/plugins/gtkui/ddbequalizer.h
+++ b/plugins/gtkui/ddbequalizer.h
@@ -1,6 +1,3 @@
-/* ddbequalizer.h generated by valac, the Vala compiler, do not modify */
-
-
#ifndef __DDBEQUALIZER_H__
#define __DDBEQUALIZER_H__
@@ -33,11 +30,11 @@ struct _DdbEqualizerClass {
};
-GType ddb_equalizer_get_type (void);
-void ddb_equalizer_set_band (DdbEqualizer* self, gint band, double v);
-double ddb_equalizer_get_band (DdbEqualizer* self, gint band);
-void ddb_equalizer_set_preamp (DdbEqualizer* self, double v);
-double ddb_equalizer_get_preamp (DdbEqualizer* self);
+GType ddb_equalizer_get_type (void) G_GNUC_CONST;
+void ddb_equalizer_set_band (DdbEqualizer* self, gint band, gdouble v);
+gdouble ddb_equalizer_get_band (DdbEqualizer* self, gint band);
+void ddb_equalizer_set_preamp (DdbEqualizer* self, gdouble v);
+gdouble ddb_equalizer_get_preamp (DdbEqualizer* self);
DdbEqualizer* ddb_equalizer_new (void);
DdbEqualizer* ddb_equalizer_construct (GType object_type);
diff --git a/plugins/gtkui/ddbequalizer.vala b/plugins/gtkui/ddbequalizer.vala
index 4b82671c..82a1f060 100644
--- a/plugins/gtkui/ddbequalizer.vala
+++ b/plugins/gtkui/ddbequalizer.vala
@@ -18,6 +18,9 @@
// sripped down and polished by Alexey Yakovenko <waker@users.sourceforge.net>
+using Gtk;
+using Gdk;
+
const string[] freqs = {
"55 Hz","77 Hz","110 Hz","156 Hz","220 Hz","311 Hz","440 Hz","622 Hz","880 Hz",
"1.2 kHz","1.8 kHz","2.5 kHz","3.5 kHz","5 kHz","7 kHz","10 kHz","14 kHz","20 kHz"
@@ -36,8 +39,8 @@ namespace Ddb {
private bool curve_hook = false;
private bool preamp_hook = false;
- private int margin_bottom = -1;
- private int margin_left = -1;
+ private int eq_margin_bottom = -1;
+ private int eq_margin_left = -1;
static const int spot_size = 3;
static const int bands = 18;
@@ -47,8 +50,8 @@ namespace Ddb {
construct
{
- margin_bottom = (int)(Pango.units_to_double (get_style ().font_desc.get_size ()) * Gdk.Screen.get_default ().get_resolution () / 72 + 4);
- margin_left = margin_bottom * 4;
+ eq_margin_bottom = (int)(Pango.units_to_double (get_style ().font_desc.get_size ()) * Gdk.Screen.get_default ().get_resolution () / 72 + 4);
+ eq_margin_left = eq_margin_bottom * 4;
//color_changed ();
}
@@ -75,121 +78,131 @@ namespace Ddb {
fore_dark_color.green += (int16)((c1.green - c2.green) * 0.5);
fore_dark_color.blue += (int16)((c1.blue - c2.blue) * 0.5);
- int width = allocation.width;
- int height = allocation.height;
+ Allocation alloc;
+ get_allocation (out alloc);
- Gdk.Drawable d = get_window();
- var gc = d.create_gc (Gdk.GCValues(), 0);
- //Gdk.Rectangle rc = {0, 0, allocation.width, allocation.height};
- //gc.set_clip_rectangle (rc);
+ int width = alloc.width;
+ int height = alloc.height;
- gc.set_rgb_fg_color (c2);
+ var ctx = Gdk.cairo_create (get_window ());
+ ctx.set_antialias (Cairo.Antialias.NONE);
+ ctx.set_line_width (1.0);
+ ctx.set_source_rgba (c2.red/65535.0, c2.green/65535.0, c2.blue/65535.0, 1);
+ ctx.rectangle (0, 0, width, height);
+ ctx.fill ();
- d.draw_rectangle (gc, true, 0, 0, width, height);
+ ctx.set_source_rgba (fore_dark_color.red/65535.0, fore_dark_color.green/65535.0, fore_dark_color.blue/65535.0, 1);
- gc.set_rgb_fg_color (fore_dark_color);
//drawing grid:
- double step = (double)(width - margin_left) / (double)(bands+1);
+ double step = (double)(width - eq_margin_left) / (double)(bands+1);
int i;
for (i = 0; i < bands; i++)
{
//does anyone know why this method is static?
- Gdk.draw_line (d, gc,
- (int)((i+1)*step)+margin_left,
- 0,
- (int)((i+1)*step)+margin_left,
- height - margin_bottom);
+ ctx.move_to ((int)((i+1)*step)+eq_margin_left, 0);
+ ctx.line_to ((int)((i+1)*step)+eq_margin_left, height - eq_margin_bottom);
}
- double vstep = (double)(height-margin_bottom);
+ double vstep = (double)(height-eq_margin_bottom);
for (double di=0; di < 2; di += 0.25)
{
- Gdk.draw_line (d, gc,
- margin_left,
- (int)((di-preamp)*vstep),
- width,
- (int)((di-preamp)*vstep));
+ ctx.move_to (eq_margin_left, (int)((di-preamp)*vstep));
+ ctx.line_to (width, (int)((di-preamp)*vstep));
}
+ ctx.stroke ();
- gc.set_rgb_fg_color (fore_bright_color);
+ ctx.set_source_rgba (fore_bright_color.red/65535.0, fore_bright_color.green/65535.0, fore_bright_color.blue/65535.0, 1);
//drawing freqs:
- Pango.Layout l = create_pango_layout (null);
- var ctx = l.get_context ();
+
+ Pango.Layout l = Pango.cairo_create_layout (ctx);
+ var pctx = l.get_context ();
var fd = get_style ().font_desc.copy ();
-// var fd = ctx.get_font_description ();
fd.set_size ((int)(get_style ().font_desc.get_size () * 0.7));
- ctx.set_font_description (fd);
+ pctx.set_font_description (fd);
for (i = 0; i < bands; i++)
{
- l.set_text (freqs[i], (int)freqs[i].len());
+ ctx.save ();
+ l.set_text (freqs[i], (int)freqs[i].length);
Pango.Rectangle ink, log;
l.get_pixel_extents (out ink, out log);
int offs = 2;
if ((i % 2) != 0) {
offs += 2;
}
- Gdk.draw_layout (d, gc, (int)((i+1)*step)+margin_left - ink.width/2, height-margin_bottom + offs, l);
+ ctx.move_to ( (int)((i+1)*step)+eq_margin_left - ink.width/2, height-eq_margin_bottom + offs);
+ Pango.cairo_show_layout (ctx, l);
+ ctx.restore ();
}
fd.set_size ((int)(get_style ().font_desc.get_size ()));
- ctx.set_font_description (fd);
+ pctx.set_font_description (fd);
//drawing db's:
- l.set_width (margin_left-1);
+ l.set_width (eq_margin_left-1);
l.set_alignment (Pango.Alignment.RIGHT);
int fontsize = (int)(Pango.units_to_double (fd.get_size ()) * Gdk.Screen.get_default ().get_resolution () / 72);
- if ((mouse_y >= 0) && (mouse_y < height - margin_bottom))
+ if ((mouse_y >= 0) && (mouse_y < height - eq_margin_bottom))
{
- double db = scale((double)(mouse_y-1) / (double)(height - margin_bottom - 2));
+ ctx.save ();
+ double db = scale((double)(mouse_y-1) / (double)(height - eq_margin_bottom - 2));
string tmp = "%s%.1fdB".printf (db > 0 ? "+" : "", db);
- l.set_text (tmp, (int)tmp.len());
- Gdk.draw_layout (d, gc, margin_left-1, mouse_y-3, l);
+ l.set_text (tmp, (int)tmp.length);
+ ctx.move_to (eq_margin_left-1, mouse_y-3);
+ Pango.cairo_show_layout (ctx, l);
+ ctx.restore ();
}
+ ctx.save ();
string tmp;
double val = scale(1);
tmp = "%s%.1fdB".printf (val > 0 ? "+" : "", val);
- l.set_text (tmp, (int)tmp.len());
- Gdk.draw_layout (d, gc, margin_left-1, height-margin_bottom-fontsize, l);
+ l.set_text (tmp, (int)tmp.length);
+ ctx.move_to (eq_margin_left-1, height-eq_margin_bottom-fontsize);
+ Pango.cairo_show_layout (ctx, l);
+ ctx.restore ();
+ ctx.save ();
val = scale(0);
tmp = "%s%.1fdB".printf (val > 0 ? "+" : "", val);
- l.set_text (tmp, (int)tmp.len());
- Gdk.draw_layout (d, gc, margin_left-1, 1, l);
+ l.set_text (tmp, (int)tmp.length);
+ ctx.move_to (eq_margin_left-1, 1);
+ Pango.cairo_show_layout (ctx, l);
+ ctx.restore ();
+ ctx.save ();
l.set_text ("+0dB", 4);
- Gdk.draw_layout (d, gc, margin_left-1, (int)((1-preamp)*(height-margin_bottom))-fontsize/2, l);
+ ctx.move_to (eq_margin_left-1, (int)((1-preamp)*(height-eq_margin_bottom))-fontsize/2);
+ Pango.cairo_show_layout (ctx, l);
+ ctx.restore ();
+ ctx.save ();
l.set_text ("preamp", 6);
l.set_alignment (Pango.Alignment.LEFT);
- Gdk.draw_layout (d, gc, 1, height-margin_bottom+2, l);
+ ctx.move_to (1, height-eq_margin_bottom+2);
+ Pango.cairo_show_layout (ctx, l);
+ ctx.restore ();
- d.draw_rectangle (gc, false, margin_left, 0, width-margin_left-1, height-margin_bottom-1);
- gc.set_line_attributes (2, Gdk.LineStyle.SOLID, Gdk.CapStyle.NOT_LAST, Gdk.JoinStyle.MITER);
-
- //draw preamp
- gc.set_clip_rectangle ({0, (int)(preamp * (height-margin_bottom)), 11, height});
+ // frame
+ ctx.rectangle (eq_margin_left, 0, width-eq_margin_left-1, height-eq_margin_bottom-1);
+ ctx.stroke ();
- gc.set_rgb_fg_color (fore_bright_color);
- int count = (int)((height-margin_bottom) / 6)+1;
- for (int j = 0; j < count; j++)
- d.draw_rectangle (
- gc,
- true,
- 1,
- height-margin_bottom-j*6 - 6,
- 11,
- 4);
+ //draw preamp
+ ctx.rectangle (0, (int)(preamp * (height-eq_margin_bottom)), 11, height);
+ ctx.clip ();
- gc.set_clip_rectangle ({margin_left+1, 1, width-margin_left-2, height-margin_bottom-2});
+ ctx.set_source_rgba (fore_bright_color.red/65535.0, fore_bright_color.green/65535.0, fore_bright_color.blue/65535.0, 1.0);
+ int count = (int)((height-eq_margin_bottom) / 6)+1;
+ for (int j = 0; j < count; j++) {
+ ctx.rectangle (1, height-eq_margin_bottom-j*6 - 6, 11, 4);
+ }
+ ctx.fill ();
+ ctx.reset_clip ();
//drawing bars:
- gc.set_rgb_fg_color (fore_bright_color);
-
int bar_w = 11;
if (step < bar_w)
bar_w = (int)step-1;
@@ -197,26 +210,22 @@ namespace Ddb {
for (i = 0; i < bands; i++)
{
- gc.set_clip_rectangle ({
- (int)((i+1)*step)+margin_left - bar_w/2,
- (int)(values[i] * (height-margin_bottom)),
- 11,
- height});
- count = (int)((height-margin_bottom) * (1-values[i]) / 6)+1;
- for (int j = 0; j < count; j++)
- d.draw_rectangle (
- gc,
- true,
- (int)((i+1)*step)+margin_left - bar_w/2,
- height-margin_bottom-j*6 - 6,
- bar_w,
- 4);
+ ctx.reset_clip ();
+ ctx.rectangle ((int)((i+1)*step)+eq_margin_left - bar_w/2, (int)(values[i] * (height-eq_margin_bottom)), 11, height);
+ ctx.clip ();
+ count = (int)((height-eq_margin_bottom) * (1-values[i]) / 6)+1;
+ for (int j = 0; j < count; j++) {
+ ctx.rectangle ( (int)((i+1)*step)+eq_margin_left - bar_w/2, height-eq_margin_bottom-j*6 - 6, bar_w, 4);
+ }
+ ctx.fill ();
}
- gc.set_clip_rectangle ({0, 0, width, height});
//drawing mouse coordinates:
- gc.set_line_attributes (1, Gdk.LineStyle.ON_OFF_DASH, Gdk.CapStyle.NOT_LAST, Gdk.JoinStyle.MITER);
- Gdk.draw_line (d, gc, margin_left+1, mouse_y, width, mouse_y);
+ ctx.reset_clip ();
+ ctx.set_dash (new double[] {4, 4}, 0);
+ ctx.move_to (eq_margin_left+1, mouse_y);
+ ctx.line_to (width, mouse_y);
+ ctx.stroke ();
return false;
}
@@ -233,16 +242,16 @@ namespace Ddb {
in_curve_area (double x, double y)
{
return
- x > margin_left &&
+ x > eq_margin_left &&
x < allocation.width-1 &&
y > 1 &&
- y < allocation.height-margin_bottom;
+ y < allocation.height-eq_margin_bottom;
}
private void
update_eq_drag (double x, double y) {
- double band_width = (double)(allocation.width - margin_left) / (double)(bands+1);
- int band = (int)GLib.Math.floor ((x - margin_left) / band_width - 0.5);
+ double band_width = (double)(allocation.width - eq_margin_left) / (double)(bands+1);
+ int band = (int)GLib.Math.floor ((x - eq_margin_left) / band_width - 0.5);
if (band < 0) {
band = 0;
}
@@ -250,7 +259,7 @@ namespace Ddb {
band = band-1;
}
if (band >= 0 && band < bands) {
- values[band] = y / (double)(allocation.height - margin_bottom);
+ values[band] = y / (double)(allocation.height - eq_margin_bottom);
if (values[band] > 1) {
values[band] = 1;
}
@@ -276,11 +285,11 @@ namespace Ddb {
if (event.x <= 11 &&
event.y > 1 &&
- event.y <= allocation.height-margin_bottom &&
+ event.y <= allocation.height-eq_margin_bottom &&
event.button == 1
)
{
- preamp = event.y / (double)(allocation.height - margin_bottom);
+ preamp = event.y / (double)(allocation.height - eq_margin_bottom);
on_changed ();
preamp_hook = true;
mouse_y = (int)event.y;
@@ -311,7 +320,7 @@ namespace Ddb {
/* Mouse pointer moved over widget */
public override bool
motion_notify_event (Gdk.EventMotion event) {
- double y = event.y / (double)(allocation.height - margin_bottom);
+ double y = event.y / (double)(allocation.height - eq_margin_bottom);
if (y < 0) y = 0;
if (y > 1) y = 1;
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index bc2ded0a..ba2b0080 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -20,7 +20,6 @@
#endif
#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
@@ -32,6 +31,7 @@
#include "ddblistview.h"
#include "drawing.h"
#include "gtkui.h"
+#include "support.h"
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
@@ -57,7 +57,7 @@ G_DEFINE_TYPE (DdbListview, ddb_listview, GTK_TYPE_TABLE);
struct _DdbListviewColumn {
char *title;
- int width;
+ float width;
int minheight;
struct _DdbListviewColumn *next;
void *user_data;
@@ -80,7 +80,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 +94,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 +118,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 +146,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 +191,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);
@@ -278,16 +288,15 @@ static void
ddb_listview_class_init(DdbListviewClass *class)
{
GtkTableClass *widget_class = (GtkTableClass *) class;
- GtkObjectClass *object_class = (GtkObjectClass *) class;
- // FIXME!!!
- object_class->destroy = ddb_listview_destroy;
+ GObjectClass *object_class = (GObjectClass *) class;
+ object_class->finalize = 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 ();
@@ -317,6 +326,7 @@ ddb_listview_init(DdbListview *listview)
listview->last_header_motion_ev = -1; //is it subject to remove?
listview->prev_header_x = -1;
listview->header_prepare = 0;
+ listview->header_width = 0;
listview->columns = NULL;
listview->groups = NULL;
@@ -382,9 +392,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);
@@ -400,9 +416,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);
@@ -457,7 +479,7 @@ GtkWidget * ddb_listview_new()
}
static void
-ddb_listview_destroy(GtkObject *object)
+ddb_listview_destroy(GObject *object)
{
DdbListview *listview;
@@ -525,7 +547,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;
@@ -610,11 +632,17 @@ 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) {
+ cairo_set_line_width (cr, 1);
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
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 ();
@@ -628,7 +656,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) {
@@ -640,9 +669,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++) {
@@ -655,9 +684,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);
+ gdk_cairo_set_source_color (cr, &st->bg[GTK_STATE_NORMAL]);
+ 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);
@@ -676,18 +708,22 @@ 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, "even_row_color", 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 (listview->list), 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);
+ gdk_cairo_set_source_color (cr, &clr);
+ 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;
@@ -698,14 +734,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, "even_row_color", 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 ();
@@ -713,24 +753,43 @@ 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;
+ // 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,
@@ -738,14 +797,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,
@@ -783,40 +843,8 @@ ddb_listview_vscroll_value_changed (GtkRange *widget,
return;
}
if (newscroll != ps->scrollpos) {
- GtkWidget *widget = ps->list;
- int di = newscroll - ps->scrollpos;
- int d = abs (di);
- int height = ps->list->allocation.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);
- // 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);
- }
- else {
- // scroll up
- // copy scrolled part of buffer
- 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);
- // 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);
- }
- }
- else {
- // scrolled more than view height, redraw everything
- ps->scrollpos = newscroll;
- ddb_listview_list_render (ps, 0, 0, widget->allocation.width, widget->allocation.height);
- }
+ ps->scrollpos = newscroll;
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);
}
}
@@ -839,10 +867,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);
@@ -912,7 +941,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;
@@ -950,23 +980,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)) {
@@ -976,7 +1007,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) {
@@ -1109,7 +1141,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);
@@ -1120,7 +1154,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);
@@ -1129,15 +1163,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;
@@ -1192,35 +1228,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;
@@ -1236,51 +1243,63 @@ 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)
+ 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 ? "even_row_color" : "odd_row_color", 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);
+ even ? gtkui_get_listview_even_row_color (&clr) : gtkui_get_listview_odd_row_color (&clr);
+ gdk_cairo_set_source_color (cr, &clr);
+ 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 ? "even_row_color" : "odd_row_color", 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) {
@@ -1288,24 +1307,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+1, y+1, 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 = &gtk_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 = &gtk_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);
}
@@ -1313,15 +1335,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
@@ -1819,6 +1841,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;
@@ -1830,7 +1855,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
@@ -1885,7 +1910,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) {
@@ -1893,7 +1918,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;
}
@@ -1907,14 +1932,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;
}
}
@@ -1922,16 +1947,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 ();
@@ -1942,14 +1967,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;
}
@@ -2035,9 +2062,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) {
@@ -2060,7 +2089,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;
@@ -2073,7 +2105,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
@@ -2104,26 +2136,42 @@ 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) {
+ cairo_set_line_width (cr, 1);
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
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);
+ cairo_line_to (cr, a.width, a.height);
+ cairo_stroke (cr);
#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);
+#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, 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;
@@ -2142,21 +2190,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 = &gtk_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;
@@ -2170,7 +2230,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 {
@@ -2195,16 +2259,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 = &gtk_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);
@@ -2215,21 +2287,36 @@ 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);
+ GtkAllocation a;
+ gtk_widget_get_allocation (widget, &a);
+ ddb_listview_header_expose (ps, cr, 0, 0, a.width, a.height);
+ 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
@@ -2238,11 +2325,26 @@ 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);
}
+
+ if (ps->header_width == 0) {
+ ps->header_width = a.width;
+ }
+ else if (ps->header_width != a.width && deadbeef->conf_get_int ("gtkui.autoresize_columns", 0)) {
+ float ratio = (float)a.width / ps->header_width;
+ ps->header_width = a.width;
+ struct _DdbListviewColumn *c;
+ for (c = ps->columns; c; c = c->next) {
+ c->width *= ratio;
+ }
+ }
+
return FALSE;
}
@@ -2291,7 +2393,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++);
@@ -2329,7 +2431,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;
@@ -2358,15 +2460,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;
}
@@ -2479,11 +2581,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;
}
@@ -2532,11 +2634,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;
}
@@ -2673,8 +2777,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..a43dbcc3 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);
@@ -138,6 +138,7 @@ struct _DdbListview {
float last_header_motion_ev; //is it subject to remove?
int prev_header_x;
int header_prepare;
+ int header_width; // previous width before resize
struct _DdbListviewColumn *columns;
struct _DdbListviewGroup *groups;
diff --git a/plugins/gtkui/ddbseekbar.c b/plugins/gtkui/ddbseekbar.c
index d70ebc05..f1b3a836 100644
--- a/plugins/gtkui/ddbseekbar.c
+++ b/plugins/gtkui/ddbseekbar.c
@@ -1,6 +1,3 @@
-/* ddbseekbar.c generated by valac, the Vala compiler
- * generated from ddbseekbar.vala, do not modify */
-
/*
DeaDBeeF - ultimate music player for GNU/Linux systems with X11
Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net>
@@ -24,8 +21,8 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
-#include <gtkui.h>
#include <drawing.h>
+#include <gtkui.h>
#define DDB_TYPE_SEEKBAR (ddb_seekbar_get_type ())
@@ -55,10 +52,14 @@ GType ddb_seekbar_get_type (void);
enum {
DDB_SEEKBAR_DUMMY_PROPERTY
};
-static void ddb_seekbar_real_realize (GtkWidget* base);
-static void ddb_seekbar_real_unrealize (GtkWidget* base);
-static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requisition);
+#if GTK_CHECK_VERSION(3,0,0)
+static void ddb_seekbar_get_preferred_width (GtkWidget* base, gint *minimal_width, gint *natural_width);
+static void ddb_seekbar_get_preferred_height (GtkWidget* base, gint *minimal_height, gint *natural_height);
+#else
static gboolean ddb_seekbar_real_expose_event (GtkWidget* base, GdkEventExpose* event);
+#endif
+static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requisition);
+static gboolean ddb_seekbar_real_draw (GtkWidget* base, cairo_t *cr);
static gboolean ddb_seekbar_real_button_press_event (GtkWidget* base, GdkEventButton* event);
static gboolean ddb_seekbar_real_button_release_event (GtkWidget* base, GdkEventButton* event);
static gboolean ddb_seekbar_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event);
@@ -68,43 +69,57 @@ DdbSeekbar* ddb_seekbar_construct (GType object_type);
static GObject * ddb_seekbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
+#if GTK_CHECK_VERSION(3,0,0)
+static void ddb_seekbar_get_preferred_width (GtkWidget* widget, gint *minimal_width, gint *natural_width) {
+ GtkRequisition requisition;
-static void ddb_seekbar_real_realize (GtkWidget* base) {
- DdbSeekbar * self;
- self = (DdbSeekbar*) base;
- gtk_widget_set_has_window ((GtkWidget*) self, FALSE);
- GTK_WIDGET_CLASS (ddb_seekbar_parent_class)->realize (GTK_WIDGET (self));
+ 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;
-static void ddb_seekbar_real_unrealize (GtkWidget* base) {
- DdbSeekbar * self;
- self = (DdbSeekbar*) base;
- GTK_WIDGET_CLASS (ddb_seekbar_parent_class)->unrealize (GTK_WIDGET (self));
-}
+ 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;
+ GtkRequisition _vala_requisition = {0};
self = (DdbSeekbar*) base;
+ if (requisition) {
+ *requisition = _vala_requisition;
+ }
}
+static gboolean ddb_seekbar_real_draw (GtkWidget* base, cairo_t *cr) {
+ seekbar_draw (base, cr);
+ return FALSE;
+}
+#if !GTK_CHECK_VERSION(3,0,0)
static gboolean ddb_seekbar_real_expose_event (GtkWidget* base, GdkEventExpose* event) {
- DdbSeekbar * self;
- gboolean result = FALSE;
- self = (DdbSeekbar*) base;
- 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 FALSE;
}
-
+#endif
static gboolean ddb_seekbar_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
DdbSeekbar * self;
gboolean result = FALSE;
+ GdkEventButton _tmp0_;
+ gboolean _tmp1_ = FALSE;
self = (DdbSeekbar*) base;
- result = on_seekbar_button_press_event ((GtkWidget*) self, event);
+ g_return_val_if_fail (event != NULL, FALSE);
+ _tmp0_ = *event;
+ _tmp1_ = on_seekbar_button_press_event ((GtkWidget*) self, &_tmp0_);
+ result = _tmp1_;
return result;
}
@@ -112,8 +127,13 @@ static gboolean ddb_seekbar_real_button_press_event (GtkWidget* base, GdkEventBu
static gboolean ddb_seekbar_real_button_release_event (GtkWidget* base, GdkEventButton* event) {
DdbSeekbar * self;
gboolean result = FALSE;
+ GdkEventButton _tmp0_;
+ gboolean _tmp1_ = FALSE;
self = (DdbSeekbar*) base;
- result = on_seekbar_button_release_event ((GtkWidget*) self, event);
+ g_return_val_if_fail (event != NULL, FALSE);
+ _tmp0_ = *event;
+ _tmp1_ = on_seekbar_button_release_event ((GtkWidget*) self, &_tmp0_);
+ result = _tmp1_;
return result;
}
@@ -121,8 +141,13 @@ static gboolean ddb_seekbar_real_button_release_event (GtkWidget* base, GdkEvent
static gboolean ddb_seekbar_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) {
DdbSeekbar * self;
gboolean result = FALSE;
+ GdkEventMotion _tmp0_;
+ gboolean _tmp1_ = FALSE;
self = (DdbSeekbar*) base;
- result = on_seekbar_motion_notify_event ((GtkWidget*) self, event);
+ g_return_val_if_fail (event != NULL, FALSE);
+ _tmp0_ = *event;
+ _tmp1_ = on_seekbar_motion_notify_event ((GtkWidget*) self, &_tmp0_);
+ result = _tmp1_;
return result;
}
@@ -131,6 +156,7 @@ static gboolean ddb_seekbar_real_configure_event (GtkWidget* base, GdkEventConfi
DdbSeekbar * self;
gboolean result = FALSE;
self = (DdbSeekbar*) base;
+ g_return_val_if_fail (event != NULL, FALSE);
gtkui_init_theme_colors ();
result = FALSE;
return result;
@@ -156,18 +182,20 @@ static GObject * ddb_seekbar_constructor (GType type, guint n_construct_properti
parent_class = G_OBJECT_CLASS (ddb_seekbar_parent_class);
obj = parent_class->constructor (type, n_construct_properties, construct_properties);
self = DDB_SEEKBAR (obj);
- {
- }
return obj;
}
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;
@@ -177,6 +205,7 @@ static void ddb_seekbar_class_init (DdbSeekbarClass * klass) {
static void ddb_seekbar_instance_init (DdbSeekbar * self) {
+ gtk_widget_set_has_window ((GtkWidget*) self, FALSE);
}
@@ -193,4 +222,3 @@ GType ddb_seekbar_get_type (void) {
-
diff --git a/plugins/gtkui/ddbseekbar.h b/plugins/gtkui/ddbseekbar.h
index 28c69cd3..ee455087 100644
--- a/plugins/gtkui/ddbseekbar.h
+++ b/plugins/gtkui/ddbseekbar.h
@@ -1,6 +1,3 @@
-/* ddbseekbar.h generated by valac, the Vala compiler, do not modify */
-
-
#ifndef __DDBSEEKBAR_H__
#define __DDBSEEKBAR_H__
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c
index e1882d1e..8b260cf8 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)&GTK_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)&GTK_REALIZED/*GTK_WIDGET_REALIZED (widget)*/)
+ if (gtk_widget_get_realized (widget))
{
- if (!(GTK_WIDGET_FLAGS (widget)&GTK_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)
+ 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;
widget_class->motion_notify_event = on_tabstrip_motion_notify_event;
@@ -229,8 +247,6 @@ ddb_tabstrip_class_init(DdbTabStripClass *class)
widget_class->drag_end = on_tabstrip_drag_end;
widget_class->drag_data_received = on_tabstrip_drag_data_received;
widget_class->drag_leave = on_tabstrip_drag_leave;
-
- object_class->destroy = ddb_tabstrip_destroy;
}
gboolean
@@ -252,24 +268,26 @@ on_tabstrip_drag_data_received (GtkWidget *widget,
guint target_type,
guint time)
{
- gchar *ptr=(char*)data->data;
+ DdbListview *ps = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
+
+ 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
- gtkui_receive_fm_drop (NULL, mem, data->length);
+ gtkui_receive_fm_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);
- main_drag_n_drop (NULL, p, d, length, drag_context->action == GDK_ACTION_COPY ? 1 : 0);
+ main_drag_n_drop (NULL, p, d, length, gdk_drag_context_get_selected_action (drag_context) == GDK_ACTION_COPY ? 1 : 0);
deadbeef->plt_unref (p);
}
}
@@ -307,9 +325,6 @@ ddb_tabstrip_init(DdbTabStrip *tabstrip)
tabstrip->dragpt[1] = 0;
tabstrip->prev_x = 0;
tabstrip->movepos = 0;
- g_signal_connect_after ((gpointer) tabstrip, "button_press_event",
- G_CALLBACK (on_tabstrip_button_press_event),
- NULL);
}
static int tab_clicked = -1;
@@ -322,8 +337,26 @@ static int min_tab_size = 80;
static int tab_moved = 0;
+static void
+cairo_draw_lines (cairo_t *cr, GdkPoint *pts, int cnt) {
+ for (int i = 1; i < cnt; i++) {
+ cairo_move_to (cr, pts[i-1].x+1, pts[i-1].y+1);
+ cairo_line_to (cr, pts[i].x+1, pts[i].y+1);
+ }
+}
+
+static void
+cairo_draw_poly (cairo_t *cr, GdkPoint *pts, int cnt) {
+ 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);
+ }
+}
+
+
+
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 },
@@ -332,7 +365,7 @@ ddb_tabstrip_draw_tab (GtkWidget *widget, GdkDrawable *drawable, int idx, int se
};
GdkPoint points_frame1[] = {
{ x, y + h-2 },
- { x, y + 1 },
+ { x, y + 0 },
{ x + 1, y + 0 },
{ x + w - h - 1, y + 0 },
{ x + w - h, y + 1 },
@@ -343,18 +376,16 @@ ddb_tabstrip_draw_tab (GtkWidget *widget, GdkDrawable *drawable, int idx, int se
};
GdkPoint points_frame2[] = {
{ x + 1, y + h + 1 },
- { x + 1, y + 1 },
+ { x + 1, y + 0 },
{ x + w - h - 1, y + 1 },
{ x + w - h, y + 2 },
{ x + w - h + 1, y + 2 },
{ 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;
+ 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);
@@ -364,35 +395,38 @@ 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_new_path (cr);
+ cairo_draw_poly (cr, points_filled, 4);
+ cairo_close_path (cr);
+ 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
@@ -414,14 +448,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;
@@ -432,7 +468,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) {
@@ -471,14 +509,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);
@@ -518,11 +558,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;
@@ -535,7 +578,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;
@@ -545,17 +588,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, 1);
+ cairo_line_to (cr, a.width, 1);
+ 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];
@@ -580,7 +628,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));
@@ -589,8 +637,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 = &gtk_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-1);
+ cairo_line_to (cr, a.width, a.height-1);
+ cairo_stroke (cr);
+ pclr = &gtk_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);
+ cairo_line_to (cr, a.width, a.height);
+ cairo_stroke (cr);
// calc position for drawin selected tab
x = -hscroll;
for (idx = 0; idx < tab_selected; idx++) {
@@ -606,7 +662,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);
@@ -621,11 +677,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);
@@ -636,19 +692,28 @@ tabstrip_render (DdbTabStrip *ts) {
x += w - tab_overlap_size;
}
}
-
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
@@ -745,10 +810,16 @@ create_plmenu (void)
plmenu = gtk_menu_new ();
rename_playlist1 = gtk_menu_item_new_with_mnemonic (_("Rename Playlist"));
+ if (tab_clicked == -1) {
+ gtk_widget_set_sensitive (rename_playlist1, FALSE);
+ }
gtk_widget_show (rename_playlist1);
gtk_container_add (GTK_CONTAINER (plmenu), rename_playlist1);
remove_playlist1 = gtk_menu_item_new_with_mnemonic (_("Remove Playlist"));
+ if (tab_clicked == -1) {
+ gtk_widget_set_sensitive (remove_playlist1, FALSE);
+ }
gtk_widget_show (remove_playlist1);
gtk_container_add (GTK_CONTAINER (plmenu), remove_playlist1);
@@ -838,6 +909,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);
@@ -846,7 +919,7 @@ on_tabstrip_button_press_event(GtkWidget *widget,
}
return TRUE;
}
- 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;
@@ -942,22 +1015,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;
}
@@ -980,7 +1062,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
@@ -1048,11 +1130,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..732210f3 100644
--- a/plugins/gtkui/ddbvolumebar.c
+++ b/plugins/gtkui/ddbvolumebar.c
@@ -35,73 +35,32 @@ 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);
}
static void
-ddb_volumebar_realize (GtkWidget *widget) {
- DdbVolumeBar *darea = DDB_VOLUMEBAR (widget);
-
- gtk_widget_set_has_window (widget, FALSE);
- GTK_WIDGET_CLASS (ddb_volumebar_parent_class)->realize (widget);
-
-#if 0
- if (GTK_WIDGET_NO_WINDOW (widget))
- {
- GTK_WIDGET_CLASS (ddb_volumebar_parent_class)->realize (widget);
- }
- else
- {
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
- gint attributes_mask;
- GdkWindowAttr attributes;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, darea);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- }
-
- ddb_volumebar_send_configure (DDB_VOLUMEBAR (widget));
-#endif
-}
-
-static void
ddb_volumebar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
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 +69,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);
@@ -136,9 +98,12 @@ static void
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;
@@ -157,43 +122,54 @@ ddb_volumebar_init(DdbVolumeBar *volumebar)
int db = deadbeef->volume_get_db ();
snprintf (s, sizeof (s), "%s%ddB", db < 0 ? "" : "+", db);
gtk_widget_set_tooltip_text (GTK_WIDGET (volumebar), s);
+ gtk_widget_set_has_window (GTK_WIDGET (volumebar), FALSE);
}
void
-volumebar_draw (GtkWidget *widget) {
+volumebar_draw (GtkWidget *widget, cairo_t *cr) {
if (!widget) {
return;
}
- GdkDrawable *volumebar_backbuf = GDK_DRAWABLE (widget->window);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (widget, &allocation);
+ cairo_translate (cr, -allocation.x, -allocation.y);
+#endif
+
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_foreground_color (&clr_fg);
+ gtkui_get_bar_background_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 +180,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 (gtk_widget_get_window (widget));
+ on_volumebar_draw (widget, cr);
+ 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 +229,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/deadbeef.glade b/plugins/gtkui/deadbeef.glade
index 926fa6ab..b0659ff5 100644
--- a/plugins/gtkui/deadbeef.glade
+++ b/plugins/gtkui/deadbeef.glade
@@ -2643,10 +2643,96 @@ Album</property>
</child>
<child>
- <widget class="GtkHBox" id="hbox100">
+ <widget class="GtkTable" id="table1">
<property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
<property name="homogeneous">False</property>
- <property name="spacing">8</property>
+ <property name="row_spacing">0</property>
+ <property name="column_spacing">8</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox100">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">8</property>
+
+ <child>
+ <widget class="GtkLabel" id="label125">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">-12 dB</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHScale" id="replaygain_preamp">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="draw_value">True</property>
+ <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="digits">0</property>
+ <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
+ <property name="inverted">False</property>
+ <property name="adjustment">0 -12 12 0 0 0</property>
+ <signal name="value_changed" handler="on_replaygain_preamp_value_changed" last_modification_time="Sat, 12 Mar 2011 14:20:29 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label126">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">+12 dB</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ </packing>
+ </child>
<child>
<widget class="GtkLabel" id="label124">
@@ -2657,7 +2743,7 @@ Album</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
- <property name="xalign">0.5</property>
+ <property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@@ -2667,22 +2753,25 @@ Album</property>
<property name="angle">0</property>
</widget>
<packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label125">
+ <widget class="GtkLabel" id="label124a">
<property name="visible">True</property>
- <property name="label" translatable="yes">-12 dB</property>
+ <property name="label" translatable="yes">Global preamp:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
- <property name="xalign">0.5</property>
+ <property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@@ -2692,53 +2781,97 @@ Album</property>
<property name="angle">0</property>
</widget>
<packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkHScale" id="replaygain_preamp">
+ <widget class="GtkHBox" id="hbox100a">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="draw_value">True</property>
- <property name="value_pos">GTK_POS_BOTTOM</property>
- <property name="digits">0</property>
- <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
- <property name="inverted">False</property>
- <property name="adjustment">0 -12 12 0 0 0</property>
- <signal name="value_changed" handler="on_replaygain_preamp_value_changed" last_modification_time="Sat, 12 Mar 2011 14:20:29 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
+ <property name="homogeneous">False</property>
+ <property name="spacing">8</property>
- <child>
- <widget class="GtkLabel" id="label126">
- <property name="visible">True</property>
- <property name="label" translatable="yes">+12 dB</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
+ <child>
+ <widget class="GtkLabel" id="label125a">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">-12 dB</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHScale" id="global_preamp">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="draw_value">True</property>
+ <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="digits">0</property>
+ <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
+ <property name="inverted">False</property>
+ <property name="adjustment">0 -12 12 0 0 0</property>
+ <signal name="value_changed" handler="on_global_preamp_value_changed" last_modification_time="Thu, 01 Sep 2011 11:40:00 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label126a">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">+12 dB</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
</packing>
</child>
</widget>
diff --git a/plugins/gtkui/drawing.h b/plugins/gtkui/drawing.h
index b73c9f97..3556ec62 100644
--- a/plugins/gtkui/drawing.h
+++ b/plugins/gtkui/drawing.h
@@ -30,27 +30,15 @@ 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);
-
-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);
-
-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/fileman.c b/plugins/gtkui/fileman.c
index 4b1b6949..0a366990 100644
--- a/plugins/gtkui/fileman.c
+++ b/plugins/gtkui/fileman.c
@@ -74,12 +74,16 @@ gtkpl_add_files (GSList *lst) {
g_slist_free (lst);
deadbeef->pl_add_files_end ();
deadbeef->plt_unref (plt);
+ deadbeef->pl_save_all ();
+ deadbeef->conf_save ();
}
static void
add_dirs_worker (void *data) {
GSList *lst = (GSList *)data;
gtkpl_add_dirs (lst);
+ deadbeef->pl_save_all ();
+ deadbeef->conf_save ();
}
void
@@ -104,6 +108,8 @@ static void
open_files_worker (void *data) {
GSList *lst = (GSList *)data;
gtkpl_add_files (lst);
+ deadbeef->pl_save_all ();
+ deadbeef->conf_save ();
deadbeef->pl_set_cursor (PL_MAIN, 0);
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 1, 0);
@@ -230,6 +236,7 @@ gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) {
deadbeef->pl_add_files_end ();
deadbeef->plt_unref (plt);
+ deadbeef->pl_save_all ();
g_idle_add (set_dnd_cursor_idle, first);
}
diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c
index cb795ccb..41967bb8 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,31 @@ 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);
-}
-
-void
-draw_get_canvas_size (uintptr_t canvas, int *w, int *h) {
- gdk_drawable_get_size (GDK_DRAWABLE (canvas), w, h);
}
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_line_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 +137,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 +147,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 +209,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 a7378953..e3081188 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;
@@ -261,6 +263,16 @@ on_trayicon_scroll_event (GtkWidget *widget,
deadbeef->volume_set_db (vol);
volumebar_redraw ();
+ //Update volume bar tooltip
+ if (mainwin) {
+ GtkWidget *volumebar = lookup_widget (mainwin, "volumebar");
+ char s[100];
+ int db = vol;
+ snprintf (s, sizeof (s), "%s%ddB", db < 0 ? "" : "+", db);
+ gtk_widget_set_tooltip_text (volumebar, s);
+ gtk_widget_trigger_tooltip_query (volumebar);
+ }
+
#if 0
char str[100];
if (deadbeef->conf_get_int ("gtkui.show_gain_in_db", 1)) {
@@ -277,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);
}
@@ -355,6 +367,10 @@ redraw_queued_tracks (DdbListview *pl) {
gboolean
redraw_queued_tracks_cb (gpointer plt) {
DdbListview *list = plt;
+ int iconified = gdk_window_get_state(gtk_widget_get_window(mainwin)) & GDK_WINDOW_STATE_ICONIFIED;
+ if (!gtk_widget_get_visible (mainwin) || iconified) {
+ return FALSE;
+ }
redraw_queued_tracks (list);
return FALSE;
}
@@ -476,7 +492,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;
}
@@ -828,7 +844,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;
}
@@ -871,7 +887,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
@@ -1304,11 +1320,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"
@@ -1317,6 +1341,7 @@ static const char settings_dlg[] =
"property \"Custom status icon\" entry gtkui.custom_tray_icon \"" TRAY_ICON "\" ;\n"
"property \"Run gtk_init with --sync (debug mode)\" checkbox gtkui.sync 0;\n"
"property \"Add separators between plugin context menu items\" checkbox gtkui.action_separators 0;\n"
+ "property \"Auto-resize columns to fit the main window\" checkbox gtkui.autoresize_columns 0;\n"
;
// define plugin interface
@@ -1326,7 +1351,11 @@ static ddb_gtkui_t plugin = {
.gui.plugin.version_major = 1,
.gui.plugin.version_minor = 0,
.gui.plugin.type = DB_PLUGIN_MISC,
+#if GTK_CHECK_VERSION(3,0,0)
+ .gui.plugin.id = "gtkui3",
+#else
.gui.plugin.id = "gtkui",
+#endif
.gui.plugin.name = "Standard GTK2 user interface",
.gui.plugin.descr = "Default DeaDBeeF GUI",
.gui.plugin.copyright =
diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h
index f3b075d3..6aa81529 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/gtkui.vapi b/plugins/gtkui/gtkui.vapi
index 59886a55..d18e90bb 100644
--- a/plugins/gtkui/gtkui.vapi
+++ b/plugins/gtkui/gtkui.vapi
@@ -1,5 +1,4 @@
-[CCode (cheader_filename = "gtkui.h")]
-[CCode (cheader_filename = "drawing.h")]
+[CCode (cheader_filename = "drawing.h,gtkui.h")]
[CCode (cprefix = "Gtkui", lower_case_cprefix = "gtkui_")]
namespace Gtkui {
public static unowned Gdk.Color get_bar_foreground_color ();
diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c
index d09e9dc7..4ae9d5a7 100644
--- a/plugins/gtkui/interface.c
+++ b/plugins/gtkui/interface.c
@@ -21,7 +21,7 @@
#define GLADE_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(G_OBJECT(widget)), (GDestroyNotify) g_object_unref)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
g_object_set_data (G_OBJECT (component), name, widget)
@@ -505,7 +505,7 @@ create_mainwin (void)
stopbtn = gtk_button_new ();
gtk_widget_show (stopbtn);
gtk_box_pack_start (GTK_BOX (hbox3), stopbtn, FALSE, FALSE, 0);
- GTK_WIDGET_UNSET_FLAGS (stopbtn, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(stopbtn, FALSE);
gtk_widget_add_accelerator (stopbtn, "activate", accel_group,
GDK_v, (GdkModifierType) 0,
GTK_ACCEL_VISIBLE);
@@ -518,7 +518,7 @@ create_mainwin (void)
playbtn = gtk_button_new ();
gtk_widget_show (playbtn);
gtk_box_pack_start (GTK_BOX (hbox3), playbtn, FALSE, FALSE, 0);
- GTK_WIDGET_UNSET_FLAGS (playbtn, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(playbtn, FALSE);
gtk_widget_add_accelerator (playbtn, "activate", accel_group,
GDK_x, (GdkModifierType) 0,
GTK_ACCEL_VISIBLE);
@@ -534,7 +534,7 @@ create_mainwin (void)
pausebtn = gtk_button_new ();
gtk_widget_show (pausebtn);
gtk_box_pack_start (GTK_BOX (hbox3), pausebtn, FALSE, FALSE, 0);
- GTK_WIDGET_UNSET_FLAGS (pausebtn, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(pausebtn, FALSE);
gtk_widget_add_accelerator (pausebtn, "activate", accel_group,
GDK_c, (GdkModifierType) 0,
GTK_ACCEL_VISIBLE);
@@ -550,7 +550,7 @@ create_mainwin (void)
prevbtn = gtk_button_new ();
gtk_widget_show (prevbtn);
gtk_box_pack_start (GTK_BOX (hbox3), prevbtn, FALSE, FALSE, 0);
- GTK_WIDGET_UNSET_FLAGS (prevbtn, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(prevbtn, FALSE);
gtk_widget_add_accelerator (prevbtn, "activate", accel_group,
GDK_z, (GdkModifierType) 0,
GTK_ACCEL_VISIBLE);
@@ -563,7 +563,7 @@ create_mainwin (void)
nextbtn = gtk_button_new ();
gtk_widget_show (nextbtn);
gtk_box_pack_start (GTK_BOX (hbox3), nextbtn, FALSE, FALSE, 0);
- GTK_WIDGET_UNSET_FLAGS (nextbtn, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(nextbtn, FALSE);
gtk_widget_add_accelerator (nextbtn, "activate", accel_group,
GDK_b, (GdkModifierType) 0,
GTK_ACCEL_VISIBLE);
@@ -577,15 +577,15 @@ create_mainwin (void)
gtk_widget_show (seekbar);
gtk_box_pack_start (GTK_BOX (hbox2), seekbar, TRUE, TRUE, 2);
gtk_widget_set_size_request (seekbar, 20, -1);
- GTK_WIDGET_UNSET_FLAGS (seekbar, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (seekbar, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_focus(seekbar, FALSE);
+ gtk_widget_set_can_default(seekbar, FALSE);
volumebar = create_volumebar_widget ("volumebar", "", "", 0, 0);
gtk_widget_show (volumebar);
gtk_box_pack_start (GTK_BOX (hbox2), volumebar, FALSE, TRUE, 2);
gtk_widget_set_size_request (volumebar, 70, -1);
- GTK_WIDGET_UNSET_FLAGS (volumebar, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (volumebar, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_focus(volumebar, FALSE);
+ gtk_widget_set_can_default(volumebar, FALSE);
plugins_bottom_vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (plugins_bottom_vbox);
@@ -907,8 +907,8 @@ create_searchwin (void)
searchlist = create_ddb_listview_widget ("searchlist", "", "", 0, 0);
gtk_widget_show (searchlist);
gtk_container_add (GTK_CONTAINER (frame2), searchlist);
- GTK_WIDGET_UNSET_FLAGS (searchlist, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (searchlist, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_focus(searchlist, FALSE);
+ gtk_widget_set_can_default(searchlist, FALSE);
g_signal_connect ((gpointer) searchwin, "key_press_event",
G_CALLBACK (on_searchwin_key_press_event),
@@ -1105,7 +1105,7 @@ create_progressdlg (void)
gtk_widget_show (progresstitle);
gtk_box_pack_start (GTK_BOX (vbox6), progresstitle, TRUE, FALSE, 0);
gtk_widget_set_size_request (progresstitle, 500, -1);
- GTK_WIDGET_UNSET_FLAGS (progresstitle, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(progresstitle, FALSE);
gtk_editable_set_editable (GTK_EDITABLE (progresstitle), FALSE);
gtk_entry_set_invisible_char (GTK_ENTRY (progresstitle), 8226);
@@ -1269,7 +1269,7 @@ create_trackproperties (void)
write_tags = gtk_button_new ();
gtk_widget_show (write_tags);
gtk_container_add (GTK_CONTAINER (hbuttonbox1), write_tags);
- GTK_WIDGET_SET_FLAGS (write_tags, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(write_tags, TRUE);
alignment11 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment11);
@@ -1290,7 +1290,7 @@ create_trackproperties (void)
closebtn = gtk_button_new ();
gtk_widget_show (closebtn);
gtk_container_add (GTK_CONTAINER (hbuttonbox1), closebtn);
- GTK_WIDGET_SET_FLAGS (closebtn, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(closebtn, TRUE);
alignment12 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment12);
@@ -1336,7 +1336,7 @@ create_trackproperties (void)
button2 = gtk_button_new ();
gtk_widget_show (button2);
gtk_container_add (GTK_CONTAINER (hbuttonbox2), button2);
- GTK_WIDGET_SET_FLAGS (button2, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(button2, TRUE);
alignment13 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment13);
@@ -1462,7 +1462,7 @@ create_editcolumndlg (void)
gtk_window_set_modal (GTK_WINDOW (editcolumndlg), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (editcolumndlg), GDK_WINDOW_TYPE_HINT_DIALOG);
- dialog_vbox1 = GTK_DIALOG (editcolumndlg)->vbox;
+ dialog_vbox1 = gtk_dialog_get_content_area (GTK_DIALOG (editcolumndlg));
gtk_widget_show (dialog_vbox1);
vbox14 = gtk_vbox_new (FALSE, 8);
@@ -1494,20 +1494,20 @@ create_editcolumndlg (void)
gtk_box_pack_start (GTK_BOX (hbox30), label37, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label37), 0, 0.5);
- id = gtk_combo_box_new_text ();
+ id = gtk_combo_box_text_new ();
gtk_widget_show (id);
gtk_box_pack_start (GTK_BOX (hbox30), id, TRUE, TRUE, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Item Index"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Playing"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Album Art"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Artist - Album"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Artist"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Album"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Title"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Duration"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Track Number"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Band / Album Artist"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id), _("Custom"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Item Index"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Playing"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Album Art"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Artist - Album"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Artist"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Album"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Title"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Duration"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Track Number"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Band / Album Artist"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id), _("Custom"));
hbox31 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox31);
@@ -1531,8 +1531,8 @@ create_editcolumndlg (void)
title_formatting_help_link = title_formatting_help_link_create ("title_formatting_help_link", "", "", 0, 0);
gtk_widget_show (title_formatting_help_link);
gtk_box_pack_start (GTK_BOX (hbox74), title_formatting_help_link, TRUE, TRUE, 0);
- GTK_WIDGET_UNSET_FLAGS (title_formatting_help_link, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (title_formatting_help_link, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_focus(title_formatting_help_link, FALSE);
+ gtk_widget_set_can_default(title_formatting_help_link, FALSE);
hbox32 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox32);
@@ -1543,20 +1543,20 @@ create_editcolumndlg (void)
gtk_box_pack_start (GTK_BOX (hbox32), label38, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label38), 0, 0.5);
- align = gtk_combo_box_new_text ();
+ align = gtk_combo_box_text_new ();
gtk_widget_show (align);
gtk_box_pack_start (GTK_BOX (hbox32), align, TRUE, TRUE, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (align), _("Left"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (align), _("Right"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (align), _("Left"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (align), _("Right"));
- dialog_action_area1 = GTK_DIALOG (editcolumndlg)->action_area;
+ dialog_action_area1 = gtk_dialog_get_action_area (GTK_DIALOG (editcolumndlg));
gtk_widget_show (dialog_action_area1);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
cancelbutton1 = gtk_button_new ();
gtk_widget_show (cancelbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (editcolumndlg), cancelbutton1, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(cancelbutton1, TRUE);
alignment9 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment9);
@@ -1577,7 +1577,7 @@ create_editcolumndlg (void)
okbutton1 = gtk_button_new ();
gtk_widget_show (okbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (editcolumndlg), okbutton1, GTK_RESPONSE_OK);
- GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(okbutton1, TRUE);
alignment8 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment8);
@@ -1652,11 +1652,17 @@ create_prefwin (void)
GtkWidget *label8;
GtkWidget *pref_replaygain_mode;
GtkWidget *pref_replaygain_scale;
+ GtkWidget *table1;
GtkWidget *hbox100;
- GtkWidget *label124;
GtkWidget *label125;
GtkWidget *replaygain_preamp;
GtkWidget *label126;
+ GtkWidget *label124;
+ GtkWidget *label124a;
+ GtkWidget *hbox100a;
+ GtkWidget *label125a;
+ GtkWidget *global_preamp;
+ GtkWidget *label126a;
GtkWidget *hbox66;
GtkWidget *cli_add_to_playlist;
GtkWidget *cli_playlist_name;
@@ -1789,7 +1795,7 @@ create_prefwin (void)
gtk_window_set_position (GTK_WINDOW (prefwin), GTK_WIN_POS_CENTER);
gtk_window_set_type_hint (GTK_WINDOW (prefwin), GDK_WINDOW_TYPE_HINT_DIALOG);
- dialog_vbox2 = GTK_DIALOG (prefwin)->vbox;
+ dialog_vbox2 = gtk_dialog_get_content_area (GTK_DIALOG (prefwin));
gtk_widget_show (dialog_vbox2);
notebook = gtk_notebook_new ();
@@ -1811,7 +1817,7 @@ create_prefwin (void)
gtk_box_pack_start (GTK_BOX (hbox11), label23, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label23), 0, 0.5);
- pref_output_plugin = gtk_combo_box_new_text ();
+ pref_output_plugin = gtk_combo_box_text_new ();
gtk_widget_show (pref_output_plugin);
gtk_box_pack_start (GTK_BOX (hbox11), pref_output_plugin, TRUE, TRUE, 0);
@@ -1824,7 +1830,7 @@ create_prefwin (void)
gtk_box_pack_start (GTK_BOX (hbox12), label4, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
- pref_soundcard = gtk_combo_box_new_text ();
+ pref_soundcard = gtk_combo_box_text_new ();
gtk_widget_show (pref_soundcard);
gtk_box_pack_start (GTK_BOX (hbox12), pref_soundcard, TRUE, TRUE, 0);
@@ -1850,25 +1856,28 @@ create_prefwin (void)
gtk_box_pack_start (GTK_BOX (hbox10), label8, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5);
- pref_replaygain_mode = gtk_combo_box_new_text ();
+ pref_replaygain_mode = gtk_combo_box_text_new ();
gtk_widget_show (pref_replaygain_mode);
gtk_box_pack_start (GTK_BOX (hbox10), pref_replaygain_mode, TRUE, TRUE, 0);
gtk_widget_set_size_request (pref_replaygain_mode, 337, -1);
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_replaygain_mode), _("Disable"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_replaygain_mode), _("Track"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_replaygain_mode), _("Album"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_replaygain_mode), _("Disable"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_replaygain_mode), _("Track"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_replaygain_mode), _("Album"));
pref_replaygain_scale = gtk_check_button_new_with_mnemonic (_("Replaygain peak scale"));
gtk_widget_show (pref_replaygain_scale);
gtk_box_pack_start (GTK_BOX (vbox8), pref_replaygain_scale, FALSE, FALSE, 0);
+ table1 = gtk_table_new (2, 2, FALSE);
+ gtk_widget_show (table1);
+ gtk_box_pack_start (GTK_BOX (vbox8), table1, FALSE, FALSE, 0);
+ gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
+
hbox100 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox100);
- gtk_box_pack_start (GTK_BOX (vbox8), hbox100, FALSE, FALSE, 0);
-
- label124 = gtk_label_new (_("Replaygain preamp:"));
- gtk_widget_show (label124);
- gtk_box_pack_start (GTK_BOX (hbox100), label124, FALSE, FALSE, 0);
+ gtk_table_attach (GTK_TABLE (table1), hbox100, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
label125 = gtk_label_new (_("-12 dB"));
gtk_widget_show (label125);
@@ -1884,6 +1893,40 @@ create_prefwin (void)
gtk_widget_show (label126);
gtk_box_pack_start (GTK_BOX (hbox100), label126, FALSE, FALSE, 0);
+ label124 = gtk_label_new (_("Replaygain preamp:"));
+ gtk_widget_show (label124);
+ gtk_table_attach (GTK_TABLE (table1), label124, 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label124), 0, 0.5);
+
+ label124a = gtk_label_new (_("Global preamp:"));
+ gtk_widget_show (label124a);
+ gtk_table_attach (GTK_TABLE (table1), label124a, 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label124a), 0, 0.5);
+
+ hbox100a = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox100a);
+ gtk_table_attach (GTK_TABLE (table1), hbox100a, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL), 0, 0);
+
+ label125a = gtk_label_new (_("-12 dB"));
+ gtk_widget_show (label125a);
+ gtk_box_pack_start (GTK_BOX (hbox100a), label125a, FALSE, FALSE, 0);
+
+ global_preamp = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, -12, 12, 0, 0, 0)));
+ gtk_widget_show (global_preamp);
+ gtk_box_pack_start (GTK_BOX (hbox100a), global_preamp, TRUE, TRUE, 0);
+ gtk_scale_set_value_pos (GTK_SCALE (global_preamp), GTK_POS_BOTTOM);
+ gtk_scale_set_digits (GTK_SCALE (global_preamp), 0);
+
+ label126a = gtk_label_new (_("+12 dB"));
+ gtk_widget_show (label126a);
+ gtk_box_pack_start (GTK_BOX (hbox100a), label126a, FALSE, FALSE, 0);
+
hbox66 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox66);
gtk_box_pack_start (GTK_BOX (vbox8), hbox66, FALSE, FALSE, 0);
@@ -2060,7 +2103,7 @@ create_prefwin (void)
gtk_widget_show (label128);
gtk_box_pack_start (GTK_BOX (hbox101), label128, FALSE, FALSE, 0);
- gui_plugin = gtk_combo_box_new_text ();
+ gui_plugin = gtk_combo_box_text_new ();
gtk_widget_show (gui_plugin);
gtk_box_pack_start (GTK_BOX (hbox101), gui_plugin, TRUE, TRUE, 0);
@@ -2347,15 +2390,15 @@ create_prefwin (void)
gtk_box_pack_start (GTK_BOX (hbox15), label20, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label20), 0, 0.5);
- pref_network_proxytype = gtk_combo_box_new_text ();
+ pref_network_proxytype = gtk_combo_box_text_new ();
gtk_widget_show (pref_network_proxytype);
gtk_box_pack_start (GTK_BOX (hbox15), pref_network_proxytype, TRUE, TRUE, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_network_proxytype), "HTTP");
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_network_proxytype), "HTTP_1_0");
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_network_proxytype), "SOCKS4");
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_network_proxytype), "SOCKS5");
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_network_proxytype), "SOCKS4A");
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_network_proxytype), "SOCKS5_HOSTNAME");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_network_proxytype), "HTTP");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_network_proxytype), "HTTP_1_0");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_network_proxytype), "SOCKS4");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_network_proxytype), "SOCKS5");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_network_proxytype), "SOCKS4A");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref_network_proxytype), "SOCKS5_HOSTNAME");
hbox61 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox61);
@@ -2486,22 +2529,22 @@ create_prefwin (void)
weblink = create_plugin_weblink ("weblink", "", "", 0, 0);
gtk_widget_show (weblink);
gtk_box_pack_start (GTK_BOX (hbox20), weblink, TRUE, FALSE, 0);
- GTK_WIDGET_UNSET_FLAGS (weblink, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (weblink, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_focus(weblink, FALSE);
+ gtk_widget_set_can_default(weblink, FALSE);
label3 = gtk_label_new (_("Plugins"));
gtk_widget_show (label3);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 6), label3);
gtk_misc_set_alignment (GTK_MISC (label3), 0.48, 0.5);
- dialog_action_area2 = GTK_DIALOG (prefwin)->action_area;
+ dialog_action_area2 = gtk_dialog_get_action_area (GTK_DIALOG (prefwin));
gtk_widget_show (dialog_action_area2);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END);
closebutton1 = gtk_button_new_from_stock ("gtk-close");
gtk_widget_show (closebutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (prefwin), closebutton1, GTK_RESPONSE_CLOSE);
- GTK_WIDGET_SET_FLAGS (closebutton1, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(closebutton1, TRUE);
g_signal_connect ((gpointer) prefwin, "configure_event",
G_CALLBACK (on_prefwin_configure_event),
@@ -2524,6 +2567,9 @@ create_prefwin (void)
g_signal_connect ((gpointer) replaygain_preamp, "value_changed",
G_CALLBACK (on_replaygain_preamp_value_changed),
NULL);
+ g_signal_connect ((gpointer) global_preamp, "value_changed",
+ G_CALLBACK (on_global_preamp_value_changed),
+ NULL);
g_signal_connect ((gpointer) cli_add_to_playlist, "toggled",
G_CALLBACK (on_cli_add_to_playlist_toggled),
NULL);
@@ -2684,11 +2730,17 @@ create_prefwin (void)
GLADE_HOOKUP_OBJECT (prefwin, label8, "label8");
GLADE_HOOKUP_OBJECT (prefwin, pref_replaygain_mode, "pref_replaygain_mode");
GLADE_HOOKUP_OBJECT (prefwin, pref_replaygain_scale, "pref_replaygain_scale");
+ GLADE_HOOKUP_OBJECT (prefwin, table1, "table1");
GLADE_HOOKUP_OBJECT (prefwin, hbox100, "hbox100");
- GLADE_HOOKUP_OBJECT (prefwin, label124, "label124");
GLADE_HOOKUP_OBJECT (prefwin, label125, "label125");
GLADE_HOOKUP_OBJECT (prefwin, replaygain_preamp, "replaygain_preamp");
GLADE_HOOKUP_OBJECT (prefwin, label126, "label126");
+ GLADE_HOOKUP_OBJECT (prefwin, label124, "label124");
+ GLADE_HOOKUP_OBJECT (prefwin, label124a, "label124a");
+ GLADE_HOOKUP_OBJECT (prefwin, hbox100a, "hbox100a");
+ GLADE_HOOKUP_OBJECT (prefwin, label125a, "label125a");
+ GLADE_HOOKUP_OBJECT (prefwin, global_preamp, "global_preamp");
+ GLADE_HOOKUP_OBJECT (prefwin, label126a, "label126a");
GLADE_HOOKUP_OBJECT (prefwin, hbox66, "hbox66");
GLADE_HOOKUP_OBJECT (prefwin, cli_add_to_playlist, "cli_add_to_playlist");
GLADE_HOOKUP_OBJECT (prefwin, cli_playlist_name, "cli_playlist_name");
@@ -2845,7 +2897,7 @@ create_entrydialog (void)
gtk_window_set_destroy_with_parent (GTK_WINDOW (entrydialog), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (entrydialog), GDK_WINDOW_TYPE_HINT_DIALOG);
- dialog_vbox3 = GTK_DIALOG (entrydialog)->vbox;
+ dialog_vbox3 = gtk_dialog_get_content_area (GTK_DIALOG (entrydialog));
gtk_widget_show (dialog_vbox3);
vbox15 = gtk_vbox_new (FALSE, 0);
@@ -2867,14 +2919,14 @@ create_entrydialog (void)
gtk_entry_set_invisible_char (GTK_ENTRY (title), 8226);
gtk_entry_set_activates_default (GTK_ENTRY (title), TRUE);
- dialog_action_area3 = GTK_DIALOG (entrydialog)->action_area;
+ dialog_action_area3 = gtk_dialog_get_action_area (GTK_DIALOG (entrydialog));
gtk_widget_show (dialog_action_area3);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area3), GTK_BUTTONBOX_END);
cancelbutton2 = gtk_button_new ();
gtk_widget_show (cancelbutton2);
gtk_dialog_add_action_widget (GTK_DIALOG (entrydialog), cancelbutton2, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (cancelbutton2, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(cancelbutton2, TRUE);
alignment17 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment17);
@@ -2895,7 +2947,7 @@ create_entrydialog (void)
okbutton2 = gtk_button_new ();
gtk_widget_show (okbutton2);
gtk_dialog_add_action_widget (GTK_DIALOG (entrydialog), okbutton2, GTK_RESPONSE_OK);
- GTK_WIDGET_SET_FLAGS (okbutton2, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(okbutton2, TRUE);
alignment16 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment16);
@@ -2960,7 +3012,7 @@ create_addlocationdlg (void)
gtk_window_set_title (GTK_WINDOW (addlocationdlg), _("Add location"));
gtk_window_set_type_hint (GTK_WINDOW (addlocationdlg), GDK_WINDOW_TYPE_HINT_DIALOG);
- dialog_vbox4 = GTK_DIALOG (addlocationdlg)->vbox;
+ dialog_vbox4 = gtk_dialog_get_content_area (GTK_DIALOG (addlocationdlg));
gtk_widget_show (dialog_vbox4);
hbox34 = gtk_hbox_new (FALSE, 8);
@@ -2979,14 +3031,14 @@ create_addlocationdlg (void)
gtk_entry_set_invisible_char (GTK_ENTRY (addlocation_entry), 8226);
gtk_entry_set_activates_default (GTK_ENTRY (addlocation_entry), TRUE);
- addlocation_actionarea = GTK_DIALOG (addlocationdlg)->action_area;
+ addlocation_actionarea = gtk_dialog_get_action_area (GTK_DIALOG (addlocationdlg));
gtk_widget_show (addlocation_actionarea);
gtk_button_box_set_layout (GTK_BUTTON_BOX (addlocation_actionarea), GTK_BUTTONBOX_END);
cancelbutton3 = gtk_button_new ();
gtk_widget_show (cancelbutton3);
gtk_dialog_add_action_widget (GTK_DIALOG (addlocationdlg), cancelbutton3, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (cancelbutton3, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(cancelbutton3, TRUE);
alignment18 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment18);
@@ -3007,7 +3059,7 @@ create_addlocationdlg (void)
okbutton3 = gtk_button_new ();
gtk_widget_show (okbutton3);
gtk_dialog_add_action_widget (GTK_DIALOG (addlocationdlg), okbutton3, GTK_RESPONSE_OK);
- GTK_WIDGET_SET_FLAGS (okbutton3, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(okbutton3, TRUE);
alignment19 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment19);
@@ -3073,7 +3125,7 @@ create_groupbydlg (void)
gtk_window_set_title (GTK_WINDOW (groupbydlg), _("Group By"));
gtk_window_set_type_hint (GTK_WINDOW (groupbydlg), GDK_WINDOW_TYPE_HINT_DIALOG);
- dialog_vbox5 = GTK_DIALOG (groupbydlg)->vbox;
+ dialog_vbox5 = gtk_dialog_get_content_area (GTK_DIALOG (groupbydlg));
gtk_widget_show (dialog_vbox5);
vbox25 = gtk_vbox_new (FALSE, 8);
@@ -3102,17 +3154,17 @@ create_groupbydlg (void)
custom1 = title_formatting_help_link_create ("custom1", "", "", 0, 0);
gtk_widget_show (custom1);
gtk_box_pack_start (GTK_BOX (hbox75), custom1, TRUE, TRUE, 0);
- GTK_WIDGET_UNSET_FLAGS (custom1, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (custom1, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_focus(custom1, FALSE);
+ gtk_widget_set_can_default(custom1, FALSE);
- dialog_action_area4 = GTK_DIALOG (groupbydlg)->action_area;
+ dialog_action_area4 = gtk_dialog_get_action_area (GTK_DIALOG (groupbydlg));
gtk_widget_show (dialog_action_area4);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area4), GTK_BUTTONBOX_END);
cancelbutton4 = gtk_button_new ();
gtk_widget_show (cancelbutton4);
gtk_dialog_add_action_widget (GTK_DIALOG (groupbydlg), cancelbutton4, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (cancelbutton4, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(cancelbutton4, TRUE);
alignment7 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment7);
@@ -3133,7 +3185,7 @@ create_groupbydlg (void)
okbutton4 = gtk_button_new ();
gtk_widget_show (okbutton4);
gtk_dialog_add_action_widget (GTK_DIALOG (groupbydlg), okbutton4, GTK_RESPONSE_OK);
- GTK_WIDGET_SET_FLAGS (okbutton4, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(okbutton4, TRUE);
alignment6 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment6);
@@ -3198,7 +3250,7 @@ create_sortbydlg (void)
gtk_window_set_modal (GTK_WINDOW (sortbydlg), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (sortbydlg), GDK_WINDOW_TYPE_HINT_DIALOG);
- dialog_vbox8 = GTK_DIALOG (sortbydlg)->vbox;
+ dialog_vbox8 = gtk_dialog_get_content_area (GTK_DIALOG (sortbydlg));
gtk_widget_show (dialog_vbox8);
vbox28 = gtk_vbox_new (FALSE, 8);
@@ -3226,8 +3278,8 @@ create_sortbydlg (void)
custom3 = title_formatting_help_link_create ("custom3", "", "", 0, 0);
gtk_widget_show (custom3);
gtk_box_pack_start (GTK_BOX (hbox77), custom3, TRUE, TRUE, 0);
- GTK_WIDGET_UNSET_FLAGS (custom3, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (custom3, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_focus(custom3, FALSE);
+ gtk_widget_set_can_default(custom3, FALSE);
hbox78 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox78);
@@ -3237,25 +3289,25 @@ create_sortbydlg (void)
gtk_widget_show (label109);
gtk_box_pack_start (GTK_BOX (hbox78), label109, FALSE, FALSE, 0);
- sortorder = gtk_combo_box_new_text ();
+ sortorder = gtk_combo_box_text_new ();
gtk_widget_show (sortorder);
gtk_box_pack_start (GTK_BOX (hbox78), sortorder, TRUE, TRUE, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (sortorder), _("Ascending"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (sortorder), _("Descending"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (sortorder), _("Ascending"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (sortorder), _("Descending"));
- dialog_action_area7 = GTK_DIALOG (sortbydlg)->action_area;
+ dialog_action_area7 = gtk_dialog_get_action_area (GTK_DIALOG (sortbydlg));
gtk_widget_show (dialog_action_area7);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area7), GTK_BUTTONBOX_END);
cancelbutton5 = gtk_button_new_from_stock ("gtk-cancel");
gtk_widget_show (cancelbutton5);
gtk_dialog_add_action_widget (GTK_DIALOG (sortbydlg), cancelbutton5, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (cancelbutton5, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(cancelbutton5, TRUE);
okbutton5 = gtk_button_new_from_stock ("gtk-ok");
gtk_widget_show (okbutton5);
gtk_dialog_add_action_widget (GTK_DIALOG (sortbydlg), okbutton5, GTK_RESPONSE_OK);
- GTK_WIDGET_SET_FLAGS (okbutton5, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(okbutton5, TRUE);
g_signal_connect ((gpointer) sortfmt, "activate",
G_CALLBACK (on_sortfmt_activate),
@@ -3298,7 +3350,7 @@ create_select_dsp_plugin (void)
gtk_window_set_modal (GTK_WINDOW (select_dsp_plugin), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (select_dsp_plugin), GDK_WINDOW_TYPE_HINT_DIALOG);
- dialog_vbox10 = GTK_DIALOG (select_dsp_plugin)->vbox;
+ dialog_vbox10 = gtk_dialog_get_content_area (GTK_DIALOG (select_dsp_plugin));
gtk_widget_show (dialog_vbox10);
vbox31 = gtk_vbox_new (FALSE, 8);
@@ -3314,23 +3366,23 @@ create_select_dsp_plugin (void)
gtk_widget_show (label113);
gtk_box_pack_start (GTK_BOX (hbox85), label113, FALSE, FALSE, 0);
- plugin = gtk_combo_box_new_text ();
+ plugin = gtk_combo_box_text_new ();
gtk_widget_show (plugin);
gtk_box_pack_start (GTK_BOX (hbox85), plugin, TRUE, TRUE, 0);
- dialog_action_area9 = GTK_DIALOG (select_dsp_plugin)->action_area;
+ dialog_action_area9 = gtk_dialog_get_action_area (GTK_DIALOG (select_dsp_plugin));
gtk_widget_show (dialog_action_area9);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area9), GTK_BUTTONBOX_END);
cancelbutton7 = gtk_button_new_from_stock ("gtk-cancel");
gtk_widget_show (cancelbutton7);
gtk_dialog_add_action_widget (GTK_DIALOG (select_dsp_plugin), cancelbutton7, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (cancelbutton7, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(cancelbutton7, TRUE);
okbutton7 = gtk_button_new_from_stock ("gtk-ok");
gtk_widget_show (okbutton7);
gtk_dialog_add_action_widget (GTK_DIALOG (select_dsp_plugin), okbutton7, GTK_RESPONSE_OK);
- GTK_WIDGET_SET_FLAGS (okbutton7, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(okbutton7, TRUE);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (select_dsp_plugin, select_dsp_plugin, "select_dsp_plugin");
@@ -3401,7 +3453,7 @@ create_tagwritersettings (void)
gtk_window_set_type_hint (GTK_WINDOW (tagwritersettings), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_dialog_set_has_separator (GTK_DIALOG (tagwritersettings), FALSE);
- dialog_vbox11 = GTK_DIALOG (tagwritersettings)->vbox;
+ dialog_vbox11 = gtk_dialog_get_content_area (GTK_DIALOG (tagwritersettings));
gtk_widget_show (dialog_vbox11);
vbox32 = gtk_vbox_new (FALSE, 0);
@@ -3463,11 +3515,11 @@ create_tagwritersettings (void)
gtk_widget_show (label118);
gtk_box_pack_start (GTK_BOX (hbox91), label118, FALSE, FALSE, 0);
- id3v2_version = gtk_combo_box_new_text ();
+ id3v2_version = gtk_combo_box_text_new ();
gtk_widget_show (id3v2_version);
gtk_box_pack_start (GTK_BOX (hbox91), id3v2_version, TRUE, TRUE, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (id3v2_version), _("2.3 (Recommended)"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (id3v2_version), _("2.4"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id3v2_version), _("2.3 (Recommended)"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id3v2_version), _("2.4"));
hbox92 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox92);
@@ -3579,14 +3631,14 @@ create_tagwritersettings (void)
gtk_frame_set_label_widget (GTK_FRAME (frame10), label122);
gtk_label_set_use_markup (GTK_LABEL (label122), TRUE);
- dialog_action_area10 = GTK_DIALOG (tagwritersettings)->action_area;
+ dialog_action_area10 = gtk_dialog_get_action_area (GTK_DIALOG (tagwritersettings));
gtk_widget_show (dialog_action_area10);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area10), GTK_BUTTONBOX_END);
closebutton2 = gtk_button_new_from_stock ("gtk-close");
gtk_widget_show (closebutton2);
gtk_dialog_add_action_widget (GTK_DIALOG (tagwritersettings), closebutton2, GTK_RESPONSE_CLOSE);
- GTK_WIDGET_SET_FLAGS (closebutton2, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(closebutton2, TRUE);
g_signal_connect ((gpointer) write_id3v2, "toggled",
G_CALLBACK (on_write_id3v2_toggled),
diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c
index 17083b7c..ceb61573 100644
--- a/plugins/gtkui/mainplaylist.c
+++ b/plugins/gtkui/mainplaylist.c
@@ -118,6 +118,7 @@ main_drag_n_drop (DdbListviewIter before, DdbPlaylistHandle from_playlist, uint3
}
deadbeef->plt_unref (plt);
deadbeef->pl_unlock ();
+ deadbeef->pl_save_all ();
}
void main_external_drag_n_drop (DdbListviewIter before, char *mem, int length) {
@@ -161,13 +162,13 @@ void main_selection_changed (DdbListviewIter it, int idx) {
deadbeef->sendmessage (DB_EV_SELCHANGED, 0, deadbeef->plt_get_curr_idx (), PL_MAIN);
}
-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 = &gtk_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);
}
@@ -186,6 +187,7 @@ void main_draw_group_title (DdbListview *listview, GdkDrawable *drawable, DdbLis
void
main_delete_selected (void) {
deadbeef->pl_delete_selected ();
+ deadbeef->pl_save_all ();
main_refresh ();
search_refresh ();
}
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index 5cc749d8..64f45d6d 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), gtk_widget_get_window (listview->list), 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
@@ -120,7 +127,6 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview
if (group_it) {
int h = cwidth - group_y;
h = min (height, art_h);
-// gdk_draw_rectangle (drawable, GTK_WIDGET (listview)->style->white_gc, TRUE, x, y, width, h);
const char *album = deadbeef->pl_find_meta (group_it, "album");
const char *artist = deadbeef->pl_find_meta (group_it, "artist");
if (!album || !*album) {
@@ -135,8 +141,9 @@ 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);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, (x + ART_PADDING_HORZ)-0, (art_y)-sy);
+ cairo_rectangle (cr, x + ART_PADDING_HORZ, art_y, pw, ph);
+ cairo_fill (cr);
}
g_object_unref (pixbuf);
}
@@ -156,7 +163,9 @@ 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);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, x + cwidth/2 - 8, y + height/2 - 8);
+ cairo_rectangle (cr, x + cwidth/2 - 8, y + height/2 - 8, 16, 16);
+ cairo_fill (cr);
}
else if (it) {
char text[1024];
@@ -164,10 +173,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 = &gtk_widget_get_style (theme_treeview)->text[GTK_STATE_SELECTED];
}
else {
- color = &theme_treeview->style->text[GTK_STATE_NORMAL];
+ color = &gtk_widget_get_style (theme_treeview)->text[GTK_STATE_NORMAL];
}
}
else {
@@ -182,7 +191,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 ();
}
@@ -281,6 +290,7 @@ on_clear1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
deadbeef->pl_clear ();
+ deadbeef->pl_save_all ();
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
@@ -289,6 +299,7 @@ on_remove1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
int cursor = deadbeef->pl_delete_selected ();
+ deadbeef->pl_save_all ();
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
@@ -298,6 +309,7 @@ on_crop1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
deadbeef->pl_crop_selected ();
+ deadbeef->pl_save_all ();
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
@@ -306,6 +318,7 @@ on_remove2_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
int cursor = deadbeef->pl_delete_selected ();
+ deadbeef->pl_save_all ();
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
@@ -340,6 +353,7 @@ on_remove_from_disk_activate (GtkMenuItem *menuitem,
}
int cursor = deadbeef->pl_delete_selected ();
+ deadbeef->pl_save_all ();
deadbeef->pl_unlock ();
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
@@ -378,7 +392,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*
@@ -392,7 +406,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)
@@ -404,6 +418,7 @@ find_popup (GtkWidget *widget,
widget_name);
return found_widget;
}
+
void
list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
clicked_idx = deadbeef->pl_get_idx_of (it);
diff --git a/plugins/gtkui/plcommon.h b/plugins/gtkui/plcommon.h
index edd7d3f2..d0ebedad 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 d2d09300..bfcc80c9 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);
}
@@ -500,6 +500,9 @@ on_preferences_activate (GtkMenuItem *menuitem,
// replaygain_preamp
gtk_range_set_value (GTK_RANGE (lookup_widget (w, "replaygain_preamp")), deadbeef->conf_get_int ("replaygain_preamp", 0));
+ // global_preamp
+ gtk_range_set_value (GTK_RANGE (lookup_widget (w, "global_preamp")), deadbeef->conf_get_int ("global_preamp", 0));
+
// 8_to_16
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "convert8to16")), deadbeef->conf_get_int ("streamer.8_to_16", 1));
@@ -547,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);
}
@@ -725,6 +728,14 @@ on_replaygain_preamp_value_changed (GtkRange *range,
deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0);
}
+void
+on_global_preamp_value_changed (GtkRange *range,
+ gpointer user_data)
+{
+ float val = gtk_range_get_value (range);
+ deadbeef->conf_set_float ("global_preamp", val);
+ deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0);
+}
void
on_pref_close_send_to_tray_clicked (GtkButton *button,
@@ -1326,7 +1337,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 00aff298..82e22c73 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)
@@ -142,3 +142,57 @@ 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_with_entry ();
+}
+
+void
+gtk_dialog_set_has_separator (GtkDialog *dlg, gboolean has) {
+}
+#endif
+
+#if !GTK_CHECK_VERSION(2,22,0)
+GdkDragAction
+gdk_drag_context_get_selected_action (GdkDragContext *context) {
+ return context->action;
+}
+GList *
+gdk_drag_context_list_targets (GdkDragContext *context) {
+ return context->targets;
+}
+#endif
+
+#if !GTK_CHECK_VERSION(2,24,0)
+#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
+GtkWidget *
+gtk_combo_box_text_new () {
+ return gtk_combo_box_new_text ();
+}
+
+GtkWidget *
+gtk_combo_box_text_new_with_entry (void) {
+ return gtk_combo_box_entry_new ();
+}
+
+void
+gtk_combo_box_text_append_text (GtkComboBoxText *combo_box, const gchar *text) {
+ gtk_combo_box_append_text (combo_box, text);
+}
+
+void
+gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box, gint position, const gchar *text) {
+ gtk_combo_box_insert_text (combo_box, position, text);
+}
+
+void
+gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box, const gchar *text) {
+ gtk_combo_box_prepend_text (combo_box, text);
+}
+gchar *
+gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box) {
+ return gtk_combo_box_get_active_text (combo_box);
+}
+
+#endif
diff --git a/plugins/gtkui/support.h b/plugins/gtkui/support.h
index b4b0ace3..351878b3 100644
--- a/plugins/gtkui/support.h
+++ b/plugins/gtkui/support.h
@@ -1,12 +1,16 @@
-/*
- * DO NOT EDIT THIS FILE - it is generated by Glade.
- */
+#ifndef __GTKUI_SUPPORT_H
+#define __GTKUI_SUPPORT_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3,0,0)
+#include <gdk/gdkkeysyms-compat.h>
+#else
+#include <gdk/gdkkeysyms.h>
+#endif
/*
* Standard gettext macros.
@@ -69,3 +73,30 @@ void glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description);
+#if GTK_CHECK_VERSION(3,0,0)
+GtkWidget *
+gtk_combo_box_entry_new_text(void);
+
+void
+gtk_dialog_set_has_separator (GtkDialog *dlg, gboolean has);
+#endif
+
+#if !GTK_CHECK_VERSION(2,22,0)
+GdkDragAction
+gdk_drag_context_get_selected_action (GdkDragContext *context);
+GList *
+gdk_drag_context_list_targets (GdkDragContext *context);
+#endif
+
+#if !GTK_CHECK_VERSION(2,24,0)
+#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
+typedef GtkComboBox GtkComboBoxText;
+GtkWidget *gtk_combo_box_text_new ();
+GtkWidget *gtk_combo_box_text_new_with_entry (void);
+void gtk_combo_box_text_append_text (GtkComboBoxText *combo_box, const gchar *text);
+void gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box, gint position, const gchar *text);
+void gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box, const gchar *text);
+gchar *gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box);
+#endif
+
+#endif
diff --git a/plugins/gtkui/trkproperties.c b/plugins/gtkui/trkproperties.c
index 5ff479ce..3601f48b 100644
--- a/plugins/gtkui/trkproperties.c
+++ b/plugins/gtkui/trkproperties.c
@@ -67,7 +67,7 @@ build_key_list (const char ***pkeys, int props, DB_playItem_t **tracks, int numt
for (int i = 0; i < numtracks; i++) {
DB_metaInfo_t *meta = deadbeef->pl_get_metadata_head (tracks[i]);
while (meta) {
- if ((props && meta->key[0] == ':') || (!props && meta->key[0] != ':')) {
+ if (meta->key[0] != '!' && ((props && meta->key[0] == ':') || (!props && meta->key[0] != ':'))) {
int k = 0;
for (; k < n; k++) {
if (meta->key == keys[k]) {
@@ -255,7 +255,7 @@ add_field (GtkListStore *store, const char *key, const char *title, int is_prop,
char val[1000];
size_t ml = strlen (mult);
memcpy (val, mult, ml+1);
- int n = get_field_value (val + ml, sizeof (val) - ml, key, deadbeef->pl_find_meta, equals_ptr, tracks, numtracks);
+ int n = get_field_value (val + ml, sizeof (val) - ml, key, deadbeef->pl_find_meta_raw, equals_ptr, tracks, numtracks);
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
@@ -265,7 +265,7 @@ add_field (GtkListStore *store, const char *key, const char *title, int is_prop,
}
else {
deadbeef->pl_lock ();
- const char *val = deadbeef->pl_find_meta (tracks[0], key);
+ const char *val = deadbeef->pl_find_meta_raw (tracks[0], key);
if (!val) {
val = "";
}
@@ -498,7 +498,7 @@ static gboolean
set_progress_cb (void *ctx) {
DB_playItem_t *track = ctx;
GtkWidget *progressitem = lookup_widget (progressdlg, "progresstitle");
- const char *fname = deadbeef->pl_find_meta (track, ":URI");
+ const char *fname = deadbeef->pl_find_meta_raw (track, ":URI");
gtk_entry_set_text (GTK_ENTRY (progressitem), fname);
deadbeef->pl_item_unref (track);
}
@@ -510,7 +510,7 @@ write_meta_worker (void *ctx) {
break;
}
DB_playItem_t *track = tracks[t];
- const char *decoder_id = deadbeef->pl_find_meta (track, ":DECODER");
+ const char *decoder_id = deadbeef->pl_find_meta_raw (track, ":DECODER");
if (track && decoder_id) {
int is_subtrack = deadbeef->pl_get_item_flags (track) & DDB_IS_SUBTRACK;
if (is_subtrack) {
@@ -564,7 +564,7 @@ on_write_tags_clicked (GtkButton *button,
DB_metaInfo_t *meta = deadbeef->pl_get_metadata_head (tracks[i]);
while (meta) {
DB_metaInfo_t *next = meta->next;
- if (meta->key[0] != ':') {
+ if (meta->key[0] != ':' && meta->key[0] != '!' && meta->key[0] != '_') {
GtkTreeIter iter;
gboolean res = gtk_tree_model_get_iter_first (model, &iter);
int mult = 0;
@@ -638,7 +638,7 @@ on_add_field_activate (GtkMenuItem *menuitem,
GtkTreeIter iter;
// check for _ and :
- if (text[0] == '_' || text[0] == ':') {
+ if (text[0] == '_' || text[0] == ':' || text[0] == '!') {
GtkWidget *d = gtk_message_dialog_new (GTK_WINDOW (dlg), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Field names must not start with : or _"));
gtk_window_set_title (GTK_WINDOW (d), _("Cannot add field"));
diff --git a/plugins/gtkui/wingeom.c b/plugins/gtkui/wingeom.c
index 8591a5c6..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
@@ -46,6 +46,7 @@ wingeom_save (GtkWidget *widget, const char *name) {
snprintf (key, sizeof (key), "%s.geometry.h", name);
deadbeef->conf_set_int (key, h);
}
+ deadbeef->conf_save ();
}
void