diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2010-11-18 11:11:14 -0500 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2010-11-18 11:11:14 -0500 |
commit | 2133a62fd09fc431c146c74b4ca13e89d610c1c9 (patch) | |
tree | c4d27e2357498eba9fde88e64e53e2afe926d981 | |
parent | fb9140db72f565fa6180a55da02302844e21c05c (diff) | |
parent | 908222c0681fba3c6e1265d0f85a0b667927c169 (diff) | |
download | ayatana-indicator-sound-2133a62fd09fc431c146c74b4ca13e89d610c1c9.tar.gz ayatana-indicator-sound-2133a62fd09fc431c146c74b4ca13e89d610c1c9.tar.bz2 ayatana-indicator-sound-2133a62fd09fc431c146c74b4ca13e89d610c1c9.zip |
releasing version 0.5.1-0ubuntu1
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | debian/changelog | 19 | ||||
-rw-r--r-- | debian/control | 4 | ||||
-rw-r--r-- | src/common-defs.h | 1 | ||||
-rw-r--r-- | src/familiar-players-db.c | 81 | ||||
-rw-r--r-- | src/familiar-players-db.vala | 24 | ||||
-rw-r--r-- | src/fetch-file.c | 16 | ||||
-rw-r--r-- | src/metadata-widget.c | 342 | ||||
-rw-r--r-- | src/music-player-bridge.c | 155 | ||||
-rw-r--r-- | src/music-player-bridge.h | 7 | ||||
-rw-r--r-- | src/music-player-bridge.vala | 60 | ||||
-rw-r--r-- | src/player-controller.c | 166 | ||||
-rw-r--r-- | src/player-controller.vala | 34 | ||||
-rw-r--r-- | src/player-item.c | 2 | ||||
-rw-r--r-- | src/player-item.vala | 2 | ||||
-rw-r--r-- | src/pulse-manager.c | 4 | ||||
-rw-r--r-- | src/title-menu-item.c | 5 | ||||
-rw-r--r-- | src/title-menu-item.vala | 8 | ||||
-rw-r--r-- | src/title-widget.c | 46 | ||||
-rw-r--r-- | src/title-widget.h | 3 | ||||
-rw-r--r-- | src/transport-widget.c | 18 | ||||
-rw-r--r-- | src/transport-widget.h | 9 | ||||
-rw-r--r-- | vapi/common-defs.vapi | 1 |
24 files changed, 578 insertions, 453 deletions
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for indicator-sound 0.5.0.1. +# Generated by GNU Autoconf 2.67 for indicator-sound 0.5.1. # # Report bugs to <conor.curran@canonical.com>. # @@ -761,8 +761,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='indicator-sound' PACKAGE_TARNAME='indicator-sound' -PACKAGE_VERSION='0.5.0.1' -PACKAGE_STRING='indicator-sound 0.5.0.1' +PACKAGE_VERSION='0.5.1' +PACKAGE_STRING='indicator-sound 0.5.1' PACKAGE_BUGREPORT='conor.curran@canonical.com' PACKAGE_URL='' @@ -1560,7 +1560,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures indicator-sound 0.5.0.1 to adapt to many kinds of systems. +\`configure' configures indicator-sound 0.5.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1630,7 +1630,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of indicator-sound 0.5.0.1:";; + short | recursive ) echo "Configuration of indicator-sound 0.5.1:";; esac cat <<\_ACEOF @@ -1761,7 +1761,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -indicator-sound configure 0.5.0.1 +indicator-sound configure 0.5.1 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2130,7 +2130,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by indicator-sound $as_me 0.5.0.1, which was +It was created by indicator-sound $as_me 0.5.1, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2950,7 +2950,7 @@ fi # Define the identity of the package. PACKAGE=indicator-sound - VERSION=0.5.0.1 + VERSION=0.5.1 cat >>confdefs.h <<_ACEOF @@ -14081,7 +14081,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by indicator-sound $as_me 0.5.0.1, which was +This file was extended by indicator-sound $as_me 0.5.1, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14147,7 +14147,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -indicator-sound config.status 0.5.0.1 +indicator-sound config.status 0.5.1 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 2908467..f10eedc 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.5.0.1, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.5.1, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.5.0.1) +AM_INIT_AUTOMAKE(indicator-sound, 0.5.1) AM_MAINTAINER_MODE diff --git a/debian/changelog b/debian/changelog index 892de98..668eb6b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,22 @@ +indicator-sound (0.5.1-0ubuntu1) natty; urgency=low + + * New upstream release. + - Includes a lot of Design updates collected at UDS. + * album art border, now rectangular with a simple top and bottom 1 pixel + border. top dark and bottom light. + * Empty album art image now has darker background rather than same + colour as menu background + * Application icon now uses application image as opposed to generic + image used in maverick + * Banshee is now the default player. + * spacing between metadata and transport widget has been resolved plus + the spacing between the transport and the separator below it. + * debian/control + - Bump standards version to 3.9.1 + - Changed build depends to valac-0.10, until it is ported to valac-0.12 + + -- Ken VanDine <ken.vandine@canonical.com> Fri, 12 Nov 2010 10:14:49 -0500 + indicator-sound (0.5.0.1-0ubuntu1) maverick-proposed; urgency=low * New upstream release. diff --git a/debian/control b/debian/control index 0c4ffbb..f795e4a 100644 --- a/debian/control +++ b/debian/control @@ -18,8 +18,8 @@ Build-Depends: debhelper (>= 7), libgconf2-dev, libgee-dev, libindicate-dev (>= 0.4.1), - valac -Standards-Version: 3.8.4 + valac-0.10 +Standards-Version: 3.9.1 Homepage: https://launchpad.net/indicator-sound Package: indicator-sound diff --git a/src/common-defs.h b/src/common-defs.h index e268aaa..27dfd32 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -41,6 +41,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-type" #define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name" +#define DBUSMENU_TITLE_MENUITEM_ICON "x-canonical-sound-menu-player-title-icon" #define DBUSMENU_TITLE_MENUITEM_RUNNING "x-canonical-sound-menu-player-title-running" #define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-type" diff --git a/src/familiar-players-db.c b/src/familiar-players-db.c index 15cf064..4adf129 100644 --- a/src/familiar-players-db.c +++ b/src/familiar-players-db.c @@ -70,7 +70,7 @@ enum { }; #define FAMILIAR_PLAYERS_DB_GROUP_NAME "Seen Database" #define FAMILIAR_PLAYERS_DB_KEY_NAME "DesktopFiles" -#define FAMILIAR_PLAYERS_DB_DEFAULT_APP_DESKTOP "/usr/share/applications/rhythmbox.desktop" +#define FAMILIAR_PLAYERS_DB_DEFAULT_APP_DESKTOP "/usr/share/applications/banshee-1.desktop" FamiliarPlayersDB* familiar_players_db_new (void); FamiliarPlayersDB* familiar_players_db_construct (GType object_type); static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self); @@ -82,6 +82,7 @@ void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop); gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const char* desktop); static gboolean _familiar_players_db_write_db_gsource_func (gpointer self); GeeSet* familiar_players_db_records (FamiliarPlayersDB* self); +char* familiar_players_db_fetch_icon_name (const char* desktop_path); static void familiar_players_db_finalize (GObject* obj); static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func); static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func); @@ -481,6 +482,84 @@ GeeSet* familiar_players_db_records (FamiliarPlayersDB* self) { } +char* familiar_players_db_fetch_icon_name (const char* desktop_path) { + char* result = NULL; + GKeyFile* desktop_keyfile; + GError * _inner_error_ = NULL; + g_return_val_if_fail (desktop_path != NULL, NULL); + desktop_keyfile = g_key_file_new (); + { + g_key_file_load_from_file (desktop_keyfile, desktop_path, G_KEY_FILE_NONE, &_inner_error_); + if (_inner_error_ != NULL) { + if (_inner_error_->domain == G_FILE_ERROR) { + goto __catch11_g_file_error; + } + goto __finally11; + } + } + goto __finally11; + __catch11_g_file_error: + { + GError * _error_; + _error_ = _inner_error_; + _inner_error_ = NULL; + { + g_warning ("familiar-players-db.vala:170: Error loading keyfile"); + result = NULL; + _g_error_free0 (_error_); + _g_key_file_free0 (desktop_keyfile); + return result; + } + } + __finally11: + if (_inner_error_ != NULL) { + _g_key_file_free0 (desktop_keyfile); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return NULL; + } + { + char* _tmp0_; + _tmp0_ = g_key_file_get_string (desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, &_inner_error_); + if (_inner_error_ != NULL) { + if (_inner_error_->domain == G_KEY_FILE_ERROR) { + goto __catch12_g_key_file_error; + } + _g_key_file_free0 (desktop_keyfile); + g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return NULL; + } + result = _tmp0_; + _g_key_file_free0 (desktop_keyfile); + return result; + } + goto __finally12; + __catch12_g_key_file_error: + { + GError * _error_; + _error_ = _inner_error_; + _inner_error_ = NULL; + { + g_warning ("familiar-players-db.vala:178: Error trying to fetch the icon name from" \ +" the keyfile"); + result = NULL; + _g_error_free0 (_error_); + _g_key_file_free0 (desktop_keyfile); + return result; + } + } + __finally12: + { + _g_key_file_free0 (desktop_keyfile); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return NULL; + } + _g_key_file_free0 (desktop_keyfile); +} + + static void familiar_players_db_class_init (FamiliarPlayersDBClass * klass) { familiar_players_db_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (FamiliarPlayersDBPrivate)); diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala index 28ac286..af7d07f 100644 --- a/src/familiar-players-db.vala +++ b/src/familiar-players-db.vala @@ -29,7 +29,7 @@ public class FamiliarPlayersDB : GLib.Object { private const string GROUP_NAME = "Seen Database"; private const string KEY_NAME = "DesktopFiles"; - private const string DEFAULT_APP_DESKTOP = "/usr/share/applications/rhythmbox.desktop"; + private const string DEFAULT_APP_DESKTOP = "/usr/share/applications/banshee-1.desktop"; private HashMap<string, bool> players_DB; private string file_name; private string dir_name; @@ -159,5 +159,25 @@ public class FamiliarPlayersDB : GLib.Object { return this.players_DB.keys; } - + + public static string? fetch_icon_name(string desktop_path) + { + KeyFile desktop_keyfile = new KeyFile (); + try{ + desktop_keyfile.load_from_file (desktop_path, KeyFileFlags.NONE); + } + catch(GLib.FileError error){ + warning("Error loading keyfile"); + return null; + } + try{ + return desktop_keyfile.get_string (KeyFileDesktop.GROUP, + KeyFileDesktop.KEY_ICON); + } + catch(GLib.KeyFileError error){ + warning("Error trying to fetch the icon name from the keyfile"); + return null; + } + } + }
\ No newline at end of file diff --git a/src/fetch-file.c b/src/fetch-file.c index c5a22ac..2bf4bbf 100644 --- a/src/fetch-file.c +++ b/src/fetch-file.c @@ -187,14 +187,14 @@ static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) { { data->_tmp0_ = g_file_read (data->self->priv->file, NULL, &data->_inner_error_); if (data->_inner_error_ != NULL) { - goto __catch11_g_error; + goto __catch13_g_error; } data->self->priv->stream = (data->_tmp2_ = g_data_input_stream_new ((GInputStream*) (data->_tmp1_ = data->_tmp0_)), _g_object_unref0 (data->self->priv->stream), data->_tmp2_); _g_object_unref0 (data->_tmp1_); g_data_input_stream_set_byte_order (data->self->priv->stream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN); } - goto __finally11; - __catch11_g_error: + goto __finally13; + __catch13_g_error: { data->e = data->_inner_error_; data->_inner_error_ = NULL; @@ -203,7 +203,7 @@ static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) { _g_error_free0 (data->e); } } - __finally11: + __finally13: if (data->_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code); g_clear_error (&data->_inner_error_); @@ -283,7 +283,7 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD _state_1: data->_tmp2_ = g_input_stream_read_finish ((GInputStream*) data->self->priv->stream, data->_res_, &data->_inner_error_); if (data->_inner_error_ != NULL) { - goto __catch12_g_error; + goto __catch14_g_error; } data->bufsize = data->_tmp2_; if (data->bufsize < 1) { @@ -298,8 +298,8 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD g_byte_array_append (data->self->priv->data, data->buffer, data->buffer_length1); } } - goto __finally12; - __catch12_g_error: + goto __finally14; + __catch14_g_error: { data->e = data->_inner_error_; data->_inner_error_ = NULL; @@ -308,7 +308,7 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD _g_error_free0 (data->e); } } - __finally12: + __finally14: if (data->_inner_error_ != NULL) { data->buffer = (g_free (data->buffer), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code); diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 0e8aa3b..ac8355c 100644 --- a/src/metadata-widget.c +++ b/src/metadata-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 @@ -26,7 +27,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "common-defs.h" #include <gtk/gtk.h> #include <glib.h> - +#include "transport-widget.h" typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; @@ -62,13 +63,14 @@ static void metadata_widget_property_update (DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata); -static void metadata_widget_style_labels(MetadataWidget* self, - GtkLabel* label); -static void image_set_from_pixbuf (GtkWidget *widget, - MetadataWidget* metadata, - GdkPixbuf *source); -static void draw_album_art_placeholder(GtkWidget *metadata); - +static void metadata_widget_style_labels ( MetadataWidget* self, + GtkLabel* label); +static void draw_album_art_placeholder ( GtkWidget *metadata); +static void draw_album_border ( GtkWidget *metadata, gboolean selected); +static void metadata_widget_selection_received_event_callback( GtkWidget *widget, + GtkSelectionData *data, + guint time, + gpointer user_data); G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); @@ -99,19 +101,21 @@ metadata_widget_init (MetadataWidget *self) // image priv->album_art = gtk_image_new(); - priv->image_path = g_string_new(dbusmenu_menuitem_property_get(priv->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_signal_connect(priv->album_art, "expose-event", G_CALLBACK(metadata_image_expose), GTK_WIDGET(self)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0); - + gtk_box_pack_start (GTK_BOX (priv->hbox), + priv->album_art, + FALSE, + FALSE, + 1); priv->theme_change_occured = FALSE; - GtkWidget* vbox = gtk_vbox_new(FALSE, 0); // artist @@ -130,7 +134,7 @@ metadata_widget_init (MetadataWidget *self) 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_misc_set_padding (GTK_MISC(piece), (gfloat)10, (gfloat)-5); 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)); @@ -153,12 +157,13 @@ metadata_widget_init (MetadataWidget *self) gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0); - gtk_widget_show_all (priv->hbox); - - g_signal_connect(self, "style-set", G_CALLBACK(metadata_widget_set_style), GTK_WIDGET(self)); - - gtk_widget_set_size_request(GTK_WIDGET(self), 200, 65); - gtk_container_add (GTK_CONTAINER (self), hbox); + g_signal_connect(self, "style-set", + G_CALLBACK(metadata_widget_set_style), GTK_WIDGET(self)); + g_signal_connect (self, "selection-received", + G_CALLBACK(metadata_widget_selection_received_event_callback), + GTK_WIDGET(self)); + gtk_widget_set_size_request(GTK_WIDGET(self), 200, 75); + gtk_container_add (GTK_CONTAINER (self), hbox); } static void @@ -183,7 +188,8 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user { g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); MetadataWidget* widget = METADATA_WIDGET(user_data); - MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); + draw_album_border(metadata, FALSE); if(priv->image_path->len > 0){ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || priv->theme_change_occured == TRUE){ @@ -195,12 +201,12 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user if(GDK_IS_PIXBUF(pixbuf) == FALSE){ //g_debug("problem loading the downloaded image just use the placeholder instead"); draw_album_art_placeholder(metadata); - return TRUE; + return TRUE; } pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR); - image_set_from_pixbuf (metadata, widget, pixbuf); + gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf); g_string_erase(priv->old_image_path, 0, -1); - g_string_overwrite(priv->old_image_path, 0, priv->image_path->str); + g_string_overwrite(priv->old_image_path, 0, priv->image_path->str); g_object_unref(pixbuf); } @@ -211,8 +217,8 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user } static void -draw_album_art_placeholder(GtkWidget *metadata) -{ +draw_album_border(GtkWidget *metadata, gboolean selected) +{ cairo_t *cr; cr = gdk_cairo_create (metadata->window); GtkStyle *style; @@ -220,33 +226,98 @@ draw_album_art_placeholder(GtkWidget *metadata) GtkAllocation alloc; gtk_widget_get_allocation (metadata, &alloc); - - cairo_rectangle (cr, + gint offset = 1; + + alloc.width = alloc.width + (offset * 2); + alloc.height = alloc.height + (offset * 2) - 7; + alloc.x = alloc.x - offset; + alloc.y = alloc.y - offset + 3; + + CairoColorRGB bg_normal, fg_normal; + + 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; + + gint state = selected ? 5 : 0; + + fg_normal.r = style->fg[state].red/65535.0; + fg_normal.g = style->fg[state].green/65535.0; + fg_normal.b = style->fg[state].blue/65535.0; + + CairoColorRGB dark_top_color; + CairoColorRGB light_bottom_color; + CairoColorRGB background_color; + + _color_shade ( &bg_normal, 0.93, &background_color ); + _color_shade ( &bg_normal, 0.23, &dark_top_color ); + _color_shade ( &fg_normal, 0.55, &light_bottom_color ); + + cairo_rectangle (cr, alloc.x, alloc.y, alloc.width, alloc.height); - cairo_clip(cr); - cairo_move_to (cr, alloc.x , alloc.y); - cairo_line_to(cr, alloc.x + alloc.width, - alloc.y); - cairo_line_to(cr, alloc.x + alloc.width, - alloc.y + alloc.height); - cairo_line_to(cr, alloc.x, alloc.y + alloc.height); - cairo_line_to(cr, alloc.x, alloc.y); + cairo_set_line_width (cr, 1.0); + + cairo_clip ( cr ); + + cairo_move_to (cr, alloc.x, alloc.y ); + cairo_line_to (cr, alloc.x + alloc.width, + alloc.y ); + cairo_line_to ( cr, alloc.x + alloc.width, + alloc.y + alloc.height ); + cairo_line_to ( cr, alloc.x, alloc.y + alloc.height ); + cairo_line_to ( cr, alloc.x, alloc.y); + cairo_close_path (cr); + + cairo_set_source_rgba ( cr, + background_color.r, + background_color.g, + background_color.b, + 1.0 ); + + cairo_fill ( cr ); + + cairo_move_to (cr, alloc.x, alloc.y ); + cairo_line_to (cr, alloc.x + alloc.width, + alloc.y ); + + cairo_close_path (cr); + cairo_set_source_rgba ( cr, + dark_top_color.r, + dark_top_color.g, + dark_top_color.b, + 1.0 ); + + cairo_stroke ( cr ); + + cairo_move_to ( cr, alloc.x + alloc.width, + alloc.y + alloc.height ); + cairo_line_to ( cr, alloc.x, alloc.y + alloc.height ); cairo_close_path (cr); + cairo_set_source_rgba ( cr, + light_bottom_color.r, + light_bottom_color.g, + light_bottom_color.b, + 1.0); + + cairo_stroke ( cr ); + cairo_destroy (cr); +} - cairo_set_source_rgba (cr, - style->fg[0].red/65535.0, - style->fg[0].green/65535.0, - style->fg[0].blue/65535.0, - 0.6); - cairo_set_line_width (cr, 2.0); - - cairo_stroke (cr); +static void +draw_album_art_placeholder(GtkWidget *metadata) +{ + cairo_t *cr; + cr = gdk_cairo_create (metadata->window); + GtkStyle *style; + style = gtk_widget_get_style (metadata); + + GtkAllocation alloc; + gtk_widget_get_allocation (metadata, &alloc); - // Draw the eight note - PangoLayout *layout; + PangoLayout *layout; PangoFontDescription *desc; layout = pango_cairo_create_layout(cr); PangoContext* pcontext = pango_cairo_create_context(cr); @@ -262,14 +333,23 @@ draw_album_art_placeholder(GtkWidget *metadata) pango_layout_set_font_description(layout, desc); pango_font_description_free(desc); + CairoColorRGB fg_normal, light_bottom_color; + + 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 ( &fg_normal, 0.78, &light_bottom_color ); + + cairo_set_source_rgba (cr, - style->fg[0].red/65535.0, - style->fg[0].green/65535.0, - style->fg[0].blue/65535.0, - 0.8); + light_bottom_color.r, + light_bottom_color.g, + light_bottom_color.b, + 1.0); pango_cairo_update_layout(cr, layout); - cairo_move_to (cr, alloc.x + alloc.width/6, alloc.y); + cairo_move_to (cr, alloc.x + alloc.width/6, alloc.y + alloc.height/8); pango_cairo_show_layout(cr, layout); g_object_unref(layout); @@ -279,6 +359,20 @@ draw_album_art_placeholder(GtkWidget *metadata) } +static void +metadata_widget_selection_received_event_callback ( GtkWidget *widget, + GtkSelectionData *data, + guint time, + gpointer user_data ) + +{ + //g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + //MetadataWidget* widget = METADATA_WIDGET(user_data); + //MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); + g_debug("metadata_widget_selection_request_event_callback"); + draw_album_border(widget, TRUE); +} + /* Suppress/consume keyevents */ static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, @@ -295,7 +389,6 @@ metadata_widget_button_press_event (GtkWidget *menuitem, 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); @@ -343,150 +436,6 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, } } - -static cairo_surface_t * -surface_from_pixbuf (GdkPixbuf *pixbuf) -{ - cairo_surface_t *surface; - cairo_t *cr; - - surface = cairo_image_surface_create (gdk_pixbuf_get_has_alpha (pixbuf) ? - CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf)); - cr = cairo_create (surface); - gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); - cairo_paint (cr); - cairo_destroy (cr); - - return surface; -} - -static void -rounded_rectangle (cairo_t *cr, - gdouble aspect, - gdouble x, - gdouble y, - gdouble corner_radius, - gdouble width, - gdouble height) -{ - gdouble radius; - gdouble degrees; - - radius = corner_radius / aspect; - degrees = G_PI / 180.0; - cairo_new_sub_path (cr); - cairo_arc (cr, - x + width - radius, - y + radius, - radius, - -90 * degrees, - 0 * degrees); - cairo_arc (cr, - x + width - radius, - y + height - radius, - radius, - 0 * degrees, - 90 * degrees); - cairo_arc (cr, - x + radius, - y + height - radius, - radius, - 90 * degrees, - 180 * degrees); - cairo_arc (cr, - x + radius, - y + radius, - radius, - 180 * degrees, - 270 * degrees); - - cairo_close_path (cr); -} - -static void -image_set_from_pixbuf (GtkWidget *widget, - MetadataWidget* metadata, - GdkPixbuf *source) -{ - cairo_t *cr; - cairo_t *cr_mask; - cairo_surface_t *surface; - GdkPixmap *pixmap; - GdkPixmap *bitmask; - int w; - int h; - int frame_width; - double radius; - GdkColor color; - double r; - double g; - double b; - - MetadataWidgetPrivate* priv = METADATA_WIDGET_GET_PRIVATE(metadata); - GtkImage* image = GTK_IMAGE(priv->album_art); - frame_width = 3; - - w = gdk_pixbuf_get_width (source) + frame_width * 2; - h = gdk_pixbuf_get_height (source) + frame_width * 2; - - radius = 10; - - pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), w, h, -1); - bitmask = gdk_pixmap_new (gtk_widget_get_window (widget), w, h, 1); - - if (gtk_widget_get_window (widget) == NULL) - return; - - cr = gdk_cairo_create (pixmap); - cr_mask = gdk_cairo_create (bitmask); - - /* setup mask */ - cairo_rectangle (cr_mask, 0, 0, w, h); - cairo_set_operator (cr_mask, CAIRO_OPERATOR_CLEAR); - cairo_fill (cr_mask); - - rounded_rectangle (cr_mask, 1.0, 0.5, 0.5, radius, w - 1, h - 1); - cairo_set_operator (cr_mask, CAIRO_OPERATOR_OVER); - cairo_set_source_rgb (cr_mask, 1, 1, 1); - cairo_fill (cr_mask); - - color = gtk_widget_get_style (GTK_WIDGET (image))->bg [GTK_STATE_NORMAL]; - r = (float)color.red / 65535.0; - g = (float)color.green / 65535.0; - b = (float)color.blue / 65535.0; - - /* set up image */ - cairo_rectangle (cr, 0, 0, w, h); - cairo_set_source_rgb (cr, r, g, b); - cairo_fill (cr); - - rounded_rectangle (cr, - 1.0, - frame_width + 0.5, - frame_width + 0.5, - radius, - w - frame_width * 2 - 1, - h - frame_width * 2 - 1); - cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.3); - cairo_fill_preserve (cr); - - surface = surface_from_pixbuf (source); - cairo_set_source_surface (cr, surface, frame_width, frame_width); - cairo_fill (cr); - - gtk_image_set_from_pixmap (image, pixmap, bitmask); - - cairo_surface_destroy (surface); - - g_object_unref (bitmask); - g_object_unref (pixmap); - - cairo_destroy (cr_mask); - cairo_destroy (cr); -} - static void metadata_widget_style_labels(MetadataWidget* self, GtkLabel* label) { @@ -542,7 +491,6 @@ metadata_widget_set_twin_item(MetadataWidget* self, } } - /** * transport_new: * @returns: a new #MetadataWidget. diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c index dddaa1a..7e0a5a8 100644 --- a/src/music-player-bridge.c +++ b/src/music-player-bridge.c @@ -117,14 +117,12 @@ void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateLis static void _music_player_bridge_on_server_removed_indicate_listener_server_removed (IndicateListener* _sender, IndicateListenerServer* object, const char* 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 (char* app_info_name); static char* music_player_bridge_determine_key (char* path); +char* familiar_players_db_fetch_icon_name (const char* desktop_path); 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, const char* mpris_name, gint offset, PlayerControllerstate initial_state); -PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); -void player_controller_set_app_info (PlayerController* self, GAppInfo* value); -GAppInfo* player_controller_get_app_info (PlayerController* self); +PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const char* mpris_name, const char* icon_name, gint offset, PlayerControllerstate initial_state); +PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const char* mpris_name, const char* icon_name, gint offset, PlayerControllerstate initial_state); #define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type); static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, IndicateListenerServer* server, char* path, void* data); @@ -189,39 +187,35 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye GDesktopAppInfo* info; GDesktopAppInfo* _tmp2_; GAppInfo* app_info; + char* mpris_key; char* _tmp3_; - char* _tmp4_; - PlayerController* _tmp5_; + PlayerController* _tmp4_; PlayerController* ctrl; - char* _tmp6_; if (!gee_iterator_next (_app_it)) { break; } app = (char*) gee_iterator_get (_app_it); if (app == NULL) { - g_warning ("music-player-bridge.vala:45: App string in keyfile is null therefore m" \ + g_warning ("music-player-bridge.vala:44: App string in keyfile is null therefore m" \ "oving on to next player"); _g_free0 (app); continue; } - g_debug ("music-player-bridge.vala:49: attempting to make an app info from %s", app); + g_debug ("music-player-bridge.vala:48: 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:54: Could not create a desktopappinfo instanc" \ -"e from app: %s", app); + g_warning ("music-player-bridge.vala:53: Could not create a desktopappinfo instanc" \ +"e from app,: %s , moving on to the next client", 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 = (_tmp5_ = player_controller_new (self->priv->root_menu, _tmp3_ = music_player_bridge_truncate_player_name (g_strdup (g_app_info_get_name (app_info))), _tmp4_ = music_player_bridge_determine_key (g_strdup (app)), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE), _g_free0 (_tmp4_), _g_free0 (_tmp3_), _tmp5_); - player_controller_set_app_info (ctrl, app_info); - if (player_controller_get_app_info (ctrl) == NULL) { - g_warning ("music-player-bridge.vala:66: for some reason the app info is null"); - } - gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp6_ = music_player_bridge_determine_key (g_strdup (app)), ctrl); - _g_free0 (_tmp6_); + mpris_key = music_player_bridge_determine_key (g_strdup (app)); + ctrl = (_tmp4_ = player_controller_new (self->priv->root_menu, app_info, mpris_key, _tmp3_ = familiar_players_db_fetch_icon_name (app), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE), _g_free0 (_tmp3_), _tmp4_); + gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, mpris_key, ctrl); _g_object_unref0 (ctrl); + _g_free0 (mpris_key); _g_object_unref0 (app_info); _g_object_unref0 (info); _g_free0 (app); @@ -247,7 +241,7 @@ static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) { g_return_if_fail (self != NULL); g_return_if_fail (type != NULL); - g_debug ("music-player-bridge.vala:83: MusicPlayerBridge -> on_server_added with" \ + g_debug ("music-player-bridge.vala:81: MusicPlayerBridge -> on_server_added with" \ " value %s", type); if (music_player_bridge_server_is_not_of_interest (self, type)) { return; @@ -260,59 +254,47 @@ void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListe } -static gboolean string_contains (const char* self, const char* needle) { - gboolean result = FALSE; - g_return_val_if_fail (self != NULL, FALSE); - g_return_val_if_fail (needle != NULL, FALSE); - result = strstr (self, needle) != NULL; - 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; + char* mpris_key; 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 (app_info == NULL) { + g_warning ("music-player-bridge.vala:96: Could not create app_info for path %s \n" \ +" Getting out of here ", path); + _g_object_unref0 (app_info); + _g_object_unref0 (bridge); + _g_free0 (path); + return; } - if (_tmp1_) { - char* _tmp2_; - PlayerController* _tmp3_; + mpris_key = music_player_bridge_determine_key (g_strdup (path)); + if (familiar_players_db_already_familiar (bridge->priv->playersDB, path) == FALSE) { + char* _tmp1_; + PlayerController* _tmp2_; PlayerController* ctrl; - char* _tmp4_; - g_debug ("music-player-bridge.vala:99: About to store desktop file path: %s", path); + g_debug ("music-player-bridge.vala:103: New client has registered that we have s" \ +"een before: %s", path); familiar_players_db_insert (bridge->priv->playersDB, path); - ctrl = (_tmp3_ = player_controller_new (bridge->priv->root_menu, name, _tmp2_ = music_player_bridge_determine_key (g_strdup (path)), music_player_bridge_calculate_menu_position (bridge), PLAYER_CONTROLLER_STATE_READY), _g_free0 (_tmp2_), _tmp3_); - g_object_set ((GObject*) ctrl, "app_info", app_info, NULL); - gee_abstract_map_set ((GeeAbstractMap*) bridge->priv->registered_clients, _tmp4_ = music_player_bridge_determine_key (g_strdup (path)), ctrl); - _g_free0 (_tmp4_); - g_debug ("music-player-bridge.vala:108: successfully created appinfo and instanc" \ + ctrl = (_tmp2_ = player_controller_new (bridge->priv->root_menu, app_info, mpris_key, _tmp1_ = familiar_players_db_fetch_icon_name (path), music_player_bridge_calculate_menu_position (bridge), PLAYER_CONTROLLER_STATE_READY), _g_free0 (_tmp1_), _tmp2_); + gee_abstract_map_set ((GeeAbstractMap*) bridge->priv->registered_clients, mpris_key, ctrl); + g_debug ("music-player-bridge.vala:112: successfully created appinfo and instanc" \ "e from path and set it on the respective instance"); _g_object_unref0 (ctrl); } else { - char* key; - PlayerController* _tmp5_; - PlayerController* _tmp6_; - key = music_player_bridge_determine_key (g_strdup (path)); - player_controller_update_state (_tmp5_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key), PLAYER_CONTROLLER_STATE_READY); - _g_object_unref0 (_tmp5_); - player_controller_activate (_tmp6_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key)); - _g_object_unref0 (_tmp6_); - g_debug ("music-player-bridge.vala:114: Ignoring desktop file path callback beca" \ -"use the db cache file has it already: %s", path); - _g_free0 (key); + PlayerController* _tmp3_; + PlayerController* _tmp4_; + player_controller_update_state (_tmp3_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, mpris_key), PLAYER_CONTROLLER_STATE_READY); + _g_object_unref0 (_tmp3_); + player_controller_activate (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, mpris_key)); + _g_object_unref0 (_tmp4_); + g_debug ("music-player-bridge.vala:117: Ignoring desktop file path callback beca" \ +"use the db cache file has it already: %s \n", path); } - _g_free0 (name); + _g_free0 (mpris_key); _g_object_unref0 (app_info); _g_object_unref0 (bridge); _g_free0 (path); @@ -322,7 +304,7 @@ static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) { g_return_if_fail (self != NULL); g_return_if_fail (type != NULL); - g_debug ("music-player-bridge.vala:120: MusicPlayerBridge -> on_server_removed w" \ + g_debug ("music-player-bridge.vala:123: MusicPlayerBridge -> on_server_removed w" \ "ith value %s", type); if (music_player_bridge_server_is_not_of_interest (self, type)) { return; @@ -334,18 +316,27 @@ void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateLis 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:124: attempt to remove %s", tmp[tmp_length1 - 1]); + g_debug ("music-player-bridge.vala:127: 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:127: Successively offlined client %s", tmp[tmp_length1 - 1]); + g_debug ("music-player-bridge.vala:130: Successively offlined client %s", tmp[tmp_length1 - 1]); } tmp = (_vala_array_free (tmp, tmp_length1, (GDestroyNotify) g_free), NULL); } } +static gboolean string_contains (const char* self, const char* needle) { + gboolean result = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (needle != NULL, FALSE); + result = strstr (self, needle) != NULL; + return result; +} + + 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); @@ -355,7 +346,7 @@ static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge return result; } if (string_contains (type, "music") == FALSE) { - g_debug ("music-player-bridge.vala:135: server is of no interest, it is not an " \ + g_debug ("music-player-bridge.vala:138: server is of no interest, it is not an " \ "music server"); result = TRUE; return result; @@ -382,7 +373,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:151: Could not create a desktopappinfo instan" \ + g_warning ("music-player-bridge.vala:154: Could not create a desktopappinfo instan" \ "ce from app: %s", path); result = NULL; _g_object_unref0 (info); @@ -395,42 +386,6 @@ 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:167: 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; @@ -464,7 +419,7 @@ static char* music_player_bridge_determine_key (char* path) { char* _tmp7_; _result_ = (_tmp7_ = g_strdup (temp[0]), _g_free0 (_result_), _tmp7_); } - g_debug ("music-player-bridge.vala:181: determine key result = %s", _result_); + g_debug ("music-player-bridge.vala:171: determine key result = %s", _result_); result = _result_; temp = (_vala_array_free (temp, temp_length1, (GDestroyNotify) g_free), NULL); _g_free0 (filename); diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h index 41ea682..2a3b9ac 100644 --- a/src/music-player-bridge.h +++ b/src/music-player-bridge.h @@ -337,8 +337,8 @@ GType mpris2_controller_get_type (void) G_GNUC_CONST; GType player_controller_widget_order_get_type (void) G_GNUC_CONST; GType player_controller_state_get_type (void) G_GNUC_CONST; #define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 -PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); -PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); +PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const char* mpris_name, const char* icon_name, gint offset, PlayerControllerstate initial_state); +PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const char* mpris_name, const char* icon_name, gint offset, PlayerControllerstate initial_state); void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); void player_controller_activate (PlayerController* self); void player_controller_instantiate (PlayerController* self); @@ -354,6 +354,8 @@ GAppInfo* player_controller_get_app_info (PlayerController* self); void player_controller_set_app_info (PlayerController* self, GAppInfo* value); gint player_controller_get_menu_offset (PlayerController* self); void player_controller_set_menu_offset (PlayerController* self, gint value); +const char* player_controller_get_icon_name (PlayerController* self); +void player_controller_set_icon_name (PlayerController* self, const char* value); MprisRoot* mpris_root_dbus_proxy_new (DBusGConnection* connection, const char* name, const char* path); GType mpris_root_get_type (void) G_GNUC_CONST; void mpris_root_Quit (MprisRoot* self, GAsyncReadyCallback _callback_, gpointer _user_data_); @@ -412,6 +414,7 @@ FamiliarPlayersDB* familiar_players_db_construct (GType object_type); void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop); gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const char* desktop); GeeSet* familiar_players_db_records (FamiliarPlayersDB* self); +char* familiar_players_db_fetch_icon_name (const char* desktop_path); GType fetch_file_get_type (void) G_GNUC_CONST; FetchFile* fetch_file_new (const char* uri, const char* prop); FetchFile* fetch_file_construct (GType object_type, const char* uri, const char* prop); diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 57f5636..f13c2f4 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -24,7 +24,6 @@ using GLib; public class MusicPlayerBridge : GLib.Object { - private Listener listener; private Dbusmenu.Menuitem root_menu; private HashMap<string, PlayerController> registered_clients; @@ -51,20 +50,19 @@ public class MusicPlayerBridge : GLib.Object DesktopAppInfo info = new DesktopAppInfo.from_filename(app); if(info == null){ - warning("Could not create a desktopappinfo instance from app: %s", app); + warning("Could not create a desktopappinfo instance from app,: %s , moving on to the next client", app); continue; } GLib.AppInfo app_info = info as GLib.AppInfo; + var mpris_key = determine_key(app); PlayerController ctrl = new PlayerController(this.root_menu, - truncate_player_name(app_info.get_name()), - determine_key(app), + app_info, + mpris_key, + playersDB.fetch_icon_name(app), calculate_menu_position(), PlayerController.state.OFFLINE); - ctrl.app_info = app_info; - if(ctrl.app_info == null) - warning("for some reason the app info is null"); - this.registered_clients.set(determine_key(app), ctrl); + this.registered_clients.set(mpris_key, ctrl); } } @@ -94,24 +92,29 @@ public class MusicPlayerBridge : GLib.Object { 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); + if ( app_info == null ){ + warning ( "Could not create app_info for path %s \n Getting out of here ", path); + return; + } + + var mpris_key = determine_key(path); + + if(bridge.playersDB.already_familiar(path) == false){ + debug("New client has registered that we have seen before: %s", path); bridge.playersDB.insert(path); - PlayerController ctrl = new PlayerController(bridge.root_menu, - name, - determine_key(path), - bridge.calculate_menu_position(), - PlayerController.state.READY); - ctrl.set("app_info", app_info); - bridge.registered_clients.set(determine_key(path), ctrl); + PlayerController ctrl = new PlayerController ( bridge.root_menu, + app_info, + mpris_key, + playersDB.fetch_icon_name(path), + bridge.calculate_menu_position(), + PlayerController.state.READY ); + bridge.registered_clients.set(mpris_key, 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); + bridge.registered_clients[mpris_key].update_state(PlayerController.state.READY); + bridge.registered_clients[mpris_key].activate(); + debug("Ignoring desktop file path callback because the db cache file has it already: %s \n", path); } } @@ -155,19 +158,6 @@ 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("/"); diff --git a/src/player-controller.c b/src/player-controller.c index 896d826..ee477e7 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -119,6 +119,7 @@ struct _PlayerControllerPrivate { char* _mpris_name; GAppInfo* _app_info; gint _menu_offset; + char* _icon_name; }; typedef enum { @@ -148,16 +149,20 @@ enum { PLAYER_CONTROLLER_NAME, PLAYER_CONTROLLER_MPRIS_NAME, PLAYER_CONTROLLER_APP_INFO, - PLAYER_CONTROLLER_MENU_OFFSET + PLAYER_CONTROLLER_MENU_OFFSET, + PLAYER_CONTROLLER_ICON_NAME }; GType player_controller_widget_order_get_type (void) G_GNUC_CONST; GType player_controller_state_get_type (void) G_GNUC_CONST; #define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 -PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); -PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); -static char* player_controller_format_client_name (const char* client_name); +PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const char* mpris_name, const char* icon_name, gint offset, PlayerControllerstate initial_state); +PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const char* mpris_name, const char* icon_name, gint offset, PlayerControllerstate initial_state); +void player_controller_set_app_info (PlayerController* self, GAppInfo* value); +static char* player_controller_format_player_name (char* app_info_name); +GAppInfo* player_controller_get_app_info (PlayerController* self); void player_controller_set_name (PlayerController* self, const char* value); void player_controller_set_mpris_name (PlayerController* self, const char* value); +void player_controller_set_icon_name (PlayerController* self, const char* value); void player_controller_set_menu_offset (PlayerController* self, gint value); static void player_controller_construct_widgets (PlayerController* self); static void player_controller_establish_mpris_connection (PlayerController* self); @@ -166,7 +171,6 @@ void player_controller_update_state (PlayerController* self, PlayerControllersta const char* player_controller_get_name (PlayerController* self); void player_controller_activate (PlayerController* self); void player_controller_instantiate (PlayerController* self); -GAppInfo* player_controller_get_app_info (PlayerController* self); Mpris2Controller* mpris2_controller_new (PlayerController* ctrl); Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl); void player_controller_determine_state (PlayerController* self); @@ -192,10 +196,13 @@ gint player_controller_get_menu_offset (PlayerController* self); gboolean mpris2_controller_connected (Mpris2Controller* self); void mpris2_controller_initial_update (Mpris2Controller* self); const char* player_controller_get_mpris_name (PlayerController* self); -void player_controller_set_app_info (PlayerController* self, GAppInfo* value); +const char* player_controller_get_icon_name (PlayerController* self); static void player_controller_finalize (GObject* obj); static void player_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); static void player_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); +static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func); +static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func); +static gint _vala_array_length (gpointer array); @@ -228,33 +235,23 @@ static gpointer _g_object_ref0 (gpointer self) { } -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; -} - - -PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state) { +PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const char* mpris_name, const char* icon_name, gint offset, PlayerControllerstate initial_state) { PlayerController * self; DbusmenuMenuitem* _tmp0_; char* _tmp1_; - char* _tmp2_; - GeeArrayList* _tmp3_; + GeeArrayList* _tmp2_; g_return_val_if_fail (root != NULL, NULL); - g_return_val_if_fail (client_name != NULL, NULL); + g_return_val_if_fail (app != NULL, NULL); g_return_val_if_fail (mpris_name != NULL, NULL); + g_return_val_if_fail (icon_name != NULL, NULL); self = (PlayerController*) g_object_new (object_type, NULL); self->priv->root_menu = (_tmp0_ = _g_object_ref0 (root), _g_object_unref0 (self->priv->root_menu), _tmp0_); - player_controller_set_name (self, _tmp2_ = player_controller_format_client_name (_tmp1_ = string_strip (client_name))); - _g_free0 (_tmp2_); + player_controller_set_app_info (self, app); + player_controller_set_name (self, _tmp1_ = player_controller_format_player_name (g_strdup (g_app_info_get_name (self->priv->_app_info)))); _g_free0 (_tmp1_); player_controller_set_mpris_name (self, mpris_name); - self->custom_items = (_tmp3_ = gee_array_list_new (TYPE_PLAYER_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->custom_items), _tmp3_); + player_controller_set_icon_name (self, icon_name); + self->custom_items = (_tmp2_ = gee_array_list_new (TYPE_PLAYER_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->custom_items), _tmp2_); self->current_state = (gint) initial_state; player_controller_set_menu_offset (self, offset); player_controller_construct_widgets (self); @@ -264,14 +261,14 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit } -PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state) { - return player_controller_construct (TYPE_PLAYER_CONTROLLER, root, client_name, mpris_name, offset, initial_state); +PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const char* mpris_name, const char* icon_name, gint offset, PlayerControllerstate initial_state) { + return player_controller_construct (TYPE_PLAYER_CONTROLLER, root, app, mpris_name, icon_name, offset, initial_state); } void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state) { g_return_if_fail (self != NULL); - g_debug ("player-controller.vala:72: update_state - player controller %s : new s" \ + g_debug ("player-controller.vala:76: update_state - player controller %s : new s" \ "tate %i", self->priv->_name, (gint) new_state); self->current_state = (gint) new_state; player_controller_update_layout (self); @@ -287,7 +284,7 @@ void player_controller_activate (PlayerController* self) { void player_controller_instantiate (PlayerController* self) { GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); - g_debug ("player-controller.vala:90: instantiate in player controller for %s", self->priv->_name); + g_debug ("player-controller.vala:94: instantiate in player controller for %s", self->priv->_name); { g_app_info_launch (self->priv->_app_info, NULL, NULL, &_inner_error_); if (_inner_error_ != NULL) { @@ -302,8 +299,8 @@ void player_controller_instantiate (PlayerController* self) { _error_ = _inner_error_; _inner_error_ = NULL; { - g_warning ("player-controller.vala:96: Failed to launch app %s with error message:" \ -" %s", self->priv->_name, _error_->message); + g_warning ("player-controller.vala:100: Failed to launch app %s with error message" \ +": %s", self->priv->_name, _error_->message); _g_error_free0 (_error_); } } @@ -320,7 +317,7 @@ static void player_controller_establish_mpris_connection (PlayerController* self Mpris2Controller* _tmp0_; g_return_if_fail (self != NULL); if (self->current_state != PLAYER_CONTROLLER_STATE_READY) { - g_debug ("player-controller.vala:103: establish_mpris_connection - Not ready to " \ + g_debug ("player-controller.vala:107: establish_mpris_connection - Not ready to " \ "connect"); return; } @@ -427,6 +424,17 @@ static void player_controller_construct_widgets (PlayerController* self) { } +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 glong string_get_length (const char* self) { glong result; g_return_val_if_fail (self != NULL, 0L); @@ -468,22 +476,36 @@ static char* string_slice (const char* self, glong start, glong end) { } -static char* player_controller_format_client_name (const char* client_name) { +static char* player_controller_format_player_name (char* app_info_name) { char* result = NULL; - char* formatted; - g_return_val_if_fail (client_name != NULL, NULL); - formatted = g_strdup (client_name); - 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, string_get_length (client_name)), NULL), _g_free0 (formatted), _tmp2_); - _g_free0 (_tmp1_); - _g_free0 (_tmp0_); - g_debug ("player-controller.vala:168: PlayerController->format_client_name - : %" \ -"s", formatted); + 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_); } - result = formatted; + if (string_get_length (_result_) > 1) { + char* _tmp5_; + char* _tmp6_; + char* _tmp7_; + _result_ = (_tmp7_ = g_strconcat (_tmp5_ = g_utf8_strup (_result_, (gssize) 1), _tmp6_ = string_slice (_result_, (glong) 1, string_get_length (_result_)), NULL), _g_free0 (_result_), _tmp7_); + _g_free0 (_tmp6_); + _g_free0 (_tmp5_); + g_debug ("player-controller.vala:176: PlayerController->format_player_name - : %" \ +"s", _result_); + } + result = _result_; + tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL); + _g_free0 (app_info_name); return result; } @@ -567,6 +589,22 @@ void player_controller_set_menu_offset (PlayerController* self, gint value) { } +const char* player_controller_get_icon_name (PlayerController* self) { + const char* result; + g_return_val_if_fail (self != NULL, NULL); + result = self->priv->_icon_name; + return result; +} + + +void player_controller_set_icon_name (PlayerController* self, const char* value) { + char* _tmp0_; + g_return_if_fail (self != NULL); + self->priv->_icon_name = (_tmp0_ = g_strdup (value), _g_free0 (self->priv->_icon_name), _tmp0_); + g_object_notify ((GObject *) self, "icon-name"); +} + + static void player_controller_class_init (PlayerControllerClass * klass) { player_controller_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (PlayerControllerPrivate)); @@ -577,6 +615,7 @@ static void player_controller_class_init (PlayerControllerClass * klass) { g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_MPRIS_NAME, g_param_spec_string ("mpris-name", "mpris-name", "mpris-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_APP_INFO, g_param_spec_object ("app-info", "app-info", "app-info", G_TYPE_APP_INFO, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_MENU_OFFSET, g_param_spec_int ("menu-offset", "menu-offset", "menu-offset", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_ICON_NAME, g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); } @@ -595,6 +634,7 @@ static void player_controller_finalize (GObject* obj) { _g_object_unref0 (self->custom_items); _g_object_unref0 (self->mpris_bridge); _g_object_unref0 (self->priv->_app_info); + _g_free0 (self->priv->_icon_name); G_OBJECT_CLASS (player_controller_parent_class)->finalize (obj); } @@ -627,6 +667,9 @@ static void player_controller_get_property (GObject * object, guint property_id, case PLAYER_CONTROLLER_MENU_OFFSET: g_value_set_int (value, player_controller_get_menu_offset (self)); break; + case PLAYER_CONTROLLER_ICON_NAME: + g_value_set_string (value, player_controller_get_icon_name (self)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -650,6 +693,9 @@ static void player_controller_set_property (GObject * object, guint property_id, case PLAYER_CONTROLLER_MENU_OFFSET: player_controller_set_menu_offset (self, g_value_get_int (value)); break; + case PLAYER_CONTROLLER_ICON_NAME: + player_controller_set_icon_name (self, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -657,5 +703,35 @@ static void player_controller_set_property (GObject * object, guint property_id, } +static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) { + if ((array != NULL) && (destroy_func != NULL)) { + int i; + for (i = 0; i < array_length; i = i + 1) { + if (((gpointer*) array)[i] != NULL) { + destroy_func (((gpointer*) array)[i]); + } + } + } +} + + +static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) { + _vala_array_destroy (array, array_length, destroy_func); + g_free (array); +} + + +static gint _vala_array_length (gpointer array) { + int length; + length = 0; + if (array) { + while (((gpointer*) array)[length]) { + length++; + } + } + return length; +} + + diff --git a/src/player-controller.vala b/src/player-controller.vala index f9cbe71..e2ae4d7 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -49,22 +49,26 @@ public class PlayerController : GLib.Object public Mpris2Controller mpris_bridge; public AppInfo? app_info { get; set;} public int menu_offset { get; set;} + public string icon_name { get; set; } public PlayerController(Dbusmenu.Menuitem root, - string client_name, + GLib.AppInfo app, string mpris_name, + string icon_name, int offset, state initial_state) { this.root_menu = root; - this.name = format_client_name(client_name.strip()); + this.app_info = app; + this.name = format_player_name(this.app_info.get_name()); this.mpris_name = mpris_name; + this.icon_name = icon_name; this.custom_items = new ArrayList<PlayerItem>(); this.current_state = initial_state; this.menu_offset = offset; construct_widgets(); establish_mpris_connection(); - this.update_layout(); + this.update_layout(); } public void update_state(state new_state) @@ -160,15 +164,19 @@ public class PlayerController : GLib.Object } } - private static string format_client_name(string client_name) - { - string formatted = client_name; - if(formatted.length > 1){ - formatted = client_name.up(1).concat(client_name.slice(1, client_name.length)); - debug("PlayerController->format_client_name - : %s", formatted); + private static string format_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]; + } + if(result.length > 1){ + result = result.up(1).concat(result.slice(1, result.length)); + debug("PlayerController->format_player_name - : %s", result); } - return formatted; - } + return result; + } // Temporarily we will need to handle to different mpris implemenations // Do it for now - a couple of weeks should see this messy carry on out of @@ -184,5 +192,5 @@ public class PlayerController : GLib.Object else{ this.update_state(state.DISCONNECTED); } - } -}
\ No newline at end of file + } +} diff --git a/src/player-item.c b/src/player-item.c index cc83381..fe0d8db 100644 --- a/src/player-item.c +++ b/src/player-item.c @@ -306,7 +306,7 @@ gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs) { g_debug ("player-item.vala:96: populated ? - prop: %s", prop); value_int = dbusmenu_menuitem_property_get_int ((DbusmenuMenuitem*) self, prop); if (dbusmenu_menuitem_property_get_int ((DbusmenuMenuitem*) self, prop) != PLAYER_ITEM_EMPTY) { - g_debug ("player-item.vala:99: populated ? - prop %s and value %i", prop, value_int); + g_debug ("player-item.vala:99: populated - prop %s and value %i", prop, value_int); result = TRUE; _g_free0 (prop); _g_object_unref0 (_prop_it); diff --git a/src/player-item.vala b/src/player-item.vala index 2729cb7..51471d1 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -96,7 +96,7 @@ public class PlayerItem : Dbusmenu.Menuitem debug("populated ? - prop: %s", prop); int value_int = property_get_int(prop); if(property_get_int(prop) != EMPTY){ - debug("populated ? - prop %s and value %i", prop, value_int); + debug("populated - prop %s and value %i", prop, value_int); return true; } } diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 1ff1598..14633fe 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -534,10 +534,10 @@ static void context_state_callback(pa_context *c, void *userdata) { switch (pa_context_get_state(c)) { case PA_CONTEXT_UNCONNECTED: - /* g_debug("unconnected");*/ + g_debug("unconnected"); break; case PA_CONTEXT_CONNECTING: - /* g_debug("connecting - waiting for the server to become available");*/ + g_debug("connecting - waiting for the server to become available"); break; case PA_CONTEXT_AUTHORIZING: /* g_debug("authorizing");*/ diff --git a/src/title-menu-item.c b/src/title-menu-item.c index 8ae80c4..4dcd986 100644 --- a/src/title-menu-item.c +++ b/src/title-menu-item.c @@ -128,6 +128,7 @@ GType player_controller_get_type (void) G_GNUC_CONST; TitleMenuitem* title_menuitem_new (PlayerController* parent); TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent); const char* player_controller_get_name (PlayerController* self); +const char* player_controller_get_icon_name (PlayerController* self); static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp); PlayerController* player_item_get_owner (PlayerItem* self); GType mpris2_controller_get_type (void) G_GNUC_CONST; @@ -144,6 +145,8 @@ TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* pa g_return_val_if_fail (parent != NULL, NULL); self = (TitleMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_TITLE_MENUITEM_TYPE, "owner", parent, NULL); dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_NAME, player_controller_get_name (parent)); + g_debug ("title-menu-item.vala:30: title init - icon name = %s", player_controller_get_icon_name (parent)); + dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_ICON, player_controller_get_icon_name (parent)); dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_RUNNING, FALSE); return self; } @@ -179,6 +182,8 @@ GeeHashSet* title_menuitem_attributes_format (void) { GeeHashSet* attrs; attrs = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL); gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_TITLE_MENUITEM_NAME); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_TITLE_MENUITEM_RUNNING); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_TITLE_MENUITEM_ICON); result = attrs; return result; } diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala index bb3d103..64ddebf 100644 --- a/src/title-menu-item.vala +++ b/src/title-menu-item.vala @@ -27,7 +27,9 @@ public class TitleMenuitem : PlayerItem { Object(item_type: MENUITEM_TYPE, owner: parent); this.property_set(MENUITEM_NAME, parent.name); - this.property_set_bool(MENUITEM_RUNNING, false); + debug("title init - icon name = %s", parent.icon_name); + this.property_set(MENUITEM_ICON, parent.icon_name); + this.property_set_bool(MENUITEM_RUNNING, false); } public override void handle_event(string name, GLib.Value input_value, uint timestamp) @@ -50,6 +52,8 @@ public class TitleMenuitem : PlayerItem { HashSet<string> attrs = new HashSet<string>(); attrs.add(MENUITEM_NAME); - return attrs; + attrs.add(MENUITEM_RUNNING); + attrs.add(MENUITEM_ICON); + return attrs; } }
\ No newline at end of file diff --git a/src/title-widget.c b/src/title-widget.c index 3003e10..5bc2a93 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -58,43 +58,50 @@ static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, 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; + widget_class->button_press_event = title_widget_button_press_event; - g_type_class_add_private (klass, sizeof (TitleWidgetPrivate)); + 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"); +} + +static void +title_widget_set_icon(TitleWidget *self) +{ + TitleWidgetPrivate *priv = TITLE_WIDGET_GET_PRIVATE(self); - gint padding = 0; + gchar* icon_name = g_strdup(dbusmenu_menuitem_property_get(priv->twin_item, + DBUSMENU_TITLE_MENUITEM_ICON)); + gint padding = 0; gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - GtkWidget * icon = gtk_image_new_from_icon_name("sound-icon", GTK_ICON_SIZE_MENU); + GtkWidget * icon = gtk_image_new_from_icon_name(icon_name, + GTK_ICON_SIZE_MENU); gtk_widget_set_size_request(icon, width + 5 /* ref triangle is 5x9 pixels */ + 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_widget_show(icon); - + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon)); + gtk_widget_show(icon); + g_free(icon_name); } static void @@ -132,11 +139,19 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, { g_return_if_fail (IS_TITLE_WIDGET (userdata)); TitleWidget* mitem = TITLE_WIDGET(userdata); - + g_debug("PROPERTY UPDATE FOR THE TITLE"); if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), g_value_get_string(value)); } + else if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_ICON, property) == 0){ + g_debug("changing the icon data on the title - %s", + g_value_get_string(value)); + GtkWidget * icon = gtk_image_new_from_icon_name(g_value_get_string(value), + GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mitem), GTK_WIDGET(icon)); + + } } static void @@ -159,6 +174,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)); + title_widget_set_icon(self); } static gboolean @@ -217,7 +233,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/title-widget.h b/src/title-widget.h index 574a2b1..029aba4 100644 --- a/src/title-widget.h +++ b/src/title-widget.h @@ -20,7 +20,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define __TITLE_WIDGET_H__ #include <gtk/gtkimagemenuitem.h> -#include <libdbusmenu-gtk/menuitem.h> +#include <libdbusmenu-glib/menuitem.h> + G_BEGIN_DECLS diff --git a/src/transport-widget.c b/src/transport-widget.c index 7ada71a..26b7a98 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -69,7 +69,6 @@ Uses code from ctk #define INNER_COMPRESSED_START_SHADE 0.95 #define INNER_COMPRESSED_END_SHADE 1.05 - typedef struct _TransportWidgetPrivate TransportWidgetPrivate; struct _TransportWidgetPrivate @@ -80,14 +79,6 @@ struct _TransportWidgetPrivate 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 */ @@ -117,7 +108,6 @@ static void transport_widget_menu_hidden ( GtkWidget *menu, static void transport_widget_notify ( GObject *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, @@ -159,8 +149,8 @@ transport_widget_init (TransportWidget *self) 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); + GINT_TO_POINTER(TRANSPORT_PREVIOUS), + previous_list); GList* play_list = NULL; play_list = g_list_insert(play_list, GINT_TO_POINTER(58), 0); @@ -182,7 +172,7 @@ transport_widget_init (TransportWidget *self) GINT_TO_POINTER(TRANSPORT_NEXT), next_list); - gtk_widget_set_size_request(GTK_WIDGET(self), 200, 50); + gtk_widget_set_size_request(GTK_WIDGET(self), 200, 43); g_signal_connect (G_OBJECT(self), "notify", G_CALLBACK (transport_widget_notify), @@ -742,7 +732,7 @@ _color_hls_to_rgb (gdouble *h, } } -static void +void _color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b) { double red; diff --git a/src/transport-widget.h b/src/transport-widget.h index 337ccdf..6ccce05 100644 --- a/src/transport-widget.h +++ b/src/transport-widget.h @@ -55,6 +55,15 @@ struct _TransportWidget { GtkMenuItem parent; }; +typedef struct +{ + double r; + double g; + double b; +} CairoColorRGB; + + +void _color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b); GType transport_widget_get_type (void); GtkWidget* transport_widget_new ( DbusmenuMenuitem *item ); diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 9d49a92..6938420 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -36,6 +36,7 @@ namespace DbusmenuTransport{ namespace DbusmenuTitle{ public const string MENUITEM_TYPE; public const string MENUITEM_NAME; + public const string MENUITEM_ICON; public const string MENUITEM_RUNNING; } |