From 1cf8f05c990006339e85f3e26a93dfc68eee7824 Mon Sep 17 00:00:00 2001 From: Conor Curran <conor.curran@canonical.com> Date: Wed, 28 Jul 2010 14:01:07 +0100 Subject: scrub bar is scrubbing --- src/scrub-widget.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'src/scrub-widget.c') diff --git a/src/scrub-widget.c b/src/scrub-widget.c index f9d0cef..3dfa309 100644 --- a/src/scrub-widget.c +++ b/src/scrub-widget.c @@ -93,10 +93,13 @@ scrub_widget_init (ScrubWidget *self) priv->ido_scrub_bar = ido_scale_menu_item_new_with_range ("Scrub", IDO_RANGE_STYLE_SMALL, 0, 0, 100, 1); priv->time_line = ido_timeline_new(0); - ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), IDO_SCALE_MENU_ITEM_STYLE_LABEL); + ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), IDO_SCALE_MENU_ITEM_STYLE_LABEL); + g_object_set(priv->ido_scrub_bar, "reverse-scroll-events", TRUE, NULL); priv->scrubbing = FALSE; - + + gtk_widget_set_size_request(GTK_WIDGET(priv->ido_scrub_bar), 100, 80); + // register slider changes listening on the range GtkWidget* scrub_widget = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar); g_signal_connect(scrub_widget, "change-value", G_CALLBACK(scrub_widget_change_value_cb), self); @@ -105,6 +108,7 @@ scrub_widget_init (ScrubWidget *self) g_signal_connect(priv->time_line, "finished", G_CALLBACK(scrub_widget_timeline_finished_cb), self); g_signal_connect(priv->ido_scrub_bar, "slider-grabbed", G_CALLBACK(scrub_widget_slider_grabbed), self); g_signal_connect(priv->ido_scrub_bar, "slider-released", G_CALLBACK(scrub_widget_slider_released), self); + } static void @@ -131,14 +135,15 @@ scrub_widget_property_update(DbusmenuMenuitem* item, gchar* property, if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_DURATION, property) == 0){ g_debug("scrub-widget::update length = %i", g_value_get_int(value)); - ido_scale_menu_item_set_secondary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), + + ido_scale_menu_item_set_secondary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), scrub_widget_format_time(g_value_get_int(value))); - + ido_timeline_set_duration(priv->time_line, g_value_get_int(value) * 1000); ido_timeline_rewind(priv->time_line); scrub_widget_check_play_state(mitem); - g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line)); - g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line)); + //g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line)); + //g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line)); scrub_widget_set_ido_position(mitem, dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_POSITION)/1000, @@ -152,11 +157,11 @@ scrub_widget_property_update(DbusmenuMenuitem* item, gchar* property, g_debug("scrub-widget::update progress = %f", scrub_widget_calculate_progress(mitem)*100); - ido_timeline_set_progress(priv->time_line, scrub_widget_calculate_progress(mitem)*1000); + ido_timeline_set_progress(priv->time_line, scrub_widget_calculate_progress(mitem)); scrub_widget_set_ido_position(mitem, g_value_get_int(value)/1000, dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_DURATION)); - ido_timeline_start(priv->time_line); + scrub_widget_check_play_state(mitem); } else if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_PLAY_STATE, property) == 0){ scrub_widget_check_play_state(mitem); @@ -190,7 +195,8 @@ scrub_widget_set_twin_item(ScrubWidget* self, g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(scrub_widget_property_update), self); - gchar* left_text = scrub_widget_format_time(dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_POSITION)/1000); + gchar* left_text = scrub_widget_format_time(dbusmenu_menuitem_property_get_int(priv->twin_item, + DBUSMENU_SCRUB_MENUITEM_POSITION)/1000); gchar* right_text = scrub_widget_format_time(dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_DURATION)); scrub_widget_set_ido_position(self, @@ -209,7 +215,7 @@ scrub_widget_change_value_cb (GtkRange *range, gdouble new_value, gpointer user_data) { - /*g_return_val_if_fail (IS_SCRUB_WIDGET (user_data), FALSE); + g_return_val_if_fail (IS_SCRUB_WIDGET (user_data), FALSE); ScrubWidget* mitem = SCRUB_WIDGET(user_data); ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); @@ -217,14 +223,8 @@ scrub_widget_change_value_cb (GtkRange *range, g_value_init(&value, G_TYPE_DOUBLE); gdouble clamped = CLAMP(new_value, 0, 100); g_value_set_double(&value, clamped); - //g_debug("scrub-widget-change-value callback - = %f", clamped); - if(priv->scrubbing == FALSE){ - dbusmenu_menuitem_handle_event (priv->twin_item, "scrubbing", &value, 0); - } - else{ - g_debug("blocking scrubbing because the slider is still grabbed" - }*/ - return FALSE; + dbusmenu_menuitem_handle_event (priv->twin_item, "scrubbing", &value, 0); + return TRUE; } GtkWidget* @@ -251,6 +251,7 @@ scrub_widget_format_time(gint time) if(seconds > 9) seconds_prefix=""; return g_strdup_printf("%s%i:%s%i", prefix, minutes, seconds_prefix, seconds); + } else{ return g_strdup_printf("%s-:%s-", prefix, seconds_prefix); @@ -308,7 +309,7 @@ scrub_widget_timeline_frame_cb( IdoTimeline *timeline, ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), left_text); GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar); GtkRange *range = (GtkRange*)slider; - //gtk_range_set_value(range, progress * 100); + gtk_range_set_value(range, progress * 100); /*g_debug("position in seconds %i and in words %s", position, left_text); g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line)); g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line)); @@ -355,10 +356,6 @@ scrub_widget_timeline_finished_cb(IdoTimeline *timeline, gpointer user_data) { g_debug("Timeline Finished!"); - /*g_return_if_fail (IS_SCRUB_WIDGET (user_data)); - ScrubWidget* mitem = SCRUB_WIDGET(user_data); - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); - ido_timeline_rewind(priv->time_line);*/ } /** -- cgit v1.2.3 From a100dc24a2eb10a1f63be5391b97700032a16111 Mon Sep 17 00:00:00 2001 From: Conor Curran <conor.curran@canonical.com> Date: Thu, 29 Jul 2010 13:19:00 +0100 Subject: tweaked the spacing and the transport bar dimensions - getting very close to sign off --- src/scrub-widget.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/scrub-widget.c') diff --git a/src/scrub-widget.c b/src/scrub-widget.c index 3dfa309..52d7b83 100644 --- a/src/scrub-widget.c +++ b/src/scrub-widget.c @@ -98,7 +98,7 @@ scrub_widget_init (ScrubWidget *self) g_object_set(priv->ido_scrub_bar, "reverse-scroll-events", TRUE, NULL); priv->scrubbing = FALSE; - gtk_widget_set_size_request(GTK_WIDGET(priv->ido_scrub_bar), 100, 80); + gtk_widget_set_size_request(GTK_WIDGET(priv->ido_scrub_bar), 100, 25); // register slider changes listening on the range GtkWidget* scrub_widget = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar); @@ -219,6 +219,10 @@ scrub_widget_change_value_cb (GtkRange *range, ScrubWidget* mitem = SCRUB_WIDGET(user_data); ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); + // Don't bother when the slider is grabbed + if(priv->scrubbing == TRUE) + return FALSE; + GValue value = {0}; g_value_init(&value, G_TYPE_DOUBLE); gdouble clamped = CLAMP(new_value, 0, 100); @@ -340,8 +344,7 @@ scrub_widget_slider_grabbed(GtkWidget *widget, gpointer user_data) { ScrubWidget* mitem = SCRUB_WIDGET(user_data); ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); - priv->scrubbing = TRUE; - + priv->scrubbing = TRUE; } static void -- cgit v1.2.3