summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-10-09 11:55:27 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-09 11:55:27 +0200
commit7fed8ecd54d5004cabc38f634d0efb32840f4cb5 (patch)
tree37ee6c6fee99dae02aa0ed8d55f433df9cb4ef70
parent1c89b325521ccd180b4e1248a44f8f25edfc4e0f (diff)
fixed seekbar and volumebar drawing in gtkui3
-rw-r--r--plugins/gtkui/callbacks.c30
-rw-r--r--plugins/gtkui/ddbseekbar.c29
-rw-r--r--plugins/gtkui/ddbvolumebar.c52
3 files changed, 22 insertions, 89 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index b871ee1e..12cbcc19 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -514,6 +514,13 @@ seekbar_draw (GtkWidget *widget, cairo_t *cr) {
if (!widget) {
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);
@@ -578,27 +585,6 @@ seekbar_draw (GtkWidget *widget, cairo_t *cr) {
}
}
-#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)
@@ -652,8 +638,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
diff --git a/plugins/gtkui/ddbseekbar.c b/plugins/gtkui/ddbseekbar.c
index bdfb7845..ffbb0cd1 100644
--- a/plugins/gtkui/ddbseekbar.c
+++ b/plugins/gtkui/ddbseekbar.c
@@ -55,14 +55,13 @@ GType ddb_seekbar_get_type (void) G_GNUC_CONST;
enum {
DDB_SEEKBAR_DUMMY_PROPERTY
};
-static void ddb_seekbar_real_realize (GtkWidget* base);
-static void ddb_seekbar_real_unrealize (GtkWidget* base);
#if GTK_CHECK_VERSION(3,0,0)
static void ddb_seekbar_get_preferred_width (GtkWidget* base, gint *minimal_width, gint *natural_width);
static void ddb_seekbar_get_preferred_height (GtkWidget* base, gint *minimal_height, gint *natural_height);
+#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_expose_event (GtkWidget* base, GdkEventExpose* event);
static gboolean ddb_seekbar_real_draw (GtkWidget* base, cairo_t *cr);
static gboolean ddb_seekbar_real_button_press_event (GtkWidget* base, GdkEventButton* event);
static gboolean ddb_seekbar_real_button_release_event (GtkWidget* base, GdkEventButton* event);
@@ -73,20 +72,6 @@ DdbSeekbar* ddb_seekbar_construct (GType object_type);
static GObject * ddb_seekbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
-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));
-}
-
-
-static void ddb_seekbar_real_unrealize (GtkWidget* base) {
- DdbSeekbar * self;
- self = (DdbSeekbar*) base;
- GTK_WIDGET_CLASS (ddb_seekbar_parent_class)->unrealize (GTK_WIDGET (self));
-}
-
#if GTK_CHECK_VERSION(3,0,0)
static void ddb_seekbar_get_preferred_width (GtkWidget* widget, gint *minimal_width, gint *natural_width) {
GtkRequisition requisition;
@@ -116,16 +101,17 @@ static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requ
static gboolean ddb_seekbar_real_draw (GtkWidget* base, cairo_t *cr) {
seekbar_draw (base, cr);
- return TRUE;
+ return FALSE;
}
+#if !GTK_CHECK_VERSION(3,0,0)
static gboolean ddb_seekbar_real_expose_event (GtkWidget* base, GdkEventExpose* event) {
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (base));
ddb_seekbar_real_draw (base, cr);
cairo_destroy (cr);
- return TRUE;
+ return FALSE;
}
-
+#endif
static gboolean ddb_seekbar_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
DdbSeekbar * self;
@@ -205,8 +191,6 @@ static GObject * ddb_seekbar_constructor (GType type, guint n_construct_properti
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;
@@ -224,6 +208,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);
}
diff --git a/plugins/gtkui/ddbvolumebar.c b/plugins/gtkui/ddbvolumebar.c
index bfc9325f..732210f3 100644
--- a/plugins/gtkui/ddbvolumebar.c
+++ b/plugins/gtkui/ddbvolumebar.c
@@ -49,49 +49,6 @@ ddb_volumebar_send_configure (DdbVolumeBar *darea)
}
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;
-
- gtk_widget_get_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, gtk_widget_get_window(widget));
- gtk_style_set_background (widget->style, gtk_widget_get_window(widget), GTK_STATE_NORMAL);
- }
-
- ddb_volumebar_send_configure (DDB_VOLUMEBAR (widget));
-#endif
-}
-
-static void
ddb_volumebar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
@@ -141,7 +98,6 @@ 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;
@@ -166,6 +122,7 @@ 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
@@ -173,6 +130,13 @@ volumebar_draw (GtkWidget *widget, cairo_t *cr) {
if (!widget) {
return;
}
+
+#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 ();
GtkAllocation a;
gtk_widget_get_allocation (widget, &a);