From bd74119fe73c955a458b414b12ac92d580a15344 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 14 Feb 2012 18:44:19 +0000 Subject: fixed typo in makefile am --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 36fe490..5a36822 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,7 +33,7 @@ libsoundmenu_la_CFLAGS = \ $(COVERAGE_CFLAGS) \ -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\" libsoundmenu_la_LIBADD = $(APPLET_LIBS) -lm -libsoundmenu_la_LDFLAGS = +libsoundmenu_la_LDFLAGS = \ $(COVERAGE_LDFLAGS) \ -module -avoid-version -- cgit v1.2.3 From e884478843aaf00a05c325da5766f44cdf67c26a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 21 Feb 2012 11:22:40 -0600 Subject: Fix LP Bug #937461 Coverity is complaining that we don't check the return value of g_dbus_connection_register_object(). IMO this is harmless, but is fixed here by remembering the returned registration_id and using it to unregister the object in our object's dispose() function. --- src/sound-service-dbus.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 5650002..07d3d6f 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -58,6 +58,7 @@ struct _SoundServiceDbusPrivate { DbusmenuMenuitem* root_menuitem; Device* device; gboolean greeter_mode; + guint registration_id; }; enum { @@ -155,18 +156,18 @@ sound_service_dbus_init (SoundServiceDbus *self) return; } /* register the service on it */ - g_dbus_connection_register_object (priv->connection, - INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH, - interface_info, - &interface_table, - self, - NULL, - &error); - if (error != NULL) { - g_error("Unable to register the object to DBus: %s", error->message); - g_error_free(error); - return; - } + priv->registration_id = g_dbus_connection_register_object (priv->connection, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH, + interface_info, + &interface_table, + self, + NULL, + &error); + if (error != NULL) { + g_error("Unable to register the object to DBus: %s", error->message); + g_error_free(error); + return; + } } DbusmenuMenuitem* @@ -239,6 +240,15 @@ show_sound_settings_dialog (DbusmenuMenuitem *mi, static void sound_service_dbus_dispose (GObject *object) { + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (object); + + if (priv->connection && priv->registration_id) { + g_dbus_connection_unregister_object (priv->connection, priv->registration_id); + priv->registration_id = 0; + } + + g_clear_object(&priv->connection); + G_OBJECT_CLASS (sound_service_dbus_parent_class)->dispose (object); //TODO dispose of the active sink instance ! return; -- cgit v1.2.3 From 9e3e24efd718efe26b62ba1db5b151d6a78c6544 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 22 Feb 2012 13:22:55 +0000 Subject: fix layout of the metadata widget --- src/metadata-widget.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index a3383df..5f4e1a1 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -129,13 +129,13 @@ metadata_widget_init (MetadataWidget *self) priv->icon_buf = NULL; #if GTK_CHECK_VERSION(3, 0, 0) - outer_v_box = gtk_box_new (FALSE, 0); + outer_v_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); #else outer_v_box = gtk_vbox_new (FALSE, 0); #endif #if GTK_CHECK_VERSION(3, 0, 0) - hbox = gtk_box_new(FALSE, 0); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); #else hbox = gtk_hbox_new(FALSE, 0); #endif @@ -168,13 +168,13 @@ metadata_widget_init (MetadataWidget *self) #endif gtk_box_pack_start (GTK_BOX (priv->meta_data_h_box), priv->album_art, - FALSE, - FALSE, + TRUE, + TRUE, 1); priv->theme_change_occured = FALSE; #if GTK_CHECK_VERSION(3, 0, 0) - GtkWidget* vbox = gtk_box_new(FALSE, 0); + GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); #else GtkWidget* vbox = gtk_vbox_new(FALSE, 0); #endif @@ -227,16 +227,15 @@ metadata_widget_init (MetadataWidget *self) // player label GtkWidget* player_label; - player_label = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0.5); - gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)0); - gtk_widget_set_size_request (player_label, 200, 24); + player_label = gtk_label_new (""); + gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0); + gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)0); + gtk_widget_set_size_request (player_label, 150, 24); priv->player_label = player_label; gtk_box_pack_start (GTK_BOX(outer_v_box), priv->player_label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 0); - + gtk_container_add (GTK_CONTAINER (self), outer_v_box); gtk_widget_show_all (priv->meta_data_h_box); -- cgit v1.2.3 From 78837fe1befbc45df6fe4e92ae299ada83ea6c0e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 22 Feb 2012 16:40:59 +0000 Subject: play defensively around setting the volume related to lp#90017 --- src/pulseaudio-mgr.c | 1 - src/slider-menu-item.c | 25 ++++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index ba83c71..3a80cbd 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -174,7 +174,6 @@ reconnect_to_pulse (gpointer user_data) void pm_update_volume (gint sink_index, pa_cvolume new_volume) { - // LP: #850662 if (sink_index < 0 || pulse_context == NULL){ return; } diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index 165c3d5..7efdf74 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -77,7 +77,6 @@ slider_menu_item_init (SliderMenuItem *self) priv->index = NOT_ACTIVE; priv->name = NULL; - return; } @@ -147,21 +146,25 @@ slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update) static void slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent) { + g_return_if_fail (IS_SLIDER_MENU_ITEM (self)); -/* - g_debug ("slider menu item update volume - about to set the volume to %f", percent); -*/ - - pa_cvolume new_volume; - pa_cvolume_init(&new_volume); - new_volume.channels = 1; + pa_cvolume mono_new_volume; + pa_cvolume_init(&mono_new_volume); + mono_new_volume.channels = 1; pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100); - pa_cvolume_set(&new_volume, 1, new_volume_value); + pa_cvolume_set(&mono_new_volume, 1, new_volume_value); SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); - + if (!pa_cvolume_valid (&mono_new_volume)){ + g_warning ("Invalid volume - ignore it!"); + return; + } + if (!pa_channel_map_valid(&priv->channel_map)){ + g_warning ("Invalid channel map - ignore update volume!"); + return; + } pa_cvolume_set(&priv->volume, priv->channel_map.channels, new_volume_value); - pm_update_volume (priv->index, new_volume); + pm_update_volume (priv->index, mono_new_volume); } // To the UI -- cgit v1.2.3 From b7038fe83944c2dc6a8d00222fd8db228d191c40 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 22 Feb 2012 20:04:37 +0000 Subject: putting in place more checks for transport-widget and the slider, also fixed some more ui glitches --- src/metadata-widget.c | 14 ++++++++------ src/slider-menu-item.c | 7 +++++++ src/transport-widget.c | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 5f4e1a1..36b48f8 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -168,8 +168,8 @@ metadata_widget_init (MetadataWidget *self) #endif gtk_box_pack_start (GTK_BOX (priv->meta_data_h_box), priv->album_art, - TRUE, - TRUE, + FALSE, + FALSE, 1); priv->theme_change_occured = FALSE; @@ -281,7 +281,7 @@ metadata_widget_get_preferred_width (GtkWidget* self, } /** * We override the expose method to enable primitive drawing of the - * empty album art image and rounded rectangles on the album art. + * empty album art image. */ static gboolean metadata_image_expose_gtk_3 (GtkWidget *metadata, @@ -298,8 +298,6 @@ metadata_image_expose_gtk_3 (GtkWidget *metadata, return FALSE; } - draw_album_border (metadata, FALSE); - if(priv->image_path->len > 0){ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || priv->theme_change_occured == TRUE){ @@ -310,6 +308,7 @@ metadata_image_expose_gtk_3 (GtkWidget *metadata, if(GDK_IS_PIXBUF(pixbuf) == FALSE){ gtk_image_clear ( GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); + draw_album_border (metadata, FALSE); draw_album_art_placeholder(metadata); return FALSE; } @@ -319,6 +318,7 @@ metadata_image_expose_gtk_3 (GtkWidget *metadata, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); + draw_album_border (metadata, FALSE); g_string_erase (priv->old_image_path, 0, -1); g_string_overwrite (priv->old_image_path, 0, priv->image_path->str); g_object_unref(pixbuf); @@ -327,6 +327,7 @@ metadata_image_expose_gtk_3 (GtkWidget *metadata, } gtk_image_clear (GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); + draw_album_border (metadata, FALSE); draw_album_art_placeholder(metadata); return FALSE; } @@ -499,7 +500,8 @@ metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, #endif static void -draw_album_border(GtkWidget *metadata, gboolean selected) +draw_album_border(GtkWidget *metadata, + gboolean selected) { cairo_t *cr; cr = gdk_cairo_create (gtk_widget_get_window (metadata)); diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index 7efdf74..dc0671c 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -77,6 +77,7 @@ slider_menu_item_init (SliderMenuItem *self) priv->index = NOT_ACTIVE; priv->name = NULL; + return; } @@ -152,6 +153,12 @@ slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent) pa_cvolume_init(&mono_new_volume); mono_new_volume.channels = 1; pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100); + + if (new_volume_value == PA_VOLUME_INVALID || new_volume_value >= PA_VOLUME_MAX){ + g_warning ("slider_menu_item_update_volume - volume is out of range !"); + return; + } + pa_cvolume_set(&mono_new_volume, 1, new_volume_value); SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); diff --git a/src/transport-widget.c b/src/transport-widget.c index 08e4ba9..09bb302 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -309,6 +309,7 @@ transport_widget_expose (GtkWidget *button, GdkEventExpose *event) gboolean transport_widget_is_selected ( TransportWidget* widget ) { + g_return_val_if_fail (IS_TRANSPORT_WIDGET (widget), FALSE); TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(widget); return priv->has_focus; } -- cgit v1.2.3 From d7aac51c9318e7e4613ca630902b520861af5bb9 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 24 Feb 2012 12:40:59 +0000 Subject: pad appication name text by 2 pixels --- src/metadata-widget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 36b48f8..85b4f92 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -229,7 +229,7 @@ metadata_widget_init (MetadataWidget *self) GtkWidget* player_label; player_label = gtk_label_new (""); gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0); - gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)0); + gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)2); gtk_widget_set_size_request (player_label, 150, 24); priv->player_label = player_label; -- cgit v1.2.3 From 59eb64fdd2e3848973951fbbbfd6869545f960dc Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 24 Feb 2012 16:56:22 +0000 Subject: push it down another 2 pixels --- src/metadata-widget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 85b4f92..597c12c 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -229,7 +229,7 @@ metadata_widget_init (MetadataWidget *self) GtkWidget* player_label; player_label = gtk_label_new (""); gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0); - gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)2); + gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)4); gtk_widget_set_size_request (player_label, 150, 24); priv->player_label = player_label; -- cgit v1.2.3 From b55fd2bd64c8075c86a38054900f3c59dbf53957 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 27 Feb 2012 19:08:57 +0000 Subject: make sure we are dynamically sensitive to players being uninstalled whilst they still have an entry in the menu --- src/music-player-bridge.vala | 50 +++++++++++++++++++++++++++++++++++++++++++- src/player-controller.vala | 2 -- src/settings-manager.vala | 16 +++++++++++++- 3 files changed, 64 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index e7bc1fb..c2d6623 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -28,6 +28,7 @@ public class MusicPlayerBridge : GLib.Object private SettingsManager settings_manager; private Dbusmenu.Menuitem root_menu; private HashMap registered_clients; + private HashMap file_monitors; private Mpris2Watcher watcher; public MusicPlayerBridge() @@ -36,6 +37,7 @@ public class MusicPlayerBridge : GLib.Object construct{ this.registered_clients = new HashMap (); + this.file_monitors = new HashMap (); this.settings_manager = new SettingsManager(); this.settings_manager.blacklist_updates.connect ( this.on_blacklist_update ); } @@ -74,9 +76,54 @@ public class MusicPlayerBridge : GLib.Object calculate_menu_position(), null, PlayerController.state.OFFLINE ); - this.registered_clients.set(mpris_key, ctrl); + this.registered_clients.set(mpris_key, ctrl); + this.establish_file_monitoring (app_info, mpris_key); } } + + private void establish_file_monitoring (AppInfo info, string mpris_key){ + DesktopAppInfo desktop_info = info as DesktopAppInfo; + var file_path = desktop_info.get_filename (); + File f = File.new_for_path (file_path); + FileMonitor monitor; + try { + monitor = f.monitor (FileMonitorFlags.SEND_MOVED, null); + } + catch (Error e){ + warning ("Unable to create a file monitor for %s", info.get_name()); + return; + } + this.file_monitors.set (file_path, mpris_key); + // Finally watch for a change. + monitor.changed.connect ((desktop_file, other_file, event_type) => { + this.relevant_desktop_file_changed (desktop_file, other_file, event_type, monitor); + }); + } + + private void relevant_desktop_file_changed (File desktop_file, + File? other_file, + FileMonitorEvent event_type, + FileMonitor monitor) + { + if (event_type != FileMonitorEvent.DELETED) + return; + + string? path = desktop_file.get_path (); + if (path == null){ + warning ("relevant_desktop_file_changed is returning a file with no path !"); + return; + } + if (!this.file_monitors.has_key (path)){ + warning ("relevant_desktop_file_changed is returning a file which we know nothing about - %s", + path); + return; + } + this.registered_clients[this.file_monitors[path]].remove_from_menu(); + this.settings_manager.remove_interested (this.file_monitors[path]); + this.registered_clients.unset (this.file_monitors[path]); + monitor.cancel (); + monitor.unref(); + } private int calculate_menu_position() { @@ -125,6 +172,7 @@ public class MusicPlayerBridge : GLib.Object this.registered_clients.set ( mpris_key, ctrl ); debug ( "Have not seen this %s before, new controller created.", desktop ); this.settings_manager.add_interested ( desktop ); + this.establish_file_monitoring (app_info, mpris_key); debug ( "application added to the interested list" ); } else{ diff --git a/src/player-controller.vala b/src/player-controller.vala index 05996c6..8d3e6cc 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -30,8 +30,6 @@ public class PlayerController : GLib.Object TRANSPORT, PLAYLISTS } - - public enum state{ OFFLINE, diff --git a/src/settings-manager.vala b/src/settings-manager.vala index a2be080..034cd03 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -46,7 +46,7 @@ public class SettingsManager : GLib.Object } if (s in list) continue; if (s in blacklisted) continue; - list.add(s); + list.add(s); } return list; } @@ -56,6 +56,20 @@ public class SettingsManager : GLib.Object this.settings.reset("interested-media-players"); } + public void remove_interested (string app_desktop_name) + { + var already_interested = this.settings.get_strv ("interested-media-players"); + var list = new ArrayList(); + + foreach (var s in already_interested){ + if (s == app_desktop_name) continue; + list.add (s); + } + this.settings.set_strv("interested-media-players", + list.to_array()); + this.settings.apply(); + } + public void add_interested (string app_desktop_name) { var already_interested = this.settings.get_strv ("interested-media-players"); -- cgit v1.2.3 From 5d56e1dc1ee21ec92028275690b5ce2f7595e68e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 29 Feb 2012 21:05:26 +0000 Subject: make sure to return if there is no valid playlist --- src/mpris2-controller.vala | 3 +-- src/mpris2-interfaces.vala | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index cc80a86..0fa7b6c 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -248,8 +248,7 @@ public class Mpris2Controller : GLib.Object private bool fetch_active_playlist() { if (this.playlists.ActivePlaylist.valid == false){ - // TODO - // What happens here ? + return false; } PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details ); diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index 5dab1d2..57b582d 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -49,9 +49,9 @@ public interface MprisPlayer : Object { // Playlist container public struct PlaylistDetails{ - public ObjectPath path; - public string name; - public string icon_path; + public ObjectPath? path; + public string? name; + public string? icon_path; } // Active playlist property container @@ -69,11 +69,11 @@ public interface MprisPlaylists : Object { //methods public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError; - public abstract async PlaylistDetails[] GetPlaylists ( uint32 index, + public abstract async PlaylistDetails[]? GetPlaylists ( int32 index, uint32 max_count, string order, bool reverse_order ) throws IOError; //signals public signal void PlaylistChanged (PlaylistDetails details); -} \ No newline at end of file +} -- cgit v1.2.3 From 00455609711cfc94e2488ad5a5012632bcbfee44 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 1 Mar 2012 12:12:43 +0000 Subject: how can we be sure the details struct is not null, is this the fix to that memory corruption --- src/mpris2-interfaces.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index 57b582d..ee86c2b 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -57,7 +57,7 @@ public struct PlaylistDetails{ // Active playlist property container public struct ActivePlaylistContainer{ public bool valid; - public PlaylistDetails details; + public PlaylistDetails? details; } [DBus (name = "org.mpris.MediaPlayer2.Playlists")] -- cgit v1.2.3 From ee55f50a379890e68ab9af68d02565b52a24655d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 1 Mar 2012 13:55:50 +0000 Subject: play it safe around UI pulse interactions - hopefully circumvents odd crashes that have been reported --- src/pulseaudio-mgr.c | 88 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index 3a80cbd..aca156a 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -121,7 +121,6 @@ static gboolean reconnect_to_pulse (gpointer user_data) { g_debug("Attempt a pulse connection"); - // reset g_return_val_if_fail (IS_DEVICE (user_data), FALSE); connection_attempts += 1; @@ -175,50 +174,83 @@ void pm_update_volume (gint sink_index, pa_cvolume new_volume) { if (sink_index < 0 || pulse_context == NULL){ + g_warning ("pm_update_volume sink index is negative or the context is null"); return; } - pa_operation_unref (pa_context_set_sink_volume_by_index (pulse_context, - sink_index, - &new_volume, - NULL, - NULL) ); + pa_operation *operation = NULL; + + operation = pa_context_set_sink_volume_by_index (pulse_context, + sink_index, + &new_volume, + NULL, + NULL); + if (!operation){ + g_warning ("pm_update_volume operation failed for some reason"); + return; + } + pa_operation_unref (operation); } void pm_update_mute (gboolean update) { - pa_operation_unref (pa_context_get_sink_info_list (pulse_context, - pm_toggle_mute_for_every_sink_callback, - GINT_TO_POINTER (update))); + if (pulse_context == NULL){ + g_warning ("pm_update_mute - the context is null"); + return; + } + pa_operation *operation = NULL; + + operation = pa_context_get_sink_info_list (pulse_context, + pm_toggle_mute_for_every_sink_callback, + GINT_TO_POINTER (update)); + if (!operation){ + g_warning ("pm_update_mute operation failed for some reason"); + return; + } + pa_operation_unref (operation); } void pm_update_mic_gain (gint source_index, pa_cvolume new_gain) { - // LP: #850662 if (source_index < 0 || pulse_context == NULL){ + g_warning ("pm_update_mic_gain source index is negative or the context is null"); + return; + } + pa_operation *operation = NULL; + + operation = pa_context_set_source_volume_by_index (pulse_context, + source_index, + &new_gain, + NULL, + NULL); + if (!operation){ + g_warning ("pm_update_mic_gain operation failed for some reason"); return; } - pa_operation_unref (pa_context_set_source_volume_by_index (pulse_context, - source_index, - &new_gain, - NULL, - NULL) ); + pa_operation_unref (operation); } void pm_update_mic_mute (gint source_index, gint mute_update) { - // LP: #850662 - if (source_index < 0){ - return; - } - pa_operation_unref (pa_context_set_source_mute_by_index (pulse_context, - source_index, - mute_update, - NULL, - NULL)); + if (source_index < 0){ + return; + } + pa_operation *operation = NULL; + + operation = pa_context_set_source_mute_by_index (pulse_context, + source_index, + mute_update, + NULL, + NULL); + if (!operation){ + g_warning ("pm_update_mic_mute operation failed for some reason"); + return; + } + pa_operation_unref (operation); } + /**********************************************************************************************************************/ // Pulse-Audio asychronous call-backs /**********************************************************************************************************************/ @@ -308,8 +340,6 @@ pm_subscribed_events_callback (pa_context *c, } } - - static void pm_context_state_callback (pa_context *c, void *userdata) { @@ -337,6 +367,12 @@ pm_context_state_callback (pa_context *c, void *userdata) break; case PA_CONTEXT_TERMINATED: g_debug ("Terminated"); + device_sink_deactivated (DEVICE (userdata)); + + if (reconnect_idle_id != 0){ + g_source_remove (reconnect_idle_id); + reconnect_idle_id = 0; + } break; case PA_CONTEXT_READY: connection_attempts = 0; -- cgit v1.2.3 From 40837488c4fa94e96cdfefae65020e2b443e46f5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 1 Mar 2012 16:00:38 +0000 Subject: check the state of the pulse context to ensure it's ready for interaction --- src/pulseaudio-mgr.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index aca156a..fee504e 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -177,6 +177,12 @@ pm_update_volume (gint sink_index, pa_cvolume new_volume) g_warning ("pm_update_volume sink index is negative or the context is null"); return; } + + if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){ + g_warning ("pm_update_volume context is not in a ready state"); + return; + } + pa_operation *operation = NULL; operation = pa_context_set_sink_volume_by_index (pulse_context, @@ -198,6 +204,12 @@ pm_update_mute (gboolean update) g_warning ("pm_update_mute - the context is null"); return; } + + if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){ + g_warning ("pm_update_mute context is not in a ready state"); + return; + } + pa_operation *operation = NULL; operation = pa_context_get_sink_info_list (pulse_context, @@ -217,6 +229,12 @@ pm_update_mic_gain (gint source_index, pa_cvolume new_gain) g_warning ("pm_update_mic_gain source index is negative or the context is null"); return; } + + if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){ + g_warning ("pm_update_mic_gain context is not in a ready state"); + return; + } + pa_operation *operation = NULL; operation = pa_context_set_source_volume_by_index (pulse_context, @@ -237,6 +255,12 @@ pm_update_mic_mute (gint source_index, gint mute_update) if (source_index < 0){ return; } + + if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){ + g_warning ("pm_update_mic_mute context is not in a ready state"); + return; + } + pa_operation *operation = NULL; operation = pa_context_set_source_mute_by_index (pulse_context, -- cgit v1.2.3 From 3fc82a0f5983b37d517098700928c9cbf6086e5a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 3 Mar 2012 13:12:05 -0600 Subject: fix static overrun in lp Bug #944250 --- src/metadata-widget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 597c12c..08528d1 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -528,7 +528,7 @@ draw_album_border(GtkWidget *metadata, bg_normal.g = style->bg[0].green/65535.0; bg_normal.b = style->bg[0].blue/65535.0; - gint state = selected ? 5 : 0; + const gint state = selected ? GTK_STATE_SELECTED : GTK_STATE_NORMAL; fg_normal.r = style->fg[state].red/65535.0; fg_normal.g = style->fg[state].green/65535.0; -- cgit v1.2.3 From 03ea74c27df1d586f14cca8e177944bc0f3b7bfa Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 10 Mar 2012 00:15:23 -0600 Subject: use the new signals from lp:~charlesk/ido/lp-921065 to fix lp bug #921065 --- src/volume-widget.c | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/volume-widget.c b/src/volume-widget.c index bd68eb3..c71c1e3 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -56,7 +56,8 @@ static gboolean volume_widget_change_value_cb (GtkRange *range, GtkScrollType scroll, gdouble value, gpointer user_data); -static gboolean volume_widget_value_changed_cb(GtkRange *range, gpointer user_data); +static void volume_widget_primary_clicked(GtkWidget *widget, gpointer user_data); +static void volume_widget_secondary_clicked(GtkWidget *widget, gpointer user_data); static void volume_widget_slider_grabbed(GtkWidget *widget, gpointer user_data); static void volume_widget_slider_released(GtkWidget *widget, gpointer user_data); static void volume_widget_parent_changed (GtkWidget *widget, gpointer user_data); @@ -93,7 +94,8 @@ volume_widget_init (VolumeWidget *self) GtkWidget* volume_widget = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); g_signal_connect(volume_widget, "change-value", G_CALLBACK(volume_widget_change_value_cb), self); - g_signal_connect(volume_widget, "value-changed", G_CALLBACK(volume_widget_value_changed_cb), self); + g_signal_connect(priv->ido_volume_slider, "primary-clicked", G_CALLBACK(volume_widget_primary_clicked), self); + g_signal_connect(priv->ido_volume_slider, "secondary-clicked", G_CALLBACK(volume_widget_secondary_clicked), self); g_signal_connect(priv->ido_volume_slider, "slider-grabbed", G_CALLBACK(volume_widget_slider_grabbed), self); g_signal_connect(priv->ido_volume_slider, "slider-released", G_CALLBACK(volume_widget_slider_released), self); @@ -213,32 +215,6 @@ volume_widget_change_value_cb (GtkRange *range, return FALSE; } -/* - We only want this callback to catch mouse icon press events - which set the slider to 0 or 100. Ignore all other events. -*/ -static gboolean -volume_widget_value_changed_cb (GtkRange *range, gpointer user_data) -{ - - g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); - VolumeWidget* mitem = VOLUME_WIDGET (user_data); - VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); - GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); - gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100); - - gboolean mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant (priv->twin_item, - DBUSMENU_VOLUME_MENUITEM_MUTE)); - if((current_value == 0 && mute == FALSE) || current_value == 100){ -/* - g_debug ("value changed - actual set %f", current_value); -*/ - volume_widget_update (mitem, current_value, "value-changed"); - } - - return FALSE; -} - void volume_widget_update(VolumeWidget* self, gdouble update, gchar* label) { @@ -253,6 +229,30 @@ volume_widget_update(VolumeWidget* self, gdouble update, gchar* label) dbusmenu_menuitem_handle_event (priv->twin_item, source, new_volume, 0); } +static void +volume_widget_update_from_scale (VolumeWidget *self) +{ + g_return_if_fail (IS_VOLUME_WIDGET (self)); + + VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self); + GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); + const gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100); + g_debug ("%s - setting value to %.0f", G_STRFUNC, current_value); + volume_widget_update (self, current_value, "value-changed"); +} + +static void +volume_widget_primary_clicked (GtkWidget *widget G_GNUC_UNUSED, gpointer user_data) +{ + volume_widget_update_from_scale (VOLUME_WIDGET(user_data)); +} + +static void +volume_widget_secondary_clicked(GtkWidget *widget, gpointer user_data) +{ + volume_widget_update_from_scale (VOLUME_WIDGET(user_data)); +} + GtkWidget* volume_widget_get_ido_slider(VolumeWidget* self) { -- cgit v1.2.3 From 8ff7b4e126fff53f596810063cf27d136dc74fa4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 12 Mar 2012 15:56:26 +0000 Subject: signature on the GetPlaylists mpris in the interface corrected --- src/mpris2-interfaces.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index ee86c2b..db6888d 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -69,7 +69,7 @@ public interface MprisPlaylists : Object { //methods public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError; - public abstract async PlaylistDetails[]? GetPlaylists ( int32 index, + public abstract async PlaylistDetails[]? GetPlaylists ( uint32 index, uint32 max_count, string order, bool reverse_order ) throws IOError; -- cgit v1.2.3 From c759f4e9b00132c499241448d8c4f8eb72297d17 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 13 Mar 2012 15:36:35 +0000 Subject: Makes sure to accommodate for null player titles as supplied by the mpris interface of the player, redundant code spotted by Coverity --- src/metadata-menu-item.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 42f9667..897a502 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -178,7 +178,7 @@ public class MetadataMenuitem : PlayerItem } } - public void alter_label (string new_title) + public void alter_label (string? new_title) { if (new_title == null) return; this.property_set (MENUITEM_PLAYER_NAME, new_title); -- cgit v1.2.3 From f61ca4cc7e620fe55b4d91f6a798abb3063fdcf2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 14 Mar 2012 11:57:48 +0000 Subject: make sure to be defensive if pulse goes away in the middle of a global mute operation --- src/pulseaudio-mgr.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index fee504e..747f59b 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -218,7 +218,7 @@ pm_update_mute (gboolean update) if (!operation){ g_warning ("pm_update_mute operation failed for some reason"); return; - } + } pa_operation_unref (operation); } @@ -621,17 +621,23 @@ pm_toggle_mute_for_every_sink_callback (pa_context *c, if (eol > 0) { return; } - else { - if (sink == NULL) { - g_warning ("toggle_mute cb - sink parameter is null - why ?"); - return; - } - pa_operation_unref (pa_context_set_sink_mute_by_index (c, - sink->index, - GPOINTER_TO_INT(userdata), - NULL, - NULL)); + + if (sink == NULL) { + g_warning ("toggle_mute cb - sink parameter is null - why ?"); + return; } + + pa_operation *operation = NULL; + operation = pa_context_set_sink_mute_by_index (c, + sink->index, + GPOINTER_TO_INT(userdata), + NULL, + NULL); + if (!operation){ + g_warning ("pm_update_mic_mute operation failed for some reason"); + return; + } + pa_operation_unref (operation); } // Source info related callbacks -- cgit v1.2.3 From ca2d708b57218c16c505fc5092f4c0c3ea52f89c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 14 Mar 2012 18:55:22 +0000 Subject: make the code clear so as coverity stops whinging. --- src/pulseaudio-mgr.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index fee504e..b8d754f 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -401,27 +401,39 @@ pm_context_state_callback (pa_context *c, void *userdata) case PA_CONTEXT_READY: connection_attempts = 0; g_debug("PA_CONTEXT_READY"); + if (reconnect_idle_id != 0){ g_source_remove (reconnect_idle_id); reconnect_idle_id = 0; } - pa_operation *o; pa_context_set_subscribe_callback(c, pm_subscribed_events_callback, userdata); - - if (!(o = pa_context_subscribe (c, (pa_subscription_mask_t) - (PA_SUBSCRIPTION_MASK_SINK| - PA_SUBSCRIPTION_MASK_SOURCE| - PA_SUBSCRIPTION_MASK_SINK_INPUT| - PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT| - PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) { - g_warning("pa_context_subscribe() failed"); + pa_operation *o = NULL; + + o = pa_context_subscribe (c, (pa_subscription_mask_t) + (PA_SUBSCRIPTION_MASK_SINK| + PA_SUBSCRIPTION_MASK_SOURCE| + PA_SUBSCRIPTION_MASK_SINK_INPUT| + PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT| + PA_SUBSCRIPTION_MASK_SERVER), + NULL, + NULL); + + if (!o){ + g_critical("pa_context_subscribe() failed - ?"); + return; } - if (!(o = pa_context_get_server_info (c, pm_server_info_callback, userdata))) { - g_warning("Initial - pa_context_get_server_info() failed"); + pa_operation_unref(o); + + o = pa_context_get_server_info (c, pm_server_info_callback, userdata); + + if (!o){ + g_warning("pa_context_get_server_info() failed - ?"); + return; } + pa_operation_unref(o); break; -- cgit v1.2.3 From bd9058c2d24803cf0224128df18fdb3471700b68 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 14 Mar 2012 19:19:11 +0000 Subject: remove crud --- src/familiar-players-db.vala | 164 ------------------------------------------- 1 file changed, 164 deletions(-) delete mode 100644 src/familiar-players-db.vala (limited to 'src') diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala deleted file mode 100644 index c47a35d..0000000 --- a/src/familiar-players-db.vala +++ /dev/null @@ -1,164 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, 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, see . -*/ - -using Gee; -using GLib.Path; -using GLib.DirUtils; -using GLib.FileUtils; -using GLib.Timeout; -using GLib.Environment; - -// TODO: more refactoring needed here -public class FamiliarPlayersDB : GLib.Object -{ - private const string GROUP_NAME = "Seen Database"; - private const string KEY_NAME = "DesktopFiles"; - private const string DEFAULT_APP_DESKTOP = "/usr/share/applications/banshee-1.desktop"; - private HashMap players_DB; - private string file_name; - private string dir_name; - private KeyFile key_file; - private uint write_id; - - public FamiliarPlayersDB() - { - this.write_id = 0; - this.players_DB = new HashMap(); - if ( !create_key_file() ){ - this.players_DB.set(DEFAULT_APP_DESKTOP, true); - this.write_db(); - } - - this.dir_name = build_filename(get_user_cache_dir(), "indicator", "sound"); - this.file_name = build_filename(this.dir_name, "familiar-players-db.keyfile"); - if(create_key_file() && check_for_keys() && load_data_from_key_file()){ - debug("keyfiles in place and ready for action"); - } - else{ - this.key_file = null; - warning("FamiliarPlayersDB:: problems loading key file - can't go any further"); - } - } - - private bool create_key_file(){ - bool result = false; - if (test(this.file_name, GLib.FileTest.EXISTS)) { - this.key_file = new KeyFile(); - try{ - result = this.key_file.load_from_file(this.file_name, KeyFileFlags.NONE); - } - catch(GLib.KeyFileError e){ - warning("FamiliarPlayersDB::create_key_file() - KeyFileError"); - } - catch(GLib.FileError e){ - warning("FamiliarPlayersDB::create_key_file() - FileError"); - } - } - return result; - } - - private bool check_for_keys(){ - try{ - if(this.key_file.has_key(GROUP_NAME, KEY_NAME) == true){ - return true; - } - } - catch(KeyFileError e){ - return false; - } - warning("Seen DB '%s' does not have key '%s' in group '%s'", this.file_name, KEY_NAME, GROUP_NAME); - return false; - } - - private bool load_data_from_key_file(){ - try{ - string[] desktops = this.key_file.get_string_list(GROUP_NAME, - KEY_NAME); - foreach(string s in desktops){ - this.players_DB.set(s, true); - } - return true; - } - catch(GLib.KeyFileError error){ - warning("Error loading the Desktop string list"); - return false; - } - } - - private bool write_db() - { - KeyFile keyfile = new KeyFile(); - string[] desktops = {}; - foreach(string key in this.players_DB.keys){ - desktops += key; - } - keyfile.set_string_list(GROUP_NAME, - KEY_NAME, - desktops); - size_t data_length; - string data = null; - try{ - data = keyfile.to_data(out data_length); - } - catch(GLib.KeyFileError e){ - warning("Problems dumping keyfile to a string"); - return false; - } - - if(create_with_parents(this.dir_name, 0700) != 0){ - warning("Unable to make directory: %s", this.dir_name); - return false; - } - - try{ - if(set_contents(this.file_name, data, (ssize_t)data_length) == false){ - warning("Unable to write out file '%s'", this.file_name); - } - } - catch(FileError err){ - warning("Unable to write out file '%s'", this.file_name); - } - return true; - } - - public void insert(string desktop) - { - if(already_familiar(desktop) == false){ - if(this.write_id != 0){ - Source.remove(this.write_id); - this.write_id = 0; - } - this.write_id = Timeout.add_seconds(60, write_db); - this.players_DB.set(desktop.dup(), true); - } - } - - public bool already_familiar(string desktop) - { - debug("playerDB->already_familiar - result %s", this.players_DB.keys.contains(desktop).to_string()); - return this.players_DB.keys.contains(desktop); - } - - public Gee.Set records() - { - return this.players_DB.keys; - } - - -} \ No newline at end of file -- cgit v1.2.3 From c0423cafd88209571251ae71b17ef482a6da9f9a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 15 Mar 2012 17:04:15 +0000 Subject: fixes excessive draw calls --- src/metadata-widget.c | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 08528d1..c360348 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -138,8 +138,7 @@ metadata_widget_init (MetadataWidget *self) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); #else hbox = gtk_hbox_new(FALSE, 0); - #endif - + #endif priv->meta_data_h_box = hbox; priv->current_height = 1; @@ -270,6 +269,18 @@ metadata_widget_finalize (GObject *object) G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object); } +/** +* Make sure to only clear the album art only when it is not empty +* Otherwise it will continuously call queue_draw after each empty call. +*/ +static void +clear_album_art (GtkImage* album_art) +{ + if (gtk_image_get_storage_type(album_art) != GTK_IMAGE_EMPTY){ + gtk_image_clear (album_art); + } +} + #if GTK_CHECK_VERSION(3, 0, 0) static void @@ -279,6 +290,7 @@ metadata_widget_get_preferred_width (GtkWidget* self, { *minimum_width = *natural_width = 200; } + /** * We override the expose method to enable primitive drawing of the * empty album art image. @@ -298,15 +310,16 @@ metadata_image_expose_gtk_3 (GtkWidget *metadata, return FALSE; } - if(priv->image_path->len > 0){ - if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || + if((guint)priv->image_path->len != 0){ + + if(g_string_equal (priv->image_path, priv->old_image_path) == FALSE || priv->theme_change_occured == TRUE){ priv->theme_change_occured = FALSE; GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL); - + if(GDK_IS_PIXBUF(pixbuf) == FALSE){ - gtk_image_clear ( GTK_IMAGE(priv->album_art)); + clear_album_art (GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_border (metadata, FALSE); draw_album_art_placeholder(metadata); @@ -325,9 +338,10 @@ metadata_image_expose_gtk_3 (GtkWidget *metadata, } return FALSE; } - gtk_image_clear (GTK_IMAGE(priv->album_art)); + clear_album_art (GTK_IMAGE(priv->album_art)); + g_string_erase (priv->old_image_path, 0, -1); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); - draw_album_border (metadata, FALSE); + draw_album_border (metadata, FALSE); draw_album_art_placeholder(metadata); return FALSE; } @@ -337,8 +351,7 @@ static gboolean metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget, cairo_t* cr, gpointer user_data) -{ - +{ g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); MetadataWidget* meta = METADATA_WIDGET(user_data); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); @@ -371,11 +384,8 @@ metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget, if (dbusmenu_menuitem_property_get_bool (priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ y += gdk_pixbuf_get_height (priv->icon_buf) / 3 + 3; - //allocation.height/2.0 - (double)arrow_height/2.0; cairo_set_line_width (cr, 1.0); - //g_debug ("triangle drawing"); - cairo_move_to (cr, x, y); cairo_line_to (cr, x, y + arrow_height); cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); @@ -417,7 +427,7 @@ metadata_image_expose (GtkWidget *metadata, pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL); if(GDK_IS_PIXBUF(pixbuf) == FALSE){ - gtk_image_clear ( GTK_IMAGE(priv->album_art)); + clear_album_art (GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); return FALSE; @@ -434,7 +444,7 @@ metadata_image_expose (GtkWidget *metadata, } return FALSE; } - gtk_image_clear (GTK_IMAGE(priv->album_art)); + clear_album_art (GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); return FALSE; @@ -597,7 +607,7 @@ draw_album_border(GtkWidget *metadata, static void draw_album_art_placeholder(GtkWidget *metadata) -{ +{ cairo_t *cr; cr = gdk_cairo_create (gtk_widget_get_window (metadata)); GtkStyle *style; @@ -726,7 +736,7 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){ g_string_erase(priv->image_path, 0, -1); - g_string_overwrite(priv->image_path, 0, g_variant_get_string (value, NULL)); + g_string_overwrite (priv->image_path, 0, g_variant_get_string (value, NULL)); gtk_widget_queue_draw(GTK_WIDGET(mitem)); } else if (g_ascii_strcasecmp (DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, property) == 0){ @@ -753,7 +763,7 @@ metadata_widget_handle_resizing (MetadataWidget* self) else{ gtk_widget_show (priv->meta_data_h_box); } - gtk_widget_queue_draw(GTK_WIDGET(self)); + gtk_widget_queue_draw(GTK_WIDGET(self)); } static void @@ -773,7 +783,7 @@ metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style) MetadataWidget* widg = METADATA_WIDGET(metadata); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widg); priv->theme_change_occured = TRUE; - gtk_widget_queue_draw(GTK_WIDGET(metadata)); + gtk_widget_queue_draw (GTK_WIDGET(metadata)); } static void -- cgit v1.2.3 From 68056b33ce18e68e6ceea1a8b260f1b5e51edd7d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 15 Mar 2012 17:07:53 +0000 Subject: make sure to clear the old image for gtk2 aswell --- src/metadata-widget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index c360348..da2ae9a 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -444,7 +444,8 @@ metadata_image_expose (GtkWidget *metadata, } return FALSE; } - clear_album_art (GTK_IMAGE(priv->album_art)); + clear_album_art (GTK_IMAGE(priv->album_art)); + g_string_erase (priv->old_image_path, 0, -1); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); return FALSE; -- cgit v1.2.3 From 380631efc3397de66c9ac8309c69802c4e04195d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 16 Mar 2012 11:07:29 +0000 Subject: don't g_error just use g_critical --- src/indicator-sound.c | 8 ++++---- src/sound-service-dbus.c | 17 ++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 243e759..272c8da 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -299,8 +299,8 @@ connection_changed (IndicatorServiceManager * sm, node_info = g_dbus_node_info_new_for_xml ( _sound_service, &error ); if (error != NULL) { - g_warning( "Failed to get create interface info from xml: %s", - error->message ); + g_critical ( "Failed to get create interface info from xml: %s", + error->message ); g_error_free(error); return; } @@ -310,7 +310,7 @@ connection_changed (IndicatorServiceManager * sm, interface_info = g_dbus_node_info_lookup_interface (node_info, INDICATOR_SOUND_DBUS_INTERFACE); if (interface_info == NULL) { - g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); + g_critical ("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); } } @@ -339,7 +339,7 @@ static void create_connection_to_service (GObject *source_object, priv->dbus_proxy = g_dbus_proxy_new_finish(res, &error); if (error != NULL) { - g_warning("Failed to get dbus proxy: %s", error->message); + g_critical ("Failed to get dbus proxy: %s", error->message); g_error_free(error); return; } diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 07d3d6f..7cad2bc 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -107,7 +107,7 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) node_info = g_dbus_node_info_new_for_xml(_sound_service, &error); if (error != NULL) { - g_error("Unable to parse Indicator Service Interface description: %s", + g_critical ("Unable to parse Indicator Service Interface description: %s", error->message); g_error_free(error); } @@ -118,7 +118,7 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) INDICATOR_SOUND_DBUS_INTERFACE); if (interface_info == NULL) { - g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); + g_critical("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); } } signals[TRACK_SPECIFIC_ITEM] = g_signal_new("track-specific-item-requested", @@ -151,8 +151,8 @@ sound_service_dbus_init (SoundServiceDbus *self) priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (error != NULL) { - g_error("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message); - g_error_free(error); + g_critical ("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message); + g_error_free (error); return; } /* register the service on it */ @@ -164,9 +164,8 @@ sound_service_dbus_init (SoundServiceDbus *self) NULL, &error); if (error != NULL) { - g_error("Unable to register the object to DBus: %s", error->message); - g_error_free(error); - return; + g_critical ("Unable to register the sound service on DBus: %s", error->message); + g_error_free (error); } } @@ -275,12 +274,12 @@ sound_service_dbus_update_sound_state (SoundServiceDbus* self, if (priv->connection == NULL || g_dbus_connection_is_closed (priv->connection) == TRUE){ - g_critical ("sound_service_dbus_update_sound_state - connection is %s !!", + g_critical ("sound_service_dbus_update_sound_state - dbus connection is %s !!", priv->connection == NULL? "NULL" : "closed"); return; } - g_debug ("emitting state signal with value %i", (int)new_state); + //g_debug ("emitting state signal with value %i", (int)new_state); g_dbus_connection_emit_signal( priv->connection, NULL, INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH, -- cgit v1.2.3 From f0bcb96d0f2a62ba7497b387ca1cf290b39aea33 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 16 Mar 2012 17:30:21 +0000 Subject: set the player name on the transport item so as hud can identify the default player --- src/metadata-menu-item.vala | 2 +- src/player-controller.vala | 2 +- src/transport-menu-item.vala | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 897a502..b2dd752 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -39,7 +39,7 @@ public class MetadataMenuitem : PlayerItem MetadataMenuitem.clean_album_art_temp_dir(); this.previous_temp_album_art_path = null; this.album_art_cache_dir = MetadataMenuitem.create_album_art_temp_dir(); - debug ("JUST ABOUT TO ATTEMPT PLAYER NAME SETTING %s", this.owner.app_info.get_name()); + //debug ("JUST ABOUT TO ATTEMPT PLAYER NAME SETTING %s", this.owner.app_info.get_name()); this.property_set (MENUITEM_PLAYER_NAME, this.owner.app_info.get_name()); this.property_set (MENUITEM_PLAYER_ICON, this.owner.icon_name); this.property_set_bool (MENUITEM_PLAYER_RUNNING, false); diff --git a/src/player-controller.vala b/src/player-controller.vala index 8d3e6cc..80a48c3 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -174,7 +174,7 @@ public class PlayerController : GLib.Object if(this.current_state != state.CONNECTED){ metadata_menuitem.should_collapse (true); playlists_menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, - false ); + false); this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE, this.app_info.get_id() == "rhythmbox.desktop"); return; diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index ec41dd7..4ec7dad 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -38,6 +38,7 @@ public class TransportMenuitem : PlayerItem } construct{ this.property_set_int(MENUITEM_PLAY_STATE, (int)Transport.State.PAUSED); + this.property_set (MENUITEM_PROP_LABEL, this.owner.app_info.get_name()); this.cached_action = Transport.Action.NO_ACTION; } -- cgit v1.2.3 From 3540a2cd6281cebe2a0765d56d1af8343c12447a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 16 Mar 2012 18:20:35 -0500 Subject: fix a pair of minor memory leaks when processing blacklist requests via dbus. --- src/sound-service-dbus.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 7cad2bc..5e004cb 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -82,11 +82,11 @@ static void sound_service_dbus_finalize (GObject *object); static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data); static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, - gchar* player_name, + const gchar* player_name, gboolean blacklist); static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus* self, - gchar* player_name); + const gchar* player_name); G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT); @@ -315,8 +315,8 @@ bus_method_call (GDBusConnection * connection, } else if (g_strcmp0(method, "BlacklistMediaPlayer") == 0) { gboolean blacklist; - gchar* player_name; - g_variant_get (params, "(sb)", &player_name, &blacklist); + const gchar* player_name; + g_variant_get (params, "(&sb)", &player_name, &blacklist); g_debug ("BlacklistMediaPlayer - bool %i", blacklist); g_debug ("BlacklistMediaPlayer - name %s", player_name); @@ -326,8 +326,8 @@ bus_method_call (GDBusConnection * connection, retval = g_variant_new ("(b)", result); } else if (g_strcmp0(method, "IsBlacklisted") == 0) { - gchar* player_name; - g_variant_get (params, "(s)", &player_name); + const gchar* player_name; + g_variant_get (params, "(&s)", &player_name); g_debug ("IsBlacklisted - name %s", player_name); gboolean result = sound_service_dbus_is_blacklisted (service, @@ -374,7 +374,7 @@ bus_method_call (GDBusConnection * connection, TODO - Works nicely but refactor into at least two different methods **/ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, - gchar* player_name, + const gchar* player_name, gboolean blacklist) { g_return_val_if_fail (player_name != NULL, FALSE); @@ -457,7 +457,7 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, } static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus *self, - gchar *player_name) + const gchar *player_name) { GSettings *our_settings; GVariant *the_black_list; -- cgit v1.2.3 From fef2588bd53233c6b4282bedf47b416ed95e2402 Mon Sep 17 00:00:00 2001 From: Gabor Kelemen Date: Sat, 17 Mar 2012 01:37:32 +0100 Subject: Change i18n header to gi18n-lib.h to translate the accessible description. Also change it in other files too to make them futureproof. LP: #957517 --- src/indicator-sound.c | 4 ++-- src/metadata-widget.c | 2 +- src/voip-input-widget.c | 2 +- src/volume-widget.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 272c8da..ff7b58c 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -17,10 +17,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "indicator-sound.h" #include #include #include -#include +#include #include #include #include @@ -28,7 +29,6 @@ with this program. If not, see . #include -#include "indicator-sound.h" #include "transport-widget.h" #include "metadata-widget.h" #include "volume-widget.h" diff --git a/src/metadata-widget.c b/src/metadata-widget.c index da2ae9a..ceae79a 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -22,7 +22,7 @@ with this program. If not, see . #include "config.h" #endif -#include +#include #include "metadata-widget.h" #include "common-defs.h" #include diff --git a/src/voip-input-widget.c b/src/voip-input-widget.c index 5f67fab..03879e7 100644 --- a/src/voip-input-widget.c +++ b/src/voip-input-widget.c @@ -22,7 +22,7 @@ with this program. If not, see . #include "config.h" #endif -#include +#include #include #include #include "voip-input-widget.h" diff --git a/src/volume-widget.c b/src/volume-widget.c index c71c1e3..ac603c1 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -22,7 +22,7 @@ with this program. If not, see . #include "config.h" #endif -#include +#include #include #include #include "volume-widget.h" -- cgit v1.2.3 From 90c440a05e9d0f45583719c921e2fbd2d4eefaa7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 19 Mar 2012 18:35:30 +0000 Subject: more defensive approach to dealing with the playlistdetails struct specifically the activeplaylist prop, tweaked player label padding by 1 pixel --- src/metadata-widget.c | 2 +- src/mpris2-controller.vala | 22 +++++++++++++++++++--- src/mpris2-interfaces.vala | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index ceae79a..7c7e750 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -228,7 +228,7 @@ metadata_widget_init (MetadataWidget *self) GtkWidget* player_label; player_label = gtk_label_new (""); gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0); - gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)4); + gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)3); gtk_widget_set_size_request (player_label, 150, 24); priv->player_label = player_label; diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 0fa7b6c..9cd02c4 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -92,7 +92,7 @@ public class Mpris2Controller : GLib.Object } Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); if ( playlist_v != null && this.owner.use_playlists == true ){ - Timeout.add (300, this.fetch_active_playlist); + Timeout.add (500, this.fetch_active_playlist); } Variant? playlist_count_v = changed_properties.lookup("PlaylistCount"); if ( playlist_count_v != null && this.owner.use_playlists == true ){ @@ -240,14 +240,30 @@ public class Mpris2Controller : GLib.Object playlists_item.update(current_playlists); } else{ - warning(" Playlists are on but its returning no current_playlists" ); + warning(" Playlists are on but %s is returning no current_playlists ?", + this.owner.app_info.get_name()); this.owner.use_playlists = false; } } + private bool validate_playlists_details() + { + if (this.playlists.ActivePlaylist.valid == false){ + return false; + } + if (this.playlists.ActivePlaylist.details == null){ + return false; + } + if (this.playlists.ActivePlaylist.details.path == null || + this.playlists.ActivePlaylist.details.name == null){ + return false; + } + return true; + } + private bool fetch_active_playlist() { - if (this.playlists.ActivePlaylist.valid == false){ + if (this.validate_playlists_details() == false){ return false; } PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index db6888d..cb68e84 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -65,7 +65,7 @@ public interface MprisPlaylists : Object { //properties public abstract string[] Orderings{owned get; set;} public abstract uint32 PlaylistCount{owned get; set;} - public abstract ActivePlaylistContainer ActivePlaylist {owned get; set;} + public abstract ActivePlaylistContainer? ActivePlaylist {owned get; set;} //methods public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError; -- cgit v1.2.3 From cf5c77a39f7355e8a2a6ee719a36bcbe6dfc0d7f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 21 Mar 2012 09:47:53 +0000 Subject: make sure to check the active playlists container is not null --- src/mpris2-controller.vala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 9cd02c4..2cc8d12 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -248,6 +248,9 @@ public class Mpris2Controller : GLib.Object private bool validate_playlists_details() { + if (this.playlists.ActivePlaylist == null){ + return false; + } if (this.playlists.ActivePlaylist.valid == false){ return false; } -- cgit v1.2.3 From e02ed10f6b14e5d43a6e02e0ea929a71cfba5964 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 26 Mar 2012 18:30:58 -0700 Subject: remove_interested() and add_interested() shouldn't call g_settings_set_strv() with an array of strings that isn't NULL-terminated. --- src/settings-manager.vala | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/settings-manager.vala b/src/settings-manager.vala index 034cd03..d57241e 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -58,27 +58,31 @@ public class SettingsManager : GLib.Object public void remove_interested (string app_desktop_name) { - var already_interested = this.settings.get_strv ("interested-media-players"); - var list = new ArrayList(); + const string key = "interested-media-players"; + var players = new GLib.VariantBuilder (new VariantType ("as")); // array of strings - foreach (var s in already_interested){ - if (s == app_desktop_name) continue; - list.add (s); + foreach (var player in this.settings.get_strv (key)) { + if (player != app_desktop_name) + players.add ("s", player); } - this.settings.set_strv("interested-media-players", - list.to_array()); - this.settings.apply(); + + this.settings.set_value(key, players.end()); + this.settings.apply(); } public void add_interested (string app_desktop_name) { - var already_interested = this.settings.get_strv ("interested-media-players"); - foreach (var s in already_interested){ - if ( s == app_desktop_name ) return; + const string key = "interested-media-players"; + var players = new GLib.VariantBuilder (new VariantType ("as")); // array of strings + + foreach (var player in this.settings.get_strv (key)) { + if (player == app_desktop_name) + return; + players.add ("s", player); } - already_interested += (app_desktop_name); - this.settings.set_strv( "interested-media-players", - already_interested ); + + players.add ("s", app_desktop_name); + this.settings.set_value(key, players.end()); this.settings.apply(); } -- cgit v1.2.3 From afb59cd4a8fa5731b5f737a4ef58fe1f3ae2fbb8 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 26 Mar 2012 18:33:40 -0700 Subject: prevent a cyclical dependency in establish_file_monitoring() from trying to unref 'monitor' right after it's been freed. --- src/music-player-bridge.vala | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index c2d6623..18f1c40 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -85,19 +85,20 @@ public class MusicPlayerBridge : GLib.Object DesktopAppInfo desktop_info = info as DesktopAppInfo; var file_path = desktop_info.get_filename (); File f = File.new_for_path (file_path); - FileMonitor monitor; try { - monitor = f.monitor (FileMonitorFlags.SEND_MOVED, null); + FileMonitor monitor = f.monitor (FileMonitorFlags.SEND_MOVED, null); + unowned FileMonitor weak_monitor = monitor; + monitor.changed.connect ((desktop_file, other_file, event_type) => { + this.relevant_desktop_file_changed (desktop_file, other_file, event_type, weak_monitor); + }); + monitor.ref(); // will be unref()ed by relevant_desktop_file_changed() + GLib.debug ("monitoring file '%s'", file_path); + this.file_monitors.set (file_path, mpris_key); } catch (Error e){ warning ("Unable to create a file monitor for %s", info.get_name()); return; } - this.file_monitors.set (file_path, mpris_key); - // Finally watch for a change. - monitor.changed.connect ((desktop_file, other_file, event_type) => { - this.relevant_desktop_file_changed (desktop_file, other_file, event_type, monitor); - }); } private void relevant_desktop_file_changed (File desktop_file, @@ -117,10 +118,13 @@ public class MusicPlayerBridge : GLib.Object warning ("relevant_desktop_file_changed is returning a file which we know nothing about - %s", path); return; - } - this.registered_clients[this.file_monitors[path]].remove_from_menu(); - this.settings_manager.remove_interested (this.file_monitors[path]); - this.registered_clients.unset (this.file_monitors[path]); + } + + var mpris_key = this.file_monitors[path]; + GLib.debug ("file \"%s\" was removed; stopping monitoring \"%s\"", path, mpris_key); + this.registered_clients[mpris_key].remove_from_menu(); + this.settings_manager.remove_interested (mpris_key); + this.registered_clients.unset (mpris_key); monitor.cancel (); monitor.unref(); } -- cgit v1.2.3 From f1182db17f363783178c191b1e7af328deea0372 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 30 Mar 2012 13:20:48 +0100 Subject: move the app icon in from the gutter --- src/Makefile.am | 2 +- src/metadata-widget.c | 96 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 58 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 5a36822..debaa2f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,7 +31,7 @@ libsoundmenu_la_SOURCES = \ libsoundmenu_la_CFLAGS = \ $(APPLET_CFLAGS) \ $(COVERAGE_CFLAGS) \ - -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\" + -Wall -DG_LOG_DOMAIN=\"Indicator-Sound\" libsoundmenu_la_LIBADD = $(APPLET_LIBS) -lm libsoundmenu_la_LDFLAGS = \ $(COVERAGE_LDFLAGS) \ diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 7c7e750..238c5b1 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -44,7 +44,7 @@ struct _MetadataWidgetPrivate GtkWidget* piece_label; GtkWidget* container_label; GtkWidget* player_label; - GdkPixbuf* icon_buf; + GtkWidget* player_icon; DbusmenuMenuitem* twin_item; gint current_height; }; @@ -126,7 +126,7 @@ metadata_widget_init (MetadataWidget *self) MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); GtkWidget *hbox; GtkWidget *outer_v_box; - priv->icon_buf = NULL; + //priv->icon_buf = NULL; #if GTK_CHECK_VERSION(3, 0, 0) outer_v_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); @@ -178,7 +178,6 @@ metadata_widget_init (MetadataWidget *self) GtkWidget* vbox = gtk_vbox_new(FALSE, 0); #endif - // artist GtkWidget* artist; artist = gtk_label_new(""); @@ -224,16 +223,31 @@ metadata_widget_init (MetadataWidget *self) G_CALLBACK(metadata_widget_selection_received_event_callback), GTK_WIDGET(self)); + gint padding = 4; + gtk_widget_style_get(GTK_WIDGET(self), "toggle-spacing", &padding, NULL); + +#if GTK_CHECK_VERSION(3, 0, 0) + GtkWidget * tophbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, padding); +#else + GtkWidget * tophbox = gtk_hbox_new(FALSE, padding); +#endif + + GtkWidget *player_icon; + player_icon = gtk_image_new(); + priv->player_icon = player_icon; + + gtk_misc_set_alignment (GTK_MISC(priv->player_icon), 1.0 /* right aligned */, 0.5); + gtk_box_pack_start (GTK_BOX (tophbox), priv->player_icon, FALSE, FALSE, 0); + // player label GtkWidget* player_label; player_label = gtk_label_new (""); - gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0); - gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)3); - gtk_widget_set_size_request (player_label, 150, 24); + gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, 0.5); priv->player_label = player_label; + gtk_box_pack_start (GTK_BOX (tophbox), priv->player_label, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX(outer_v_box), priv->player_label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(outer_v_box), tophbox, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 5); gtk_container_add (GTK_CONTAINER (self), outer_v_box); @@ -246,16 +260,16 @@ metadata_widget_init (MetadataWidget *self) static void metadata_widget_dispose (GObject *object) { - MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); + //MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); - if (priv->icon_buf != NULL){ + /*if (priv->icon_buf != NULL){ #if GTK_CHECK_VERSION(3, 0, 0) g_object_unref(priv->icon_buf); #else gdk_pixbuf_unref(priv->icon_buf); #endif priv->icon_buf = NULL; - } + }*/ G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); } @@ -352,7 +366,7 @@ metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget, cairo_t* cr, gpointer user_data) { - g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + /*g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); MetadataWidget* meta = METADATA_WIDGET(user_data); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); @@ -372,16 +386,16 @@ metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget, gint offset = gdk_pixbuf_get_height (priv->icon_buf) / 3; // Draw player icon - if (priv->icon_buf != NULL){ + /*if (priv->icon_buf != NULL){ gdk_cairo_set_source_pixbuf (cr, priv->icon_buf, x + arrow_width + 1, y + offset); cairo_paint (cr); - } + }*/ // Draw triangle but only if the player is running. - if (dbusmenu_menuitem_property_get_bool (priv->twin_item, + /*if (dbusmenu_menuitem_property_get_bool (priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ y += gdk_pixbuf_get_height (priv->icon_buf) / 3 + 3; cairo_set_line_width (cr, 1.0); @@ -394,7 +408,7 @@ metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget, style->fg[gtk_widget_get_state(widget)].green/65535.0, style->fg[gtk_widget_get_state(widget)].blue/65535.0); cairo_fill (cr); - } + }*/ return FALSE; } @@ -445,7 +459,7 @@ metadata_image_expose (GtkWidget *metadata, return FALSE; } clear_album_art (GTK_IMAGE(priv->album_art)); - g_string_erase (priv->old_image_path, 0, -1); + g_string_erase (priv->old_image_path, 0, -1); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); return FALSE; @@ -458,10 +472,14 @@ metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { - g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + /*g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + MetadataWidget* meta = METADATA_WIDGET(user_data); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); + g_return_val_if_fail (dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING), FALSE); + GtkStyle *style; cairo_t *cr; int x, y, arrow_width, arrow_height; @@ -481,31 +499,28 @@ metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, gint offset = (allocation.height - gdk_pixbuf_get_height (priv->icon_buf)) / 2; // Draw player icon - if (priv->icon_buf != NULL){ + /*if (priv->icon_buf != NULL){ gdk_cairo_set_source_pixbuf (cr, priv->icon_buf, x + arrow_width + 1, y + offset); cairo_paint (cr); - } + }*/ // Draw triangle but only if the player is running. - if (dbusmenu_menuitem_property_get_bool (priv->twin_item, - DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ - y += allocation.height/2.0 - (double)arrow_height/2.0; - cairo_set_line_width (cr, 1.0); + /*y += allocation.height/2.0 - (double)arrow_height/2.0; + cairo_set_line_width (cr, 1.0); - cairo_move_to (cr, x, y); - cairo_line_to (cr, x, y + arrow_height); - cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); - cairo_close_path (cr); - cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, - style->fg[gtk_widget_get_state(widget)].green/65535.0, - style->fg[gtk_widget_get_state(widget)].blue/65535.0); - cairo_fill (cr); - } + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); - cairo_destroy (cr); + cairo_destroy (cr);*/ return FALSE; } #endif @@ -792,7 +807,7 @@ metadata_widget_set_icon (MetadataWidget *self) { MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); - if (priv->icon_buf != NULL){ + /*if (priv->icon_buf != NULL){ #if GTK_CHECK_VERSION(3, 0, 0) g_object_unref(priv->icon_buf); #else @@ -804,13 +819,13 @@ metadata_widget_set_icon (MetadataWidget *self) gint padding = 0; gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); gint width, height; - gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height); + gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);*/ GString* banshee_string = g_string_new ( "banshee" ); gchar * tmp = g_utf8_strdown (dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME), -1); GString* app_panel = g_string_new (tmp); g_free (tmp); - GdkPixbuf* icon_buf; + //GdkPixbuf* icon_buf; // Banshee Special case! // Not ideal but apparently we want the banshee icon to be the greyscale one @@ -827,12 +842,15 @@ metadata_widget_set_icon (MetadataWidget *self) dbusmenu_menuitem_property_get ( priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_ICON )); } - icon_buf = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), + + gtk_image_set_from_icon_name(GTK_IMAGE (priv->player_icon), app_panel->str, GTK_ICON_SIZE_MENU); + + /*icon_buf = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), app_panel->str, (width > height) ? width : height, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL ); - priv->icon_buf = icon_buf; + priv->icon_buf = icon_buf;*/ g_string_free ( app_panel, TRUE); g_string_free ( banshee_string, TRUE); } -- cgit v1.2.3 From f8b37d6a67fdcc00a882129a8aca0382d4ab52e9 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 30 Mar 2012 16:48:32 +0100 Subject: pad the top of the box around metadata --- src/metadata-widget.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 238c5b1..282de7d 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -143,6 +143,12 @@ metadata_widget_init (MetadataWidget *self) priv->meta_data_h_box = hbox; priv->current_height = 1; + GtkWidget* spacer; + spacer = gtk_alignment_new (0,0,1,10); + gtk_widget_show (spacer); + gtk_container_add (GTK_CONTAINER (priv->meta_data_h_box), spacer); + gtk_alignment_set_padding (GTK_ALIGNMENT (spacer),10,10,10,10); + // image priv->album_art = gtk_image_new(); priv->image_path = g_string_new(""); @@ -247,7 +253,7 @@ metadata_widget_init (MetadataWidget *self) gtk_box_pack_start (GTK_BOX (tophbox), priv->player_label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX(outer_v_box), tophbox, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (self), outer_v_box); -- cgit v1.2.3 From e8170f5e6bbff3d06b93e16c9b7101b1d72096a5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 30 Mar 2012 18:02:34 +0100 Subject: draw the triangle using the image and not the pixbuf from before --- src/metadata-widget.c | 121 +++++++++++++++----------------------------------- 1 file changed, 36 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 282de7d..70505c5 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -143,12 +143,6 @@ metadata_widget_init (MetadataWidget *self) priv->meta_data_h_box = hbox; priv->current_height = 1; - GtkWidget* spacer; - spacer = gtk_alignment_new (0,0,1,10); - gtk_widget_show (spacer); - gtk_container_add (GTK_CONTAINER (priv->meta_data_h_box), spacer); - gtk_alignment_set_padding (GTK_ALIGNMENT (spacer),10,10,10,10); - // image priv->album_art = gtk_image_new(); priv->image_path = g_string_new(""); @@ -244,6 +238,10 @@ metadata_widget_init (MetadataWidget *self) gtk_misc_set_alignment (GTK_MISC(priv->player_icon), 1.0 /* right aligned */, 0.5); gtk_box_pack_start (GTK_BOX (tophbox), priv->player_icon, FALSE, FALSE, 0); + GtkWidget* spacer; + spacer = gtk_alignment_new (0,0,0,0); + gtk_container_add (GTK_CONTAINER (spacer), priv->meta_data_h_box); + gtk_alignment_set_padding (GTK_ALIGNMENT (spacer),5,0,0,0); // player label GtkWidget* player_label; @@ -253,7 +251,7 @@ metadata_widget_init (MetadataWidget *self) gtk_box_pack_start (GTK_BOX (tophbox), priv->player_label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX(outer_v_box), tophbox, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(outer_v_box), spacer, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (self), outer_v_box); @@ -266,16 +264,6 @@ metadata_widget_init (MetadataWidget *self) static void metadata_widget_dispose (GObject *object) { - //MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); - - /*if (priv->icon_buf != NULL){ - #if GTK_CHECK_VERSION(3, 0, 0) - g_object_unref(priv->icon_buf); - #else - gdk_pixbuf_unref(priv->icon_buf); - #endif - priv->icon_buf = NULL; - }*/ G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); } @@ -369,13 +357,19 @@ metadata_image_expose_gtk_3 (GtkWidget *metadata, // Draw the triangle if the player is running ... static gboolean metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget, - cairo_t* cr, - gpointer user_data) + cairo_t* cr, + gpointer user_data) { - /*g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); - MetadataWidget* meta = METADATA_WIDGET(user_data); + g_return_val_if_fail (IS_METADATA_WIDGET (user_data), FALSE); + MetadataWidget* meta = METADATA_WIDGET (user_data); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); + gboolean running = dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING); + + if (!running) + return FALSE; + GtkStyle *style; int x, y, arrow_width, arrow_height; @@ -389,32 +383,18 @@ metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget, x = allocation.x; y = 0; - gint offset = gdk_pixbuf_get_height (priv->icon_buf) / 3; - - // Draw player icon - /*if (priv->icon_buf != NULL){ - gdk_cairo_set_source_pixbuf (cr, - priv->icon_buf, - x + arrow_width + 1, - y + offset); - cairo_paint (cr); - }*/ - // Draw triangle but only if the player is running. - /*if (dbusmenu_menuitem_property_get_bool (priv->twin_item, - DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ - y += gdk_pixbuf_get_height (priv->icon_buf) / 3 + 3; - cairo_set_line_width (cr, 1.0); - - cairo_move_to (cr, x, y); - cairo_line_to (cr, x, y + arrow_height); - cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); - cairo_close_path (cr); - cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, - style->fg[gtk_widget_get_state(widget)].green/65535.0, - style->fg[gtk_widget_get_state(widget)].blue/65535.0); - cairo_fill (cr); - }*/ + y += gtk_image_get_pixel_size (GTK_IMAGE (priv->player_icon)) / 3 + 5; + cairo_set_line_width (cr, 1.0); + + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); return FALSE; } @@ -478,13 +458,16 @@ metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { - /*g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); MetadataWidget* meta = METADATA_WIDGET(user_data); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); - g_return_val_if_fail (dbusmenu_menuitem_property_get_bool (priv->twin_item, - DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING), FALSE); + gboolean running = dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING); + + if (!running) + return FALSE; GtkStyle *style; cairo_t *cr; @@ -502,19 +485,8 @@ metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, x = allocation.x; y = allocation.y; - gint offset = (allocation.height - gdk_pixbuf_get_height (priv->icon_buf)) / 2; - - // Draw player icon - /*if (priv->icon_buf != NULL){ - gdk_cairo_set_source_pixbuf (cr, - priv->icon_buf, - x + arrow_width + 1, - y + offset); - cairo_paint (cr); - }*/ - // Draw triangle but only if the player is running. - /*y += allocation.height/2.0 - (double)arrow_height/2.0; + y += allocation.height/2.0 - (double)arrow_height/2.0; cairo_set_line_width (cr, 1.0); cairo_move_to (cr, x, y); @@ -526,7 +498,7 @@ metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, style->fg[gtk_widget_get_state(widget)].blue/65535.0); cairo_fill (cr); - cairo_destroy (cr);*/ + cairo_destroy (cr); return FALSE; } #endif @@ -811,27 +783,12 @@ metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style) static void metadata_widget_set_icon (MetadataWidget *self) { - MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); - - /*if (priv->icon_buf != NULL){ - #if GTK_CHECK_VERSION(3, 0, 0) - g_object_unref(priv->icon_buf); - #else - gdk_pixbuf_unref(priv->icon_buf); - #endif - priv->icon_buf = NULL; - } - - gint padding = 0; - gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); - gint width, height; - gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);*/ - + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + GString* banshee_string = g_string_new ( "banshee" ); gchar * tmp = g_utf8_strdown (dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME), -1); GString* app_panel = g_string_new (tmp); g_free (tmp); - //GdkPixbuf* icon_buf; // Banshee Special case! // Not ideal but apparently we want the banshee icon to be the greyscale one @@ -851,12 +808,6 @@ metadata_widget_set_icon (MetadataWidget *self) gtk_image_set_from_icon_name(GTK_IMAGE (priv->player_icon), app_panel->str, GTK_ICON_SIZE_MENU); - /*icon_buf = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), - app_panel->str, - (width > height) ? width : height, - GTK_ICON_LOOKUP_GENERIC_FALLBACK, - NULL ); - priv->icon_buf = icon_buf;*/ g_string_free ( app_panel, TRUE); g_string_free ( banshee_string, TRUE); } -- cgit v1.2.3 From e6f217fb7e308bf8d0e3605f39a619b0eede2e56 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 30 Mar 2012 18:16:34 +0100 Subject: tidy up --- src/Makefile.am | 2 +- src/metadata-widget.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index debaa2f..5a36822 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,7 +31,7 @@ libsoundmenu_la_SOURCES = \ libsoundmenu_la_CFLAGS = \ $(APPLET_CFLAGS) \ $(COVERAGE_CFLAGS) \ - -Wall -DG_LOG_DOMAIN=\"Indicator-Sound\" + -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\" libsoundmenu_la_LIBADD = $(APPLET_LIBS) -lm libsoundmenu_la_LDFLAGS = \ $(COVERAGE_LDFLAGS) \ diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 70505c5..4d7763f 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -126,7 +126,6 @@ metadata_widget_init (MetadataWidget *self) MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); GtkWidget *hbox; GtkWidget *outer_v_box; - //priv->icon_buf = NULL; #if GTK_CHECK_VERSION(3, 0, 0) outer_v_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); -- cgit v1.2.3 From 1ea2919f7b445d54dbffc7fd0b2638a5a12e228c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 12 Apr 2012 13:46:10 -0700 Subject: ensure to set the name of the gtk range for atk --- src/volume-widget.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/volume-widget.c b/src/volume-widget.c index ac603c1..595e602 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -143,6 +143,13 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, /* g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update); */ + AtkObject* atk_object; + atk_object = gtk_widget_get_accessible(GTK_WIDGET(range)); + if (atk_object != NULL){ + gchar* desc = g_strdup_printf(_("Volume (%'.0f%%)"), + volume_widget_get_current_volume (GTK_WIDGET (userdata))); + atk_object_set_name (atk_object, desc); + } update_accessible_desc(priv->indicator); } } -- cgit v1.2.3 From 9740d6e7079ac8118d3a75d90b42ac40054449f3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 12 Apr 2012 13:56:27 -0700 Subject: use instances available and don't cast --- src/volume-widget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/volume-widget.c b/src/volume-widget.c index 595e602..246963b 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -144,10 +144,10 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update); */ AtkObject* atk_object; - atk_object = gtk_widget_get_accessible(GTK_WIDGET(range)); + atk_object = gtk_widget_get_accessible (slider); if (atk_object != NULL){ gchar* desc = g_strdup_printf(_("Volume (%'.0f%%)"), - volume_widget_get_current_volume (GTK_WIDGET (userdata))); + update); atk_object_set_name (atk_object, desc); } update_accessible_desc(priv->indicator); -- cgit v1.2.3 From a41f4d3cacb59fbef9544a736fc43f0340ff4a33 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 23 Apr 2012 11:31:29 -0700 Subject: set the desc prop on the menuitem, disregard the atk approach from the widget --- src/volume-widget.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/volume-widget.c b/src/volume-widget.c index 246963b..d9f8cd4 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -142,14 +142,19 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, gtk_range_set_value(range, update); /* g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update); -*/ AtkObject* atk_object; - atk_object = gtk_widget_get_accessible (slider); + atk_object = gtk_widget_get_accessible (priv->ido_volume_slider); if (atk_object != NULL){ - gchar* desc = g_strdup_printf(_("Volume (%'.0f%%)"), - update); atk_object_set_name (atk_object, desc); - } + + }*/ + + gchar* desc = g_strdup_printf(_("Volume (%'.0f%%)"), + update); + dbusmenu_menuitem_property_set (priv->twin_item, + DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC, + desc); + g_free (desc); update_accessible_desc(priv->indicator); } } -- cgit v1.2.3 From 2c3d9c4cbfb106b34716eda98e3beb2878756ae4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 23 Apr 2012 12:23:37 -0700 Subject: make sure on start up it's set --- src/volume-widget.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/volume-widget.c b/src/volume-widget.c index d9f8cd4..02d0330 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -208,6 +208,13 @@ volume_widget_set_twin_item(VolumeWidget* self, initial_level = 0; } gtk_range_set_value(range, initial_level); + gchar* desc = g_strdup_printf(_("Volume (%'.0f%%)"), + initial_level); + dbusmenu_menuitem_property_set (priv->twin_item, + DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC, + desc); + g_free (desc); + } static gboolean -- cgit v1.2.3 From 6e076f02999d0010a355fb57f60d4e9b5e799460 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 23 Apr 2012 12:38:58 -0700 Subject: make sure on key press it updates atk --- src/volume-widget.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/volume-widget.c b/src/volume-widget.c index 02d0330..1258c20 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -135,10 +135,11 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_LEVEL, property) == 0){ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) ); + gdouble update = g_variant_get_double (value); + if(priv->grabbed == FALSE){ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); GtkRange *range = (GtkRange*)slider; - gdouble update = g_variant_get_double (value); gtk_range_set_value(range, update); /* g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update); @@ -148,15 +149,14 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, atk_object_set_name (atk_object, desc); }*/ - - gchar* desc = g_strdup_printf(_("Volume (%'.0f%%)"), - update); - dbusmenu_menuitem_property_set (priv->twin_item, - DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC, - desc); - g_free (desc); - update_accessible_desc(priv->indicator); } + gchar* desc = g_strdup_printf(_("Volume (%'.0f%%)"), + update); + dbusmenu_menuitem_property_set (priv->twin_item, + DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC, + desc); + g_free (desc); + update_accessible_desc(priv->indicator); } else if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)); @@ -214,7 +214,7 @@ volume_widget_set_twin_item(VolumeWidget* self, DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC, desc); g_free (desc); - + } static gboolean -- cgit v1.2.3 From c172666fbbd2bbb021e34bc625973ec4fe49178c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 3 May 2012 12:17:27 -0700 Subject: make sure to handle amaroks desktop file name --- src/music-player-bridge.vala | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 18f1c40..bd69668 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -163,7 +163,6 @@ public class MusicPlayerBridge : GLib.Object } var mpris_key = determine_key ( desktop ); - // Are we sure clients will appear like this with the new registration method in place. if ( this.registered_clients.has_key (mpris_key) == false ){ debug("New client has registered that we have not seen before: %s", dbus_name ); PlayerController ctrl = new PlayerController ( this.root_menu, @@ -189,14 +188,14 @@ public class MusicPlayerBridge : GLib.Object public void client_has_vanished ( string mpris_root_interface ) { - debug("MusicPlayerBridge -> client with dbus interface %s has vanished", + debug("\n MusicPlayerBridge -> client with dbus interface %s has vanished", mpris_root_interface ); if (root_menu != null){ - debug("attempt to remove %s", mpris_root_interface); + debug("\n attempt to remove %s", mpris_root_interface); var mpris_key = determine_key ( mpris_root_interface ); if ( mpris_key != null && this.registered_clients.has_key(mpris_key)){ registered_clients[mpris_key].hibernate(); - debug("Successively offlined client %s", mpris_key); + debug("\n Successively offlined client %s", mpris_key); } } } @@ -286,8 +285,8 @@ public class MusicPlayerBridge : GLib.Object } var temp = result.split("-"); if (temp != null && temp.length > 1){ - result = temp[0]; - } + result = temp[1]; + } return result; } -- cgit v1.2.3 From 5f9a9b8b0ba50dcb5f47233df9e7123ed37501ad Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 3 May 2012 15:05:51 -0700 Subject: be explicit in handling ardour --- src/music-player-bridge.vala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index bd69668..5b9afea 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -278,14 +278,20 @@ public class MusicPlayerBridge : GLib.Object */ private static string? determine_key(owned string desktop_or_interface) { + // handle the special case of amarok, (kde4-amarok desktop file name) + if (desktop_or_interface.contains("amarok")){ + return "amarok"; + } + var result = desktop_or_interface; + var tokens = desktop_or_interface.split( "." ); if (tokens != null && tokens.length > 1){ result = tokens[tokens.length - 1]; - } + } var temp = result.split("-"); if (temp != null && temp.length > 1){ - result = temp[1]; + result = temp[0]; } return result; } -- cgit v1.2.3 From dcde0e28f8cd4d674ba744fad1779f6e9f91eb6e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 21 Jun 2012 17:45:16 +0100 Subject: manually merge of lp:~victored/indicator-sound/lp-1014955 --- src/music-player-bridge.vala | 30 +++++++++++++++++++++++++++--- src/player-controller.vala | 23 +++++++++++++++++------ src/settings-manager.vala | 26 ++++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 5b9afea..606b129 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -40,6 +40,7 @@ public class MusicPlayerBridge : GLib.Object this.file_monitors = new HashMap (); this.settings_manager = new SettingsManager(); this.settings_manager.blacklist_updates.connect ( this.on_blacklist_update ); + this.settings_manager.preferred_updates.connect ( this.on_preferred_update ); } private void on_blacklist_update ( string[] blacklist ) @@ -58,8 +59,26 @@ public class MusicPlayerBridge : GLib.Object this.watcher.check_for_active_clients.begin(); } + private void on_preferred_update ( Gee.ArrayList preferred ) + { + debug ("Preferred players update. Clearing current preferred players..."); + + foreach (var player_controller in this.registered_clients.values) { + player_controller.set_as_preferred (false); + } + + foreach (var s in preferred) { + string key = this.determine_key (s); + if (this.registered_clients.has_key (key)) { + debug ("Setting %s as preferred player", key); + this.registered_clients[key].set_as_preferred (true); + } + } + } + private void try_to_add_inactive_familiar_clients() { + var preferred_players = this.settings_manager.fetch_preferred (); foreach ( string desktop in this.settings_manager.fetch_interested()){ debug ( "interested client found : %s", desktop ); AppInfo? app_info = create_app_info ( desktop.concat( ".desktop" ) ); @@ -68,14 +87,16 @@ public class MusicPlayerBridge : GLib.Object desktop ); continue; } - var mpris_key = determine_key ( desktop ); + bool is_preferred = desktop in preferred_players; PlayerController ctrl = new PlayerController ( this.root_menu, app_info, null, this.fetch_icon_name(desktop), calculate_menu_position(), null, - PlayerController.state.OFFLINE ); + PlayerController.state.OFFLINE, + is_preferred ); + var mpris_key = determine_key ( desktop ); this.registered_clients.set(mpris_key, ctrl); this.establish_file_monitoring (app_info, mpris_key); } @@ -163,6 +184,8 @@ public class MusicPlayerBridge : GLib.Object } var mpris_key = determine_key ( desktop ); + bool is_preferred = desktop in this.settings_manager.fetch_preferred (); + if ( this.registered_clients.has_key (mpris_key) == false ){ debug("New client has registered that we have not seen before: %s", dbus_name ); PlayerController ctrl = new PlayerController ( this.root_menu, @@ -171,7 +194,8 @@ public class MusicPlayerBridge : GLib.Object this.fetch_icon_name(desktop), this.calculate_menu_position(), use_playlists, - PlayerController.state.READY ); + PlayerController.state.READY, + is_preferred); this.registered_clients.set ( mpris_key, ctrl ); debug ( "Have not seen this %s before, new controller created.", desktop ); this.settings_manager.add_interested ( desktop ); diff --git a/src/player-controller.vala b/src/player-controller.vala index 80a48c3..fd66a8a 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -40,7 +40,7 @@ public class PlayerController : GLib.Object } public int current_state = state.OFFLINE; - + public Dbusmenu.Menuitem root_menu; public string dbus_name { get; set;} public ArrayList custom_items; @@ -49,6 +49,7 @@ public class PlayerController : GLib.Object public int menu_offset { get; set;} public string icon_name { get; set; } public bool? use_playlists; + public bool is_preferred { get; private set; } private SpecificItemsManager track_specific_mgr; private SpecificItemsManager player_specific_mgr; @@ -58,7 +59,8 @@ public class PlayerController : GLib.Object string icon_name, int offset, bool? use_playlists, - state initial_state) + state initial_state, + bool is_preferred) { this.use_playlists = use_playlists; this.root_menu = root; @@ -68,6 +70,8 @@ public class PlayerController : GLib.Object this.custom_items = new ArrayList(); this.current_state = initial_state; this.menu_offset = offset; + this.is_preferred = is_preferred; + this.construct_widgets(); this.establish_mpris_connection(); this.update_layout(); @@ -156,6 +160,11 @@ public class PlayerController : GLib.Object } } + public void set_as_preferred (bool val) { + this.is_preferred = val; + this.update_layout(); + } + public void hibernate() { update_state(PlayerController.state.OFFLINE); @@ -175,12 +184,14 @@ public class PlayerController : GLib.Object metadata_menuitem.should_collapse (true); playlists_menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, false); - this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE, - this.app_info.get_id() == "rhythmbox.desktop"); + this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE, is_preferred); return; } - metadata_menuitem.should_collapse (!this.custom_items[widget_order.METADATA].populated (MetadataMenuitem.relevant_attributes_for_ui()) ); - if (this.app_info.get_id() == "rhythmbox.desktop"){ + + bool should_collapse = !this.custom_items[widget_order.METADATA].populated (MetadataMenuitem.relevant_attributes_for_ui()); + metadata_menuitem.should_collapse (should_collapse); + + if (is_preferred){ TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem; transport.handle_cached_action(); } diff --git a/src/settings-manager.vala b/src/settings-manager.vala index d57241e..458ac21 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -22,12 +22,14 @@ public class SettingsManager : GLib.Object { private Settings settings; public signal void blacklist_updates ( string[] new_blacklist ); + public signal void preferred_updates (Gee.ArrayList new_preferred); public SettingsManager ( ){ } construct{ this.settings = new Settings ("com.canonical.indicator.sound"); - this.settings.changed["blacklisted-media-players"].connect (on_blacklist_event); + this.settings.changed["blacklisted-media-players"].connect (on_blacklist_event); + this.settings.changed["preferred-media-players"].connect (on_preferred_event); } public string[] fetch_blacklist() @@ -35,9 +37,24 @@ public class SettingsManager : GLib.Object return this.settings.get_strv ("blacklisted-media-players"); } + public ArrayList fetch_preferred() + { + var list = new ArrayList(); + + var preferred = this.settings.get_strv ("preferred-media-players"); + var interested = fetch_interested (); + + foreach (var s in preferred) { + if (!(s in list) && interested.contains (s)) + list.add (s); + } + + return list; + } + public ArrayList fetch_interested() { - var blacklisted = this.settings.get_strv ("blacklisted-media-players"); + var blacklisted = fetch_blacklist (); var interested = this.settings.get_strv ("interested-media-players"); var list = new ArrayList(); foreach(var s in interested){ @@ -91,6 +108,11 @@ public class SettingsManager : GLib.Object this.blacklist_updates(this.settings.get_strv ("blacklisted-media-players")); } + private void on_preferred_event() + { + this.preferred_updates (this.fetch_preferred()); + } + // Convenient debug method inorder to provide visability over // the contents of both interested and blacklisted containers in its gsettings /** -- cgit v1.2.3 From f71a90bfb6946646960cea78ccd20fd99826de63 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 11 Jul 2012 14:00:28 -0500 Subject: remove deprecated call to gtk_style_context_notify_state_change() ... according to the GTK documentation, it's been deprecated since GTK 3.6 and does nothing. --- src/transport-widget.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index 09bb302..0931e1d 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -1849,11 +1849,6 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, //g_debug("transport_widget_update_state - with value %i", new_state); if (new_state == TRANSPORT_STATE_LAUNCHING){ #if GTK_CHECK_VERSION(3, 0, 0) - gtk_style_context_notify_state_change (spinner_style_context, - gtk_widget_get_window ( GTK_WIDGET(userdata)), - NULL, - GTK_STATE_FLAG_ACTIVE, - TRUE); gtk_style_context_set_state (spinner_style_context, GTK_STATE_FLAG_ACTIVE); #endif -- cgit v1.2.3