diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/common-defs.h | 17 | ||||
-rw-r--r-- | src/metadata-menu-item.vala | 10 | ||||
-rw-r--r-- | src/metadata-widget.c | 12 | ||||
-rw-r--r-- | src/mpris-controller.vala | 10 | ||||
-rw-r--r-- | src/music-player-bridge.vala | 5 | ||||
-rw-r--r-- | src/player-controller.vala | 19 | ||||
-rw-r--r-- | src/scrub-menu-item.vala | 43 | ||||
-rw-r--r-- | src/scrub-widget.c | 117 | ||||
-rw-r--r-- | src/scrub-widget.h | 52 | ||||
-rw-r--r-- | src/sound-service.c | 4 | ||||
-rw-r--r-- | src/title-menu-item.vala | 8 | ||||
-rw-r--r-- | src/title-widget.c | 5 |
13 files changed, 264 insertions, 40 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 79ba7d2..a02c5a4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ libsoundmenu_la_SOURCES = \ indicator-sound.c \ title-widget.c \ title-widget.h \ + scrub-widget.h \ dbus-shared-names.h \ sound-service-client.h @@ -58,6 +59,7 @@ music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ metadata-menu-item.vala \ + scrub-menu-item.vala \ title-menu-item.vala \ player-controller.vala \ mpris-controller-v2.vala \ diff --git a/src/common-defs.h b/src/common-defs.h index 9c1fbab..3b54dd0 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -29,11 +29,16 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" #define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-transport-play-state" -#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_TITLE "x-canonical-metadata-text-title" -#define DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM "x-canonical-metadata-text-album" -#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-metadata-arturl" +#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-menu-item" +#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-artist" +#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-title" +#define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-album" +#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-arturl" #define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-menu-item" -#define DBUSMENU_TITLE_MENUITEM_TEXT_NAME "x-canonical-sound-menu-player-title-name" +#define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name" + +#define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-menu-item" +#define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-duration" +#define DBUSMENU_SCRUB_MENUITEM_POSITION "x-canonical-sound-menu-player-scrub-position" + diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index cfcb3bc..3af9ff1 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -31,17 +31,17 @@ public class MetadataMenuitem : PlayerItem public static HashSet<string> attributes_format() { HashSet<string> attrs = new HashSet<string>(); - attrs.add(MENUITEM_TEXT_TITLE); - attrs.add(MENUITEM_TEXT_ARTIST); - attrs.add(MENUITEM_TEXT_ALBUM); + attrs.add(MENUITEM_TITLE); + attrs.add(MENUITEM_ARTIST); + attrs.add(MENUITEM_ALBUM); attrs.add(MENUITEM_ARTURL); return attrs; } public bool populated() { - return (this.property_get(MENUITEM_TEXT_TITLE) != null && - this.property_get(MENUITEM_TEXT_TITLE) != ""); + return (this.property_get(MENUITEM_TITLE) != null && + this.property_get(MENUITEM_TITLE) != ""); } }
\ No newline at end of file diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 8235725..dce9226 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -109,7 +109,7 @@ metadata_widget_init (MetadataWidget *self) // artist GtkWidget* artist; artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, - DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST)); + DBUSMENU_METADATA_MENUITEM_ARTIST)); gtk_misc_set_alignment(GTK_MISC(artist), (gfloat)0, (gfloat)0); gtk_label_set_width_chars(GTK_LABEL(artist), 15); @@ -121,7 +121,7 @@ metadata_widget_init (MetadataWidget *self) // piece GtkWidget* piece; piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, - DBUSMENU_METADATA_MENUITEM_TEXT_TITLE)); + DBUSMENU_METADATA_MENUITEM_TITLE)); gtk_misc_set_alignment(GTK_MISC(piece), (gfloat)0, (gfloat)0); gtk_label_set_width_chars(GTK_LABEL(piece), 12); gtk_label_set_ellipsize(GTK_LABEL(piece), PANGO_ELLIPSIZE_MIDDLE); @@ -132,7 +132,7 @@ metadata_widget_init (MetadataWidget *self) // container GtkWidget* container; container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, - DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM)); + DBUSMENU_METADATA_MENUITEM_ALBUM)); gtk_misc_set_alignment(GTK_MISC(container), (gfloat)0, (gfloat)0); gtk_label_set_width_chars(GTK_LABEL(container), 15); gtk_label_set_ellipsize(GTK_LABEL(container), PANGO_ELLIPSIZE_MIDDLE); @@ -202,15 +202,15 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, MetadataWidget* mitem = METADATA_WIDGET(userdata); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem); - if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, property) == 0){ + if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTIST, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->artist_label), g_value_get_string(value)); style_artist_text(mitem); } - else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, property) == 0){ + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TITLE, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value)); style_title_text(mitem); } - else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, property) == 0){ + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ALBUM, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value)); style_album_text(mitem); } diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index 8dd0cc9..c3f21d8 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -56,8 +56,8 @@ public class MprisController : GLib.Object status st = this.mpris_player.GetStatus(); int play_state = st.playback; debug("GetStatusChange - play state %i", play_state); - (this.owner.custom_items[this.owner.TRANSPORT] as TransportMenuitem).change_play_state(play_state); - this.owner.custom_items[this.owner.METADATA].update(this.mpris_player.GetMetadata(), + (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(play_state); + this.owner.custom_items[PlayerController.widget_order.METADATA].update(this.mpris_player.GetMetadata(), MetadataMenuitem.attributes_format()); } @@ -66,8 +66,8 @@ public class MprisController : GLib.Object private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht) { debug("onTrackChange"); - this.owner.custom_items[this.owner.METADATA].reset(MetadataMenuitem.attributes_format()); - this.owner.custom_items[this.owner.METADATA].update(ht, + this.owner.custom_items[PlayerController.widget_order.METADATA].reset(MetadataMenuitem.attributes_format()); + this.owner.custom_items[PlayerController.widget_order.METADATA].update(ht, MetadataMenuitem.attributes_format()); } @@ -117,7 +117,7 @@ public class MprisController : GLib.Object Value v = Value(typeof(int)); v.set_int(play_state); ht.insert("state", v); - this.owner.custom_items[this.owner.TRANSPORT].update(ht, TransportMenuitem.attributes_format()); + this.owner.custom_items[PlayerController.widget_order.TRANSPORT].update(ht, TransportMenuitem.attributes_format()); } diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 2f87b2d..3ee7b55 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -77,7 +77,7 @@ public class MusicPlayerBridge : GLib.Object return 2; } else{ - return (2 + (this.registered_clients.size * 4)); + return (2 + (this.registered_clients.size * PlayerController.WIDGET_QUANTITY)); } } @@ -93,9 +93,8 @@ public class MusicPlayerBridge : GLib.Object this.registered_clients[client_name].update_state(PlayerController.state.READY); this.registered_clients[client_name].activate(); } - //else init a new one else{ - + //else init a new one PlayerController ctrl = new PlayerController(root_menu, client_name, calculate_menu_position(), diff --git a/src/player-controller.vala b/src/player-controller.vala index d272d14..db81ee2 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -23,8 +23,16 @@ using Gee; public class PlayerController : GLib.Object { - public const int METADATA = 2; - private const int TRANSPORT = 3; + public const int WIDGET_QUANTITY = 4;//for now //5; + + public static enum widget_order{ + SEPARATOR, + TITLE, + METADATA, + TRANSPORT + } + //public const int METADATA = 2; + //private const int TRANSPORT = 3; public enum state{ OFFLINE, @@ -51,7 +59,6 @@ public class PlayerController : GLib.Object this.custom_items = new ArrayList<PlayerItem>(); this.update_state(initial_state); this.menu_offset = offset; - debug("offset = %i", offset); construct_widgets(); establish_mpris_connection(); update_layout(); @@ -66,7 +73,7 @@ public class PlayerController : GLib.Object public void activate() { this.establish_mpris_connection(); - this.custom_items[METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, true); + this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, true); } /* @@ -126,8 +133,8 @@ public class PlayerController : GLib.Object visibility = false; } debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string()); - this.custom_items[TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); - this.custom_items[METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); + this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); + this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); // DEBUG if(this.mpris_adaptor == null){ warning("Why is the mpris object null"); diff --git a/src/scrub-menu-item.vala b/src/scrub-menu-item.vala index e69de29..409494a 100644 --- a/src/scrub-menu-item.vala +++ b/src/scrub-menu-item.vala @@ -0,0 +1,43 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using Dbusmenu; +using DbusmenuScrub; +using Gee; + +public class ScrubMenuitem : PlayerItem +{ + public ScrubMenuitem(PlayerController parent) + { + Object(item_type: MENUITEM_TYPE); + } + + public override void handle_event(string name, GLib.Value input_value, uint timestamp) + { + debug("handle_event for owner %s with owner state = %i", this.owner.name, this.owner.current_state); + } + + public static HashSet<string> attributes_format() + { + HashSet<string> attrs = new HashSet<string>(); + attrs.add(MENUITEM_DURATION); + attrs.add(MENUITEM_POSITION); + return attrs; + } +}
\ No newline at end of file diff --git a/src/scrub-widget.c b/src/scrub-widget.c index e69de29..f5e1eda 100644 --- a/src/scrub-widget.c +++ b/src/scrub-widget.c @@ -0,0 +1,117 @@ +/* +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/>. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <glib/gi18n.h> +#include "scrub-widget.h" +#include "common-defs.h" + + +typedef struct _ScrubWidgetPrivate ScrubWidgetPrivate; + +struct _ScrubWidgetPrivate +{ + DbusmenuMenuitem* twin_item; +}; + +#define SCRUB_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SCRUB_WIDGET_TYPE, ScrubWidgetPrivate)) + +/* Prototypes */ +static void scrub_widget_class_init (ScrubWidgetClass *klass); +static void scrub_widget_init (ScrubWidget *self); +static void scrub_widget_dispose (GObject *object); +static void scrub_widget_finalize (GObject *object); + +static void scrub_widget_property_update(DbusmenuMenuitem* item, gchar* property, + GValue* value, gpointer userdata); +static void scrub_widget_set_twin_item( ScrubWidget* self, + DbusmenuMenuitem* twin_item); + +G_DEFINE_TYPE (ScrubWidget, scrub_widget, G_TYPE_OBJECT); + +static void +scrub_widget_class_init (ScrubWidgetClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (ScrubWidgetPrivate)); + + gobject_class->dispose = scrub_widget_dispose; + gobject_class->finalize = scrub_widget_finalize; +} + +static void +scrub_widget_init (ScrubWidget *self) +{ + g_debug("ScrubWidget::scrub_widget_init"); + //ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self); +} + +static void +scrub_widget_dispose (GObject *object) +{ + G_OBJECT_CLASS (scrub_widget_parent_class)->dispose (object); +} + +static void +scrub_widget_finalize (GObject *object) +{ + G_OBJECT_CLASS (scrub_widget_parent_class)->finalize (object); +} + +static void +scrub_widget_property_update(DbusmenuMenuitem* item, gchar* property, + GValue* value, gpointer userdata) +{ + g_return_if_fail (IS_SCRUB_WIDGET (userdata)); + //ScrubWidget* mitem = SCRUB_WIDGET(userdata); + //ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); + + if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_DURATION, property) == 0){ + } + else if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_POSITION, property) == 0){ + } +} + +static void +scrub_widget_set_twin_item(ScrubWidget* self, + DbusmenuMenuitem* twin_item) +{ + ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self); + priv->twin_item = twin_item; + + g_signal_connect(G_OBJECT(twin_item), "property-changed", + G_CALLBACK(scrub_widget_property_update), self); +} + + /** + * scrub_widget_new: + * @returns: a new #ScrubWidget. + **/ +GtkWidget* +scrub_widget_new(DbusmenuMenuitem *item) +{ + GtkWidget* widget = g_object_new(SCRUB_WIDGET_TYPE, NULL); + scrub_widget_set_twin_item((ScrubWidget*)widget, item); + return widget; +} + diff --git a/src/scrub-widget.h b/src/scrub-widget.h index e69de29..2b72c74 100644 --- a/src/scrub-widget.h +++ b/src/scrub-widget.h @@ -0,0 +1,52 @@ +s/* +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 __SCRUB_WIDGET_H__ +#define __SCRUB_WIDGET_H__ + +#include <glib.h> +#include <glib-object.h> +#include <libdbusmenu-gtk/menu.h> + +G_BEGIN_DECLS + +#define SCRUB_WIDGET_TYPE (scrub_widget_get_type ()) +#define SCRUB_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRUB_WIDGET_TYPE, ScrubWidget)) +#define SCRUB_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRUB_WIDGET_TYPE, ScrubWidgetClass)) +#define IS_SCRUB_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRUB_WIDGET_TYPE)) +#define IS_SCRUB_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRUB_WIDGET_TYPE)) +#define SCRUB_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRUB_WIDGET_TYPE, ScrubWidgetClass)) + +typedef struct _ScrubWidget ScrubWidget; +typedef struct _ScrubWidgetClass ScrubWidgetClass; + +struct _ScrubWidgetClass { + GObjectClass parent_class; +}; + +struct _ScrubWidget { + GObject parent; +}; + +GType scrub_widget_get_type (void) G_GNUC_CONST; +GtkWidget* scrub_widget_new(DbusmenuMenuitem *twin_item); + +G_END_DECLS + +#endif + diff --git a/src/sound-service.c b/src/sound-service.c index 8f4e941..a5f3941 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -43,8 +43,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/title-menu-item.vala b/src/title-menu-item.vala index 8183821..d7e16df 100644 --- a/src/title-menu-item.vala +++ b/src/title-menu-item.vala @@ -26,13 +26,11 @@ public class TitleMenuitem : PlayerItem public TitleMenuitem(PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); - this.property_set(MENUITEM_TEXT_NAME, parent.name); + this.property_set(MENUITEM_NAME, parent.name); } public override void handle_event(string name, GLib.Value input_value, uint timestamp) - { - debug("handle_event for owner %s with owner state = %i and title menu name %s", this.owner.name, this.owner.current_state, property_get(MENUITEM_TEXT_NAME)); - + { if(this.owner.current_state == PlayerController.state.OFFLINE) { this.owner.instantiate(); @@ -43,7 +41,7 @@ public class TitleMenuitem : PlayerItem public static HashSet<string> attributes_format() { HashSet<string> attrs = new HashSet<string>(); - attrs.add(MENUITEM_TEXT_NAME); + attrs.add(MENUITEM_NAME); return attrs; } }
\ No newline at end of file diff --git a/src/title-widget.c b/src/title-widget.c index 7e48940..5de2fb8 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -23,6 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib/gi18n.h> #include "title-widget.h" +#include "scrub-widget.h" #include "common-defs.h" #include <gtk/gtk.h> #include <libindicator/indicator-image-helper.h> @@ -152,7 +153,7 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, TitleWidget* mitem = TITLE_WIDGET(userdata); TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(mitem); - if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_TEXT_NAME, property) == 0){ + if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value)); title_widget_style_name_text(mitem); } @@ -167,7 +168,7 @@ title_widget_set_twin_item(TitleWidget* self, g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(title_widget_property_update), self); priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_TITLE_MENUITEM_TEXT_NAME)); + DBUSMENU_TITLE_MENUITEM_NAME)); gtk_misc_set_padding(GTK_MISC(priv->name), 10, 0); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0); |