[rhythmbox] mtp: use the can_eject and eject vmethods rather than a custom action



commit f84916201bda837313aaf9b9ba9cb323468f3497
Author: Jonathan Matthew <jonathan d14n org>
Date:   Fri May 21 17:50:48 2010 +1000

    mtp: use the can_eject and eject vmethods rather than a custom action

 plugins/mtpdevice/mtp-ui.xml      |    2 +-
 plugins/mtpdevice/rb-mtp-plugin.c |   11 -----------
 plugins/mtpdevice/rb-mtp-source.c |   18 +++++++++++++++++-
 3 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/plugins/mtpdevice/mtp-ui.xml b/plugins/mtpdevice/mtp-ui.xml
index bdc7161..5c09ebc 100644
--- a/plugins/mtpdevice/mtp-ui.xml
+++ b/plugins/mtpdevice/mtp-ui.xml
@@ -2,7 +2,7 @@
   <popup name="MTPSourcePopup">
     <menuitem name="MTPSrcPopupSync" action="MediaPlayerSourceSync"/>
     <menuitem name="MTPSrcPopupRename" action="MTPSourceRename"/>
-    <menuitem name="MTPSrcPopupEject" action="MTPSourceEject"/>
+    <menuitem name="MTPSrcPopupEject" action="RemovableSourceEject"/>
     <menuitem name="MTPSrcPopupProperties" action="MTPSourceProperties"/>
   </popup>
 </ui>
diff --git a/plugins/mtpdevice/rb-mtp-plugin.c b/plugins/mtpdevice/rb-mtp-plugin.c
index 6df8746..94971be 100644
--- a/plugins/mtpdevice/rb-mtp-plugin.c
+++ b/plugins/mtpdevice/rb-mtp-plugin.c
@@ -109,7 +109,6 @@ static void rb_mtp_plugin_device_removed (LibHalContext *context, const char *ud
 static gboolean rb_mtp_plugin_setup_dbus_hal_connection (RBMtpPlugin *plugin);
 #endif
 
-static void rb_mtp_plugin_eject  (GtkAction *action, RBSource *source);
 static void rb_mtp_plugin_rename (GtkAction *action, RBSource *source);
 static void rb_mtp_plugin_properties (GtkAction *action, RBSource *source);
 
@@ -120,9 +119,6 @@ RB_PLUGIN_REGISTER(RBMtpPlugin, rb_mtp_plugin)
 
 static GtkActionEntry rb_mtp_plugin_actions [] =
 {
-	{ "MTPSourceEject", GNOME_MEDIA_EJECT, N_("_Eject"), NULL,
-	  N_("Eject MTP-device"),
-	  G_CALLBACK (rb_mtp_plugin_eject) },
 	{ "MTPSourceRename", NULL, N_("_Rename"), NULL,
 	  N_("Rename MTP-device"),
 	  G_CALLBACK (rb_mtp_plugin_rename) },
@@ -289,13 +285,6 @@ impl_deactivate (RBPlugin *bplugin, RBShell *shell)
 }
 
 static void
-rb_mtp_plugin_eject (GtkAction *action, RBSource *source)
-{
-	g_return_if_fail (RB_IS_MTP_SOURCE (source));
-	rb_source_delete_thyself (source);
-}
-
-static void
 rb_mtp_plugin_rename (GtkAction *action, RBSource *source)
 {
 	RBShell *shell;
diff --git a/plugins/mtpdevice/rb-mtp-source.c b/plugins/mtpdevice/rb-mtp-source.c
index ca27535..ec96d3f 100644
--- a/plugins/mtpdevice/rb-mtp-source.c
+++ b/plugins/mtpdevice/rb-mtp-source.c
@@ -98,6 +98,8 @@ static char* impl_build_dest_uri (RBRemovableMediaSource *source,
 				  RhythmDBEntry *entry,
 				  const char *mimetype,
 				  const char *extension);
+static void impl_eject (RBRemovableMediaSource *source);
+static gboolean impl_can_eject (RBRemovableMediaSource *source);
 
 static void mtp_device_open_cb (LIBMTP_mtpdevice_t *device, RBMtpSource *source);
 static void mtp_tracklist_cb (LIBMTP_track_t *tracks, RBMtpSource *source);
@@ -212,6 +214,8 @@ rb_mtp_source_class_init (RBMtpSourceClass *klass)
 	rms_class->impl_build_dest_uri = impl_build_dest_uri;
 	rms_class->impl_get_mime_types = impl_get_mime_types;
 	rms_class->impl_should_paste = rb_removable_media_source_should_paste_no_duplicate;
+	rms_class->impl_can_eject = impl_can_eject;
+	rms_class->impl_eject = impl_eject;
 
 	mps_class->impl_get_entries = impl_get_entries;
 	mps_class->impl_get_capacity = impl_get_capacity;
@@ -1024,7 +1028,7 @@ impl_get_ui_actions (RBSource *source)
 {
 	GList *actions = NULL;
 
-	actions = g_list_prepend (actions, g_strdup ("MTPSourceEject"));
+	actions = g_list_prepend (actions, g_strdup ("RemovableSourceEject"));
 	actions = g_list_prepend (actions, g_strdup ("MediaPlayerSourceSync"));
 
 	return actions;
@@ -1568,6 +1572,18 @@ prepare_encoder_source_cb (RBEncoderFactory *factory,
 	prepare_source (source, stream_uri, src);
 }
 
+static gboolean
+impl_can_eject (RBRemovableMediaSource *source)
+{
+	return TRUE;
+}
+
+static void
+impl_eject (RBRemovableMediaSource *source)
+{
+	rb_source_delete_thyself (RB_SOURCE (source));
+}
+
 #if defined(HAVE_GUDEV)
 
 static GMount *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]