aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-01-12 14:33:30 -0600
committerConor Curran <conor.curran@canonical.com>2011-01-12 14:33:30 -0600
commit055df674f70f7961c6d47e3b031881e142f6dea8 (patch)
tree80074b6f540408d5a2781173057029124bded0ee
parent5f1d857f263edd696fe1d9af793a26e9bbd5a6c3 (diff)
downloadayatana-indicator-sound-055df674f70f7961c6d47e3b031881e142f6dea8.tar.gz
ayatana-indicator-sound-055df674f70f7961c6d47e3b031881e142f6dea8.tar.bz2
ayatana-indicator-sound-055df674f70f7961c6d47e3b031881e142f6dea8.zip
rf underway
-rw-r--r--src/dbus-menu-manager.c71
-rw-r--r--src/dbus-menu-manager.h2
-rw-r--r--src/mute-menu-item.c38
-rw-r--r--src/mute-menu-item.h2
4 files changed, 77 insertions, 36 deletions
diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c
index 92bfba5..8c255e3 100644
--- a/src/dbus-menu-manager.c
+++ b/src/dbus-menu-manager.c
@@ -1,5 +1,4 @@
/*
-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
Copyright 2010 Canonical Ltd.
Authors:
@@ -18,6 +17,11 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ *TODO:
+ * Makes this a proper GObject
+ **/
+
#include <unistd.h>
#include <glib/gi18n.h>
@@ -28,19 +32,20 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sound-service-dbus.h"
#include "pulse-manager.h"
#include "slider-menu-item.h"
+#include "mute-menu-item.h"
+
#include "common-defs.h"
#include "dbus-shared-names.h"
-// DBUS items
+// DBUS related
static DbusmenuMenuitem *root_menuitem = NULL;
-static DbusmenuMenuitem *mute_all_menuitem = NULL;
static SliderMenuItem *volume_slider_menuitem = NULL;
+static MuteMenuItem *mute_menuitem = NULL;
static SoundServiceDbus *dbus_interface = NULL;
// PULSEAUDIO
static gboolean b_sink_available = FALSE;
-static gboolean b_all_muted = FALSE;
static gboolean b_pulse_ready = FALSE;
static gboolean b_startup = TRUE;
static gdouble volume_percent = 0.0;
@@ -48,7 +53,9 @@ static gdouble volume_percent = 0.0;
static void set_global_mute_from_ui();
static gboolean idle_routine (gpointer data);
static void rebuild_sound_menu(DbusmenuMenuitem *root,
- SoundServiceDbus *service);
+ gboolean mute_update,
+ gboolean availability,
+ gdouble volume);
static void refresh_menu();
@@ -86,10 +93,12 @@ void dbus_menu_manager_update_volume(gdouble volume)
/**
update_pa_state:
**/
-void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble percent)
+void dbus_menu_manager_update_pa_state (gboolean pa_state,
+ gboolean sink_available,
+ gboolean sink_muted,
+ gdouble percent)
{
b_sink_available = sink_available;
- b_all_muted = sink_muted;
b_pulse_ready = pa_state;
volume_percent = percent;
g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent);
@@ -114,8 +123,8 @@ update_mute_ui:
**/
void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value)
{
- b_all_muted = incoming_mute_value;
- dbusmenu_menuitem_property_set(mute_all_menuitem,
+
+ dbusmenu_menuitem_property_set(DBUSMENUITEM(mute_all_menuitem),
DBUSMENU_MENUITEM_PROP_LABEL,
b_all_muted == FALSE ? _("Mute") : _("Unmute"));
}
@@ -181,36 +190,39 @@ static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data
}
/**
-rebuild_sound_menu:
-Build the DBus menu items, mute/unmute, slider, separator and sound preferences 'link'
+build_sound_menu's default items (without the any player items):
**/
-static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service)
+static void build_sound_menu (DbusmenuMenuitem *root,
+ gboolean mute_update,
+ gboolean availability,
+ gdouble volume);
+
{
// Mute button
- mute_all_menuitem = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, b_all_muted == FALSE ? _("Mute") : _("Unmute"));
- g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL);
- dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available);
+ mute_all_menuitem = mute_menu_item_new ( mute_update, availability);
+ dbusmenu_menuitem_child_append(root, mute_all_menuitem);
// Slider
- volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent);
- dbusmenu_menuitem_child_append(root, mute_all_menuitem);
+ volume_slider_menuitem = slider_menu_item_new(available, volume);
dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem));
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
DBUSMENU_MENUITEM_PROP_ENABLED,
b_sink_available && !b_all_muted);
- g_debug("!!!!!!**in the rebuild sound menu - slider active = %i", b_sink_available && !b_all_muted);
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
DBUSMENU_MENUITEM_PROP_VISIBLE,
b_sink_available);
// Separator
DbusmenuMenuitem *separator = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+ dbusmenu_menuitem_property_set( separator,
+ DBUSMENU_MENUITEM_PROP_TYPE,
+ DBUSMENU_CLIENT_TYPES_SEPARATOR);
dbusmenu_menuitem_child_append(root, separator);
// Sound preferences dialog
DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences..."));
+ dbusmenu_menuitem_property_set( settings_mi,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Sound Preferences..."));
//_("Sound Preferences..."));
dbusmenu_menuitem_child_append(root, settings_mi);
@@ -226,9 +238,20 @@ static void set_global_mute_from_ui()
{
b_all_muted = !b_all_muted;
toggle_global_mute(b_all_muted);
- dbusmenu_menuitem_property_set(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL,
- b_all_muted == FALSE ? _("Mute") : _("Unmute"));
+ dbusmenu_menuitem_property_set((DBUSMENU_MENUITEM)mute_all_menuitem,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ b_all_muted == FALSE ? _("Mute") : _("Unmute"));
+}
+
+
+/*
+ TODO: use these temporary wrappers around pulsemanager for the short term
+ Until I get to the point where I can refactor it entirely.
+*/
+
+void dbmm_pa_wrapper_toggle_mute(gboolean update)
+{
+ toggle_global_mute (update);
}
diff --git a/src/dbus-menu-manager.h b/src/dbus-menu-manager.h
index ec2b2e2..5b6544e 100644
--- a/src/dbus-menu-manager.h
+++ b/src/dbus-menu-manager.h
@@ -29,6 +29,6 @@ void dbus_menu_manager_update_volume(gdouble volume);
void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble current_vol);
// TODO update pa_state should incorporate the method below !
void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value);
-
+void dbmm_pa_wrapper_toggle_mute(gboolean update);
#endif
diff --git a/src/mute-menu-item.c b/src/mute-menu-item.c
index bdb14a6..bc96a2a 100644
--- a/src/mute-menu-item.c
+++ b/src/mute-menu-item.c
@@ -1,5 +1,5 @@
/*
-Copyright 2010 Canonical Ltd.
+Copyright 2011 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
@@ -25,6 +25,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mute-menu-item.h"
#include "common-defs.h"
+#include "dbus-menu-manager.h"
typedef struct _MuteMenuItemPrivate MuteMenuItemPrivate;
@@ -76,7 +77,6 @@ mute_menu_item_finalize (GObject *object)
G_OBJECT_CLASS (mute_menu_item_parent_class)->finalize (object);
}
-
static void
handle_event (DbusmenuMenuitem * mi,
const gchar * name,
@@ -96,19 +96,35 @@ handle_event (DbusmenuMenuitem * mi,
}
gboolean mute_input = g_variant_get_boolean(input);
+ dbmm_pa_wrapper_toggle_mute (input);
g_variant_unref (input);
}
-MuteMenuItem* mute_menu_item_new(gboolean sinks_available, gdouble start_volume)
-{
- MuteMenuItem *self = g_object_new(MUTE_MENU_ITEM_TYPE, NULL);
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_MUTE_MENUITEM_TYPE);
-
- //dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, sinks_available);
- //dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, sinks_available);
- return self;
+void mute_menu_item_update(MuteMenuItem* item, gboolean value_update)
+{
+ dbusmenu_menuitem_property_set_bool (DBUSMENU_MENUITEM(item),
+ DBUSMENU_MUTE_MENUITEM_VALUE,
+ update);
+ dbusmenu_menuitem_property_set (DBUSMENUITEM(item),
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ update == FALSE ? _("Mute") : _("Unmute"));
}
+void mute_menu_item_enable(MuteMenuItem* item, gboolean active)
+{
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(item),
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ active);
+}
-
+MuteMenuItem* mute_menu_item_new (gboolean initial_update, gboolean enabled)
+{
+ MuteMenuItem *self = g_object_new(MUTE_MENU_ITEM_TYPE, NULL);
+ dbusmenu_menuitem_property_set (DBUSMENU_MENUITEM(self),
+ DBUSMENU_MENUITEM_PROP_TYPE,
+ DBUSMENU_MUTE_MENUITEM_TYPE);
+ mute_menu_item_enable (self, enabled);
+ mute_menu_item_update (self, initial_update);
+ return self;
+}
diff --git a/src/mute-menu-item.h b/src/mute-menu-item.h
index 36f5e69..d7232d0 100644
--- a/src/mute-menu-item.h
+++ b/src/mute-menu-item.h
@@ -49,6 +49,8 @@ GType mute_menu_item_get_type (void);
MuteMenuItem* mute_menu_item_new();
+void mute_menu_item_update(MuteMenuItem* item, gboolean update);
+
G_END_DECLS
#endif