summaryrefslogtreecommitdiff
path: root/src/audacious
diff options
context:
space:
mode:
authorJackson Doak (Noskcaj) <noskcaj@ubuntu.com>2014-02-16 17:42:21 +1100
committerJackson Doak (Noskcaj) <noskcaj@ubuntu.com>2014-02-16 17:42:21 +1100
commitb380f841f764543f477b658af25194c4d9f8a1eb (patch)
treeda7b318a1ab8ce408bba700186fbabdc5fdc7b10 /src/audacious
parentc423357c93592bfb48ee7edbfba8936f20987cf7 (diff)
Imported Upstream version 3.4.3
Diffstat (limited to 'src/audacious')
-rw-r--r--src/audacious/adder.c10
-rw-r--r--src/audacious/config.c8
-rw-r--r--src/audacious/playlist-files.c14
-rw-r--r--src/audacious/plugin-init.c8
-rw-r--r--src/audacious/ui_preferences.c176
-rw-r--r--src/audacious/ui_preferences.h9
-rw-r--r--src/audacious/util.c59
7 files changed, 61 insertions, 223 deletions
diff --git a/src/audacious/adder.c b/src/audacious/adder.c
index 4fd39e7..5d3a138 100644
--- a/src/audacious/adder.c
+++ b/src/audacious/adder.c
@@ -281,9 +281,6 @@ static void add_folder (char * filename, PlaylistFilterFunc filter,
return;
}
- if (unix_name[strlen (unix_name) - 1] == '/')
- unix_name[strlen (unix_name) - 1] = 0;
-
GList * files = NULL;
DIR * folder = opendir (unix_name);
if (! folder)
@@ -293,8 +290,7 @@ static void add_folder (char * filename, PlaylistFilterFunc filter,
while ((entry = readdir (folder)))
{
if (entry->d_name[0] != '.')
- files = g_list_prepend (files, g_strdup_printf ("%s"
- G_DIR_SEPARATOR_S "%s", unix_name, entry->d_name));
+ files = g_list_prepend (files, g_build_filename (unix_name, entry->d_name, NULL));
}
closedir (folder);
@@ -303,7 +299,11 @@ static void add_folder (char * filename, PlaylistFilterFunc filter,
while (files)
{
struct stat info;
+#ifdef S_ISLNK
+ if (lstat (files->data, & info) < 0)
+#else
if (stat (files->data, & info) < 0)
+#endif
goto NEXT;
if (S_ISREG (info.st_mode))
diff --git a/src/audacious/config.c b/src/audacious/config.c
index 8b1a06b..c40de94 100644
--- a/src/audacious/config.c
+++ b/src/audacious/config.c
@@ -98,12 +98,6 @@ static GHashTable * defaults;
static GKeyFile * keyfile;
static bool_t modified;
-/* str_unref() may be a macro */
-static void str_unref_cb (void * str)
-{
- str_unref (str);
-}
-
void config_load (void)
{
g_return_if_fail (! defaults && ! keyfile);
@@ -200,7 +194,7 @@ void config_set_defaults (const char * section, const char * const * entries)
GHashTable * table = g_hash_table_lookup (defaults, section);
if (! table)
{
- table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, str_unref_cb);
+ table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) str_unref);
g_hash_table_replace (defaults, g_strdup (section), table);
}
diff --git a/src/audacious/playlist-files.c b/src/audacious/playlist-files.c
index 6943dae..795042e 100644
--- a/src/audacious/playlist-files.c
+++ b/src/audacious/playlist-files.c
@@ -47,10 +47,9 @@ static PluginHandle * get_plugin (const char * filename, bool_t saving)
if (! plugin)
{
- char * error = str_printf (_("Cannot %s %s: unsupported file "
- "extension."), saving ? _("save") : _("load"), filename);
+ SPRINTF (error, _("Cannot %s %s: unsupported file extension."),
+ saving ? _("save") : _("load"), filename);
interface_show_error (error);
- str_unref (error);
return NULL;
}
@@ -127,7 +126,14 @@ bool_t playlist_save (int list, const char * filename)
return FALSE;
PlaylistPlugin * pp = plugin_get_header (plugin);
- g_return_val_if_fail (pp && PLUGIN_HAS_FUNC (pp, load), FALSE);
+ g_return_val_if_fail (pp, FALSE);
+
+ if (! PLUGIN_HAS_FUNC (pp, save))
+ {
+ SPRINTF (error, _("Cannot save %s: plugin does not support saving."), filename);
+ interface_show_error (error);
+ return FALSE;
+ }
bool_t fast = get_bool (NULL, "metadata_on_play");
diff --git a/src/audacious/plugin-init.c b/src/audacious/plugin-init.c
index fcfccf6..0992bf5 100644
--- a/src/audacious/plugin-init.c
+++ b/src/audacious/plugin-init.c
@@ -220,6 +220,8 @@ static bool_t enable_single (int type, PluginHandle * p)
{
PluginHandle * old = table[type].u.s.get_current ();
+ plugin_misc_cleanup (old);
+
AUDDBG ("Switching from %s to %s.\n", plugin_get_name (old),
plugin_get_name (p));
plugin_set_enabled (old, FALSE);
@@ -243,6 +245,9 @@ static bool_t enable_single (int type, PluginHandle * p)
static bool_t enable_multi (int type, PluginHandle * p, bool_t enable)
{
+ if (! enable)
+ plugin_misc_cleanup (p);
+
AUDDBG ("%sabling %s.\n", enable ? "En" : "Dis", plugin_get_name (p));
plugin_set_enabled (p, enable);
@@ -269,9 +274,6 @@ bool_t plugin_enable (PluginHandle * plugin, bool_t enable)
if (! enable == ! plugin_get_enabled (plugin))
return TRUE;
- if (! enable)
- plugin_misc_cleanup (plugin);
-
int type = plugin_get_type (plugin);
if (table[type].is_single)
diff --git a/src/audacious/ui_preferences.c b/src/audacious/ui_preferences.c
index 6599b5c..96dab5b 100644
--- a/src/audacious/ui_preferences.c
+++ b/src/audacious/ui_preferences.c
@@ -112,15 +112,6 @@ static ComboBoxElements bitdepth_elements[] = {
{GINT_TO_POINTER (0), N_("Floating point")},
};
-typedef struct {
- void *next;
- GtkWidget *container;
- const char * pg_name;
- const char * img_url;
-} CategoryQueueEntry;
-
-CategoryQueueEntry *category_queue = NULL;
-
static void * create_output_plugin_box (void);
static void output_bit_depth_changed (void);
@@ -243,8 +234,6 @@ static const char * const titlestring_preset_names[TITLESTRING_NPRESETS] = {
N_("ARTIST [ ALBUM ] - TRACK. TITLE"),
N_("ALBUM - TITLE")};
-static void prefswin_page_queue_destroy(CategoryQueueEntry *ent);
-
static void
change_category(GtkNotebook * notebook,
GtkTreeSelection * selection)
@@ -261,14 +250,6 @@ change_category(GtkNotebook * notebook,
}
static void
-editable_insert_text(GtkEditable * editable,
- const char * text,
- int * pos)
-{
- gtk_editable_insert_text(editable, text, strlen(text), pos);
-}
-
-static void
titlestring_tag_menu_callback(GtkMenuItem * menuitem,
void * data)
{
@@ -279,12 +260,10 @@ titlestring_tag_menu_callback(GtkMenuItem * menuitem,
pos = gtk_editable_get_position(GTK_EDITABLE(titlestring_entry));
/* insert separator as needed */
- if (g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(titlestring_entry)), -1) > 0)
- editable_insert_text(GTK_EDITABLE(titlestring_entry), separator, &pos);
-
- editable_insert_text(GTK_EDITABLE(titlestring_entry), _(title_field_tags[item].tag),
- &pos);
+ if (gtk_entry_get_text(GTK_ENTRY(titlestring_entry))[0])
+ gtk_editable_insert_text(GTK_EDITABLE(titlestring_entry), separator, -1, &pos);
+ gtk_editable_insert_text(GTK_EDITABLE(titlestring_entry), _(title_field_tags[item].tag), -1, &pos);
gtk_editable_set_position(GTK_EDITABLE(titlestring_entry), pos);
}
@@ -450,7 +429,6 @@ static void fill_category_list (GtkTreeView * treeview, GtkNotebook * notebook)
GtkTreeSelection *selection;
GtkTreeIter iter;
GdkPixbuf *img;
- CategoryQueueEntry *qlist;
int i;
column = gtk_tree_view_column_new();
@@ -493,18 +471,6 @@ static void fill_category_list (GtkTreeView * treeview, GtkNotebook * notebook)
g_signal_connect_swapped(selection, "changed",
G_CALLBACK(change_category), notebook);
-
- /* mark the treeview widget as available to third party plugins */
- category_treeview = GTK_WIDGET(treeview);
-
- /* prefswin_page_queue_destroy already pops the queue forward for us. */
- for (qlist = category_queue; qlist != NULL; qlist = category_queue)
- {
- CategoryQueueEntry *ent = (CategoryQueueEntry *) qlist;
-
- prefswin_page_new(ent->container, ent->pg_name, ent->img_url);
- prefswin_page_queue_destroy(ent);
- }
}
static void on_radio_button_toggled (GtkWidget * button, const PreferencesWidget * widget)
@@ -1251,8 +1217,7 @@ prefswin_destroy(GtkWidget *window, GdkEvent *event, void * data)
return TRUE;
}
-/* GtkWidget * * create_prefs_window (void) */
-void * * create_prefs_window (void)
+static void create_prefs_window (void)
{
char *aud_version_string;
@@ -1349,8 +1314,6 @@ void * * create_prefs_window (void)
gtk_label_set_markup( GTK_LABEL(audversionlabel) , aud_version_string );
g_free(aud_version_string);
gtk_widget_show_all(vbox);
-
- return & prefswin;
}
void
@@ -1367,137 +1330,8 @@ void show_prefs_window (void)
gtk_window_present ((GtkWindow *) prefswin);
}
-void
-hide_prefs_window(void)
+void hide_prefs_window (void)
{
g_return_if_fail(prefswin);
gtk_widget_hide(GTK_WIDGET(prefswin));
}
-
-static void prefswin_page_queue_new (GtkWidget * container, const char * name,
- const char * imgurl)
-{
- CategoryQueueEntry *ent = g_new0(CategoryQueueEntry, 1);
-
- ent->container = container;
- ent->pg_name = name;
- ent->img_url = imgurl;
-
- if (category_queue)
- ent->next = category_queue;
-
- category_queue = ent;
-}
-
-static void
-prefswin_page_queue_destroy(CategoryQueueEntry *ent)
-{
- category_queue = ent->next;
- g_free(ent);
-}
-
-/*
- * Public APIs for adding new pages to the prefs window.
- *
- * Basically, the concept here is that third party components can register themselves in the root
- * preferences window.
- *
- * From a usability standpoint this makes the application look more "united", instead of cluttered
- * and malorganised. Hopefully this option will be used further in the future.
- *
- * - nenolod
- */
-/* int prefswin_page_new (GtkWidget * container, const char * name,
- const char * imgurl) */
-int prefswin_page_new (void * container, const char * name, const char *
- imgurl)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GdkPixbuf *img = NULL;
- GtkTreeView *treeview = GTK_TREE_VIEW(category_treeview);
- int id;
-
- if (treeview == NULL || category_notebook == NULL)
- {
- prefswin_page_queue_new(container, name, imgurl);
- return -1;
- }
-
- model = gtk_tree_view_get_model(treeview);
-
- if (model == NULL)
- {
- prefswin_page_queue_new(container, name, imgurl);
- return -1;
- }
-
- /* Make sure the widgets are visible. */
- gtk_widget_show(container);
- id = gtk_notebook_append_page(GTK_NOTEBOOK(category_notebook), container, NULL);
-
- if (id == -1)
- return -1;
-
- if (imgurl != NULL)
- img = gdk_pixbuf_new_from_file(imgurl, NULL);
-
- gtk_list_store_append(GTK_LIST_STORE(model), &iter);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter,
- CATEGORY_VIEW_COL_ICON, img,
- CATEGORY_VIEW_COL_NAME,
- name, CATEGORY_VIEW_COL_ID, id, -1);
-
- if (img != NULL)
- g_object_unref(img);
-
- return id;
-}
-
-void
-prefswin_page_destroy(GtkWidget *container)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeView *treeview = GTK_TREE_VIEW(category_treeview);
- bool_t ret;
- int id;
- int index = -1;
-
- if (category_notebook == NULL || treeview == NULL || container == NULL)
- return;
-
- id = gtk_notebook_page_num(GTK_NOTEBOOK(category_notebook), container);
-
- if (id == -1)
- return;
-
- gtk_notebook_remove_page(GTK_NOTEBOOK(category_notebook), id);
-
- model = gtk_tree_view_get_model(treeview);
-
- if (model == NULL)
- return;
-
- ret = gtk_tree_model_get_iter_first(model, &iter);
-
- while (ret == TRUE)
- {
- gtk_tree_model_get(model, &iter, CATEGORY_VIEW_COL_ID, &index, -1);
-
- if (index == id)
- {
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- ret = gtk_tree_model_get_iter_first(model, &iter);
- continue;
- }
-
- if (index > id)
- {
- index--;
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, CATEGORY_VIEW_COL_ID, index, -1);
- }
-
- ret = gtk_tree_model_iter_next(model, &iter);
- }
-}
diff --git a/src/audacious/ui_preferences.h b/src/audacious/ui_preferences.h
index 408fb50..ab91f1b 100644
--- a/src/audacious/ui_preferences.h
+++ b/src/audacious/ui_preferences.h
@@ -24,18 +24,9 @@
#include "preferences.h"
-/* GtkWidget * * create_prefs_window (void); */
-void * * create_prefs_window (void);
-void destroy_prefs_window(void);
void show_prefs_window(void);
void hide_prefs_window(void);
-/* int prefswin_page_new (GtkWidget * container, const char * name,
- const char * imgurl); */
-int prefswin_page_new (void * container, const char * name, const char *
- imgurl);
-void prefswin_page_destroy(GtkWidget *container);
-
/* plugin-preferences.c */
void plugin_make_about_window (PluginHandle * plugin);
void plugin_make_config_window (PluginHandle * plugin);
diff --git a/src/audacious/util.c b/src/audacious/util.c
index dd960b7..37455b5 100644
--- a/src/audacious/util.c
+++ b/src/audacious/util.c
@@ -211,40 +211,45 @@ char * get_path_to_self (void)
#endif
}
-/* Strips various common top-level folders from a URI. The string passed will
- * not be modified, but the string returned will share the same memory.
+/* Strips various common top-level folders from a filename. The string passed
+ * will not be modified, but the string returned will share the same memory.
* Examples:
- * "file:///home/john/folder/file.mp3" -> "folder/file.mp3"
- * "file:///folder/file.mp3" -> "folder/file.mp3" */
+ * "/home/john/folder/file.mp3" -> "folder/file.mp3"
+ * "/folder/file.mp3" -> "folder/file.mp3" */
static char * skip_top_folders (char * name)
{
- static char * home;
+ static const char * home;
static int len;
if (! home)
{
- home = filename_to_uri (g_get_home_dir ());
+ home = g_get_home_dir ();
len = strlen (home);
- if (len > 0 && home[len - 1] == '/')
+ if (len > 0 && home[len - 1] == G_DIR_SEPARATOR)
len --;
}
#ifdef _WIN32
- if (! g_ascii_strncasecmp (name, home, len) && name[len] == '/')
+ if (! g_ascii_strncasecmp (name, home, len) && name[len] == '\\')
#else
if (! strncmp (name, home, len) && name[len] == '/')
#endif
return name + len + 1;
- if (! strncmp (name, "file:///", 8))
- return name + 8;
+#ifdef _WIN32
+ if (g_ascii_isalpha (name[0]) && name[1] == ':' && name[2] == '\\')
+ return name + 3;
+#else
+ if (name[0] == '/')
+ return name + 1;
+#endif
return name;
}
-/* Divides a URI into the base name, the lowest folder, and the
+/* Divides a filename into the base name, the lowest folder, and the
* second lowest folder. The string passed will be modified, and the strings
* returned will use the same memory. May return NULL for <first> and <second>.
* Examples:
@@ -259,7 +264,7 @@ static void split_filename (char * name, char * * base, char * * first,
char * c;
- if ((c = strrchr (name, '/')))
+ if ((c = strrchr (name, G_DIR_SEPARATOR)))
{
* base = c + 1;
* c = 0;
@@ -270,7 +275,7 @@ static void split_filename (char * name, char * * base, char * * first,
goto DONE;
}
- if ((c = strrchr (name, '/')))
+ if ((c = strrchr (name, G_DIR_SEPARATOR)))
{
* first = c + 1;
* c = 0;
@@ -281,7 +286,7 @@ static void split_filename (char * name, char * * base, char * * first,
goto DONE;
}
- if ((c = strrchr (name, '/')))
+ if ((c = strrchr (name, G_DIR_SEPARATOR)))
* second = c + 1;
else
* second = name;
@@ -364,16 +369,17 @@ DONE:
return;
}
- char buf[strlen (name) + 1];
- memcpy (buf, name, sizeof buf);
-
- if (! strncmp (buf, "file:///", 8))
+ if (! strncmp (name, "file:///", 8))
{
+ char * filename = uri_to_display (name);
+ if (! filename)
+ goto DONE;
+
char * base, * first, * second;
- split_filename (skip_top_folders (buf), & base, & first, & second);
+ split_filename (skip_top_folders (filename), & base, & first, & second);
if (! title)
- title = str_get_decoded (base);
+ title = str_get (base);
for (int i = 0; i < G_N_ELEMENTS (skip); i ++)
{
@@ -387,17 +393,22 @@ DONE:
{
if (second && ! artist && ! album)
{
- artist = str_get_decoded (second);
- album = str_get_decoded (first);
+ artist = str_get (second);
+ album = str_get (first);
}
else if (! artist)
- artist = str_get_decoded (first);
+ artist = str_get (first);
else if (! album)
- album = str_get_decoded (first);
+ album = str_get (first);
}
+
+ free (filename);
}
else
{
+ char buf[strlen (name) + 1];
+ strcpy (buf, name);
+
if (! title)
{
title = str_get_decoded (stream_name (buf));