static void import_complete_cb (RhythmDBImportJob *job, int total, RBAndroidSource *source) { RBAndroidSourcePrivate *priv = GET_PRIVATE (source); GSettings *settings; RBShell *shell; if (priv->ejecting) { rb_device_source_default_eject (RB_DEVICE_SOURCE (source)); } else { g_object_get (source, "shell", &shell, NULL); rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (priv->import_errors), RB_DISPLAY_PAGE (source)); g_object_unref (shell); g_object_set (source, "load-status", RB_SOURCE_LOAD_STATUS_LOADED, NULL); g_object_get (source, "encoding-settings", &settings, NULL); rb_transfer_target_transfer (RB_TRANSFER_TARGET (source), settings, NULL, FALSE); g_object_unref (settings); rb_media_player_source_purge_metadata_cache (RB_MEDIA_PLAYER_SOURCE (source)); } g_clear_object (&priv->import_job); }
static void eject_action_cb (GSimpleAction *action, GVariant *parameter, gpointer data) { RBRemovableMediaManager *mgr = RB_REMOVABLE_MEDIA_MANAGER (data); RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (mgr); RBDisplayPage *page; g_object_get (priv->shell, "selected-page", &page, NULL); if (RB_IS_DEVICE_SOURCE (page)) { rb_device_source_eject (RB_DEVICE_SOURCE (page)); } }
static void impl_constructed (GObject *object) { RBAndroidSource *source; RBAndroidSourcePrivate *priv; RhythmDBEntryType *entry_type; RBShell *shell; char **output_formats; RB_CHAIN_GOBJECT_METHOD (rb_android_source_parent_class, constructed, object); source = RB_ANDROID_SOURCE (object); priv = GET_PRIVATE (source); rb_device_source_set_display_details (RB_DEVICE_SOURCE (source)); g_object_get (source, "shell", &shell, "entry-type", &entry_type, NULL); g_object_get (shell, "db", &priv->db, NULL); priv->import_errors = rb_import_errors_source_new (shell, priv->error_type, entry_type, priv->ignore_type); g_object_get (priv->device_info, "output-formats", &output_formats, NULL); if (output_formats != NULL) { GstEncodingTarget *target; int i; target = gst_encoding_target_new ("android-device", "device", "", NULL); for (i = 0; output_formats[i] != NULL; i++) { const char *media_type = rb_gst_mime_type_to_media_type (output_formats[i]); if (media_type != NULL) { GstEncodingProfile *profile; profile = rb_gst_get_encoding_profile (media_type); if (profile != NULL) { gst_encoding_target_add_profile (target, profile); } } } g_object_set (source, "encoding-target", target, NULL); } g_strfreev (output_formats); g_object_unref (shell); }
static void page_changed_cb (RBShell *shell, GParamSpec *pspec, RBRemovableMediaManager *mgr) { RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (mgr); RBDisplayPage *page; gboolean can_eject; GApplication *app; GAction *action; g_object_get (priv->shell, "selected-page", &page, NULL); if (RB_IS_DEVICE_SOURCE (page)) { can_eject = rb_device_source_can_eject (RB_DEVICE_SOURCE (page)); } else { can_eject = FALSE; } app = g_application_get_default (); action = g_action_map_lookup_action (G_ACTION_MAP (app), "removable-media-eject"); g_object_set (action, "enabled", can_eject, NULL); }
static void impl_constructed (GObject *object) { RBGenericPlayerSource *source; RBGenericPlayerSourcePrivate *priv; RhythmDBEntryType *entry_type; char **playlist_formats; char **output_formats; char *mount_name; RBShell *shell; GFile *root; GFileInfo *info; GError *error = NULL; RB_CHAIN_GOBJECT_METHOD (rb_generic_player_source_parent_class, constructed, object); source = RB_GENERIC_PLAYER_SOURCE (object); priv = GET_PRIVATE (source); rb_device_source_set_display_details (RB_DEVICE_SOURCE (source)); g_object_get (source, "shell", &shell, "entry-type", &entry_type, NULL); g_object_get (shell, "db", &priv->db, NULL); priv->import_errors = rb_import_errors_source_new (shell, priv->error_type, entry_type, priv->ignore_type); g_object_unref (shell); root = g_mount_get_root (priv->mount); mount_name = g_mount_get_name (priv->mount); info = g_file_query_filesystem_info (root, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, NULL, &error); if (error != NULL) { rb_debug ("error querying filesystem info for %s: %s", mount_name, error->message); g_error_free (error); priv->read_only = FALSE; } else { priv->read_only = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY); g_object_unref (info); } g_free (mount_name); g_object_unref (root); g_object_get (priv->device_info, "playlist-formats", &playlist_formats, NULL); if (playlist_formats != NULL && g_strv_length (playlist_formats) > 0) { g_object_set (entry_type, "has-playlists", TRUE, NULL); } g_strfreev (playlist_formats); g_object_unref (entry_type); g_object_get (priv->device_info, "output-formats", &output_formats, NULL); if (output_formats != NULL) { GstEncodingTarget *target; int i; target = gst_encoding_target_new ("generic-player", "device", "", NULL); for (i = 0; output_formats[i] != NULL; i++) { const char *media_type = rb_gst_mime_type_to_media_type (output_formats[i]); if (media_type != NULL) { GstEncodingProfile *profile; profile = rb_gst_get_encoding_profile (media_type); if (profile != NULL) { gst_encoding_target_add_profile (target, profile); } } } g_object_set (source, "encoding-target", target, NULL); } g_strfreev (output_formats); }
static void impl_constructed (GObject *object) { RBGenericPlayerSource *source; RBGenericPlayerSourcePrivate *priv; RhythmDBEntryType *entry_type; char **playlist_formats; char **output_formats; char *mount_name; RBShell *shell; GFile *root; GFileInfo *info; GError *error = NULL; char *label; char *fullname; char *name; RB_CHAIN_GOBJECT_METHOD (rb_generic_player_source_parent_class, constructed, object); source = RB_GENERIC_PLAYER_SOURCE (object); priv = GET_PRIVATE (source); rb_device_source_set_display_details (RB_DEVICE_SOURCE (source)); g_object_get (source, "shell", &shell, "entry-type", &entry_type, "name", &name, NULL); g_object_get (shell, "db", &priv->db, NULL); priv->import_errors = rb_import_errors_source_new (shell, priv->error_type, entry_type, priv->ignore_type); priv->new_playlist_action_name = g_strdup_printf ("generic-player-%p-playlist-new", source); fullname = g_strdup_printf ("app.%s", priv->new_playlist_action_name); label = g_strdup_printf (_("New Playlist on %s"), name); rb_application_add_plugin_menu_item (RB_APPLICATION (g_application_get_default ()), "display-page-add-playlist", priv->new_playlist_action_name, g_menu_item_new (label, fullname)); g_free (fullname); g_free (label); g_free (name); root = g_mount_get_root (priv->mount); mount_name = g_mount_get_name (priv->mount); info = g_file_query_filesystem_info (root, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, NULL, &error); if (error != NULL) { rb_debug ("error querying filesystem info for %s: %s", mount_name, error->message); g_error_free (error); priv->read_only = FALSE; } else { priv->read_only = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY); g_object_unref (info); } g_free (mount_name); g_object_unref (root); g_object_get (priv->device_info, "playlist-formats", &playlist_formats, NULL); if ((priv->read_only == FALSE) && playlist_formats != NULL && g_strv_length (playlist_formats) > 0) { RBDisplayPageModel *model; GMenu *playlist_menu; GMenuModel *playlists; priv->new_playlist_action = g_simple_action_new (priv->new_playlist_action_name, NULL); g_signal_connect (priv->new_playlist_action, "activate", G_CALLBACK (new_playlist_action_cb), source); g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()), G_ACTION (priv->new_playlist_action)); g_object_get (shell, "display-page-model", &model, NULL); playlists = rb_display_page_menu_new (model, RB_DISPLAY_PAGE (source), RB_TYPE_GENERIC_PLAYER_PLAYLIST_SOURCE, "app.playlist-add-to"); g_object_unref (model); playlist_menu = g_menu_new (); g_menu_append (playlist_menu, _("Add to New Playlist"), priv->new_playlist_action_name); g_menu_append_section (playlist_menu, NULL, playlists); g_object_set (source, "playlist-menu", playlist_menu, NULL); } g_strfreev (playlist_formats); g_object_unref (entry_type); g_object_get (priv->device_info, "output-formats", &output_formats, NULL); if (output_formats != NULL) { GstEncodingTarget *target; int i; target = gst_encoding_target_new ("generic-player", "device", "", NULL); for (i = 0; output_formats[i] != NULL; i++) { const char *media_type = rb_gst_mime_type_to_media_type (output_formats[i]); if (media_type != NULL) { GstEncodingProfile *profile; profile = rb_gst_get_encoding_profile (media_type); if (profile != NULL) { gst_encoding_target_add_profile (target, profile); } } } g_object_set (source, "encoding-target", target, NULL); } g_strfreev (output_formats); g_object_unref (shell); }