diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-03-17 14:08:16 -0400 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2011-03-17 14:08:16 -0400 |
commit | 7619eab48daaa739fb3418237c693b7b463182f0 (patch) | |
tree | 0f87b54f1425f9228c950d906eba75173fa19f6a /src | |
parent | a65cff5ec2d7625408d58fe6b23ddb40d7f63ee2 (diff) | |
parent | 6de8affd0a17ab7729ac7647d8e84e58a158601a (diff) | |
download | ayatana-indicator-sound-7619eab48daaa739fb3418237c693b7b463182f0.tar.gz ayatana-indicator-sound-7619eab48daaa739fb3418237c693b7b463182f0.tar.bz2 ayatana-indicator-sound-7619eab48daaa739fb3418237c693b7b463182f0.zip |
Import upstream version 0.6.4
Diffstat (limited to 'src')
33 files changed, 988 insertions, 900 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7525d71..ae0d55a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -56,8 +56,7 @@ music_bridge_VALASOURCES = \ settings-manager.vala \ playlists-menu-item.vala \ freedesktop-interfaces.vala \ - fetch-file.vala - + fetch-file.vala music_bridge_VALAFLAGS = \ --ccode \ @@ -69,10 +68,11 @@ music_bridge_VALAFLAGS = \ --pkg gee-1.0 \ --pkg Dbusmenu-0.4 \ --pkg common-defs \ - --pkg gio-2.0 \ - --pkg gio-unix-2.0 \ - --pkg gdk-pixbuf-2.0 \ - --pkg libxml-2.0 + --pkg config \ + --pkg gio-2.0 \ + --pkg gio-unix-2.0 \ + --pkg gdk-pixbuf-2.0 \ + --pkg libxml-2.0 $(MAINTAINER_VALAFLAGS) @@ -92,8 +92,8 @@ indicator_sound_service_SOURCES = \ sound-service.c \ pulseaudio-mgr.h \ pulseaudio-mgr.c \ - active-sink.c \ - active-sink.h \ + device.c \ + device.h \ sound-service-dbus.h \ sound-service-dbus.c \ slider-menu-item.h \ @@ -137,10 +137,10 @@ EXTRA_DIST = \ ####################### BUILT_SOURCES = \ music_bridge_vala.stamp \ - $(music_bridge_APIFILES) \ + $(music_bridge_APIFILES) \ gen-sound-service.xml.h \ gen-sound-service.xml.c \ - $(music_bridge_VALASOURCES:.vala=.c) + $(music_bridge_VALASOURCES:.vala=.c) CLEANFILES = \ $(BUILT_SOURCES) diff --git a/src/Makefile.in b/src/Makefile.in index df50c00..0cffd55 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -105,7 +105,7 @@ am__objects_1 = indicator_sound_service-music-player-bridge.$(OBJEXT) \ am_indicator_sound_service_OBJECTS = \ indicator_sound_service-sound-service.$(OBJEXT) \ indicator_sound_service-pulseaudio-mgr.$(OBJEXT) \ - indicator_sound_service-active-sink.$(OBJEXT) \ + indicator_sound_service-device.$(OBJEXT) \ indicator_sound_service-sound-service-dbus.$(OBJEXT) \ indicator_sound_service-slider-menu-item.$(OBJEXT) \ indicator_sound_service-voip-input-menu-item.$(OBJEXT) \ @@ -361,7 +361,7 @@ music_bridge_VALASOURCES = \ settings-manager.vala \ playlists-menu-item.vala \ freedesktop-interfaces.vala \ - fetch-file.vala + fetch-file.vala music_bridge_VALAFLAGS = \ --ccode \ @@ -373,10 +373,11 @@ music_bridge_VALAFLAGS = \ --pkg gee-1.0 \ --pkg Dbusmenu-0.4 \ --pkg common-defs \ - --pkg gio-2.0 \ - --pkg gio-unix-2.0 \ - --pkg gdk-pixbuf-2.0 \ - --pkg libxml-2.0 + --pkg config \ + --pkg gio-2.0 \ + --pkg gio-unix-2.0 \ + --pkg gdk-pixbuf-2.0 \ + --pkg libxml-2.0 music_bridge_APIFILES = \ music-player-bridge.h @@ -391,8 +392,8 @@ indicator_sound_service_SOURCES = \ sound-service.c \ pulseaudio-mgr.h \ pulseaudio-mgr.c \ - active-sink.c \ - active-sink.h \ + device.c \ + device.h \ sound-service-dbus.h \ sound-service-dbus.c \ slider-menu-item.h \ @@ -426,10 +427,10 @@ EXTRA_DIST = \ ####################### BUILT_SOURCES = \ music_bridge_vala.stamp \ - $(music_bridge_APIFILES) \ + $(music_bridge_APIFILES) \ gen-sound-service.xml.h \ gen-sound-service.xml.c \ - $(music_bridge_VALASOURCES:.vala=.c) + $(music_bridge_VALASOURCES:.vala=.c) CLEANFILES = \ $(BUILT_SOURCES) @@ -555,7 +556,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-active-sink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-device.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-fetch-file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-freedesktop-interfaces.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-gen-sound-service.xml.Po@am__quote@ @@ -705,21 +706,21 @@ indicator_sound_service-pulseaudio-mgr.obj: pulseaudio-mgr.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-pulseaudio-mgr.obj `if test -f 'pulseaudio-mgr.c'; then $(CYGPATH_W) 'pulseaudio-mgr.c'; else $(CYGPATH_W) '$(srcdir)/pulseaudio-mgr.c'; fi` -indicator_sound_service-active-sink.o: active-sink.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-active-sink.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-active-sink.Tpo -c -o indicator_sound_service-active-sink.o `test -f 'active-sink.c' || echo '$(srcdir)/'`active-sink.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-active-sink.Tpo $(DEPDIR)/indicator_sound_service-active-sink.Po +indicator_sound_service-device.o: device.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-device.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-device.Tpo -c -o indicator_sound_service-device.o `test -f 'device.c' || echo '$(srcdir)/'`device.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-device.Tpo $(DEPDIR)/indicator_sound_service-device.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='active-sink.c' object='indicator_sound_service-active-sink.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='device.c' object='indicator_sound_service-device.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-active-sink.o `test -f 'active-sink.c' || echo '$(srcdir)/'`active-sink.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-device.o `test -f 'device.c' || echo '$(srcdir)/'`device.c -indicator_sound_service-active-sink.obj: active-sink.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-active-sink.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-active-sink.Tpo -c -o indicator_sound_service-active-sink.obj `if test -f 'active-sink.c'; then $(CYGPATH_W) 'active-sink.c'; else $(CYGPATH_W) '$(srcdir)/active-sink.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-active-sink.Tpo $(DEPDIR)/indicator_sound_service-active-sink.Po +indicator_sound_service-device.obj: device.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-device.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-device.Tpo -c -o indicator_sound_service-device.obj `if test -f 'device.c'; then $(CYGPATH_W) 'device.c'; else $(CYGPATH_W) '$(srcdir)/device.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-device.Tpo $(DEPDIR)/indicator_sound_service-device.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='active-sink.c' object='indicator_sound_service-active-sink.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='device.c' object='indicator_sound_service-device.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-active-sink.obj `if test -f 'active-sink.c'; then $(CYGPATH_W) 'active-sink.c'; else $(CYGPATH_W) '$(srcdir)/active-sink.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-device.obj `if test -f 'device.c'; then $(CYGPATH_W) 'device.c'; else $(CYGPATH_W) '$(srcdir)/device.c'; fi` indicator_sound_service-sound-service-dbus.o: sound-service-dbus.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-sound-service-dbus.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-sound-service-dbus.Tpo -c -o indicator_sound_service-sound-service-dbus.o `test -f 'sound-service-dbus.c' || echo '$(srcdir)/'`sound-service-dbus.c diff --git a/src/active-sink.c b/src/active-sink.c deleted file mode 100644 index a78d33e..0000000 --- a/src/active-sink.c +++ /dev/null @@ -1,349 +0,0 @@ -/* -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/>. -*/ -#include <libdbusmenu-glib/menuitem.h> - -#include "active-sink.h" -#include "slider-menu-item.h" -#include "mute-menu-item.h" -#include "voip-input-menu-item.h" -#include "pulseaudio-mgr.h" - -typedef struct _ActiveSinkPrivate ActiveSinkPrivate; - -struct _ActiveSinkPrivate -{ - SliderMenuItem* volume_slider_menuitem; - MuteMenuItem* mute_menuitem; - VoipInputMenuItem* voip_input_menu_item; - SoundState current_sound_state; - SoundServiceDbus* service; - gint index; - gchar* name; - pa_cvolume volume; - pa_channel_map channel_map; - pa_volume_t base_volume; -}; - -#define ACTIVE_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ACTIVE_SINK_TYPE, ActiveSinkPrivate)) - -/* Prototypes */ -static void active_sink_class_init (ActiveSinkClass *klass); -static void active_sink_init (ActiveSink *self); -static void active_sink_dispose (GObject *object); -static void active_sink_finalize (GObject *object); - -static SoundState active_sink_get_state_from_volume (ActiveSink* self); -static pa_cvolume active_sink_construct_mono_volume (const pa_cvolume* vol); -static void active_sink_volume_update (ActiveSink* self, gdouble percent); -static void active_sink_mute_update (ActiveSink* self, gboolean muted); - -G_DEFINE_TYPE (ActiveSink, active_sink, G_TYPE_OBJECT); - -static void -active_sink_class_init (ActiveSinkClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (ActiveSinkPrivate)); - - gobject_class->dispose = active_sink_dispose; - gobject_class->finalize = active_sink_finalize; -} - -static void -active_sink_init (ActiveSink *self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - priv->mute_menuitem = NULL; - priv->volume_slider_menuitem = NULL; - priv->voip_input_menu_item = NULL; - priv->current_sound_state = UNAVAILABLE; - priv->index = -1; - priv->name = NULL; - priv->service = NULL; - - // Init our menu items. - priv->mute_menuitem = g_object_new (MUTE_MENU_ITEM_TYPE, NULL); - priv->voip_input_menu_item = g_object_new (VOIP_INPUT_MENU_ITEM_TYPE, NULL);; - priv->volume_slider_menuitem = slider_menu_item_new (self); - mute_menu_item_enable (priv->mute_menuitem, FALSE); - slider_menu_item_enable (priv->volume_slider_menuitem, FALSE); -} - -static void -active_sink_dispose (GObject *object) -{ - G_OBJECT_CLASS (active_sink_parent_class)->dispose (object); -} - -static void -active_sink_finalize (GObject *object) -{ - G_OBJECT_CLASS (active_sink_parent_class)->finalize (object); -} - -void -active_sink_populate (ActiveSink* sink, - const pa_sink_info* update) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE(sink); - - priv->name = g_strdup (update->name); - priv->index = update->index; - active_sink_mute_update (sink, update->mute); - priv->volume = active_sink_construct_mono_volume (&update->volume); - priv->base_volume = update->base_volume; - priv->channel_map = update->channel_map; - - pa_volume_t vol = pa_cvolume_max (&update->volume); - gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; - - active_sink_volume_update (sink, volume_percent); - active_sink_mute_update (sink, update->mute); - mute_menu_item_enable (priv->mute_menuitem, TRUE); - slider_menu_item_enable (priv->volume_slider_menuitem, TRUE); - - g_debug ("Active sink has been populated - volume %f", volume_percent); -} - -void -active_sink_activate_voip_item (ActiveSink* self, gint sink_input_index, gint client_index) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - if (voip_input_menu_item_is_interested (priv->voip_input_menu_item, - sink_input_index, - client_index)){ - voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE); - } -} - -void -active_sink_deactivate_voip_source (ActiveSink* self, gboolean visible) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item); - voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible); -} - -void -active_sink_deactivate_voip_client (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item); -} - -void -active_sink_update (ActiveSink* sink, - const pa_sink_info* update) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink); - active_sink_mute_update (sink, update->mute); - priv->volume = active_sink_construct_mono_volume (&update->volume); - priv->base_volume = update->base_volume; - priv->channel_map = update->channel_map; - - pa_volume_t vol = pa_cvolume_max (&update->volume); - gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; - - active_sink_volume_update (sink, volume_percent); - active_sink_mute_update (sink, update->mute); -} - -// To the UI -static void -active_sink_volume_update (ActiveSink* self, gdouble percent) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - slider_menu_item_update (priv->volume_slider_menuitem, percent); - SoundState state = active_sink_get_state_from_volume (self); - if (priv->current_sound_state != state){ - priv->current_sound_state = state; - sound_service_dbus_update_sound_state (priv->service, - priv->current_sound_state); - } -} - -// From the UI -void -active_sink_update_volume (ActiveSink* self, gdouble percent) -{ - pa_cvolume new_volume; - pa_cvolume_init(&new_volume); - 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); - - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - - pa_cvolume_set(&priv->volume, priv->channel_map.channels, new_volume_value); - pm_update_volume (priv->index, new_volume); -} - - -gint -active_sink_get_current_sink_input_index (ActiveSink* sink) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink); - return voip_input_menu_item_get_sink_input_index (priv->voip_input_menu_item); -} - -static void -active_sink_mute_update (ActiveSink* self, gboolean muted) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - mute_menu_item_update (priv->mute_menuitem, muted); - SoundState state = active_sink_get_state_from_volume (self); - - if (muted == TRUE){ - state = MUTED; - } - if (priv->current_sound_state != state){ - priv->current_sound_state = state; - sound_service_dbus_update_sound_state (priv->service, state); - } -} - -void -active_sink_ensure_sink_is_unmuted (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - if (mute_menu_item_is_muted (priv->mute_menuitem)){ - pm_update_mute (FALSE); - } -} - - -static SoundState -active_sink_get_state_from_volume (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - GVariant* v = dbusmenu_menuitem_property_get_variant (DBUSMENU_MENUITEM(priv->volume_slider_menuitem), - 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; -} - -pa_cvolume -active_sink_construct_mono_volume (const pa_cvolume* vol) -{ - pa_cvolume new_volume; - pa_cvolume_init(&new_volume); - new_volume.channels = 1; - pa_volume_t max_vol = pa_cvolume_max(vol); - pa_cvolume_set(&new_volume, 1, max_vol); - return new_volume; -} - -void -active_sink_determine_blocking_state (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - if (mute_menu_item_is_muted (priv->mute_menuitem)){ - /** - We don't want to set the current state to blocking - as this is a fire and forget event. - */ - sound_service_dbus_update_sound_state (priv->service, - BLOCKED); - } -} - -gint -active_sink_get_index (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - return priv->index; -} - -gboolean -active_sink_is_populated (ActiveSink* sink) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink); - return (priv->index != -1); -} - -void -active_sink_deactivate (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - priv->current_sound_state = UNAVAILABLE; - sound_service_dbus_update_sound_state (priv->service, - priv->current_sound_state); - mute_menu_item_enable (priv->mute_menuitem, FALSE); - slider_menu_item_enable (priv->volume_slider_menuitem, FALSE); - priv->index = -1; - g_free(priv->name); - priv->name = NULL; -} - -SoundState -active_sink_get_state (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - return priv->current_sound_state; -} - -void -active_sink_update_voip_input_source (ActiveSink* self, const pa_source_info* update) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - voip_input_menu_item_update (priv->voip_input_menu_item, update); -} - -gboolean -active_sink_is_voip_source_populated (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - return voip_input_menu_item_is_populated (priv->voip_input_menu_item); -} - -gint active_sink_get_source_index (ActiveSink* self) -{ - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - return voip_input_menu_item_get_index (priv->voip_input_menu_item); -} - -ActiveSink* -active_sink_new (SoundServiceDbus* service) -{ - ActiveSink* sink = g_object_new (ACTIVE_SINK_TYPE, NULL); - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink); - priv->service = service; - sound_service_dbus_build_sound_menu (service, - mute_menu_item_get_button (priv->mute_menuitem), - DBUSMENU_MENUITEM (priv->volume_slider_menuitem), - DBUSMENU_MENUITEM (priv->voip_input_menu_item)); - pm_establish_pulse_connection (sink); - return sink; -} diff --git a/src/active-sink.h b/src/active-sink.h deleted file mode 100644 index 57b3079..0000000 --- a/src/active-sink.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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/>. - */ - -#ifndef __ACTIVE_SINK_H__ -#define __ACTIVE_SINK_H__ - -#include <glib.h> -#include <glib-object.h> - -#include "common-defs.h" -#include "sound-service-dbus.h" - -#include <pulse/pulseaudio.h> - -G_BEGIN_DECLS - -#define ACTIVE_SINK_TYPE (active_sink_get_type ()) -#define ACTIVE_SINK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ACTIVE_SINK_TYPE, ActiveSink)) -#define ACTIVE_SINK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), ACTIVE_SINK_TYPE, ActiveSinkClass)) -#define IS_ACTIVE_SINK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ACTIVE_SINK_TYPE)) -#define IS_ACTIVE_SINK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ACTIVE_SINK_TYPE)) -#define ACTIVE_SINK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ACTIVE_SINK_TYPE, ActiveSinkClass)) - -typedef struct _ActiveSink ActiveSink; -typedef struct _ActiveSinkClass ActiveSinkClass; - -struct _ActiveSink { - GObject parent; -}; - -struct _ActiveSinkClass { - GObjectClass parent_class; -}; - -GType active_sink_get_type (void) G_GNUC_CONST; - -/** - * TODO - * Refactor this to become a device manager obj basically acting as wrapper for - * the communication between pulseaudio-mgr and the individual items. - * First steps collapse slider/volume related stuff into slider-menu-item. - */ - -// Sink related -void active_sink_populate (ActiveSink* sink, const pa_sink_info* update); -void active_sink_update (ActiveSink* sink, const pa_sink_info* update); -gboolean active_sink_is_populated (ActiveSink* sink); -gint active_sink_get_index (ActiveSink* self); -void active_sink_deactivate (ActiveSink* self); -void active_sink_update_mute (ActiveSink* self, gboolean mute_update); -void active_sink_update_volume (ActiveSink* self, gdouble percent); -void active_sink_ensure_sink_is_unmuted (ActiveSink* self); - -// source and sinkinput/client related for VOIP functionality -void active_sink_update_voip_input_source (ActiveSink* sink, const pa_source_info* update); -void active_sink_activate_voip_item (ActiveSink* sink, gint sink_input_index, gint client_index); -gint active_sink_get_current_sink_input_index (ActiveSink* sink); -gboolean active_sink_is_voip_source_populated (ActiveSink* sink); -gint active_sink_get_source_index (ActiveSink* self); -void active_sink_determine_blocking_state (ActiveSink* self); -void active_sink_deactivate_voip_source (ActiveSink* self, gboolean visible); -void active_sink_deactivate_voip_client (ActiveSink* self); -SoundState active_sink_get_state (ActiveSink* self); - -ActiveSink* active_sink_new (SoundServiceDbus* service); - -G_END_DECLS - -#endif diff --git a/src/common-defs.h b/src/common-defs.h index da504de..68cb0b8 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -19,6 +19,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef __COMMON_DEFS_H__ #define __COMMON_DEFS_H__ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif typedef enum { MUTED, @@ -45,12 +48,13 @@ typedef enum { TRANSPORT_STATE_PAUSED }TransportState; -#define NOT_ACTIVE -1 +#define NOT_ACTIVE -1 #define DBUSMENU_PROPERTY_EMPTY -1 /* DBUS Custom Items */ #define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type" #define DBUSMENU_VOLUME_MENUITEM_LEVEL "x-canonical-ido-volume-level" +#define DBUSMENU_VOLUME_MENUITEM_MUTE "x-canonical-ido-volume-mute" #define DBUSMENU_VOIP_INPUT_MENUITEM_TYPE "x-canonical-ido-voip-input-type" #define DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL "x-canonical-ido-voip-input-level" diff --git a/src/device.c b/src/device.c new file mode 100644 index 0000000..79b7b50 --- /dev/null +++ b/src/device.c @@ -0,0 +1,289 @@ +/* +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/>. +*/ +#include <libdbusmenu-glib/menuitem.h> + +#include "device.h" +#include "slider-menu-item.h" +#include "mute-menu-item.h" +#include "voip-input-menu-item.h" +#include "pulseaudio-mgr.h" + +typedef struct _DevicePrivate DevicePrivate; + +struct _DevicePrivate +{ + SliderMenuItem* volume_slider_menuitem; + MuteMenuItem* mute_menuitem; + VoipInputMenuItem* voip_input_menu_item; + SoundState current_sound_state; + SoundServiceDbus* service; +}; + +#define DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEVICE_TYPE, DevicePrivate)) + +/* Prototypes */ +static void device_class_init (DeviceClass *klass); +static void device_init (Device *self); +static void device_dispose (GObject *object); +static void device_finalize (GObject *object); + +static SoundState device_get_state_from_volume (Device* self); +static void device_mute_update (Device* self, gboolean muted); + +G_DEFINE_TYPE (Device, device, G_TYPE_OBJECT); + +static void +device_class_init (DeviceClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (DevicePrivate)); + + gobject_class->dispose = device_dispose; + gobject_class->finalize = device_finalize; +} + +static void +device_init (Device *self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + priv->mute_menuitem = NULL; + priv->volume_slider_menuitem = NULL; + priv->voip_input_menu_item = NULL; + priv->current_sound_state = UNAVAILABLE; + priv->service = NULL; + + // Init our menu items. + priv->mute_menuitem = g_object_new (MUTE_MENU_ITEM_TYPE, NULL); + priv->voip_input_menu_item = g_object_new (VOIP_INPUT_MENU_ITEM_TYPE, NULL);; + priv->volume_slider_menuitem = slider_menu_item_new (self); + mute_menu_item_enable (priv->mute_menuitem, FALSE); + slider_menu_item_enable (priv->volume_slider_menuitem, FALSE); +} + +static void +device_dispose (GObject *object) +{ + G_OBJECT_CLASS (device_parent_class)->dispose (object); +} + +static void +device_finalize (GObject *object) +{ + G_OBJECT_CLASS (device_parent_class)->finalize (object); +} + +void +device_sink_populate (Device* self, + const pa_sink_info* update) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE(self); + mute_menu_item_enable (priv->mute_menuitem, TRUE); + slider_menu_item_populate (priv->volume_slider_menuitem, update); + SoundState state = device_get_state_from_volume (self); + if (priv->current_sound_state != state){ + priv->current_sound_state = state; + sound_service_dbus_update_sound_state (priv->service, + priv->current_sound_state); + } + device_mute_update (self, update->mute); +} + +void +device_sink_update (Device* self, + const pa_sink_info* update) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + slider_menu_item_update (priv->volume_slider_menuitem, update); + + SoundState state = device_get_state_from_volume (self); + if (priv->current_sound_state != state){ + priv->current_sound_state = state; + sound_service_dbus_update_sound_state (priv->service, + priv->current_sound_state); + } + + device_mute_update (self, update->mute); +} + +gint +device_get_current_sink_input_index (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + return voip_input_menu_item_get_sink_input_index (priv->voip_input_menu_item); +} + +static void +device_mute_update (Device* self, gboolean muted) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + mute_menu_item_update (priv->mute_menuitem, muted); + SoundState state = device_get_state_from_volume (self); + + if (muted == TRUE){ + state = MUTED; + } + // Only send signals if something has changed + if (priv->current_sound_state != state){ + priv->current_sound_state = state; + sound_service_dbus_update_sound_state (priv->service, state); + } +} + +void +device_ensure_sink_is_unmuted (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + if (mute_menu_item_is_muted (priv->mute_menuitem)){ + pm_update_mute (FALSE); + } +} + + +static SoundState +device_get_state_from_volume (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + GVariant* v = dbusmenu_menuitem_property_get_variant (DBUSMENU_MENUITEM(priv->volume_slider_menuitem), + 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; +} + +void +device_determine_blocking_state (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + if (mute_menu_item_is_muted (priv->mute_menuitem)){ + /** + We don't want to set the current state to blocking + as this is a fire and forget event. + */ + sound_service_dbus_update_sound_state (priv->service, + BLOCKED); + } +} + +gint +device_get_sink_index (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + return slider_menu_item_get_sink_index (priv->volume_slider_menuitem); +} + +gboolean +device_is_sink_populated (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + return dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM (priv->volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_ENABLED); +} + +void +device_activate_voip_item (Device* self, gint sink_input_index, gint client_index) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + if (voip_input_menu_item_is_interested (priv->voip_input_menu_item, + sink_input_index, + client_index)){ + voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE); + } +} + +void +device_deactivate_voip_source (Device* self, gboolean visible) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item); + voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible); +} + +void +device_deactivate_voip_client (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item); +} + +void +device_sink_deactivated (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + priv->current_sound_state = UNAVAILABLE; + sound_service_dbus_update_sound_state (priv->service, + priv->current_sound_state); + mute_menu_item_enable (priv->mute_menuitem, FALSE); + slider_menu_item_enable (priv->volume_slider_menuitem, FALSE); +} + +SoundState +device_get_state (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + return priv->current_sound_state; +} + +void +device_update_voip_input_source (Device* self, const pa_source_info* update) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + voip_input_menu_item_update (priv->voip_input_menu_item, update); +} + +gboolean +device_is_voip_source_populated (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + return voip_input_menu_item_is_populated (priv->voip_input_menu_item); +} + +gint device_get_source_index (Device* self) +{ + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); + return voip_input_menu_item_get_index (priv->voip_input_menu_item); +} + +Device* +device_new (SoundServiceDbus* service) +{ + Device* sink = g_object_new (DEVICE_TYPE, NULL); + DevicePrivate* priv = DEVICE_GET_PRIVATE (sink); + priv->service = service; + sound_service_dbus_build_sound_menu (service, + mute_menu_item_get_button (priv->mute_menuitem), + DBUSMENU_MENUITEM (priv->volume_slider_menuitem), + DBUSMENU_MENUITEM (priv->voip_input_menu_item)); + pm_establish_pulse_connection (sink); + return sink; +} diff --git a/src/device.h b/src/device.h new file mode 100644 index 0000000..9c74344 --- /dev/null +++ b/src/device.h @@ -0,0 +1,84 @@ +/* + * 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/>. + */ + +#ifndef __DEVICE_H__ +#define __DEVICE_H__ + +#include <glib.h> +#include <glib-object.h> + +#include "common-defs.h" +#include "sound-service-dbus.h" + +#include <pulse/pulseaudio.h> + +G_BEGIN_DECLS + +#define DEVICE_TYPE (device_get_type ()) +#define DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DEVICE_TYPE, Device)) +#define DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), DEVICE_TYPE, DeviceClass)) +#define IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DEVICE_TYPE)) +#define IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DEVICE_TYPE)) +#define DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DEVICE_TYPE, DeviceClass)) + +typedef struct _Device Device; +typedef struct _DeviceClass DeviceClass; + +struct _Device { + GObject parent; +}; + +struct _DeviceClass { + GObjectClass parent_class; +}; + +GType device_get_type (void) G_GNUC_CONST; + +/** + * TODO + * Refactor this to become a device manager obj basically acting as wrapper for + * the communication between pulseaudio-mgr and the individual items. + * First steps collapse slider/volume related stuff into slider-menu-item. + */ + +// Sink related +void device_sink_populate (Device* sink, const pa_sink_info* update); +void device_sink_update (Device* sink, const pa_sink_info* update); +gboolean device_is_sink_populated (Device* sink); +gint device_get_sink_index (Device* self); +void device_sink_deactivated (Device* self); +void device_update_mute (Device* self, gboolean mute_update); +void device_ensure_sink_is_unmuted (Device* self); + +// source and sinkinput/client related for VOIP functionality +void device_update_voip_input_source (Device* sink, const pa_source_info* update); +void device_activate_voip_item (Device* sink, gint sink_input_index, gint client_index); +gint device_get_current_sink_input_index (Device* sink); +gboolean device_is_voip_source_populated (Device* sink); +gint device_get_source_index (Device* self); +void device_determine_blocking_state (Device* self); +void device_deactivate_voip_source (Device* self, gboolean visible); +void device_deactivate_voip_client (Device* self); +SoundState device_get_state (Device* self); + +Device* device_new (SoundServiceDbus* service); + +G_END_DECLS + +#endif diff --git a/src/fetch-file.c b/src/fetch-file.c index 47f0558..7fb8e14 100644 --- a/src/fetch-file.c +++ b/src/fetch-file.c @@ -1,4 +1,4 @@ -/* fetch-file.c generated by valac 0.11.6, the Vala compiler +/* fetch-file.c generated by valac 0.11.7, the Vala compiler * generated from fetch-file.vala, do not modify */ /* @@ -73,7 +73,6 @@ struct _FetchFileFetchDataData { GFileInputStream* _tmp1_; GFileInputStream* _tmp2_; GDataInputStream* _tmp3_; - GDataInputStream* _tmp4_; GError * e; GError * _inner_error_; }; @@ -193,9 +192,8 @@ static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) { data->_tmp2_ = data->_tmp1_; data->_tmp3_ = NULL; data->_tmp3_ = g_data_input_stream_new ((GInputStream*) data->_tmp2_); - data->_tmp4_ = data->_tmp3_; _g_object_unref0 (data->self->priv->stream); - data->self->priv->stream = data->_tmp4_; + data->self->priv->stream = data->_tmp3_; _g_object_unref0 (data->_tmp2_); g_data_input_stream_set_byte_order (data->self->priv->stream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN); goto __finally14; @@ -346,12 +344,10 @@ const gchar* fetch_file_get_uri (FetchFile* self) { static void fetch_file_set_uri (FetchFile* self, const gchar* value) { gchar* _tmp0_; - gchar* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = g_strdup (value); - _tmp1_ = _tmp0_; _g_free0 (self->priv->_uri); - self->priv->_uri = _tmp1_; + self->priv->_uri = _tmp0_; g_object_notify ((GObject *) self, "uri"); } @@ -366,12 +362,10 @@ const gchar* fetch_file_get_intended_property (FetchFile* self) { static void fetch_file_set_intended_property (FetchFile* self, const gchar* value) { gchar* _tmp0_; - gchar* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = g_strdup (value); - _tmp1_ = _tmp0_; _g_free0 (self->priv->_intended_property); - self->priv->_intended_property = _tmp1_; + self->priv->_intended_property = _tmp0_; g_object_notify ((GObject *) self, "intended-property"); } @@ -400,20 +394,16 @@ static GObject * fetch_file_constructor (GType type, guint n_construct_propertie GObjectClass * parent_class; FetchFile * self; GFile* _tmp0_ = NULL; - GFile* _tmp1_; - GByteArray* _tmp2_ = NULL; - GByteArray* _tmp3_; + GByteArray* _tmp1_ = NULL; parent_class = G_OBJECT_CLASS (fetch_file_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = FETCH_FILE (obj); _tmp0_ = g_file_new_for_uri (self->priv->_uri); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->file); - self->priv->file = _tmp1_; - _tmp2_ = g_byte_array_new (); - _tmp3_ = _tmp2_; + self->priv->file = _tmp0_; + _tmp1_ = g_byte_array_new (); _g_byte_array_free0 (self->priv->data); - self->priv->data = _tmp3_; + self->priv->data = _tmp1_; return obj; } diff --git a/src/freedesktop-interfaces.c b/src/freedesktop-interfaces.c index c91cdb9..b7c8474 100644 --- a/src/freedesktop-interfaces.c +++ b/src/freedesktop-interfaces.c @@ -1,4 +1,4 @@ -/* freedesktop-interfaces.c generated by valac 0.11.6, the Vala compiler +/* freedesktop-interfaces.c generated by valac 0.11.7, the Vala compiler * generated from freedesktop-interfaces.vala, do not modify */ /* diff --git a/src/indicator-sound.c b/src/indicator-sound.c index a7d3808..7d74a42 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -45,6 +45,7 @@ typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate; struct _IndicatorSoundPrivate { GtkWidget* volume_widget; + GtkWidget* voip_widget; GList* transport_widgets_list; GDBusProxy *dbus_proxy; SoundStateManager* state_manager; @@ -443,11 +444,16 @@ new_voip_slider_widget (DbusmenuMenuitem * newitem, { g_debug("indicator-sound: new_voip_slider_widget"); GtkWidget* voip_widget = NULL; + IndicatorObject *io = NULL; g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + io = g_object_get_data (G_OBJECT (client), "indicator"); + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); + voip_widget = voip_input_widget_new (newitem); + priv->voip_widget = voip_widget; GtkWidget* ido_slider_widget = voip_input_widget_get_ido_slider(VOIP_INPUT_WIDGET(voip_widget)); @@ -478,21 +484,35 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) IndicatorSound *indicator = INDICATOR_SOUND (data); IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(indicator); - if(priv->volume_widget == NULL){ - return FALSE; - } - - GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); - GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget); - GtkRange* range = (GtkRange*)slider; - g_return_val_if_fail(GTK_IS_RANGE(range), FALSE); - gdouble current_value = gtk_range_get_value(range); - gdouble new_value = current_value; - const gdouble five_percent = 5; GtkWidget *menuitem; - menuitem = GTK_MENU_SHELL (widget)->active_menu_item; - if (IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) { + + if (IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE){ + gdouble current_value = 0; + gdouble new_value = 0; + const gdouble five_percent = 5; + gboolean is_voip_slider = FALSE; + + if (g_ascii_strcasecmp (ido_scale_menu_item_get_primary_label (IDO_SCALE_MENU_ITEM(menuitem)), "VOLUME") == 0) { + g_debug ("vOLUME SLIDER KEY PRESS"); + GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); + GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget); + GtkRange* range = (GtkRange*)slider; + g_return_val_if_fail(GTK_IS_RANGE(range), FALSE); + current_value = gtk_range_get_value(range); + new_value = current_value; + } + else if (g_ascii_strcasecmp (ido_scale_menu_item_get_primary_label (IDO_SCALE_MENU_ITEM(menuitem)), "VOIP") == 0) { + g_debug ("VOIP SLIDER KEY PRESS"); + GtkWidget* slider_widget = voip_input_widget_get_ido_slider(VOIP_INPUT_WIDGET(priv->voip_widget)); + GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget); + GtkRange* range = (GtkRange*)slider; + g_return_val_if_fail(GTK_IS_RANGE(range), FALSE); + current_value = gtk_range_get_value(range); + new_value = current_value; + is_voip_slider = TRUE; + } + switch (event->keyval) { case GDK_Right: digested = TRUE; @@ -514,9 +534,13 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) break; } new_value = CLAMP(new_value, 0, 100); - if (new_value != current_value && sound_state_manager_get_current_state (priv->state_manager) != MUTED) { - //g_debug("Attempting to set the range from the key listener to %f", new_value); - volume_widget_update(VOLUME_WIDGET(priv->volume_widget), new_value); + if (new_value != current_value){ + if (is_voip_slider == TRUE){ + voip_input_widget_update (VOIP_INPUT_WIDGET(priv->voip_widget), new_value); + } + else{ + volume_widget_update (VOLUME_WIDGET(priv->volume_widget), new_value); + } } } else if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) { diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c index 08231ca..981b951 100644 --- a/src/metadata-menu-item.c +++ b/src/metadata-menu-item.c @@ -1,4 +1,4 @@ -/* metadata-menu-item.c generated by valac 0.11.6, the Vala compiler +/* metadata-menu-item.c generated by valac 0.11.7, the Vala compiler * generated from metadata-menu-item.vala, do not modify */ /* @@ -337,8 +337,7 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons GFile* _tmp0_ = NULL; GFile* art_file; gboolean _tmp1_; - FetchFile* _tmp8_ = NULL; - FetchFile* _tmp9_; + FetchFile* _tmp7_ = NULL; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (uri != NULL); @@ -353,11 +352,12 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons gchar* _tmp4_ = NULL; gchar* _tmp5_; gchar* _tmp6_; - gchar* _tmp7_; _tmp2_ = string_strip (uri); _tmp3_ = _tmp2_; _tmp4_ = g_filename_from_uri (_tmp3_, NULL, &_inner_error_); - _tmp6_ = (_tmp5_ = _tmp4_, _g_free0 (_tmp3_), _tmp5_); + _tmp5_ = _tmp4_; + _g_free0 (_tmp3_); + _tmp6_ = _tmp5_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_CONVERT_ERROR) { goto __catch4_g_convert_error; @@ -368,9 +368,8 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons g_clear_error (&_inner_error_); return; } - _tmp7_ = _tmp6_; _g_free0 (path); - path = _tmp7_; + path = _tmp6_; dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, prop, path); goto __finally4; __catch4_g_convert_error: @@ -398,10 +397,9 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons _g_object_unref0 (art_file); return; } - _tmp8_ = fetch_file_new (uri, prop); - _tmp9_ = _tmp8_; + _tmp7_ = fetch_file_new (uri, prop); _g_object_unref0 (metadata_menuitem_fetcher); - metadata_menuitem_fetcher = _tmp9_; + metadata_menuitem_fetcher = _tmp7_; g_signal_connect_object (metadata_menuitem_fetcher, "failed", (GCallback) __lambda0__fetch_file_failed, self, 0); g_signal_connect_object (metadata_menuitem_fetcher, "completed", (GCallback) _metadata_menuitem_on_fetcher_completed_fetch_file_completed, self, 0); fetch_file_fetch_data (metadata_menuitem_fetcher, NULL, NULL); @@ -458,7 +456,6 @@ static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByt GdkPixbufFormat* _tmp5_ = NULL; const gchar* _tmp6_ = NULL; gchar* _tmp7_; - gchar* _tmp8_; _tmp5_ = gdk_pixbuf_loader_get_format (loader); _tmp6_ = gdk_pixbuf_format_get_name (_tmp5_); gdk_pixbuf_save (icon, path, _tmp6_, &_inner_error_, NULL); @@ -473,9 +470,8 @@ static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByt g_remove (self->priv->previous_temp_album_art_path); } _tmp7_ = g_strdup (path); - _tmp8_ = _tmp7_; _g_free0 (self->priv->previous_temp_album_art_path); - self->priv->previous_temp_album_art_path = _tmp8_; + self->priv->previous_temp_album_art_path = _tmp7_; } _g_free0 (path); _g_object_unref0 (icon); @@ -518,20 +514,16 @@ static GObject * metadata_menuitem_constructor (GType type, guint n_construct_pr GObject * obj; GObjectClass * parent_class; MetadataMenuitem * self; - gchar* _tmp0_; - gchar* _tmp1_ = NULL; - gchar* _tmp2_; + gchar* _tmp0_ = NULL; parent_class = G_OBJECT_CLASS (metadata_menuitem_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = METADATA_MENUITEM (obj); metadata_menuitem_clean_album_art_temp_dir (); - _tmp0_ = NULL; _g_free0 (self->priv->previous_temp_album_art_path); - self->priv->previous_temp_album_art_path = _tmp0_; - _tmp1_ = metadata_menuitem_create_album_art_temp_dir (); - _tmp2_ = _tmp1_; + self->priv->previous_temp_album_art_path = NULL; + _tmp0_ = metadata_menuitem_create_album_art_temp_dir (); _g_free0 (metadata_menuitem_album_art_cache_dir); - metadata_menuitem_album_art_cache_dir = _tmp2_; + metadata_menuitem_album_art_cache_dir = _tmp0_; return obj; } diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c index 4a9b1ff..89ef02d 100644 --- a/src/mpris2-controller.c +++ b/src/mpris2-controller.c @@ -1,4 +1,4 @@ -/* mpris2-controller.c generated by valac 0.11.6, the Vala compiler +/* mpris2-controller.c generated by valac 0.11.7, the Vala compiler * generated from mpris2-controller.vala, do not modify */ /* @@ -269,14 +269,12 @@ struct _Mpris2ControllerFetchPlaylistsData { PlaylistDetails* _tmp2_; gint _tmp2__length1; gint __tmp2__size_; - PlaylistDetails* _tmp3_; GError * e; - gpointer _tmp4_; - PlayerItem* _tmp5_; + gpointer _tmp3_; + PlayerItem* _tmp4_; PlaylistsMenuitem* playlists_item; - gboolean _tmp6_; - gboolean* _tmp7_; - gboolean* _tmp8_; + gboolean _tmp5_; + gboolean* _tmp6_; GError * _inner_error_; }; @@ -496,7 +494,8 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* _tmp5_ = mpris2_controller_determine_play_state (self, state); p = (TransportState) _tmp5_; _tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); - _tmp8_ = (_tmp7_ = (PlayerItem*) _tmp6_, IS_TRANSPORT_MENUITEM (_tmp7_) ? ((TransportMenuitem*) _tmp7_) : NULL); + _tmp7_ = (PlayerItem*) _tmp6_; + _tmp8_ = IS_TRANSPORT_MENUITEM (_tmp7_) ? ((TransportMenuitem*) _tmp7_) : NULL; transport_menuitem_change_play_state (_tmp8_, p); _g_object_unref0 (_tmp8_); _g_free0 (state); @@ -541,7 +540,8 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* playlist_v = _tmp21_; if (playlist_v != NULL) { gboolean _tmp23_; - _tmp22_ = _bool_equal (self->priv->_owner->use_playlists, (_tmp23_ = TRUE, &_tmp23_)) == TRUE; + _tmp23_ = TRUE; + _tmp22_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp23_) == TRUE; } else { _tmp22_ = FALSE; } @@ -553,7 +553,8 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* playlist_count_v = _tmp25_; if (playlist_count_v != NULL) { gboolean _tmp27_; - _tmp26_ = _bool_equal (self->priv->_owner->use_playlists, (_tmp27_ = TRUE, &_tmp27_)) == TRUE; + _tmp27_ = TRUE; + _tmp26_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp27_) == TRUE; } else { _tmp26_ = FALSE; } @@ -566,7 +567,8 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* playlist_orderings_v = _tmp29_; if (playlist_orderings_v != NULL) { gboolean _tmp31_; - _tmp30_ = _bool_equal (self->priv->_owner->use_playlists, (_tmp31_ = TRUE, &_tmp31_)) == TRUE; + _tmp31_ = TRUE; + _tmp30_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp31_) == TRUE; } else { _tmp30_ = FALSE; } @@ -584,7 +586,8 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* gchar* _tmp36_ = NULL; gchar* _tmp37_; _tmp34_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); - title = (_tmp35_ = (PlayerItem*) _tmp34_, IS_TITLE_MENUITEM (_tmp35_) ? ((TitleMenuitem*) _tmp35_) : NULL); + _tmp35_ = (PlayerItem*) _tmp34_; + title = IS_TITLE_MENUITEM (_tmp35_) ? ((TitleMenuitem*) _tmp35_) : NULL; _tmp36_ = mpris_root_get_Identity (self->priv->_mpris2_root); _tmp37_ = _tmp36_; title_menuitem_alter_label (title, _tmp37_); @@ -614,9 +617,12 @@ static gboolean mpris2_controller_ensure_correct_playback_status (Mpris2Controll _tmp0_ = mpris_player_get_PlaybackStatus (self->priv->_player); _tmp1_ = _tmp0_; _tmp2_ = mpris2_controller_determine_play_state (self, _tmp1_); - p = (_tmp3_ = (TransportState) _tmp2_, _g_free0 (_tmp1_), _tmp3_); + _tmp3_ = (TransportState) _tmp2_; + _g_free0 (_tmp1_); + p = _tmp3_; _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); - _tmp6_ = (_tmp5_ = (PlayerItem*) _tmp4_, IS_TRANSPORT_MENUITEM (_tmp5_) ? ((TransportMenuitem*) _tmp5_) : NULL); + _tmp5_ = (PlayerItem*) _tmp4_; + _tmp6_ = IS_TRANSPORT_MENUITEM (_tmp5_) ? ((TransportMenuitem*) _tmp5_) : NULL; transport_menuitem_change_play_state (_tmp6_, p); _g_object_unref0 (_tmp6_); result = FALSE; @@ -651,7 +657,9 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) { _tmp2_ = _tmp1_; _tmp3_ = g_hash_table_lookup (_tmp2_, "xesam:artist"); _tmp4_ = _g_variant_ref0 ((GVariant*) _tmp3_); - artist_v = (_tmp5_ = _tmp4_, _g_hash_table_unref0 (_tmp2_), _tmp5_); + _tmp5_ = _tmp4_; + _g_hash_table_unref0 (_tmp2_); + artist_v = _tmp5_; if (artist_v != NULL) { GHashTable* _tmp6_ = NULL; GHashTable* _tmp7_; @@ -662,48 +670,46 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) { const gchar* _tmp11_ = NULL; gchar* display_artists = NULL; const gchar* _tmp12_ = NULL; - gchar* _tmp20_; - gconstpointer _tmp21_ = NULL; + gchar* _tmp18_; + gconstpointer _tmp19_ = NULL; _tmp6_ = mpris_player_get_Metadata (self->priv->_player); _tmp7_ = _tmp6_; _tmp8_ = g_hash_table_lookup (_tmp7_, "xesam:artist"); _tmp9_ = _g_variant_ref0 ((GVariant*) _tmp8_); - v_artists = (_tmp10_ = _tmp9_, _g_hash_table_unref0 (_tmp7_), _tmp10_); + _tmp10_ = _tmp9_; + _g_hash_table_unref0 (_tmp7_); + v_artists = _tmp10_; _tmp11_ = g_variant_get_type_string (v_artists); g_debug ("mpris2-controller.vala:130: artists is of type %s", _tmp11_); _tmp12_ = g_variant_get_type_string (v_artists); if (g_strcmp0 (_tmp12_, "s") == 0) { const gchar* _tmp13_ = NULL; gchar* _tmp14_; - gchar* _tmp15_; g_debug ("mpris2-controller.vala:133: SPOTIFY is that you ?"); _tmp13_ = g_variant_get_string (v_artists, NULL); _tmp14_ = g_strdup (_tmp13_); - _tmp15_ = _tmp14_; _g_free0 (display_artists); - display_artists = _tmp15_; + display_artists = _tmp14_; } else { - size_t _tmp16_; - gchar** _tmp17_ = NULL; + size_t _tmp15_; + gchar** _tmp16_ = NULL; gchar** artists; gint artists_length1; gint _artists_size_; - gchar* _tmp18_ = NULL; - gchar* _tmp19_; - _tmp17_ = g_variant_dup_strv (v_artists, &_tmp16_); - artists = _tmp17_; - artists_length1 = _tmp16_; - _artists_size_ = _tmp16_; - _tmp18_ = g_strjoinv (", ", artists); - _tmp19_ = _tmp18_; + gchar* _tmp17_ = NULL; + _tmp16_ = g_variant_dup_strv (v_artists, &_tmp15_); + artists = _tmp16_; + artists_length1 = _tmp15_; + _artists_size_ = _tmp15_; + _tmp17_ = g_strjoinv (", ", artists); _g_free0 (display_artists); - display_artists = _tmp19_; + display_artists = _tmp17_; artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL); } - _tmp20_ = g_strdup ("xesam:artist"); - g_hash_table_replace (changed_updates, _tmp20_, _variant_new1 (display_artists)); - _tmp21_ = g_hash_table_lookup (changed_updates, "xesam:artist"); - g_debug ("mpris2-controller.vala:141: artist : %s", _variant_get2 ((GVariant*) _tmp21_)); + _tmp18_ = g_strdup ("xesam:artist"); + g_hash_table_replace (changed_updates, _tmp18_, _variant_new1 (display_artists)); + _tmp19_ = g_hash_table_lookup (changed_updates, "xesam:artist"); + g_debug ("mpris2-controller.vala:141: artist : %s", _variant_get2 ((GVariant*) _tmp19_)); _g_free0 (display_artists); _g_variant_unref0 (v_artists); } @@ -752,7 +758,9 @@ void mpris2_controller_initial_update (Mpris2Controller* self) { g_return_if_fail (self != NULL); _tmp0_ = mpris_player_get_PlaybackStatus (self->priv->_player); _tmp1_ = _tmp0_; - if ((_tmp2_ = _tmp1_ == NULL, _g_free0 (_tmp1_), _tmp2_)) { + _tmp2_ = _tmp1_ == NULL; + _g_free0 (_tmp1_); + if (_tmp2_) { update = TRANSPORT_STATE_PAUSED; } else { gchar* _tmp3_ = NULL; @@ -766,14 +774,17 @@ void mpris2_controller_initial_update (Mpris2Controller* self) { } _tmp6_ = mpris_root_get_Identity (self->priv->_mpris2_root); _tmp7_ = _tmp6_; - if ((_tmp8_ = _tmp7_ != NULL, _g_free0 (_tmp7_), _tmp8_)) { + _tmp8_ = _tmp7_ != NULL; + _g_free0 (_tmp7_); + if (_tmp8_) { gpointer _tmp9_ = NULL; PlayerItem* _tmp10_; TitleMenuitem* title; gchar* _tmp11_ = NULL; gchar* _tmp12_; _tmp9_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); - title = (_tmp10_ = (PlayerItem*) _tmp9_, IS_TITLE_MENUITEM (_tmp10_) ? ((TitleMenuitem*) _tmp10_) : NULL); + _tmp10_ = (PlayerItem*) _tmp9_; + title = IS_TITLE_MENUITEM (_tmp10_) ? ((TitleMenuitem*) _tmp10_) : NULL; _tmp11_ = mpris_root_get_Identity (self->priv->_mpris2_root); _tmp12_ = _tmp11_; title_menuitem_alter_label (title, _tmp12_); @@ -781,7 +792,8 @@ void mpris2_controller_initial_update (Mpris2Controller* self) { _g_object_unref0 (title); } _tmp13_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); - _tmp15_ = (_tmp14_ = (PlayerItem*) _tmp13_, IS_TRANSPORT_MENUITEM (_tmp14_) ? ((TransportMenuitem*) _tmp14_) : NULL); + _tmp14_ = (PlayerItem*) _tmp13_; + _tmp15_ = IS_TRANSPORT_MENUITEM (_tmp14_) ? ((TransportMenuitem*) _tmp14_) : NULL; transport_menuitem_change_play_state (_tmp15_, update); _g_object_unref0 (_tmp15_); _tmp16_ = mpris2_controller_clean_metadata (self); @@ -793,7 +805,8 @@ void mpris2_controller_initial_update (Mpris2Controller* self) { player_item_update (_tmp18_, cleaned_metadata, _tmp20_); _g_object_unref0 (_tmp20_); _g_object_unref0 (_tmp18_); - if (_bool_equal (self->priv->_owner->use_playlists, (_tmp21_ = TRUE, &_tmp21_)) == TRUE) { + _tmp21_ = TRUE; + if (_bool_equal (self->priv->_owner->use_playlists, &_tmp21_) == TRUE) { mpris2_controller_fetch_playlists (self, NULL, NULL); mpris2_controller_fetch_active_playlist (self); } @@ -855,7 +868,8 @@ static void mpris2_controller_on_playlistdetails_changed (Mpris2Controller* self PlaylistsMenuitem* playlists_item; g_return_if_fail (self != NULL); _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); - playlists_item = (_tmp1_ = (PlayerItem*) _tmp0_, IS_PLAYLISTS_MENUITEM (_tmp1_) ? ((PlaylistsMenuitem*) _tmp1_) : NULL); + _tmp1_ = (PlayerItem*) _tmp0_; + playlists_item = IS_PLAYLISTS_MENUITEM (_tmp1_) ? ((PlaylistsMenuitem*) _tmp1_) : NULL; playlists_menuitem_update_individual_playlist (playlists_item, details); _g_object_unref0 (playlists_item); } @@ -954,11 +968,10 @@ static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlayl g_clear_error (&data->_inner_error_); return FALSE; } - data->_tmp3_ = data->_tmp2_; data->current_playlists = (_vala_PlaylistDetails_array_free (data->current_playlists, data->current_playlists_length1), NULL); + data->current_playlists = data->_tmp2_; data->current_playlists_length1 = data->_tmp2__length1; - data->_current_playlists_size_ = data->current_playlists_length1; - data->current_playlists = data->_tmp3_; + data->_current_playlists_size_ = data->__tmp2__size_; goto __finally11; __catch11_g_io_error: { @@ -984,18 +997,19 @@ static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlayl } if (data->current_playlists != NULL) { g_debug ("mpris2-controller.vala:234: Size of the playlist array = %i", data->current_playlists_length1); - data->_tmp4_ = NULL; - data->_tmp4_ = gee_abstract_list_get ((GeeAbstractList*) data->self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); - data->playlists_item = (data->_tmp5_ = (PlayerItem*) data->_tmp4_, IS_PLAYLISTS_MENUITEM (data->_tmp5_) ? ((PlaylistsMenuitem*) data->_tmp5_) : NULL); + data->_tmp3_ = NULL; + data->_tmp3_ = gee_abstract_list_get ((GeeAbstractList*) data->self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); + data->_tmp4_ = (PlayerItem*) data->_tmp3_; + data->playlists_item = IS_PLAYLISTS_MENUITEM (data->_tmp4_) ? ((PlaylistsMenuitem*) data->_tmp4_) : NULL; playlists_menuitem_update (data->playlists_item, data->current_playlists, data->current_playlists_length1); _g_object_unref0 (data->playlists_item); } else { g_warning ("mpris2-controller.vala:239: Playlists are on but its returning no cur" \ "rent_playlists"); - data->_tmp7_ = __bool_dup0 ((data->_tmp6_ = FALSE, &data->_tmp6_)); - data->_tmp8_ = data->_tmp7_; + data->_tmp5_ = FALSE; + data->_tmp6_ = __bool_dup0 (&data->_tmp5_); _g_free0 (data->self->priv->_owner->use_playlists); - data->self->priv->_owner->use_playlists = data->_tmp8_; + data->self->priv->_owner->use_playlists = data->_tmp6_; } data->current_playlists = (_vala_PlaylistDetails_array_free (data->current_playlists, data->current_playlists_length1), NULL); if (data->_state_ == 0) { @@ -1021,11 +1035,14 @@ static gboolean mpris2_controller_fetch_active_playlist (Mpris2Controller* self) g_return_val_if_fail (self != NULL, FALSE); mpris_playlists_get_ActivePlaylist (self->priv->_playlists, &_tmp0_); _tmp1_ = _tmp0_; - if ((_tmp2_ = _tmp1_.valid == FALSE, active_playlist_container_destroy (&_tmp1_), _tmp2_)) { + _tmp2_ = _tmp1_.valid == FALSE; + active_playlist_container_destroy (&_tmp1_); + if (_tmp2_) { g_debug ("mpris2-controller.vala:247: We don't have an active playlist"); } _tmp3_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); - playlists_item = (_tmp4_ = (PlayerItem*) _tmp3_, IS_PLAYLISTS_MENUITEM (_tmp4_) ? ((PlaylistsMenuitem*) _tmp4_) : NULL); + _tmp4_ = (PlayerItem*) _tmp3_; + playlists_item = IS_PLAYLISTS_MENUITEM (_tmp4_) ? ((PlaylistsMenuitem*) _tmp4_) : NULL; mpris_playlists_get_ActivePlaylist (self->priv->_playlists, &_tmp5_); _tmp6_ = _tmp5_; playlists_menuitem_active_playlist_update (playlists_item, &_tmp6_.details); @@ -1069,12 +1086,10 @@ MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self) { static void mpris2_controller_set_mpris2_root (Mpris2Controller* self, MprisRoot* value) { MprisRoot* _tmp0_; - MprisRoot* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->_mpris2_root); - self->priv->_mpris2_root = _tmp1_; + self->priv->_mpris2_root = _tmp0_; g_object_notify ((GObject *) self, "mpris2-root"); } @@ -1089,12 +1104,10 @@ MprisPlayer* mpris2_controller_get_player (Mpris2Controller* self) { static void mpris2_controller_set_player (Mpris2Controller* self, MprisPlayer* value) { MprisPlayer* _tmp0_; - MprisPlayer* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->_player); - self->priv->_player = _tmp1_; + self->priv->_player = _tmp0_; g_object_notify ((GObject *) self, "player"); } @@ -1109,12 +1122,10 @@ MprisPlaylists* mpris2_controller_get_playlists (Mpris2Controller* self) { static void mpris2_controller_set_playlists (Mpris2Controller* self, MprisPlaylists* value) { MprisPlaylists* _tmp0_; - MprisPlaylists* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->_playlists); - self->priv->_playlists = _tmp1_; + self->priv->_playlists = _tmp0_; g_object_notify ((GObject *) self, "playlists"); } @@ -1129,12 +1140,10 @@ FreeDesktopProperties* mpris2_controller_get_properties_interface (Mpris2Control static void mpris2_controller_set_properties_interface (Mpris2Controller* self, FreeDesktopProperties* value) { FreeDesktopProperties* _tmp0_; - FreeDesktopProperties* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->_properties_interface); - self->priv->_properties_interface = _tmp1_; + self->priv->_properties_interface = _tmp0_; g_object_notify ((GObject *) self, "properties-interface"); } @@ -1149,12 +1158,10 @@ PlayerController* mpris2_controller_get_owner (Mpris2Controller* self) { static void mpris2_controller_set_owner (Mpris2Controller* self, PlayerController* value) { PlayerController* _tmp0_; - PlayerController* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->_owner); - self->priv->_owner = _tmp1_; + self->priv->_owner = _tmp0_; g_object_notify ((GObject *) self, "owner"); } @@ -1174,27 +1181,24 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr GObjectClass * parent_class; Mpris2Controller * self; const gchar* _tmp0_ = NULL; - const gchar* _tmp1_ = NULL; - MprisRoot* _tmp2_ = NULL; + MprisRoot* _tmp1_ = NULL; + MprisRoot* _tmp2_; MprisRoot* _tmp3_; - MprisRoot* _tmp4_; - const gchar* _tmp5_ = NULL; - const gchar* _tmp6_ = NULL; - MprisPlayer* _tmp7_ = NULL; - MprisPlayer* _tmp8_; - MprisPlayer* _tmp9_; - gboolean _tmp10_; - FreeDesktopProperties* _tmp16_ = NULL; - FreeDesktopProperties* _tmp17_; - FreeDesktopProperties* _tmp18_; + const gchar* _tmp4_ = NULL; + MprisPlayer* _tmp5_ = NULL; + MprisPlayer* _tmp6_; + MprisPlayer* _tmp7_; + gboolean _tmp8_; + FreeDesktopProperties* _tmp13_ = NULL; + FreeDesktopProperties* _tmp14_; + FreeDesktopProperties* _tmp15_; GError * _inner_error_ = NULL; parent_class = G_OBJECT_CLASS (mpris2_controller_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = MPRIS2_CONTROLLER (obj); _tmp0_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp1_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp2_ = g_initable_new (TYPE_MPRIS_ROOT_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp1_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2", NULL); - _tmp3_ = (MprisRoot*) _tmp2_; + _tmp1_ = g_initable_new (TYPE_MPRIS_ROOT_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp0_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2", NULL); + _tmp2_ = (MprisRoot*) _tmp1_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { goto __catch13_g_io_error; @@ -1202,13 +1206,12 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); } - _tmp4_ = _tmp3_; - mpris2_controller_set_mpris2_root (self, _tmp4_); - _g_object_unref0 (_tmp4_); - _tmp5_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp6_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp7_ = g_initable_new (TYPE_MPRIS_PLAYER_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp6_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Player", NULL); - _tmp8_ = (MprisPlayer*) _tmp7_; + _tmp3_ = _tmp2_; + mpris2_controller_set_mpris2_root (self, _tmp3_); + _g_object_unref0 (_tmp3_); + _tmp4_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp5_ = g_initable_new (TYPE_MPRIS_PLAYER_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp4_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Player", NULL); + _tmp6_ = (MprisPlayer*) _tmp5_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { goto __catch13_g_io_error; @@ -1216,19 +1219,18 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); } - _tmp9_ = _tmp8_; - mpris2_controller_set_player (self, _tmp9_); - _g_object_unref0 (_tmp9_); - if (_bool_equal (self->priv->_owner->use_playlists, (_tmp10_ = TRUE, &_tmp10_)) == TRUE) { - const gchar* _tmp11_ = NULL; - const gchar* _tmp12_ = NULL; - MprisPlaylists* _tmp13_ = NULL; - MprisPlaylists* _tmp14_; - MprisPlaylists* _tmp15_; - _tmp11_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp12_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp13_ = g_initable_new (TYPE_MPRIS_PLAYLISTS_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp12_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Playlists", NULL); - _tmp14_ = (MprisPlaylists*) _tmp13_; + _tmp7_ = _tmp6_; + mpris2_controller_set_player (self, _tmp7_); + _g_object_unref0 (_tmp7_); + _tmp8_ = TRUE; + if (_bool_equal (self->priv->_owner->use_playlists, &_tmp8_) == TRUE) { + const gchar* _tmp9_ = NULL; + MprisPlaylists* _tmp10_ = NULL; + MprisPlaylists* _tmp11_; + MprisPlaylists* _tmp12_; + _tmp9_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp10_ = g_initable_new (TYPE_MPRIS_PLAYLISTS_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp9_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Playlists", NULL); + _tmp11_ = (MprisPlaylists*) _tmp10_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { goto __catch13_g_io_error; @@ -1236,13 +1238,13 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); } - _tmp15_ = _tmp14_; - mpris2_controller_set_playlists (self, _tmp15_); - _g_object_unref0 (_tmp15_); + _tmp12_ = _tmp11_; + mpris2_controller_set_playlists (self, _tmp12_); + _g_object_unref0 (_tmp12_); g_signal_connect_object (self->priv->_playlists, "playlist-changed", (GCallback) _mpris2_controller_on_playlistdetails_changed_mpris_playlists_playlist_changed, self, 0); } - _tmp16_ = g_initable_new (TYPE_FREE_DESKTOP_PROPERTIES_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.freedesktop.Properties.PropertiesChanged", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.freedesktop.DBus.Properties", NULL); - _tmp17_ = (FreeDesktopProperties*) _tmp16_; + _tmp13_ = g_initable_new (TYPE_FREE_DESKTOP_PROPERTIES_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.freedesktop.Properties.PropertiesChanged", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.freedesktop.DBus.Properties", NULL); + _tmp14_ = (FreeDesktopProperties*) _tmp13_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { goto __catch13_g_io_error; @@ -1250,9 +1252,9 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); } - _tmp18_ = _tmp17_; - mpris2_controller_set_properties_interface (self, _tmp18_); - _g_object_unref0 (_tmp18_); + _tmp15_ = _tmp14_; + mpris2_controller_set_properties_interface (self, _tmp15_); + _g_object_unref0 (_tmp15_); g_signal_connect_object (self->priv->_properties_interface, "properties-changed", (GCallback) _mpris2_controller_property_changed_cb_free_desktop_properties_properties_changed, self, 0); goto __finally13; __catch13_g_io_error: diff --git a/src/mpris2-interfaces.c b/src/mpris2-interfaces.c index 2a73d2e..f12429f 100644 --- a/src/mpris2-interfaces.c +++ b/src/mpris2-interfaces.c @@ -1,4 +1,4 @@ -/* mpris2-interfaces.c generated by valac 0.11.6, the Vala compiler +/* mpris2-interfaces.c generated by valac 0.11.7, the Vala compiler * generated from mpris2-interfaces.vala, do not modify */ /* @@ -1722,9 +1722,9 @@ void playlist_details_copy (const PlaylistDetails* self, PlaylistDetails* dest) void playlist_details_destroy (PlaylistDetails* self) { - _g_free0 (self->path); - _g_free0 (self->name); - _g_free0 (self->icon_path); + _g_free0 ((*self).path); + _g_free0 ((*self).name); + _g_free0 ((*self).icon_path); } @@ -1756,12 +1756,13 @@ GType playlist_details_get_type (void) { void active_playlist_container_copy (const ActivePlaylistContainer* self, ActivePlaylistContainer* dest) { PlaylistDetails _tmp0_ = {0}; dest->valid = self->valid; - dest->details = (playlist_details_copy (&self->details, &_tmp0_), _tmp0_); + playlist_details_copy (&self->details, &_tmp0_); + dest->details = _tmp0_; } void active_playlist_container_destroy (ActivePlaylistContainer* self) { - playlist_details_destroy (&self->details); + playlist_details_destroy (&(*self).details); } diff --git a/src/mpris2-watcher.c b/src/mpris2-watcher.c index f93a528..f22c63c 100644 --- a/src/mpris2-watcher.c +++ b/src/mpris2-watcher.c @@ -1,4 +1,4 @@ -/* mpris2-watcher.c generated by valac 0.11.6, the Vala compiler +/* mpris2-watcher.c generated by valac 0.11.7, the Vala compiler * generated from mpris2-watcher.vala, do not modify */ /* @@ -125,20 +125,19 @@ struct _Mpris2WatcherCheckForActiveClientsData { gchar** _tmp2_; gint _tmp2__length1; gint __tmp2__size_; - gchar** _tmp3_; GError * e; gchar** address_collection; int address_collection_length1; int address_it; - gchar* _tmp4_; + gchar* _tmp3_; gchar* address; - gboolean _tmp5_; - MprisRoot* _tmp6_; + gboolean _tmp4_; + MprisRoot* _tmp5_; MprisRoot* mpris2_root; - gboolean _tmp7_; + gboolean _tmp6_; gboolean use_playlists; + gchar* _tmp7_; gchar* _tmp8_; - gchar* _tmp9_; GError * _inner_error_; }; @@ -271,11 +270,10 @@ static gboolean mpris2_watcher_check_for_active_clients_co (Mpris2WatcherCheckFo g_clear_error (&data->_inner_error_); return FALSE; } - data->_tmp3_ = data->_tmp2_; data->interfaces = (_vala_array_free (data->interfaces, data->interfaces_length1, (GDestroyNotify) g_free), NULL); + data->interfaces = data->_tmp2_; data->interfaces_length1 = data->_tmp2__length1; - data->_interfaces_size_ = data->interfaces_length1; - data->interfaces = data->_tmp3_; + data->_interfaces_size_ = data->__tmp2__size_; goto __finally7; __catch7_g_io_error: { @@ -304,14 +302,14 @@ static gboolean mpris2_watcher_check_for_active_clients_co (Mpris2WatcherCheckFo data->address_collection = data->interfaces; data->address_collection_length1 = data->interfaces_length1; for (data->address_it = 0; data->address_it < data->interfaces_length1; data->address_it = data->address_it + 1) { - data->_tmp4_ = g_strdup (data->address_collection[data->address_it]); - data->address = data->_tmp4_; + data->_tmp3_ = g_strdup (data->address_collection[data->address_it]); + data->address = data->_tmp3_; { - data->_tmp5_ = g_str_has_prefix (data->address, MPRIS_PREFIX); - if (data->_tmp5_) { - data->_tmp6_ = NULL; - data->_tmp6_ = mpris2_watcher_create_mpris_root (data->self, data->address); - data->mpris2_root = data->_tmp6_; + data->_tmp4_ = g_str_has_prefix (data->address, MPRIS_PREFIX); + if (data->_tmp4_) { + data->_tmp5_ = NULL; + data->_tmp5_ = mpris2_watcher_create_mpris_root (data->self, data->address); + data->mpris2_root = data->_tmp5_; if (data->mpris2_root == NULL) { _g_object_unref0 (data->mpris2_root); _g_free0 (data->address); @@ -324,13 +322,13 @@ static gboolean mpris2_watcher_check_for_active_clients_co (Mpris2WatcherCheckFo g_object_unref (data->_async_result); return FALSE; } - data->_tmp7_ = mpris2_watcher_supports_playlists (data->self, data->address); - data->use_playlists = data->_tmp7_; - data->_tmp8_ = NULL; - data->_tmp8_ = mpris_root_get_DesktopEntry (data->mpris2_root); - data->_tmp9_ = data->_tmp8_; - g_signal_emit_by_name (data->self, "client-appeared", data->_tmp9_, data->address, data->use_playlists); - _g_free0 (data->_tmp9_); + data->_tmp6_ = mpris2_watcher_supports_playlists (data->self, data->address); + data->use_playlists = data->_tmp6_; + data->_tmp7_ = NULL; + data->_tmp7_ = mpris_root_get_DesktopEntry (data->mpris2_root); + data->_tmp8_ = data->_tmp7_; + g_signal_emit_by_name (data->self, "client-appeared", data->_tmp8_, data->address, data->use_playlists); + _g_free0 (data->_tmp8_); _g_object_unref0 (data->mpris2_root); } _g_free0 (data->address); @@ -408,7 +406,6 @@ static MprisRoot* mpris2_watcher_create_mpris_root (Mpris2Watcher* self, const g if (_tmp0_) { MprisRoot* _tmp1_ = NULL; MprisRoot* _tmp2_; - MprisRoot* _tmp3_; _tmp1_ = g_initable_new (TYPE_MPRIS_ROOT_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", name, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", MPRIS_MEDIA_PLAYER_PATH, "g-interface-name", "org.mpris.MediaPlayer2", NULL); _tmp2_ = (MprisRoot*) _tmp1_; if (_inner_error_ != NULL) { @@ -420,9 +417,8 @@ static MprisRoot* mpris2_watcher_create_mpris_root (Mpris2Watcher* self, const g g_clear_error (&_inner_error_); return NULL; } - _tmp3_ = _tmp2_; _g_object_unref0 (mpris2_root); - mpris2_root = _tmp3_; + mpris2_root = _tmp2_; goto __finally8; __catch8_g_io_error: { @@ -451,10 +447,9 @@ static gboolean mpris2_watcher_supports_playlists (Mpris2Watcher* self, const gc FreeDesktopIntrospectable* introspectable = NULL; FreeDesktopIntrospectable* _tmp0_ = NULL; FreeDesktopIntrospectable* _tmp1_; - FreeDesktopIntrospectable* _tmp2_; - gchar* _tmp3_ = NULL; + gchar* _tmp2_ = NULL; gchar* results; - gboolean _tmp4_; + gboolean _tmp3_; GError * _inner_error_ = NULL; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (name != NULL, FALSE); @@ -469,11 +464,10 @@ static gboolean mpris2_watcher_supports_playlists (Mpris2Watcher* self, const gc g_clear_error (&_inner_error_); return FALSE; } - _tmp2_ = _tmp1_; _g_object_unref0 (introspectable); - introspectable = _tmp2_; - _tmp3_ = free_desktop_introspectable_Introspect (introspectable, &_inner_error_); - results = _tmp3_; + introspectable = _tmp1_; + _tmp2_ = free_desktop_introspectable_Introspect (introspectable, &_inner_error_); + results = _tmp2_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { goto __catch9_g_io_error; @@ -483,8 +477,8 @@ static gboolean mpris2_watcher_supports_playlists (Mpris2Watcher* self, const gc g_clear_error (&_inner_error_); return FALSE; } - _tmp4_ = mpris2_watcher_parse_interfaces (self, results); - result = _tmp4_; + _tmp3_ = mpris2_watcher_parse_interfaces (self, results); + result = _tmp3_; _g_free0 (results); _g_object_unref0 (introspectable); return result; @@ -567,7 +561,9 @@ static gboolean mpris2_watcher_parse_interfaces (Mpris2Watcher* self, const gcha g_debug ("mpris2-watcher.vala:163: this dbus object has interface %s ", interface_name); _tmp4_ = g_strconcat (MPRIS_PREFIX, "Playlists", NULL); _tmp5_ = _tmp4_; - if ((_tmp6_ = g_strcmp0 (interface_name, _tmp5_) == 0, _g_free0 (_tmp5_), _tmp6_)) { + _tmp6_ = g_strcmp0 (interface_name, _tmp5_) == 0; + _g_free0 (_tmp5_); + if (_tmp6_) { _result_ = TRUE; } _g_free0 (interface_name); @@ -610,7 +606,6 @@ static GObject * mpris2_watcher_constructor (GType type, guint n_construct_prope Mpris2Watcher * self; FreeDesktopObject* _tmp0_ = NULL; FreeDesktopObject* _tmp1_; - FreeDesktopObject* _tmp2_; GError * _inner_error_ = NULL; parent_class = G_OBJECT_CLASS (mpris2_watcher_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); @@ -624,9 +619,8 @@ static GObject * mpris2_watcher_constructor (GType type, guint n_construct_prope g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); } - _tmp2_ = _tmp1_; _g_object_unref0 (self->priv->fdesktop_obj); - self->priv->fdesktop_obj = _tmp2_; + self->priv->fdesktop_obj = _tmp1_; g_signal_connect_object (self->priv->fdesktop_obj, "name-owner-changed", (GCallback) _mpris2_watcher_name_changes_detected_free_desktop_object_name_owner_changed, self, 0); mpris2_watcher_check_for_active_clients (self, NULL, NULL); goto __finally10; diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c index dc04230..7c652a1 100644 --- a/src/music-player-bridge.c +++ b/src/music-player-bridge.c @@ -1,4 +1,4 @@ -/* music-player-bridge.c generated by valac 0.11.6, the Vala compiler +/* music-player-bridge.c generated by valac 0.11.7, the Vala compiler * generated from music-player-bridge.vala, do not modify */ /* @@ -173,9 +173,9 @@ void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, c gchar** settings_manager_fetch_blacklist (SettingsManager* self, int* result_length1); static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle); void settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name); +static gboolean* _bool_dup (gboolean* self); GType player_item_get_type (void) G_GNUC_CONST; GType mpris2_controller_get_type (void) G_GNUC_CONST; -static gboolean* _bool_dup (gboolean* self); void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); void player_controller_activate (PlayerController* self, const gchar* dbus_name); void music_player_bridge_client_has_vanished (MusicPlayerBridge* self, const gchar* mpris_root_interface); @@ -290,7 +290,9 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye _tmp3_ = g_strconcat (desktop, ".desktop", NULL); _tmp4_ = _tmp3_; _tmp5_ = music_player_bridge_create_app_info (_tmp4_); - app_info = (_tmp6_ = _tmp5_, _g_free0 (_tmp4_), _tmp6_); + _tmp6_ = _tmp5_; + _g_free0 (_tmp4_); + app_info = _tmp6_; if (app_info == NULL) { g_warning ("music-player-bridge.vala:65: Could not create app_info for path %s \n" \ " Getting out of here ", desktop); @@ -305,7 +307,9 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye _tmp10_ = _tmp9_; _tmp11_ = music_player_bridge_calculate_menu_position (self); _tmp12_ = player_controller_new (self->priv->root_menu, app_info, NULL, _tmp10_, _tmp11_, NULL, PLAYER_CONTROLLER_STATE_OFFLINE); - ctrl = (_tmp13_ = _tmp12_, _g_free0 (_tmp10_), _tmp13_); + _tmp13_ = _tmp12_; + _g_free0 (_tmp10_); + ctrl = _tmp13_; gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, mpris_key, ctrl); _g_object_unref0 (ctrl); _g_free0 (mpris_key); @@ -390,7 +394,9 @@ void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, c _tmp2_ = settings_manager_fetch_blacklist (self->priv->settings_manager, &_tmp1_); _tmp3_ = _tmp2_; _tmp3__length1 = _tmp1_; - if ((_tmp4_ = _vala_string_array_contains (_tmp3_, _tmp1_, desktop), _tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL), _tmp4_)) { + _tmp4_ = _vala_string_array_contains (_tmp3_, _tmp1_, desktop); + _tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL); + if (_tmp4_) { g_debug ("music-player-bridge.vala:101: Client %s attempting to register but I'm" \ " afraid it is blacklisted", desktop); return; @@ -399,7 +405,9 @@ void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, c _tmp5_ = g_strconcat (desktop, ".desktop", NULL); _tmp6_ = _tmp5_; _tmp7_ = music_player_bridge_create_app_info (_tmp6_); - app_info = (_tmp8_ = _tmp7_, _g_free0 (_tmp6_), _tmp8_); + _tmp8_ = _tmp7_; + _g_free0 (_tmp6_); + app_info = _tmp8_; if (app_info == NULL) { g_warning ("music-player-bridge.vala:109: Could not create app_info for path %s \n" \ " Getting out of here ", desktop); @@ -423,7 +431,9 @@ void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, c _tmp13_ = _tmp12_; _tmp14_ = music_player_bridge_calculate_menu_position (self); _tmp15_ = player_controller_new (self->priv->root_menu, app_info, dbus_name, _tmp13_, _tmp14_, &use_playlists, PLAYER_CONTROLLER_STATE_READY); - ctrl = (_tmp16_ = _tmp15_, _g_free0 (_tmp13_), _tmp16_); + _tmp16_ = _tmp15_; + _g_free0 (_tmp13_); + ctrl = _tmp16_; gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, mpris_key, ctrl); g_debug ("music-player-bridge.vala:126: Have not seen this %s before, new contro" \ "ller created.", desktop); @@ -434,26 +444,24 @@ void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, c gpointer _tmp17_ = NULL; PlayerController* _tmp18_; gboolean* _tmp19_; - gboolean* _tmp20_; - gpointer _tmp21_ = NULL; - PlayerController* _tmp22_; - gpointer _tmp23_ = NULL; - PlayerController* _tmp24_; + gpointer _tmp20_ = NULL; + PlayerController* _tmp21_; + gpointer _tmp22_ = NULL; + PlayerController* _tmp23_; _tmp17_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); _tmp18_ = (PlayerController*) _tmp17_; _tmp19_ = __bool_dup0 (&use_playlists); - _tmp20_ = _tmp19_; _g_free0 (_tmp18_->use_playlists); - _tmp18_->use_playlists = _tmp20_; + _tmp18_->use_playlists = _tmp19_; _g_object_unref0 (_tmp18_); - _tmp21_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); - _tmp22_ = (PlayerController*) _tmp21_; - player_controller_update_state (_tmp22_, PLAYER_CONTROLLER_STATE_READY); - _g_object_unref0 (_tmp22_); - _tmp23_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); - _tmp24_ = (PlayerController*) _tmp23_; - player_controller_activate (_tmp24_, dbus_name); - _g_object_unref0 (_tmp24_); + _tmp20_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + _tmp21_ = (PlayerController*) _tmp20_; + player_controller_update_state (_tmp21_, PLAYER_CONTROLLER_STATE_READY); + _g_object_unref0 (_tmp21_); + _tmp22_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + _tmp23_ = (PlayerController*) _tmp22_; + player_controller_activate (_tmp23_, dbus_name); + _g_object_unref0 (_tmp23_); g_debug ("music-player-bridge.vala:134: Application has already registered - awa" \ "ken the hibernation: %s \n", dbus_name); } @@ -514,20 +522,16 @@ static void _music_player_bridge_client_has_vanished_mpris2_watcher_client_disap void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu) { DbusmenuMenuitem* _tmp0_; - DbusmenuMenuitem* _tmp1_; - Mpris2Watcher* _tmp2_ = NULL; - Mpris2Watcher* _tmp3_; + Mpris2Watcher* _tmp1_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (menu != NULL); _tmp0_ = _g_object_ref0 (menu); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->root_menu); - self->priv->root_menu = _tmp1_; + self->priv->root_menu = _tmp0_; music_player_bridge_try_to_add_inactive_familiar_clients (self); - _tmp2_ = mpris2_watcher_new (); - _tmp3_ = _tmp2_; + _tmp1_ = mpris2_watcher_new (); _g_object_unref0 (self->priv->watcher); - self->priv->watcher = _tmp3_; + self->priv->watcher = _tmp1_; g_signal_connect_object (self->priv->watcher, "client-appeared", (GCallback) _music_player_bridge_client_has_become_available_mpris2_watcher_client_appeared, self, 0); g_signal_connect_object (self->priv->watcher, "client-disappeared", (GCallback) _music_player_bridge_client_has_vanished_mpris2_watcher_client_disappeared, self, 0); } @@ -556,7 +560,8 @@ static GAppInfo* music_player_bridge_create_app_info (const gchar* desktop) { _g_object_unref0 (info); return result; } - _tmp3_ = _g_object_ref0 ((_tmp2_ = info, G_IS_APP_INFO (_tmp2_) ? ((GAppInfo*) _tmp2_) : NULL)); + _tmp2_ = info; + _tmp3_ = _g_object_ref0 (G_IS_APP_INFO (_tmp2_) ? ((GAppInfo*) _tmp2_) : NULL); app_info = _tmp3_; result = app_info; _g_object_unref0 (info); @@ -581,7 +586,9 @@ static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop) { _tmp0_ = g_strconcat (desktop, ".desktop", NULL); _tmp1_ = _tmp0_; _tmp2_ = g_desktop_app_info_new (_tmp1_); - info = (_tmp3_ = _tmp2_, _g_free0 (_tmp1_), _tmp3_); + _tmp3_ = _tmp2_; + _g_free0 (_tmp1_); + info = _tmp3_; _tmp4_ = g_key_file_new (); desktop_keyfile = _tmp4_; _tmp5_ = g_desktop_app_info_get_filename (info); @@ -681,8 +688,8 @@ static gchar* music_player_bridge_determine_key (gchar* desktop_or_interface) { gchar** tokens; gint tokens_length1; gint _tokens_size_; - gchar** _tmp5_; - gchar** _tmp6_ = NULL; + gchar** _tmp4_; + gchar** _tmp5_ = NULL; gchar** temp; gint temp_length1; gint _temp_size_; @@ -695,23 +702,19 @@ static gchar* music_player_bridge_determine_key (gchar* desktop_or_interface) { _tokens_size_ = _vala_array_length (_tmp1_); if (tokens_length1 > 1) { gchar* _tmp3_; - gchar* _tmp4_; _tmp3_ = g_strdup (tokens[tokens_length1 - 1]); - _tmp4_ = _tmp3_; _g_free0 (_result_); - _result_ = _tmp4_; + _result_ = _tmp3_; } - _tmp6_ = _tmp5_ = g_strsplit (_result_, "-", 0); - temp = _tmp6_; - temp_length1 = _vala_array_length (_tmp5_); - _temp_size_ = _vala_array_length (_tmp5_); + _tmp5_ = _tmp4_ = g_strsplit (_result_, "-", 0); + temp = _tmp5_; + temp_length1 = _vala_array_length (_tmp4_); + _temp_size_ = _vala_array_length (_tmp4_); if (temp_length1 > 1) { - gchar* _tmp7_; - gchar* _tmp8_; - _tmp7_ = g_strdup (temp[0]); - _tmp8_ = _tmp7_; + gchar* _tmp6_; + _tmp6_ = g_strdup (temp[0]); _g_free0 (_result_); - _result_ = _tmp8_; + _result_ = _tmp6_; } g_debug ("music-player-bridge.vala:218: determine key result = %s", _result_); result = _result_; @@ -731,20 +734,16 @@ static GObject * music_player_bridge_constructor (GType type, guint n_construct_ GObjectClass * parent_class; MusicPlayerBridge * self; GeeHashMap* _tmp0_ = NULL; - GeeHashMap* _tmp1_; - SettingsManager* _tmp2_ = NULL; - SettingsManager* _tmp3_; + SettingsManager* _tmp1_ = NULL; parent_class = G_OBJECT_CLASS (music_player_bridge_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = MUSIC_PLAYER_BRIDGE (obj); _tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, TYPE_PLAYER_CONTROLLER, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->registered_clients); - self->priv->registered_clients = _tmp1_; - _tmp2_ = settings_manager_new (); - _tmp3_ = _tmp2_; + self->priv->registered_clients = _tmp0_; + _tmp1_ = settings_manager_new (); _g_object_unref0 (self->priv->settings_manager); - self->priv->settings_manager = _tmp3_; + self->priv->settings_manager = _tmp1_; g_signal_connect_object (self->priv->settings_manager, "blacklist-updates", (GCallback) _music_player_bridge_on_blacklist_update_settings_manager_blacklist_updates, self, 0); return obj; } diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h index 5301177..857e220 100644 --- a/src/music-player-bridge.h +++ b/src/music-player-bridge.h @@ -1,4 +1,4 @@ -/* music-player-bridge.h generated by valac 0.11.6, the Vala compiler, do not modify */ +/* music-player-bridge.h generated by valac 0.11.7, the Vala compiler, do not modify */ #ifndef __MUSIC_PLAYER_BRIDGE_H__ diff --git a/src/player-controller.c b/src/player-controller.c index f0d5d60..2eb7992 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -1,4 +1,4 @@ -/* player-controller.c generated by valac 0.11.6, the Vala compiler +/* player-controller.c generated by valac 0.11.7, the Vala compiler * generated from player-controller.vala, do not modify */ /* @@ -283,30 +283,24 @@ static gpointer _g_object_ref0 (gpointer self) { PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, gboolean* use_playlists, PlayerControllerstate initial_state) { PlayerController * self = NULL; gboolean* _tmp0_; - gboolean* _tmp1_; - DbusmenuMenuitem* _tmp2_; - DbusmenuMenuitem* _tmp3_; - GeeArrayList* _tmp4_ = NULL; - GeeArrayList* _tmp5_; + DbusmenuMenuitem* _tmp1_; + GeeArrayList* _tmp2_ = NULL; g_return_val_if_fail (root != NULL, NULL); g_return_val_if_fail (app != NULL, NULL); g_return_val_if_fail (icon_name != NULL, NULL); self = (PlayerController*) g_object_new (object_type, NULL); _tmp0_ = __bool_dup0 (use_playlists); - _tmp1_ = _tmp0_; _g_free0 (self->use_playlists); - self->use_playlists = _tmp1_; - _tmp2_ = _g_object_ref0 (root); - _tmp3_ = _tmp2_; + self->use_playlists = _tmp0_; + _tmp1_ = _g_object_ref0 (root); _g_object_unref0 (self->priv->root_menu); - self->priv->root_menu = _tmp3_; + self->priv->root_menu = _tmp1_; player_controller_set_app_info (self, app); player_controller_set_dbus_name (self, dbus_name); player_controller_set_icon_name (self, icon_name); - _tmp4_ = gee_array_list_new (TYPE_PLAYER_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); - _tmp5_ = _tmp4_; + _tmp2_ = gee_array_list_new (TYPE_PLAYER_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); _g_object_unref0 (self->custom_items); - self->custom_items = _tmp5_; + self->custom_items = _tmp2_; self->current_state = (gint) initial_state; player_controller_set_menu_offset (self, offset); player_controller_construct_widgets (self); @@ -393,7 +387,6 @@ static void player_controller_establish_mpris_connection (PlayerController* self gchar* _tmp1_ = NULL; gchar* _tmp2_; Mpris2Controller* _tmp3_ = NULL; - Mpris2Controller* _tmp4_; g_return_if_fail (self != NULL); if (self->current_state != PLAYER_CONTROLLER_STATE_READY) { _tmp0_ = TRUE; @@ -411,9 +404,8 @@ static void player_controller_establish_mpris_connection (PlayerController* self "s value = %s ", _tmp2_); _g_free0 (_tmp2_); _tmp3_ = mpris2_controller_new (self); - _tmp4_ = _tmp3_; _g_object_unref0 (self->mpris_bridge); - self->mpris_bridge = _tmp4_; + self->mpris_bridge = _tmp3_; player_controller_determine_state (self); } @@ -460,12 +452,14 @@ void player_controller_remove_from_menu (PlayerController* self) { } _g_object_unref0 (_item_list); } - if (_bool_equal (self->use_playlists, (_tmp3_ = TRUE, &_tmp3_)) == TRUE) { + _tmp3_ = TRUE; + if (_bool_equal (self->use_playlists, &_tmp3_) == TRUE) { gpointer _tmp4_ = NULL; PlayerItem* _tmp5_; PlaylistsMenuitem* playlists_menuitem; _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); - playlists_menuitem = (_tmp5_ = (PlayerItem*) _tmp4_, IS_PLAYLISTS_MENUITEM (_tmp5_) ? ((PlaylistsMenuitem*) _tmp5_) : NULL); + _tmp5_ = (PlayerItem*) _tmp4_; + playlists_menuitem = IS_PLAYLISTS_MENUITEM (_tmp5_) ? ((PlaylistsMenuitem*) _tmp5_) : NULL; dbusmenu_menuitem_child_delete (self->priv->root_menu, playlists_menuitem->root_item); _g_object_unref0 (playlists_menuitem); } @@ -484,7 +478,6 @@ void player_controller_hibernate (PlayerController* self) { gpointer _tmp8_ = NULL; PlayerItem* _tmp9_; TitleMenuitem* title; - Mpris2Controller* _tmp10_; g_return_if_fail (self != NULL); player_controller_update_state (self, PLAYER_CONTROLLER_STATE_OFFLINE); _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); @@ -502,11 +495,11 @@ void player_controller_hibernate (PlayerController* self) { _g_object_unref0 (_tmp7_); _g_object_unref0 (_tmp5_); _tmp8_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); - title = (_tmp9_ = (PlayerItem*) _tmp8_, IS_TITLE_MENUITEM (_tmp9_) ? ((TitleMenuitem*) _tmp9_) : NULL); + _tmp9_ = (PlayerItem*) _tmp8_; + title = IS_TITLE_MENUITEM (_tmp9_) ? ((TitleMenuitem*) _tmp9_) : NULL; title_menuitem_toggle_active_triangle (title, FALSE); - _tmp10_ = NULL; _g_object_unref0 (self->mpris_bridge); - self->mpris_bridge = _tmp10_; + self->mpris_bridge = NULL; _g_object_unref0 (title); } @@ -526,7 +519,8 @@ void player_controller_update_layout (PlayerController* self) { PlayerItem* _tmp14_; g_return_if_fail (self != NULL); _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); - playlists_menuitem = (_tmp1_ = (PlayerItem*) _tmp0_, IS_PLAYLISTS_MENUITEM (_tmp1_) ? ((PlaylistsMenuitem*) _tmp1_) : NULL); + _tmp1_ = (PlayerItem*) _tmp0_; + playlists_menuitem = IS_PLAYLISTS_MENUITEM (_tmp1_) ? ((PlaylistsMenuitem*) _tmp1_) : NULL; if (self->current_state != PLAYER_CONTROLLER_STATE_CONNECTED) { gpointer _tmp2_ = NULL; PlayerItem* _tmp3_; @@ -623,7 +617,8 @@ static void player_controller_construct_widgets (PlayerController* self) { PlaylistsMenuitem* _tmp12_; PlaylistsMenuitem* playlists_menuitem; gint _tmp13_; - _tmp12_ = _g_object_ref0 ((_tmp11_ = item, IS_PLAYLISTS_MENUITEM (_tmp11_) ? ((PlaylistsMenuitem*) _tmp11_) : NULL)); + _tmp11_ = item; + _tmp12_ = _g_object_ref0 (IS_PLAYLISTS_MENUITEM (_tmp11_) ? ((PlaylistsMenuitem*) _tmp11_) : NULL); playlists_menuitem = _tmp12_; _tmp13_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item); dbusmenu_menuitem_child_add_position (self->priv->root_menu, playlists_menuitem->root_item, (guint) (self->priv->_menu_offset + _tmp13_)); @@ -650,7 +645,8 @@ static void player_controller_determine_state (PlayerController* self) { TitleMenuitem* title; player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED); _tmp1_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); - title = (_tmp2_ = (PlayerItem*) _tmp1_, IS_TITLE_MENUITEM (_tmp2_) ? ((TitleMenuitem*) _tmp2_) : NULL); + _tmp2_ = (PlayerItem*) _tmp1_; + title = IS_TITLE_MENUITEM (_tmp2_) ? ((TitleMenuitem*) _tmp2_) : NULL; title_menuitem_toggle_active_triangle (title, TRUE); mpris2_controller_initial_update (self->mpris_bridge); _g_object_unref0 (title); @@ -670,12 +666,10 @@ const gchar* player_controller_get_dbus_name (PlayerController* self) { void player_controller_set_dbus_name (PlayerController* self, const gchar* value) { gchar* _tmp0_; - gchar* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = g_strdup (value); - _tmp1_ = _tmp0_; _g_free0 (self->priv->_dbus_name); - self->priv->_dbus_name = _tmp1_; + self->priv->_dbus_name = _tmp0_; g_object_notify ((GObject *) self, "dbus-name"); } @@ -690,12 +684,10 @@ GAppInfo* player_controller_get_app_info (PlayerController* self) { void player_controller_set_app_info (PlayerController* self, GAppInfo* value) { GAppInfo* _tmp0_; - GAppInfo* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->_app_info); - self->priv->_app_info = _tmp1_; + self->priv->_app_info = _tmp0_; g_object_notify ((GObject *) self, "app-info"); } @@ -725,12 +717,10 @@ const gchar* player_controller_get_icon_name (PlayerController* self) { void player_controller_set_icon_name (PlayerController* self, const gchar* value) { gchar* _tmp0_; - gchar* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = g_strdup (value); - _tmp1_ = _tmp0_; _g_free0 (self->priv->_icon_name); - self->priv->_icon_name = _tmp1_; + self->priv->_icon_name = _tmp0_; g_object_notify ((GObject *) self, "icon-name"); } diff --git a/src/player-item.c b/src/player-item.c index 01286a7..6133279 100644 --- a/src/player-item.c +++ b/src/player-item.c @@ -1,4 +1,4 @@ -/* player-item.c generated by valac 0.11.6, the Vala compiler +/* player-item.c generated by valac 0.11.7, the Vala compiler * generated from player-item.vala, do not modify */ /* @@ -254,7 +254,8 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu PlayerItem* _tmp12_; MetadataMenuitem* _tmp13_; MetadataMenuitem* metadata; - _tmp13_ = _g_object_ref0 ((_tmp12_ = self, IS_METADATA_MENUITEM (_tmp12_) ? ((MetadataMenuitem*) _tmp12_) : NULL)); + _tmp12_ = self; + _tmp13_ = _g_object_ref0 (IS_METADATA_MENUITEM (_tmp12_) ? ((MetadataMenuitem*) _tmp12_) : NULL); metadata = _tmp13_; metadata_menuitem_fetch_art (metadata, update, property); _g_object_unref0 (metadata); @@ -350,12 +351,10 @@ PlayerController* player_item_get_owner (PlayerItem* self) { static void player_item_set_owner (PlayerItem* self, PlayerController* value) { PlayerController* _tmp0_; - PlayerController* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->_owner); - self->priv->_owner = _tmp1_; + self->priv->_owner = _tmp0_; g_object_notify ((GObject *) self, "owner"); } @@ -370,12 +369,10 @@ const gchar* player_item_get_item_type (PlayerItem* self) { static void player_item_set_item_type (PlayerItem* self, const gchar* value) { gchar* _tmp0_; - gchar* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = g_strdup (value); - _tmp1_ = _tmp0_; _g_free0 (self->priv->_item_type); - self->priv->_item_type = _tmp1_; + self->priv->_item_type = _tmp0_; g_object_notify ((GObject *) self, "item-type"); } diff --git a/src/playlists-menu-item.c b/src/playlists-menu-item.c index b8ea942..ced54cf 100644 --- a/src/playlists-menu-item.c +++ b/src/playlists-menu-item.c @@ -1,4 +1,4 @@ -/* playlists-menu-item.c generated by valac 0.11.6, the Vala compiler +/* playlists-menu-item.c generated by valac 0.11.7, the Vala compiler * generated from playlists-menu-item.vala, do not modify */ /* @@ -33,6 +33,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <common-defs.h> #include <stdlib.h> #include <string.h> +#include <glib/gi18n-lib.h> #include <gio/gio.h> @@ -225,7 +226,8 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli PlaylistDetails _tmp0_; PlaylistDetails _tmp1_ = {0}; PlaylistDetails detail; - _tmp0_ = (playlist_details_copy (&detail_collection[detail_it], &_tmp1_), _tmp1_); + playlist_details_copy (&detail_collection[detail_it], &_tmp1_); + _tmp0_ = _tmp1_; detail = _tmp0_; { Block1Data* _data1_; @@ -275,7 +277,9 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli _tmp6_ = gee_map_get_values ((GeeMap*) self->priv->current_playlists); _tmp7_ = _tmp6_; _tmp8_ = gee_iterable_iterator ((GeeIterable*) _tmp7_); - _item_it = (_tmp9_ = _tmp8_, _g_object_unref0 (_tmp7_), _tmp9_); + _tmp9_ = _tmp8_; + _g_object_unref0 (_tmp7_); + _item_it = _tmp9_; while (TRUE) { gboolean _tmp10_; gpointer _tmp11_ = NULL; @@ -298,7 +302,8 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli PlaylistDetails _tmp12_; PlaylistDetails _tmp13_ = {0}; PlaylistDetails detail; - _tmp12_ = (playlist_details_copy (&detail_collection[detail_it], &_tmp13_), _tmp13_); + playlist_details_copy (&detail_collection[detail_it], &_tmp13_); + _tmp12_ = _tmp13_; detail = _tmp12_; { const gchar* _tmp14_ = NULL; @@ -318,7 +323,9 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli _tmp15_ = dbusmenu_menuitem_property_get (self->root_item, DBUSMENU_PLAYLIST_MENUITEM_PATH); _tmp16_ = dbusmenu_menuitem_property_get (item, DBUSMENU_PLAYLIST_MENUITEM_PATH); if (g_strcmp0 (_tmp15_, _tmp16_) == 0) { - dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, "Choose Playlist"); + const gchar* _tmp17_ = NULL; + _tmp17_ = _ ("Choose Playlist"); + dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, _tmp17_); } dbusmenu_menuitem_child_delete (self->root_item, item); } @@ -354,7 +361,9 @@ static gchar* playlists_menuitem_parse_icon_path (PlaylistsMenuitem* self, const icon_file = _tmp0_; _tmp1_ = g_file_get_path (icon_file); _tmp2_ = _tmp1_; - if ((_tmp3_ = _tmp2_ == NULL, _g_free0 (_tmp2_), _tmp3_)) { + _tmp3_ = _tmp2_ == NULL; + _g_free0 (_tmp2_); + if (_tmp3_) { result = NULL; _g_object_unref0 (icon_file); return result; @@ -365,7 +374,10 @@ static gchar* playlists_menuitem_parse_icon_path (PlaylistsMenuitem* self, const _tmp8_ = _tmp7_; _tmp8__length1 = _vala_array_length (_tmp6_); _tmp9_ = g_strdup (_tmp8_[0]); - result = (_tmp10_ = _tmp9_, _tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL), _g_free0 (_tmp5_), _tmp10_); + _tmp10_ = _tmp9_; + _tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL); + _g_free0 (_tmp5_); + result = _tmp10_; _g_object_unref0 (icon_file); return result; } @@ -383,7 +395,9 @@ void playlists_menuitem_update_individual_playlist (PlaylistsMenuitem* self, Pla _tmp0_ = gee_map_get_values ((GeeMap*) self->priv->current_playlists); _tmp1_ = _tmp0_; _tmp2_ = gee_iterable_iterator ((GeeIterable*) _tmp1_); - _item_it = (_tmp3_ = _tmp2_, _g_object_unref0 (_tmp1_), _tmp3_); + _tmp3_ = _tmp2_; + _g_object_unref0 (_tmp1_); + _item_it = _tmp3_; while (TRUE) { gboolean _tmp4_; gpointer _tmp5_ = NULL; @@ -430,7 +444,9 @@ static gboolean playlists_menuitem_already_observed (PlaylistsMenuitem* self, Pl _tmp0_ = gee_map_get_values ((GeeMap*) self->priv->current_playlists); _tmp1_ = _tmp0_; _tmp2_ = gee_iterable_iterator ((GeeIterable*) _tmp1_); - _item_it = (_tmp3_ = _tmp2_, _g_object_unref0 (_tmp1_), _tmp3_); + _tmp3_ = _tmp2_; + _g_object_unref0 (_tmp1_); + _item_it = _tmp3_; while (TRUE) { gboolean _tmp4_; gpointer _tmp5_ = NULL; @@ -471,10 +487,10 @@ void playlists_menuitem_active_playlist_update (PlaylistsMenuitem* self, Playlis _tmp0_ = g_strdup ((*detail).name); update = _tmp0_; if (g_strcmp0 (update, "") == 0) { - gchar* _tmp1_; + const gchar* _tmp1_ = NULL; gchar* _tmp2_; - _tmp1_ = g_strdup ("Choose Playlist"); - _tmp2_ = _tmp1_; + _tmp1_ = _ ("Choose Playlist"); + _tmp2_ = g_strdup (_tmp1_); _g_free0 (update); update = _tmp2_; } @@ -493,7 +509,7 @@ static void playlists_menuitem_submenu_item_activated (PlaylistsMenuitem* self, g_return_if_fail (self != NULL); _tmp0_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->current_playlists, GINT_TO_POINTER (menu_item_id)); if (!_tmp0_) { - g_warning ("playlists-menu-item.vala:129: item %i was activated but we don't have " \ + g_warning ("playlists-menu-item.vala:133: item %i was activated but we don't have " \ "a corresponding playlist", menu_item_id); return; } @@ -524,21 +540,19 @@ static GObject * playlists_menuitem_constructor (GType type, guint n_construct_p GObjectClass * parent_class; PlaylistsMenuitem * self; GeeHashMap* _tmp0_ = NULL; - GeeHashMap* _tmp1_; - DbusmenuMenuitem* _tmp2_ = NULL; - DbusmenuMenuitem* _tmp3_; + DbusmenuMenuitem* _tmp1_ = NULL; + const gchar* _tmp2_ = NULL; parent_class = G_OBJECT_CLASS (playlists_menuitem_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = PLAYLISTS_MENUITEM (obj); _tmp0_ = gee_hash_map_new (G_TYPE_INT, NULL, NULL, DBUSMENU_TYPE_MENUITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->current_playlists); - self->priv->current_playlists = _tmp1_; - _tmp2_ = dbusmenu_menuitem_new (); - _tmp3_ = _tmp2_; + self->priv->current_playlists = _tmp0_; + _tmp1_ = dbusmenu_menuitem_new (); _g_object_unref0 (self->root_item); - self->root_item = _tmp3_; - dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, "Choose Playlist"); + self->root_item = _tmp1_; + _tmp2_ = _ ("Choose Playlist"); + dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, _tmp2_); dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_PLAYLIST_MENUITEM_PATH, ""); return obj; } diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 98d18f4..79ab506 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -17,11 +17,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +using Config; using Dbusmenu; using DbusmenuPlaylists; using DbusmenuPlaylist; using Gee; + public class PlaylistsMenuitem : PlayerItem { private HashMap<int, Dbusmenu.Menuitem> current_playlists; @@ -31,12 +33,14 @@ public class PlaylistsMenuitem : PlayerItem { Object ( item_type: MENUITEM_TYPE, owner: parent ); } + construct{ this.current_playlists = new HashMap<int, Dbusmenu.Menuitem>(); this.root_item = new Menuitem(); - this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" ); + this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Choose Playlist") ); this.root_item.property_set ( MENUITEM_PATH, "" ); + } public new void update (PlaylistDetails[] playlists) @@ -74,7 +78,7 @@ public class PlaylistsMenuitem : PlayerItem } if (within == false){ if (this.root_item.property_get (MENUITEM_PATH) == item.property_get (MENUITEM_PATH)){ - this.root_item.property_set (MENUITEM_PROP_LABEL, "Choose Playlist"); + this.root_item.property_set (MENUITEM_PROP_LABEL, _("Choose Playlist")); } this.root_item.child_delete (item); } @@ -118,7 +122,7 @@ public class PlaylistsMenuitem : PlayerItem public void active_playlist_update (PlaylistDetails detail) { var update = detail.name; - if ( update == "" ) update = "Choose Playlist"; + if ( update == "" ) update = _("Choose Playlist"); this.root_item.property_set (MENUITEM_PROP_LABEL, update); this.root_item.property_set (MENUITEM_PATH, detail.path); } diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index 6d11221..95f4c06 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -68,7 +68,7 @@ static void pm_sink_input_info_callback (pa_context *c, const pa_sink_input_info *info, int eol, void *userdata); -static void pm_update_active_sink (pa_context *c, +static void pm_update_device (pa_context *c, const pa_sink_info *info, int eol, void *userdata); @@ -89,11 +89,11 @@ static pa_glib_mainloop *pa_main_loop = NULL; Entry Point **/ void -pm_establish_pulse_connection (ActiveSink* active_sink) +pm_establish_pulse_connection (Device* device) { pa_main_loop = pa_glib_mainloop_new (g_main_context_default ()); g_assert (pa_main_loop); - reconnect_to_pulse ((gpointer)active_sink); + reconnect_to_pulse ((gpointer)device); } /** @@ -119,7 +119,7 @@ reconnect_to_pulse (gpointer user_data) { g_debug("Attempt a pulse connection"); // reset - g_return_val_if_fail (IS_ACTIVE_SINK (user_data), FALSE); + g_return_val_if_fail (IS_DEVICE (user_data), FALSE); connection_attempts += 1; if (pulse_context != NULL) { @@ -216,38 +216,38 @@ pm_subscribed_events_callback (pa_context *c, uint32_t index, void* userdata) { - if (IS_ACTIVE_SINK (userdata) == FALSE){ + if (IS_DEVICE (userdata) == FALSE){ g_critical ("subscribed events callback - our userdata is not what we think it should be"); return; } - ActiveSink* sink = ACTIVE_SINK (userdata); + Device* sink = DEVICE (userdata); switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { case PA_SUBSCRIPTION_EVENT_SINK: // We don't care about any other sink other than the active one. - if (index != active_sink_get_index (sink)) + if (index != device_get_sink_index (sink)) return; if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { - active_sink_deactivate (sink); + device_sink_deactivated (sink); } else{ pa_operation_unref (pa_context_get_sink_info_by_index (c, index, - pm_update_active_sink, + pm_update_device, userdata) ); } break; case PA_SUBSCRIPTION_EVENT_SOURCE: g_debug ("Looks like source event of some description - index = %i", index); // We don't care about any other sink other than the active one. - if (index != active_sink_get_source_index (sink)) + if (index != device_get_source_index (sink)) return; if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { g_debug ("Source removal event - index = %i", index); - active_sink_deactivate_voip_source (sink, FALSE); + device_deactivate_voip_source (sink, FALSE); } else{ pa_operation_unref (pa_context_get_source_info_by_index (c, @@ -260,12 +260,12 @@ pm_subscribed_events_callback (pa_context *c, // We don't care about sink input removals. g_debug ("sink input event"); if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { - gint cached_index = active_sink_get_current_sink_input_index (sink); + gint cached_index = device_get_current_sink_input_index (sink); g_debug ("Just saw a sink input removal event - index = %i and cached index = %i", index, cached_index); if (index == cached_index){ - active_sink_deactivate_voip_client (sink); + device_deactivate_voip_client (sink); } } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { @@ -308,7 +308,7 @@ pm_context_state_callback (pa_context *c, void *userdata) break; case PA_CONTEXT_FAILED: g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?"); - active_sink_deactivate (ACTIVE_SINK (userdata)); + device_sink_deactivated (DEVICE (userdata)); if (reconnect_idle_id == 0){ reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY, reconnect_to_pulse, @@ -362,7 +362,7 @@ pm_server_info_callback (pa_context *c, if (info == NULL) { g_warning("No PA server - get the hell out of here"); - active_sink_deactivate (ACTIVE_SINK (userdata)); + device_sink_deactivated (DEVICE (userdata)); return; } // Go for the default sink @@ -373,7 +373,7 @@ pm_server_info_callback (pa_context *c, pm_default_sink_info_callback, userdata) )) { g_warning("pa_context_get_sink_info_by_namet() failed"); - active_sink_deactivate (ACTIVE_SINK (userdata)); + device_sink_deactivated (DEVICE (userdata)); pa_operation_unref(operation); return; } @@ -382,7 +382,7 @@ pm_server_info_callback (pa_context *c, pm_sink_info_callback, userdata))) { g_warning("pa_context_get_sink_info_list() failed"); - active_sink_deactivate (ACTIVE_SINK (userdata)); + device_sink_deactivated (DEVICE (userdata)); pa_operation_unref(operation); return; } @@ -421,14 +421,14 @@ pm_sink_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE || sink == NULL){ + if (IS_DEVICE (userdata) == FALSE || sink == NULL){ g_warning ("sink info callback - our user data is not what we think it should be or the sink parameter is null"); return; } - ActiveSink* a_sink = ACTIVE_SINK (userdata); - if (active_sink_is_populated (a_sink) == FALSE && + Device* a_sink = DEVICE (userdata); + if (device_is_sink_populated (a_sink) == FALSE && g_ascii_strncasecmp("auto_null", sink->name, 9) != 0){ - active_sink_populate (a_sink, sink); + device_sink_populate (a_sink, sink); } } } @@ -443,16 +443,16 @@ pm_default_sink_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ + if (IS_DEVICE (userdata) == FALSE || info == NULL){ g_warning ("Default sink info callback - our user data is not what we think it should be or the info parameter is null"); return; } // Only repopulate if there is a change with regards the index - if (active_sink_get_index (ACTIVE_SINK (userdata)) == info->index) + if (device_get_sink_index (DEVICE (userdata)) == info->index) return; g_debug ("Pulse Server has handed us a new default sink"); - active_sink_populate (ACTIVE_SINK (userdata), info); + device_sink_populate (DEVICE (userdata), info); } } @@ -466,26 +466,26 @@ pm_sink_input_info_callback (pa_context *c, return; } else { - if (info == NULL || IS_ACTIVE_SINK (userdata) == FALSE) { + if (info == NULL || IS_DEVICE (userdata) == FALSE) { g_warning("Sink input info callback : SINK INPUT INFO IS NULL or our user_data is not what we think it should be"); return; } - if (IS_ACTIVE_SINK (userdata) == FALSE){ + if (IS_DEVICE (userdata) == FALSE){ g_warning ("sink input info callback - our user data is not what we think it should be"); return; } // Check if this is Voip sink input gint result = pa_proplist_contains (info->proplist, PA_PROP_MEDIA_ROLE); - ActiveSink* a_sink = ACTIVE_SINK (userdata); + Device* a_sink = DEVICE (userdata); if (result == 1){ g_debug ("Sink input info has media role property"); const char* value = pa_proplist_gets (info->proplist, PA_PROP_MEDIA_ROLE); g_debug ("prop role = %s", value); - if (g_strcmp0 (value, "phone") == 0) { + if (g_strcmp0 (value, "phone") == 0 || g_strcmp0 (value, "production") == 0) { g_debug ("And yes its a VOIP app ... sink input index = %i", info->index); - active_sink_activate_voip_item (a_sink, (gint)info->index, (gint)info->client); + device_activate_voip_item (a_sink, (gint)info->index, (gint)info->client); // TODO to start with we will assume our source is the same as what this 'client' // is pointing at. This should probably be more intelligent : // query for the list of source output info's and going on the name of the client @@ -494,14 +494,14 @@ pm_sink_input_info_callback (pa_context *c, } // And finally check for the mute blocking state - if (active_sink_get_index (a_sink) == info->sink){ - active_sink_determine_blocking_state (a_sink); + if (device_get_sink_index (a_sink) == info->sink){ + device_determine_blocking_state (a_sink); } } } static void -pm_update_active_sink (pa_context *c, +pm_update_device (pa_context *c, const pa_sink_info *info, int eol, void *userdata) @@ -510,11 +510,11 @@ pm_update_active_sink (pa_context *c, return; } else{ - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ - g_warning ("update_active_sink - our user data is not what we think it should be or the info parameter is null"); + if (IS_DEVICE (userdata) == FALSE || info == NULL){ + g_warning ("update_device - our user data is not what we think it should be or the info parameter is null"); return; } - active_sink_update (ACTIVE_SINK(userdata), info); + device_sink_update (DEVICE(userdata), info); } } @@ -551,16 +551,16 @@ pm_default_source_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ + if (IS_DEVICE (userdata) == FALSE || info == NULL){ g_warning ("Default source info callback - our user data is not what we think it should be or the source info parameter is null"); return; } // If there is an index change we need to change our cached source - if (active_sink_get_source_index (ACTIVE_SINK (userdata)) == info->index) + if (device_get_source_index (DEVICE (userdata)) == info->index) return; g_debug ("Pulse Server has handed us a new default source"); - active_sink_deactivate_voip_source (ACTIVE_SINK (userdata), TRUE); - active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); + device_deactivate_voip_source (DEVICE (userdata), TRUE); + device_update_voip_input_source (DEVICE (userdata), info); } } @@ -574,13 +574,13 @@ pm_source_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ + if (IS_DEVICE (userdata) == FALSE || info == NULL){ g_warning ("source info callback - our user data is not what we think it should be or the source info parameter is null"); return; } // For now we will take the first available - if (active_sink_is_voip_source_populated (ACTIVE_SINK (userdata)) == FALSE){ - active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); + if (device_is_voip_source_populated (DEVICE (userdata)) == FALSE){ + device_update_voip_input_source (DEVICE (userdata), info); } } } @@ -595,11 +595,11 @@ pm_update_source_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL ){ + if (IS_DEVICE (userdata) == FALSE || info == NULL ){ g_warning ("source info update callback - our user data is not what we think it should be or the source info paramter is null"); return; } g_debug ("Got a source update for %s , index %i", info->name, info->index); - active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); + device_update_voip_input_source (DEVICE (userdata), info); } } diff --git a/src/pulseaudio-mgr.h b/src/pulseaudio-mgr.h index d61117d..ace47f3 100644 --- a/src/pulseaudio-mgr.h +++ b/src/pulseaudio-mgr.h @@ -17,9 +17,9 @@ 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 "active-sink.h" +#include "device.h" -void pm_establish_pulse_connection (ActiveSink* active_sink); +void pm_establish_pulse_connection (Device* device); void close_pulse_activites(); void pm_update_volume (gint sink_index, pa_cvolume new_volume); void pm_update_mic_gain (gint source_index, pa_cvolume new_gain); diff --git a/src/settings-manager.c b/src/settings-manager.c index 7536ced..a22d4fa 100644 --- a/src/settings-manager.c +++ b/src/settings-manager.c @@ -1,4 +1,4 @@ -/* settings-manager.c generated by valac 0.11.6, the Vala compiler +/* settings-manager.c generated by valac 0.11.7, the Vala compiler * generated from settings-manager.vala, do not modify */ /* @@ -271,14 +271,12 @@ static GObject * settings_manager_constructor (GType type, guint n_construct_pro GObjectClass * parent_class; SettingsManager * self; GSettings* _tmp0_ = NULL; - GSettings* _tmp1_; parent_class = G_OBJECT_CLASS (settings_manager_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = SETTINGS_MANAGER (obj); _tmp0_ = g_settings_new ("com.canonical.indicators.sound"); - _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->settings); - self->priv->settings = _tmp1_; + self->priv->settings = _tmp0_; g_signal_connect_object (self->priv->settings, "changed::blacklisted-media-players", (GCallback) _settings_manager_on_blacklist_event_g_settings_changed, self, 0); return obj; } diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index 1c88f01..974749f 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -23,11 +23,18 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib/gi18n.h> #include "slider-menu-item.h" #include "common-defs.h" +#include "pulseaudio-mgr.h" typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate; struct _SliderMenuItemPrivate { - ActiveSink* a_sink; + Device* a_sink; + gint index; + gchar* name; + gboolean mute; + pa_cvolume volume; + pa_channel_map channel_map; + pa_volume_t base_volume; }; #define SLIDER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SLIDER_MENU_ITEM_TYPE, SliderMenuItemPrivate)) @@ -39,6 +46,8 @@ static void slider_menu_item_dispose (GObject *object); static void slider_menu_item_finalize (GObject *object); static void handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp); +static pa_cvolume slider_menu_item_construct_mono_volume (const pa_cvolume* vol); +static void slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent); G_DEFINE_TYPE (SliderMenuItem, slider_menu_item, DBUSMENU_TYPE_MENUITEM); @@ -63,7 +72,13 @@ slider_menu_item_init (SliderMenuItem *self) g_debug("Building new Slider Menu Item"); dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_VOLUME_MENUITEM_TYPE ); + DBUSMENU_VOLUME_MENUITEM_TYPE ); + + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); + + priv->index = NOT_ACTIVE; + priv->name = NULL; + return; } @@ -97,33 +112,122 @@ handle_event (DbusmenuMenuitem * mi, SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (SLIDER_MENU_ITEM (mi)); gdouble volume_input = g_variant_get_double(input); //g_debug ("slider menu item about to update volume %f", volume_input); - active_sink_update_volume (priv->a_sink, volume_input); - active_sink_ensure_sink_is_unmuted (priv->a_sink); + slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input); + device_ensure_sink_is_unmuted (priv->a_sink); } } } + void -slider_menu_item_update (SliderMenuItem* item, - gdouble update) +slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update) +{ + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); + priv->name = g_strdup (update->name); + priv->index = update->index; + priv->volume = slider_menu_item_construct_mono_volume (&update->volume); + priv->base_volume = update->base_volume; + priv->channel_map = update->channel_map; + priv->mute = update->mute; + + pa_volume_t vol = pa_cvolume_max (&update->volume); + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; + GVariant* new_volume = g_variant_new_double (volume_percent); + dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), + DBUSMENU_VOLUME_MENUITEM_LEVEL, + new_volume); + GVariant* new_mute_update = g_variant_new_int32 (update->mute); + dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), + DBUSMENU_VOLUME_MENUITEM_MUTE, + new_mute_update); + + slider_menu_item_enable (self, TRUE); +} + +// From the UI +static void +slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent) { - GVariant* new_volume = g_variant_new_double(update); - dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(item), - DBUSMENU_VOLUME_MENUITEM_LEVEL, - new_volume); + pa_cvolume new_volume; + pa_cvolume_init(&new_volume); + 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); + + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); + + pa_cvolume_set(&priv->volume, priv->channel_map.channels, new_volume_value); + pm_update_volume (priv->index, new_volume); } +// To the UI void -slider_menu_item_enable (SliderMenuItem* item, - gboolean active) +slider_menu_item_update (SliderMenuItem* self, const pa_sink_info* update) { - dbusmenu_menuitem_property_set_bool( DBUSMENU_MENUITEM(item), + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); + + priv->volume = slider_menu_item_construct_mono_volume (&update->volume); + priv->base_volume = update->base_volume; + priv->channel_map = update->channel_map; + + pa_volume_t vol = pa_cvolume_max (&update->volume); + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; + + GVariant* new_volume = g_variant_new_double (volume_percent); + dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), + DBUSMENU_VOLUME_MENUITEM_LEVEL, + new_volume); + if (priv->mute != update->mute){ + priv->mute = update->mute; + g_debug ("volume menu item - update - mute = %i", update->mute); + GVariant* new_mute_update = g_variant_new_int32 (update->mute); + dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), + DBUSMENU_VOLUME_MENUITEM_MUTE, + new_mute_update); + } +} + +/* + * Enable/Disabled can be considered the equivalent of whether we have an active + * sink or not, let the widget have inherent state. + */ +void +slider_menu_item_enable (SliderMenuItem* self, gboolean active) +{ + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); + + dbusmenu_menuitem_property_set_bool (DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, - active ); + active); + if(active == FALSE){ + priv->index = NOT_ACTIVE; + if(priv->name != NULL){ + g_free(priv->name); + priv->name = NULL; + } + } +} + +gint +slider_menu_item_get_sink_index (SliderMenuItem* self) +{ + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); + return priv->index; +} + +static pa_cvolume +slider_menu_item_construct_mono_volume (const pa_cvolume* vol) +{ + pa_cvolume new_volume; + pa_cvolume_init(&new_volume); + new_volume.channels = 1; + pa_volume_t max_vol = pa_cvolume_max(vol); + pa_cvolume_set(&new_volume, 1, max_vol); + return new_volume; } SliderMenuItem* -slider_menu_item_new (ActiveSink* sink) +slider_menu_item_new (Device* sink) { SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL); SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); diff --git a/src/slider-menu-item.h b/src/slider-menu-item.h index f094c71..4375971 100644 --- a/src/slider-menu-item.h +++ b/src/slider-menu-item.h @@ -23,7 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib-object.h> #include <libdbusmenu-glib/menuitem.h> -#include "active-sink.h" +#include "device.h" G_BEGIN_DECLS @@ -47,10 +47,16 @@ struct _SliderMenuItem { GType slider_menu_item_get_type (void); -void slider_menu_item_update(SliderMenuItem* item, gdouble update); +void slider_menu_item_update(SliderMenuItem* item, const pa_sink_info* update); void slider_menu_item_enable(SliderMenuItem* item, gboolean active); +void slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update); +//void +//active_sink_update (ActiveSink* sink, +// const pa_sink_info* update) -SliderMenuItem* slider_menu_item_new (ActiveSink* sink); +gint slider_menu_item_get_sink_index (SliderMenuItem* self); + +SliderMenuItem* slider_menu_item_new (Device* sink); G_END_DECLS diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 8d0cc0b..7c817af 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -29,7 +29,7 @@ #include <libdbusmenu-glib/client.h> #include "sound-service-dbus.h" -#include "active-sink.h" +#include "device.h" #include "gen-sound-service.xml.h" #include "dbus-shared-names.h" @@ -55,7 +55,7 @@ typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate; struct _SoundServiceDbusPrivate { GDBusConnection* connection; DbusmenuMenuitem* root_menuitem; - ActiveSink* active_sink; + Device* device; }; static GDBusNodeInfo * node_info = NULL; @@ -155,7 +155,7 @@ sound_service_dbus_create_root_item (SoundServiceDbus* self) paths); dbusmenu_server_set_root (server, priv->root_menuitem); g_object_unref (priv->root_menuitem); - priv->active_sink = active_sink_new (self); + priv->device = device_new (self); return priv->root_menuitem; } @@ -272,8 +272,8 @@ bus_method_call (GDBusConnection * connection, SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (service); if (g_strcmp0(method, "GetSoundState") == 0) { - g_debug("Get state - %i", active_sink_get_state (priv->active_sink)); - retval = g_variant_new ( "(i)", active_sink_get_state (priv->active_sink)); + g_debug("Get state - %i", device_get_state (priv->device)); + retval = g_variant_new ( "(i)", device_get_state (priv->device)); } else if (g_strcmp0(method, "BlacklistMediaPlayer") == 0) { gboolean blacklist; diff --git a/src/sound-service.c b/src/sound-service.c index cfc0b7e..7e6426c 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -51,11 +51,11 @@ main: int main (int argc, char ** argv) { + g_type_init(); - - setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + setlocale (LC_ALL, ""); IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); diff --git a/src/title-menu-item.c b/src/title-menu-item.c index 702fa24..168bfd9 100644 --- a/src/title-menu-item.c +++ b/src/title-menu-item.c @@ -1,4 +1,4 @@ -/* title-menu-item.c generated by valac 0.11.6, the Vala compiler +/* title-menu-item.c generated by valac 0.11.7, the Vala compiler * generated from title-menu-item.vala, do not modify */ /* diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c index 0cc2850..df1cc14 100644 --- a/src/transport-menu-item.c +++ b/src/transport-menu-item.c @@ -1,4 +1,4 @@ -/* transport-menu-item.c generated by valac 0.11.6, the Vala compiler +/* transport-menu-item.c generated by valac 0.11.7, the Vala compiler * generated from transport-menu-item.vala, do not modify */ /* @@ -162,9 +162,9 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const GVariant* _tmp0_; GVariant* v; gboolean _tmp1_; - gint32 _tmp4_; + gint32 _tmp3_; gint32 input; - PlayerController* _tmp5_ = NULL; + PlayerController* _tmp4_ = NULL; self = (TransportMenuitem*) base; g_return_if_fail (name != NULL); g_return_if_fail (input_value != NULL); @@ -173,16 +173,14 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const _tmp1_ = g_variant_is_of_type (input_value, G_VARIANT_TYPE_VARIANT); if (_tmp1_) { GVariant* _tmp2_ = NULL; - GVariant* _tmp3_; _tmp2_ = g_variant_get_variant (input_value); - _tmp3_ = _tmp2_; _g_variant_unref0 (v); - v = _tmp3_; + v = _tmp2_; } - _tmp4_ = g_variant_get_int32 (v); - input = _tmp4_; - _tmp5_ = player_item_get_owner ((PlayerItem*) self); - mpris2_controller_transport_update (_tmp5_->mpris_bridge, (TransportAction) input); + _tmp3_ = g_variant_get_int32 (v); + input = _tmp3_; + _tmp4_ = player_item_get_owner ((PlayerItem*) self); + mpris2_controller_transport_update (_tmp4_->mpris_bridge, (TransportAction) input); _g_variant_unref0 (v); } diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c index a742654..a92f91c 100644 --- a/src/voip-input-menu-item.c +++ b/src/voip-input-menu-item.c @@ -28,7 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. typedef struct _VoipInputMenuItemPrivate VoipInputMenuItemPrivate; struct _VoipInputMenuItemPrivate { - ActiveSink* a_sink; + Device* a_sink; pa_cvolume volume; gint mute; guint32 volume_steps; @@ -129,8 +129,6 @@ handle_event (DbusmenuMenuitem * mi, if (priv->mute == 1) { pm_update_mic_mute (priv->source_index, 0); } - //active_sink_update_volume (priv->a_sink, volume_input); - //active_sink_ensure_sink_is_unmuted (priv->a_sink); } } } @@ -268,7 +266,7 @@ voip_input_menu_item_enable (VoipInputMenuItem* item, } VoipInputMenuItem* -voip_input_menu_item_new (ActiveSink* sink) +voip_input_menu_item_new (Device* sink) { VoipInputMenuItem *self = g_object_new(VOIP_INPUT_MENU_ITEM_TYPE, NULL); VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (self); diff --git a/src/voip-input-menu-item.h b/src/voip-input-menu-item.h index 6f4ed85..30ada5a 100644 --- a/src/voip-input-menu-item.h +++ b/src/voip-input-menu-item.h @@ -22,7 +22,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib.h> #include <pulse/pulseaudio.h> #include <libdbusmenu-glib/menuitem.h> -#include "active-sink.h" +#include "device.h" G_BEGIN_DECLS @@ -62,7 +62,7 @@ gint voip_input_menu_item_get_sink_input_index (VoipInputMenuItem* item); void voip_input_menu_item_deactivate_source (VoipInputMenuItem* item, gboolean visible); void voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item); -VoipInputMenuItem* voip_input_menu_item_new (ActiveSink* sink); +VoipInputMenuItem* voip_input_menu_item_new (Device* sink); G_END_DECLS diff --git a/src/voip-input-widget.c b/src/voip-input-widget.c index fc295ce..6878361 100644 --- a/src/voip-input-widget.c +++ b/src/voip-input-widget.c @@ -80,6 +80,8 @@ voip_input_widget_init (VoipInputWidget *self) priv->ido_voip_input_slider = ido_scale_menu_item_new_with_range ("VOLUME", IDO_RANGE_STYLE_DEFAULT, 0, 0, 100, 1); g_object_ref (priv->ido_voip_input_slider); + ido_scale_menu_item_set_primary_label (IDO_SCALE_MENU_ITEM(priv->ido_voip_input_slider), "VOIP"); + ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (priv->ido_voip_input_slider), IDO_SCALE_MENU_ITEM_STYLE_IMAGE); g_object_set(priv->ido_voip_input_slider, "reverse-scroll-events", TRUE, NULL); @@ -95,7 +97,7 @@ voip_input_widget_init (VoipInputWidget *self) g_signal_connect(priv->ido_voip_input_slider, "slider-released", G_CALLBACK(voip_input_widget_slider_released), self); GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)priv->ido_voip_input_slider); - GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks("audio-input-microphone-none-panel"); + GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks("audio-input-microphone-zero-panel"); gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU); g_object_unref(primary_gicon); diff --git a/src/volume-widget.c b/src/volume-widget.c index 5c842dc..f638bd4 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -83,7 +83,8 @@ volume_widget_init (VolumeWidget *self) priv->ido_volume_slider = ido_scale_menu_item_new_with_range ("VOLUME", IDO_RANGE_STYLE_DEFAULT, 0, 0, 100, 1); g_object_ref (priv->ido_volume_slider); - ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (priv->ido_volume_slider), IDO_SCALE_MENU_ITEM_STYLE_IMAGE); + ido_scale_menu_item_set_primary_label (IDO_SCALE_MENU_ITEM(priv->ido_volume_slider), "VOLUME"); + ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (priv->ido_volume_slider), IDO_SCALE_MENU_ITEM_STYLE_IMAGE); g_object_set(priv->ido_volume_slider, "reverse-scroll-events", TRUE, NULL); g_signal_connect (priv->ido_volume_slider, @@ -128,11 +129,11 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, GVariant* value, gpointer userdata) { g_return_if_fail (IS_VOLUME_WIDGET (userdata)); - g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) ); VolumeWidget* mitem = VOLUME_WIDGET(userdata); VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); - //g_debug("scrub-widget::property_update for prop %s", 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) ); if(priv->grabbed == FALSE){ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); GtkRange *range = (GtkRange*)slider; @@ -141,6 +142,27 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, update_accessible_desc(priv->indicator); } } + if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ + g_debug ("volume widget - mute update "); + if(priv->grabbed == FALSE){ + GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); + GtkRange *range = (GtkRange*)slider; + gint update = g_variant_get_int32 (value); + gdouble level; + + g_debug ("volume widget - mute update %i", update); + + if (update == 1){ + level = 0; + } + else{ + level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item, + DBUSMENU_VOLUME_MENUITEM_LEVEL)); + } + gtk_range_set_value(range, level); + g_debug ("volume-widget - update mute with value %i", update); + } + } } static void @@ -154,9 +176,15 @@ volume_widget_set_twin_item(VolumeWidget* self, G_CALLBACK(volume_widget_property_update), self); gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item, DBUSMENU_VOLUME_MENUITEM_LEVEL)); + gint initial_mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant(twin_item, + DBUSMENU_VOLUME_MENUITEM_MUTE)); + //g_debug("volume_widget_set_twin_item initial level = %f", initial_level); GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); GtkRange *range = (GtkRange*)slider; + if(initial_mute == 1){ + initial_level = 0; + } gtk_range_set_value(range, initial_level); update_accessible_desc(priv->indicator); } @@ -188,7 +216,10 @@ volume_widget_value_changed_cb (GtkRange *range, gpointer user_data) 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); //g_debug ("value changed %f", gtk_range_get_value(GTK_RANGE(slider))); - if(current_value == 0 || current_value == 100){ + gint mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant (priv->twin_item, + DBUSMENU_VOLUME_MENUITEM_MUTE)); + + if((current_value == 0 && mute != 1) || current_value == 100){ volume_widget_update(mitem, current_value); } |