diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/device.c | 17 | ||||
-rw-r--r-- | src/indicator-sound.c | 15 | ||||
-rw-r--r-- | src/metadata-widget.c | 20 | ||||
-rw-r--r-- | src/mpris2-controller.vala | 13 | ||||
-rw-r--r-- | src/player-controller.vala | 4 | ||||
-rw-r--r-- | src/settings-manager.vala | 3 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 26 | ||||
-rw-r--r-- | src/sound-state-manager.c | 14 | ||||
-rw-r--r-- | src/sound-state.c | 43 | ||||
-rw-r--r-- | src/sound-state.h | 31 |
11 files changed, 140 insertions, 50 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ae0d55a..bafd6be 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,6 +10,8 @@ libsoundmenu_la_SOURCES = \ common-defs.h \ indicator-sound.h \ indicator-sound.c \ + sound-state.c \ + sound-state.h \ sound-state-manager.c \ sound-state-manager.h \ transport-widget.c \ @@ -90,6 +92,8 @@ indicator_sound_service_SOURCES = \ common-defs.h \ sound-service.h \ sound-service.c \ + sound-state.c \ + sound-state.h \ pulseaudio-mgr.h \ pulseaudio-mgr.c \ device.c \ diff --git a/src/device.c b/src/device.c index bf4a543..84db596 100644 --- a/src/device.c +++ b/src/device.c @@ -23,6 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "mute-menu-item.h" #include "voip-input-menu-item.h" #include "pulseaudio-mgr.h" +#include "sound-state.h" typedef struct _DevicePrivate DevicePrivate; @@ -164,21 +165,7 @@ device_get_state_from_volume (Device* self) DBUSMENU_VOLUME_MENUITEM_LEVEL); gdouble volume_percent = g_variant_get_double (v); - SoundState state = LOW_LEVEL; - - if (volume_percent < 30.0 && volume_percent > 0) { - state = LOW_LEVEL; - } - else if (volume_percent < 70.0 && volume_percent >= 30.0) { - state = MEDIUM_LEVEL; - } - else if (volume_percent >= 70.0) { - state = HIGH_LEVEL; - } - else if (volume_percent == 0.0) { - state = ZERO_LEVEL; - } - return state; + return sound_state_get_from_volume ((int)volume_percent); } void diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 042bf89..5002463 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -137,6 +137,7 @@ indicator_sound_init (IndicatorSound *self) IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); priv->volume_widget = NULL; + priv->voip_widget = NULL; priv->dbus_proxy = NULL; GList* t_list = NULL; priv->transport_widgets_list = t_list; @@ -407,8 +408,14 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); io = g_object_get_data (G_OBJECT (client), "indicator"); - volume_widget = volume_widget_new (newitem, io); IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); + + if (priv->volume_widget != NULL){ + volume_widget_tidy_up (priv->volume_widget); + gtk_widget_destroy (priv->volume_widget); + priv->volume_widget = NULL; + } + volume_widget = volume_widget_new (newitem, io); priv->volume_widget = volume_widget; GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); @@ -452,6 +459,12 @@ new_voip_slider_widget (DbusmenuMenuitem * newitem, io = g_object_get_data (G_OBJECT (client), "indicator"); IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); + if (priv->voip_widget != NULL){ + voip_input_widget_tidy_up (priv->voip_widget); + gtk_widget_destroy (priv->voip_widget); + priv->voip_widget = NULL; + } + voip_widget = voip_input_widget_new (newitem); priv->voip_widget = voip_widget; diff --git a/src/metadata-widget.c b/src/metadata-widget.c index a37053b..38ed529 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -106,8 +106,7 @@ metadata_widget_init (MetadataWidget *self) g_signal_connect(priv->album_art, "expose-event", G_CALLBACK(metadata_image_expose), - GTK_WIDGET(self)); - gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); + GTK_WIDGET(self)); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, @@ -190,26 +189,29 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || priv->theme_change_occured == TRUE){ priv->theme_change_occured = FALSE; - GdkPixbuf* orig_pixbuf; - orig_pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL); + GdkPixbuf* pixbuf; + pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL); //g_debug("metadata_load_new_image -> pixbuf from %s", // priv->image_path->str); - if(GDK_IS_PIXBUF(orig_pixbuf) == FALSE){ + if(GDK_IS_PIXBUF(pixbuf) == FALSE){ //g_debug("problem loading the downloaded image just use the placeholder instead"); + gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); return TRUE; } - GdkPixbuf* pixbuf; - pixbuf = gdk_pixbuf_scale_simple(orig_pixbuf,60, 60, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf); + gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), + gdk_pixbuf_get_width(pixbuf), + gdk_pixbuf_get_height(pixbuf)); + 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); - g_object_unref(orig_pixbuf); + g_object_unref(pixbuf); } return FALSE; } + gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); return TRUE; } diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 94c52c0..04ceb88 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -45,19 +45,19 @@ public class Mpris2Controller : GLib.Object this.player = Bus.get_proxy_sync ( BusType.SESSION, this.owner.dbus_name, "/org/mpris/MediaPlayer2" ); + this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION, + "org.freedesktop.Properties.PropertiesChanged", + "/org/mpris/MediaPlayer2" ); + this.properties_interface.PropertiesChanged.connect ( property_changed_cb ); if ( this.owner.use_playlists == true ){ this.playlists = Bus.get_proxy_sync ( BusType.SESSION, this.owner.dbus_name, "/org/mpris/MediaPlayer2" ); this.playlists.PlaylistChanged.connect (on_playlistdetails_changed); } - this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION, - "org.freedesktop.Properties.PropertiesChanged", - "/org/mpris/MediaPlayer2" ); - this.properties_interface.PropertiesChanged.connect ( property_changed_cb ); } catch (IOError e) { - error("Problems connecting to the session bus - %s", e.message); + critical("Problems connecting to the session bus - %s", e.message); } } @@ -68,7 +68,7 @@ public class Mpris2Controller : GLib.Object //debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name); if ( changed_properties == null || interface_source.has_prefix ( MPRIS_PREFIX ) == false ){ - warning("Property-changed hash is null or this is an interface that doesn't concerns us"); + warning("Property-changed hash is null or this is an interface that doesn't concern us"); return; } Variant? play_v = changed_properties.lookup("PlaybackStatus"); @@ -124,6 +124,7 @@ public class Mpris2Controller : GLib.Object private GLib.HashTable<string, Variant?>? clean_metadata() { GLib.HashTable<string, Variant?> changed_updates = this.player.Metadata; + Variant? artist_v = this.player.Metadata.lookup("xesam:artist"); if(artist_v != null){ Variant? v_artists = this.player.Metadata.lookup("xesam:artist"); diff --git a/src/player-controller.vala b/src/player-controller.vala index 86dfe9b..20479d9 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -150,12 +150,12 @@ public class PlayerController : GLib.Object 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() == "banshee-1.desktop"); + this.app_info.get_id() == "banshee.desktop"); return; } this.custom_items[widget_order.METADATA].property_set_bool (MENUITEM_PROP_VISIBLE, this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); - if (this.app_info.get_id() == "banshee-1.desktop"){ + if (this.app_info.get_id() == "banshee.desktop"){ 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 7acc3b1..1b99cbc 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -41,6 +41,9 @@ public class SettingsManager : GLib.Object var interested = this.settings.get_strv ("interested-media-players"); var list = new ArrayList<string>(); foreach(var s in interested){ + if (s == "banshee-1"){ + s = "banshee"; + } if (s in list) continue; if (s in blacklisted) continue; list.add(s); diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 1b9d29e..d0fd765 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -164,13 +164,10 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, { SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); - // Mute button - // TODO this additions should be fixed position, i.e. add via position and not just append - // be explicit as it is fixed. - dbusmenu_menuitem_child_append (priv->root_menuitem, mute_item); - dbusmenu_menuitem_child_append (priv->root_menuitem, slider_item); - g_debug ("just about to add the slider %i", DBUSMENU_IS_MENUITEM(slider_item)); - dbusmenu_menuitem_child_append (priv->root_menuitem, voip_input_menu_item); + // Mute, Volume and Voip widgets + dbusmenu_menuitem_child_add_position (priv->root_menuitem, mute_item, 0); + dbusmenu_menuitem_child_add_position (priv->root_menuitem, slider_item, 1); + dbusmenu_menuitem_child_add_position (priv->root_menuitem, voip_input_menu_item, 2); // Separator DbusmenuMenuitem* separator = dbusmenu_menuitem_new(); @@ -178,7 +175,7 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, dbusmenu_menuitem_property_set (separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(priv->root_menuitem, separator); + dbusmenu_menuitem_child_add_position (priv->root_menuitem, separator, 3); g_object_unref (separator); // Sound preferences dialog @@ -203,7 +200,8 @@ show_sound_settings_dialog (DbusmenuMenuitem *mi, { GError * error = NULL; if (!g_spawn_command_line_async("gnome-volume-control --page=applications", &error) && - !g_spawn_command_line_async("xfce4-mixer", &error)) + !g_spawn_command_line_async("gnome-control-center sound", &error) && + !g_spawn_command_line_async("xfce4-mixer", &error)) { g_warning("Unable to show dialog: %s", error->message); g_error_free(error); @@ -237,6 +235,13 @@ sound_service_dbus_update_sound_state (SoundServiceDbus* self, GError * error = NULL; + if (priv->connection == NULL || + g_dbus_connection_is_closed (priv->connection) == TRUE){ + g_critical ("sound_service_dbus_update_sound_state - connection is %s !!", + priv->connection == NULL? "NULL" : "closed"); + return; + } + g_debug ("emitting state signal with value %i", (int)new_state); g_dbus_connection_emit_signal( priv->connection, NULL, @@ -246,9 +251,8 @@ sound_service_dbus_update_sound_state (SoundServiceDbus* self, v_output, &error ); if (error != NULL) { - g_error("Unable to emit signal 'sinkinputwhilemuted' because : %s", error->message); + g_critical ("Unable to emit signal because : %s", error->message); g_error_free(error); - return; } } diff --git a/src/sound-state-manager.c b/src/sound-state-manager.c index 7095a39..c851407 100644 --- a/src/sound-state-manager.c +++ b/src/sound-state-manager.c @@ -24,6 +24,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "sound-state-manager.h" #include "dbus-shared-names.h" +#include "sound-state.h" typedef struct _SoundStateManagerPrivate SoundStateManagerPrivate; @@ -170,19 +171,20 @@ sound_state_manager_show_notification (SoundStateManager *self, char *icon; const int notify_value = CLAMP((int)value, -1, 101); - SoundState state = sound_state_manager_get_current_state (self); + + SoundState state = sound_state_get_from_volume ((int)value); if (state == ZERO_LEVEL) { // Not available for all the themes - icon = "audio-volume-off"; + icon = "notification-audio-volume-off"; } else if (state == LOW_LEVEL) { - icon = "audio-volume-low"; + icon = "notification-audio-volume-low"; } else if (state == MEDIUM_LEVEL) { - icon = "audio-volume-medium"; + icon = "notification-audio-volume-medium"; } else if (state == HIGH_LEVEL) { - icon = "audio-volume-high"; + icon = "notification-audio-volume-high"; } else { - icon = "audio-volume-muted"; + icon = "notification-audio-volume-muted"; } notify_notification_update(priv->notification, PACKAGE_NAME, NULL, icon); diff --git a/src/sound-state.c b/src/sound-state.c new file mode 100644 index 0000000..72e411a --- /dev/null +++ b/src/sound-state.c @@ -0,0 +1,43 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +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 <http://www.gnu.org/licenses/>. +*/ + +#include "config.h" + +#include "sound-state.h" + +SoundState +sound_state_get_from_volume (int volume_percent) +{ + SoundState state = LOW_LEVEL; + + if (volume_percent < 30 && volume_percent > 0) { + state = LOW_LEVEL; + } + else if (volume_percent < 70 && volume_percent >= 30) { + state = MEDIUM_LEVEL; + } + else if (volume_percent >= 70) { + state = HIGH_LEVEL; + } + else if (volume_percent <= 0) { + state = ZERO_LEVEL; + } + return state; +} + diff --git a/src/sound-state.h b/src/sound-state.h new file mode 100644 index 0000000..9527c8e --- /dev/null +++ b/src/sound-state.h @@ -0,0 +1,31 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +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 <http://www.gnu.org/licenses/>. +*/ + +#ifndef _SOUND_STATE_H_ +#define _SOUND_STATE_H_ + +#include <glib.h> +#include "common-defs.h" + +/* Helper functions for determining SOUNDSTATE */ + +SoundState sound_state_get_from_volume (int volume_percent); + +#endif /* _SOUND_STATE_H_ */ + |