From 91aa6c3f4cdf7fdf3c5b96fa9c24c6ba089c8c42 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 27 Jul 2010 12:39:51 +0100 Subject: tidy ups across the ui --- src/common-defs.h | 23 +++++++++++++---------- src/metadata-menu-item.vala | 7 +------ src/metadata-widget.c | 10 ++++++++++ src/play-button.c | 28 ++++++++++++++++++---------- src/player-controller.vala | 42 ++++++++++++++++++++++++------------------ src/player-item.vala | 34 ++++++++++++++++++---------------- src/scrub-menu-item.vala | 1 + src/scrub-widget.c | 38 ++++++++++++++++++++++++-------------- src/sound-service.c | 4 ++-- src/transport-widget.c | 13 ++++++++----- 10 files changed, 119 insertions(+), 81 deletions(-) (limited to 'src') diff --git a/src/common-defs.h b/src/common-defs.h index 208c8cb..46ff520 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -19,26 +19,29 @@ with this program. If not, see . /* constants used for signals on the dbus. This file is shared between client and server implementation */ -#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted" -#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate" -#define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate" -#define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" +#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted" +#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate" +#define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate" +#define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" + +#define DBUSMENU_PROPERTY_EMPTY -1 /* DBUS Custom Items */ -#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" -#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" -#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-transport-play-state" +#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-type" + +#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type" +#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state" -#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-menu-item" +#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type" #define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-artist" #define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-title" #define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-album" #define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-arturl" -#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-menu-item" +#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-type" #define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name" -#define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-menu-item" +#define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-type" #define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-time" #define DBUSMENU_SCRUB_MENUITEM_POSITION "x-canonical-sound-menu-player-scrub-position" #define DBUSMENU_SCRUB_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-scrub-play-state" diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 388ef81..3818b1c 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -26,6 +26,7 @@ public class MetadataMenuitem : PlayerItem public MetadataMenuitem() { Object(item_type: MENUITEM_TYPE); + reset(attributes_format()); } public static HashSet attributes_format() @@ -37,11 +38,5 @@ public class MetadataMenuitem : PlayerItem attrs.add(MENUITEM_ARTURL); return attrs; } - - public bool not_populated() - { - return (this.property_get(MENUITEM_TITLE) == null && - this.property_get(MENUITEM_TITLE) == ""); - } } \ No newline at end of file diff --git a/src/metadata-widget.c b/src/metadata-widget.c index dce9226..670d983 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -199,6 +199,16 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, { g_return_if_fail (IS_METADATA_WIDGET (userdata)); + if(g_value_get_int(value) == DBUSMENU_PROPERTY_EMPTY){ + g_debug("Metadata widget: property update - reset"); + gchar* empty = ""; + GValue new_value = {0}; + g_value_init(&new_value, G_TYPE_STRING); + g_value_set_string(&new_value, g_strdup("")); + //g_free(empty); + value = &new_value; + } + MetadataWidget* mitem = METADATA_WIDGET(userdata); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem); diff --git a/src/play-button.c b/src/play-button.c index 1aeff12..cb09442 100644 --- a/src/play-button.c +++ b/src/play-button.c @@ -85,16 +85,6 @@ G_DEFINE_TYPE (PlayButton, play_button, GTK_TYPE_DRAWING_AREA); /// internal helper functions ////////////////////////////////////////////////// -/*static double -_align (double val) -{ - double fract = val - (int) val; - - if (fract != 0.5f) - return (double) ((int) val + 0.5f); - else - return val; -}*/ static inline void _blurinner (guchar* pixel, @@ -466,6 +456,24 @@ play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update) PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button); priv->current_state = update; g_debug("PlayButton::toggle play state : %i", priv->current_state); + + cairo_t *cr; + + cr = gdk_cairo_create (button->window); + + GList* list = g_hash_table_lookup(priv->command_coordinates, + GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE)); + + cairo_rectangle(cr, + GPOINTER_TO_INT(g_list_nth_data(list, 0)), + GPOINTER_TO_INT(g_list_nth_data(list, 1)), + GPOINTER_TO_INT(g_list_nth_data(list, 2)), + GPOINTER_TO_INT(g_list_nth_data(list, 3))); + + cairo_clip(cr); + draw (button, cr); + cairo_destroy (cr); + } diff --git a/src/player-controller.vala b/src/player-controller.vala index f824d6f..7ba2a70 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -56,7 +56,7 @@ public class PlayerController : GLib.Object this.root_menu = root; this.name = format_client_name(client_name.strip()); this.custom_items = new ArrayList(); - this.update_state(initial_state); + this.current_state = initial_state; this.menu_offset = offset; construct_widgets(); establish_mpris_connection(); @@ -67,7 +67,7 @@ public class PlayerController : GLib.Object { debug("update_state - player controller %s : new state %i", this.name, new_state); this.current_state = new_state; - //this.update_layout(); + this.update_layout(); } public void activate() @@ -108,7 +108,7 @@ public class PlayerController : GLib.Object else{ this.mpris_adaptor = new MprisController(this); } - + // TODO refactor if(this.mpris_adaptor.connected() == true){ debug("yup I'm connected"); this.update_state(state.CONNECTED); @@ -116,7 +116,6 @@ public class PlayerController : GLib.Object else{ this.update_state(state.DISCONNECTED); } - this.update_layout(); } public void vanish() @@ -127,21 +126,28 @@ public class PlayerController : GLib.Object } public void update_layout() - { - bool visibility = true; - MetadataMenuitem meta_item = this.custom_items[widget_order.METADATA] as MetadataMenuitem; - if(this.current_state != state.CONNECTED /*|| - meta_item.not_populated()*/){ - visibility = false; - } - debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string()); - this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); - this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); - this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); - // DEBUG - if(visibility == false){ - warning("Update layout of client %s is setting widgets to invisibile!", this.name); + { + if(this.current_state != state.CONNECTED){ + this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, + false); + this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE, + false); + this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, + false); + return; } + + debug("update layout - metadata %s", this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()).to_string()); + this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, + this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); + debug("update layout - scrub %s", this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format()).to_string()); + this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE, + this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format())); + + + this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, + this.current_state == state.CONNECTED); + } private void construct_widgets() diff --git a/src/player-item.vala b/src/player-item.vala index 2952f71..288ac47 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -24,7 +24,8 @@ public class PlayerItem : Dbusmenu.Menuitem { public PlayerController owner {get; construct;} public string item_type { get; construct; } - + private const int EMPTY = -1; + public PlayerItem(string type) { Object(item_type: type); @@ -36,17 +37,16 @@ public class PlayerItem : Dbusmenu.Menuitem public void reset(HashSet attrs){ foreach(string s in attrs){ - debug("attempting to set prop %s to null", s); - this.property_set(s, null); - this.property_set_int(s, 0); + debug("attempting to set prop %s to EMPTY", s); + this.property_set_int(s, EMPTY); } } public void update(HashTable data, HashSet attributes) { debug("PlayerItem::update()"); - if(ensure_valid_updates(data, attributes) == false){ - debug("PlayerItem::Update -> The hashtable update does not contain what we were expecting - just leave it!"); + if(data == null){ + debug("PlayerItem::Update -> The hashtable was null - just leave it!"); return; } @@ -82,19 +82,21 @@ public class PlayerItem : Dbusmenu.Menuitem this.property_set_bool(property, v.get_boolean()); } } + if(this.property_get_bool(MENUITEM_PROP_VISIBLE) == false){ + this.property_set_bool(MENUITEM_PROP_VISIBLE, true); + } } - - private static bool ensure_valid_updates(HashTable data, HashSet attributes) + + public bool populated(HashSet attrs) { - if(data == null){ - return false; + foreach(string prop in attrs){ + int value_int = property_get_int(prop); + debug("populate - prop %s and value %i", prop, value_int); + if(property_get_int(prop) != EMPTY){ + return true; + } } - /*if(data.size() < attributes.size){ - warning("update hash was too small for the target"); - return false; - }*/ - return true; + return false; } - } diff --git a/src/scrub-menu-item.vala b/src/scrub-menu-item.vala index 29fa903..ca81c38 100644 --- a/src/scrub-menu-item.vala +++ b/src/scrub-menu-item.vala @@ -26,6 +26,7 @@ public class ScrubMenuitem : PlayerItem public ScrubMenuitem(PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); + reset(attributes_format()); } public override void handle_event(string name, GLib.Value input_value, uint timestamp) diff --git a/src/scrub-widget.c b/src/scrub-widget.c index fa290e0..f9d0cef 100644 --- a/src/scrub-widget.c +++ b/src/scrub-widget.c @@ -149,6 +149,8 @@ scrub_widget_property_update(DbusmenuMenuitem* item, gchar* property, ido_timeline_pause(priv->time_line); ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), scrub_widget_format_time(g_value_get_int(value)/1000)); + + 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); scrub_widget_set_ido_position(mitem, g_value_get_int(value)/1000, @@ -235,18 +237,26 @@ scrub_widget_get_ido_bar(ScrubWidget* self) static gchar* scrub_widget_format_time(gint time) { - // Assuming its in seconds for now ... - gint minutes = time/60; - gint seconds = time % 60; - gchar* prefix="0"; - gchar* seconds_prefix="0"; - if(minutes > 9) - prefix=""; - if(seconds > 9) - seconds_prefix=""; - return g_strdup_printf("%s%i:%s%i", prefix, minutes, seconds_prefix, seconds); +// Assuming its in seconds for now ... + gchar* prefix = "-"; + gchar* seconds_prefix = "-"; + + if(time != DBUSMENU_PROPERTY_EMPTY){ + gint minutes = time/60; + gint seconds = time % 60; + prefix="0"; + seconds_prefix="0"; + if(minutes > 9) + prefix=""; + 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); + } } - + static void scrub_widget_set_ido_position(ScrubWidget* self, gint position, @@ -289,7 +299,7 @@ scrub_widget_timeline_frame_cb( IdoTimeline *timeline, ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); if(priv->scrubbing == TRUE) { - //g_debug("don't update the slider or timeline, slider is being scrubbed"); + g_debug("don't update the slider or timeline, slider is being scrubbed"); return; } gint position = progress * dbusmenu_menuitem_property_get_int(priv->twin_item, @@ -298,12 +308,12 @@ 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)); */ + //g_debug("timeline-update - progress = %f", progress); g_free(left_text); } diff --git a/src/sound-service.c b/src/sound-service.c index 8768cd3..16fa87c 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -42,8 +42,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-widget.c b/src/transport-widget.c index c616fff..10a1fd7 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -182,11 +182,14 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, g_debug("transport_widget_update_state - with property %s", property); TransportWidget* bar = (TransportWidget*)userdata; g_return_if_fail(IS_TRANSPORT_WIDGET(bar)); - - TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); - int update_value = g_value_get_int(value); - g_debug("transport_widget_update_state - with value %i", update_value); - play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value); + + if(g_ascii_strcasecmp(DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, property) == 0) + { + TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); + int update_value = g_value_get_int(value); + g_debug("transport_widget_update_state - with value %i", update_value); + play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value); + } } /** -- cgit v1.2.3 From 694340cf4123edee2d3c22173c1ac855a6b187f7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 27 Jul 2010 15:14:53 +0100 Subject: lots of bits tidied up --- src/play-button.c | 29 ++++++++++++++++------------- src/sound-service.c | 4 ++-- src/transport-widget.c | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/play-button.c b/src/play-button.c index cb09442..cf8bc2f 100644 --- a/src/play-button.c +++ b/src/play-button.c @@ -454,26 +454,29 @@ void play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update) { PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button); + gboolean changed = priv->current_state != update; priv->current_state = update; g_debug("PlayButton::toggle play state : %i", priv->current_state); - cairo_t *cr; + if(changed == TRUE){ + g_debug("Toggle play pause - changed of state detected"); + cairo_t *cr; - cr = gdk_cairo_create (button->window); + cr = gdk_cairo_create (button->window); - GList* list = g_hash_table_lookup(priv->command_coordinates, - GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE)); + GList* list = g_hash_table_lookup(priv->command_coordinates, + GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE)); - cairo_rectangle(cr, - GPOINTER_TO_INT(g_list_nth_data(list, 0)), - GPOINTER_TO_INT(g_list_nth_data(list, 1)), - GPOINTER_TO_INT(g_list_nth_data(list, 2)), - GPOINTER_TO_INT(g_list_nth_data(list, 3))); - - cairo_clip(cr); - draw (button, cr); - cairo_destroy (cr); + cairo_rectangle(cr, + GPOINTER_TO_INT(g_list_nth_data(list, 0)), + GPOINTER_TO_INT(g_list_nth_data(list, 1)), + GPOINTER_TO_INT(g_list_nth_data(list, 2)), + GPOINTER_TO_INT(g_list_nth_data(list, 3))); + cairo_clip(cr); + draw (button, cr); + cairo_destroy (cr); + } } diff --git a/src/sound-service.c b/src/sound-service.c index 16fa87c..8768cd3 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -42,8 +42,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-widget.c b/src/transport-widget.c index 10a1fd7..535add2 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -152,8 +152,8 @@ transport_widget_button_press_event (GtkWidget *menuitem, g_value_init(&value, G_TYPE_INT); g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result); g_value_set_int(&value, (int)result); - dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0); play_button_react_to_button_press(priv->play_button, result); + dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0); } return TRUE; } -- cgit v1.2.3 From 1cf8f05c990006339e85f3e26a93dfc68eee7824 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 28 Jul 2010 14:01:07 +0100 Subject: scrub bar is scrubbing --- src/play-button.c | 4 ++-- src/scrub-widget.c | 43 ++++++++++++++++++++----------------------- src/sound-service.c | 4 ++-- 3 files changed, 24 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/play-button.c b/src/play-button.c index cf8bc2f..3f8f9f6 100644 --- a/src/play-button.c +++ b/src/play-button.c @@ -458,7 +458,7 @@ play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update) priv->current_state = update; g_debug("PlayButton::toggle play state : %i", priv->current_state); - if(changed == TRUE){ + /*if(changed == TRUE){ g_debug("Toggle play pause - changed of state detected"); cairo_t *cr; @@ -476,7 +476,7 @@ play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update) cairo_clip(cr); draw (button, cr); cairo_destroy (cr); - } + }*/ } 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);*/ } /** diff --git a/src/sound-service.c b/src/sound-service.c index 8768cd3..16fa87c 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -42,8 +42,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From 06e8e90161cec524e5a875aa709b96d5489ae91a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 28 Jul 2010 18:20:04 +0100 Subject: playlist mock up landed --- src/player-controller.vala | 37 ++++++++++++++++++++++++++++++++----- src/sound-service.c | 4 ++-- 2 files changed, 34 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/player-controller.vala b/src/player-controller.vala index 7ba2a70..2fa9dd2 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -23,14 +23,15 @@ using Gee; public class PlayerController : GLib.Object { - public const int WIDGET_QUANTITY = 5; + public const int WIDGET_QUANTITY = 6; public static enum widget_order{ SEPARATOR, TITLE, METADATA, SCRUB, - TRANSPORT + TRANSPORT, + PLAYLIST } public enum state{ @@ -133,6 +134,8 @@ public class PlayerController : GLib.Object this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE, false); this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, + false); + this.custom_items[widget_order.PLAYLIST].property_set_bool(MENUITEM_PROP_VISIBLE, false); return; } @@ -146,8 +149,10 @@ public class PlayerController : GLib.Object this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, - this.current_state == state.CONNECTED); - + true); + + this.custom_items[widget_order.PLAYLIST].property_set_bool(MENUITEM_PROP_VISIBLE, + true); } private void construct_widgets() @@ -170,12 +175,34 @@ public class PlayerController : GLib.Object // Transport item TransportMenuitem transport_item = new TransportMenuitem(this); this.custom_items.add(transport_item); - + + this.custom_items.add(create_playlist()); foreach(PlayerItem item in this.custom_items){ root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); } } + + private PlayerItem create_playlist() + { + PlayerItem playlist_root = new PlayerItem(CLIENT_TYPES_DEFAULT); + playlist_root.property_set(MENUITEM_PROP_LABEL, "Choose Playlist"); + + PlayerItem subentry_1 = new PlayerItem(CLIENT_TYPES_DEFAULT); + subentry_1.property_set(MENUITEM_PROP_LABEL, "90's Warp"); + + PlayerItem subentry_2 = new PlayerItem(CLIENT_TYPES_DEFAULT); + subentry_2.property_set(MENUITEM_PROP_LABEL, "Rune Grammafon 00's"); + + PlayerItem subentry_3 = new PlayerItem(CLIENT_TYPES_DEFAULT); + subentry_3.property_set(MENUITEM_PROP_LABEL, "Kranky pics"); + + playlist_root.child_append(subentry_1); + playlist_root.child_append(subentry_2); + playlist_root.child_append(subentry_3); + + return playlist_root; + } private static string format_client_name(string client_name) { diff --git a/src/sound-service.c b/src/sound-service.c index 16fa87c..8768cd3 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -42,8 +42,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From a100dc24a2eb10a1f63be5391b97700032a16111 Mon Sep 17 00:00:00 2001 From: Conor Curran 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/play-button.c | 75 +++++++++++++++++++++++----------------------- src/player-controller.vala | 6 ++-- src/scrub-widget.c | 9 ++++-- src/transport-widget.c | 2 -- 4 files changed, 47 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/play-button.c b/src/play-button.c index 3f8f9f6..e4382c1 100644 --- a/src/play-button.c +++ b/src/play-button.c @@ -28,12 +28,12 @@ Uses code from ctk #include "play-button.h" #define RECT_WIDTH 130.0f -#define Y 15.0f +#define Y 5.0f #define X 37.0f #define INNER_RADIUS 12.5 #define MIDDLE_RADIUS 13.5f #define OUTER_RADIUS 14.5f -#define CIRCLE_RADIUS 19.0f +#define CIRCLE_RADIUS 21.0f #define PREV_WIDTH 25.0f #define PREV_HEIGHT 17.0f #define NEXT_WIDTH 25.0f //PREV_WIDTH @@ -42,16 +42,16 @@ Uses code from ctk #define TRI_HEIGHT 13.0f #define TRI_OFFSET 6.0f #define PREV_X 35.0f -#define PREV_Y 21.0f +#define PREV_Y 11.0f #define NEXT_X 113.0f -#define NEXT_Y 21.0f //prev_y +#define NEXT_Y 11.0f //prev_y #define PAUSE_WIDTH 21.0f #define PAUSE_HEIGHT 27.0f #define BAR_WIDTH 4.5f #define BAR_HEIGHT 24.0f #define BAR_OFFSET 10.0f -#define PAUSE_X 77.0f -#define PAUSE_Y 15.0f +#define PAUSE_X 78.0f +#define PAUSE_Y 5.0f #define PLAY_WIDTH 28.0f #define PLAY_HEIGHT 29.0f #define PLAY_PADDING 5.0f @@ -321,7 +321,7 @@ play_button_init (PlayButton *self) (GDestroyNotify)g_list_free); GList* previous_list = NULL; previous_list = g_list_insert(previous_list, GINT_TO_POINTER(15), 0); - previous_list = g_list_insert(previous_list, GINT_TO_POINTER(10), 1); + previous_list = g_list_insert(previous_list, GINT_TO_POINTER(5), 1); previous_list = g_list_insert(previous_list, GINT_TO_POINTER(60), 2); previous_list = g_list_insert(previous_list, GINT_TO_POINTER(34), 3); @@ -330,10 +330,10 @@ play_button_init (PlayButton *self) previous_list); GList* play_list = NULL; - play_list = g_list_insert(play_list, GINT_TO_POINTER(60), 0); - play_list = g_list_insert(play_list, GINT_TO_POINTER(10), 1); - play_list = g_list_insert(play_list, GINT_TO_POINTER(45), 2); - play_list = g_list_insert(play_list, GINT_TO_POINTER(40), 3); + play_list = g_list_insert(play_list, GINT_TO_POINTER(58), 0); + play_list = g_list_insert(play_list, GINT_TO_POINTER(0), 1); + play_list = g_list_insert(play_list, GINT_TO_POINTER(50), 2); + play_list = g_list_insert(play_list, GINT_TO_POINTER(43), 3); g_hash_table_insert(priv->command_coordinates, GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE), @@ -341,7 +341,7 @@ play_button_init (PlayButton *self) GList* next_list = NULL; next_list = g_list_insert(next_list, GINT_TO_POINTER(100), 0); - next_list = g_list_insert(next_list, GINT_TO_POINTER(10), 1); + next_list = g_list_insert(next_list, GINT_TO_POINTER(5), 1); next_list = g_list_insert(next_list, GINT_TO_POINTER(60), 2); next_list = g_list_insert(next_list, GINT_TO_POINTER(34), 3); @@ -349,7 +349,7 @@ play_button_init (PlayButton *self) GINT_TO_POINTER(TRANSPORT_NEXT), next_list); - gtk_widget_set_size_request(GTK_WIDGET(self), 200, 80); + gtk_widget_set_size_request(GTK_WIDGET(self), 200, 50); } static void @@ -389,15 +389,15 @@ determine_button_event(GtkWidget* button, GdkEventButton* event) PlayButtonEvent button_event = TRANSPORT_NADA; // For now very simple rectangular collision detection if(event->x > 55 && event->x < 95 - && event->y > 22 && event->y < 46){ + && event->y > 12 && event->y < 40){ button_event = TRANSPORT_PREVIOUS; } - else if(event->x > 101 && event->x < 133 - && event->y > 20 && event->y < 47){ + else if(event->x > 99 && event->x < 136 + && event->y > 5 && event->y < 47){ button_event = TRANSPORT_PLAY_PAUSE; } else if(event->x > 137 && event->x < 179 - && event->y > 22 && event->y < 46){ + && event->y > 12 && event->y < 40){ button_event = TRANSPORT_NEXT; } return button_event; @@ -458,8 +458,8 @@ play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update) priv->current_state = update; g_debug("PlayButton::toggle play state : %i", priv->current_state); - /*if(changed == TRUE){ - g_debug("Toggle play pause - changed of state detected"); + if(changed == TRUE){ + g_debug("Toggle play pause - changed of state detected - redraw button"); cairo_t *cr; cr = gdk_cairo_create (button->window); @@ -476,7 +476,7 @@ play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update) cairo_clip(cr); draw (button, cr); cairo_destroy (cr); - }*/ + } } @@ -796,33 +796,34 @@ draw (GtkWidget* button, cairo_t *cr) // play/pause-background draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f, Y - ((CIRCLE_RADIUS - OUTER_RADIUS)), CIRCLE_RADIUS, OUTER_START, OUTER_END); draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f + 1.0f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.0f, - CIRCLE_RADIUS - 1, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 0.5f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 0.5f, + CIRCLE_RADIUS - 0.75f, MIDDLE_START, MIDDLE_END); - draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f + 2.0f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 2.0f, - CIRCLE_RADIUS - 2.0f, - INNER_START, - INNER_END); + if(priv->current_command == TRANSPORT_PLAY_PAUSE){ draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f + 2.0f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 2.0f, - CIRCLE_RADIUS - 2.0f, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.5f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.5f, + CIRCLE_RADIUS - 1.5f, INNER_COMPRESSED_START, INNER_COMPRESSED_END); } - - + else{ + draw_circle (cr, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.5f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.5f, + CIRCLE_RADIUS - 1.5f, + INNER_START, + INNER_END); + } // draw previous-button drop-shadow _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT); _mask_prev (cr_surf, @@ -951,7 +952,7 @@ draw (GtkWidget* button, cairo_t *cr) BUTTON_SHADOW, FALSE); _surface_blur (surf, 1); - _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f); + _finalize (cr, &cr_surf, &surf, PAUSE_X-0.75f, PAUSE_Y + 1.0f); // draw play-button _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT); cairo_set_line_width (cr, 10.5); @@ -970,7 +971,7 @@ draw (GtkWidget* button, cairo_t *cr) BUTTON_START, BUTTON_END, FALSE); - _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y); + _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y); } } diff --git a/src/player-controller.vala b/src/player-controller.vala index 2fa9dd2..fc5ca9b 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -189,13 +189,13 @@ public class PlayerController : GLib.Object playlist_root.property_set(MENUITEM_PROP_LABEL, "Choose Playlist"); PlayerItem subentry_1 = new PlayerItem(CLIENT_TYPES_DEFAULT); - subentry_1.property_set(MENUITEM_PROP_LABEL, "90's Warp"); + subentry_1.property_set(MENUITEM_PROP_LABEL, "Raster-noton selection"); PlayerItem subentry_2 = new PlayerItem(CLIENT_TYPES_DEFAULT); - subentry_2.property_set(MENUITEM_PROP_LABEL, "Rune Grammafon 00's"); + subentry_2.property_set(MENUITEM_PROP_LABEL, "Rune Grammofon selection"); PlayerItem subentry_3 = new PlayerItem(CLIENT_TYPES_DEFAULT); - subentry_3.property_set(MENUITEM_PROP_LABEL, "Kranky pics"); + subentry_3.property_set(MENUITEM_PROP_LABEL, "Kranky selection"); playlist_root.child_append(subentry_1); playlist_root.child_append(subentry_2); 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 diff --git a/src/transport-widget.c b/src/transport-widget.c index 535add2..702b472 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -118,8 +118,6 @@ transport_widget_finalize (GObject *object) static gboolean transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event) { - //TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(widget); - //gtk_container_propagate_expose(GTK_CONTAINER(widget),priv->play_button, event); return TRUE; } -- cgit v1.2.3