aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/familiar-players-db.c29
-rw-r--r--src/familiar-players-db.vala10
-rw-r--r--src/metadata-widget.c33
-rw-r--r--src/mpris2-controller.vala6
-rw-r--r--src/player-controller.c16
-rw-r--r--src/player-controller.vala5
-rw-r--r--src/pulse-manager.c84
-rw-r--r--src/transport-menu-item.c6
-rw-r--r--src/transport-menu-item.vala3
-rw-r--r--src/transport-widget.c41
10 files changed, 158 insertions, 75 deletions
diff --git a/src/familiar-players-db.c b/src/familiar-players-db.c
index e0fff11..15cf064 100644
--- a/src/familiar-players-db.c
+++ b/src/familiar-players-db.c
@@ -70,12 +70,13 @@ 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"
FamiliarPlayersDB* familiar_players_db_new (void);
FamiliarPlayersDB* familiar_players_db_construct (GType object_type);
static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self);
+static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self);
static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self);
static gboolean familiar_players_db_load_data_from_key_file (FamiliarPlayersDB* self);
-static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self);
static void _vala_array_add1 (char*** array, int* length, int* size, char* value);
void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop);
gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const char* desktop);
@@ -97,6 +98,10 @@ FamiliarPlayersDB* familiar_players_db_construct (GType object_type) {
self = (FamiliarPlayersDB*) g_object_new (object_type, NULL);
self->priv->write_id = (guint) 0;
self->priv->players_DB = (_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_BOOLEAN, NULL, NULL, NULL, NULL, NULL), _g_object_unref0 (self->priv->players_DB), _tmp0_);
+ if (!familiar_players_db_create_key_file (self)) {
+ gee_abstract_map_set ((GeeAbstractMap*) self->priv->players_DB, FAMILIAR_PLAYERS_DB_DEFAULT_APP_DESKTOP, GINT_TO_POINTER (TRUE));
+ familiar_players_db_write_db (self);
+ }
self->priv->dir_name = (_tmp1_ = g_build_filename (g_get_user_cache_dir (), "indicators", "sound", NULL), _g_free0 (self->priv->dir_name), _tmp1_);
self->priv->file_name = (_tmp2_ = g_build_filename (self->priv->dir_name, "familiar-players-db.keyfile", NULL), _g_free0 (self->priv->file_name), _tmp2_);
if (familiar_players_db_create_key_file (self)) {
@@ -110,11 +115,11 @@ FamiliarPlayersDB* familiar_players_db_construct (GType object_type) {
_tmp3_ = FALSE;
}
if (_tmp3_) {
- g_debug ("familiar-players-db.vala:45: keyfiles in place and ready for action");
+ g_debug ("familiar-players-db.vala:51: keyfiles in place and ready for action");
} else {
GKeyFile* _tmp5_;
self->priv->key_file = (_tmp5_ = NULL, _g_key_file_free0 (self->priv->key_file), _tmp5_);
- g_warning ("familiar-players-db.vala:49: FamiliarPlayersDB:: problems loading key " \
+ g_warning ("familiar-players-db.vala:55: FamiliarPlayersDB:: problems loading key " \
"file - can't go any further");
}
return self;
@@ -158,7 +163,7 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
e = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("familiar-players-db.vala:61: FamiliarPlayersDB::create_key_file() - Ke" \
+ g_warning ("familiar-players-db.vala:67: FamiliarPlayersDB::create_key_file() - Ke" \
"yFileError");
_g_error_free0 (e);
}
@@ -170,7 +175,7 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
e = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("familiar-players-db.vala:64: FamiliarPlayersDB::create_key_file() - Fi" \
+ g_warning ("familiar-players-db.vala:70: FamiliarPlayersDB::create_key_file() - Fi" \
"leError");
_g_error_free0 (e);
}
@@ -225,7 +230,7 @@ static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self) {
g_clear_error (&_inner_error_);
return FALSE;
}
- g_warning ("familiar-players-db.vala:79: Seen DB '%s' does not have key '%s' in gr" \
+ g_warning ("familiar-players-db.vala:85: Seen DB '%s' does not have key '%s' in gr" \
"oup '%s'", self->priv->file_name, FAMILIAR_PLAYERS_DB_KEY_NAME, FAMILIAR_PLAYERS_DB_GROUP_NAME);
result = FALSE;
return result;
@@ -277,7 +282,7 @@ static gboolean familiar_players_db_load_data_from_key_file (FamiliarPlayersDB*
_error_ = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("familiar-players-db.vala:93: Error loading the Desktop string list");
+ g_warning ("familiar-players-db.vala:99: Error loading the Desktop string list");
result = FALSE;
_g_error_free0 (_error_);
return result;
@@ -345,7 +350,7 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
e = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("familiar-players-db.vala:114: Problems dumping keyfile to a string");
+ g_warning ("familiar-players-db.vala:120: Problems dumping keyfile to a string");
result = FALSE;
_g_error_free0 (e);
_g_free0 (data);
@@ -364,7 +369,7 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
return FALSE;
}
if (g_mkdir_with_parents (self->priv->dir_name, 0700) != 0) {
- g_warning ("familiar-players-db.vala:119: Unable to make directory: %s", self->priv->dir_name);
+ g_warning ("familiar-players-db.vala:125: Unable to make directory: %s", self->priv->dir_name);
result = FALSE;
_g_free0 (data);
desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
@@ -386,7 +391,7 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
return FALSE;
}
if (_tmp5_ == FALSE) {
- g_warning ("familiar-players-db.vala:125: Unable to write out file '%s'", self->priv->file_name);
+ g_warning ("familiar-players-db.vala:131: Unable to write out file '%s'", self->priv->file_name);
}
}
goto __finally10;
@@ -396,7 +401,7 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
err = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("familiar-players-db.vala:129: Unable to write out file '%s'", self->priv->file_name);
+ g_warning ("familiar-players-db.vala:135: Unable to write out file '%s'", self->priv->file_name);
_g_error_free0 (err);
}
}
@@ -460,7 +465,7 @@ gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const ch
gboolean _tmp3_;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (desktop != NULL, FALSE);
- g_debug ("familiar-players-db.vala:148: playerDB->already_familiar - result %s", _tmp1_ = bool_to_string (gee_collection_contains ((GeeCollection*) (_tmp0_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB)), desktop)));
+ g_debug ("familiar-players-db.vala:154: playerDB->already_familiar - result %s", _tmp1_ = bool_to_string (gee_collection_contains ((GeeCollection*) (_tmp0_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB)), desktop)));
_g_free0 (_tmp1_);
_g_object_unref0 (_tmp0_);
result = (_tmp3_ = gee_collection_contains ((GeeCollection*) (_tmp2_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB)), desktop), _g_object_unref0 (_tmp2_), _tmp3_);
diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala
index 894447c..28ac286 100644
--- a/src/familiar-players-db.vala
+++ b/src/familiar-players-db.vala
@@ -29,6 +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 HashMap<string, bool> players_DB;
private string file_name;
private string dir_name;
@@ -38,13 +39,18 @@ public class FamiliarPlayersDB : GLib.Object
public FamiliarPlayersDB()
{
this.write_id = 0;
- this.players_DB = new HashMap<string, bool>();
+ this.players_DB = new HashMap<string, bool>();
+ if ( !create_key_file() ){
+ this.players_DB.set(DEFAULT_APP_DESKTOP, true);
+ this.write_db();
+ }
+
this.dir_name = build_filename(get_user_cache_dir(), "indicators", "sound");
this.file_name = build_filename(this.dir_name, "familiar-players-db.keyfile");
if(create_key_file() && check_for_keys() && load_data_from_key_file()){
debug("keyfiles in place and ready for action");
}
- else{
+ else{
this.key_file = null;
warning("FamiliarPlayersDB:: problems loading key file - can't go any further");
}
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index cbbaeff..0e8aa3b 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -511,10 +511,35 @@ 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);
+ 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);
+ gtk_label_set_text( GTK_LABEL(priv->container_label),
+ dbusmenu_menuitem_property_get( priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_ALBUM));
+ metadata_widget_style_labels( self, GTK_LABEL(priv->container_label));
+
+ gtk_label_set_text( GTK_LABEL(priv->piece_label),
+ dbusmenu_menuitem_property_get( priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_TITLE));
+ metadata_widget_style_labels( self, GTK_LABEL(priv->piece_label));
+ gtk_label_set_text( GTK_LABEL(priv->artist_label),
+ dbusmenu_menuitem_property_get( priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_ARTIST));
+ metadata_widget_style_labels( self, GTK_LABEL(priv->artist_label));
+
+ g_string_erase(priv->image_path, 0, -1);
+ g_string_overwrite( priv->image_path,
+ 0,
+ dbusmenu_menuitem_property_get( priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_ARTURL ));
+
+ // if its a remote image queue a redraw incase the download took too long
+ if (g_str_has_prefix (dbusmenu_menuitem_property_get (priv->twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL ),
+ g_get_user_cache_dir())){
+ gtk_widget_queue_draw(GTK_WIDGET(self));
+ }
}
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index f355d28..f440c13 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -84,7 +84,7 @@ public class Mpris2Controller : GLib.Object
this.properties_interface = (FreeDesktopProperties) connection.get_object("org.freedesktop.Properties.PropertiesChanged",
"/org/mpris/MediaPlayer2");
this.properties_interface.PropertiesChanged += property_changed_cb;
-
+
} catch (DBus.Error e) {
error("Problems connecting to the session bus - %s", e.message);
}
@@ -150,8 +150,8 @@ public class Mpris2Controller : GLib.Object
}
else{
update = determine_play_state(this.player.PlaybackStatus);
- }
- (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(update);
+ }
+ (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(update);
GLib.HashTable<string, Value?> cleaned_metadata = this.clean_metadata();
this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
MetadataMenuitem.attributes_format());
diff --git a/src/player-controller.c b/src/player-controller.c
index 3eee29a..896d826 100644
--- a/src/player-controller.c
+++ b/src/player-controller.c
@@ -101,8 +101,6 @@ typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
typedef struct _TransportMenuitem TransportMenuitem;
typedef struct _TransportMenuitemClass TransportMenuitemClass;
-#define TRANSPORT_MENUITEM_TYPE_STATE (transport_menuitem_state_get_type ())
-
struct _PlayerController {
GObject parent_instance;
PlayerControllerPrivate * priv;
@@ -138,11 +136,6 @@ typedef enum {
PLAYER_CONTROLLER_STATE_DISCONNECTED
} PlayerControllerstate;
-typedef enum {
- TRANSPORT_MENUITEM_STATE_PLAYING,
- TRANSPORT_MENUITEM_STATE_PAUSED
-} TransportMenuitemstate;
-
static gpointer player_controller_parent_class = NULL;
@@ -197,8 +190,7 @@ TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerContro
GType transport_menuitem_get_type (void) G_GNUC_CONST;
gint player_controller_get_menu_offset (PlayerController* self);
gboolean mpris2_controller_connected (Mpris2Controller* self);
-GType transport_menuitem_state_get_type (void) G_GNUC_CONST;
-void transport_menuitem_change_play_state (TransportMenuitem* self, TransportMenuitemstate update);
+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);
static void player_controller_finalize (GObject* obj);
@@ -501,14 +493,10 @@ void player_controller_determine_state (PlayerController* self) {
if (mpris2_controller_connected (self->mpris_bridge) == TRUE) {
PlayerItem* _tmp0_;
TitleMenuitem* title;
- PlayerItem* _tmp1_;
- TransportMenuitem* transport;
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED);
title = (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE), IS_TITLE_MENUITEM (_tmp0_) ? ((TitleMenuitem*) _tmp0_) : NULL);
title_menuitem_toggle_active_triangle (title, TRUE);
- transport = (_tmp1_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT), IS_TRANSPORT_MENUITEM (_tmp1_) ? ((TransportMenuitem*) _tmp1_) : NULL);
- transport_menuitem_change_play_state (transport, TRANSPORT_MENUITEM_STATE_PAUSED);
- _g_object_unref0 (transport);
+ mpris2_controller_initial_update (self->mpris_bridge);
_g_object_unref0 (title);
} else {
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED);
diff --git a/src/player-controller.vala b/src/player-controller.vala
index ad8e989..f9cbe71 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -178,9 +178,8 @@ public class PlayerController : GLib.Object
if(this.mpris_bridge.connected() == true){
this.update_state(state.CONNECTED);
TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem;
- title.toggle_active_triangle(true);
- TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem;
- transport.change_play_state(TransportMenuitem.state.PAUSED);
+ title.toggle_active_triangle(true);
+ this.mpris_bridge.initial_update();
}
else{
this.update_state(state.DISCONNECTED);
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index 8779525..1ff1598 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include <pulse/glib-mainloop.h>
#include <pulse/error.h>
#include <pulse/gccmacro.h>
@@ -28,14 +27,18 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "pulse-manager.h"
#include "dbus-menu-manager.h"
+#define RECONNECT_DELAY 5
+
static GHashTable *sink_hash = NULL;
static SoundServiceDbus *dbus_service = NULL;
static gint DEFAULT_SINK_INDEX = -1;
static gboolean pa_server_available = FALSE;
-// PA related
+static gint reconnect_idle_id = 0;
static pa_context *pulse_context = NULL;
static pa_glib_mainloop *pa_main_loop = NULL;
+
static void context_state_callback(pa_context *c, void *userdata);
+static gboolean reconnect_to_pulse();
static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink_info, int eol, void *userdata);
static void context_success_callback(pa_context *c, int success, void *userdata);
static void pulse_sink_input_info_callback(pa_context *c, const pa_sink_input_info *info, int eol, void *userdata);
@@ -61,15 +64,19 @@ void establish_pulse_activities(SoundServiceDbus *service)
dbus_service = service;
pa_main_loop = pa_glib_mainloop_new(g_main_context_default());
g_assert(pa_main_loop);
- pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound");
+ 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);
+ 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);
+ 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);
}
/**
@@ -81,6 +88,41 @@ pa_context* get_context()
return pulse_context;
}
+static gboolean
+reconnect_to_pulse()
+{
+ g_debug("Attempt to reconnect to pulse");
+ // reset
+ if (pulse_context != NULL) {
+ pa_context_unref(pulse_context);
+ pulse_context = NULL;
+ }
+
+ if (sink_hash != NULL) {
+ g_hash_table_destroy(sink_hash);
+ sink_hash = NULL;
+ }
+ 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);
+ int result = pa_context_connect (pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
+
+ if (result < 0) {
+ g_warning ("Failed to connect context: %s",
+ pa_strerror (pa_context_errno (pulse_context)));
+ }
+ // we always want to cancel any continious callbacks with the existing timeout
+ // if the connection failed the new context created above will catch any updates
+ // to do with the state of pulse and thus take care of business.
+ reconnect_idle_id = 0;
+ return FALSE;
+}
+
/**
close_pulse_activites()
Gracefully close our connection with the Pulse async library.
@@ -294,9 +336,6 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in
static void pulse_default_sink_info_callback(pa_context *c, const pa_sink_info *info, int eol, void *userdata)
{
if (eol > 0) {
- if (pa_context_errno(c) == PA_ERR_NOENTITY)
- return;
- g_warning("Default Sink info callback failure");
return;
} else {
DEFAULT_SINK_INDEX = info->index;
@@ -416,7 +455,9 @@ static gboolean has_volume_changed(const pa_sink_info* new_sink, sink_info* cach
}
-static void pulse_server_info_callback(pa_context *c, const pa_server_info *info, void *userdata)
+static void pulse_server_info_callback(pa_context *c,
+ const pa_server_info *info,
+ void *userdata)
{
/* g_debug("server info callback");*/
pa_operation *operation;
@@ -428,7 +469,10 @@ static void pulse_server_info_callback(pa_context *c, const pa_server_info *info
}
pa_server_available = TRUE;
if (info->default_sink_name != NULL) {
- if (!(operation = pa_context_get_sink_info_by_name(c, info->default_sink_name, pulse_default_sink_info_callback, userdata))) {
+ if (!(operation = pa_context_get_sink_info_by_name(c,
+ info->default_sink_name,
+ pulse_default_sink_info_callback,
+ userdata))) {
g_warning("pa_context_get_sink_info_by_name() failed");
} else {
pa_operation_unref(operation);
@@ -502,16 +546,26 @@ static void context_state_callback(pa_context *c, void *userdata)
/* g_debug("context setting name");*/
break;
case PA_CONTEXT_FAILED:
- g_warning("FAILED to retrieve context - Is PulseAudio Daemon running ?");
+ g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?");
pa_server_available = FALSE;
+ dbus_menu_manager_update_pa_state(TRUE,
+ pa_server_available,
+ default_sink_is_muted(),
+ get_default_sink_volume());
+
+ if (reconnect_idle_id == 0){
+ reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY,
+ reconnect_to_pulse,
+ NULL);
+ }
break;
case PA_CONTEXT_TERMINATED:
/* g_debug("context terminated");*/
break;
case PA_CONTEXT_READY:
- g_debug("PA daemon is ready");
+ g_debug("PA_CONTEXT_READY");
pa_operation *o;
-
+
pa_context_set_subscribe_callback(c, subscribed_events_callback, userdata);
if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t)
diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c
index 3161da8..d6a66a2 100644
--- a/src/transport-menu-item.c
+++ b/src/transport-menu-item.c
@@ -185,6 +185,8 @@ TransportMenuitem* transport_menuitem_new (PlayerController* parent) {
void transport_menuitem_change_play_state (TransportMenuitem* self, TransportMenuitemstate update) {
g_return_if_fail (self != NULL);
+ g_debug ("transport-menu-item.vala:45: UPDATING THE TRANSPORT DBUSMENUITEM PLAY " \
+"STATE WITH VALUE %i", (gint) update);
dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, (gint) update);
}
@@ -196,9 +198,9 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const
self = (TransportMenuitem*) base;
g_return_if_fail (name != NULL);
input = g_value_get_int (input_value);
- g_debug ("transport-menu-item.vala:51: handle_event with value %s", _tmp0_ = g_strdup_printf ("%i", input));
+ g_debug ("transport-menu-item.vala:53: handle_event with value %s", _tmp0_ = g_strdup_printf ("%i", input));
_g_free0 (_tmp0_);
- g_debug ("transport-menu-item.vala:52: transport owner name = %s", player_controller_get_name (player_item_get_owner ((PlayerItem*) self)));
+ g_debug ("transport-menu-item.vala:54: transport owner name = %s", player_controller_get_name (player_item_get_owner ((PlayerItem*) self)));
mpris2_controller_transport_update (player_item_get_owner ((PlayerItem*) self)->mpris_bridge, (TransportMenuitemaction) input);
}
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index 7faadb5..36429e8 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -42,6 +42,8 @@ public class TransportMenuitem : PlayerItem
public void change_play_state(state update)
{
+ debug("UPDATING THE TRANSPORT DBUSMENUITEM PLAY STATE WITH VALUE %i",
+ (int)update);
this.property_set_int(MENUITEM_PLAY_STATE, update);
}
@@ -60,5 +62,4 @@ public class TransportMenuitem : PlayerItem
return attrs;
}
-
} \ No newline at end of file
diff --git a/src/transport-widget.c b/src/transport-widget.c
index e7f0b4d..7ada71a 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -114,7 +114,7 @@ static void transport_widget_property_update ( DbusmenuMenuitem* item,
gpointer userdata );
static void transport_widget_menu_hidden ( GtkWidget *menu,
TransportWidget *transport);
-static void transport_widget_notify ( TransportWidget *item,
+static void transport_widget_notify ( GObject *item,
GParamSpec *pspec,
gpointer user_data );
@@ -135,12 +135,12 @@ transport_widget_class_init (TransportWidgetClass *klass)
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->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
@@ -158,9 +158,9 @@ transport_widget_init (TransportWidget *self)
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);
+ 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);
@@ -183,10 +183,10 @@ transport_widget_init (TransportWidget *self)
next_list);
gtk_widget_set_size_request(GTK_WIDGET(self), 200, 50);
- g_signal_connect (G_OBJECT(self),
- "notify::parent",
- G_CALLBACK (transport_widget_notify),
- NULL);
+ g_signal_connect (G_OBJECT(self),
+ "notify",
+ G_CALLBACK (transport_widget_notify),
+ NULL);
}
static void
@@ -213,7 +213,7 @@ transport_widget_expose (GtkWidget *button, GdkEventExpose *event)
event->area.width, event->area.height);
cairo_clip(cr);
- draw (button, cr);
+ draw (button, cr);
cairo_destroy (cr);
return FALSE;
@@ -230,16 +230,16 @@ transport_widget_toggle_play_pause(TransportWidget* button,
}
static void
-transport_widget_notify (TransportWidget *item,
- GParamSpec *pspec,
- gpointer user_data)
+transport_widget_notify ( GObject *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);
+ item );
}
}
}
@@ -248,7 +248,6 @@ static void
transport_widget_menu_hidden ( GtkWidget *menu,
TransportWidget *transport)
{
- //g_debug("Transport Widget's menu hidden method called");
g_return_if_fail(IS_TRANSPORT_WIDGET(transport));
transport_widget_react_to_button_release(transport, TRANSPORT_NADA);
}
@@ -1272,6 +1271,11 @@ transport_widget_set_twin_item(TransportWidget* self,
priv->twin_item = twin_item;
g_signal_connect(G_OBJECT(priv->twin_item), "property-changed",
G_CALLBACK(transport_widget_property_update), self);
+ gint initial_state = dbusmenu_menuitem_property_get_int( twin_item,
+ DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE );
+ //g_debug("TRANSPORT WIDGET - INITIAL UPDATE = %i", initial_state);
+ transport_widget_toggle_play_pause( self,
+ (TransportWidgetState)initial_state);
}
/**
@@ -1290,8 +1294,7 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
{
int update_value = g_value_get_int(value);
//g_debug("transport_widget_update_state - with value %i", update_value);
- transport_widget_toggle_play_pause(bar,
- (TransportWidgetState)update_value);
+ transport_widget_toggle_play_pause(bar, (TransportWidgetState)update_value);
}
}