aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-03-03 15:45:05 +0000
committerConor Curran <conor.curran@canonical.com>2011-03-03 15:45:05 +0000
commit52976fc65cc974e481722acc68e44857a737599a (patch)
treeb816caf83d7fe31dc99ae8e655f8a631ca38fb2c
parent8716e591859e3a6a15723a2bf1ee9c9d8fb0545a (diff)
downloadayatana-indicator-sound-52976fc65cc974e481722acc68e44857a737599a.tar.gz
ayatana-indicator-sound-52976fc65cc974e481722acc68e44857a737599a.tar.bz2
ayatana-indicator-sound-52976fc65cc974e481722acc68e44857a737599a.zip
fixes two playlists bugs plus a little code tidy up in the indicator-sound
-rw-r--r--src/indicator-sound.c29
-rw-r--r--src/mpris2-controller.vala6
-rw-r--r--src/playlists-menu-item.vala30
3 files changed, 31 insertions, 34 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 4980ab8..6e1acc9 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -443,28 +443,15 @@ new_voip_slider_widget (DbusmenuMenuitem * newitem,
{
g_debug("indicator-sound: new_voip_slider_widget");
GtkWidget* voip_widget = NULL;
- //IndicatorObject *io = NULL;
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
voip_widget = voip_input_widget_new (newitem);
-/*
- / io = g_object_get_data (G_OBJECT (client), "indicator");
-*/
- //IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
- //priv->volume_widget = volume_widget;
GtkWidget* ido_slider_widget = voip_input_widget_get_ido_slider(VOIP_INPUT_WIDGET(voip_widget));
gtk_widget_show_all(ido_slider_widget);
- // register the style callback on this widget with state manager's style change
- // handler (needs to remake the blocking animation for each style).
-/*
- g_signal_connect (ido_slider_widget, "style-set",
- G_CALLBACK(sound_state_manager_style_changed_cb),
- priv->state_manager);
-*/
GtkMenuItem *menu_volume_item = GTK_MENU_ITEM(ido_slider_widget);
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client),
@@ -509,23 +496,11 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
switch (event->keyval) {
case GDK_Right:
digested = TRUE;
-/*
- if (event->state & GDK_CONTROL_MASK) {
- new_value = 100;
- } else {
-*/
- new_value = current_value + five_percent;
- //}
+ new_value = current_value + five_percent;
break;
case GDK_Left:
digested = TRUE;
-/*
- if (event->state & GDK_CONTROL_MASK) {
- new_value = 0;
- } else {
-*/
- new_value = current_value - five_percent;
- //}
+ new_value = current_value - five_percent;
break;
case GDK_plus:
digested = TRUE;
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index bf930fc..c7305f4 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -222,7 +222,7 @@ public class Mpris2Controller : GLib.Object
}
if( current_playlists != null ){
- //debug( "Size of the playlist array = %i", current_playlists.length );
+ debug( "Size of the playlist array = %i", current_playlists.length );
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
playlists_item.update(current_playlists);
}
@@ -238,7 +238,7 @@ public class Mpris2Controller : GLib.Object
debug(" We don't have an active playlist");
}
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
- playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details );
+ playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details );
return false;
}
@@ -251,4 +251,4 @@ public class Mpris2Controller : GLib.Object
debug("Could not activate playlist %s because %s", (string)path, e.message);
}
}
-} \ No newline at end of file
+}
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
index 8a2ccac..bc39129 100644
--- a/src/playlists-menu-item.vala
+++ b/src/playlists-menu-item.vala
@@ -34,7 +34,9 @@ public class PlaylistsMenuitem : PlayerItem
construct{
this.current_playlists = new HashMap<int, Dbusmenu.Menuitem>();
this.root_item = new Menuitem();
+
this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" );
+ this.root_item.property_set ( MENUITEM_PATH, "" );
}
public new void update (PlaylistDetails[] playlists)
@@ -51,10 +53,25 @@ public class PlaylistsMenuitem : PlayerItem
menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true);
menuitem.item_activated.connect(() => {
- submenu_item_activated (menuitem.id );});
- this.current_playlists.set( menuitem.id, menuitem );
+ submenu_item_activated (menuitem.id );
+ }
+ );
+ this.current_playlists.set( menuitem.id, menuitem );
this.root_item.child_append( menuitem );
}
+ // Finally remove any that might have been deleted
+ foreach (Dbusmenu.Menuitem item in this.current_playlists.values) {
+ bool within = false;
+ foreach (PlaylistDetails detail in playlists){
+ if (detail.path == item.property_get (MENUITEM_PATH)) {
+ within = true;
+ break;
+ }
+ }
+ if (within == false){
+ this.root_item.child_delete (item);
+ }
+ }
}
public void update_individual_playlist (PlaylistDetails new_detail)
@@ -65,6 +82,10 @@ public class PlaylistsMenuitem : PlayerItem
item.property_set (MENUITEM_PROP_ICON_NAME, new_detail.icon_path);
}
}
+ // If its active make sure the name is updated on the root item.
+ if (this.root_item.property_get (MENUITEM_PATH) == new_detail.path) {
+ this.root_item.property_set (MENUITEM_PROP_LABEL, new_detail.name);
+ }
}
private bool already_observed (PlaylistDetails new_detail)
@@ -76,11 +97,12 @@ public class PlaylistsMenuitem : PlayerItem
return false;
}
- public void update_active_playlist(PlaylistDetails detail)
+ public void active_playlist_update (PlaylistDetails detail)
{
var update = detail.name;
if ( update == "" ) update = "Choose Playlist";
- this.root_item.property_set ( MENUITEM_PROP_LABEL, update );
+ this.root_item.property_set (MENUITEM_PROP_LABEL, update);
+ this.root_item.property_set (MENUITEM_PATH, detail.path);
}
private void submenu_item_activated (int menu_item_id)