Author: dannym Date: 2009-01-11 21:11:34 +0000 (Sun, 11 Jan 2009) New Revision: 29181
Modified: xfce4-mixer/branches/xfce_4_4/panel-plugin/mixer-slider-tiny.gob xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny-private.h xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny.c xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny.h Log: fix bug# 3410: drag slider. Modified: xfce4-mixer/branches/xfce_4_4/panel-plugin/mixer-slider-tiny.gob =================================================================== --- xfce4-mixer/branches/xfce_4_4/panel-plugin/mixer-slider-tiny.gob 2009-01-11 20:52:13 UTC (rev 29180) +++ xfce4-mixer/branches/xfce_4_4/panel-plugin/mixer-slider-tiny.gob 2009-01-11 21:11:34 UTC (rev 29181) @@ -15,6 +15,7 @@ protected GtkProgressBar *progress = NULL; /*protected GtkBox *hbox = NULL;*/ public GtkEventBox *eb = NULL; + protected gboolean pressed = FALSE; protected void set_vval (self, gint vval) { @@ -63,6 +64,7 @@ g_signal_connect_swapped (self->eb, "scroll-event", G_CALLBACK(self_scroll_cb), self); g_signal_connect_swapped (self->eb, "button-press-event", G_CALLBACK(self_button_cb), self); g_signal_connect_swapped (self->eb, "button-release-event", G_CALLBACK(self_button_cb), self); + g_signal_connect_swapped (self->eb, "motion-notify-event", G_CALLBACK(self_motion_cb), self); } public gboolean scroll_cb (self, GdkEventScroll *event, GtkWidget *w) @@ -88,37 +90,68 @@ protected gboolean button_cb (self, GdkEventButton *b, GtkWidget *widget) { - int y; /* pos */ - int sy; /* size */ + int y; - y = (int)b->y; + y = (int) b->y; /* pos */ if (b->button == 3 || b->button == 2) { if (b->type == GDK_BUTTON_PRESS) { + /* mute */ y = 0; } else { return TRUE; } } else if (b->button == 1) { - sy = widget->allocation.height; - if (sy != 0) { - /* this is a hack 'cause I dont know how to get the height - * of the border of the progressbar yet ;) - */ - y = (sy + 2 - y) * 100 / sy; - if (y <= 0) y = 0; - } else y = 0; + if (b->type == GDK_BUTTON_PRESS) { + y = self_figure_out_volume(self, widget, y); + self->pressed = TRUE; + } else if (b->type == GDK_BUTTON_RELEASE){ + y = self_figure_out_volume(self, widget, y); + self->pressed = FALSE; + } else { + return TRUE; + } } else { return FALSE; } - - if (y < 0) { y = 0; } - if (y > 100) { y = 100; } self_set_vval (self, y); return TRUE; } + /* returns the volume in range 0..100, given a coordinate in the widget. */ + protected int figure_out_volume(self, GtkWidget *widget, int y) { + int sy; /* size in pixels. */ + sy = widget->allocation.height; /* size */ + if (sy > 4) { + sy -= 4; + /* this is a hack 'cause I dont know how to get the height of the border of the progressbar yet ;) */ + y = (sy + 2 - y) * 100 / sy; + if (y <= 0) + y = 0; + } else { + y = 0; + } + + if (y < 0) { + y = 0; + } else if (y > 100) { + y = 100; + } + return y; + } + + protected gboolean motion_cb (self, GdkEventMotion *m, GtkWidget *widget) + { + if (self->pressed) { + int y = (int) m->y; /* pos */ + y = self_figure_out_volume(self, widget, y); + self_set_vval (self, y); + return TRUE; + } + return FALSE; + } + public XfceMixerControl *new(void) { return XFCE_MIXER_CONTROL(GET_NEW); Modified: xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny-private.h =================================================================== --- xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny-private.h 2009-01-11 20:52:13 UTC (rev 29180) +++ xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny-private.h 2009-01-11 21:11:34 UTC (rev 29181) @@ -1,4 +1,4 @@ -/* Generated by GOB (v2.0.14) (do not edit directly) */ +/* Generated by GOB (v2.0.15) (do not edit directly) */ #ifndef __XFCE_MIXER_SLIDER_TINY_PRIVATE_H__ #define __XFCE_MIXER_SLIDER_TINY_PRIVATE_H__ @@ -17,6 +17,8 @@ #line 18 "xfce-mixer-slider-tiny-private.h" void xfce_mixer_slider_tiny_set_vval (XfceMixerSliderTiny * self, gint vval); gboolean xfce_mixer_slider_tiny_button_cb (XfceMixerSliderTiny * self, GdkEventButton * b, GtkWidget * widget); +int xfce_mixer_slider_tiny_figure_out_volume (XfceMixerSliderTiny * self, GtkWidget * widget, int y); +gboolean xfce_mixer_slider_tiny_motion_cb (XfceMixerSliderTiny * self, GdkEventMotion * m, GtkWidget * widget); #ifdef __cplusplus } Modified: xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny.c =================================================================== --- xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny.c 2009-01-11 20:52:13 UTC (rev 29180) +++ xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny.c 2009-01-11 21:11:34 UTC (rev 29181) @@ -1,10 +1,10 @@ -/* Generated by GOB (v2.0.14) (do not edit directly) */ +/* Generated by GOB (v2.0.15) (do not edit directly) */ /* End world hunger, donate to the World Food Programme, http://www.wfp.org */ #define GOB_VERSION_MAJOR 2 #define GOB_VERSION_MINOR 0 -#define GOB_VERSION_PATCHLEVEL 14 +#define GOB_VERSION_PATCHLEVEL 15 #define selfp (self->_priv) @@ -60,8 +60,8 @@ /* here are local prototypes */ static void xfce_mixer_slider_tiny_class_init (XfceMixerSliderTinyClass * c) G_GNUC_UNUSED; static void xfce_mixer_slider_tiny_init (XfceMixerSliderTiny * self) G_GNUC_UNUSED; -static void ___6_xfce_mixer_slider_tiny_value_changed (XfceMixerControl * pself) G_GNUC_UNUSED; -static void ___7_xfce_mixer_slider_tiny_vcname_changed (XfceMixerControl * pself) G_GNUC_UNUSED; +static void ___8_xfce_mixer_slider_tiny_value_changed (XfceMixerControl * pself) G_GNUC_UNUSED; +static void ___9_xfce_mixer_slider_tiny_vcname_changed (XfceMixerControl * pself) G_GNUC_UNUSED; /* pointer to the class of our parent */ static XfceMixerControlClass *parent_class = NULL; @@ -70,6 +70,8 @@ #define self_set_vval xfce_mixer_slider_tiny_set_vval #define self_scroll_cb xfce_mixer_slider_tiny_scroll_cb #define self_button_cb xfce_mixer_slider_tiny_button_cb +#define self_figure_out_volume xfce_mixer_slider_tiny_figure_out_volume +#define self_motion_cb xfce_mixer_slider_tiny_motion_cb #define self_new xfce_mixer_slider_tiny_new GType xfce_mixer_slider_tiny_get_type (void) @@ -121,27 +123,30 @@ parent_class = g_type_class_ref (XFCE_TYPE_MIXER_CONTROL); -#line 127 "mixer-slider-tiny.gob" - xfce_mixer_control_class->value_changed = ___6_xfce_mixer_slider_tiny_value_changed; -#line 141 "mixer-slider-tiny.gob" - xfce_mixer_control_class->vcname_changed = ___7_xfce_mixer_slider_tiny_vcname_changed; -#line 129 "xfce-mixer-slider-tiny.c" +#line 160 "mixer-slider-tiny.gob" + xfce_mixer_control_class->value_changed = ___8_xfce_mixer_slider_tiny_value_changed; +#line 174 "mixer-slider-tiny.gob" + xfce_mixer_control_class->vcname_changed = ___9_xfce_mixer_slider_tiny_vcname_changed; +#line 131 "xfce-mixer-slider-tiny.c" } #undef __GOB_FUNCTION__ -#line 33 "mixer-slider-tiny.gob" +#line 34 "mixer-slider-tiny.gob" static void xfce_mixer_slider_tiny_init (XfceMixerSliderTiny * self G_GNUC_UNUSED) -#line 135 "xfce-mixer-slider-tiny.c" +#line 137 "xfce-mixer-slider-tiny.c" { #define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::init" #line 10 "mixer-slider-tiny.gob" self->progress = NULL; -#line 140 "xfce-mixer-slider-tiny.c" +#line 142 "xfce-mixer-slider-tiny.c" #line 10 "mixer-slider-tiny.gob" self->eb = NULL; -#line 143 "xfce-mixer-slider-tiny.c" +#line 145 "xfce-mixer-slider-tiny.c" +#line 10 "mixer-slider-tiny.gob" + self->pressed = FALSE; +#line 148 "xfce-mixer-slider-tiny.c" { -#line 34 "mixer-slider-tiny.gob" +#line 35 "mixer-slider-tiny.gob" GtkRcStyle *rc; GdkColor color; @@ -174,26 +179,27 @@ g_signal_connect_swapped (self->eb, "scroll-event", G_CALLBACK(self_scroll_cb), self); g_signal_connect_swapped (self->eb, "button-press-event", G_CALLBACK(self_button_cb), self); g_signal_connect_swapped (self->eb, "button-release-event", G_CALLBACK(self_button_cb), self); + g_signal_connect_swapped (self->eb, "motion-notify-event", G_CALLBACK(self_motion_cb), self); -#line 179 "xfce-mixer-slider-tiny.c" +#line 185 "xfce-mixer-slider-tiny.c" } } #undef __GOB_FUNCTION__ -#line 19 "mixer-slider-tiny.gob" +#line 20 "mixer-slider-tiny.gob" void xfce_mixer_slider_tiny_set_vval (XfceMixerSliderTiny * self, gint vval) -#line 188 "xfce-mixer-slider-tiny.c" +#line 194 "xfce-mixer-slider-tiny.c" { #define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::set_vval" -#line 19 "mixer-slider-tiny.gob" +#line 20 "mixer-slider-tiny.gob" g_return_if_fail (self != NULL); -#line 19 "mixer-slider-tiny.gob" +#line 20 "mixer-slider-tiny.gob" g_return_if_fail (XFCE_IS_MIXER_SLIDER_TINY (self)); -#line 195 "xfce-mixer-slider-tiny.c" +#line 201 "xfce-mixer-slider-tiny.c" { -#line 20 "mixer-slider-tiny.gob" +#line 21 "mixer-slider-tiny.gob" gdouble val; gchar *tmp; @@ -206,23 +212,23 @@ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(self->progress), val / 100.0); }} -#line 210 "xfce-mixer-slider-tiny.c" +#line 216 "xfce-mixer-slider-tiny.c" #undef __GOB_FUNCTION__ -#line 68 "mixer-slider-tiny.gob" +#line 70 "mixer-slider-tiny.gob" gboolean xfce_mixer_slider_tiny_scroll_cb (XfceMixerSliderTiny * self, GdkEventScroll * event, GtkWidget * w) -#line 217 "xfce-mixer-slider-tiny.c" +#line 223 "xfce-mixer-slider-tiny.c" { #define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::scroll_cb" -#line 68 "mixer-slider-tiny.gob" +#line 70 "mixer-slider-tiny.gob" g_return_val_if_fail (self != NULL, (gboolean )0); -#line 68 "mixer-slider-tiny.gob" +#line 70 "mixer-slider-tiny.gob" g_return_val_if_fail (XFCE_IS_MIXER_SLIDER_TINY (self), (gboolean )0); -#line 224 "xfce-mixer-slider-tiny.c" +#line 230 "xfce-mixer-slider-tiny.c" { -#line 69 "mixer-slider-tiny.gob" +#line 71 "mixer-slider-tiny.gob" int vol; /* new volume */ vol = xfce_mixer_control_calc_num_value (XFCE_MIXER_CONTROL (self)); @@ -242,85 +248,145 @@ return TRUE; }} -#line 246 "xfce-mixer-slider-tiny.c" +#line 252 "xfce-mixer-slider-tiny.c" #undef __GOB_FUNCTION__ -#line 89 "mixer-slider-tiny.gob" +#line 91 "mixer-slider-tiny.gob" gboolean xfce_mixer_slider_tiny_button_cb (XfceMixerSliderTiny * self, GdkEventButton * b, GtkWidget * widget) -#line 252 "xfce-mixer-slider-tiny.c" +#line 258 "xfce-mixer-slider-tiny.c" { #define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::button_cb" -#line 89 "mixer-slider-tiny.gob" +#line 91 "mixer-slider-tiny.gob" g_return_val_if_fail (self != NULL, (gboolean )0); -#line 89 "mixer-slider-tiny.gob" +#line 91 "mixer-slider-tiny.gob" g_return_val_if_fail (XFCE_IS_MIXER_SLIDER_TINY (self), (gboolean )0); -#line 259 "xfce-mixer-slider-tiny.c" +#line 265 "xfce-mixer-slider-tiny.c" { -#line 90 "mixer-slider-tiny.gob" +#line 92 "mixer-slider-tiny.gob" - int y; /* pos */ - int sy; /* size */ + int y; - y = (int)b->y; + y = (int) b->y; /* pos */ if (b->button == 3 || b->button == 2) { if (b->type == GDK_BUTTON_PRESS) { + /* mute */ y = 0; } else { return TRUE; } } else if (b->button == 1) { - sy = widget->allocation.height; - if (sy != 0) { - /* this is a hack 'cause I dont know how to get the height - * of the border of the progressbar yet ;) - */ - y = (sy + 2 - y) * 100 / sy; - if (y <= 0) y = 0; - } else y = 0; + if (b->type == GDK_BUTTON_PRESS) { + y = self_figure_out_volume(self, widget, y); + self->pressed = TRUE; + } else if (b->type == GDK_BUTTON_RELEASE){ + y = self_figure_out_volume(self, widget, y); + self->pressed = FALSE; + } else { + return TRUE; + } } else { return FALSE; } - - if (y < 0) { y = 0; } - if (y > 100) { y = 100; } self_set_vval (self, y); return TRUE; }} -#line 292 "xfce-mixer-slider-tiny.c" +#line 296 "xfce-mixer-slider-tiny.c" #undef __GOB_FUNCTION__ #line 122 "mixer-slider-tiny.gob" +int +xfce_mixer_slider_tiny_figure_out_volume (XfceMixerSliderTiny * self, GtkWidget * widget, int y) +#line 302 "xfce-mixer-slider-tiny.c" +{ +#define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::figure_out_volume" +#line 122 "mixer-slider-tiny.gob" + g_return_val_if_fail (self != NULL, (int )0); +#line 122 "mixer-slider-tiny.gob" + g_return_val_if_fail (XFCE_IS_MIXER_SLIDER_TINY (self), (int )0); +#line 309 "xfce-mixer-slider-tiny.c" +{ +#line 122 "mixer-slider-tiny.gob" + + int sy; /* size in pixels. */ + + sy = widget->allocation.height; /* size */ + if (sy > 4) { + sy -= 4; + /* this is a hack 'cause I dont know how to get the height of the border of the progressbar yet ;) */ + y = (sy + 2 - y) * 100 / sy; + if (y <= 0) + y = 0; + } else { + y = 0; + } + + if (y < 0) { + y = 0; + } else if (y > 100) { + y = 100; + } + return y; + }} +#line 333 "xfce-mixer-slider-tiny.c" +#undef __GOB_FUNCTION__ + +#line 144 "mixer-slider-tiny.gob" +gboolean +xfce_mixer_slider_tiny_motion_cb (XfceMixerSliderTiny * self, GdkEventMotion * m, GtkWidget * widget) +#line 339 "xfce-mixer-slider-tiny.c" +{ +#define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::motion_cb" +#line 144 "mixer-slider-tiny.gob" + g_return_val_if_fail (self != NULL, (gboolean )0); +#line 144 "mixer-slider-tiny.gob" + g_return_val_if_fail (XFCE_IS_MIXER_SLIDER_TINY (self), (gboolean )0); +#line 346 "xfce-mixer-slider-tiny.c" +{ +#line 145 "mixer-slider-tiny.gob" + + if (self->pressed) { + int y = (int) m->y; /* pos */ + y = self_figure_out_volume(self, widget, y); + self_set_vval (self, y); + return TRUE; + } + return FALSE; + }} +#line 358 "xfce-mixer-slider-tiny.c" +#undef __GOB_FUNCTION__ + +#line 155 "mixer-slider-tiny.gob" XfceMixerControl * xfce_mixer_slider_tiny_new (void) -#line 298 "xfce-mixer-slider-tiny.c" +#line 364 "xfce-mixer-slider-tiny.c" { #define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::new" { -#line 123 "mixer-slider-tiny.gob" +#line 156 "mixer-slider-tiny.gob" return XFCE_MIXER_CONTROL(GET_NEW); }} -#line 306 "xfce-mixer-slider-tiny.c" +#line 372 "xfce-mixer-slider-tiny.c" #undef __GOB_FUNCTION__ -#line 127 "mixer-slider-tiny.gob" +#line 160 "mixer-slider-tiny.gob" static void -___6_xfce_mixer_slider_tiny_value_changed (XfceMixerControl * pself G_GNUC_UNUSED) -#line 312 "xfce-mixer-slider-tiny.c" +___8_xfce_mixer_slider_tiny_value_changed (XfceMixerControl * pself G_GNUC_UNUSED) +#line 378 "xfce-mixer-slider-tiny.c" #define PARENT_HANDLER(___pself) \ { if(XFCE_MIXER_CONTROL_CLASS(parent_class)->value_changed) \ (* XFCE_MIXER_CONTROL_CLASS(parent_class)->value_changed)(___pself); } { #define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::value_changed" -#line 127 "mixer-slider-tiny.gob" +#line 160 "mixer-slider-tiny.gob" g_return_if_fail (pself != NULL); -#line 127 "mixer-slider-tiny.gob" +#line 160 "mixer-slider-tiny.gob" g_return_if_fail (XFCE_IS_MIXER_CONTROL (pself)); -#line 322 "xfce-mixer-slider-tiny.c" +#line 388 "xfce-mixer-slider-tiny.c" { -#line 129 "mixer-slider-tiny.gob" +#line 162 "mixer-slider-tiny.gob" gint v; @@ -332,26 +398,26 @@ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->progress), ((gdouble) v) / 100.0); }} -#line 336 "xfce-mixer-slider-tiny.c" +#line 402 "xfce-mixer-slider-tiny.c" #undef __GOB_FUNCTION__ #undef PARENT_HANDLER -#line 141 "mixer-slider-tiny.gob" +#line 174 "mixer-slider-tiny.gob" static void -___7_xfce_mixer_slider_tiny_vcname_changed (XfceMixerControl * pself G_GNUC_UNUSED) -#line 343 "xfce-mixer-slider-tiny.c" +___9_xfce_mixer_slider_tiny_vcname_changed (XfceMixerControl * pself G_GNUC_UNUSED) +#line 409 "xfce-mixer-slider-tiny.c" #define PARENT_HANDLER(___pself) \ { if(XFCE_MIXER_CONTROL_CLASS(parent_class)->vcname_changed) \ (* XFCE_MIXER_CONTROL_CLASS(parent_class)->vcname_changed)(___pself); } { #define __GOB_FUNCTION__ "Xfce:Mixer:Slider:Tiny::vcname_changed" -#line 141 "mixer-slider-tiny.gob" +#line 174 "mixer-slider-tiny.gob" g_return_if_fail (pself != NULL); -#line 141 "mixer-slider-tiny.gob" +#line 174 "mixer-slider-tiny.gob" g_return_if_fail (XFCE_IS_MIXER_CONTROL (pself)); -#line 353 "xfce-mixer-slider-tiny.c" +#line 419 "xfce-mixer-slider-tiny.c" { -#line 143 "mixer-slider-tiny.gob" +#line 176 "mixer-slider-tiny.gob" Self *self; char *sanename; @@ -365,6 +431,6 @@ } g_free (sanename); }} -#line 369 "xfce-mixer-slider-tiny.c" +#line 435 "xfce-mixer-slider-tiny.c" #undef __GOB_FUNCTION__ #undef PARENT_HANDLER Modified: xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny.h =================================================================== --- xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny.h 2009-01-11 20:52:13 UTC (rev 29180) +++ xfce4-mixer/branches/xfce_4_4/panel-plugin/xfce-mixer-slider-tiny.h 2009-01-11 21:11:34 UTC (rev 29181) @@ -1,4 +1,4 @@ -/* Generated by GOB (v2.0.14) (do not edit directly) */ +/* Generated by GOB (v2.0.15) (do not edit directly) */ #include <glib.h> #include <glib-object.h> @@ -38,6 +38,7 @@ GtkEventBox * eb; /*< private >*/ GtkProgressBar * progress; /* protected */ + gboolean pressed; /* protected */ }; /* _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits