aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am28
-rw-r--r--src/Makefile.in38
-rw-r--r--src/familiar-players-db.c2
-rw-r--r--src/fetch-file.c2
-rw-r--r--src/indicator-sound.c58
-rw-r--r--src/metadata-menu-item.c2
-rw-r--r--src/metadata-widget.c92
-rw-r--r--src/mpris2-controller.c8
-rw-r--r--src/mpris2-controller.vala5
-rw-r--r--src/music-player-bridge.c382
-rw-r--r--src/music-player-bridge.h6
-rw-r--r--src/music-player-bridge.vala157
-rw-r--r--src/play-button.c1224
-rw-r--r--src/play-button.h68
-rw-r--r--src/player-controller.c6
-rw-r--r--src/player-controller.vala4
-rw-r--r--src/player-item.c2
-rw-r--r--src/pulse-manager.c31
-rw-r--r--src/sound-service-server.h3
-rw-r--r--src/title-menu-item.c2
-rw-r--r--src/title-widget.c33
-rw-r--r--src/transport-menu-item.c2
-rw-r--r--src/transport-widget.c1270
-rw-r--r--src/transport-widget.h15
-rw-r--r--src/volume-widget.c10
25 files changed, 1565 insertions, 1885 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index aa5fdc7..b23e9c1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,21 +7,19 @@ libexec_PROGRAMS = indicator-sound-service
soundmenulibdir = $(INDICATORDIR)
soundmenulib_LTLIBRARIES = libsoundmenu.la
libsoundmenu_la_SOURCES = \
- common-defs.h \
- indicator-sound.h \
- transport-widget.c \
- transport-widget.h \
- metadata-widget.c \
- metadata-widget.h \
- play-button.c \
- play-button.h \
- indicator-sound.c \
- title-widget.c \
- title-widget.h \
- volume-widget.c \
- volume-widget.h \
- dbus-shared-names.h \
- sound-service-client.h
+ common-defs.h \
+ indicator-sound.h \
+ transport-widget.c \
+ transport-widget.h \
+ metadata-widget.c \
+ metadata-widget.h \
+ indicator-sound.c \
+ title-widget.c \
+ title-widget.h \
+ volume-widget.c \
+ volume-widget.h \
+ dbus-shared-names.h \
+ sound-service-client.h
libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -DG_LOG_DOMAIN=\"Indicator-Sound\"
libsoundmenu_la_LIBADD = $(APPLET_LIBS)
diff --git a/src/Makefile.in b/src/Makefile.in
index 7a9cd47..088cefe 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -74,7 +74,6 @@ am__DEPENDENCIES_1 =
libsoundmenu_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_libsoundmenu_la_OBJECTS = libsoundmenu_la-transport-widget.lo \
libsoundmenu_la-metadata-widget.lo \
- libsoundmenu_la-play-button.lo \
libsoundmenu_la-indicator-sound.lo \
libsoundmenu_la-title-widget.lo \
libsoundmenu_la-volume-widget.lo
@@ -307,21 +306,19 @@ top_srcdir = @top_srcdir@
soundmenulibdir = $(INDICATORDIR)
soundmenulib_LTLIBRARIES = libsoundmenu.la
libsoundmenu_la_SOURCES = \
- common-defs.h \
- indicator-sound.h \
- transport-widget.c \
- transport-widget.h \
- metadata-widget.c \
- metadata-widget.h \
- play-button.c \
- play-button.h \
- indicator-sound.c \
- title-widget.c \
- title-widget.h \
- volume-widget.c \
- volume-widget.h \
- dbus-shared-names.h \
- sound-service-client.h
+ common-defs.h \
+ indicator-sound.h \
+ transport-widget.c \
+ transport-widget.h \
+ metadata-widget.c \
+ metadata-widget.h \
+ indicator-sound.c \
+ title-widget.c \
+ title-widget.h \
+ volume-widget.c \
+ volume-widget.h \
+ dbus-shared-names.h \
+ sound-service-client.h
libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -DG_LOG_DOMAIN=\"Indicator-Sound\"
libsoundmenu_la_LIBADD = $(APPLET_LIBS)
@@ -541,7 +538,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-transport-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-indicator-sound.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-metadata-widget.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-play-button.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-title-widget.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-transport-widget.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-volume-widget.Plo@am__quote@
@@ -586,14 +582,6 @@ libsoundmenu_la-metadata-widget.lo: metadata-widget.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -c -o libsoundmenu_la-metadata-widget.lo `test -f 'metadata-widget.c' || echo '$(srcdir)/'`metadata-widget.c
-libsoundmenu_la-play-button.lo: play-button.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -MT libsoundmenu_la-play-button.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-play-button.Tpo -c -o libsoundmenu_la-play-button.lo `test -f 'play-button.c' || echo '$(srcdir)/'`play-button.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-play-button.Tpo $(DEPDIR)/libsoundmenu_la-play-button.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='play-button.c' object='libsoundmenu_la-play-button.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -c -o libsoundmenu_la-play-button.lo `test -f 'play-button.c' || echo '$(srcdir)/'`play-button.c
-
libsoundmenu_la-indicator-sound.lo: indicator-sound.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -MT libsoundmenu_la-indicator-sound.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-indicator-sound.Tpo -c -o libsoundmenu_la-indicator-sound.lo `test -f 'indicator-sound.c' || echo '$(srcdir)/'`indicator-sound.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-indicator-sound.Tpo $(DEPDIR)/libsoundmenu_la-indicator-sound.Plo
diff --git a/src/familiar-players-db.c b/src/familiar-players-db.c
index 2556b6c..e0fff11 100644
--- a/src/familiar-players-db.c
+++ b/src/familiar-players-db.c
@@ -1,4 +1,4 @@
-/* familiar-players-db.c generated by valac 0.9.8, the Vala compiler
+/* familiar-players-db.c generated by valac 0.10.0, the Vala compiler
* generated from familiar-players-db.vala, do not modify */
/*
diff --git a/src/fetch-file.c b/src/fetch-file.c
index 4a8d595..c5a22ac 100644
--- a/src/fetch-file.c
+++ b/src/fetch-file.c
@@ -1,4 +1,4 @@
-/* fetch-file.c generated by valac 0.9.8, the Vala compiler
+/* fetch-file.c generated by valac 0.10.0, the Vala compiler
* generated from fetch-file.vala, do not modify */
/*
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 35045d7..13f1529 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -68,7 +68,6 @@ static GtkImage * get_icon (IndicatorObject * io);
static GtkMenu * get_menu (IndicatorObject * io);
static void indicator_sound_scroll (IndicatorObject* io, gint delta, IndicatorScrollDirection direction);
-
//Slider related
static gboolean new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data);
@@ -196,12 +195,13 @@ get_label (IndicatorObject * io)
static GtkImage *
get_icon (IndicatorObject * io)
{
- gchar* current_name = g_hash_table_lookup(volume_states,
+ gchar* current_name = g_hash_table_lookup(volume_states,
GINT_TO_POINTER(current_state));
- g_debug("At start-up attempting to set the image to %s",
- current_name);
+ //g_debug("At start-up attempting to set the image to %s",
+ // current_name);
speaker_image = indicator_image_helper(current_name);
gtk_widget_show(GTK_WIDGET(speaker_image));
+
return speaker_image;
}
@@ -238,7 +238,7 @@ free_the_animation_list()
static gboolean
new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
- g_debug("indicator-sound: new_transport_bar() called ");
+ //g_debug("indicator-sound: new_transport_bar() called ");
GtkWidget* bar = NULL;
@@ -257,7 +257,7 @@ new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbus
static gboolean
new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
- g_debug("indicator-sound: new_metadata_widget");
+ //g_debug("indicator-sound: new_metadata_widget");
GtkWidget* metadata = NULL;
@@ -276,11 +276,11 @@ new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
static gboolean
new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
- g_debug("indicator-sound: new_title_widget");
+ //g_debug("indicator-sound: new_title_widget");
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
- g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME));
+ //g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME));
GtkWidget* title = NULL;
@@ -298,7 +298,7 @@ new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu
static gboolean
new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
- g_debug("indicator-sound: new_volume_slider_widget");
+ //g_debug("indicator-sound: new_volume_slider_widget");
GtkWidget* volume_widget = NULL;
IndicatorObject *io = NULL;
@@ -324,6 +324,8 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent,
newitem,
menu_volume_item,
parent);
+ fetch_mute_value_from_dbus();
+ fetch_sink_availability_from_dbus(INDICATOR_SOUND (io));
return TRUE;
}
@@ -352,13 +354,14 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u
g_warning("Unable to get status proxy: %s", error->message);
g_error_free(error);
}
- g_debug("about to connect to the signals");
+ //g_debug("about to connect to the signals");
dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_TYPE_BOOLEAN, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL);
dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_CALLBACK(catch_signal_sink_mute_update), user_data, NULL);
dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL);
+
if( service_restart == TRUE){
fetch_mute_value_from_dbus();
// Ensure UI is in sync with service again.
@@ -420,7 +423,7 @@ prepare_blocked_animation()
GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image);
if (mute_buf == NULL || blocked_buf == NULL) {
- g_debug("Don bother with the animation, the theme aint got the goods !");
+ //g_debug("Don bother with the animation, the theme aint got the goods !");
return;
}
@@ -512,7 +515,7 @@ fade_back_to_mute_image()
return TRUE;
} else {
animation_id = 0;
- g_debug("exit from animation now\n");
+ //g_debug("exit from animation now\n");
return FALSE;
}
}
@@ -521,12 +524,12 @@ static void
reset_mute_blocking_animation()
{
if (animation_id != 0) {
- g_debug("about to remove the animation_id callback from the mainloop!!**");
+ //g_debug("about to remove the animation_id callback from the mainloop!!**");
g_source_remove(animation_id);
animation_id = 0;
}
if (blocked_id != 0) {
- g_debug("about to remove the blocked_id callback from the mainloop!!**");
+ //g_debug("about to remove the blocked_id callback from the mainloop!!**");
g_source_remove(blocked_id);
blocked_id = 0;
}
@@ -555,7 +558,7 @@ fetch_sink_availability_from_dbus(IndicatorSound* self)
device_available = *available_input;
if (device_available == FALSE) {
update_state(STATE_SINKS_NONE);
- g_debug("NO DEVICE AVAILABLE");
+ //g_debug("NO DEVICE AVAILABLE");
}
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
@@ -566,7 +569,7 @@ fetch_sink_availability_from_dbus(IndicatorSound* self)
}
g_free(available_input);
- g_debug("IndicatorSound::fetch_sink_availability_from_dbus ->%i", device_available);
+ //g_debug("IndicatorSound::fetch_sink_availability_from_dbus ->%i", device_available);
}
@@ -584,10 +587,11 @@ fetch_mute_value_from_dbus()
return;
}
initial_mute = *mute_input;
- if (initial_mute == TRUE)
+ if (initial_mute == TRUE){
update_state(STATE_MUTED);
+ }
g_free(mute_input);
- g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute);
+ //g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute);
}
/*******************************************************************/
@@ -596,7 +600,7 @@ fetch_mute_value_from_dbus()
static void
catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata)
{
- g_debug("signal caught - sink input while muted with value %i", block_value);
+ //g_debug("signal caught - sink input while muted with value %i", block_value);
if (block_value == 1 && blocked_id == 0 && animation_id == 0 && blocked_animation_list != NULL) {
gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT));
indicator_image_helper_update(speaker_image, image_name);
@@ -616,7 +620,7 @@ catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer u
} else {
reset_mute_blocking_animation();
}
- g_debug("signal caught - sink mute update with mute value: %i", mute_value);
+ //g_debug("signal caught - sink mute update with mute value: %i", mute_value);
g_return_if_fail(IS_INDICATOR_SOUND(userdata));
IndicatorSound* indicator = INDICATOR_SOUND(userdata);
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(indicator);
@@ -636,7 +640,7 @@ catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_valu
if (device_available == FALSE) {
update_state(STATE_SINKS_NONE);
}
- g_debug("signal caught - sink availability update with value: %i", available_value);
+ //g_debug("signal caught - sink availability update with value: %i", available_value);
}
/*******************************************************************/
@@ -701,7 +705,7 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
}
new_value = CLAMP(new_value, 0, 100);
if (new_value != current_value && current_state != STATE_MUTED) {
- g_debug("Attempting to set the range from the key listener to %f", new_value);
+ //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);
}
}
@@ -711,7 +715,7 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
static void
style_changed_cb(GtkWidget *widget, gpointer user_data)
{
- g_debug("Just caught a style change event");
+ //g_debug("Just caught a style change event");
update_state(current_state);
reset_mute_blocking_animation();
update_state(current_state);
@@ -722,7 +726,7 @@ style_changed_cb(GtkWidget *widget, gpointer user_data)
static void
indicator_sound_scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction)
{
- g_debug("indicator-sound-scroll - current slider value");
+ //g_debug("indicator-sound-scroll - current slider value");
if (device_available == FALSE || current_state == STATE_MUTED)
return;
@@ -736,12 +740,12 @@ indicator_sound_scroll (IndicatorObject *io, gint delta, IndicatorScrollDirectio
gdouble value = gtk_range_get_value(range);
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider));
- g_debug("indicator-sound-scroll - current slider value %f", value);
+ //g_debug("indicator-sound-scroll - current slider value %f", value);
if (direction == INDICATOR_OBJECT_SCROLL_UP) {
value += adj->step_increment;
} else {
value -= adj->step_increment;
}
- g_debug("indicator-sound-scroll - update slider with value %f", value);
+ //g_debug("indicator-sound-scroll - update slider with value %f", value);
volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value);
-} \ No newline at end of file
+}
diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c
index 07f18e5..5cb2d03 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.9.8, the Vala compiler
+/* metadata-menu-item.c generated by valac 0.10.0, the Vala compiler
* generated from metadata-menu-item.vala, do not modify */
/*
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index 7179014..cbbaeff 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -27,7 +27,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gtk/gtk.h>
#include <glib.h>
-static DbusmenuMenuitem* twin_item;
typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate;
@@ -40,7 +39,8 @@ struct _MetadataWidgetPrivate
GString* old_image_path;
GtkWidget* artist_label;
GtkWidget* piece_label;
- GtkWidget* container_label;
+ GtkWidget* container_label;
+ DbusmenuMenuitem* twin_item;
};
#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate))
@@ -51,8 +51,8 @@ static void metadata_widget_init (MetadataWidget *self);
static void metadata_widget_dispose (GObject *object);
static void metadata_widget_finalize (GObject *object);
static gboolean metadata_image_expose (GtkWidget *image, GdkEventExpose *event, gpointer user_data);
-//static void metadata_widget_style_changed_cb(GtkWidget *widget, gpointer user_data);
static void metadata_widget_set_style (GtkWidget* button, GtkStyle* style);
+static void metadata_widget_set_twin_item (MetadataWidget* self, DbusmenuMenuitem* twin_item);
// keyevent consumers
static gboolean metadata_widget_button_press_event (GtkWidget *menuitem,
@@ -89,7 +89,7 @@ metadata_widget_class_init (MetadataWidgetClass *klass)
static void
metadata_widget_init (MetadataWidget *self)
{
- g_debug("MetadataWidget::metadata_widget_init");
+ //g_debug("MetadataWidget::metadata_widget_init");
MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
GtkWidget *hbox;
@@ -99,9 +99,9 @@ metadata_widget_init (MetadataWidget *self)
// image
priv->album_art = gtk_image_new();
- priv->image_path = g_string_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL));
+ priv->image_path = g_string_new(dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL));
priv->old_image_path = g_string_new("");
- g_debug("Metadata::At startup and image path = %s", priv->image_path->str);
+ //g_debug("Metadata::At startup and image path = %s", priv->image_path->str);
g_signal_connect(priv->album_art, "expose-event",
G_CALLBACK(metadata_image_expose),
@@ -116,33 +116,33 @@ metadata_widget_init (MetadataWidget *self)
// artist
GtkWidget* artist;
- artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
+ artist = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item,
DBUSMENU_METADATA_MENUITEM_ARTIST));
gtk_misc_set_alignment(GTK_MISC(artist), (gfloat)0, (gfloat)0);
gtk_misc_set_padding (GTK_MISC(artist), (gfloat)10, (gfloat)0);
- gtk_label_set_width_chars(GTK_LABEL(artist), 15);
- gtk_label_set_ellipsize(GTK_LABEL(artist), PANGO_ELLIPSIZE_MIDDLE);
+ gtk_widget_set_size_request (artist, 140, 15);
+ gtk_label_set_ellipsize(GTK_LABEL(artist), PANGO_ELLIPSIZE_MIDDLE);
metadata_widget_style_labels(self, GTK_LABEL(artist));
priv->artist_label = artist;
// title
GtkWidget* piece;
- piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
- DBUSMENU_METADATA_MENUITEM_TITLE));
+ piece = gtk_label_new(dbusmenu_menuitem_property_get( priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_TITLE) );
gtk_misc_set_alignment(GTK_MISC(piece), (gfloat)0, (gfloat)0);
gtk_misc_set_padding (GTK_MISC(piece), (gfloat)10, (gfloat)0);
- gtk_label_set_width_chars(GTK_LABEL(piece), 15);
- gtk_label_set_ellipsize(GTK_LABEL(piece), PANGO_ELLIPSIZE_MIDDLE);
+ gtk_widget_set_size_request (piece, 140, 15);
+ gtk_label_set_ellipsize(GTK_LABEL(piece), PANGO_ELLIPSIZE_MIDDLE);
metadata_widget_style_labels(self, GTK_LABEL(piece));
priv->piece_label = piece;
// container
GtkWidget* container;
- container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
- DBUSMENU_METADATA_MENUITEM_ALBUM));
+ container = gtk_label_new(dbusmenu_menuitem_property_get( priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_ALBUM) );
gtk_misc_set_alignment(GTK_MISC(container), (gfloat)0, (gfloat)0);
gtk_misc_set_padding (GTK_MISC(container), (gfloat)10, (gfloat)0);
- gtk_label_set_width_chars(GTK_LABEL(container), 15);
+ gtk_widget_set_size_request (container, 140, 15);
gtk_label_set_ellipsize(GTK_LABEL(container), PANGO_ELLIPSIZE_MIDDLE);
metadata_widget_style_labels(self, GTK_LABEL(container));
priv->container_label = container;
@@ -153,8 +153,6 @@ metadata_widget_init (MetadataWidget *self)
gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(twin_item), "property-changed",
- G_CALLBACK(metadata_widget_property_update), self);
gtk_widget_show_all (priv->hbox);
g_signal_connect(self, "style-set", G_CALLBACK(metadata_widget_set_style), GTK_WIDGET(self));
@@ -192,10 +190,10 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user
priv->theme_change_occured = FALSE;
GdkPixbuf* pixbuf;
pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
- g_debug("metadata_load_new_image -> pixbuf from %s",
- priv->image_path->str);
+ //g_debug("metadata_load_new_image -> pixbuf from %s",
+ // priv->image_path->str);
if(GDK_IS_PIXBUF(pixbuf) == FALSE){
- g_debug("problem loading the downloaded image just use the placeholder instead");
+ //g_debug("problem loading the downloaded image just use the placeholder instead");
draw_album_art_placeholder(metadata);
return TRUE;
}
@@ -212,9 +210,9 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user
return TRUE;
}
-static void draw_album_art_placeholder(GtkWidget *metadata)
-{
-
+static void
+draw_album_art_placeholder(GtkWidget *metadata)
+{
cairo_t *cr;
cr = gdk_cairo_create (metadata->window);
GtkStyle *style;
@@ -287,20 +285,20 @@ metadata_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
GtkClipboard* board = gtk_clipboard_get (GDK_NONE);
- gchar* title = g_strdup(dbusmenu_menuitem_property_get(twin_item,
- DBUSMENU_METADATA_MENUITEM_TITLE));
- gchar* artist = g_strdup(dbusmenu_menuitem_property_get(twin_item,
- DBUSMENU_METADATA_MENUITEM_ARTIST));
- gchar* album = g_strdup(dbusmenu_menuitem_property_get(twin_item,
- DBUSMENU_METADATA_MENUITEM_ALBUM));
- gchar* contents = g_strdup_printf("artist: %s \ntitle: %s \nalbum: %s", artist, title, album);
- g_debug("contents to be copied will be : %s", contents);
+
+ MetadataWidgetPrivate* priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(menuitem));
+
+ gchar* contents = g_strdup_printf("artist: %s \ntitle: %s \nalbum: %s",
+ dbusmenu_menuitem_property_get(priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_ARTIST),
+ dbusmenu_menuitem_property_get(priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_TITLE),
+ dbusmenu_menuitem_property_get(priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_ALBUM));
+ //g_debug("contents to be copied will be : %s", contents);
gtk_clipboard_set_text (board, contents, -1);
gtk_clipboard_store (board);
g_free(contents);
- g_free(title);
- g_free(artist);
- g_free(album);
return FALSE;
}
@@ -312,7 +310,7 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
g_return_if_fail (IS_METADATA_WIDGET (userdata));
if(g_value_get_int(value) == DBUSMENU_PROPERTY_EMPTY){
- g_debug("Metadata widget: property update - reset");
+ //g_debug("Metadata widget: property update - reset");
GValue new_value = {0};
g_value_init(&new_value, G_TYPE_STRING);
g_value_set_string(&new_value, g_strdup(""));
@@ -339,7 +337,7 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
g_string_overwrite(priv->image_path, 0, g_value_get_string (value));
// if its a remote image queue a redraw incase the download took too long
if (g_str_has_prefix(g_value_get_string (value), g_get_user_cache_dir())){
- g_debug("the image update is a download so redraw");
+ //g_debug("the image update is a download so redraw");
gtk_widget_queue_draw(GTK_WIDGET(mitem));
}
}
@@ -489,7 +487,6 @@ image_set_from_pixbuf (GtkWidget *widget,
cairo_destroy (cr);
}
-// TODO refactor next 3 methods into one once the style has been
static void
metadata_widget_style_labels(MetadataWidget* self, GtkLabel* label)
{
@@ -508,9 +505,19 @@ metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style)
MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widg);
priv->theme_change_occured = TRUE;
gtk_widget_queue_draw(GTK_WIDGET(metadata));
- g_debug("metadata_widget: theme change");
}
+static void
+metadata_widget_set_twin_item(MetadataWidget* self,
+ DbusmenuMenuitem* twin_item)
+{
+ MetadataWidgetPrivate* priv = METADATA_WIDGET_GET_PRIVATE(self);
+ priv->twin_item = twin_item;
+ g_signal_connect(G_OBJECT(priv->twin_item), "property-changed",
+ G_CALLBACK(metadata_widget_property_update), self);
+}
+
+
/**
* transport_new:
* @returns: a new #MetadataWidget.
@@ -518,7 +525,10 @@ metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style)
GtkWidget*
metadata_widget_new(DbusmenuMenuitem *item)
{
- twin_item = item;
- return g_object_new(METADATA_WIDGET_TYPE, NULL);
+
+ GtkWidget* widget = g_object_new(METADATA_WIDGET_TYPE, NULL);
+ metadata_widget_set_twin_item ( METADATA_WIDGET(widget),
+ item );
+ return widget;
}
diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c
index ac90fc4..ced6bdb 100644
--- a/src/mpris2-controller.c
+++ b/src/mpris2-controller.c
@@ -1,4 +1,4 @@
-/* mpris2-controller.c generated by valac 0.9.8, the Vala compiler
+/* mpris2-controller.c generated by valac 0.10.0, the Vala compiler
* generated from mpris2-controller.vala, do not modify */
/*
@@ -4571,10 +4571,6 @@ static TransportMenuitemstate mpris2_controller_determine_play_state (Mpris2Cont
gboolean _tmp0_ = FALSE;
g_return_val_if_fail (self != NULL, 0);
g_return_val_if_fail (status != NULL, 0);
- if (status == NULL) {
- result = TRANSPORT_MENUITEM_STATE_PAUSED;
- return result;
- }
if (status != NULL) {
_tmp0_ = _vala_strcmp0 (status, "Playing") == 0;
} else {
@@ -4618,7 +4614,7 @@ void mpris2_controller_initial_update (Mpris2Controller* self) {
void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command) {
g_return_if_fail (self != NULL);
- g_debug ("mpris2-controller.vala:165: transport_event input = %i", (gint) command);
+ g_debug ("mpris2-controller.vala:162: transport_event input = %i", (gint) command);
if (command == TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE) {
mpris_player_PlayPause (self->priv->_player, NULL, NULL);
} else {
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 54e1868..29dd4cf 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -135,10 +135,7 @@ public class Mpris2Controller : GLib.Object
return changed_updates;
}
- private TransportMenuitem.state determine_play_state(string status){
- if(status == null)
- return TransportMenuitem.state.PAUSED;
-
+ private TransportMenuitem.state determine_play_state(string status){
if(status != null && status == "Playing"){
return TransportMenuitem.state.PLAYING;
}
diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c
index f139738..3746bf6 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.9.8, the Vala compiler
+/* music-player-bridge.c generated by valac 0.10.0, the Vala compiler
* generated from music-player-bridge.vala, do not modify */
/*
@@ -111,36 +111,29 @@ MusicPlayerBridge* music_player_bridge_new (void);
MusicPlayerBridge* music_player_bridge_construct (GType object_type);
FamiliarPlayersDB* familiar_players_db_new (void);
FamiliarPlayersDB* familiar_players_db_construct (GType object_type);
-void music_player_bridge_on_indicator_added (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0);
-static void _music_player_bridge_on_indicator_added_indicate_listener_indicator_added (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, gpointer self);
-void music_player_bridge_on_indicator_removed (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0);
-static void _music_player_bridge_on_indicator_removed_indicate_listener_indicator_removed (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, gpointer self);
-void music_player_bridge_on_indicator_modified (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* s);
-static void _music_player_bridge_on_indicator_modified_indicate_listener_indicator_modified (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* p1, gpointer self);
void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type);
static void _music_player_bridge_on_server_added_indicate_listener_server_added (IndicateListener* _sender, IndicateListenerServer* object, const char* p0, gpointer self);
void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type);
static void _music_player_bridge_on_server_removed_indicate_listener_server_removed (IndicateListener* _sender, IndicateListenerServer* object, const char* p0, gpointer self);
-void music_player_bridge_on_server_count_changed (MusicPlayerBridge* self, IndicateListenerServer* object, guint i);
-static void _music_player_bridge_on_server_count_changed_indicate_listener_server_count_changed (IndicateListener* _sender, IndicateListenerServer* object, guint p0, gpointer self);
static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlayerBridge* self);
GeeSet* familiar_players_db_records (FamiliarPlayersDB* self);
-static char* music_player_bridge_truncate_player_name (const char* app_info_name);
+static char* music_player_bridge_truncate_player_name (char* app_info_name);
static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self);
GType player_controller_state_get_type (void) G_GNUC_CONST;
PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
void player_controller_set_app_info (PlayerController* self, GAppInfo* value);
GAppInfo* player_controller_get_app_info (PlayerController* self);
+static char* music_player_bridge_determine_key (char* path);
#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4
static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type);
-void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state);
-void player_controller_activate (PlayerController* self);
static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, IndicateListenerServer* server, char* path, void* data);
-void player_controller_hibernate (PlayerController* self);
+GAppInfo* music_player_bridge_create_app_info (const char* path);
gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const char* desktop);
void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop);
-GAppInfo* music_player_bridge_create_app_info (const char* path);
+void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state);
+void player_controller_activate (PlayerController* self);
+void player_controller_hibernate (PlayerController* self);
void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu);
static void music_player_bridge_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
@@ -149,21 +142,6 @@ static gint _vala_array_length (gpointer array);
-static void _music_player_bridge_on_indicator_added_indicate_listener_indicator_added (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, gpointer self) {
- music_player_bridge_on_indicator_added (self, object, p0);
-}
-
-
-static void _music_player_bridge_on_indicator_removed_indicate_listener_indicator_removed (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, gpointer self) {
- music_player_bridge_on_indicator_removed (self, object, p0);
-}
-
-
-static void _music_player_bridge_on_indicator_modified_indicate_listener_indicator_modified (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* p1, gpointer self) {
- music_player_bridge_on_indicator_modified (self, object, p0, p1);
-}
-
-
static void _music_player_bridge_on_server_added_indicate_listener_server_added (IndicateListener* _sender, IndicateListenerServer* object, const char* p0, gpointer self) {
music_player_bridge_on_server_added (self, object, p0);
}
@@ -174,11 +152,6 @@ static void _music_player_bridge_on_server_removed_indicate_listener_server_remo
}
-static void _music_player_bridge_on_server_count_changed_indicate_listener_server_count_changed (IndicateListener* _sender, IndicateListenerServer* object, guint p0, gpointer self) {
- music_player_bridge_on_server_count_changed (self, object, p0);
-}
-
-
MusicPlayerBridge* music_player_bridge_construct (GType object_type) {
MusicPlayerBridge * self;
FamiliarPlayersDB* _tmp0_;
@@ -188,12 +161,8 @@ MusicPlayerBridge* music_player_bridge_construct (GType object_type) {
self->priv->playersDB = (_tmp0_ = familiar_players_db_new (), _g_object_unref0 (self->priv->playersDB), _tmp0_);
self->priv->registered_clients = (_tmp1_ = 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), _g_object_unref0 (self->priv->registered_clients), _tmp1_);
self->priv->listener = (_tmp2_ = indicate_listener_ref_default (), _g_object_unref0 (self->priv->listener), _tmp2_);
- g_signal_connect_object (self->priv->listener, "indicator-added", (GCallback) _music_player_bridge_on_indicator_added_indicate_listener_indicator_added, self, 0);
- g_signal_connect_object (self->priv->listener, "indicator-removed", (GCallback) _music_player_bridge_on_indicator_removed_indicate_listener_indicator_removed, self, 0);
- g_signal_connect_object (self->priv->listener, "indicator-modified", (GCallback) _music_player_bridge_on_indicator_modified_indicate_listener_indicator_modified, self, 0);
g_signal_connect_object (self->priv->listener, "server-added", (GCallback) _music_player_bridge_on_server_added_indicate_listener_server_added, self, 0);
g_signal_connect_object (self->priv->listener, "server-removed", (GCallback) _music_player_bridge_on_server_removed_indicate_listener_server_removed, self, 0);
- g_signal_connect_object (self->priv->listener, "server-count-changed", (GCallback) _music_player_bridge_on_server_count_changed_indicate_listener_server_count_changed, self, 0);
return self;
}
@@ -229,27 +198,27 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye
}
app = (char*) gee_iterator_get (_app_it);
if (app == NULL) {
- g_warning ("music-player-bridge.vala:49: App string in keyfile is null therefore m" \
+ g_warning ("music-player-bridge.vala:45: App string in keyfile is null therefore m" \
"oving on to next player");
_g_free0 (app);
continue;
}
- g_debug ("music-player-bridge.vala:53: attempting to make an app info from %s", app);
+ g_debug ("music-player-bridge.vala:49: attempting to make an app info from %s", app);
info = g_desktop_app_info_new_from_filename (app);
if (info == NULL) {
- g_warning ("music-player-bridge.vala:57: Could not create a desktopappinfo instanc" \
+ g_warning ("music-player-bridge.vala:54: Could not create a desktopappinfo instanc" \
"e from app: %s", app);
_g_object_unref0 (info);
_g_free0 (app);
continue;
}
app_info = _g_object_ref0 ((_tmp2_ = info, G_IS_APP_INFO (_tmp2_) ? ((GAppInfo*) _tmp2_) : NULL));
- ctrl = (_tmp4_ = player_controller_new (self->priv->root_menu, _tmp3_ = music_player_bridge_truncate_player_name (g_app_info_get_name (app_info)), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE), _g_free0 (_tmp3_), _tmp4_);
+ ctrl = (_tmp4_ = player_controller_new (self->priv->root_menu, _tmp3_ = music_player_bridge_truncate_player_name (g_strdup (g_app_info_get_name (app_info))), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE), _g_free0 (_tmp3_), _tmp4_);
player_controller_set_app_info (ctrl, app_info);
if (player_controller_get_app_info (ctrl) == NULL) {
- g_warning ("music-player-bridge.vala:69: for some reason the app info is null");
+ g_warning ("music-player-bridge.vala:65: for some reason the app info is null");
}
- gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp5_ = music_player_bridge_truncate_player_name (g_app_info_get_name (app_info)), ctrl);
+ gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp5_ = music_player_bridge_determine_key (g_strdup (app)), ctrl);
_g_free0 (_tmp5_);
_g_object_unref0 (ctrl);
_g_object_unref0 (app_info);
@@ -261,41 +230,6 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye
}
-static char* string_strip (const char* self) {
- char* result = NULL;
- char* _result_;
- g_return_val_if_fail (self != NULL, NULL);
- _result_ = g_strdup (self);
- g_strstrip (_result_);
- result = _result_;
- return result;
-}
-
-
-static char* music_player_bridge_truncate_player_name (const char* app_info_name) {
- char* result = NULL;
- char* _tmp0_;
- char* _tmp1_;
- char* _result_;
- gint tokens_length1;
- gint _tokens_size_;
- char** _tmp3_;
- char** _tmp2_;
- char** tokens;
- g_return_val_if_fail (app_info_name != NULL, NULL);
- _result_ = (_tmp1_ = string_strip (_tmp0_ = g_utf8_strdown (app_info_name, -1)), _g_free0 (_tmp0_), _tmp1_);
- tokens = (_tmp3_ = _tmp2_ = g_strsplit (_result_, " ", 0), tokens_length1 = _vala_array_length (_tmp2_), _tokens_size_ = tokens_length1, _tmp3_);
- if (tokens_length1 > 1) {
- char* _tmp4_;
- _result_ = (_tmp4_ = g_strdup (tokens[0]), _g_free0 (_result_), _tmp4_);
- }
- g_debug ("music-player-bridge.vala:84: truncate player name %s", _result_);
- result = _result_;
- tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
- return result;
-}
-
-
static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self) {
gint result = 0;
g_return_val_if_fail (self != NULL, 0);
@@ -310,84 +244,18 @@ static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self
void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) {
- char** _tmp0_;
- char** _tmp1_;
- gint _tmp1__length1;
- char* _tmp2_;
- char* client_name;
- gboolean _tmp3_ = FALSE;
g_return_if_fail (self != NULL);
g_return_if_fail (type != NULL);
- g_debug ("music-player-bridge.vala:100: MusicPlayerBridge -> on_server_added wit" \
-"h value %s", type);
+ g_debug ("music-player-bridge.vala:82: MusicPlayerBridge -> on_server_added with" \
+" value %s", type);
if (music_player_bridge_server_is_not_of_interest (self, type)) {
return;
}
- client_name = (_tmp2_ = g_strdup ((_tmp1_ = _tmp0_ = g_strsplit (type, ".", 0), _tmp1__length1 = _vala_array_length (_tmp0_), _tmp1_)[1]), _tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL), _tmp2_);
if (self->priv->root_menu != NULL) {
- _tmp3_ = client_name != NULL;
- } else {
- _tmp3_ = FALSE;
- }
- if (_tmp3_) {
- GeeSet* _tmp4_;
- gboolean _tmp5_;
- PlayerController* _tmp8_;
- gboolean _tmp9_;
- if ((_tmp5_ = gee_collection_contains ((GeeCollection*) (_tmp4_ = gee_map_get_keys ((GeeMap*) self->priv->registered_clients)), client_name), _g_object_unref0 (_tmp4_), _tmp5_)) {
- PlayerController* _tmp6_;
- PlayerController* _tmp7_;
- g_debug ("music-player-bridge.vala:106: It figured out that it already has an in" \
-"stance for this player already");
- player_controller_update_state (_tmp6_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name), PLAYER_CONTROLLER_STATE_READY);
- _g_object_unref0 (_tmp6_);
- player_controller_activate (_tmp7_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name));
- _g_object_unref0 (_tmp7_);
- } else {
- PlayerController* ctrl;
- ctrl = player_controller_new (self->priv->root_menu, client_name, music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_READY);
- gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, client_name, ctrl);
- g_debug ("music-player-bridge.vala:117: New Client of name %s has successfully r" \
-"egistered with us", client_name);
- _g_object_unref0 (ctrl);
- }
- if ((_tmp9_ = player_controller_get_app_info (_tmp8_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name)) == NULL, _g_object_unref0 (_tmp8_), _tmp9_)) {
- indicate_listener_get_server_property_cb cb;
- cb = (indicate_listener_get_server_property_cb) music_player_bridge_desktop_info_callback;
- indicate_listener_server_get_desktop (self->priv->listener, object, cb, self);
- }
- }
- _g_free0 (client_name);
-}
-
-
-void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) {
- char** _tmp0_;
- char** _tmp1_;
- gint _tmp1__length1;
- char* _tmp2_;
- char* client_name;
- gboolean _tmp3_ = FALSE;
- g_return_if_fail (self != NULL);
- g_return_if_fail (type != NULL);
- g_debug ("music-player-bridge.vala:129: MusicPlayerBridge -> on_server_removed w" \
-"ith value %s", type);
- if (music_player_bridge_server_is_not_of_interest (self, type)) {
- return;
- }
- client_name = (_tmp2_ = g_strdup ((_tmp1_ = _tmp0_ = g_strsplit (type, ".", 0), _tmp1__length1 = _vala_array_length (_tmp0_), _tmp1_)[1]), _tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL), _tmp2_);
- if (self->priv->root_menu != NULL) {
- _tmp3_ = client_name != NULL;
- } else {
- _tmp3_ = FALSE;
+ indicate_listener_get_server_property_cb cb;
+ cb = (indicate_listener_get_server_property_cb) music_player_bridge_desktop_info_callback;
+ indicate_listener_server_get_desktop (self->priv->listener, object, cb, self);
}
- if (_tmp3_) {
- PlayerController* _tmp4_;
- player_controller_hibernate (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name));
- _g_object_unref0 (_tmp4_);
- g_debug ("music-player-bridge.vala:134: Successively offlined client %s", client_name);
- }
- _g_free0 (client_name);
}
@@ -400,97 +268,106 @@ static gboolean string_contains (const char* self, const char* needle) {
}
-static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type) {
- gboolean result = FALSE;
- g_return_val_if_fail (self != NULL, FALSE);
- g_return_val_if_fail (type != NULL, FALSE);
- if (type == NULL) {
- result = TRUE;
- return result;
- }
- if (string_contains (type, "music") == FALSE) {
- g_debug ("music-player-bridge.vala:141: server is of no interest, it is not an " \
-"music server");
- result = TRUE;
- return result;
- }
- result = FALSE;
- return result;
-}
-
-
static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, IndicateListenerServer* server, char* path, void* data) {
void* _tmp0_;
MusicPlayerBridge* bridge;
+ GAppInfo* app_info;
+ char* name;
gboolean _tmp1_ = FALSE;
g_return_if_fail (self != NULL);
g_return_if_fail (path != NULL);
bridge = _g_object_ref0 ((_tmp0_ = data, IS_MUSIC_PLAYER_BRIDGE (_tmp0_) ? ((MusicPlayerBridge*) _tmp0_) : NULL));
+ app_info = music_player_bridge_create_app_info (path);
+ name = music_player_bridge_truncate_player_name (g_strdup (g_app_info_get_name (app_info)));
if (string_contains (path, "/")) {
_tmp1_ = familiar_players_db_already_familiar (bridge->priv->playersDB, path) == FALSE;
} else {
_tmp1_ = FALSE;
}
if (_tmp1_) {
- GAppInfo* app_info;
- g_debug ("music-player-bridge.vala:152: About to store desktop file path: %s", path);
+ PlayerController* ctrl;
+ char* _tmp2_;
+ g_debug ("music-player-bridge.vala:98: About to store desktop file path: %s", path);
familiar_players_db_insert (bridge->priv->playersDB, path);
- app_info = music_player_bridge_create_app_info (path);
- if (app_info != NULL) {
- char* _tmp2_;
- char* _tmp3_;
- PlayerController* _tmp4_;
- PlayerController* ctrl;
- ctrl = (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, _tmp3_ = string_strip (_tmp2_ = g_utf8_strdown (g_app_info_get_name (app_info), -1))), _g_free0 (_tmp3_), _g_free0 (_tmp2_), _tmp4_);
- g_object_set ((GObject*) ctrl, "app_info", app_info, NULL);
- g_debug ("music-player-bridge.vala:158: successfully created appinfo from path a" \
-"nd set it on the respective instance");
- _g_object_unref0 (ctrl);
- }
- _g_object_unref0 (app_info);
+ ctrl = player_controller_new (bridge->priv->root_menu, name, music_player_bridge_calculate_menu_position (bridge), PLAYER_CONTROLLER_STATE_READY);
+ g_object_set ((GObject*) ctrl, "app_info", app_info, NULL);
+ gee_abstract_map_set ((GeeAbstractMap*) bridge->priv->registered_clients, _tmp2_ = music_player_bridge_determine_key (g_strdup (path)), ctrl);
+ _g_free0 (_tmp2_);
+ g_debug ("music-player-bridge.vala:106: successfully created appinfo and instanc" \
+"e from path and set it on the respective instance");
+ _g_object_unref0 (ctrl);
} else {
- g_debug ("music-player-bridge.vala:162: Ignoring desktop file path because its e" \
-"ither invalid of the db cache file has it already: %s", path);
+ char* key;
+ PlayerController* _tmp3_;
+ PlayerController* _tmp4_;
+ key = music_player_bridge_determine_key (g_strdup (path));
+ player_controller_update_state (_tmp3_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key), PLAYER_CONTROLLER_STATE_READY);
+ _g_object_unref0 (_tmp3_);
+ player_controller_activate (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key));
+ _g_object_unref0 (_tmp4_);
+ g_debug ("music-player-bridge.vala:112: Ignoring desktop file path callback beca" \
+"use the db cache file has it already: %s", path);
+ _g_free0 (key);
}
+ _g_free0 (name);
+ _g_object_unref0 (app_info);
_g_object_unref0 (bridge);
_g_free0 (path);
}
-void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu) {
- DbusmenuMenuitem* _tmp0_;
- g_return_if_fail (self != NULL);
- g_return_if_fail (menu != NULL);
- self->priv->root_menu = (_tmp0_ = _g_object_ref0 (menu), _g_object_unref0 (self->priv->root_menu), _tmp0_);
- music_player_bridge_try_to_add_inactive_familiar_clients (self);
-}
-
-
-void music_player_bridge_on_server_count_changed (MusicPlayerBridge* self, IndicateListenerServer* object, guint i) {
- g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:174: MusicPlayerBridge-> on_server_count_chan" \
-"ged with value %u", i);
-}
-
-
-void music_player_bridge_on_indicator_added (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0) {
+void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) {
g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:178: MusicPlayerBridge-> on_indicator_added");
+ g_return_if_fail (type != NULL);
+ g_debug ("music-player-bridge.vala:118: MusicPlayerBridge -> on_server_removed w" \
+"ith value %s", type);
+ if (music_player_bridge_server_is_not_of_interest (self, type)) {
+ return;
+ }
+ if (self->priv->root_menu != NULL) {
+ gint tmp_length1;
+ gint _tmp_size_;
+ char** _tmp1_;
+ char** _tmp0_;
+ char** tmp;
+ tmp = (_tmp1_ = _tmp0_ = g_strsplit (type, ".", 0), tmp_length1 = _vala_array_length (_tmp0_), _tmp_size_ = tmp_length1, _tmp1_);
+ g_debug ("music-player-bridge.vala:122: attempt to remove %s", tmp[tmp_length1 - 1]);
+ if (tmp_length1 > 0) {
+ PlayerController* _tmp2_;
+ player_controller_hibernate (_tmp2_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, tmp[tmp_length1 - 1]));
+ _g_object_unref0 (_tmp2_);
+ g_debug ("music-player-bridge.vala:125: Successively offlined client %s", tmp[tmp_length1 - 1]);
+ }
+ tmp = (_vala_array_free (tmp, tmp_length1, (GDestroyNotify) g_free), NULL);
+ }
}
-void music_player_bridge_on_indicator_removed (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0) {
- g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:183: MusicPlayerBridge -> on_indicator_remove" \
-"d");
+static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type) {
+ gboolean result = FALSE;
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (type != NULL, FALSE);
+ if (type == NULL) {
+ result = TRUE;
+ return result;
+ }
+ if (string_contains (type, "music") == FALSE) {
+ g_debug ("music-player-bridge.vala:133: server is of no interest, it is not an " \
+"music server");
+ result = TRUE;
+ return result;
+ }
+ result = FALSE;
+ return result;
}
-void music_player_bridge_on_indicator_modified (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* s) {
+void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu) {
+ DbusmenuMenuitem* _tmp0_;
g_return_if_fail (self != NULL);
- g_return_if_fail (s != NULL);
- g_debug ("music-player-bridge.vala:188: MusicPlayerBridge -> indicator_modified " \
-"with vale %s", s);
+ g_return_if_fail (menu != NULL);
+ self->priv->root_menu = (_tmp0_ = _g_object_ref0 (menu), _g_object_unref0 (self->priv->root_menu), _tmp0_);
+ music_player_bridge_try_to_add_inactive_familiar_clients (self);
}
@@ -502,7 +379,7 @@ GAppInfo* music_player_bridge_create_app_info (const char* path) {
g_return_val_if_fail (path != NULL, NULL);
info = g_desktop_app_info_new_from_filename (path);
if (path == NULL) {
- g_warning ("music-player-bridge.vala:195: Could not create a desktopappinfo instan" \
+ g_warning ("music-player-bridge.vala:149: Could not create a desktopappinfo instan" \
"ce from app: %s", path);
result = NULL;
_g_object_unref0 (info);
@@ -515,6 +392,85 @@ GAppInfo* music_player_bridge_create_app_info (const char* path) {
}
+static char* string_strip (const char* self) {
+ char* result = NULL;
+ char* _result_;
+ g_return_val_if_fail (self != NULL, NULL);
+ _result_ = g_strdup (self);
+ g_strstrip (_result_);
+ result = _result_;
+ return result;
+}
+
+
+static char* music_player_bridge_truncate_player_name (char* app_info_name) {
+ char* result = NULL;
+ char* _tmp0_;
+ char* _tmp1_;
+ char* _result_;
+ gint tokens_length1;
+ gint _tokens_size_;
+ char** _tmp3_;
+ char** _tmp2_;
+ char** tokens;
+ g_return_val_if_fail (app_info_name != NULL, NULL);
+ _result_ = (_tmp1_ = string_strip (_tmp0_ = g_utf8_strdown (app_info_name, -1)), _g_free0 (_tmp0_), _tmp1_);
+ tokens = (_tmp3_ = _tmp2_ = g_strsplit (_result_, " ", 0), tokens_length1 = _vala_array_length (_tmp2_), _tokens_size_ = tokens_length1, _tmp3_);
+ if (tokens_length1 > 1) {
+ char* _tmp4_;
+ _result_ = (_tmp4_ = g_strdup (tokens[0]), _g_free0 (_result_), _tmp4_);
+ }
+ g_debug ("music-player-bridge.vala:165: truncate player name %s", _result_);
+ result = _result_;
+ tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (app_info_name);
+ return result;
+}
+
+
+static char* music_player_bridge_determine_key (char* path) {
+ char* result = NULL;
+ gint tokens_length1;
+ gint _tokens_size_;
+ char** _tmp1_;
+ char** _tmp0_;
+ char** tokens;
+ char* filename;
+ char** _tmp2_;
+ char** _tmp3_;
+ gint _tmp3__length1;
+ char* _tmp4_;
+ char* _result_;
+ gint temp_length1;
+ gint _temp_size_;
+ char** _tmp6_;
+ char** _tmp5_;
+ char** temp;
+ g_return_val_if_fail (path != NULL, NULL);
+ tokens = (_tmp1_ = _tmp0_ = g_strsplit (path, "/", 0), tokens_length1 = _vala_array_length (_tmp0_), _tokens_size_ = tokens_length1, _tmp1_);
+ if (tokens_length1 < 2) {
+ result = NULL;
+ tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (path);
+ return result;
+ }
+ filename = g_strdup (tokens[tokens_length1 - 1]);
+ _result_ = (_tmp4_ = g_strdup ((_tmp3_ = _tmp2_ = g_strsplit (filename, ".", 0), _tmp3__length1 = _vala_array_length (_tmp2_), _tmp3_)[0]), _tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL), _tmp4_);
+ temp = (_tmp6_ = _tmp5_ = g_strsplit (_result_, "-", 0), temp_length1 = _vala_array_length (_tmp5_), _temp_size_ = temp_length1, _tmp6_);
+ if (temp_length1 > 1) {
+ char* _tmp7_;
+ _result_ = (_tmp7_ = g_strdup (temp[0]), _g_free0 (_result_), _tmp7_);
+ }
+ g_debug ("music-player-bridge.vala:179: determine key result = %s", _result_);
+ result = _result_;
+ temp = (_vala_array_free (temp, temp_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (filename);
+ tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (path);
+ return result;
+}
+
+
static void music_player_bridge_class_init (MusicPlayerBridgeClass * klass) {
music_player_bridge_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (MusicPlayerBridgePrivate));
diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h
index 3179f96..111a76d 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.9.8, the Vala compiler, do not modify */
+/* music-player-bridge.h generated by valac 0.10.0, the Vala compiler, do not modify */
#ifndef __MUSIC_PLAYER_BRIDGE_H__
@@ -311,10 +311,6 @@ MusicPlayerBridge* music_player_bridge_construct (GType object_type);
void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type);
void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type);
void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu);
-void music_player_bridge_on_server_count_changed (MusicPlayerBridge* self, IndicateListenerServer* object, guint i);
-void music_player_bridge_on_indicator_added (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0);
-void music_player_bridge_on_indicator_removed (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0);
-void music_player_bridge_on_indicator_modified (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* s);
GAppInfo* music_player_bridge_create_app_info (const char* path);
GType player_item_get_type (void) G_GNUC_CONST;
GType transport_menuitem_get_type (void) G_GNUC_CONST;
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 61dfa2e..9ba4ef6 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -35,12 +35,8 @@ public class MusicPlayerBridge : GLib.Object
playersDB = new FamiliarPlayersDB();
registered_clients = new HashMap<string, PlayerController> ();
listener = Listener.ref_default();
- listener.indicator_added += on_indicator_added;
- listener.indicator_removed.connect(on_indicator_removed);
- listener.indicator_modified.connect(on_indicator_modified);
listener.server_added.connect(on_server_added);
listener.server_removed.connect(on_server_removed);
- listener.server_count_changed.connect(on_server_count_changed);
}
private void try_to_add_inactive_familiar_clients(){
@@ -53,13 +49,13 @@ public class MusicPlayerBridge : GLib.Object
debug("attempting to make an app info from %s", app);
DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
- if(info == null){
+
+ if(info == null){
warning("Could not create a desktopappinfo instance from app: %s", app);
continue;
}
+
GLib.AppInfo app_info = info as GLib.AppInfo;
- // TODO refactor to remove need for further name refactoring in the player controller
- // truncate should not do a down() on the name
PlayerController ctrl = new PlayerController(this.root_menu,
truncate_player_name(app_info.get_name()),
calculate_menu_position(),
@@ -67,24 +63,10 @@ public class MusicPlayerBridge : GLib.Object
ctrl.app_info = app_info;
if(ctrl.app_info == null)
warning("for some reason the app info is null");
-
- this.registered_clients.set(truncate_player_name(app_info.get_name()), ctrl);
+ this.registered_clients.set(determine_key(app), ctrl);
}
}
-
- private static string truncate_player_name(string app_info_name)
- {
- string result = app_info_name.down().strip();
-
- var tokens = result.split(" ");
-
- if(tokens.length > 1){
- result = tokens[0];
- }
- debug("truncate player name %s", result);
- return result;
- }
-
+
private int calculate_menu_position()
{
if(this.registered_clients.size == 0){
@@ -99,42 +81,52 @@ public class MusicPlayerBridge : GLib.Object
{
debug("MusicPlayerBridge -> on_server_added with value %s", type);
if(server_is_not_of_interest(type)) return;
- string client_name = type.split(".")[1];
- if (root_menu != null && client_name != null){
- // If we have an instance already for this player, ensure it is switched to active
- if(this.registered_clients.keys.contains(client_name)){
- debug("It figured out that it already has an instance for this player already");
- this.registered_clients[client_name].update_state(PlayerController.state.READY);
- this.registered_clients[client_name].activate();
- }
- else{
- //else init a new one
- PlayerController ctrl = new PlayerController(root_menu,
- client_name,
- calculate_menu_position(),
- PlayerController.state.READY);
- registered_clients.set(client_name, ctrl);
- debug("New Client of name %s has successfully registered with us", client_name);
- }
- // irregardless check that it has a desktop file if not kick off a request for it
- if(this.registered_clients[client_name].app_info == null){
- listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback;
- this.listener.server_get_desktop(object, cb, this);
- }
+ if ( this.root_menu != null ){
+ listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback;
+ this.listener.server_get_desktop(object, cb, this);
}
}
+ private void desktop_info_callback ( Indicate.ListenerServer server,
+ owned string path,
+ void* data )
+ {
+ MusicPlayerBridge bridge = data as MusicPlayerBridge;
+ AppInfo? app_info = create_app_info(path);
+ var name = truncate_player_name(app_info.get_name());
+ if(path.contains("/") && bridge.playersDB.already_familiar(path) == false){
+ debug("About to store desktop file path: %s", path);
+ bridge.playersDB.insert(path);
+ PlayerController ctrl = new PlayerController(bridge.root_menu,
+ name,
+ bridge.calculate_menu_position(),
+ PlayerController.state.READY);
+ ctrl.set("app_info", app_info);
+ bridge.registered_clients.set(determine_key(path), ctrl);
+ debug("successfully created appinfo and instance from path and set it on the respective instance");
+ }
+ else{
+ var key = determine_key(path);
+ bridge.registered_clients[key].update_state(PlayerController.state.READY);
+ bridge.registered_clients[key].activate();
+ debug("Ignoring desktop file path callback because the db cache file has it already: %s", path);
+ }
+ }
+
public void on_server_removed(Indicate.ListenerServer object, string type)
{
debug("MusicPlayerBridge -> on_server_removed with value %s", type);
if(server_is_not_of_interest(type)) return;
- string client_name = type.split(".")[1];
- if (root_menu != null && client_name != null){
- registered_clients[client_name].hibernate();
- debug("Successively offlined client %s", client_name);
+ if (root_menu != null){
+ var tmp = type.split(".");
+ debug("attempt to remove %s", tmp[tmp.length-1]);
+ if(tmp.length > 0){
+ registered_clients[tmp[tmp.length - 1]].hibernate();
+ debug("Successively offlined client %s", tmp[tmp.length - 1]);
+ }
}
}
-
+
private bool server_is_not_of_interest(string type){
if (type == null) return true;
if (type.contains("music") == false) {
@@ -144,50 +136,12 @@ public class MusicPlayerBridge : GLib.Object
return false;
}
- private void desktop_info_callback(Indicate.ListenerServer server,
- owned string path, void* data)
- {
- MusicPlayerBridge bridge = data as MusicPlayerBridge;
- if(path.contains("/") && bridge.playersDB.already_familiar(path) == false){
- debug("About to store desktop file path: %s", path);
- bridge.playersDB.insert(path);
- AppInfo? app_info = create_app_info(path);
- if(app_info != null){
- PlayerController ctrl = bridge.registered_clients[app_info.get_name().down().strip()];
- ctrl.set("app_info", app_info);
- debug("successfully created appinfo from path and set it on the respective instance");
- }
- }
- else{
- debug("Ignoring desktop file path because its either invalid of the db cache file has it already: %s", path);
- }
- }
-
public void set_root_menu_item(Dbusmenu.Menuitem menu)
{
this.root_menu = menu;
try_to_add_inactive_familiar_clients();
}
- public void on_server_count_changed(Indicate.ListenerServer object, uint i)
- {
- debug("MusicPlayerBridge-> on_server_count_changed with value %u", i);
- }
- public void on_indicator_added(ListenerServer object, ListenerIndicator p0)
- {
- debug("MusicPlayerBridge-> on_indicator_added");
- }
-
- public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0)
- {
- debug("MusicPlayerBridge -> on_indicator_removed");
- }
-
- public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s)
- {
- debug("MusicPlayerBridge -> indicator_modified with vale %s", s );
- }
-
public static AppInfo? create_app_info(string path)
{
DesktopAppInfo info = new DesktopAppInfo.from_filename(path);
@@ -199,6 +153,33 @@ public class MusicPlayerBridge : GLib.Object
return app_info;
}
+ private static string truncate_player_name(owned string app_info_name)
+ {
+ string result = app_info_name.down().strip();
+
+ var tokens = result.split(" ");
+
+ if(tokens.length > 1){
+ result = tokens[0];
+ }
+ debug("truncate player name %s", result);
+ return result;
+ }
+
+ private static string? determine_key(owned string path)
+ {
+ var tokens = path.split("/");
+ if ( tokens.length < 2) return null;
+ var filename = tokens[tokens.length - 1];
+ var result = filename.split(".")[0];
+ var temp = result.split("-");
+ if (temp.length > 1){
+ result = temp[0];
+ }
+ debug("determine key result = %s", result);
+ return result;
+ }
+
}
diff --git a/src/play-button.c b/src/play-button.c
deleted file mode 100644
index 5e8a90d..0000000
--- a/src/play-button.c
+++ /dev/null
@@ -1,1224 +0,0 @@
-/*
-Copyright 2010 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@canonical.com>
- Mirco Müller <mirco.mueller@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/>.
-
-Uses code from ctk
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include "play-button.h"
-
-#define RECT_WIDTH 130.0f
-#define Y 7.0f
-#define X 37.0f
-#define INNER_RADIUS 12.5
-#define MIDDLE_RADIUS 13.5f
-#define OUTER_RADIUS 14.5f
-#define CIRCLE_RADIUS 21.0f
-#define PREV_WIDTH 25.0f
-#define PREV_HEIGHT 17.0f
-#define NEXT_WIDTH 25.0f //PREV_WIDTH
-#define NEXT_HEIGHT 17.0f //PREV_HEIGHT
-#define TRI_WIDTH 11.0f
-#define TRI_HEIGHT 13.0f
-#define TRI_OFFSET 6.0f
-#define PREV_X 35.0f
-#define PREV_Y 13.0f
-#define NEXT_X 113.0f
-#define NEXT_Y 13.0f //prev_y
-#define PAUSE_WIDTH 21.0f
-#define PAUSE_HEIGHT 27.0f
-#define BAR_WIDTH 4.5f
-#define BAR_HEIGHT 24.0f
-#define BAR_OFFSET 10.0f
-#define PAUSE_X 78.0f
-#define PAUSE_Y 7.0f
-#define PLAY_WIDTH 28.0f
-#define PLAY_HEIGHT 29.0f
-#define PLAY_PADDING 5.0f
-#define INNER_START_SHADE 0.98
-#define INNER_END_SHADE 0.98
-#define MIDDLE_START_SHADE 0.7
-#define MIDDLE_END_SHADE 1.4
-#define OUTER_START_SHADE 0.96
-#define OUTER_END_SHADE 0.96
-#define BUTTON_START_SHADE 1.1
-#define BUTTON_END_SHADE 0.9
-#define BUTTON_SHADOW_SHADE 0.8
-#define INNER_COMPRESSED_START_SHADE 0.95
-#define INNER_COMPRESSED_END_SHADE 1.05
-
-
-typedef struct _PlayButtonPrivate PlayButtonPrivate;
-
-struct _PlayButtonPrivate
-{
- GdkColor background_colour_fg;
- GdkColor background_colour_bg_dark;
- GdkColor background_colour_bg_light;
- GdkColor foreground_colour_fg;
- GdkColor foreground_colour_bg;
- PlayButtonEvent current_command;
- PlayButtonState current_state;
- GHashTable* command_coordinates;
-};
-
-typedef struct
-{
- double r;
- double g;
- double b;
-} CairoColorRGB;
-
-
-#define PLAY_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PLAY_BUTTON_TYPE, PlayButtonPrivate))
-
-/* Gobject boiler plate */
-static void play_button_class_init (PlayButtonClass *klass);
-static void play_button_init (PlayButton *self);
-static void play_button_dispose (GObject *object);
-static void play_button_finalize (GObject *object);
-
-static gboolean play_button_expose (GtkWidget *button, GdkEventExpose *event);
-
-static void draw (GtkWidget* button, cairo_t *cr);
-
-G_DEFINE_TYPE (PlayButton, play_button, GTK_TYPE_DRAWING_AREA);
-
-/// internal helper functions //////////////////////////////////////////////////
-
-
-static inline void
-_blurinner (guchar* pixel,
- gint* zR,
- gint* zG,
- gint* zB,
- gint* zA,
- gint alpha,
- gint aprec,
- gint zprec)
-{
- gint R;
- gint G;
- gint B;
- guchar A;
-
- R = *pixel;
- G = *(pixel + 1);
- B = *(pixel + 2);
- A = *(pixel + 3);
-
- *zR += (alpha * ((R << zprec) - *zR)) >> aprec;
- *zG += (alpha * ((G << zprec) - *zG)) >> aprec;
- *zB += (alpha * ((B << zprec) - *zB)) >> aprec;
- *zA += (alpha * ((A << zprec) - *zA)) >> aprec;
-
- *pixel = *zR >> zprec;
- *(pixel + 1) = *zG >> zprec;
- *(pixel + 2) = *zB >> zprec;
- *(pixel + 3) = *zA >> zprec;
-}
-
-static inline void
-_blurrow (guchar* pixels,
- gint width,
- gint height,
- gint channels,
- gint line,
- gint alpha,
- gint aprec,
- gint zprec)
-{
- gint zR;
- gint zG;
- gint zB;
- gint zA;
- gint index;
- guchar* scanline;
-
- scanline = &(pixels[line * width * channels]);
-
- zR = *scanline << zprec;
- zG = *(scanline + 1) << zprec;
- zB = *(scanline + 2) << zprec;
- zA = *(scanline + 3) << zprec;
-
- for (index = 0; index < width; index ++)
- _blurinner (&scanline[index * channels],
- &zR,
- &zG,
- &zB,
- &zA,
- alpha,
- aprec,
- zprec);
-
- for (index = width - 2; index >= 0; index--)
- _blurinner (&scanline[index * channels],
- &zR,
- &zG,
- &zB,
- &zA,
- alpha,
- aprec,
- zprec);
-}
-
-static inline void
-_blurcol (guchar* pixels,
- gint width,
- gint height,
- gint channels,
- gint x,
- gint alpha,
- gint aprec,
- gint zprec)
-{
- gint zR;
- gint zG;
- gint zB;
- gint zA;
- gint index;
- guchar* ptr;
-
- ptr = pixels;
-
- ptr += x * channels;
-
- zR = *((guchar*) ptr ) << zprec;
- zG = *((guchar*) ptr + 1) << zprec;
- zB = *((guchar*) ptr + 2) << zprec;
- zA = *((guchar*) ptr + 3) << zprec;
-
- for (index = width; index < (height - 1) * width; index += width)
- _blurinner ((guchar*) &ptr[index * channels],
- &zR,
- &zG,
- &zB,
- &zA,
- alpha,
- aprec,
- zprec);
-
- for (index = (height - 2) * width; index >= 0; index -= width)
- _blurinner ((guchar*) &ptr[index * channels],
- &zR,
- &zG,
- &zB,
- &zA,
- alpha,
- aprec,
- zprec);
-}
-
-void
-_expblur (guchar* pixels,
- gint width,
- gint height,
- gint channels,
- gint radius,
- gint aprec,
- gint zprec)
-{
- gint alpha;
- gint row = 0;
- gint col = 0;
-
- if (radius < 1)
- return;
-
- // calculate the alpha such that 90% of
- // the kernel is within the radius.
- // (Kernel extends to infinity)
- alpha = (gint) ((1 << aprec) * (1.0f - expf (-2.3f / (radius + 1.f))));
-
- for (; row < height; row++)
- _blurrow (pixels,
- width,
- height,
- channels,
- row,
- alpha,
- aprec,
- zprec);
-
- for(; col < width; col++)
- _blurcol (pixels,
- width,
- height,
- channels,
- col,
- alpha,
- aprec,
- zprec);
-
- return;
-}
-
-void
-_surface_blur (cairo_surface_t* surface,
- guint radius)
-{
- guchar* pixels;
- guint width;
- guint height;
- cairo_format_t format;
-
- // before we mess with the surface execute any pending drawing
- cairo_surface_flush (surface);
-
- pixels = cairo_image_surface_get_data (surface);
- width = cairo_image_surface_get_width (surface);
- height = cairo_image_surface_get_height (surface);
- format = cairo_image_surface_get_format (surface);
-
- switch (format)
- {
- case CAIRO_FORMAT_ARGB32:
- _expblur (pixels, width, height, 4, radius, 16, 7);
- break;
-
- case CAIRO_FORMAT_RGB24:
- _expblur (pixels, width, height, 3, radius, 16, 7);
- break;
-
- case CAIRO_FORMAT_A8:
- _expblur (pixels, width, height, 1, radius, 16, 7);
- break;
-
- default :
- // do nothing
- break;
- }
-
- // inform cairo we altered the surfaces contents
- cairo_surface_mark_dirty (surface);
-}
-
-/// GObject functions //////////////////////////////////////////////////////////
-
-static void
-play_button_class_init (PlayButtonClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (PlayButtonPrivate));
-
- widget_class->expose_event = play_button_expose;
-
- gobject_class->dispose = play_button_dispose;
- gobject_class->finalize = play_button_finalize;
-}
-
-static void
-play_button_init (PlayButton *self)
-{
- PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(self);
- priv->current_command = TRANSPORT_NADA;
- priv->current_state = PAUSE;
- priv->command_coordinates = g_hash_table_new_full(g_direct_hash,
- g_direct_equal,
- NULL,
- (GDestroyNotify)g_list_free);
- GList* previous_list = NULL;
- previous_list = g_list_insert(previous_list, GINT_TO_POINTER(15), 0);
- previous_list = g_list_insert(previous_list, GINT_TO_POINTER(5), 1);
- previous_list = g_list_insert(previous_list, GINT_TO_POINTER(60), 2);
- previous_list = g_list_insert(previous_list, GINT_TO_POINTER(34), 3);
-
- g_hash_table_insert(priv->command_coordinates,
- GINT_TO_POINTER(TRANSPORT_PREVIOUS),
- previous_list);
-
- GList* play_list = NULL;
- play_list = g_list_insert(play_list, GINT_TO_POINTER(58), 0);
- play_list = g_list_insert(play_list, GINT_TO_POINTER(0), 1);
- play_list = g_list_insert(play_list, GINT_TO_POINTER(50), 2);
- play_list = g_list_insert(play_list, GINT_TO_POINTER(43), 3);
-
- g_hash_table_insert(priv->command_coordinates,
- GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE),
- play_list);
-
- GList* next_list = NULL;
- next_list = g_list_insert(next_list, GINT_TO_POINTER(100), 0);
- next_list = g_list_insert(next_list, GINT_TO_POINTER(5), 1);
- next_list = g_list_insert(next_list, GINT_TO_POINTER(60), 2);
- next_list = g_list_insert(next_list, GINT_TO_POINTER(34), 3);
-
- g_hash_table_insert(priv->command_coordinates,
- GINT_TO_POINTER(TRANSPORT_NEXT),
- next_list);
-
- gtk_widget_set_size_request(GTK_WIDGET(self), 200, 50);
-
-}
-
-static void
-play_button_dispose (GObject *object)
-{
- G_OBJECT_CLASS (play_button_parent_class)->dispose (object);
-}
-
-static void
-play_button_finalize (GObject *object)
-{
- G_OBJECT_CLASS (play_button_parent_class)->finalize (object);
-}
-
-static gboolean
-play_button_expose (GtkWidget *button, GdkEventExpose *event)
-{
- cairo_t *cr;
- cr = gdk_cairo_create (button->window);
-
- cairo_rectangle (cr,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- cairo_clip(cr);
-
- draw (button, cr);
- cairo_destroy (cr);
- return FALSE;
-}
-
-
-PlayButtonEvent
-determine_button_event(GtkWidget* button, GdkEventButton* event)
-{
- g_debug("event x coordinate = %f", event->x);
- g_debug("event y coordinate = %f", event->y);
- PlayButtonEvent button_event = TRANSPORT_NADA;
- // For now very simple rectangular collision detection
- if(event->x > 67 && event->x < 112
- && event->y > 12 && event->y < 40){
- button_event = TRANSPORT_PREVIOUS;
- }
- else if(event->x > 111 && event->x < 153
- && event->y > 5 && event->y < 47){
- button_event = TRANSPORT_PLAY_PAUSE;
- }
- else if(event->x > 152 && event->x < 197
- && event->y > 12 && event->y < 40){
- button_event = TRANSPORT_NEXT;
- }
- return button_event;
-
-}
-
-void
-play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command)
-{
- g_return_if_fail(IS_PLAY_BUTTON(button));
- PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
- priv->current_command = command;
-
- cairo_t *cr;
- cr = gdk_cairo_create (button->window);
-
- GList* list = g_hash_table_lookup(priv->command_coordinates,
- GINT_TO_POINTER(priv->current_command));
- cairo_rectangle(cr,
- GPOINTER_TO_INT(g_list_nth_data(list, 0)),
- GPOINTER_TO_INT(g_list_nth_data(list, 1)),
- GPOINTER_TO_INT(g_list_nth_data(list, 2)),
- GPOINTER_TO_INT(g_list_nth_data(list, 3)));
- cairo_clip(cr);
- draw (button, cr);
- cairo_destroy (cr);
-}
-
-
-void
-play_button_react_to_button_release(GtkWidget* button, PlayButtonEvent command)
-{
- g_return_if_fail(IS_PLAY_BUTTON(button));
- PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
- if(priv->current_command == TRANSPORT_NADA){
- g_debug("returning from the playbutton release because my previous command was nada");
- return;
- }
- else if(priv->current_command != TRANSPORT_NADA &&
- command != TRANSPORT_NADA){
- priv->current_command = command;
- }
-
- cairo_t *cr;
-
- cr = gdk_cairo_create (button->window);
- GList* list = g_hash_table_lookup(priv->command_coordinates,
- GINT_TO_POINTER(priv->current_command));
-
- priv->current_command = TRANSPORT_NADA;
-
- cairo_rectangle(cr,
- GPOINTER_TO_INT(g_list_nth_data(list, 0)),
- GPOINTER_TO_INT(g_list_nth_data(list, 1)),
- GPOINTER_TO_INT(g_list_nth_data(list, 2)),
- GPOINTER_TO_INT(g_list_nth_data(list, 3)));
-
- cairo_clip(cr);
- draw (button, cr);
- cairo_destroy (cr);
-
-}
-
-void
-play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update)
-{
- PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
- priv->current_state = update;
- g_debug("PlayButton::toggle play state : %i", priv->current_state);
- gtk_widget_queue_draw (GTK_WIDGET(button));
-}
-
-
-void
-play_button_set_style(GtkWidget* button, GtkStyle* style)
-{
- PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
- priv->background_colour_fg = style->fg[GTK_STATE_NORMAL];
- priv->background_colour_bg_dark = style->bg[GTK_STATE_NORMAL];
- priv->background_colour_bg_light = style->base[GTK_STATE_NORMAL];
- priv->foreground_colour_fg = style->fg[GTK_STATE_PRELIGHT];
- priv->foreground_colour_bg = style->bg[GTK_STATE_NORMAL];
-}
-
-static void
-draw_gradient (cairo_t* cr,
- double x,
- double y,
- double w,
- double r,
- double* rgba_start,
- double* rgba_end)
-{
- cairo_pattern_t* pattern = NULL;
-
- cairo_move_to (cr, x, y);
- cairo_line_to (cr, x + w - 2.0f * r, y);
- cairo_arc (cr,
- x + w - 2.0f * r,
- y + r,
- r,
- -90.0f * G_PI / 180.0f,
- 90.0f * G_PI / 180.0f);
- cairo_line_to (cr, x, y + 2.0f * r);
- cairo_arc (cr,
- x,
- y + r,
- r,
- 90.0f * G_PI / 180.0f,
- 270.0f * G_PI / 180.0f);
- cairo_close_path (cr);
-
- pattern = cairo_pattern_create_linear (x, y, x, y + 2.0f * r);
- cairo_pattern_add_color_stop_rgba (pattern,
- 0.0f,
- rgba_start[0],
- rgba_start[1],
- rgba_start[2],
- rgba_start[3]);
- cairo_pattern_add_color_stop_rgba (pattern,
- 1.0f,
- rgba_end[0],
- rgba_end[1],
- rgba_end[2],
- rgba_end[3]);
- cairo_set_source (cr, pattern);
- cairo_fill (cr);
- cairo_pattern_destroy (pattern);
-}
-
-static void
-draw_circle (cairo_t* cr,
- double x,
- double y,
- double r,
- double* rgba_start,
- double* rgba_end)
-{
- cairo_pattern_t* pattern = NULL;
-
- cairo_move_to (cr, x, y);
- cairo_arc (cr,
- x + r,
- y + r,
- r,
- 0.0f * G_PI / 180.0f,
- 360.0f * G_PI / 180.0f);
-
- pattern = cairo_pattern_create_linear (x, y, x, y + 2.0f * r);
- cairo_pattern_add_color_stop_rgba (pattern,
- 0.0f,
- rgba_start[0],
- rgba_start[1],
- rgba_start[2],
- rgba_start[3]);
- cairo_pattern_add_color_stop_rgba (pattern,
- 1.0f,
- rgba_end[0],
- rgba_end[1],
- rgba_end[2],
- rgba_end[3]);
- cairo_set_source (cr, pattern);
- cairo_fill (cr);
- cairo_pattern_destroy (pattern);
-}
-
-static void
-_setup (cairo_t** cr,
- cairo_surface_t** surf,
- gint width,
- gint height)
-{
- if (!cr || !surf)
- return;
-
- *surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
- *cr = cairo_create (*surf);
- cairo_scale (*cr, 1.0f, 1.0f);
- cairo_set_operator (*cr, CAIRO_OPERATOR_CLEAR);
- cairo_paint (*cr);
- cairo_set_operator (*cr, CAIRO_OPERATOR_OVER);
-}
-
-static void
-_mask_prev (cairo_t* cr,
- double x,
- double y,
- double tri_width,
- double tri_height,
- double tri_offset)
-{
- if (!cr)
- return;
-
- cairo_move_to (cr, x, y + tri_height / 2.0f);
- cairo_line_to (cr, x + tri_width, y);
- cairo_line_to (cr, x + tri_width, y + tri_height);
- x += tri_offset;
- cairo_move_to (cr, x, y + tri_height / 2.0f);
- cairo_line_to (cr, x + tri_width, y);
- cairo_line_to (cr, x + tri_width, y + tri_height);
- x -= tri_offset;
- cairo_rectangle (cr, x, y, 2.5f, tri_height);
- cairo_close_path (cr);
-}
-
-static void
-_mask_next (cairo_t* cr,
- double x,
- double y,
- double tri_width,
- double tri_height,
- double tri_offset)
-{
- if (!cr)
- return;
-
- cairo_move_to (cr, x, y);
- cairo_line_to (cr, x + tri_width, y + tri_height / 2.0f);
- cairo_line_to (cr, x, y + tri_height);
- x += tri_offset;
- cairo_move_to (cr, x, y);
- cairo_line_to (cr, x + tri_width, y + tri_height / 2.0f);
- cairo_line_to (cr, x, y + tri_height);
- x -= tri_offset;
- x += 2.0f * tri_width - tri_offset - 1.0f;
- cairo_rectangle (cr, x, y, 2.5f, tri_height);
-
- cairo_close_path (cr);
-}
-
-static void
-_mask_pause (cairo_t* cr,
- double x,
- double y,
- double bar_width,
- double bar_height,
- double bar_offset)
-{
- if (!cr)
- return;
-
- cairo_set_line_width (cr, bar_width);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
-
- x += bar_width;
- y += bar_width;
- cairo_move_to (cr, x, y);
- cairo_line_to (cr, x, y + bar_height);
- cairo_move_to (cr, x + bar_offset, y);
- cairo_line_to (cr, x + bar_offset, y + bar_height);
-
-}
-
-static void
-_mask_play (cairo_t* cr,
- double x,
- double y,
- double tri_width,
- double tri_height
- /*double tri_offset*/)
-{
- if (!cr)
- return;
-
- cairo_move_to (cr, x, y);
- cairo_line_to (cr, x + tri_width, y + tri_height / 2.0f);
- cairo_line_to (cr, x, y + tri_height);
- cairo_close_path (cr);
-
-}
-
-static void
-_fill (cairo_t* cr,
- double x_start,
- double y_start,
- double x_end,
- double y_end,
- double* rgba_start,
- double* rgba_end,
- gboolean stroke)
-{
- cairo_pattern_t* pattern = NULL;
-
- if (!cr || !rgba_start || !rgba_end)
- return;
-
- pattern = cairo_pattern_create_linear (x_start, y_start, x_end, y_end);
- cairo_pattern_add_color_stop_rgba (pattern,
- 0.0f,
- rgba_start[0],
- rgba_start[1],
- rgba_start[2],
- rgba_start[3]);
- cairo_pattern_add_color_stop_rgba (pattern,
- 1.0f,
- rgba_end[0],
- rgba_end[1],
- rgba_end[2],
- rgba_end[3]);
- cairo_set_source (cr, pattern);
- if (stroke)
- cairo_stroke (cr);
- else
- cairo_fill (cr);
- cairo_pattern_destroy (pattern);
-}
-
-static void
-_finalize (cairo_t* cr,
- cairo_t** cr_surf,
- cairo_surface_t** surf,
- double x,
- double y)
-{
- if (!cr || !cr_surf || !surf)
- return;
-
- cairo_set_source_surface (cr, *surf, x, y);
- cairo_paint (cr);
- cairo_surface_destroy (*surf);
- cairo_destroy (*cr_surf);
-}
-
-static void
-_color_rgb_to_hls (gdouble *r,
- gdouble *g,
- gdouble *b)
-{
- gdouble min;
- gdouble max;
- gdouble red;
- gdouble green;
- gdouble blue;
- gdouble h, l, s;
- gdouble delta;
-
- red = *r;
- green = *g;
- blue = *b;
-
- if (red > green)
- {
- if (red > blue)
- max = red;
- else
- max = blue;
-
- if (green < blue)
- min = green;
- else
- min = blue;
- }
- else
- {
- if (green > blue)
- max = green;
- else
- max = blue;
-
- if (red < blue)
- min = red;
- else
- min = blue;
- }
- l = (max+min)/2;
- if (fabs (max-min) < 0.0001)
- {
- h = 0;
- s = 0;
- }
- else
- {
- if (l <= 0.5)
- s = (max-min)/(max+min);
- else
- s = (max-min)/(2-max-min);
-
- delta = (max -min) != 0 ? (max -min) : 1;
-
- if(delta == 0)
- delta = 1;
- if (red == max)
- h = (green-blue)/delta;
- else if (green == max)
- h = 2+(blue-red)/delta;
- else if (blue == max)
- h = 4+(red-green)/delta;
-
- h *= 60;
- if (h < 0.0)
- h += 360;
- }
-
- *r = h;
- *g = l;
- *b = s;
-}
-
-static void
-_color_hls_to_rgb (gdouble *h,
- gdouble *l,
- gdouble *s)
-{
- gdouble hue;
- gdouble lightness;
- gdouble saturation;
- gdouble m1, m2;
- gdouble r, g, b;
-
- lightness = *l;
- saturation = *s;
-
- if (lightness <= 0.5)
- m2 = lightness*(1+saturation);
- else
- m2 = lightness+saturation-lightness*saturation;
-
- m1 = 2*lightness-m2;
-
- if (saturation == 0)
- {
- *h = lightness;
- *l = lightness;
- *s = lightness;
- }
- else
- {
- hue = *h+120;
- while (hue > 360)
- hue -= 360;
- while (hue < 0)
- hue += 360;
-
- if (hue < 60)
- r = m1+(m2-m1)*hue/60;
- else if (hue < 180)
- r = m2;
- else if (hue < 240)
- r = m1+(m2-m1)*(240-hue)/60;
- else
- r = m1;
-
- hue = *h;
- while (hue > 360)
- hue -= 360;
- while (hue < 0)
- hue += 360;
-
- if (hue < 60)
- g = m1+(m2-m1)*hue/60;
- else if (hue < 180)
- g = m2;
- else if (hue < 240)
- g = m1+(m2-m1)*(240-hue)/60;
- else
- g = m1;
-
- hue = *h-120;
- while (hue > 360)
- hue -= 360;
- while (hue < 0)
- hue += 360;
-
- if (hue < 60)
- b = m1+(m2-m1)*hue/60;
- else if (hue < 180)
- b = m2;
- else if (hue < 240)
- b = m1+(m2-m1)*(240-hue)/60;
- else
- b = m1;
-
- *h = r;
- *l = g;
- *s = b;
- }
-}
-
-static void
-_color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b)
-{
- double red;
- double green;
- double blue;
-
- red = a->r;
- green = a->g;
- blue = a->b;
-
- if (k == 1.0)
- {
- b->r = red;
- b->g = green;
- b->b = blue;
- return;
- }
-
- _color_rgb_to_hls (&red, &green, &blue);
-
- green *= k;
- if (green > 1.0)
- green = 1.0;
- else if (green < 0.0)
- green = 0.0;
-
- blue *= k;
- if (blue > 1.0)
- blue = 1.0;
- else if (blue < 0.0)
- blue = 0.0;
-
- _color_hls_to_rgb (&red, &green, &blue);
-
- b->r = red;
- b->g = green;
- b->b = blue;
-}
-
-static void
-draw (GtkWidget* button, cairo_t *cr)
-{
- g_return_if_fail(IS_PLAY_BUTTON(button));
- PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
-
- cairo_surface_t* surf = NULL;
- cairo_t* cr_surf = NULL;
-
- GtkStyle *style;
-
- CairoColorRGB bg_normal, fg_normal;
- CairoColorRGB color_inner[2], color_middle[2], color_outer[2], color_button[3], color_inner_compressed[2];
-
- style = gtk_widget_get_style (button);
-
- bg_normal.r = style->bg[0].red/65535.0;
- bg_normal.g = style->bg[0].green/65535.0;
- bg_normal.b = style->bg[0].blue/65535.0;
-
- fg_normal.r = style->fg[0].red/65535.0;
- fg_normal.g = style->fg[0].green/65535.0;
- fg_normal.b = style->fg[0].blue/65535.0;
-
- _color_shade (&bg_normal, INNER_START_SHADE, &color_inner[0]);
- _color_shade (&bg_normal, INNER_END_SHADE, &color_inner[1]);
- _color_shade (&bg_normal, MIDDLE_START_SHADE, &color_middle[0]);
- _color_shade (&bg_normal, MIDDLE_END_SHADE, &color_middle[1]);
- _color_shade (&bg_normal, OUTER_START_SHADE, &color_outer[0]);
- _color_shade (&bg_normal, OUTER_END_SHADE, &color_outer[1]);
- _color_shade (&fg_normal, BUTTON_START_SHADE, &color_button[0]);
- _color_shade (&fg_normal, BUTTON_END_SHADE, &color_button[1]);
- _color_shade (&bg_normal, BUTTON_SHADOW_SHADE, &color_button[2]);
- _color_shade (&bg_normal, INNER_COMPRESSED_START_SHADE, &color_inner_compressed[0]);
- _color_shade (&bg_normal, INNER_COMPRESSED_END_SHADE, &color_inner_compressed[1]);
-
- double MIDDLE_END[] = {color_middle[0].r, color_middle[0].g, color_middle[0].b, 1.0f};
- double MIDDLE_START[] = {color_middle[1].r, color_middle[1].g, color_middle[1].b, 1.0f};
- double OUTER_END[] = {color_outer[0].r, color_outer[0].g, color_outer[0].b, 1.0f};
- double OUTER_START[] = {color_outer[1].r, color_outer[1].g, color_outer[1].b, 1.0f};
- double BUTTON_END[] = {color_button[0].r, color_button[0].g, color_button[0].b, 1.0f};
- double BUTTON_START[] = {color_button[1].r, color_button[1].g, color_button[1].b, 1.0f};
- double BUTTON_SHADOW[] = {color_button[2].r, color_button[2].g, color_button[2].b, 0.75f};
- double INNER_COMPRESSED_END[] = {color_inner_compressed[1].r, color_inner_compressed[1].g, color_inner_compressed[1].b, 1.0f};
- double INNER_COMPRESSED_START[] = {color_inner_compressed[0].r, color_inner_compressed[0].g, color_inner_compressed[0].b, 1.0f};
-
- // prev/next-background
- draw_gradient (cr,
- X,
- Y,
- RECT_WIDTH,
- OUTER_RADIUS,
- OUTER_START,
- OUTER_END);
- draw_gradient (cr,
- X,
- Y + 1,
- RECT_WIDTH - 2,
- MIDDLE_RADIUS,
- MIDDLE_START,
- MIDDLE_END);
- draw_gradient (cr,
- X,
- Y + 2,
- RECT_WIDTH - 4,
- MIDDLE_RADIUS,
- MIDDLE_START,
- MIDDLE_END);
-
- if(priv->current_command == TRANSPORT_PREVIOUS){
- draw_gradient (cr,
- X,
- Y + 2,
- RECT_WIDTH/2,
- INNER_RADIUS,
- INNER_COMPRESSED_START,
- INNER_COMPRESSED_END);
- }
- else if(priv->current_command == TRANSPORT_NEXT){
- draw_gradient (cr,
- RECT_WIDTH / 2 + X,
- Y + 2,
- (RECT_WIDTH - 7)/2,
- INNER_RADIUS,
- INNER_COMPRESSED_START,
- INNER_COMPRESSED_END);
- }
-
- // play/pause-background
- draw_circle (cr,
- X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f,
- Y - ((CIRCLE_RADIUS - OUTER_RADIUS)),
- CIRCLE_RADIUS,
- OUTER_START,
- OUTER_END);
- draw_circle (cr,
- X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 0.5f,
- Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 0.5f,
- CIRCLE_RADIUS - 0.75f,
- MIDDLE_START,
- MIDDLE_END);
-
- if(priv->current_command == TRANSPORT_PLAY_PAUSE){
- draw_circle (cr,
- X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.5f,
- Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.5f,
- CIRCLE_RADIUS - 1.5f,
- INNER_COMPRESSED_START,
- INNER_COMPRESSED_END);
- }
- else{
- draw_circle (cr,
- X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.5f,
- Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.5f,
- CIRCLE_RADIUS - 1.5f,
- MIDDLE_START,
- MIDDLE_END);
- }
- // draw previous-button drop-shadow
- _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT);
- _mask_prev (cr_surf,
- (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
- TRI_WIDTH,
- TRI_HEIGHT,
- TRI_OFFSET);
- _fill (cr_surf,
- (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
- (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (double) TRI_HEIGHT,
- BUTTON_SHADOW,
- BUTTON_SHADOW,
- FALSE);
- _surface_blur (surf, 1);
- _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y + 1.0f);
-
- // draw previous-button
- _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT);
- _mask_prev (cr_surf,
- (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
- TRI_WIDTH,
- TRI_HEIGHT,
- TRI_OFFSET);
- _fill (cr_surf,
- (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
- (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (double) TRI_HEIGHT,
- BUTTON_START,
- BUTTON_END,
- FALSE);
- _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y);
-
- // draw next-button drop-shadow
- _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT);
- _mask_next (cr_surf,
- (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f,
- TRI_WIDTH,
- TRI_HEIGHT,
- TRI_OFFSET);
- _fill (cr_surf,
- (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f,
- (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (double) TRI_HEIGHT,
- BUTTON_SHADOW,
- BUTTON_SHADOW,
- FALSE);
- _surface_blur (surf, 1);
- _finalize (cr, &cr_surf, &surf, NEXT_X, NEXT_Y + 1.0f);
-
- // draw next-button
- _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT);
- _mask_next (cr_surf,
- (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f,
- TRI_WIDTH,
- TRI_HEIGHT,
- TRI_OFFSET);
- _fill (cr_surf,
- (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f,
- (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (double) TRI_HEIGHT,
- BUTTON_START,
- BUTTON_END,
- FALSE);
- _finalize (cr, &cr_surf, &surf, NEXT_X, NEXT_Y);
-
- // draw pause-button drop-shadow
- if(priv->current_state == PLAY){
- _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT);
- _mask_pause (cr_surf,
- (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
- (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f,
- BAR_WIDTH,
- BAR_HEIGHT - 2.0f * BAR_WIDTH,
- BAR_OFFSET);
- _fill (cr_surf,
- (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
- (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f,
- (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
- (double) BAR_HEIGHT,
- BUTTON_SHADOW,
- BUTTON_SHADOW,
- TRUE);
- _surface_blur (surf, 1);
- _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f);
-
- // draw pause-button
- _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT);
- _mask_pause (cr_surf,
- (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
- (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f,
- BAR_WIDTH,
- BAR_HEIGHT - 2.0f * BAR_WIDTH,
- BAR_OFFSET);
- _fill (cr_surf,
- (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
- (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f,
- (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
- (double) BAR_HEIGHT,
- BUTTON_START,
- BUTTON_END,
- TRUE);
- _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y);
- }
- else if(priv->current_state == PAUSE){
- _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT);
- _mask_play (cr_surf,
- PLAY_PADDING,
- PLAY_PADDING,
- PLAY_WIDTH - (2*PLAY_PADDING),
- PLAY_HEIGHT - (2*PLAY_PADDING));
- _fill (cr_surf,
- PLAY_PADDING,
- PLAY_PADDING,
- PLAY_WIDTH - (2*PLAY_PADDING),
- PLAY_HEIGHT - (2*PLAY_PADDING),
- BUTTON_SHADOW,
- BUTTON_SHADOW,
- FALSE);
- _surface_blur (surf, 1);
- _finalize (cr, &cr_surf, &surf, PAUSE_X-0.75f, PAUSE_Y + 1.0f);
- // draw play-button
- _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT);
- cairo_set_line_width (cr, 10.5);
- cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
- _mask_play (cr_surf,
- PLAY_PADDING,
- PLAY_PADDING,
- PLAY_WIDTH - (2*PLAY_PADDING),
- PLAY_HEIGHT - (2*PLAY_PADDING));
- _fill (cr_surf,
- PLAY_PADDING,
- PLAY_PADDING,
- PLAY_WIDTH - (2*PLAY_PADDING),
- PLAY_HEIGHT - (2*PLAY_PADDING),
- BUTTON_START,
- BUTTON_END,
- FALSE);
- _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y);
- }
-
-}
-
-/**
-* play_button_new:
-* @returns: a new #PlayButton.
-**/
-GtkWidget*
-play_button_new()
-{
- GtkWidget* widget = g_object_new(PLAY_BUTTON_TYPE, NULL);
- gtk_widget_set_app_paintable (widget, TRUE);
- return widget;
-}
-
diff --git a/src/play-button.h b/src/play-button.h
deleted file mode 100644
index 6bacac7..0000000
--- a/src/play-button.h
+++ /dev/null
@@ -1,68 +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 __PLAY_BUTTON_H__
-#define __PLAY_BUTTON_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define PLAY_BUTTON_TYPE (play_button_get_type ())
-#define PLAY_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLAY_BUTTON_TYPE, PlayButton))
-#define PLAY_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLAY_BUTTON_TYPE, PlayButtonClass))
-#define IS_PLAY_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLAY_BUTTON_TYPE))
-#define IS_PLAY_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLAY_BUTTON_TYPE))
-#define PLAY_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLAY_BUTTON_TYPE, PlayButtonClass))
-
-typedef struct _PlayButton PlayButton;
-typedef struct _PlayButtonClass PlayButtonClass;
-
-typedef enum {
- TRANSPORT_PREVIOUS,
- TRANSPORT_PLAY_PAUSE,
- TRANSPORT_NEXT,
- TRANSPORT_NADA
-}PlayButtonEvent;
-
-typedef enum {
- PLAY,
- PAUSE
-}PlayButtonState;
-
-struct _PlayButtonClass {
- GtkDrawingAreaClass parent_class;
-};
-
-struct _PlayButton {
- GtkDrawingArea parent;
-};
-
-GType play_button_get_type (void);
-void play_button_set_style(GtkWidget* button, GtkStyle* style);
-PlayButtonEvent determine_button_event(GtkWidget* button, GdkEventButton* event);
-void play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command);
-void play_button_react_to_button_release(GtkWidget* button, PlayButtonEvent command);
-void play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update);
-
-GtkWidget* play_button_new();
-
-G_END_DECLS
-
-#endif
-
diff --git a/src/player-controller.c b/src/player-controller.c
index b7be2a0..ab05cb3 100644
--- a/src/player-controller.c
+++ b/src/player-controller.c
@@ -1,4 +1,4 @@
-/* player-controller.c generated by valac 0.9.8, the Vala compiler
+/* player-controller.c generated by valac 0.10.0, the Vala compiler
* generated from player-controller.vala, do not modify */
/*
@@ -475,11 +475,11 @@ static char* player_controller_format_client_name (const char* client_name) {
char* formatted;
g_return_val_if_fail (client_name != NULL, NULL);
formatted = g_strdup (client_name);
- if (g_utf8_strlen (formatted, -1) > 1) {
+ if (string_get_length (formatted) > 1) {
char* _tmp0_;
char* _tmp1_;
char* _tmp2_;
- formatted = (_tmp2_ = g_strconcat (_tmp0_ = g_utf8_strup (client_name, (gssize) 1), _tmp1_ = string_slice (client_name, (glong) 1, g_utf8_strlen (client_name, -1)), NULL), _g_free0 (formatted), _tmp2_);
+ formatted = (_tmp2_ = g_strconcat (_tmp0_ = g_utf8_strup (client_name, (gssize) 1), _tmp1_ = string_slice (client_name, (glong) 1, string_get_length (client_name)), NULL), _g_free0 (formatted), _tmp2_);
_g_free0 (_tmp1_);
_g_free0 (_tmp0_);
g_debug ("player-controller.vala:165: PlayerController->format_client_name - : %" \
diff --git a/src/player-controller.vala b/src/player-controller.vala
index f5ec205..d5b79e7 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -160,8 +160,8 @@ public class PlayerController : GLib.Object
private static string format_client_name(string client_name)
{
string formatted = client_name;
- if(formatted.len() > 1){
- formatted = client_name.up(1).concat(client_name.slice(1, client_name.len()));
+ if(formatted.length > 1){
+ formatted = client_name.up(1).concat(client_name.slice(1, client_name.length));
debug("PlayerController->format_client_name - : %s", formatted);
}
return formatted;
diff --git a/src/player-item.c b/src/player-item.c
index 2449bfb..707d161 100644
--- a/src/player-item.c
+++ b/src/player-item.c
@@ -1,4 +1,4 @@
-/* player-item.c generated by valac 0.9.8, the Vala compiler
+/* player-item.c generated by valac 0.10.0, the Vala compiler
* generated from player-item.vala, do not modify */
/*
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index f93368e..8779525 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -43,7 +43,6 @@ static void pulse_server_info_callback(pa_context *c, const pa_server_info *info
static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, void *userdata);
static void destroy_sink_info(void *value);
static gboolean determine_sink_availability();
-static void reconnect_to_pulse();
static gboolean has_volume_changed(const pa_sink_info* new_sink, sink_info* cached_sink);
static pa_cvolume construct_mono_volume(const pa_cvolume* vol);
@@ -100,35 +99,6 @@ void close_pulse_activites()
}
/**
-reconnect_to_pulse()
-In the event of Pulseaudio flapping in the wind handle gracefully without
-memory leaks !
-*/
-static void reconnect_to_pulse()
-{
- // reset
- if (pulse_context != NULL) {
- g_debug("freeing the pulse context");
- pa_context_unref(pulse_context);
- pulse_context = NULL;
- }
-
- if (sink_hash != NULL) {
- g_hash_table_destroy(sink_hash);
- sink_hash = NULL;
- }
-
- // reconnect
- pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound");
- g_assert(pulse_context);
- sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info);
- // Establish event callback registration
- pa_context_set_state_callback(pulse_context, context_state_callback, NULL);
- dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0);
- pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
-}
-
-/**
destroy_sink_info()
item destructor method for the sink_info hash
**/
@@ -534,7 +504,6 @@ static void context_state_callback(pa_context *c, void *userdata)
case PA_CONTEXT_FAILED:
g_warning("FAILED to retrieve context - Is PulseAudio Daemon running ?");
pa_server_available = FALSE;
- reconnect_to_pulse();
break;
case PA_CONTEXT_TERMINATED:
/* g_debug("context terminated");*/
diff --git a/src/sound-service-server.h b/src/sound-service-server.h
index 0431d64..19d3f89 100644
--- a/src/sound-service-server.h
+++ b/src/sound-service-server.h
@@ -112,8 +112,7 @@ static const DBusGMethodInfo dbus_glib__sound_service_server_methods[] = {
{ (GCallback) sound_service_dbus_get_sink_availability, dbus_glib_marshal__sound_service_server_BOOLEAN__POINTER_POINTER, 62 },
};
-const DBusGObjectInfo dbus_glib__sound_service_server_object_info = {
- 0,
+const DBusGObjectInfo dbus_glib__sound_service_server_object_info = { 1,
dbus_glib__sound_service_server_methods,
2,
"org.ayatana.indicator.sound\0GetSinkMute\0S\0mute_input\0O\0F\0N\0b\0\0org.ayatana.indicator.sound\0GetSinkAvailability\0S\0availability_input\0O\0F\0N\0b\0\0\0",
diff --git a/src/title-menu-item.c b/src/title-menu-item.c
index f66a8f8..8ae80c4 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.9.8, the Vala compiler
+/* title-menu-item.c generated by valac 0.10.0, the Vala compiler
* generated from title-menu-item.vala, do not modify */
/*
diff --git a/src/title-widget.c b/src/title-widget.c
index bc1d453..3003e10 100644
--- a/src/title-widget.c
+++ b/src/title-widget.c
@@ -32,7 +32,7 @@ typedef struct _TitleWidgetPrivate TitleWidgetPrivate;
struct _TitleWidgetPrivate
{
- DbusmenuMenuitem* twin_item;
+ DbusmenuMenuitem* twin_item;
};
#define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate))
@@ -63,21 +63,21 @@ G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_IMAGE_MENU_ITEM);
static void
title_widget_class_init (TitleWidgetClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->button_press_event = title_widget_button_press_event;
-
- g_type_class_add_private (klass, sizeof (TitleWidgetPrivate));
+ widget_class->button_press_event = title_widget_button_press_event;
+
+ g_type_class_add_private (klass, sizeof (TitleWidgetPrivate));
- gobject_class->dispose = title_widget_dispose;
- gobject_class->finalize = title_widget_finalize;
+ gobject_class->dispose = title_widget_dispose;
+ gobject_class->finalize = title_widget_finalize;
}
static void
title_widget_init (TitleWidget *self)
{
- g_debug("TitleWidget::title_widget_init");
+ //g_debug("TitleWidget::title_widget_init");
gint padding = 0;
gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL);
@@ -92,7 +92,7 @@ title_widget_init (TitleWidget *self)
+ 1 /* padding */,
height);
gtk_misc_set_alignment(GTK_MISC(icon), 0.5 /* right aligned */, 0);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon));
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon));
gtk_widget_show(icon);
}
@@ -114,11 +114,11 @@ static gboolean
title_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("TitleWidget::menu_press_event");
+ //g_debug("TitleWidget::menu_press_event");
TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem);
GValue value = {0};
- g_value_init(&value, G_TYPE_BOOLEAN);
+ g_value_init(&value, G_TYPE_BOOLEAN);
g_value_set_boolean(&value, TRUE);
dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0);
@@ -134,8 +134,8 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
TitleWidget* mitem = TITLE_WIDGET(userdata);
if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){
- gtk_menu_item_set_label (GTK_MENU_ITEM(mitem),
- g_value_get_string(value));
+ gtk_menu_item_set_label (GTK_MENU_ITEM(mitem),
+ g_value_get_string(value));
}
}
@@ -158,8 +158,7 @@ title_widget_set_twin_item(TitleWidget* self,
gtk_menu_item_set_label (GTK_MENU_ITEM(self),
dbusmenu_menuitem_property_get(priv->twin_item,
- DBUSMENU_TITLE_MENUITEM_NAME));
-
+ DBUSMENU_TITLE_MENUITEM_NAME));
}
static gboolean
@@ -218,7 +217,7 @@ title_widget_new(DbusmenuMenuitem *item)
{
GtkWidget* widget = g_object_new (TITLE_WIDGET_TYPE,
NULL);
- gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (widget), TRUE);
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (widget), TRUE);
title_widget_set_twin_item((TitleWidget*)widget, item);
return widget;
diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c
index 0181bd3..3161da8 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.9.8, the Vala compiler
+/* transport-menu-item.c generated by valac 0.10.0, the Vala compiler
* generated from transport-menu-item.vala, do not modify */
/*
diff --git a/src/transport-widget.c b/src/transport-widget.c
index eba2099..e7f0b4d 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -3,6 +3,7 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
+ Mirco Müller <mirco.mueller@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
@@ -15,27 +16,78 @@ 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/>.
+
+Uses code from ctk
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <glib/gi18n.h>
+#include <math.h>
#include "transport-widget.h"
#include "common-defs.h"
-#include <gtk/gtk.h>
-#include "play-button.h"
+
+
+#define RECT_WIDTH 130.0f
+#define Y 7.0f
+#define X 80.0f
+#define INNER_RADIUS 12.5
+#define MIDDLE_RADIUS 13.5f
+#define OUTER_RADIUS 14.5f
+#define CIRCLE_RADIUS 21.0f
+#define PREV_WIDTH 25.0f
+#define PREV_HEIGHT 17.0f
+#define NEXT_WIDTH 25.0f //PREV_WIDTH
+#define NEXT_HEIGHT 17.0f //PREV_HEIGHT
+#define TRI_WIDTH 11.0f
+#define TRI_HEIGHT 13.0f
+#define TRI_OFFSET 6.0f
+#define PREV_X 78.0f
+#define PREV_Y 13.0f
+#define NEXT_X 156.0f
+#define NEXT_Y 13.0f //prev_y
+#define PAUSE_WIDTH 21.0f
+#define PAUSE_HEIGHT 27.0f
+#define BAR_WIDTH 4.5f
+#define BAR_HEIGHT 24.0f
+#define BAR_OFFSET 10.0f
+#define PAUSE_X 121.0f
+#define PAUSE_Y 7.0f
+#define PLAY_WIDTH 28.0f
+#define PLAY_HEIGHT 29.0f
+#define PLAY_PADDING 5.0f
+#define INNER_START_SHADE 0.98
+#define INNER_END_SHADE 0.98
+#define MIDDLE_START_SHADE 0.7
+#define MIDDLE_END_SHADE 1.4
+#define OUTER_START_SHADE 0.96
+#define OUTER_END_SHADE 0.96
+#define BUTTON_START_SHADE 1.1
+#define BUTTON_END_SHADE 0.9
+#define BUTTON_SHADOW_SHADE 0.8
+#define INNER_COMPRESSED_START_SHADE 0.95
+#define INNER_COMPRESSED_END_SHADE 1.05
+
typedef struct _TransportWidgetPrivate TransportWidgetPrivate;
struct _TransportWidgetPrivate
{
- GtkWidget* hbox;
- GtkWidget* play_button;
- DbusmenuMenuitem* twin_item;
+ TransportWidgetEvent current_command;
+ TransportWidgetState current_state;
+ GHashTable* command_coordinates;
+ DbusmenuMenuitem* twin_item;
};
+typedef struct
+{
+ double r;
+ double g;
+ double b;
+} CairoColorRGB;
+
+
#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate))
/* Gobject boiler plate */
@@ -43,73 +95,98 @@ static void transport_widget_class_init (TransportWidgetClass *klass);
static void transport_widget_init (TransportWidget *self);
static void transport_widget_dispose (GObject *object);
static void transport_widget_finalize (GObject *object);
+G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
-static void transport_widget_set_twin_item(TransportWidget* self,
- DbusmenuMenuitem* twin_item);
-static gboolean transport_widget_expose_event(GtkWidget* widget,
- GdkEventExpose* event);
+/* essentials */
+static void transport_widget_set_twin_item ( TransportWidget* self,
+ DbusmenuMenuitem* twin_item);
+static gboolean transport_widget_expose ( GtkWidget *button, GdkEventExpose *event);
+static void draw (GtkWidget* button, cairo_t *cr);
/* UI and dbusmenu callbacks */
static gboolean transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event);
-static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
+static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
GdkEventButton *event);
-static void transport_widget_property_update( DbusmenuMenuitem* item,
- gchar * property,
- GValue * value,
- gpointer userdata );
+static void transport_widget_property_update ( DbusmenuMenuitem* item,
+ gchar * property,
+ GValue * value,
+ gpointer userdata );
static void transport_widget_menu_hidden ( GtkWidget *menu,
TransportWidget *transport);
static void transport_widget_notify ( TransportWidget *item,
GParamSpec *pspec,
gpointer user_data );
+static TransportWidgetEvent transport_widget_determine_button_event ( TransportWidget* button,
+ GdkEventButton* event);
+static void transport_widget_react_to_button_release ( TransportWidget* button,
+ TransportWidgetEvent command);
+static void transport_widget_toggle_play_pause ( TransportWidget* button,
+ TransportWidgetState update);
-G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
+/// Init functions //////////////////////////////////////////////////////////
static void
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);
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass* widget_class = GTK_WIDGET_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;
- widget_class->expose_event = transport_widget_expose_event;
g_type_class_add_private (klass, sizeof (TransportWidgetPrivate));
+ widget_class->button_press_event = transport_widget_button_press_event;
+ widget_class->button_release_event = transport_widget_button_release_event;
+ widget_class->expose_event = transport_widget_expose;
+
gobject_class->dispose = transport_widget_dispose;
- gobject_class->finalize = transport_widget_finalize;
+ gobject_class->finalize = transport_widget_finalize;
}
static void
transport_widget_init (TransportWidget *self)
{
- g_debug("TransportWidget::transport_widget_init");
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
+ priv->current_command = TRANSPORT_NADA;
+ priv->current_state = PAUSE;
+ priv->command_coordinates = g_hash_table_new_full(g_direct_hash,
+ g_direct_equal,
+ NULL,
+ (GDestroyNotify)g_list_free);
+ GList* previous_list = NULL;
+ previous_list = g_list_insert(previous_list, GINT_TO_POINTER(15), 0);
+ previous_list = g_list_insert(previous_list, GINT_TO_POINTER(5), 1);
+ previous_list = g_list_insert(previous_list, GINT_TO_POINTER(60), 2);
+ previous_list = g_list_insert(previous_list, GINT_TO_POINTER(34), 3);
+ g_hash_table_insert(priv->command_coordinates,
+ GINT_TO_POINTER(TRANSPORT_PREVIOUS),
+ previous_list);
+
+ GList* play_list = NULL;
+ play_list = g_list_insert(play_list, GINT_TO_POINTER(58), 0);
+ play_list = g_list_insert(play_list, GINT_TO_POINTER(0), 1);
+ play_list = g_list_insert(play_list, GINT_TO_POINTER(50), 2);
+ play_list = g_list_insert(play_list, GINT_TO_POINTER(43), 3);
- TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
- GtkWidget* hbox;
+ g_hash_table_insert(priv->command_coordinates,
+ GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE),
+ play_list);
- hbox = gtk_hbox_new(TRUE, 2);
+ GList* next_list = NULL;
+ next_list = g_list_insert(next_list, GINT_TO_POINTER(100), 0);
+ next_list = g_list_insert(next_list, GINT_TO_POINTER(5), 1);
+ next_list = g_list_insert(next_list, GINT_TO_POINTER(60), 2);
+ next_list = g_list_insert(next_list, GINT_TO_POINTER(34), 3);
- GtkStyle* style = gtk_rc_get_style(GTK_WIDGET(self));
+ g_hash_table_insert(priv->command_coordinates,
+ GINT_TO_POINTER(TRANSPORT_NEXT),
+ next_list);
- priv->hbox = hbox;
- priv->play_button = play_button_new();
- play_button_set_style(priv->play_button, style);
-
- gtk_box_pack_start (GTK_BOX (priv->hbox), priv->play_button, FALSE, FALSE, 0);
-
- gtk_container_add (GTK_CONTAINER (self), priv->hbox);
-
- gtk_widget_show_all (priv->hbox);
-
- g_signal_connect (G_OBJECT(self),
- "notify",
- G_CALLBACK (transport_widget_notify),
- NULL);
+ gtk_widget_set_size_request(GTK_WIDGET(self), 200, 50);
+ g_signal_connect (G_OBJECT(self),
+ "notify::parent",
+ G_CALLBACK (transport_widget_notify),
+ NULL);
}
static void
@@ -124,19 +201,32 @@ transport_widget_finalize (GObject *object)
G_OBJECT_CLASS (transport_widget_parent_class)->finalize (object);
}
-static gboolean
-transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
+static gboolean
+transport_widget_expose (GtkWidget *button, GdkEventExpose *event)
{
- return TRUE;
+ cairo_t *cr;
+ cr = gdk_cairo_create (button->window);
+
+ //g_debug("In the playbutton's expose method, x = %i, y=%i and width: %i and height: %i'");
+ cairo_rectangle (cr,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height);
+
+ cairo_clip(cr);
+ draw (button, cr);
+
+ cairo_destroy (cr);
+ return FALSE;
}
-static void transport_widget_set_twin_item(TransportWidget* self,
- DbusmenuMenuitem* twin_item)
+static void
+transport_widget_toggle_play_pause(TransportWidget* button,
+ TransportWidgetState update)
{
- TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
- priv->twin_item = twin_item;
- g_signal_connect(G_OBJECT(priv->twin_item), "property-changed",
- G_CALLBACK(transport_widget_property_update), self);
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(button);
+ priv->current_state = update;
+ //g_debug("TransportWidget::toggle play state : %i", priv->current_state);
+ gtk_widget_queue_draw (GTK_WIDGET(button));
}
static void
@@ -144,69 +234,1044 @@ transport_widget_notify (TransportWidget *item,
GParamSpec *pspec,
gpointer user_data)
{
-
- if (g_strcmp0 (pspec->name, "parent"))
- {
- GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (item));
-
- if (parent)
- {
- g_signal_connect (parent, "hide",
- G_CALLBACK (transport_widget_menu_hidden),
- item);
- }
+ if (g_strcmp0 (pspec->name, "parent")){
+ GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (item));
+ if (parent){
+ g_signal_connect ( parent, "hide",
+ G_CALLBACK (transport_widget_menu_hidden),
+ item);
}
+ }
}
static void
transport_widget_menu_hidden ( GtkWidget *menu,
TransportWidget *transport)
{
- g_debug("Transport Widget's menu hidden method called");
+ //g_debug("Transport Widget's menu hidden method called");
g_return_if_fail(IS_TRANSPORT_WIDGET(transport));
- TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(transport));
- play_button_react_to_button_release(priv->play_button, TRANSPORT_NADA);
-
+ transport_widget_react_to_button_release(transport, TRANSPORT_NADA);
}
-
/* keyevents */
static gboolean
transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
- TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
-
- PlayButtonEvent result = determine_button_event(priv->play_button, event);
+ g_return_val_if_fail ( IS_TRANSPORT_WIDGET(menuitem), FALSE );
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE ( TRANSPORT_WIDGET(menuitem) );
+ TransportWidgetEvent result = transport_widget_determine_button_event ( TRANSPORT_WIDGET(menuitem),
+ event);
if(result != TRANSPORT_NADA){
- play_button_react_to_button_press(priv->play_button, result);
- }
+ priv->current_command = result;
+ cairo_t *cr;
+ cr = gdk_cairo_create (menuitem->window);
+ draw ( menuitem, cr );
+ cairo_destroy ( cr );
+ }
return TRUE;
}
-
static gboolean
transport_widget_button_release_event (GtkWidget *menuitem,
- GdkEventButton *event)
+ GdkEventButton *event)
{
- g_debug("TransportWidget::menu_release_event");
- g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
- TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+ //g_debug("TransportWidget::menu_release_event");
+ g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
+ TransportWidget* transport = TRANSPORT_WIDGET(menuitem);
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
+
+ TransportWidgetEvent result = transport_widget_determine_button_event ( transport,
+ event );
+ if(result != TRANSPORT_NADA){
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_INT);
+ //g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
+ g_value_set_int(&value, (int)result);
+ dbusmenu_menuitem_handle_event ( priv->twin_item,
+ "Transport state change",
+ &value,
+ 0 );
+ }
+
+ transport_widget_react_to_button_release ( transport,
+ result );
+ return TRUE;
+}
+
+static TransportWidgetEvent
+transport_widget_determine_button_event( TransportWidget* button,
+ GdkEventButton* event )
+{
+ //g_debug("event x coordinate = %f", event->x);
+ //g_debug("event y coordinate = %f", event->y);
+ TransportWidgetEvent button_event = TRANSPORT_NADA;
+ // For now very simple rectangular collision detection
+ if(event->x > 67 && event->x < 112
+ && event->y > 12 && event->y < 40){
+ button_event = TRANSPORT_PREVIOUS;
+ }
+ else if(event->x > 111 && event->x < 153
+ && event->y > 5 && event->y < 47){
+ button_event = TRANSPORT_PLAY_PAUSE;
+ }
+ else if(event->x > 152 && event->x < 197
+ && event->y > 12 && event->y < 40){
+ button_event = TRANSPORT_NEXT;
+ }
+ return button_event;
+}
+
+
+static void
+transport_widget_react_to_button_release ( TransportWidget* button,
+ TransportWidgetEvent command )
+{
+ g_return_if_fail(IS_TRANSPORT_WIDGET(button));
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(button);
+ if(priv->current_command == TRANSPORT_NADA){
+ //g_debug("returning from the playbutton release because my previous command was nada");
+ return;
+ }
+ else if(priv->current_command != TRANSPORT_NADA &&
+ command != TRANSPORT_NADA){
+ priv->current_command = command;
+ }
+ cairo_t *cr;
+ cr = gdk_cairo_create ( GTK_WIDGET(button)->window );
+ priv->current_command = TRANSPORT_NADA;
+
+ draw ( GTK_WIDGET(button), cr );
+ cairo_destroy (cr);
+}
+
+/// internal helper functions //////////////////////////////////////////////////
+
+static void
+draw_gradient (cairo_t* cr,
+ double x,
+ double y,
+ double w,
+ double r,
+ double* rgba_start,
+ double* rgba_end)
+{
+ cairo_pattern_t* pattern = NULL;
+
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + w - 2.0f * r, y);
+ cairo_arc (cr,
+ x + w - 2.0f * r,
+ y + r,
+ r,
+ -90.0f * G_PI / 180.0f,
+ 90.0f * G_PI / 180.0f);
+ cairo_line_to (cr, x, y + 2.0f * r);
+ cairo_arc (cr,
+ x,
+ y + r,
+ r,
+ 90.0f * G_PI / 180.0f,
+ 270.0f * G_PI / 180.0f);
+ cairo_close_path (cr);
+
+ pattern = cairo_pattern_create_linear (x, y, x, y + 2.0f * r);
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 0.0f,
+ rgba_start[0],
+ rgba_start[1],
+ rgba_start[2],
+ rgba_start[3]);
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 1.0f,
+ rgba_end[0],
+ rgba_end[1],
+ rgba_end[2],
+ rgba_end[3]);
+ cairo_set_source (cr, pattern);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pattern);
+}
+
+static void
+draw_circle (cairo_t* cr,
+ double x,
+ double y,
+ double r,
+ double* rgba_start,
+ double* rgba_end)
+{
+ cairo_pattern_t* pattern = NULL;
+
+ cairo_move_to (cr, x, y);
+ cairo_arc (cr,
+ x + r,
+ y + r,
+ r,
+ 0.0f * G_PI / 180.0f,
+ 360.0f * G_PI / 180.0f);
+
+ pattern = cairo_pattern_create_linear (x, y, x, y + 2.0f * r);
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 0.0f,
+ rgba_start[0],
+ rgba_start[1],
+ rgba_start[2],
+ rgba_start[3]);
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 1.0f,
+ rgba_end[0],
+ rgba_end[1],
+ rgba_end[2],
+ rgba_end[3]);
+ cairo_set_source (cr, pattern);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pattern);
+}
+
+static void
+_setup (cairo_t** cr,
+ cairo_surface_t** surf,
+ gint width,
+ gint height)
+{
+ if (!cr || !surf)
+ return;
+
+ *surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ *cr = cairo_create (*surf);
+ cairo_scale (*cr, 1.0f, 1.0f);
+ cairo_set_operator (*cr, CAIRO_OPERATOR_CLEAR);
+ cairo_paint (*cr);
+ cairo_set_operator (*cr, CAIRO_OPERATOR_OVER);
+}
+
+static void
+_mask_prev (cairo_t* cr,
+ double x,
+ double y,
+ double tri_width,
+ double tri_height,
+ double tri_offset)
+{
+ if (!cr)
+ return;
+
+ cairo_move_to (cr, x, y + tri_height / 2.0f);
+ cairo_line_to (cr, x + tri_width, y);
+ cairo_line_to (cr, x + tri_width, y + tri_height);
+ x += tri_offset;
+ cairo_move_to (cr, x, y + tri_height / 2.0f);
+ cairo_line_to (cr, x + tri_width, y);
+ cairo_line_to (cr, x + tri_width, y + tri_height);
+ x -= tri_offset;
+ cairo_rectangle (cr, x, y, 2.5f, tri_height);
+ cairo_close_path (cr);
+}
+
+static void
+_mask_next (cairo_t* cr,
+ double x,
+ double y,
+ double tri_width,
+ double tri_height,
+ double tri_offset)
+{
+ if (!cr)
+ return;
+
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + tri_width, y + tri_height / 2.0f);
+ cairo_line_to (cr, x, y + tri_height);
+ x += tri_offset;
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + tri_width, y + tri_height / 2.0f);
+ cairo_line_to (cr, x, y + tri_height);
+ x -= tri_offset;
+ x += 2.0f * tri_width - tri_offset - 1.0f;
+ cairo_rectangle (cr, x, y, 2.5f, tri_height);
+
+ cairo_close_path (cr);
+}
+
+static void
+_mask_pause (cairo_t* cr,
+ double x,
+ double y,
+ double bar_width,
+ double bar_height,
+ double bar_offset)
+{
+ if (!cr)
+ return;
+
+ cairo_set_line_width (cr, bar_width);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+
+ x += bar_width;
+ y += bar_width;
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x, y + bar_height);
+ cairo_move_to (cr, x + bar_offset, y);
+ cairo_line_to (cr, x + bar_offset, y + bar_height);
+
+}
+
+static void
+_mask_play (cairo_t* cr,
+ double x,
+ double y,
+ double tri_width,
+ double tri_height
+ /*double tri_offset*/)
+{
+ if (!cr)
+ return;
+
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + tri_width, y + tri_height / 2.0f);
+ cairo_line_to (cr, x, y + tri_height);
+ cairo_close_path (cr);
- PlayButtonEvent result = determine_button_event(priv->play_button, event);
+}
- if(result != TRANSPORT_NADA){
- GValue value = {0};
- g_value_init(&value, G_TYPE_INT);
- g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
- g_value_set_int(&value, (int)result);
- dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
+static void
+_fill (cairo_t* cr,
+ double x_start,
+ double y_start,
+ double x_end,
+ double y_end,
+ double* rgba_start,
+ double* rgba_end,
+ gboolean stroke)
+{
+ cairo_pattern_t* pattern = NULL;
+
+ if (!cr || !rgba_start || !rgba_end)
+ return;
+
+ pattern = cairo_pattern_create_linear (x_start, y_start, x_end, y_end);
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 0.0f,
+ rgba_start[0],
+ rgba_start[1],
+ rgba_start[2],
+ rgba_start[3]);
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 1.0f,
+ rgba_end[0],
+ rgba_end[1],
+ rgba_end[2],
+ rgba_end[3]);
+ cairo_set_source (cr, pattern);
+ if (stroke)
+ cairo_stroke (cr);
+ else
+ cairo_fill (cr);
+ cairo_pattern_destroy (pattern);
+}
+
+static void
+_finalize (cairo_t* cr,
+ cairo_t** cr_surf,
+ cairo_surface_t** surf,
+ double x,
+ double y)
+{
+ if (!cr || !cr_surf || !surf)
+ return;
+
+ cairo_set_source_surface (cr, *surf, x, y);
+ cairo_paint (cr);
+ cairo_surface_destroy (*surf);
+ cairo_destroy (*cr_surf);
+}
+
+static void
+_color_rgb_to_hls (gdouble *r,
+ gdouble *g,
+ gdouble *b)
+{
+ gdouble min;
+ gdouble max;
+ gdouble red;
+ gdouble green;
+ gdouble blue;
+ gdouble h, l, s;
+ gdouble delta;
+
+ red = *r;
+ green = *g;
+ blue = *b;
+
+ if (red > green)
+ {
+ if (red > blue)
+ max = red;
+ else
+ max = blue;
+
+ if (green < blue)
+ min = green;
+ else
+ min = blue;
+ }
+ else
+ {
+ if (green > blue)
+ max = green;
+ else
+ max = blue;
+
+ if (red < blue)
+ min = red;
+ else
+ min = blue;
+ }
+ l = (max+min)/2;
+ if (fabs (max-min) < 0.0001)
+ {
+ h = 0;
+ s = 0;
+ }
+ else
+ {
+ if (l <= 0.5)
+ s = (max-min)/(max+min);
+ else
+ s = (max-min)/(2-max-min);
+
+ delta = (max -min) != 0 ? (max -min) : 1;
+
+ if(delta == 0)
+ delta = 1;
+ if (red == max)
+ h = (green-blue)/delta;
+ else if (green == max)
+ h = 2+(blue-red)/delta;
+ else if (blue == max)
+ h = 4+(red-green)/delta;
+
+ h *= 60;
+ if (h < 0.0)
+ h += 360;
}
- play_button_react_to_button_release(priv->play_button, result);
+
+ *r = h;
+ *g = l;
+ *b = s;
+}
+
+static void
+_color_hls_to_rgb (gdouble *h,
+ gdouble *l,
+ gdouble *s)
+{
+ gdouble hue;
+ gdouble lightness;
+ gdouble saturation;
+ gdouble m1, m2;
+ gdouble r, g, b;
+
+ lightness = *l;
+ saturation = *s;
+
+ if (lightness <= 0.5)
+ m2 = lightness*(1+saturation);
+ else
+ m2 = lightness+saturation-lightness*saturation;
+
+ m1 = 2*lightness-m2;
+
+ if (saturation == 0)
+ {
+ *h = lightness;
+ *l = lightness;
+ *s = lightness;
+ }
+ else
+ {
+ hue = *h+120;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ r = m1+(m2-m1)*hue/60;
+ else if (hue < 180)
+ r = m2;
+ else if (hue < 240)
+ r = m1+(m2-m1)*(240-hue)/60;
+ else
+ r = m1;
+
+ hue = *h;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ g = m1+(m2-m1)*hue/60;
+ else if (hue < 180)
+ g = m2;
+ else if (hue < 240)
+ g = m1+(m2-m1)*(240-hue)/60;
+ else
+ g = m1;
+
+ hue = *h-120;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ b = m1+(m2-m1)*hue/60;
+ else if (hue < 180)
+ b = m2;
+ else if (hue < 240)
+ b = m1+(m2-m1)*(240-hue)/60;
+ else
+ b = m1;
+
+ *h = r;
+ *l = g;
+ *s = b;
+ }
+}
+
+static void
+_color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b)
+{
+ double red;
+ double green;
+ double blue;
+
+ red = a->r;
+ green = a->g;
+ blue = a->b;
+
+ if (k == 1.0)
+ {
+ b->r = red;
+ b->g = green;
+ b->b = blue;
+ return;
+ }
+
+ _color_rgb_to_hls (&red, &green, &blue);
+
+ green *= k;
+ if (green > 1.0)
+ green = 1.0;
+ else if (green < 0.0)
+ green = 0.0;
+
+ blue *= k;
+ if (blue > 1.0)
+ blue = 1.0;
+ else if (blue < 0.0)
+ blue = 0.0;
+
+ _color_hls_to_rgb (&red, &green, &blue);
+
+ b->r = red;
+ b->g = green;
+ b->b = blue;
+}
+
+static inline void
+_blurinner (guchar* pixel,
+ gint* zR,
+ gint* zG,
+ gint* zB,
+ gint* zA,
+ gint alpha,
+ gint aprec,
+ gint zprec)
+{
+ gint R;
+ gint G;
+ gint B;
+ guchar A;
+
+ R = *pixel;
+ G = *(pixel + 1);
+ B = *(pixel + 2);
+ A = *(pixel + 3);
+
+ *zR += (alpha * ((R << zprec) - *zR)) >> aprec;
+ *zG += (alpha * ((G << zprec) - *zG)) >> aprec;
+ *zB += (alpha * ((B << zprec) - *zB)) >> aprec;
+ *zA += (alpha * ((A << zprec) - *zA)) >> aprec;
+
+ *pixel = *zR >> zprec;
+ *(pixel + 1) = *zG >> zprec;
+ *(pixel + 2) = *zB >> zprec;
+ *(pixel + 3) = *zA >> zprec;
+}
+
+static inline void
+_blurrow (guchar* pixels,
+ gint width,
+ gint height,
+ gint channels,
+ gint line,
+ gint alpha,
+ gint aprec,
+ gint zprec)
+{
+ gint zR;
+ gint zG;
+ gint zB;
+ gint zA;
+ gint index;
+ guchar* scanline;
+
+ scanline = &(pixels[line * width * channels]);
+
+ zR = *scanline << zprec;
+ zG = *(scanline + 1) << zprec;
+ zB = *(scanline + 2) << zprec;
+ zA = *(scanline + 3) << zprec;
+
+ for (index = 0; index < width; index ++)
+ _blurinner (&scanline[index * channels],
+ &zR,
+ &zG,
+ &zB,
+ &zA,
+ alpha,
+ aprec,
+ zprec);
+
+ for (index = width - 2; index >= 0; index--)
+ _blurinner (&scanline[index * channels],
+ &zR,
+ &zG,
+ &zB,
+ &zA,
+ alpha,
+ aprec,
+ zprec);
+}
+
+static inline void
+_blurcol (guchar* pixels,
+ gint width,
+ gint height,
+ gint channels,
+ gint x,
+ gint alpha,
+ gint aprec,
+ gint zprec)
+{
+ gint zR;
+ gint zG;
+ gint zB;
+ gint zA;
+ gint index;
+ guchar* ptr;
+
+ ptr = pixels;
+
+ ptr += x * channels;
+
+ zR = *((guchar*) ptr ) << zprec;
+ zG = *((guchar*) ptr + 1) << zprec;
+ zB = *((guchar*) ptr + 2) << zprec;
+ zA = *((guchar*) ptr + 3) << zprec;
+
+ for (index = width; index < (height - 1) * width; index += width)
+ _blurinner ((guchar*) &ptr[index * channels],
+ &zR,
+ &zG,
+ &zB,
+ &zA,
+ alpha,
+ aprec,
+ zprec);
+
+ for (index = (height - 2) * width; index >= 0; index -= width)
+ _blurinner ((guchar*) &ptr[index * channels],
+ &zR,
+ &zG,
+ &zB,
+ &zA,
+ alpha,
+ aprec,
+ zprec);
+}
+
+void
+_expblur (guchar* pixels,
+ gint width,
+ gint height,
+ gint channels,
+ gint radius,
+ gint aprec,
+ gint zprec)
+{
+ gint alpha;
+ gint row = 0;
+ gint col = 0;
+
+ if (radius < 1)
+ return;
+
+ // calculate the alpha such that 90% of
+ // the kernel is within the radius.
+ // (Kernel extends to infinity)
+ alpha = (gint) ((1 << aprec) * (1.0f - expf (-2.3f / (radius + 1.f))));
+
+ for (; row < height; row++)
+ _blurrow (pixels,
+ width,
+ height,
+ channels,
+ row,
+ alpha,
+ aprec,
+ zprec);
+
+ for(; col < width; col++)
+ _blurcol (pixels,
+ width,
+ height,
+ channels,
+ col,
+ alpha,
+ aprec,
+ zprec);
+
+ return;
+}
+
+void
+_surface_blur (cairo_surface_t* surface,
+ guint radius)
+{
+ guchar* pixels;
+ guint width;
+ guint height;
+ cairo_format_t format;
+
+ // before we mess with the surface execute any pending drawing
+ cairo_surface_flush (surface);
+
+ pixels = cairo_image_surface_get_data (surface);
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+ format = cairo_image_surface_get_format (surface);
+
+ switch (format)
+ {
+ case CAIRO_FORMAT_ARGB32:
+ _expblur (pixels, width, height, 4, radius, 16, 7);
+ break;
+
+ case CAIRO_FORMAT_RGB24:
+ _expblur (pixels, width, height, 3, radius, 16, 7);
+ break;
+
+ case CAIRO_FORMAT_A8:
+ _expblur (pixels, width, height, 1, radius, 16, 7);
+ break;
+
+ default :
+ // do nothing
+ break;
+ }
+
+ // inform cairo we altered the surfaces contents
+ cairo_surface_mark_dirty (surface);
+}
+
+static void
+draw (GtkWidget* button, cairo_t *cr)
+{
+ g_return_if_fail(IS_TRANSPORT_WIDGET(button));
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(button);
+
+ cairo_surface_t* surf = NULL;
+ cairo_t* cr_surf = NULL;
+
+ cairo_translate (cr, button->allocation.x, button->allocation.y);
- return TRUE;
+ //g_debug("button x allocation = %i", button->allocation.x);
+ //g_debug("button y allocation = %i", button->allocation.y);
+
+ GtkStyle *style;
+
+ CairoColorRGB bg_normal, fg_normal;
+ CairoColorRGB color_inner[2], color_middle[2], color_outer[2], color_button[3], color_inner_compressed[2];
+
+ style = gtk_widget_get_style (button);
+
+ bg_normal.r = style->bg[0].red/65535.0;
+ bg_normal.g = style->bg[0].green/65535.0;
+ bg_normal.b = style->bg[0].blue/65535.0;
+
+ fg_normal.r = style->fg[0].red/65535.0;
+ fg_normal.g = style->fg[0].green/65535.0;
+ fg_normal.b = style->fg[0].blue/65535.0;
+
+ _color_shade (&bg_normal, INNER_START_SHADE, &color_inner[0]);
+ _color_shade (&bg_normal, INNER_END_SHADE, &color_inner[1]);
+ _color_shade (&bg_normal, MIDDLE_START_SHADE, &color_middle[0]);
+ _color_shade (&bg_normal, MIDDLE_END_SHADE, &color_middle[1]);
+ _color_shade (&bg_normal, OUTER_START_SHADE, &color_outer[0]);
+ _color_shade (&bg_normal, OUTER_END_SHADE, &color_outer[1]);
+ _color_shade (&fg_normal, BUTTON_START_SHADE, &color_button[0]);
+ _color_shade (&fg_normal, BUTTON_END_SHADE, &color_button[1]);
+ _color_shade (&bg_normal, BUTTON_SHADOW_SHADE, &color_button[2]);
+ _color_shade (&bg_normal, INNER_COMPRESSED_START_SHADE, &color_inner_compressed[0]);
+ _color_shade (&bg_normal, INNER_COMPRESSED_END_SHADE, &color_inner_compressed[1]);
+
+ double MIDDLE_END[] = {color_middle[0].r, color_middle[0].g, color_middle[0].b, 1.0f};
+ double MIDDLE_START[] = {color_middle[1].r, color_middle[1].g, color_middle[1].b, 1.0f};
+ double OUTER_END[] = {color_outer[0].r, color_outer[0].g, color_outer[0].b, 1.0f};
+ double OUTER_START[] = {color_outer[1].r, color_outer[1].g, color_outer[1].b, 1.0f};
+ double BUTTON_END[] = {color_button[0].r, color_button[0].g, color_button[0].b, 1.0f};
+ double BUTTON_START[] = {color_button[1].r, color_button[1].g, color_button[1].b, 1.0f};
+ double BUTTON_SHADOW[] = {color_button[2].r, color_button[2].g, color_button[2].b, 0.75f};
+ double INNER_COMPRESSED_END[] = {color_inner_compressed[1].r, color_inner_compressed[1].g, color_inner_compressed[1].b, 1.0f};
+ double INNER_COMPRESSED_START[] = {color_inner_compressed[0].r, color_inner_compressed[0].g, color_inner_compressed[0].b, 1.0f};
+
+ // prev/next-background
+ draw_gradient (cr,
+ X,
+ Y,
+ RECT_WIDTH,
+ OUTER_RADIUS,
+ OUTER_START,
+ OUTER_END);
+ draw_gradient (cr,
+ X,
+ Y + 1,
+ RECT_WIDTH - 2,
+ MIDDLE_RADIUS,
+ MIDDLE_START,
+ MIDDLE_END);
+ draw_gradient (cr,
+ X,
+ Y + 2,
+ RECT_WIDTH - 4,
+ MIDDLE_RADIUS,
+ MIDDLE_START,
+ MIDDLE_END);
+
+ if(priv->current_command == TRANSPORT_PREVIOUS){
+ draw_gradient (cr,
+ X,
+ Y + 2,
+ RECT_WIDTH/2,
+ INNER_RADIUS,
+ INNER_COMPRESSED_START,
+ INNER_COMPRESSED_END);
+ }
+ else if(priv->current_command == TRANSPORT_NEXT){
+ draw_gradient (cr,
+ RECT_WIDTH / 2 + X,
+ Y + 2,
+ (RECT_WIDTH - 7)/2,
+ INNER_RADIUS,
+ INNER_COMPRESSED_START,
+ INNER_COMPRESSED_END);
+ }
+
+ // play/pause-background
+ draw_circle (cr,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f,
+ Y - ((CIRCLE_RADIUS - OUTER_RADIUS)),
+ CIRCLE_RADIUS,
+ OUTER_START,
+ OUTER_END);
+ draw_circle (cr,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 0.5f,
+ Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 0.5f,
+ CIRCLE_RADIUS - 0.75f,
+ MIDDLE_START,
+ MIDDLE_END);
+
+ if(priv->current_command == TRANSPORT_PLAY_PAUSE){
+ draw_circle (cr,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.5f,
+ Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.5f,
+ CIRCLE_RADIUS - 1.5f,
+ INNER_COMPRESSED_START,
+ INNER_COMPRESSED_END);
+ }
+ else{
+ draw_circle (cr,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.5f,
+ Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.5f,
+ CIRCLE_RADIUS - 1.5f,
+ MIDDLE_START,
+ MIDDLE_END);
+ }
+ // draw previous-button drop-shadow
+ _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT);
+ _mask_prev (cr_surf,
+ (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
+ TRI_WIDTH,
+ TRI_HEIGHT,
+ TRI_OFFSET);
+ _fill (cr_surf,
+ (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
+ (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (double) TRI_HEIGHT,
+ BUTTON_SHADOW,
+ BUTTON_SHADOW,
+ FALSE);
+ _surface_blur (surf, 1);
+ _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y + 1.0f);
+
+ // draw previous-button
+ _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT);
+ _mask_prev (cr_surf,
+ (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
+ TRI_WIDTH,
+ TRI_HEIGHT,
+ TRI_OFFSET);
+ _fill (cr_surf,
+ (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
+ (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (double) TRI_HEIGHT,
+ BUTTON_START,
+ BUTTON_END,
+ FALSE);
+ _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y);
+
+ // draw next-button drop-shadow
+ _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT);
+ _mask_next (cr_surf,
+ (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f,
+ TRI_WIDTH,
+ TRI_HEIGHT,
+ TRI_OFFSET);
+ _fill (cr_surf,
+ (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f,
+ (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (double) TRI_HEIGHT,
+ BUTTON_SHADOW,
+ BUTTON_SHADOW,
+ FALSE);
+ _surface_blur (surf, 1);
+ _finalize (cr, &cr_surf, &surf, NEXT_X, NEXT_Y + 1.0f);
+
+ // draw next-button
+ _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT);
+ _mask_next (cr_surf,
+ (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f,
+ TRI_WIDTH,
+ TRI_HEIGHT,
+ TRI_OFFSET);
+ _fill (cr_surf,
+ (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f,
+ (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (double) TRI_HEIGHT,
+ BUTTON_START,
+ BUTTON_END,
+ FALSE);
+ _finalize (cr, &cr_surf, &surf, NEXT_X, NEXT_Y);
+
+ // draw pause-button drop-shadow
+ if(priv->current_state == PLAY){
+ _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT);
+ _mask_pause (cr_surf,
+ (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
+ (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f,
+ BAR_WIDTH,
+ BAR_HEIGHT - 2.0f * BAR_WIDTH,
+ BAR_OFFSET);
+ _fill (cr_surf,
+ (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
+ (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f,
+ (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
+ (double) BAR_HEIGHT,
+ BUTTON_SHADOW,
+ BUTTON_SHADOW,
+ TRUE);
+ _surface_blur (surf, 1);
+ _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f);
+
+ // draw pause-button
+ _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT);
+ _mask_pause (cr_surf,
+ (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
+ (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f,
+ BAR_WIDTH,
+ BAR_HEIGHT - 2.0f * BAR_WIDTH,
+ BAR_OFFSET);
+ _fill (cr_surf,
+ (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
+ (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f,
+ (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f,
+ (double) BAR_HEIGHT,
+ BUTTON_START,
+ BUTTON_END,
+ TRUE);
+ _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y);
+ }
+ else if(priv->current_state == PAUSE){
+ _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT);
+ _mask_play (cr_surf,
+ PLAY_PADDING,
+ PLAY_PADDING,
+ PLAY_WIDTH - (2*PLAY_PADDING),
+ PLAY_HEIGHT - (2*PLAY_PADDING));
+ _fill (cr_surf,
+ PLAY_PADDING,
+ PLAY_PADDING,
+ PLAY_WIDTH - (2*PLAY_PADDING),
+ PLAY_HEIGHT - (2*PLAY_PADDING),
+ BUTTON_SHADOW,
+ BUTTON_SHADOW,
+ FALSE);
+ _surface_blur (surf, 1);
+ _finalize (cr, &cr_surf, &surf, PAUSE_X-0.75f, PAUSE_Y + 1.0f);
+ // draw play-button
+ _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT);
+ cairo_set_line_width (cr, 10.5);
+ cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
+ _mask_play (cr_surf,
+ PLAY_PADDING,
+ PLAY_PADDING,
+ PLAY_WIDTH - (2*PLAY_PADDING),
+ PLAY_HEIGHT - (2*PLAY_PADDING));
+ _fill (cr_surf,
+ PLAY_PADDING,
+ PLAY_PADDING,
+ PLAY_WIDTH - (2*PLAY_PADDING),
+ PLAY_HEIGHT - (2*PLAY_PADDING),
+ BUTTON_START,
+ BUTTON_END,
+ FALSE);
+ _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y);
+ }
+}
+
+static void
+transport_widget_set_twin_item(TransportWidget* self,
+ DbusmenuMenuitem* twin_item)
+{
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
+ priv->twin_item = twin_item;
+ g_signal_connect(G_OBJECT(priv->twin_item), "property-changed",
+ G_CALLBACK(transport_widget_property_update), self);
}
/**
@@ -217,29 +1282,30 @@ static void
transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata)
{
- g_debug("transport_widget_update_state - with property %s", property);
+ //g_debug("transport_widget_update_state - with property %s", property);
TransportWidget* bar = (TransportWidget*)userdata;
g_return_if_fail(IS_TRANSPORT_WIDGET(bar));
if(g_ascii_strcasecmp(DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, property) == 0)
{
- TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
int update_value = g_value_get_int(value);
- g_debug("transport_widget_update_state - with value %i", update_value);
- play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value);
-
+ //g_debug("transport_widget_update_state - with value %i", update_value);
+ transport_widget_toggle_play_pause(bar,
+ (TransportWidgetState)update_value);
}
}
- /**
- * transport_new:
- * @returns: a new #TransportWidget.
- **/
+
+/**
+* transport_widget_new:
+* @returns: a new #TransportWidget.
+**/
GtkWidget*
-transport_widget_new(DbusmenuMenuitem *item)
-{
- GtkWidget* widget = g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
- transport_widget_set_twin_item((TransportWidget*)widget, item);
+transport_widget_new ( DbusmenuMenuitem *item )
+{
+ GtkWidget* widget = g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
+ gtk_widget_set_app_paintable (widget, TRUE);
+ transport_widget_set_twin_item((TransportWidget*)widget, item);
return widget;
}
diff --git a/src/transport-widget.h b/src/transport-widget.h
index c69836a..337ccdf 100644
--- a/src/transport-widget.h
+++ b/src/transport-widget.h
@@ -19,6 +19,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef __TRANSPORT_WIDGET_H__
#define __TRANSPORT_WIDGET_H__
+#include <gtk/gtk.h>
#include <gtk/gtkmenuitem.h>
#include <libdbusmenu-gtk/menuitem.h>
@@ -34,6 +35,18 @@ G_BEGIN_DECLS
typedef struct _TransportWidget TransportWidget;
typedef struct _TransportWidgetClass TransportWidgetClass;
+typedef enum {
+ TRANSPORT_PREVIOUS,
+ TRANSPORT_PLAY_PAUSE,
+ TRANSPORT_NEXT,
+ TRANSPORT_NADA
+}TransportWidgetEvent;
+
+typedef enum {
+ PLAY,
+ PAUSE
+}TransportWidgetState;
+
struct _TransportWidgetClass {
GtkMenuItemClass parent_class;
};
@@ -43,7 +56,7 @@ struct _TransportWidget {
};
GType transport_widget_get_type (void);
-GtkWidget* transport_widget_new(DbusmenuMenuitem *twin_item);
+GtkWidget* transport_widget_new ( DbusmenuMenuitem *item );
G_END_DECLS
diff --git a/src/volume-widget.c b/src/volume-widget.c
index 1cfdcc4..6964741 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -76,7 +76,7 @@ volume_widget_class_init (VolumeWidgetClass *klass)
static void
volume_widget_init (VolumeWidget *self)
{
- g_debug("VolumeWidget::volume_widget_init");
+ //g_debug("VolumeWidget::volume_widget_init");
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self);
priv->ido_volume_slider = ido_scale_menu_item_new_with_range ("VOLUME", IDO_RANGE_STYLE_DEFAULT, 0, 0, 100, 1);
@@ -128,13 +128,13 @@ volume_widget_property_update(DbusmenuMenuitem* item, gchar* property,
g_return_if_fail (IS_VOLUME_WIDGET (userdata));
VolumeWidget* mitem = VOLUME_WIDGET(userdata);
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
- g_debug("scrub-widget::property_update for prop %s", property);
+ //g_debug("scrub-widget::property_update for prop %s", property);
if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_LEVEL, property) == 0){
if(priv->grabbed == FALSE){
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
gdouble update = g_value_get_double (value);
- g_debug("volume-widget - update level with value %f", update);
+ //g_debug("volume-widget - update level with value %f", update);
gtk_range_set_value(range, update);
determine_state_from_volume(update);
}
@@ -152,7 +152,7 @@ volume_widget_set_twin_item(VolumeWidget* self,
G_CALLBACK(volume_widget_property_update), self);
gdouble initial_level = g_value_get_double (dbusmenu_menuitem_property_get_value(twin_item,
DBUSMENU_VOLUME_MENUITEM_LEVEL));
- g_debug("volume_widget_set_twin_item initial level = %f", initial_level);
+ //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;
gtk_range_set_value(range, initial_level);
@@ -214,7 +214,7 @@ volume_widget_parent_changed (GtkWidget *widget,
gpointer user_data)
{
gtk_widget_set_size_request (widget, 200, -1);
- g_debug("volume_widget_parent_changed");
+ //g_debug("volume_widget_parent_changed");
}
static void