static GObject * impl_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { RBGenericPlayerSource *source; RBGenericPlayerSourcePrivate *priv; GMount *mount; char *mount_name; RBShell *shell; GFile *root; GFileInfo *info; GError *error = NULL; source = RB_GENERIC_PLAYER_SOURCE (G_OBJECT_CLASS (rb_generic_player_source_parent_class)-> constructor (type, n_construct_properties, construct_properties)); priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (source); g_object_get (source, "shell", &shell, NULL); g_object_get (shell, "db", &priv->db, NULL); priv->import_errors = rb_import_errors_source_new (shell, priv->error_type); g_object_unref (shell); g_object_get (source, "mount", &mount, NULL); root = g_mount_get_root (mount); mount_name = g_mount_get_name (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_unref (mount); priv->folder_depth = -1; /* 0 is a possible value, I guess */ priv->playlist_format_unknown = TRUE; get_device_info (source); load_songs (source); return G_OBJECT (source); }
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 GObject * impl_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { RBGenericPlayerSource *source; RBGenericPlayerSourcePrivate *priv; GMount *mount; char **playlist_formats; char *mount_name; RBShell *shell; GFile *root; GFileInfo *info; GError *error = NULL; source = RB_GENERIC_PLAYER_SOURCE (G_OBJECT_CLASS (rb_generic_player_source_parent_class)-> constructor (type, n_construct_properties, construct_properties)); priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (source); g_object_get (source, "shell", &shell, NULL); g_object_get (shell, "db", &priv->db, NULL); priv->import_errors = rb_import_errors_source_new (shell, priv->error_type); g_object_unref (shell); g_object_get (source, "mount", &mount, NULL); root = g_mount_get_root (mount); mount_name = g_mount_get_name (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_unref (mount); g_object_get (priv->device_info, "playlist-formats", &playlist_formats, NULL); if (playlist_formats != NULL && g_strv_length (playlist_formats) > 0) { RhythmDBEntryType entry_type; g_object_get (source, "entry-type", &entry_type, NULL); entry_type->has_playlists = TRUE; g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type); } g_strfreev (playlist_formats); load_songs (source); return G_OBJECT (source); }
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); }