aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-06-21 11:36:58 +0100
committerConor Curran <conor.curran@canonical.com>2010-06-21 11:36:58 +0100
commit1b9837ab2ddfac074149d020e700e9272579b211 (patch)
tree8f3906ac4bd479ec9c1ee3aede7152a20e20b848 /src
parent9bba58ee4dae536ce92f396854e2c0e671d9b7f0 (diff)
downloadayatana-indicator-sound-1b9837ab2ddfac074149d020e700e9272579b211.tar.gz
ayatana-indicator-sound-1b9837ab2ddfac074149d020e700e9272579b211.tar.bz2
ayatana-indicator-sound-1b9837ab2ddfac074149d020e700e9272579b211.zip
lots of changes
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/common-defs.h6
-rw-r--r--src/metadata-menu-item.vala28
-rw-r--r--src/metadata-widget.c8
-rw-r--r--src/mpris-controller.vala13
-rw-r--r--src/player-controller.vala21
-rw-r--r--src/sound-service.c4
-rw-r--r--src/transport-menu-item.vala15
-rw-r--r--src/transport-widget.c20
9 files changed, 69 insertions, 51 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5a42dc6..e556eed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,17 +56,20 @@ music_bridge_VALASOURCES = \
metadata-menu-item.vala \
player-controller.vala \
mpris-controller-v2.vala \
- mpris-controller.vala
+ mpris-controller.vala \
+ player-item.vala
music_bridge_VALAFLAGS = \
--ccode \
-H music-player-bridge.h -d . \
--library music-bridge \
--vapidir=./ \
+ --vapidir=$(topsrcdir)/vapi \
--thread \
--pkg gee-1.0 \
--pkg Indicate-0.2 \
--pkg Dbusmenu-Glib-0.2 \
+ --pkg music-bridge \
--pkg dbus-glib-1
$(MAINTAINER_VALAFLAGS)
diff --git a/src/common-defs.h b/src/common-defs.h
index 014d864..d35c672 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -31,6 +31,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-metadata-menu-item"
#define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist"
-#define DBUSMENU_METADATA_MENUITEM_TEXT_PIECE "x-canonical-metadata-text-piece"
-#define DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER "x-canonical-metadata-text-container"
-#define DBUSMENU_METADATA_MENUITEM_IMAGE_PATH "x-canonical-metadata-image"
+#define DBUSMENU_METADATA_MENUITEM_TEXT_TITLE "x-canonical-metadata-text-title"
+#define DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM "x-canonical-metadata-text-album"
+#define DBUSMENU_METADATA_MENUITEM_IMAGE_PATH "x-canonical-metadata-image"
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index 82926b1..28e034a 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -1,21 +1,23 @@
using Dbusmenu;
using Gee;
+using CommonDefs;
-public class MetadataMenuitem : Dbusmenu.Menuitem
+public class MetadataMenuitem : PlayerItem
{
/* Not ideal duplicate definition of const - see common-defs/h */
- const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item";
- const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist";
- const string DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece";
- const string DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container";
- const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image";
+ //const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item";
+ //const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist";
+ //const string DBUSMENU_METADATA_MENUITEM_TEXT_TITLE = "x-canonical-metadata-text-title";
+ //const string DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM = "x-canonical-metadata-text-album";
+ //const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image";
public MetadataMenuitem()
{
this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE);
+
}
- public void update(HashMap<string, string> data)
+ public override void update(HashMap<string, string> data)
{
this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip());
this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, data.get("title").strip());
@@ -37,4 +39,16 @@ public class MetadataMenuitem : Dbusmenu.Menuitem
{
debug("MetadataItem -> handle event caught!");
}
+
+ public static HashMap<string, Type> attributes()
+ {
+ HashMap<string, Type> result = new HashMap<string, Type>();
+ result.set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, typeof(string));
+ result.set("x-canonical-metadata-text-title", typeof(string));
+ result.set("x-canonical-metadata-text-album", typeof(string));
+ result.set("x-canonical-metadata-text-image", typeof(string));
+
+ return result;
+ }
+
} \ No newline at end of file
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index c4d3b50..b2ca255 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -106,13 +106,13 @@ metadata_widget_init (MetadataWidget *self)
// piece
GtkWidget* piece;
- piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE));
+ piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_TITLE));
priv->piece_label = piece;
// container
GtkWidget* container;
- container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER));
+ container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM));
priv->container_label = container;
// Pack in the right order
@@ -171,10 +171,10 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->artist_label), g_value_get_string(value));
}
- else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, property) == 0){
+ else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value));
}
- else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, property) == 0){
+ else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value));
}
else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, property) == 0){
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index 7e65594..cd1d2db 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -76,13 +76,12 @@ public class MprisController : GLib.Object
private void onStatusChange(dynamic DBus.Object mpris_client, status st)
{
debug("onStatusChange - signal received");
- //ValueArray a = new ValueArray(4);
- //Value v = new Value(typeof(int32));
- //v.set_int(st.playback);
- //a.append(v);
- //debug("onStatusChange - play %i", a.get_nth(0).get_int());
- //int playback = (ValueArray)st.get_nth(0).get_int();
- //int shuffle = ar.get_nth(1).get_int();
+ status* status = &st;
+ unowned ValueArray ar = (ValueArray)status;
+
+ int playback = ar.get_nth(0).get_int();
+ debug("onStatusChange - play %i", ar.get_nth(0).get_int());
+
//int repeat = ar.get_nth(2).get_int();
//int endless = ar.get_nth(3).get_int();
}
diff --git a/src/player-controller.vala b/src/player-controller.vala
index aa72cac..22a200e 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -29,7 +29,7 @@ public class PlayerController : GLib.Object
private Dbusmenu.Menuitem root_menu;
private string name;
private bool is_active;
- private ArrayList<Dbusmenu.Menuitem> custom_items;
+ private ArrayList<PlayerItem> custom_items;
private MprisController mpris_adaptor;
public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active)
@@ -37,7 +37,7 @@ public class PlayerController : GLib.Object
this.root_menu = root;
this.name = format_client_name(client_name.strip());
this.is_active = active;
- this.custom_items = new ArrayList<Dbusmenu.Menuitem>();
+ this.custom_items = new ArrayList<PlayerItem>();
self_construct();
// Temporary scenario to handle both v1 and v2 of MPRIS.
@@ -48,11 +48,7 @@ public class PlayerController : GLib.Object
this.mpris_adaptor = new MprisController(this.name, this);
}
- // TODO subclass dbusmenuMenuitem to something like a playermenuitem
- // and use this type to collectively
- // control widgets.
- TransportMenuitem t = (TransportMenuitem)this.custom_items[TRANSPORT];
- t.set_adaptor(this.mpris_adaptor);
+ this.custom_items[TRANSPORT].set_adaptor(this.mpris_adaptor);
}
public void vanish()
@@ -65,15 +61,10 @@ public class PlayerController : GLib.Object
private bool self_construct()
{
// Separator item
- Dbusmenu.Menuitem separator_item = new Dbusmenu.Menuitem();
- separator_item.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR);
- this.custom_items.add(separator_item);
+ this.custom_items.add(PlayerItem.new_separator_item());
// Title item
- Dbusmenu.Menuitem title_item = new Dbusmenu.Menuitem();
- title_item.property_set(MENUITEM_PROP_LABEL, this.name);
- title_item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia");
- this.custom_items.add(title_item);
+ this.custom_items.add(PlayerItem.new_title_item(this.name));
// Metadata item
MetadataMenuitem metadata_item = new MetadataMenuitem();
@@ -84,7 +75,7 @@ public class PlayerController : GLib.Object
this.custom_items.add(transport_item);
int offset = 2;
- foreach(Dbusmenu.Menuitem item in this.custom_items){
+ foreach(PlayerItem item in this.custom_items){
root_menu.child_add_position(item, offset + this.custom_items.index_of(item));
}
return true;
diff --git a/src/sound-service.c b/src/sound-service.c
index bcdac07..ea04e4b 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
if (mainloop != NULL) {
g_debug("Service shutdown !");
// TODO: uncomment for release !!
- close_pulse_activites();
- g_main_loop_quit(mainloop);
+ //close_pulse_activites();
+ //g_main_loop_quit(mainloop);
}
return;
}
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index 2e1ed0b..7dc1c7f 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -21,31 +21,24 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
using Dbusmenu;
using Gee;
-public class TransportMenuitem : Dbusmenu.Menuitem
+public class TransportMenuitem : PlayerItem
{
/* Not ideal duplicate definition of const - see common-defs/h */
const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar";
const string DBUSMENU_TRANSPORT_MENUITEM_STATE = "x-canonical-transport-state";
- private MprisController mpris_adaptor;
public TransportMenuitem()
{
this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE);
- // Hardcode the set up state until we can get the struct vala bug fixed
this.property_set_bool(DBUSMENU_TRANSPORT_MENUITEM_STATE, false);
debug("transport on the vala side");
}
- public void set_adaptor(MprisController adaptor)
+ public override void update(HashMap<string, string> data)
{
- this.mpris_adaptor = adaptor;
+ debug("TransportMenuitem::update()");
}
-
- /**
- Callback method for the handle_event
- * TRUE => Playing
- * FALSE => Paused
- **/
+
public override void handle_event(string name, GLib.Value input_value, uint timestamp)
{
debug("handle_event with bool value %s", input_value.get_boolean().to_string());
diff --git a/src/transport-widget.c b/src/transport-widget.c
index c53513d..10b96df 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -61,7 +61,9 @@ static gboolean transport_widget_button_press_event (GtkWidget *men
GdkEventButton *event);
static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
GdkEventButton *event);
-
+static void transport_widget_play_clicked (GtkWidget* button,
+ TransportWidget* self);
+
static void transport_widget_property_update(DbusmenuMenuitem* item,
gchar * property,
GValue * value,
@@ -78,7 +80,9 @@ transport_widget_class_init (TransportWidgetClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkMenuItemClass *menu_item_class = GTK_MENU_ITEM_CLASS(klass);
+ menu_item_class->hide_on_activate = FALSE;
widget_class->button_press_event = transport_widget_button_press_event;
widget_class->button_release_event = transport_widget_button_release_event;
@@ -143,6 +147,8 @@ transport_widget_init (TransportWidget *self)
g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_property_update), self);
+ g_signal_connect(priv->play_button, "clicked", G_CALLBACK(transport_widget_play_clicked), self);
+
gtk_container_add (GTK_CONTAINER (self), priv->hbox);
gtk_widget_show_all (priv->hbox);
@@ -166,8 +172,10 @@ transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_debug("TransportWidget::menu_press_event");
+
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+ gtk_widget_event (priv->hbox, (GdkEvent*)event);
gboolean state = g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(priv->play_button)), ">") == 0;
gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button))));
@@ -181,11 +189,21 @@ transport_widget_button_press_event (GtkWidget *menuitem,
return TRUE;
}
+static void
+transport_widget_play_clicked(GtkWidget* button,
+ TransportWidget* self)
+{
+ g_debug("Transport_widget_play_clicked");
+}
+
static gboolean
transport_widget_button_release_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_debug("TransportWidget::menu_release_event");
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+ gtk_widget_event (priv->hbox, (GdkEvent*)event);
+
return TRUE;
}