diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-04-09 22:22:23 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-04-09 22:22:23 +0200 |
commit | 49508a75eeb63ab65f6cb84c14e46e679fad2688 (patch) | |
tree | dedd7b5c03ad8b411ecd26277bcc3f00527dabcc /plugins | |
parent | 133b2f31913b25ff222bd9ba9aa716a990e0d94a (diff) |
implemented seekbar gtk widget in vala
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtkui/Makefile.am | 5 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.c | 66 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.h | 26 | ||||
-rw-r--r-- | plugins/gtkui/ddbequalizer.h | 23 | ||||
-rw-r--r-- | plugins/gtkui/ddbseekbar.c | 183 | ||||
-rw-r--r-- | plugins/gtkui/ddbseekbar.h | 71 | ||||
-rw-r--r-- | plugins/gtkui/ddbseekbar.vala | 59 | ||||
-rw-r--r-- | plugins/gtkui/deadbeef.glade | 12 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.h | 15 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.vapi | 5 | ||||
-rw-r--r-- | plugins/gtkui/interface.c | 18 |
11 files changed, 412 insertions, 71 deletions
diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am index 2b37eda8..46cf6b7b 100644 --- a/plugins/gtkui/Makefile.am +++ b/plugins/gtkui/Makefile.am @@ -2,13 +2,14 @@ if HAVE_GTK gtkuidir = $(libdir)/$(PACKAGE) pkglib_LTLIBRARIES = gtkui.la -gtkui_VALASOURCES = ddbequalizer.vala -gtkui_VALABUILTSOURCES = $(gtkui_VALASOURCES:.vala=.c) ddbequalizer.h +gtkui_VALASOURCES = ddbequalizer.vala ddbseekbar.vala +gtkui_VALABUILTSOURCES = $(gtkui_VALASOURCES:.vala=.c) ddbequalizer.h ddbseekbar.h if MAINTAINER_MODE BUILT_SOURCES = vala.stamp vala.stamp: $(gtkui_VALASOURCES) $(VALAC) -C -H ddbequalizer.h --library ddbequalizer gtkui.vapi --pkg=gtk+-2.0 $^ + $(VALAC) -C -H ddbseekbar.h --library ddbseekbar gtkui.vapi --pkg=gtk+-2.0 $^ touch $@ endif diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 4811b592..d239ff03 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -35,6 +35,7 @@ #include "ddblistview.h" #include "ddbtabstrip.h" #include "ddbvolumebar.h" +#include "ddbseekbar.h" #include "search.h" #include "progress.h" #include "../../session.h" @@ -477,12 +478,17 @@ seekbar_draw (GtkWidget *widget) { 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; + DB_playItem_t *trk = deadbeef->streamer_get_playing_track (); if (!trk || deadbeef->pl_get_item_duration (trk) < 0) { if (trk) { deadbeef->pl_item_unref (trk); } - clearlooks_rounded_rectangle (cr, 2, widget->allocation.height/2-4, widget->allocation.width-4, 8, 4, 0xff); + clearlooks_rounded_rectangle (cr, 2+ax, widget->allocation.height/2-4+ay, aw-4, 8, 4, 0xff); // empty seekbar, just a frame cairo_set_source_rgb (cr, clr_selection.red/65535.f, clr_selection.green/65535.f, clr_selection.blue/65535.f ); cairo_stroke (cr); @@ -509,18 +515,18 @@ seekbar_draw (GtkWidget *widget) { // left if (pos > 0) { cairo_set_source_rgb (cr, clr_selection.red/65535.f, clr_selection.green/65535.f, clr_selection.blue/65535.f ); - cairo_rectangle (cr, 0, widget->allocation.height/2-4, pos, 8); + cairo_rectangle (cr, ax, ah/2-4+ay, pos, 8); cairo_clip (cr); - clearlooks_rounded_rectangle (cr, 0, widget->allocation.height/2-4, widget->allocation.width, 8, 4, 0xff); + clearlooks_rounded_rectangle (cr, 0+ax, ah/2-4 + ay, aw, 8, 4, 0xff); cairo_fill (cr); cairo_reset_clip (cr); } // right cairo_set_source_rgb (cr, clr_back.red/65535.f, clr_back.green/65535.f, clr_back.blue/65535.f ); - cairo_rectangle (cr, pos, widget->allocation.height/2-4, widget->allocation.width-pos, 8); + cairo_rectangle (cr, pos+ax, ah/2-4+ay, aw-pos, 8); cairo_clip (cr); - clearlooks_rounded_rectangle (cr, 0, widget->allocation.height/2-4, widget->allocation.width, 8, 4, 0xff); + clearlooks_rounded_rectangle (cr, 0+ax, ah/2-4+ay, aw, 8, 4, 0xff); cairo_fill (cr); cairo_reset_clip (cr); @@ -563,39 +569,32 @@ on_seekbar_expose_event (GtkWidget *widget, gboolean on_seekbar_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event, - gpointer user_data) + GdkEventMotion *event) { if (seekbar_moving) { - seekbar_move_x = event->x; + seekbar_move_x = event->x - widget->allocation.x; gtk_widget_queue_draw (widget); - //seekbar_draw (widget); - //seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height); } return FALSE; } gboolean on_seekbar_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) + GdkEventButton *event) { if (deadbeef->get_output ()->state () == OUTPUT_STATE_STOPPED) { return FALSE; } seekbar_moving = 1; - seekbar_move_x = event->x; + seekbar_move_x = event->x - widget->allocation.x; gtk_widget_queue_draw (widget); - //seekbar_draw (widget); - //seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height); return FALSE; } gboolean on_seekbar_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) + GdkEventButton *event) { seekbar_moving = 0; gtk_widget_queue_draw (widget); @@ -603,7 +602,7 @@ on_seekbar_button_release_event (GtkWidget *widget, //seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height); DB_playItem_t *trk = deadbeef->streamer_get_playing_track (); if (trk) { - float time = event->x * deadbeef->pl_get_item_duration (trk) / (widget->allocation.width); + float time = (event->x - widget->allocation.x) * deadbeef->pl_get_item_duration (trk) / (widget->allocation.width); if (time < 0) { time = 0; } @@ -1089,11 +1088,17 @@ on_mainwin_button_press_event (GtkWidget *widget, gpointer user_data) { 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) { 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) { + capture = seekbar; + return gtk_widget_event (seekbar, (GdkEvent *)event); + } return FALSE; } @@ -1104,10 +1109,8 @@ on_mainwin_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - GtkWidget *volumebar = lookup_widget (mainwin, "volumebar"); - 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) { - return gtk_widget_event (volumebar, (GdkEvent *)event); + if (capture) { + return gtk_widget_event (capture, (GdkEvent *)event); } capture = NULL; @@ -1122,10 +1125,15 @@ on_mainwin_scroll_event (GtkWidget *widget, { GdkEventScroll *event = (GdkEventScroll *)ev; 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) { 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) { + return gtk_widget_event (seekbar, (GdkEvent *)event); + } return FALSE; } @@ -1135,11 +1143,17 @@ on_mainwin_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { - GtkWidget *volumebar = lookup_widget (mainwin, "volumebar"); - if (capture == volumebar || (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)) { - return gtk_widget_event (volumebar, (GdkEvent *)event); + if (capture) { + return gtk_widget_event (capture, (GdkEvent *)event); } return FALSE; } + +GtkWidget* +create_seekbar (gchar *widget_name, gchar *string1, gchar *string2, + gint int1, gint int2) +{ + return GTK_WIDGET (ddb_seekbar_new ()); +} + diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h index 56da05c9..09dad46d 100644 --- a/plugins/gtkui/callbacks.h +++ b/plugins/gtkui/callbacks.h @@ -247,30 +247,10 @@ void on_playlist_save_as_activate (GtkMenuItem *menuitem, gpointer user_data); -gboolean -on_seekbar_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - -gboolean -on_seekbar_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - -gboolean -on_seekbar_configure_event (GtkWidget *widget, - GdkEventConfigure *event, - gpointer user_data); - -gboolean -on_seekbar_expose_event (GtkWidget *widget, - GdkEventExpose *event, - gpointer user_data); gboolean on_seekbar_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event, - gpointer user_data); + GdkEventMotion *event); gboolean on_volumebar_button_press_event (GtkWidget *widget, @@ -949,3 +929,7 @@ gboolean on_mainwin_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); + +GtkWidget* +create_seekbar (gchar *widget_name, gchar *string1, gchar *string2, + gint int1, gint int2); diff --git a/plugins/gtkui/ddbequalizer.h b/plugins/gtkui/ddbequalizer.h index 74507c39..dcc4acdc 100644 --- a/plugins/gtkui/ddbequalizer.h +++ b/plugins/gtkui/ddbequalizer.h @@ -23,6 +23,17 @@ typedef struct _DdbEqualizer DdbEqualizer; typedef struct _DdbEqualizerClass DdbEqualizerClass; typedef struct _DdbEqualizerPrivate DdbEqualizerPrivate; +#define DDB_TYPE_SEEKBAR (ddb_seekbar_get_type ()) +#define DDB_SEEKBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDB_TYPE_SEEKBAR, DdbSeekbar)) +#define DDB_SEEKBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DDB_TYPE_SEEKBAR, DdbSeekbarClass)) +#define DDB_IS_SEEKBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DDB_TYPE_SEEKBAR)) +#define DDB_IS_SEEKBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DDB_TYPE_SEEKBAR)) +#define DDB_SEEKBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DDB_TYPE_SEEKBAR, DdbSeekbarClass)) + +typedef struct _DdbSeekbar DdbSeekbar; +typedef struct _DdbSeekbarClass DdbSeekbarClass; +typedef struct _DdbSeekbarPrivate DdbSeekbarPrivate; + struct _DdbEqualizer { GtkDrawingArea parent_instance; DdbEqualizerPrivate * priv; @@ -32,6 +43,15 @@ struct _DdbEqualizerClass { GtkDrawingAreaClass parent_class; }; +struct _DdbSeekbar { + GtkWidget parent_instance; + DdbSeekbarPrivate * priv; +}; + +struct _DdbSeekbarClass { + GtkWidgetClass parent_class; +}; + GType ddb_equalizer_get_type (void); void ddb_equalizer_set_band (DdbEqualizer* self, gint band, double v); @@ -41,6 +61,9 @@ double ddb_equalizer_get_preamp (DdbEqualizer* self); void ddb_equalizer_color_changed (DdbEqualizer* self); DdbEqualizer* ddb_equalizer_new (void); DdbEqualizer* ddb_equalizer_construct (GType object_type); +GType ddb_seekbar_get_type (void); +DdbSeekbar* ddb_seekbar_new (void); +DdbSeekbar* ddb_seekbar_construct (GType object_type); G_END_DECLS diff --git a/plugins/gtkui/ddbseekbar.c b/plugins/gtkui/ddbseekbar.c new file mode 100644 index 00000000..e53ba83f --- /dev/null +++ b/plugins/gtkui/ddbseekbar.c @@ -0,0 +1,183 @@ +/* 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> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include <glib.h> +#include <glib-object.h> +#include <gtk/gtk.h> +#include <gtkui.h> +#include <gdk/gdk.h> + + +#define DDB_TYPE_SEEKBAR (ddb_seekbar_get_type ()) +#define DDB_SEEKBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDB_TYPE_SEEKBAR, DdbSeekbar)) +#define DDB_SEEKBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DDB_TYPE_SEEKBAR, DdbSeekbarClass)) +#define DDB_IS_SEEKBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DDB_TYPE_SEEKBAR)) +#define DDB_IS_SEEKBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DDB_TYPE_SEEKBAR)) +#define DDB_SEEKBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DDB_TYPE_SEEKBAR, DdbSeekbarClass)) + +typedef struct _DdbSeekbar DdbSeekbar; +typedef struct _DdbSeekbarClass DdbSeekbarClass; +typedef struct _DdbSeekbarPrivate DdbSeekbarPrivate; + +struct _DdbSeekbar { + GtkWidget parent_instance; + DdbSeekbarPrivate * priv; +}; + +struct _DdbSeekbarClass { + GtkWidgetClass parent_class; +}; + + +static gpointer ddb_seekbar_parent_class = NULL; + +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); +static gboolean ddb_seekbar_real_expose_event (GtkWidget* base, GdkEventExpose* event); +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); +DdbSeekbar* ddb_seekbar_new (void); +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)); +} + + +static void ddb_seekbar_real_size_request (GtkWidget* base, GtkRequisition* requisition) { + DdbSeekbar * self; + self = (DdbSeekbar*) base; +} + + +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; +} + + +static gboolean ddb_seekbar_real_button_press_event (GtkWidget* base, GdkEventButton* event) { + DdbSeekbar * self; + gboolean result = FALSE; + self = (DdbSeekbar*) base; + result = on_seekbar_button_press_event ((GtkWidget*) self, event); + return result; +} + + +static gboolean ddb_seekbar_real_button_release_event (GtkWidget* base, GdkEventButton* event) { + DdbSeekbar * self; + gboolean result = FALSE; + self = (DdbSeekbar*) base; + result = on_seekbar_button_release_event ((GtkWidget*) self, event); + return result; +} + + +static gboolean ddb_seekbar_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) { + DdbSeekbar * self; + gboolean result = FALSE; + self = (DdbSeekbar*) base; + result = on_seekbar_motion_notify_event ((GtkWidget*) self, event); + return result; +} + + +DdbSeekbar* ddb_seekbar_construct (GType object_type) { + DdbSeekbar * self; + self = g_object_newv (object_type, 0, NULL); + return self; +} + + +DdbSeekbar* ddb_seekbar_new (void) { + return ddb_seekbar_construct (DDB_TYPE_SEEKBAR); +} + + +static GObject * ddb_seekbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + DdbSeekbar * self; + 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; + GTK_WIDGET_CLASS (klass)->size_request = ddb_seekbar_real_size_request; + GTK_WIDGET_CLASS (klass)->expose_event = ddb_seekbar_real_expose_event; + GTK_WIDGET_CLASS (klass)->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; + G_OBJECT_CLASS (klass)->constructor = ddb_seekbar_constructor; +} + + +static void ddb_seekbar_instance_init (DdbSeekbar * self) { +} + + +GType ddb_seekbar_get_type (void) { + static volatile gsize ddb_seekbar_type_id__volatile = 0; + if (g_once_init_enter (&ddb_seekbar_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (DdbSeekbarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ddb_seekbar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DdbSeekbar), 0, (GInstanceInitFunc) ddb_seekbar_instance_init, NULL }; + GType ddb_seekbar_type_id; + ddb_seekbar_type_id = g_type_register_static (GTK_TYPE_WIDGET, "DdbSeekbar", &g_define_type_info, 0); + g_once_init_leave (&ddb_seekbar_type_id__volatile, ddb_seekbar_type_id); + } + return ddb_seekbar_type_id__volatile; +} + + + + diff --git a/plugins/gtkui/ddbseekbar.h b/plugins/gtkui/ddbseekbar.h new file mode 100644 index 00000000..7308a721 --- /dev/null +++ b/plugins/gtkui/ddbseekbar.h @@ -0,0 +1,71 @@ +/* ddbseekbar.h generated by valac, the Vala compiler, do not modify */ + + +#ifndef __DDBSEEKBAR_H__ +#define __DDBSEEKBAR_H__ + +#include <glib.h> +#include <gtk/gtk.h> +#include <float.h> +#include <math.h> + +G_BEGIN_DECLS + + +#define DDB_TYPE_EQUALIZER (ddb_equalizer_get_type ()) +#define DDB_EQUALIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDB_TYPE_EQUALIZER, DdbEqualizer)) +#define DDB_EQUALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DDB_TYPE_EQUALIZER, DdbEqualizerClass)) +#define DDB_IS_EQUALIZER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DDB_TYPE_EQUALIZER)) +#define DDB_IS_EQUALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DDB_TYPE_EQUALIZER)) +#define DDB_EQUALIZER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DDB_TYPE_EQUALIZER, DdbEqualizerClass)) + +typedef struct _DdbEqualizer DdbEqualizer; +typedef struct _DdbEqualizerClass DdbEqualizerClass; +typedef struct _DdbEqualizerPrivate DdbEqualizerPrivate; + +#define DDB_TYPE_SEEKBAR (ddb_seekbar_get_type ()) +#define DDB_SEEKBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDB_TYPE_SEEKBAR, DdbSeekbar)) +#define DDB_SEEKBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DDB_TYPE_SEEKBAR, DdbSeekbarClass)) +#define DDB_IS_SEEKBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DDB_TYPE_SEEKBAR)) +#define DDB_IS_SEEKBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DDB_TYPE_SEEKBAR)) +#define DDB_SEEKBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DDB_TYPE_SEEKBAR, DdbSeekbarClass)) + +typedef struct _DdbSeekbar DdbSeekbar; +typedef struct _DdbSeekbarClass DdbSeekbarClass; +typedef struct _DdbSeekbarPrivate DdbSeekbarPrivate; + +struct _DdbEqualizer { + GtkDrawingArea parent_instance; + DdbEqualizerPrivate * priv; +}; + +struct _DdbEqualizerClass { + GtkDrawingAreaClass parent_class; +}; + +struct _DdbSeekbar { + GtkWidget parent_instance; + DdbSeekbarPrivate * priv; +}; + +struct _DdbSeekbarClass { + GtkWidgetClass parent_class; +}; + + +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); +void ddb_equalizer_color_changed (DdbEqualizer* self); +DdbEqualizer* ddb_equalizer_new (void); +DdbEqualizer* ddb_equalizer_construct (GType object_type); +GType ddb_seekbar_get_type (void); +DdbSeekbar* ddb_seekbar_new (void); +DdbSeekbar* ddb_seekbar_construct (GType object_type); + + +G_END_DECLS + +#endif diff --git a/plugins/gtkui/ddbseekbar.vala b/plugins/gtkui/ddbseekbar.vala new file mode 100644 index 00000000..f6c70efd --- /dev/null +++ b/plugins/gtkui/ddbseekbar.vala @@ -0,0 +1,59 @@ +/* + DeaDBeeF - ultimate music player for GNU/Linux systems with X11 + Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +namespace Ddb { + public class Seekbar : Gtk.Widget + { + construct + { + } + + public override void realize () { + set_has_window (false); + base.realize (); + } + + public override void unrealize () { + base.unrealize (); + } + + public override void size_request (out Gtk.Requisition requisition) { + // leave at default for now + } + + public override bool expose_event (Gdk.EventExpose event) { + seekbar_draw (base); + return true; + } + + public override bool button_press_event (Gdk.EventButton event) { + return on_seekbar_button_press_event (this, event); + } + + public override bool button_release_event (Gdk.EventButton event) { + return on_seekbar_button_release_event (this, event); + } + + public override bool motion_notify_event (Gdk.EventMotion event) { + return on_seekbar_motion_notify_event (this, event); + } + } + +} + diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index 844f07bb..968aab0d 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -804,14 +804,12 @@ </child> <child> - <widget class="GtkDrawingArea" id="seekbar"> - <property name="width_request">200</property> + <widget class="Custom" id="seekbar"> <property name="visible">True</property> - <property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <signal name="button_press_event" handler="on_seekbar_button_press_event" last_modification_time="Tue, 11 Aug 2009 17:47:59 GMT"/> - <signal name="button_release_event" handler="on_seekbar_button_release_event" last_modification_time="Tue, 11 Aug 2009 17:48:02 GMT"/> - <signal name="expose_event" handler="on_seekbar_expose_event" last_modification_time="Tue, 11 Aug 2009 17:48:11 GMT"/> - <signal name="motion_notify_event" handler="on_seekbar_motion_notify_event" last_modification_time="Tue, 11 Aug 2009 17:48:18 GMT"/> + <property name="creation_function">create_seekbar</property> + <property name="int1">0</property> + <property name="int2">0</property> + <property name="last_modification_time">Fri, 09 Apr 2010 19:51:15 GMT</property> </widget> <packing> <property name="padding">2</property> diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index ef8cf9a3..4df4b47a 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -93,6 +93,21 @@ void seekbar_redraw (void); void +seekbar_draw (GtkWidget *widget); + +gboolean +on_seekbar_button_press_event (GtkWidget *widget, + GdkEventButton *event); + +gboolean +on_seekbar_button_release_event (GtkWidget *widget, + GdkEventButton *event); + +gboolean +on_seekbar_motion_notify_event (GtkWidget *widget, + GdkEventMotion *event); + +void volumebar_redraw (void); void diff --git a/plugins/gtkui/gtkui.vapi b/plugins/gtkui/gtkui.vapi index 353d9f9d..7ad5e312 100644 --- a/plugins/gtkui/gtkui.vapi +++ b/plugins/gtkui/gtkui.vapi @@ -5,4 +5,9 @@ namespace Gtkui { public static unowned Gdk.Color get_bar_background_color (); public static unowned void init_theme_colors (); } +[CCode (cheader_filename = "gtkui.h")] +public static unowned void seekbar_draw(Gtk.Widget *widget); +public static unowned bool on_seekbar_button_press_event(Gtk.Widget widget, Gdk.EventButton event); +public static unowned bool on_seekbar_button_release_event(Gtk.Widget widget, Gdk.EventButton event); +public static unowned bool on_seekbar_motion_notify_event(Gtk.Widget widget, Gdk.EventMotion event); diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index e378ceaf..7061c306 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -516,11 +516,11 @@ create_mainwin (void) gtk_widget_show (image5); gtk_container_add (GTK_CONTAINER (nextbtn), image5); - seekbar = gtk_drawing_area_new (); + seekbar = create_seekbar ("seekbar", "", "", 0, 0); gtk_widget_show (seekbar); gtk_box_pack_start (GTK_BOX (hbox2), seekbar, TRUE, TRUE, 2); - gtk_widget_set_size_request (seekbar, 200, -1); - gtk_widget_set_events (seekbar, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); + GTK_WIDGET_UNSET_FLAGS (seekbar, GTK_CAN_FOCUS); + GTK_WIDGET_UNSET_FLAGS (seekbar, GTK_CAN_DEFAULT); volumebar = create_volumebar_widget ("volumebar", "", "", 0, 0); gtk_widget_show (volumebar); @@ -705,18 +705,6 @@ create_mainwin (void) g_signal_connect ((gpointer) nextbtn, "clicked", G_CALLBACK (on_nextbtn_clicked), NULL); - g_signal_connect ((gpointer) seekbar, "button_press_event", - G_CALLBACK (on_seekbar_button_press_event), - NULL); - g_signal_connect ((gpointer) seekbar, "button_release_event", - G_CALLBACK (on_seekbar_button_release_event), - NULL); - g_signal_connect ((gpointer) seekbar, "expose_event", - G_CALLBACK (on_seekbar_expose_event), - NULL); - g_signal_connect ((gpointer) seekbar, "motion_notify_event", - G_CALLBACK (on_seekbar_motion_notify_event), - NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (mainwin, mainwin, "mainwin"); |