[Goodies-commits] r6837 - in xfmpc/trunk: . src
Vincent Legout
vincent at xfce.org
Tue Mar 3 18:48:48 CET 2009
Author: vincent
Date: 2009-03-03 17:48:48 +0000 (Tue, 03 Mar 2009)
New Revision: 6837
Modified:
xfmpc/trunk/ChangeLog
xfmpc/trunk/src/dbbrowser.c
xfmpc/trunk/src/main.c
xfmpc/trunk/src/mpdclient.c
xfmpc/trunk/src/playlist.c
xfmpc/trunk/src/preferences-dialog.c
xfmpc/trunk/src/preferences.c
xfmpc/trunk/src/preferences.h
Log:
New options to choose the song format
Modified: xfmpc/trunk/ChangeLog
===================================================================
--- xfmpc/trunk/ChangeLog 2009-03-03 16:51:03 UTC (rev 6836)
+++ xfmpc/trunk/ChangeLog 2009-03-03 17:48:48 UTC (rev 6837)
@@ -1,3 +1,27 @@
+2009-03-03 Vincent Legout <vincent at legout.info>
+
+New options to choose the song format
+ * src/preferences.c, src/preferences.h:
+ - Update copyright date
+ - New XfmpcSongFormat type
+ - Add song-format property
+ - Add song-format-custom property
+ * src/preferences-dialog.c:
+ - Update the dialog with a new combobox and a new entry to choose the
+ song format
+ - Add a timeout on entry changes to update the custom song format
+ * src/mpdclient.c:
+ - Update copyright information
+ - Update _get_formatted_name to use the new XfmpcSongFormat
+ - New functions _get_formatted_name_predefined and
+ _get_formatted_name_custom used by _get_formatted_name
+ * src/dbbrowser.c:
+ - Update the dbbrowser if the song format has changed
+ * src/playlist.c:
+ - Update the playlist if the song format has changed
+ * src/main.c:
+ - New function transform_string_to_enum
+
2009-03-01 Vincent Legout <vincent at legout.info>
New XfmpcMainWindow widget
Modified: xfmpc/trunk/src/dbbrowser.c
===================================================================
--- xfmpc/trunk/src/dbbrowser.c 2009-03-03 16:51:03 UTC (rev 6836)
+++ xfmpc/trunk/src/dbbrowser.c 2009-03-03 17:48:48 UTC (rev 6837)
@@ -267,6 +267,11 @@
G_CALLBACK (cb_search_entry_key_released), dbbrowser);
g_signal_connect_swapped (priv->search_entry, "changed",
G_CALLBACK (cb_search_entry_changed), dbbrowser);
+ /* Preferences */
+ g_signal_connect_swapped (dbbrowser->preferences, "notify::song-format",
+ G_CALLBACK (xfmpc_dbbrowser_reload), dbbrowser);
+ g_signal_connect_swapped (dbbrowser->preferences, "notify::song-format-custom",
+ G_CALLBACK (xfmpc_dbbrowser_reload), dbbrowser);
}
static void
Modified: xfmpc/trunk/src/main.c
===================================================================
--- xfmpc/trunk/src/main.c 2009-03-03 16:51:03 UTC (rev 6836)
+++ xfmpc/trunk/src/main.c 2009-03-03 17:48:48 UTC (rev 6837)
@@ -49,8 +49,28 @@
g_value_set_boolean (dst, (gboolean) strcmp (g_value_get_string (src), "FALSE") != 0);
}
+static void
+transform_string_to_enum (const GValue *src,
+ GValue *dst)
+{
+ GEnumClass *klass;
+ gint value = 0;
+ guint n;
+ klass = g_type_class_ref (G_VALUE_TYPE (dst));
+ for (n = 0; n < klass->n_values; ++n)
+ {
+ value = klass->values[n].value;
+ if (!g_ascii_strcasecmp (klass->values[n].value_name, g_value_get_string (src)))
+ break;
+ }
+ g_type_class_unref (klass);
+ g_value_set_enum (dst, value);
+}
+
+
+
int
main (int argc, char *argv[])
{
@@ -60,6 +80,7 @@
g_value_register_transform_func (G_TYPE_STRING, G_TYPE_INT, transform_string_to_int);
g_value_register_transform_func (G_TYPE_STRING, G_TYPE_BOOLEAN, transform_string_to_boolean);
+ g_value_register_transform_func (G_TYPE_STRING, G_TYPE_ENUM, transform_string_to_enum);
GtkWidget *window = xfmpc_main_window_new ();
gtk_widget_show_all (window);
Modified: xfmpc/trunk/src/mpdclient.c
===================================================================
--- xfmpc/trunk/src/mpdclient.c 2009-03-03 16:51:03 UTC (rev 6836)
+++ xfmpc/trunk/src/mpdclient.c 2009-03-03 17:48:48 UTC (rev 6837)
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008-2009 Mike Massonnet <mmassonnet at xfce.org>
+ * Copyright (c) 2009 Vincent Legout <vincent at xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -60,6 +61,10 @@
ChangedStatusType what,
gpointer user_data);
static gchar * _get_formatted_name (mpd_Song *song);
+static gchar * _get_formatted_name_predefined (mpd_Song *song,
+ XfmpcSongFormat song_format);
+static gchar * _get_formatted_name_custom (mpd_Song *song,
+ const gchar *format);
@@ -914,18 +919,219 @@
static gchar *
_get_formatted_name (mpd_Song *song)
{
+ XfmpcPreferences *preferences = xfmpc_preferences_get ();
+ XfmpcSongFormat song_format;
+ gchar *format_custom;
gchar *formatted_name;
- if (NULL != song->title)
+ g_object_get (preferences,
+ "song-format", &song_format,
+ "song-format-custom", &format_custom,
+ NULL);
+
+ if (NULL == song->title)
{
- if (song->artist)
- formatted_name = g_strdup_printf ("%s - %s", song->artist, song->title);
- else
- formatted_name = g_strdup (song->title);
+ formatted_name = g_path_get_basename (song->file);
}
+ else if (song_format == XFMPC_SONG_FORMAT_CUSTOM)
+ {
+ formatted_name = _get_formatted_name_custom (song, format_custom);
+ }
else
- formatted_name = g_path_get_basename (song->file);
+ {
+ formatted_name = _get_formatted_name_predefined (song, song_format);
+ }
+ g_free (format_custom);
return formatted_name;
}
+static gchar *
+_get_formatted_name_predefined (mpd_Song *song,
+ XfmpcSongFormat song_format)
+{
+ gchar *formatted_name, *tmp;
+
+ switch (song_format)
+ {
+ case XFMPC_SONG_FORMAT_TITLE:
+ formatted_name = g_strdup_printf ("%s", song->title);
+ break;
+
+ case XFMPC_SONG_FORMAT_ARTIST_TITLE:
+ if (NULL != song->artist)
+ {
+ formatted_name = g_strdup_printf ("%s - %s", song->artist, song->title);
+ }
+ else
+ {
+ formatted_name = g_strdup_printf ("%s", song->title);
+ }
+ break;
+
+ case XFMPC_SONG_FORMAT_ALBUM_TITLE:
+ if (NULL != song->album)
+ {
+ formatted_name = g_strdup_printf ("%s - %s", song->album, song->title);
+ }
+ else
+ {
+ formatted_name = g_strdup_printf ("%s", song->title);
+ }
+ break;
+
+ case XFMPC_SONG_FORMAT_ARTIST_TITLE_DATE:
+ if (NULL != song->artist && NULL != song->date)
+ {
+ formatted_name = g_strdup_printf ("%s - %s (%s)", song->artist, song->title, song->date);
+ }
+ else if (NULL != song->date)
+ {
+ formatted_name = g_strdup_printf ("%s (%s)", song->title, song->date);
+ }
+ else if (NULL != song->artist)
+ {
+ formatted_name = g_strdup_printf ("%s - %s", song->artist, song->title);
+ }
+ else
+ {
+ formatted_name = g_strdup_printf ("%s", song->title);
+ }
+ break;
+
+ case XFMPC_SONG_FORMAT_ARTIST_ALBUM_TITLE:
+ if (NULL != song->artist && NULL != song->album)
+ {
+ formatted_name = g_strdup_printf ("%s - %s - %s", song->artist, song->album, song->title);
+ }
+ else if (NULL != song->album)
+ {
+ formatted_name = g_strdup_printf ("%s - %s", song->album, song->title);
+ }
+ else if (NULL != song->artist)
+ {
+ formatted_name = g_strdup_printf ("%s - %s", song->artist, song->title);
+ }
+ else
+ {
+ formatted_name = g_strdup_printf ("%s", song->title);
+ }
+ break;
+
+ case XFMPC_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE:
+ formatted_name = g_strdup ("");
+
+ if (song->artist != NULL)
+ {
+ tmp = g_strconcat (formatted_name, song->artist, " - ", NULL);
+ g_free (formatted_name);
+ formatted_name = tmp;
+ }
+
+ if (song->album != NULL)
+ {
+ tmp = g_strconcat (formatted_name, song->album, " - ", NULL);
+ g_free (formatted_name);
+ formatted_name = tmp;
+ }
+
+ if (song->track != NULL)
+ {
+ tmp = g_strconcat (formatted_name, song->track, ". ", NULL);
+ g_free (formatted_name);
+ formatted_name = tmp;
+ }
+
+ tmp = g_strconcat (formatted_name, song->title, NULL);
+ g_free (formatted_name);
+ formatted_name = tmp;
+ break;
+
+ default:
+ g_critical ("Unsupported song format (%d)", song_format);
+ formatted_name = g_path_get_basename (song->file);
+ break;
+ }
+
+ return formatted_name;
+}
+
+static gchar *
+_get_formatted_name_custom (mpd_Song *song,
+ const gchar *format)
+{
+ gchar *formatted_name, *tmp;
+
+ g_return_val_if_fail (G_LIKELY (format != NULL), NULL);
+
+ formatted_name = g_strdup ("");
+
+ do
+ {
+ if (*format == '%')
+ {
+ format ++;
+
+ switch (*(format))
+ {
+ case 'a':
+ if (song->artist)
+ tmp = g_strconcat (formatted_name, song->artist, NULL);
+ break;
+
+ case 'A':
+ if (song->album)
+ tmp = g_strconcat (formatted_name, song->album, NULL);
+ break;
+
+ case 'd':
+ if (song->date)
+ tmp = g_strconcat (formatted_name, song->date, NULL);
+ break;
+
+ case 'D':
+ if (song->disc)
+ tmp = g_strconcat (formatted_name, song->disc, NULL);
+ break;
+
+ case 'f':
+ if (song->file)
+ tmp = g_strconcat (formatted_name, song->file, NULL);
+ break;
+
+ case 'g':
+ if (song->genre)
+ tmp = g_strconcat (formatted_name, song->genre, NULL);
+ break;
+
+ case 't':
+ if (song->title)
+ tmp = g_strconcat (formatted_name, song->title, NULL);
+ break;
+
+ case 'T':
+ if (song->track)
+ tmp = g_strconcat (formatted_name, song->track, NULL);
+ break;
+
+ default:
+ tmp = g_strconcat (formatted_name, "%", NULL);
+ format --;
+ break;
+ }
+
+ g_free (formatted_name);
+ formatted_name = tmp;
+ }
+ else
+ {
+ tmp = g_strdup_printf ("%s%c", formatted_name, *format);
+ g_free (formatted_name);
+ formatted_name = tmp;
+ }
+ }
+ while (*format ++);
+
+ return formatted_name;
+}
+
Modified: xfmpc/trunk/src/playlist.c
===================================================================
--- xfmpc/trunk/src/playlist.c 2009-03-03 16:51:03 UTC (rev 6836)
+++ xfmpc/trunk/src/playlist.c 2009-03-03 17:48:48 UTC (rev 6837)
@@ -258,6 +258,12 @@
G_CALLBACK (cb_filter_entry_key_released), playlist);
g_signal_connect_swapped (priv->filter_entry, "changed",
G_CALLBACK (cb_filter_entry_changed), playlist);
+
+ /* Preferences */
+ g_signal_connect_swapped (playlist->preferences, "notify::song-format",
+ G_CALLBACK (cb_playlist_changed), playlist);
+ g_signal_connect_swapped (playlist->preferences, "notify::song-format-custom",
+ G_CALLBACK (cb_playlist_changed), playlist);
}
static void
Modified: xfmpc/trunk/src/preferences-dialog.c
===================================================================
--- xfmpc/trunk/src/preferences-dialog.c 2009-03-03 16:51:03 UTC (rev 6836)
+++ xfmpc/trunk/src/preferences-dialog.c 2009-03-03 17:48:48 UTC (rev 6837)
@@ -51,8 +51,17 @@
static void cb_show_statusbar_toggled (GtkToggleButton *button,
XfmpcPreferencesDialog *dialog);
+static void cb_format_entry_activated (XfmpcPreferencesDialog *dialog);
+static void cb_format_entry_changed (GtkEntry *entry,
+ XfmpcPreferencesDialog *dialog);
+static void cb_format_combo_changed (GtkComboBox *combo,
+ XfmpcPreferencesDialog *dialog);
+static gboolean timeout_format (XfmpcPreferencesDialog *dialog);
+static void timeout_format_destroy (XfmpcPreferencesDialog *dialog);
+
+
struct _XfmpcPreferencesDialogClass
{
XfceTitledDialogClass parent_class;
@@ -68,11 +77,16 @@
struct _XfmpcPreferencesDialogPrivate
{
- GtkWidget *entry_use_defaults;
- GtkWidget *entry_host;
- GtkWidget *entry_port;
- GtkWidget *entry_passwd;
- GtkWidget *statusbar_button;
+ GtkWidget *entry_use_defaults;
+ GtkWidget *entry_host;
+ GtkWidget *entry_port;
+ GtkWidget *entry_passwd;
+ GtkWidget *statusbar_button;
+ GtkWidget *entry_format;
+ GtkWidget *combo_format;
+
+ guint format_timeout;
+ gboolean is_format;
};
@@ -138,11 +152,14 @@
GtkWidget *frame;
GtkWidget *label;
GtkWidget *button;
+ GtkWidget *table;
gchar *host, *passwd;
guint port;
gboolean use_defaults;
gboolean statusbar;
+ XfmpcSongFormat song_format;
+ gchar *format_custom;
dialog->preferences = xfmpc_preferences_get ();
@@ -152,6 +169,8 @@
"mpd-password", &passwd,
"mpd-use-defaults", &use_defaults,
"show-statusbar", &statusbar,
+ "song-format", &song_format,
+ "song-format-custom", &format_custom,
NULL);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
@@ -247,10 +266,103 @@
G_CALLBACK (cb_show_statusbar_toggled), dialog);
gtk_container_add (GTK_CONTAINER (vbox2), priv->statusbar_button);
+ vbox2 = gtk_vbox_new (FALSE, 6);
+ frame = xfce_create_framebox_with_content (_("Song Format"), vbox2);
+ gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 2);
+
+ label = gtk_label_new (_("Song format:"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ priv->combo_format = gtk_combo_box_new_text ();
+ gtk_box_pack_start (GTK_BOX (hbox), priv->combo_format, TRUE, TRUE, 0);
+
+ gint i;
+ GEnumClass *klass = g_type_class_ref (XFMPC_TYPE_SONG_FORMAT);
+ for (i = 0; i < klass->n_values; i++)
+ {
+ gtk_combo_box_append_text (GTK_COMBO_BOX (priv->combo_format),
+ _(klass->values[i].value_nick));
+ }
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combo_format), song_format);
+ g_type_class_unref (klass);
+
+ gtk_container_add (GTK_CONTAINER (vbox2), hbox);
+
+ hbox = gtk_hbox_new (FALSE, 2);
+
+ label = gtk_label_new (_("Custom format:"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ priv->entry_format = gtk_entry_new ();
+ gtk_entry_set_width_chars (GTK_ENTRY (priv->entry_format), 15);
+ gtk_entry_set_max_length (GTK_ENTRY (priv->entry_format), 30);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry_format), format_custom);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->entry_format, TRUE, TRUE, 0);
+ g_signal_connect (priv->entry_format, "changed",
+ G_CALLBACK (cb_format_entry_changed), dialog);
+ g_signal_connect (priv->combo_format, "changed",
+ G_CALLBACK (cb_format_combo_changed), dialog);
+ gtk_widget_set_sensitive (priv->entry_format,
+ song_format == XFMPC_SONG_FORMAT_CUSTOM);
+
+ gtk_container_add (GTK_CONTAINER (vbox2), hbox);
+
+ label = gtk_label_new (_("Available parameters:"));
+ gtk_container_add (GTK_CONTAINER (vbox2), label);
+
+ table = gtk_table_new (4, 6, TRUE);
+
+ PangoAttrList *attrs = pango_attr_list_new ();
+ PangoAttribute *attr = pango_attr_scale_new (PANGO_SCALE_SMALL);
+ pango_attr_list_insert (attrs, attr);
+
+ label = gtk_label_new (_("%a: Artist"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 3, 0, 1);
+ label = gtk_label_new (_("%A: Album"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 6, 0, 1);
+
+ label = gtk_label_new (_("%d: Date"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 3, 1, 2);
+ label = gtk_label_new (_("%D: Disc"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 6, 1, 2);
+
+ label = gtk_label_new (_("%f: File"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 3, 2, 3);
+ label = gtk_label_new (_("%g: Genre"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 6, 2, 3);
+
+ label = gtk_label_new (_("%t: Title"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 3, 3, 4);
+ label = gtk_label_new (_("%T: Track"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 6, 3, 4);
+
+ pango_attr_list_unref (attrs);
+
+ gtk_container_add (GTK_CONTAINER (vbox2), table);
+
gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
g_free (host);
g_free (passwd);
+ g_free (format_custom);
}
static void
@@ -258,7 +370,7 @@
{
XfmpcPreferencesDialog *dialog = XFMPC_PREFERENCES_DIALOG (object);
g_object_unref (G_OBJECT (dialog->preferences));
- (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -267,6 +379,18 @@
xfmpc_preferences_dialog_response (GtkDialog *dialog,
gint response)
{
+ XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
+ XfmpcPreferences *preferences = XFMPC_PREFERENCES_DIALOG (dialog)->preferences;
+
+ if (priv->format_timeout > 0)
+ {
+ g_source_remove (priv->format_timeout);
+
+ g_object_set (G_OBJECT (preferences),
+ "song-format-custom", gtk_entry_get_text (GTK_ENTRY (priv->entry_format)),
+ NULL);
+ }
+
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -316,3 +440,60 @@
NULL);
}
+static void
+cb_format_entry_activated (XfmpcPreferencesDialog *dialog)
+{
+ XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
+ const gchar *entry_text = gtk_entry_get_text (GTK_ENTRY (priv->entry_format));
+
+ if (entry_text[0] == '\0')
+ {
+ priv->is_format = FALSE;
+ }
+
+ g_object_set (G_OBJECT (dialog->preferences),
+ "song-format-custom", gtk_entry_get_text (GTK_ENTRY (priv->entry_format)),
+ NULL);
+}
+
+static void
+cb_format_entry_changed (GtkEntry *entry,
+ XfmpcPreferencesDialog *dialog)
+{
+ XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
+
+ if (priv->format_timeout > 0)
+ g_source_remove (priv->format_timeout);
+
+ priv->format_timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 1,
+ (GSourceFunc)timeout_format, dialog,
+ (GDestroyNotify)timeout_format_destroy);
+}
+
+static void
+cb_format_combo_changed (GtkComboBox *combo,
+ XfmpcPreferencesDialog *dialog)
+{
+ XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
+ XfmpcSongFormat song_format;
+
+ song_format = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->combo_format));
+ g_object_set (G_OBJECT (dialog->preferences), "song-format", song_format, NULL);
+
+ gtk_widget_set_sensitive (priv->entry_format, song_format == XFMPC_SONG_FORMAT_CUSTOM);
+}
+
+static gboolean
+timeout_format (XfmpcPreferencesDialog *dialog)
+{
+ cb_format_entry_activated (dialog);
+ return FALSE;
+}
+
+static void
+timeout_format_destroy (XfmpcPreferencesDialog *dialog)
+{
+ XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
+ priv->format_timeout = 0;
+}
+
Modified: xfmpc/trunk/src/preferences.c
===================================================================
--- xfmpc/trunk/src/preferences.c 2009-03-03 16:51:03 UTC (rev 6836)
+++ xfmpc/trunk/src/preferences.c 2009-03-03 17:48:48 UTC (rev 6837)
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008-2009 Mike Massonnet <mmassonnet at xfce.org>
+ * Copyright (c) 2009 Vincent Legout <vincent at xfce.org>
*
* Based on ThunarPreferences:
* Copyright (c) 2005-2007 Benedikt Meurer <benny at xfce.org>
@@ -30,6 +31,30 @@
+/* Enum types */
+GType
+xfmpc_song_format_get_type ()
+{
+ static GType type = G_TYPE_INVALID;
+
+ static const GEnumValue values[] = {
+ { XFMPC_SONG_FORMAT_TITLE, "XFMPC_SONG_FORMAT_TITLE", N_("Title"), },
+ { XFMPC_SONG_FORMAT_ARTIST_TITLE, "XFMPC_SONG_FORMAT_ARTIST_TITLE", N_("Artist - Title"), },
+ { XFMPC_SONG_FORMAT_ALBUM_TITLE, "XFMPC_SONG_FORMAT_ALBUM_TITLE", N_("Album - Title"), },
+ { XFMPC_SONG_FORMAT_ARTIST_TITLE_DATE, "XFMPC_SONG_FORMAT_ARTIST_TITLE_DATE", N_("Artist - Title (Date)"), },
+ { XFMPC_SONG_FORMAT_ARTIST_ALBUM_TITLE, "XFMPC_SONG_FORMAT_ARTIST_ALBUM_TITLE", N_("Artist - Album - Title"), },
+ { XFMPC_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE, "XFMPC_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE", N_("Artist - Album - Track. Title"), },
+ { XFMPC_SONG_FORMAT_CUSTOM, "XFMPC_SONG_FORMAT_CUSTOM", N_("Custom"), },
+ { 0, NULL, NULL },
+ };
+
+ if (type != G_TYPE_INVALID)
+ return type;
+
+ type = g_enum_register_static ("XfmpcSongFormat", values);
+ return type;
+}
+
/* Property identifiers */
enum
{
@@ -46,6 +71,8 @@
PROP_MPD_PASSWORD,
PROP_MPD_USE_DEFAULTS,
PROP_SHOW_STATUSBAR,
+ PROP_SONG_FORMAT,
+ PROP_SONG_FORMAT_CUSTOM,
N_PROPERTIES,
};
@@ -223,6 +250,23 @@
"Show the statusbar",
TRUE,
G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_SONG_FORMAT,
+ g_param_spec_enum ("song-format",
+ "SongFormat",
+ "Song Format",
+ XFMPC_TYPE_SONG_FORMAT,
+ XFMPC_SONG_FORMAT_ARTIST_TITLE,
+ G_PARAM_CONSTRUCT|G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_SONG_FORMAT_CUSTOM,
+ g_param_spec_string ("song-format-custom",
+ "SongFormatCustom",
+ "Custom Song Format",
+ "\%a - \%t",
+ G_PARAM_READWRITE));
}
static void
Modified: xfmpc/trunk/src/preferences.h
===================================================================
--- xfmpc/trunk/src/preferences.h 2009-03-03 16:51:03 UTC (rev 6836)
+++ xfmpc/trunk/src/preferences.h 2009-03-03 17:48:48 UTC (rev 6837)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 Mike Massonnet <mmassonnet at xfce.org>
+ * Copyright (c) 2008-2009 Mike Massonnet <mmassonnet at xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +21,19 @@
G_BEGIN_DECLS
+typedef enum
+{
+ XFMPC_SONG_FORMAT_TITLE,
+ XFMPC_SONG_FORMAT_ARTIST_TITLE,
+ XFMPC_SONG_FORMAT_ALBUM_TITLE,
+ XFMPC_SONG_FORMAT_ARTIST_TITLE_DATE,
+ XFMPC_SONG_FORMAT_ARTIST_ALBUM_TITLE,
+ XFMPC_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE,
+ XFMPC_SONG_FORMAT_CUSTOM,
+} XfmpcSongFormat;
+GType xfmpc_song_format_get_type () G_GNUC_CONST;
+#define XFMPC_TYPE_SONG_FORMAT (xfmpc_song_format_get_type ())
+
#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type())
#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
More information about the Goodies-commits
mailing list