Пример #1
0
void
rhythmdb_register_song_entry_types (RhythmDB *db)
{
	g_assert (song_entry_type == NULL);
	g_assert (error_entry_type == NULL);
	g_assert (ignore_entry_type == NULL);

	song_entry_type = g_object_new (rhythmdb_song_entry_type_get_type (),
					"db", db,
					"name", "song",
					"save-to-disk", TRUE,
					"has-playlists", TRUE,
					NULL);

	ignore_entry_type = g_object_new (rhythmdb_ignore_entry_type_get_type (),
					  "db", db,
					  "name", "ignore",
					  "save-to-disk", TRUE,
					  "category", RHYTHMDB_ENTRY_VIRTUAL,
					  NULL);

	error_entry_type = g_object_new (rhythmdb_error_entry_type_get_type (),
					 "db", db,
					 "name", "import-error",
					 "category", RHYTHMDB_ENTRY_VIRTUAL,
					 NULL);

	rhythmdb_register_entry_type (db, song_entry_type);
	rhythmdb_register_entry_type (db, error_entry_type);
	rhythmdb_register_entry_type (db, ignore_entry_type);
}
RBSource *
rb_iradio_source_new (RBShell *shell, GObject *plugin)
{
	RBSource *source;
	RhythmDBEntryType *entry_type;
	RhythmDB *db;
	GSettings *settings;

	g_object_get (shell, "db", &db, NULL);

	entry_type = rhythmdb_entry_type_get_by_name (db, "iradio");
	if (entry_type == NULL) {
		entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
					   "db", db,
					   "name", "iradio",
					   "save-to-disk", TRUE,
					   "category", RHYTHMDB_ENTRY_STREAM,
					   NULL);
		rhythmdb_register_entry_type (db, entry_type);
	}
	g_object_unref (db);

	settings = g_settings_new ("org.gnome.rhythmbox.plugins.iradio");
	source = RB_SOURCE (g_object_new (RB_TYPE_IRADIO_SOURCE,
					  "name", _("Radio"),
					  "shell", shell,
					  "entry-type", entry_type,
					  "plugin", plugin,
					  "settings", g_settings_get_child (settings, "source"),
					  "toolbar-path", "/IRadioSourceToolBar",
					  NULL));
	g_object_unref (settings);
	rb_shell_register_entry_type_for_source (shell, source, entry_type);
	return source;
}
Пример #3
0
void
rb_podcast_register_entry_types (RhythmDB *db)
{
	g_assert (podcast_post_entry_type == NULL);
	g_assert (podcast_feed_entry_type == NULL);

	podcast_post_entry_type = g_object_new (rb_podcast_post_entry_type_get_type (),
						"db", db,
						"name", "podcast-post",
						"save-to-disk", TRUE,
						"category", RHYTHMDB_ENTRY_NORMAL,
						"type-data-size", sizeof (RhythmDBPodcastFields),
						NULL);
	rhythmdb_register_entry_type (db, podcast_post_entry_type);

	podcast_feed_entry_type = g_object_new (rb_podcast_feed_entry_type_get_type (),
						"db", db,
						"name", "podcast-feed",
						"save-to-disk", TRUE,
						"category", RHYTHMDB_ENTRY_CONTAINER,
						"type-data-size", sizeof (RhythmDBPodcastFields),
						NULL);
	rhythmdb_register_entry_type (db, podcast_feed_entry_type);
}
Пример #4
0
RBSource *
rb_grilo_source_new (GObject *plugin, GrlSource *grilo_source)
{
	GObject *source;
	RBShell *shell;
	GSettings *settings;
	RhythmDBEntryType *entry_type;
	RhythmDB *db;
	char *name;

	name = g_strdup_printf ("grilo:%s", grl_source_get_id (grilo_source));

	g_object_get (plugin, "object", &shell, NULL);
	g_object_get (shell, "db", &db, NULL);
	entry_type = g_object_new (rb_grilo_entry_type_get_type (),
				   "db", db,
				   "name", name,
				   "save-to-disk", FALSE,
				   "category", RHYTHMDB_ENTRY_NORMAL,
				   "type-data-size", sizeof(RBGriloEntryData),
				   NULL);
	rhythmdb_register_entry_type (db, entry_type);
	g_object_unref (db);
	g_free (name);

	settings = g_settings_new ("org.gnome.rhythmbox.plugins.grilo");
	source = g_object_new (RB_TYPE_GRILO_SOURCE,
			       "name", grl_source_get_name (grilo_source),
			       "entry-type", entry_type,
			       "shell", shell,
			       "plugin", plugin,
			       "show-browser", FALSE,
			       "settings", g_settings_get_child (settings, "source"),
			       "grilo-source", grilo_source,
			       NULL);
	g_object_unref (settings);
	rb_display_page_set_icon_name (RB_DISPLAY_PAGE (source), "network-server-symbolic");

	rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);

	g_object_unref (shell);
	return RB_SOURCE (source);
}
Пример #5
0
RBSource *
rb_psp_source_new (GObject *plugin, RBShell *shell, GMount *mount, MPIDDevice *device_info)
{
    RBPspSource *source;
    RhythmDBEntryType *entry_type;
    RhythmDB *db;
    char *name;
    char *path;
    GVolume *volume;

    g_assert (rb_psp_is_mount_player (mount, device_info));

    volume = g_mount_get_volume (mount);

    g_object_get (G_OBJECT (shell), "db", &db, NULL);
    path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
    name = g_strdup_printf ("psp: %s", path);
    entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
                               "db", db,
                               "name", name,
                               "save-to-disk", FALSE,
                               "category", RHYTHMDB_ENTRY_NORMAL,
                               NULL);
    rhythmdb_register_entry_type (db, entry_type);
    g_object_unref (db);
    g_free (name);
    g_free (path);
    g_object_unref (volume);

    source = RB_PSP_SOURCE (g_object_new (RB_TYPE_PSP_SOURCE,
                                          "plugin", plugin,
                                          "entry-type", entry_type,
                                          "mount", mount,
                                          "shell", shell,
                                          "device-info", device_info,
                                          NULL));

    rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);

    return RB_SOURCE (source);
}
Пример #6
0
static void
impl_constructed (GObject *object)
{
	RBImportDialog *dialog;
	RhythmDBQuery *query;
	GtkBuilder *builder;
	GSettings *settings;
	char **locations;

	RB_CHAIN_GOBJECT_METHOD (rb_import_dialog_parent_class, constructed, object);
	dialog = RB_IMPORT_DIALOG (object);

	g_object_get (dialog->priv->shell,
		      "db", &dialog->priv->db,
		      "shell-player", &dialog->priv->shell_player,
		      NULL);

	/* create entry types */
	dialog->priv->entry_type = g_object_new (rb_import_dialog_entry_type_get_type (),
						 "db", dialog->priv->db,
						 "name", "import-dialog",
						 NULL);
	dialog->priv->ignore_type = g_object_new (rb_import_dialog_ignore_type_get_type (),
						  "db", dialog->priv->db,
						  "name", "import-dialog-ignore",
						  NULL);
	rhythmdb_register_entry_type (dialog->priv->db, dialog->priv->entry_type);
	rhythmdb_register_entry_type (dialog->priv->db, dialog->priv->ignore_type);


	builder = rb_builder_load ("import-dialog.ui", NULL);

	dialog->priv->import_button = GTK_WIDGET (gtk_builder_get_object (builder, "import-button"));
	g_signal_connect_object (dialog->priv->import_button, "clicked", G_CALLBACK (import_clicked_cb), dialog, 0);
	gtk_widget_set_sensitive (dialog->priv->import_button, FALSE);

	dialog->priv->copy_check = GTK_WIDGET (gtk_builder_get_object (builder, "copy-check"));

	g_signal_connect (gtk_builder_get_object (builder, "close-button"),
			  "clicked",
			  G_CALLBACK (close_clicked_cb),
			  dialog);

	dialog->priv->file_chooser = GTK_WIDGET (gtk_builder_get_object (builder, "file-chooser-button"));
	
	/* select the first library location, since the default may be
	 * the user's home dir or / or something that will take forever to scan.
	 */
	settings = g_settings_new ("org.gnome.rhythmbox.rhythmdb");
	locations = g_settings_get_strv (settings, "locations");
	if (locations[0] != NULL) {
		dialog->priv->current_uri = g_strdup (locations[0]);
	} else {
		dialog->priv->current_uri = g_filename_to_uri (rb_music_dir (), NULL, NULL);
	}
	gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog->priv->file_chooser),
						 dialog->priv->current_uri);
	g_strfreev (locations);
	g_object_unref (settings);

	g_signal_connect_object (dialog->priv->file_chooser, "selection-changed", G_CALLBACK (current_folder_changed_cb), dialog, 0);

	/* not sure why we have to set this, it should be the default */
	gtk_widget_set_vexpand (gtk_widget_get_parent (dialog->priv->file_chooser), FALSE);

	dialog->priv->info_bar_container = GTK_WIDGET (gtk_builder_get_object (builder, "info-bar-container"));

	/* set up entry view */
	dialog->priv->entry_view = rb_entry_view_new (dialog->priv->db, G_OBJECT (dialog->priv->shell_player), TRUE, FALSE);

	g_signal_connect (dialog->priv->entry_view, "entry-activated", G_CALLBACK (entry_activated_cb), dialog);
	g_signal_connect (dialog->priv->entry_view, "selection-changed", G_CALLBACK (selection_changed_cb), dialog);

	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_TRACK_NUMBER, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_TITLE, TRUE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_GENRE, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_ARTIST, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_ALBUM, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_YEAR, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_DURATION, FALSE);
 	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_QUALITY, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_PLAY_COUNT, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_BPM, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_COMMENT, FALSE);
	rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_COL_LOCATION, FALSE);

	settings = g_settings_new ("org.gnome.rhythmbox.sources");
	g_settings_bind (settings, "visible-columns", dialog->priv->entry_view, "visible-columns", G_SETTINGS_BIND_DEFAULT);
	g_object_unref (settings);

	g_signal_connect (dialog->priv->entry_view,
			  "notify::sort-order",
			  G_CALLBACK (sort_changed_cb),
			  dialog);
	rb_entry_view_set_sorting_order (dialog->priv->entry_view, "Album", GTK_SORT_ASCENDING);

	gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (builder, "entry-view-container")),
			   GTK_WIDGET (dialog->priv->entry_view));

	dialog->priv->query_model = rhythmdb_query_model_new_empty (dialog->priv->db);
	rb_entry_view_set_model (dialog->priv->entry_view, dialog->priv->query_model);
	query = rhythmdb_query_parse (dialog->priv->db,
				      RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, dialog->priv->entry_type,
				      RHYTHMDB_QUERY_END);
	rhythmdb_do_full_query_async_parsed (dialog->priv->db, RHYTHMDB_QUERY_RESULTS (dialog->priv->query_model), query);
	rhythmdb_query_free (query);

	g_signal_connect (dialog->priv->query_model, "post-entry-delete", G_CALLBACK (entry_deleted_cb), dialog);
	g_signal_connect (dialog->priv->query_model, "row-inserted", G_CALLBACK (entry_inserted_cb), dialog);

	gtk_container_add (GTK_CONTAINER (dialog), GTK_WIDGET (gtk_builder_get_object (builder, "import-dialog")));

	gtk_widget_show_all (GTK_WIDGET (dialog));
	g_object_unref (builder);
}
Пример #7
0
RBSource *
rb_generic_player_source_new (GObject *plugin, RBShell *shell, GMount *mount, MPIDDevice *device_info)
{
	RBGenericPlayerSource *source;
	RhythmDBEntryType *entry_type;
	RhythmDBEntryType *error_type;
	RhythmDBEntryType *ignore_type;
	RhythmDB *db;
	GVolume *volume;
	GSettings *settings;
	char *name;
	char *path;

	volume = g_mount_get_volume (mount);

	g_object_get (shell, "db", &db, NULL);
	path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);

	name = g_strdup_printf ("generic audio player: %s", path);
	entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
				   "db", db,
				   "name", name,
				   "save-to-disk", FALSE,
				   "category", RHYTHMDB_ENTRY_NORMAL,
				   NULL);
	rhythmdb_register_entry_type (db, entry_type);
	g_free (name);

	name = g_strdup_printf ("generic audio player (ignore): %s", path);
	ignore_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
				    "db", db,
				    "name", name,
				    "save-to-disk", FALSE,
				    "category", RHYTHMDB_ENTRY_VIRTUAL,
				    NULL);
	rhythmdb_register_entry_type (db, ignore_type);
	g_free (name);

	name = g_strdup_printf ("generic audio player (errors): %s", path);
	error_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
				   "db", db,
				   "name", name,
				   "save-to-disk", FALSE,
				   "category", RHYTHMDB_ENTRY_VIRTUAL,
				   NULL);
	rhythmdb_register_entry_type (db, error_type);
	g_free (name);

	g_object_unref (db);
	g_object_unref (volume);
	g_free (path);

	settings = g_settings_new ("org.gnome.rhythmbox.plugins.generic-player");
	source = RB_GENERIC_PLAYER_SOURCE (g_object_new (RB_TYPE_GENERIC_PLAYER_SOURCE,
							 "plugin", plugin,
							 "entry-type", entry_type,
							 "ignore-entry-type", ignore_type,
							 "error-entry-type", error_type,
							 "mount", mount,
							 "shell", shell,
							 "device-info", device_info,
							 "load-status", RB_SOURCE_LOAD_STATUS_LOADING,
							 "settings", g_settings_get_child (settings, "source"),
							 "toolbar-path", "/GenericPlayerSourceToolBar",
							 NULL));
	g_object_unref (settings);

	rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);

	return RB_SOURCE (source);
}
Пример #8
0
static RBSource *
create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, MPIDDevice *device_info, RBGenericPlayerPlugin *plugin)
{
	RBSource *source = NULL;
	GType source_type = G_TYPE_NONE;
	RBShell *shell;
	RhythmDB *db;
	RhythmDBEntryType *entry_type;
	RhythmDBEntryType *error_type;
	RhythmDBEntryType *ignore_type;
	GtkBuilder *builder;
	GMenu *toolbar;
	GVolume *volume;
	GSettings *settings;
	const char *name_prefix;
	char *name;
	char *path;

	if (rb_psp_is_mount_player (mount, device_info)) {
		source_type = RB_TYPE_PSP_SOURCE;
		name_prefix = "psp";
	} else if (rb_nokia770_is_mount_player (mount, device_info)) {
		source_type = RB_TYPE_NOKIA770_SOURCE;
		name_prefix = "nokia770";
	} else if (rb_generic_player_is_mount_player (mount, device_info)) {
		source_type = RB_TYPE_GENERIC_PLAYER_SOURCE;
		name_prefix = "generic-player";
	} else {
		return NULL;
	}

	volume = g_mount_get_volume (mount);
	path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);

	g_object_get (plugin, "object", &shell, NULL);
	g_object_get (shell, "db", &db, NULL);

	name = g_strdup_printf ("%s: %s", name_prefix, path);
	entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
				   "db", db,
				   "name", name,
				   "save-to-disk", FALSE,
				   "category", RHYTHMDB_ENTRY_NORMAL,
				   NULL);
	rhythmdb_register_entry_type (db, entry_type);
	g_free (name);

	name = g_strdup_printf ("%s (ignore): %s", name_prefix, path);
	ignore_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
				    "db", db,
				    "name", name,
				    "save-to-disk", FALSE,
				    "category", RHYTHMDB_ENTRY_VIRTUAL,
				    NULL);
	rhythmdb_register_entry_type (db, ignore_type);
	g_free (name);

	name = g_strdup_printf ("%s (errors): %s", name_prefix, path);
	error_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
				   "db", db,
				   "name", name,
				   "save-to-disk", FALSE,
				   "category", RHYTHMDB_ENTRY_VIRTUAL,
				   NULL);
	rhythmdb_register_entry_type (db, error_type);
	g_free (name);

	g_object_unref (db);

	builder = rb_builder_load_plugin_file (G_OBJECT (plugin), "generic-player-toolbar.ui", NULL);
	toolbar = G_MENU (gtk_builder_get_object (builder, "generic-player-toolbar"));
	rb_application_link_shared_menus (RB_APPLICATION (g_application_get_default ()), toolbar);

	settings = g_settings_new ("org.gnome.rhythmbox.plugins.generic-player");

	source = RB_SOURCE (g_object_new (source_type,
					  "plugin", plugin,
					  "entry-type", entry_type,
					  "ignore-entry-type", ignore_type,
					  "error-entry-type", error_type,
					  "mount", mount,
					  "shell", shell,
					  "device-info", device_info,
					  "load-status", RB_SOURCE_LOAD_STATUS_LOADING,
					  "settings", g_settings_get_child (settings, "source"),
					  "encoding-settings", g_settings_get_child (settings, "encoding"),
					  "toolbar-menu", toolbar,
					  NULL));

	g_object_unref (settings);
	g_object_unref (builder);

	rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);

	plugin->player_sources = g_list_prepend (plugin->player_sources, source);
	g_signal_connect_object (G_OBJECT (source),
				 "deleted", G_CALLBACK (rb_generic_player_plugin_source_deleted),
				 plugin, 0);

	g_object_unref (shell);
	return source;
}