aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--src/Makefile.am8
-rw-r--r--src/familiar-players-db.vala2
-rw-r--r--src/fetch-file.vala86
-rw-r--r--src/indicator-sound.c31
-rw-r--r--src/metadata-menu-item.vala128
-rw-r--r--src/metadata-widget.c48
-rw-r--r--src/mpris2-controller.vala2
-rw-r--r--src/music-player-bridge.vala40
-rw-r--r--src/play-button.c20
-rw-r--r--src/play-button.h4
-rw-r--r--src/player-item.vala26
-rw-r--r--src/sound-service.c3
-rw-r--r--src/transport-widget.c25
-rw-r--r--src/volume-widget.c4
-rw-r--r--vapi/common-defs.vapi2
16 files changed, 348 insertions, 85 deletions
diff --git a/configure.ac b/configure.ac
index fe2957a..e4ef20f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,10 @@
-AC_INIT(indicator-sound, 0.4.1, conor.curran@canonical.com)
+AC_INIT(indicator-sound, 0.4.2, conor.curran@canonical.com)
AC_PREREQ(2.53)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(indicator-sound, 0.4.1)
+AM_INIT_AUTOMAKE(indicator-sound, 0.4.2)
AM_MAINTAINER_MODE
diff --git a/src/Makefile.am b/src/Makefile.am
index 2a4e937..e85ed93 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -67,7 +67,9 @@ music_bridge_VALASOURCES = \
player-controller.vala \
mpris2-controller.vala \
player-item.vala \
- familiar-players-db.vala
+ familiar-players-db.vala \
+ fetch-file.vala
+
music_bridge_VALAFLAGS = \
--ccode \
@@ -81,7 +83,9 @@ music_bridge_VALAFLAGS = \
--pkg Dbusmenu-Glib-0.2 \
--pkg common-defs \
--pkg dbus-glib-1 \
- --pkg gio-unix-2.0
+ --pkg gio-unix-2.0 \
+ --pkg gdk-pixbuf-2.0
+
$(MAINTAINER_VALAFLAGS)
diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala
index 2bc0a3c..894447c 100644
--- a/src/familiar-players-db.vala
+++ b/src/familiar-players-db.vala
@@ -83,7 +83,7 @@ public class FamiliarPlayersDB : GLib.Object
private bool load_data_from_key_file(){
try{
string[] desktops = this.key_file.get_string_list(GROUP_NAME,
- KEY_NAME);
+ KEY_NAME);
foreach(string s in desktops){
this.players_DB.set(s, true);
}
diff --git a/src/fetch-file.vala b/src/fetch-file.vala
new file mode 100644
index 0000000..1811cc1
--- /dev/null
+++ b/src/fetch-file.vala
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Canonical, Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License
+ * version 3.0 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3.0 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors
+ * Gordon Allott <gord.allott@canonical.com>
+ * Conor Curran <conor.curran@canonical.com>
+ */
+
+public class FetchFile : Object
+{
+ /* public variables */
+ public string uri {get; construct;}
+ public string intended_property {get; construct;}
+
+ /* private variables */
+ private DataInputStream stream;
+ private File? file;
+ private ByteArray data;
+
+ /* public signals */
+ public signal void failed ();
+ public signal void completed (ByteArray data, string property);
+
+ public FetchFile (string uri, string prop)
+ {
+ Object (uri: uri, intended_property: prop);
+ }
+
+ construct
+ {
+ this.file = File.new_for_uri(this.uri);
+ this.data = new ByteArray ();
+ }
+
+ public async void fetch_data ()
+ {
+ try {
+ this.stream = new DataInputStream(this.file.read(null));
+ this.stream.set_byte_order (DataStreamByteOrder.LITTLE_ENDIAN);
+ } catch (GLib.Error e) {
+ this.failed ();
+ }
+ this.read_something_async ();
+ }
+
+ private async void read_something_async ()
+ {
+ ssize_t size = 1024;
+ uint8[] buffer = new uint8[size];
+
+ ssize_t bufsize = 1;
+ do {
+ try {
+ bufsize = yield this.stream.read_async (buffer, size, GLib.Priority.DEFAULT, null);
+ if (bufsize < 1) { break;}
+
+ if (bufsize != size)
+ {
+ uint8[] cpybuf = new uint8[bufsize];
+ Memory.copy (cpybuf, buffer, bufsize);
+ this.data.append (cpybuf);
+ }
+ else
+ {
+ this.data.append (buffer);
+ }
+ } catch (Error e) {
+ this.failed ();
+ }
+ } while (bufsize > 0);
+ this.completed (this.data, this.intended_property);
+ }
+}
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 4f954c3..0e631fa 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -67,6 +67,8 @@ G_DEFINE_TYPE (IndicatorSound, indicator_sound, INDICATOR_OBJECT_TYPE);
static GtkLabel * get_label (IndicatorObject * io);
static GtkImage * get_icon (IndicatorObject * io);
static GtkMenu * get_menu (IndicatorObject * io);
+static void indicator_sound_scroll (IndicatorObject* io, gint delta, IndicatorScrollDirection direction);
+
//Slider related
static gboolean new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
@@ -135,7 +137,7 @@ indicator_sound_class_init (IndicatorSoundClass *klass)
io_class->get_label = get_label;
io_class->get_image = get_icon;
io_class->get_menu = get_menu;
-
+ io_class->scroll = indicator_sound_scroll;
design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
return;
@@ -498,7 +500,6 @@ start_animation()
{
blocked_iter = blocked_animation_list;
blocked_id = 0;
- //g_debug("exit from blocked hold start the animation\n");
animation_id = g_timeout_add(50, fade_back_to_mute_image, NULL);
return FALSE;
}
@@ -507,7 +508,6 @@ static gboolean
fade_back_to_mute_image()
{
if (blocked_iter != NULL) {
- g_debug("in animation 'loop'\n");
gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data);
blocked_iter = blocked_iter->next;
return TRUE;
@@ -715,3 +715,28 @@ style_changed_cb(GtkWidget *widget, gpointer user_data)
free_the_animation_list();
prepare_blocked_animation();
}
+
+static void
+indicator_sound_scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction)
+{
+ g_debug("indicator-sound-scroll - current slider value");
+
+ if (device_available == FALSE || current_state == STATE_MUTED)
+ return;
+
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
+
+ GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
+ GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget);
+ GtkRange* range = (GtkRange*)slider;
+ gdouble value = gtk_range_get_value(range);
+ GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider));
+ g_debug("indicator-sound-scroll - current slider value %f", value);
+ if (direction == INDICATOR_OBJECT_SCROLL_UP) {
+ value += adj->step_increment;
+ } else {
+ value -= adj->step_increment;
+ }
+ g_debug("indicator-sound-scroll - update slider with value %f", value);
+ volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value);
+} \ No newline at end of file
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index 0bb4a85..3f71653 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -17,18 +17,141 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-using Dbusmenu;
using Gee;
using DbusmenuMetadata;
+using Gdk;
public class MetadataMenuitem : PlayerItem
{
+ public const string ALBUM_ART_DIR_SUFFIX = "indicators/sound/album-art-cache";
+
+ public static string album_art_cache_dir;
+ private static FetchFile fetcher;
+ private string previous_temp_album_art_path;
+
public MetadataMenuitem()
{
Object(item_type: MENUITEM_TYPE);
reset(attributes_format());
}
+
+ construct{
+ MetadataMenuitem.clean_album_art_temp_dir();
+ this.previous_temp_album_art_path = null;
+ this.album_art_cache_dir = MetadataMenuitem.create_album_art_temp_dir();
+ }
+ private static void clean_album_art_temp_dir()
+ {
+ string path = GLib.Path.build_filename(Environment.get_user_cache_dir(), ALBUM_ART_DIR_SUFFIX);
+
+ GLib.File? album_art_dir = GLib.File.new_for_path(path);
+
+ if(delete_album_art_contents(album_art_dir) == false)
+ {
+ warning("could not remove the temp album art files %s", path);
+ }
+ }
+
+ private static string? create_album_art_temp_dir()
+ {
+ string path = GLib.Path.build_filename(Environment.get_user_cache_dir(), ALBUM_ART_DIR_SUFFIX);
+ if(DirUtils.create(path, 0700) == -1){
+ warning("could not create a temp dir for remote album art, it must have been created already");
+ }
+ return path;
+ }
+
+ private static bool delete_album_art_contents (GLib.File dir)
+ {
+ bool result = true;
+ try {
+ var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME,
+ FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
+ null);
+ while (true)
+ {
+ var file = e.next_file (null);
+
+ debug("file name = %s", file.get_name());
+
+ if (file == null)
+ break;
+
+ var child = dir.get_child (file.get_name ());
+
+ try {
+ child.delete (null);
+ } catch (Error error_) {
+ warning (@"Unable to delete file '$(child.get_basename ()): $(error_.message)");
+ result = false;
+ }
+ }
+ } catch (Error error) {
+ warning (@"Unable to read files from directory '$(dir.get_basename ())': %s",
+ error.message);
+ result = false;
+ }
+ return result;
+ }
+
+ public void fetch_art(string uri, string prop)
+ {
+ File art_file = File.new_for_uri(uri);
+ if(art_file.is_native() == true){
+ string path;
+ try{
+ path = Filename.from_uri(uri.strip());
+ this.property_set(prop, path);
+ }
+ catch(ConvertError e){
+ warning("Problem converting URI %s to file path",
+ uri);
+ }
+ // eitherway return, the artwork was local
+ return;
+ }
+ debug("fetch_art -remotely %s", this.album_art_cache_dir);
+ // If we didn't manage to create the temp dir
+ // don't bother with remote
+ if(this.album_art_cache_dir == null){
+ return;
+ }
+ // green light to go remote
+ this.fetcher = new FetchFile (uri, prop);
+ this.fetcher.failed.connect (() => { this.on_fetcher_failed ();});
+ this.fetcher.completed.connect (this.on_fetcher_completed);
+ this.fetcher.fetch_data ();
+ }
+
+ private void on_fetcher_failed ()
+ {
+ warning("on_fetcher_failed -> could not fetch artwork");
+ }
+
+ private void on_fetcher_completed(ByteArray update, string property)
+ {
+ try{
+ PixbufLoader loader = new PixbufLoader ();
+ loader.write (update.data, update.len);
+ loader.close ();
+ Pixbuf icon = loader.get_pixbuf ();
+ string path = this.album_art_cache_dir.concat("/downloaded-coverart-XXXXXX");
+ int r = FileUtils.mkstemp(path);
+ if(r != -1){
+ icon.save (path, loader.get_format().get_name());
+ this.property_set(property, path);
+ if(this.previous_temp_album_art_path != null){
+ FileUtils.remove(this.previous_temp_album_art_path);
+ }
+ this.previous_temp_album_art_path = path;
+ }
+ }
+ catch(GLib.Error e){
+ warning("Problem creating file from bytearray fetched from the interweb - error: %s",
+ e.message);
+ }
+ }
public static HashSet<string> attributes_format()
{
@@ -38,6 +161,5 @@ public class MetadataMenuitem : PlayerItem
attrs.add(MENUITEM_ALBUM);
attrs.add(MENUITEM_ARTURL);
return attrs;
- }
-
+ }
}
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index f600238..18ebd38 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -25,6 +25,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "metadata-widget.h"
#include "common-defs.h"
#include <gtk/gtk.h>
+#include <glib.h>
static DbusmenuMenuitem* twin_item;
@@ -69,7 +70,7 @@ static void image_set_from_pixbuf (GtkWidget *widget,
MetadataWidget* metadata,
GdkPixbuf *source);
-
+static void draw_album_art_placeholder(GtkWidget *metadata);
G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
@@ -160,7 +161,7 @@ metadata_widget_init (MetadataWidget *self)
g_signal_connect(self, "style-set", G_CALLBACK(metadata_widget_set_style), GTK_WIDGET(self));
- gtk_widget_set_size_request(GTK_WIDGET(self), 200, 60);
+ gtk_widget_set_size_request(GTK_WIDGET(self), 200, 65);
gtk_container_add (GTK_CONTAINER (self), hbox);
}
@@ -178,7 +179,7 @@ metadata_widget_finalize (GObject *object)
/**
* We override the expose method to enable primitive drawing of the
- * empty album art image (and soon rounded rectangles on the album art)
+ * empty album art image and rounded rectangles on the album art.
*/
static gboolean
metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user_data)
@@ -186,24 +187,33 @@ 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);
-
if(priv->image_path->len > 0){
-
- if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){
+ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){
GdkPixbuf* pixbuf;
pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
- g_debug("metadata_widget_expose, album art update -> pixbuf from %s",
- priv->image_path->str);
+ g_debug("metadata_load_new_image -> pixbuf from %s",
+ priv->image_path->str);
+ if(GDK_IS_PIXBUF(pixbuf) == FALSE){
+ g_debug("problem loading the downloaded image just use the placeholder instead");
+ draw_album_art_placeholder(metadata);
+ return TRUE;
+ }
pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR);
image_set_from_pixbuf (metadata, widget, pixbuf);
g_string_erase(priv->old_image_path, 0, -1);
g_string_overwrite(priv->old_image_path, 0, priv->image_path->str);
- g_object_unref(pixbuf);
+ g_object_unref(pixbuf);
}
return FALSE;
}
-
+ draw_album_art_placeholder(metadata);
+ return TRUE;
+}
+
+static void draw_album_art_placeholder(GtkWidget *metadata)
+{
+
cairo_t *cr;
cr = gdk_cairo_create (metadata->window);
GtkAllocation alloc;
@@ -255,8 +265,7 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user
g_object_unref(pcontext);
g_string_free (string, TRUE);
cairo_destroy (cr);
-
- return TRUE;
+
}
/* Suppress/consume keyevents */
@@ -314,7 +323,12 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
}
else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){
g_string_erase(priv->image_path, 0, -1);
- g_string_overwrite(priv->image_path, 0, g_value_get_string (value));
+ g_string_overwrite(priv->image_path, 0, g_value_get_string (value));
+ // if its a remote image queue a redraw incase the download took too long
+ if (g_str_has_prefix(g_value_get_string (value), g_get_user_cache_dir())){
+ g_debug("the image update is a download so redraw");
+ gtk_widget_queue_draw(GTK_WIDGET(mitem));
+ }
}
}
@@ -348,10 +362,9 @@ rounded_rectangle (cairo_t *cr,
{
gdouble radius;
gdouble degrees;
-
+
radius = corner_radius / aspect;
degrees = G_PI / 180.0;
-
cairo_new_sub_path (cr);
cairo_arc (cr,
x + width - radius,
@@ -377,6 +390,7 @@ rounded_rectangle (cairo_t *cr,
radius,
180 * degrees,
270 * degrees);
+
cairo_close_path (cr);
}
@@ -401,12 +415,12 @@ image_set_from_pixbuf (GtkWidget *widget,
MetadataWidgetPrivate* priv = METADATA_WIDGET_GET_PRIVATE(metadata);
GtkImage* image = GTK_IMAGE(priv->album_art);
- frame_width = 5;
+ frame_width = 3;
w = gdk_pixbuf_get_width (source) + frame_width * 2;
h = gdk_pixbuf_get_height (source) + frame_width * 2;
- radius = w / 10;
+ 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);
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 41c8ca8..dab5e2c 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -96,7 +96,7 @@ public class Mpris2Controller : GLib.Object
public void property_changed_cb(string interface_source, HashTable<string, Value?> changed_properties, string[] invalid )
{
- debug("properties-changed for interface %s", interface_source);
+ debug("properties-changed for interface %s and owner %s", interface_source, this.owner.name.down());
if(changed_properties == null || interface_source.has_prefix(this.root_interface) == false){
warning("Property-changed hash is null or this is an interface that concerns us");
return;
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index daad42f..c677d15 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -44,30 +44,26 @@ public class MusicPlayerBridge : GLib.Object
}
private void try_to_add_inactive_familiar_clients(){
- // TODO handle multple players - just working with one right now
- int count = 0;
foreach(string app in this.playersDB.records()){
- if(count == 0){
- if(app == null){
- warning("App string in keyfile is null therefore moving on to next player");
- continue;
- }
- DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
- if(info == null){
- warning("Could not create a desktopappinfo instance from app: %s", app);
- continue;
- }
- GLib.AppInfo app_info = info as GLib.AppInfo;
- PlayerController ctrl = new PlayerController(this.root_menu,
- app_info.get_name(),
- calculate_menu_position(),
- PlayerController.state.OFFLINE);
- ctrl.set("app_info", app_info);
- this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
- debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip());
- count += 1;
+ if(app == null){
+ warning("App string in keyfile is null therefore moving on to next player");
+ continue;
+ }
+
+ debug("attempting to make an app info from %s", app);
+
+ DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
+ if(info == null){
+ warning("Could not create a desktopappinfo instance from app: %s", app);
+ continue;
}
- break;
+ GLib.AppInfo app_info = info as GLib.AppInfo;
+ PlayerController ctrl = new PlayerController(this.root_menu,
+ app_info.get_name(),
+ calculate_menu_position(),
+ PlayerController.state.OFFLINE);
+ ctrl.set("app_info", app_info);
+ this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
}
}
diff --git a/src/play-button.c b/src/play-button.c
index 2164527..0c934e5 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -410,11 +410,12 @@ play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command)
g_return_if_fail(IS_PLAY_BUTTON(button));
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
priv->current_command = command;
-
+
cairo_t *cr;
cr = gdk_cairo_create (button->window);
- GList* list = g_hash_table_lookup(priv->command_coordinates, GINT_TO_POINTER(command));
+ GList* list = g_hash_table_lookup(priv->command_coordinates,
+ GINT_TO_POINTER(priv->current_command));
cairo_rectangle(cr,
GPOINTER_TO_INT(g_list_nth_data(list, 0)),
GPOINTER_TO_INT(g_list_nth_data(list, 1)),
@@ -427,10 +428,19 @@ play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command)
void
-play_button_react_to_button_release(GtkWidget* button)
+play_button_react_to_button_release(GtkWidget* button, PlayButtonEvent command)
{
g_return_if_fail(IS_PLAY_BUTTON(button));
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
+ if(priv->current_command == TRANSPORT_NADA){
+ g_debug("returning from the playbutton release because my previous command was nada");
+ return;
+ }
+ else if(priv->current_command != TRANSPORT_NADA &&
+ command != TRANSPORT_NADA){
+ priv->current_command = command;
+ }
+
cairo_t *cr;
cr = gdk_cairo_create (button->window);
@@ -438,7 +448,7 @@ play_button_react_to_button_release(GtkWidget* button)
GINT_TO_POINTER(priv->current_command));
priv->current_command = TRANSPORT_NADA;
-
+
cairo_rectangle(cr,
GPOINTER_TO_INT(g_list_nth_data(list, 0)),
GPOINTER_TO_INT(g_list_nth_data(list, 1)),
@@ -457,6 +467,7 @@ play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update)
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
priv->current_state = update;
g_debug("PlayButton::toggle play state : %i", priv->current_state);
+ gtk_widget_queue_draw (GTK_WIDGET(button));
}
@@ -956,7 +967,6 @@ draw (GtkWidget* button, cairo_t *cr)
}
-
/**
* play_button_new:
* @returns: a new #PlayButton.
diff --git a/src/play-button.h b/src/play-button.h
index 727a489..6bacac7 100644
--- a/src/play-button.h
+++ b/src/play-button.h
@@ -56,8 +56,8 @@ struct _PlayButton {
GType play_button_get_type (void);
void play_button_set_style(GtkWidget* button, GtkStyle* style);
PlayButtonEvent determine_button_event(GtkWidget* button, GdkEventButton* event);
-void play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command);
-void play_button_react_to_button_release(GtkWidget* button);
+void play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command);
+void play_button_react_to_button_release(GtkWidget* button, PlayButtonEvent command);
void play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update);
GtkWidget* play_button_new();
diff --git a/src/player-item.vala b/src/player-item.vala
index fbfacbd..68ae6ef 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -25,7 +25,7 @@ public class PlayerItem : Dbusmenu.Menuitem
public PlayerController owner {get; construct;}
public string item_type { get; construct; }
private const int EMPTY = -1;
-
+
public PlayerItem(string type)
{
Object(item_type: type);
@@ -42,6 +42,12 @@ public class PlayerItem : Dbusmenu.Menuitem
}
}
+ /**
+ * update()
+ * Base update method for playeritems, takes the attributes and the incoming updates
+ * and attmepts to update the appropriate props on the object.
+ * Album art is handled separately to deal with remote and local file paths.
+ */
public void update(HashTable<string, Value?> data, HashSet<string> attributes)
{
debug("PlayerItem::update()");
@@ -59,16 +65,14 @@ public class PlayerItem : Dbusmenu.Menuitem
if (v.holds (typeof (string))){
string update = v.get_string().strip();
debug("with value : %s", update);
- // Special case for the arturl URI's.
- if(property.contains("mpris:artUrl")){
- try{
- update = Filename.from_uri(update.strip());
- }
- catch(ConvertError e){
- warning("Problem converting URI %s to file path", update);
- }
+ if(property.contains("mpris:artUrl")){
+ // We know its a metadata instance because thats the only
+ // object with the arturl prop
+ MetadataMenuitem metadata = this as MetadataMenuitem;
+ metadata.fetch_art(update.strip(), property);
+ continue;
}
- this.property_set(property, update);
+ this.property_set(property, update);
}
else if (v.holds (typeof (int))){
debug("with value : %i", v.get_int());
@@ -83,7 +87,6 @@ public class PlayerItem : Dbusmenu.Menuitem
this.property_set_bool(property, v.get_boolean());
}
}
-
if(this.property_get_bool(MENUITEM_PROP_VISIBLE) == false){
this.property_set_bool(MENUITEM_PROP_VISIBLE, true);
}
@@ -101,5 +104,6 @@ public class PlayerItem : Dbusmenu.Menuitem
}
return false;
}
+
}
diff --git a/src/sound-service.c b/src/sound-service.c
index 12f067e..f19379d 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -40,14 +40,13 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
- // TODO: uncomment for release !!
+ //TODO: uncomment for release !!
close_pulse_activites();
g_main_loop_quit(mainloop);
}
return;
}
-
/**
main:
**/
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 702b472..979f6fd 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -136,22 +136,12 @@ transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
-
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
-
- GtkWidget *parent;
-
- parent = gtk_widget_get_parent (GTK_WIDGET (menuitem));
-
+
PlayButtonEvent result = determine_button_event(priv->play_button, event);
if(result != TRANSPORT_NADA){
- GValue value = {0};
- g_value_init(&value, G_TYPE_INT);
- g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
- g_value_set_int(&value, (int)result);
play_button_react_to_button_press(priv->play_button, result);
- dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
}
return TRUE;
}
@@ -164,7 +154,17 @@ transport_widget_button_release_event (GtkWidget *menuitem,
g_debug("TransportWidget::menu_release_event");
g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
- play_button_react_to_button_release(priv->play_button);
+
+ PlayButtonEvent result = determine_button_event(priv->play_button, event);
+
+ if(result != TRANSPORT_NADA){
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_INT);
+ g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
+ g_value_set_int(&value, (int)result);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
+ }
+ play_button_react_to_button_release(priv->play_button, result);
return TRUE;
}
@@ -187,6 +187,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);
play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value);
+
}
}
diff --git a/src/volume-widget.c b/src/volume-widget.c
index bf1ddb9..5e7cf9f 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -1,3 +1,4 @@
+
/*
Copyright 2010 Canonical Ltd.
@@ -48,6 +49,7 @@ static void volume_widget_set_twin_item( VolumeWidget* self,
DbusmenuMenuitem* twin_item);
static void volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata);
+
static gboolean volume_widget_change_value_cb (GtkRange *range,
GtkScrollType scroll,
gdouble value,
@@ -103,7 +105,7 @@ volume_widget_init (VolumeWidget *self)
g_object_unref(secondary_gicon);
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (volume_widget));
- gtk_adjustment_set_step_increment(adj, 3);
+ gtk_adjustment_set_step_increment(adj, 4);
}
static void
diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi
index 98dbd94..9d49a92 100644
--- a/vapi/common-defs.vapi
+++ b/vapi/common-defs.vapi
@@ -1,6 +1,6 @@
/*
Copyright 2010 Canonical Ltd.
-
+
Authors:
Conor Curran <conor.curran@canonical.com>