Exemplo n.º 1
0
static void
pragha_scanner_import_playlist (PraghaDatabase *database,
                                const gchar *playlist_file)
{
	gchar *playlist = NULL;
	gint playlist_id = 0;
	GSList *list = NULL, *i = NULL;

	playlist = get_display_filename(playlist_file, FALSE);

	if (pragha_database_find_playlist(database, playlist))
		goto duplicated;

#ifdef HAVE_PLPARSER
	gchar *uri = g_filename_to_uri (playlist_file, NULL, NULL);
	list = pragha_totem_pl_parser_parse_from_uri(uri);
	g_free (uri);
#else
	list = pragha_pl_parser_parse_from_file_by_extension (playlist_file);
#endif

	playlist_id = pragha_database_add_new_playlist (database, playlist);
	if(list) {
		for (i=list; i != NULL; i = i->next) {
			pragha_database_add_playlist_track (database, playlist_id, i->data);
			g_free(i->data);
		}
		g_slist_free(list);
	}

duplicated:
	g_free(playlist);
}
Exemplo n.º 2
0
gchar* get_display_name(PraghaMusicobject *mobj)
{
	gchar *name = NULL;
	
	if (pragha_musicobject_get_file_type(mobj) == FILE_CDDA) {
		name = g_strdup(pragha_musicobject_get_file(mobj));
	} else {
		name = get_display_filename(pragha_musicobject_get_file(mobj), FALSE);
	}
	return name;
}
Exemplo n.º 3
0
gchar* get_display_name(PraghaMusicobject *mobj)
{
	gchar *name = NULL;
	
	if (!pragha_musicobject_is_local_file(mobj)) {
		name = g_strdup(pragha_musicobject_get_file(mobj));
	} else {
		name = get_display_filename(pragha_musicobject_get_file(mobj), FALSE);
	}
	return name;
}
Exemplo n.º 4
0
static void
directory_pressed (GtkEntry       *entry,
		gint            position,
		GdkEventButton *event,
		gchar *file)
{
	if (position == GTK_ENTRY_ICON_SECONDARY && file) {
		gchar *uri = get_display_filename(file, TRUE);
		open_url(NULL, uri);
		g_free(uri);
	}
}
Exemplo n.º 5
0
static void
pragha_filter_dialog_fill_model (GtkListStore *filter_model, PraghaPlaylist *cplaylist)
{
	GtkTreeIter filter_iter;
	PraghaMusicobject *mobj = NULL;
	gchar *ch_title = NULL, *ch_artist = NULL, *ch_album = NULL;
	const gchar *file, *title, *artist, *album;
	gchar *track_data_markup = NULL;
	gint track_i = 0;
	GList *list = NULL, *i;

	list = pragha_playlist_get_mobj_list(cplaylist);

	track_i = pragha_playlist_get_no_tracks(cplaylist);

	if(list != NULL) {
		for (i=list; i != NULL; i = i->next) {
			mobj = i->data;

			file = pragha_musicobject_get_file(mobj);
			title = pragha_musicobject_get_title(mobj);
			artist = pragha_musicobject_get_artist(mobj);
			album = pragha_musicobject_get_album(mobj);

			ch_title = string_is_not_empty(title) ?  g_strdup(title) : get_display_filename (file, FALSE);
			ch_artist = string_is_not_empty(artist) ? g_strdup(artist) : g_strdup(_("Unknown Artist"));
			ch_album = string_is_not_empty(album) ? g_strdup(album) : g_strdup(_("Unknown Album"));

			track_data_markup = g_markup_printf_escaped ("%s - %s - %s", ch_title, ch_artist, ch_album);

			if (track_data_markup != NULL) {
				gtk_list_store_prepend (filter_model, &filter_iter);
				gtk_list_store_set (filter_model, &filter_iter,
							0, track_i,
							1, track_data_markup,
							-1);
			}

			track_i--;

			g_free (ch_title);
			g_free (ch_artist);
			g_free (ch_album);
			g_free (track_data_markup);
		}
		g_list_free(list);
	}
}
Exemplo n.º 6
0
static void
popup_menu_open_folder (GtkMenuItem *menuitem, gpointer storage)
{
	GtkWidget *entry_file;
	const gchar *file;
	gchar *uri;

	entry_file = g_object_get_data (storage, "entry_file");
	struct con_win *cwin = g_object_get_data (storage, "cwin");

	file = gtk_entry_get_text (GTK_ENTRY(entry_file));
	uri = get_display_filename (file, TRUE);

	open_url (cwin, uri);
	g_free (uri);
}
Exemplo n.º 7
0
void
pragha_toolbar_set_title (PraghaToolbar *toolbar, PraghaMusicobject *mobj)
{
	gchar *str = NULL, *str_title = NULL;

	const gchar *file = pragha_musicobject_get_file (mobj);
	const gchar *title = pragha_musicobject_get_title (mobj);
	const gchar *artist = pragha_musicobject_get_artist (mobj);
	const gchar *album = pragha_musicobject_get_album (mobj);

	if(string_is_not_empty(title))
		str_title = g_strdup(title);
	else
		str_title = get_display_filename(file, FALSE);

	if(string_is_not_empty(artist) && string_is_not_empty(album))
		str = g_markup_printf_escaped (_("%s <small><span weight=\"light\">by</span></small> %s <small><span weight=\"light\">in</span></small> %s"),
		                               str_title,
		                               artist,
		                               album);
	else if(string_is_not_empty(artist))
		str = g_markup_printf_escaped (_("%s <small><span weight=\"light\">by</span></small> %s"),
		                                str_title,
		                                artist);
	else if(string_is_not_empty(album))
		str = g_markup_printf_escaped (_("%s <small><span weight=\"light\">in</span></small> %s"),
		                                str_title,
		                                album);
	else
		str = g_markup_printf_escaped("%s", str_title);

	gtk_label_set_markup(GTK_LABEL(toolbar->now_playing_label), str);

	g_free(str_title);
	g_free(str);
}