[rhythmbox] device-source: fix want_uri and uri_is_source
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] device-source: fix want_uri and uri_is_source
- Date: Fri, 14 Sep 2012 12:00:36 +0000 (UTC)
commit dfdf14f0780697c8c85b26f10318922e8e2c7d10
Author: Jonathan Matthew <jonathan d14n org>
Date: Fri Sep 14 21:54:52 2012 +1000
device-source: fix want_uri and uri_is_source
It helps if they have the right arg and return types to be
used directly as RBSource impl_want_uri and impl_uri_is_source
methods.
rb_device_source_want_uri was also checking the source's mount
object badly.
sources/rb-device-source.c | 16 ++++++----------
sources/rb-device-source.h | 6 ++++--
2 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/sources/rb-device-source.c b/sources/rb-device-source.c
index 75eb033..ced3a75 100644
--- a/sources/rb-device-source.c
+++ b/sources/rb-device-source.c
@@ -232,8 +232,8 @@ rb_device_source_eject (RBDeviceSource *source)
*
* Return value: URI match strength
*/
-int
-rb_device_source_want_uri (RBDeviceSource *source, const char *uri)
+guint
+rb_device_source_want_uri (RBSource *source, const char *uri)
{
GMount *mount = NULL;
GVolume *volume = NULL;
@@ -244,16 +244,11 @@ rb_device_source_want_uri (RBDeviceSource *source, const char *uri)
retval = 0;
- /* ignore anything that isn't a local file */
file = g_file_new_for_uri (uri);
- if (g_file_has_uri_scheme (file, "file") == FALSE) {
- g_object_unref (file);
- return 0;
- }
/* Deal with the mount root being passed, eg. file:///media/IPODNAME */
if (g_object_class_find_property (G_OBJECT_GET_CLASS (source), "mount")) {
- g_object_get (source, "mount", &volume, NULL);
+ g_object_get (source, "mount", &mount, NULL);
}
if (mount != NULL) {
GFile *root;
@@ -274,7 +269,8 @@ rb_device_source_want_uri (RBDeviceSource *source, const char *uri)
}
}
- if (volume == NULL) {
+ /* ignore anything that isn't a local file or doesn't have a volume */
+ if (g_file_has_uri_scheme (file, "file") == FALSE || volume == NULL) {
g_object_unref (file);
return 0;
}
@@ -316,7 +312,7 @@ rb_device_source_want_uri (RBDeviceSource *source, const char *uri)
* Return value: %TRUE if @uri matches @source
*/
gboolean
-rb_device_source_uri_is_source (RBDeviceSource *source, const char *uri)
+rb_device_source_uri_is_source (RBSource *source, const char *uri)
{
return (rb_device_source_want_uri (source, uri) == 100);
}
diff --git a/sources/rb-device-source.h b/sources/rb-device-source.h
index f788206..e9b7994 100644
--- a/sources/rb-device-source.h
+++ b/sources/rb-device-source.h
@@ -30,6 +30,8 @@
#include <glib-object.h>
+#include "rb-source.h"
+
G_BEGIN_DECLS
#define RB_TYPE_DEVICE_SOURCE (rb_device_source_get_type ())
@@ -53,8 +55,8 @@ GType rb_device_source_get_type (void);
gboolean rb_device_source_can_eject (RBDeviceSource *source);
void rb_device_source_eject (RBDeviceSource *source);
-int rb_device_source_want_uri (RBDeviceSource *source, const char *uri);
-gboolean rb_device_source_uri_is_source (RBDeviceSource *source, const char *uri);
+guint rb_device_source_want_uri (RBSource *source, const char *uri);
+gboolean rb_device_source_uri_is_source (RBSource *source, const char *uri);
void rb_device_source_set_display_details (RBDeviceSource *source);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]