[Goodies-commits] r7600 - in xfmpc/trunk: . src
Vincent Legout
vincent at xfce.org
Tue Jun 16 21:25:03 CEST 2009
Author: vincent
Date: 2009-06-16 19:25:03 +0000 (Tue, 16 Jun 2009)
New Revision: 7600
Added:
xfmpc/trunk/src/preferences.vala
Removed:
xfmpc/trunk/src/preferences.h
xfmpc/trunk/src/preferences.vapi
Modified:
xfmpc/trunk/ChangeLog
xfmpc/trunk/src/Makefile.am
xfmpc/trunk/src/dbbrowser.c
xfmpc/trunk/src/extended-interface.c
xfmpc/trunk/src/interface.c
xfmpc/trunk/src/main-window.c
xfmpc/trunk/src/mpdclient.c
xfmpc/trunk/src/playlist.c
xfmpc/trunk/src/preferences-dialog.c
xfmpc/trunk/src/preferences-dialog.vala
xfmpc/trunk/src/preferences.c
xfmpc/trunk/src/xfmpc.h
Log:
Rewrite preferences.c in vala
Update mpdclient.c and preferences-dialog.vala to compile with the new
preferences. The configuration file xfmpcrc is changed.
Modified: xfmpc/trunk/ChangeLog
===================================================================
--- xfmpc/trunk/ChangeLog 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/ChangeLog 2009-06-16 19:25:03 UTC (rev 7600)
@@ -1,3 +1,10 @@
+2009-06-16 Vincent Legout <vincent at legout.info>
+
+Rewrite preferences.c in vala
+
+Update mpdclient.c and preferences-dialog.vala to compile with the new
+preferences. The configuration file xfmpcrc is changed.
+
2009-06-16 Vincent Legout <vincent at legout.info>
General cleanup and add dependency on xfce4-vala
Modified: xfmpc/trunk/src/Makefile.am
===================================================================
--- xfmpc/trunk/src/Makefile.am 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/Makefile.am 2009-06-16 19:25:03 UTC (rev 7600)
@@ -10,14 +10,15 @@
extended-interface.vala \
interface.vala \
main-window.vala \
- playlist.vala
+ playlist.vala \
+ preferences.vala
vala_built_SOURCES = \
$(xfmpc_VALASOURCES:.vala=.c)
BUILT_SOURCES = vala.stamp
vala.stamp: $(xfmpc_VALASOURCES)
- $(VALAC) --vapidir=. --pkg=libxfcegui4-1.0 --pkg=config --pkg=mpdclient --pkg=preferences --pkg=xfce-arrow-button $^ -C -H xfmpc.h
+ $(VALAC) --vapidir=. --pkg=libxfcegui4-1.0 --pkg=config --pkg=mpdclient --pkg=xfce-arrow-button $^ -C -H xfmpc.h
touch $@
endif
@@ -25,8 +26,6 @@
xfmpc_SOURCES = \
main.c \
main-ui.h \
- preferences.c \
- preferences.h \
mpdclient.c \
mpdclient.h \
xfce-arrow-button.c \
Modified: xfmpc/trunk/src/dbbrowser.c
===================================================================
--- xfmpc/trunk/src/dbbrowser.c 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/dbbrowser.c 2009-06-16 19:25:03 UTC (rev 7600)
@@ -21,7 +21,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <mpdclient.h>
-#include <preferences.h>
#include <stdlib.h>
#include <string.h>
#include <gdk-pixbuf/gdk-pixdata.h>
@@ -41,6 +40,16 @@
typedef struct _XfmpcDbbrowserClass XfmpcDbbrowserClass;
typedef struct _XfmpcDbbrowserPrivate XfmpcDbbrowserPrivate;
+#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type ())
+#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
+#define XFMPC_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+#define XFMPC_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+
+typedef struct _XfmpcPreferences XfmpcPreferences;
+typedef struct _XfmpcPreferencesClass XfmpcPreferencesClass;
+
#define XFMPC_DBBROWSER_TYPE_COLUMNS (xfmpc_dbbrowser_columns_get_type ())
struct _XfmpcDbbrowser {
@@ -79,6 +88,7 @@
GType xfmpc_dbbrowser_get_type (void);
+GType xfmpc_preferences_get_type (void);
#define XFMPC_DBBROWSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserPrivate))
enum {
XFMPC_DBBROWSER_DUMMY_PROPERTY
@@ -109,6 +119,8 @@
XfmpcDbbrowser* xfmpc_dbbrowser_new (void);
XfmpcDbbrowser* xfmpc_dbbrowser_construct (GType object_type);
XfmpcDbbrowser* xfmpc_dbbrowser_new (void);
+XfmpcPreferences* xfmpc_preferences_get (void);
+const char* xfmpc_preferences_get_dbbrowser_last_path (XfmpcPreferences* self);
static void _xfmpc_dbbrowser_add_selected_rows_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self);
static void _xfmpc_dbbrowser_cb_replace_with_selected_rows_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self);
static void _xfmpc_dbbrowser_cb_browse_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self);
@@ -122,7 +134,7 @@
static void _xfmpc_dbbrowser_cb_search_entry_activated_gtk_entry_activate (GtkEntry* _sender, gpointer self);
static gboolean _xfmpc_dbbrowser_cb_search_entry_key_released_gtk_widget_key_release_event (GtkEntry* _sender, const GdkEventKey* event, gpointer self);
static void _xfmpc_dbbrowser_cb_search_entry_changed_gtk_editable_changed (GtkEntry* _sender, gpointer self);
-static void _xfmpc_dbbrowser_reload_xfmpc_preferences_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self);
+static void _xfmpc_dbbrowser_reload_g_object_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self);
static GObject * xfmpc_dbbrowser_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static gpointer xfmpc_dbbrowser_parent_class = NULL;
static void xfmpc_dbbrowser_finalize (GObject* obj);
@@ -762,7 +774,7 @@
}
-static void _xfmpc_dbbrowser_reload_xfmpc_preferences_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self) {
+static void _xfmpc_dbbrowser_reload_g_object_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self) {
xfmpc_dbbrowser_reload (self);
}
@@ -858,8 +870,8 @@
g_signal_connect_object (self->priv->search_entry, "activate", (GCallback) _xfmpc_dbbrowser_cb_search_entry_activated_gtk_entry_activate, self, 0);
g_signal_connect_object ((GtkWidget*) self->priv->search_entry, "key-release-event", (GCallback) _xfmpc_dbbrowser_cb_search_entry_key_released_gtk_widget_key_release_event, self, 0);
g_signal_connect_object ((GtkEditable*) self->priv->search_entry, "changed", (GCallback) _xfmpc_dbbrowser_cb_search_entry_changed_gtk_editable_changed, self, 0);
- g_signal_connect_object (self->priv->preferences, "notify::song-format", (GCallback) _xfmpc_dbbrowser_reload_xfmpc_preferences_notify, self, 0);
- g_signal_connect_object (self->priv->preferences, "notify::song-format-custom", (GCallback) _xfmpc_dbbrowser_reload_xfmpc_preferences_notify, self, 0);
+ g_signal_connect_object ((GObject*) self->priv->preferences, "notify::song-format", (GCallback) _xfmpc_dbbrowser_reload_g_object_notify, self, 0);
+ g_signal_connect_object ((GObject*) self->priv->preferences, "notify::song-format-custom", (GCallback) _xfmpc_dbbrowser_reload_g_object_notify, self, 0);
(cell_pixbuf == NULL) ? NULL : (cell_pixbuf = (g_object_unref (cell_pixbuf), NULL));
(cell_text == NULL) ? NULL : (cell_text = (g_object_unref (cell_text), NULL));
(scrolled == NULL) ? NULL : (scrolled = (g_object_unref (scrolled), NULL));
Modified: xfmpc/trunk/src/extended-interface.c
===================================================================
--- xfmpc/trunk/src/extended-interface.c 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/extended-interface.c 2009-06-16 19:25:03 UTC (rev 7600)
@@ -21,7 +21,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <mpdclient.h>
-#include <preferences.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
@@ -43,6 +42,16 @@
typedef struct _XfmpcExtendedInterfaceClass XfmpcExtendedInterfaceClass;
typedef struct _XfmpcExtendedInterfacePrivate XfmpcExtendedInterfacePrivate;
+#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type ())
+#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
+#define XFMPC_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+#define XFMPC_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+
+typedef struct _XfmpcPreferences XfmpcPreferences;
+typedef struct _XfmpcPreferencesClass XfmpcPreferencesClass;
+
#define XFMPC_EXTENDED_INTERFACE_TYPE_COLUMNS (xfmpc_extended_interface_columns_get_type ())
#define XFMPC_EXTENDED_INTERFACE_TYPE_EXTENDED_INTERFACE_WIDGET (xfmpc_extended_interface_extended_interface_widget_get_type ())
@@ -109,6 +118,7 @@
GType xfmpc_extended_interface_get_type (void);
+GType xfmpc_preferences_get_type (void);
#define XFMPC_EXTENDED_INTERFACE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfacePrivate))
enum {
XFMPC_EXTENDED_INTERFACE_DUMMY_PROPERTY
@@ -143,6 +153,7 @@
XfmpcExtendedInterface* xfmpc_extended_interface_new (void);
XfmpcExtendedInterface* xfmpc_extended_interface_construct (GType object_type);
XfmpcExtendedInterface* xfmpc_extended_interface_new (void);
+XfmpcPreferences* xfmpc_preferences_get (void);
static void _xfmpc_extended_interface_cb_playlist_clear_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void _xfmpc_extended_interface_cb_database_refresh_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void _xfmpc_extended_interface_popup_context_menu_gtk_button_pressed (GtkButton* _sender, gpointer self);
Modified: xfmpc/trunk/src/interface.c
===================================================================
--- xfmpc/trunk/src/interface.c 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/interface.c 2009-06-16 19:25:03 UTC (rev 7600)
@@ -21,7 +21,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <mpdclient.h>
-#include <preferences.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
@@ -43,6 +42,16 @@
typedef struct _XfmpcInterfaceClass XfmpcInterfaceClass;
typedef struct _XfmpcInterfacePrivate XfmpcInterfacePrivate;
+#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type ())
+#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
+#define XFMPC_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+#define XFMPC_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+
+typedef struct _XfmpcPreferences XfmpcPreferences;
+typedef struct _XfmpcPreferencesClass XfmpcPreferencesClass;
+
struct _XfmpcInterface {
GtkVBox parent_instance;
XfmpcInterfacePrivate * priv;
@@ -68,6 +77,7 @@
GType xfmpc_interface_get_type (void);
+GType xfmpc_preferences_get_type (void);
#define XFMPC_INTERFACE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_INTERFACE, XfmpcInterfacePrivate))
enum {
XFMPC_INTERFACE_DUMMY_PROPERTY
@@ -94,6 +104,7 @@
XfmpcInterface* xfmpc_interface_new (void);
XfmpcInterface* xfmpc_interface_construct (GType object_type);
XfmpcInterface* xfmpc_interface_new (void);
+XfmpcPreferences* xfmpc_preferences_get (void);
static void _xfmpc_interface_cb_mpdclient_previous_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void _xfmpc_interface_pp_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void _xfmpc_interface_cb_mpdclient_next_gtk_button_clicked (GtkButton* _sender, gpointer self);
Modified: xfmpc/trunk/src/main-window.c
===================================================================
--- xfmpc/trunk/src/main-window.c 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/main-window.c 2009-06-16 19:25:03 UTC (rev 7600)
@@ -21,7 +21,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <mpdclient.h>
-#include <preferences.h>
#include <gdk/gdk.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
@@ -40,6 +39,16 @@
typedef struct _XfmpcMainWindowClass XfmpcMainWindowClass;
typedef struct _XfmpcMainWindowPrivate XfmpcMainWindowPrivate;
+#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type ())
+#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
+#define XFMPC_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+#define XFMPC_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+
+typedef struct _XfmpcPreferences XfmpcPreferences;
+typedef struct _XfmpcPreferencesClass XfmpcPreferencesClass;
+
#define XFMPC_TYPE_INTERFACE (xfmpc_interface_get_type ())
#define XFMPC_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_INTERFACE, XfmpcInterface))
#define XFMPC_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_INTERFACE, XfmpcInterfaceClass))
@@ -91,6 +100,7 @@
GType xfmpc_main_window_get_type (void);
+GType xfmpc_preferences_get_type (void);
#define XFMPC_MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_MAIN_WINDOW, XfmpcMainWindowPrivate))
enum {
XFMPC_MAIN_WINDOW_DUMMY_PROPERTY
@@ -110,9 +120,14 @@
static void xfmpc_main_window_action_volume (XfmpcMainWindow* self);
static void _xfmpc_main_window_action_volume_gtk_action_callback (GtkAction* action, gpointer self);
#define XFMPC_MAIN_WINDOW_ui_string "\n<ui>\n <accelerator action=\"quit\" />\n <accelerator action=\"previous\" />\n <accelerator action=\"pp\" />\n <accelerator action=\"stop\" />\n <accelerator action=\"next\" />\n <accelerator action=\"volume\" />\n</ui>\n"
+void xfmpc_preferences_set_last_window_state_sticky (XfmpcPreferences* self, gboolean value);
static gboolean xfmpc_main_window_cb_window_state_event (XfmpcMainWindow* self, const GdkEventWindowState* event);
static void xfmpc_main_window_close_window (XfmpcMainWindow* self);
static gboolean xfmpc_main_window_cb_window_closed (XfmpcMainWindow* self, GdkEvent* event);
+void xfmpc_preferences_set_last_window_posx (XfmpcPreferences* self, gint value);
+void xfmpc_preferences_set_last_window_posy (XfmpcPreferences* self, gint value);
+void xfmpc_preferences_set_last_window_width (XfmpcPreferences* self, gint value);
+void xfmpc_preferences_set_last_window_height (XfmpcPreferences* self, gint value);
GType xfmpc_interface_get_type (void);
void xfmpc_interface_pp_clicked (XfmpcInterface* self);
void xfmpc_interface_popup_volume (XfmpcInterface* self);
@@ -122,19 +137,26 @@
void xfmpc_statusbar_set_text (XfmpcStatusbar* self, const char* value);
static void xfmpc_main_window_update_statusbar (XfmpcMainWindow* self);
static void xfmpc_main_window_cb_playlist_changed (XfmpcMainWindow* self);
+gboolean xfmpc_preferences_get_show_statusbar (XfmpcPreferences* self);
static void xfmpc_main_window_cb_show_statusbar_changed (XfmpcMainWindow* self, GParamSpec* pspec);
XfmpcMainWindow* xfmpc_main_window_new (void);
XfmpcMainWindow* xfmpc_main_window_construct (GType object_type);
XfmpcMainWindow* xfmpc_main_window_new (void);
+XfmpcPreferences* xfmpc_preferences_get (void);
static gboolean _xfmpc_main_window_cb_window_closed_gtk_widget_delete_event (XfmpcMainWindow* _sender, GdkEvent* event, gpointer self);
static gboolean _xfmpc_main_window_cb_window_state_event_gtk_widget_window_state_event (XfmpcMainWindow* _sender, const GdkEventWindowState* event, gpointer self);
+gint xfmpc_preferences_get_last_window_posx (XfmpcPreferences* self);
+gint xfmpc_preferences_get_last_window_posy (XfmpcPreferences* self);
+gint xfmpc_preferences_get_last_window_width (XfmpcPreferences* self);
+gint xfmpc_preferences_get_last_window_height (XfmpcPreferences* self);
+gboolean xfmpc_preferences_get_last_window_state_sticky (XfmpcPreferences* self);
XfmpcInterface* xfmpc_interface_new (void);
XfmpcInterface* xfmpc_interface_construct (GType object_type);
XfmpcExtendedInterface* xfmpc_extended_interface_new (void);
XfmpcExtendedInterface* xfmpc_extended_interface_construct (GType object_type);
GType xfmpc_extended_interface_get_type (void);
static void _xfmpc_main_window_cb_playlist_changed_xfmpc_mpdclient_playlist_changed (XfmpcMpdclient* _sender, gpointer self);
-static void _xfmpc_main_window_cb_show_statusbar_changed_xfmpc_preferences_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self);
+static void _xfmpc_main_window_cb_show_statusbar_changed_g_object_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self);
static GObject * xfmpc_main_window_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static gpointer xfmpc_main_window_parent_class = NULL;
static void xfmpc_main_window_finalize (GObject* obj);
@@ -394,7 +416,7 @@
}
-static void _xfmpc_main_window_cb_show_statusbar_changed_xfmpc_preferences_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self) {
+static void _xfmpc_main_window_cb_show_statusbar_changed_g_object_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self) {
xfmpc_main_window_cb_show_statusbar_changed (self, pspec);
}
@@ -509,7 +531,7 @@
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_action_group_get_action (self->priv->action_group, "view-statusbar")), xfmpc_preferences_get_show_statusbar (self->priv->preferences));
/* === Signals === */
g_signal_connect_object (self->priv->mpdclient, "playlist-changed", (GCallback) _xfmpc_main_window_cb_playlist_changed_xfmpc_mpdclient_playlist_changed, self, 0);
- g_signal_connect_object (self->priv->preferences, "notify::show-statusbar", (GCallback) _xfmpc_main_window_cb_show_statusbar_changed_xfmpc_preferences_notify, self, 0);
+ g_signal_connect_object ((GObject*) self->priv->preferences, "notify::show-statusbar", (GCallback) _xfmpc_main_window_cb_show_statusbar_changed_g_object_notify, self, 0);
(interface == NULL) ? NULL : (interface = (g_object_unref (interface), NULL));
(separator == NULL) ? NULL : (separator = (g_object_unref (separator), NULL));
(extended_interface == NULL) ? NULL : (extended_interface = (g_object_unref (extended_interface), NULL));
Modified: xfmpc/trunk/src/mpdclient.c
===================================================================
--- xfmpc/trunk/src/mpdclient.c 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/mpdclient.c 2009-06-16 19:25:03 UTC (rev 7600)
@@ -25,7 +25,7 @@
#include <libmpd/libmpd.h>
#include "mpdclient.h"
-#include "preferences.h"
+#include "xfmpc.h"
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_MPDCLIENT, XfmpcMpdclientPrivate))
@@ -62,7 +62,7 @@
gpointer user_data);
static gchar * _get_formatted_name (mpd_Song *song);
static gchar * _get_formatted_name_predefined (mpd_Song *song,
- XfmpcSongFormat song_format);
+ XfmpcPreferencesSongFormat song_format);
static gchar * _get_formatted_name_custom (mpd_Song *song,
const gchar *format);
@@ -923,7 +923,7 @@
_get_formatted_name (mpd_Song *song)
{
XfmpcPreferences *preferences = xfmpc_preferences_get ();
- XfmpcSongFormat song_format;
+ XfmpcPreferencesSongFormat song_format;
gchar *format_custom;
gchar *formatted_name;
@@ -936,7 +936,7 @@
{
formatted_name = g_path_get_basename (song->file);
}
- else if (song_format == XFMPC_SONG_FORMAT_CUSTOM)
+ else if (song_format == XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM_FORMAT)
{
formatted_name = _get_formatted_name_custom (song, format_custom);
}
@@ -951,17 +951,17 @@
static gchar *
_get_formatted_name_predefined (mpd_Song *song,
- XfmpcSongFormat song_format)
+ XfmpcPreferencesSongFormat song_format)
{
gchar *formatted_name, *tmp;
switch (song_format)
{
- case XFMPC_SONG_FORMAT_TITLE:
+ case XFMPC_PREFERENCES_SONG_FORMAT_TITLE:
formatted_name = g_strdup_printf ("%s", song->title);
break;
- case XFMPC_SONG_FORMAT_ARTIST_TITLE:
+ case XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE:
if (NULL != song->artist)
{
formatted_name = g_strdup_printf ("%s - %s", song->artist, song->title);
@@ -972,7 +972,7 @@
}
break;
- case XFMPC_SONG_FORMAT_ALBUM_TITLE:
+ case XFMPC_PREFERENCES_SONG_FORMAT_ALBUM_TITLE:
if (NULL != song->album)
{
formatted_name = g_strdup_printf ("%s - %s", song->album, song->title);
@@ -983,7 +983,7 @@
}
break;
- case XFMPC_SONG_FORMAT_ARTIST_TITLE_DATE:
+ case XFMPC_PREFERENCES_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);
@@ -1002,7 +1002,7 @@
}
break;
- case XFMPC_SONG_FORMAT_ARTIST_ALBUM_TITLE:
+ case XFMPC_PREFERENCES_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);
@@ -1021,7 +1021,7 @@
}
break;
- case XFMPC_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE:
+ case XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE:
formatted_name = g_strdup ("");
if (song->artist != NULL)
Modified: xfmpc/trunk/src/playlist.c
===================================================================
--- xfmpc/trunk/src/playlist.c 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/playlist.c 2009-06-16 19:25:03 UTC (rev 7600)
@@ -21,7 +21,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <mpdclient.h>
-#include <preferences.h>
#include <stdlib.h>
#include <string.h>
#include <libxfcegui4/libxfcegui4.h>
@@ -41,6 +40,16 @@
typedef struct _XfmpcPlaylistClass XfmpcPlaylistClass;
typedef struct _XfmpcPlaylistPrivate XfmpcPlaylistPrivate;
+#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type ())
+#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
+#define XFMPC_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+#define XFMPC_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+
+typedef struct _XfmpcPreferences XfmpcPreferences;
+typedef struct _XfmpcPreferencesClass XfmpcPreferencesClass;
+
#define XFMPC_PLAYLIST_TYPE_COLUMNS (xfmpc_playlist_columns_get_type ())
#define XFMPC_TYPE_DBBROWSER (xfmpc_dbbrowser_get_type ())
@@ -115,6 +124,7 @@
GType xfmpc_playlist_get_type (void);
+GType xfmpc_preferences_get_type (void);
#define XFMPC_PLAYLIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistPrivate))
enum {
XFMPC_PLAYLIST_DUMMY_PROPERTY
@@ -152,6 +162,8 @@
XfmpcPlaylist* xfmpc_playlist_new (void);
XfmpcPlaylist* xfmpc_playlist_construct (GType object_type);
XfmpcPlaylist* xfmpc_playlist_new (void);
+XfmpcPreferences* xfmpc_preferences_get (void);
+gboolean xfmpc_preferences_get_playlist_autocenter (XfmpcPreferences* self);
static void _xfmpc_playlist_delete_selection_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self);
static void _xfmpc_playlist_cb_browse_selection_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self);
static void _xfmpc_playlist_cb_info_selection_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self);
@@ -164,7 +176,7 @@
static void _xfmpc_playlist_cb_filter_entry_activated_gtk_entry_activate (GtkEntry* _sender, gpointer self);
static gboolean _xfmpc_playlist_cb_filter_entry_key_released_gtk_widget_key_release_event (GtkEntry* _sender, const GdkEventKey* event, gpointer self);
static void _xfmpc_playlist_cb_filter_entry_changed_gtk_editable_changed (GtkEntry* _sender, gpointer self);
-static void _xfmpc_playlist_cb_playlist_changed_xfmpc_preferences_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self);
+static void _xfmpc_playlist_cb_playlist_changed_g_object_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self);
static GObject * xfmpc_playlist_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static gpointer xfmpc_playlist_parent_class = NULL;
static void xfmpc_playlist_finalize (GObject* obj);
@@ -716,7 +728,7 @@
}
-static void _xfmpc_playlist_cb_playlist_changed_xfmpc_preferences_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self) {
+static void _xfmpc_playlist_cb_playlist_changed_g_object_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self) {
xfmpc_playlist_cb_playlist_changed (self);
}
@@ -813,8 +825,8 @@
g_signal_connect_object (xfmpc_playlist_filter_entry, "activate", (GCallback) _xfmpc_playlist_cb_filter_entry_activated_gtk_entry_activate, self, 0);
g_signal_connect_object ((GtkWidget*) xfmpc_playlist_filter_entry, "key-release-event", (GCallback) _xfmpc_playlist_cb_filter_entry_key_released_gtk_widget_key_release_event, self, 0);
g_signal_connect_object ((GtkEditable*) xfmpc_playlist_filter_entry, "changed", (GCallback) _xfmpc_playlist_cb_filter_entry_changed_gtk_editable_changed, self, 0);
- g_signal_connect_object (self->priv->preferences, "notify::song-format", (GCallback) _xfmpc_playlist_cb_playlist_changed_xfmpc_preferences_notify, self, 0);
- g_signal_connect_object (self->priv->preferences, "notify::song-format-custom", (GCallback) _xfmpc_playlist_cb_playlist_changed_xfmpc_preferences_notify, self, 0);
+ g_signal_connect_object ((GObject*) self->priv->preferences, "notify::song-format", (GCallback) _xfmpc_playlist_cb_playlist_changed_g_object_notify, self, 0);
+ g_signal_connect_object ((GObject*) self->priv->preferences, "notify::song-format-custom", (GCallback) _xfmpc_playlist_cb_playlist_changed_g_object_notify, self, 0);
(cell == NULL) ? NULL : (cell = (g_object_unref (cell), NULL));
(column == NULL) ? NULL : (column = (g_object_unref (column), NULL));
(scrolled == NULL) ? NULL : (scrolled = (g_object_unref (scrolled), NULL));
Modified: xfmpc/trunk/src/preferences-dialog.c
===================================================================
--- xfmpc/trunk/src/preferences-dialog.c 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/preferences-dialog.c 2009-06-16 19:25:03 UTC (rev 7600)
@@ -20,7 +20,6 @@
#include <glib.h>
#include <glib-object.h>
#include <libxfcegui4/libxfcegui4.h>
-#include <preferences.h>
#include <gtk/gtk.h>
#include <mpdclient.h>
#include <stdlib.h>
@@ -40,6 +39,18 @@
typedef struct _XfmpcPreferencesDialogClass XfmpcPreferencesDialogClass;
typedef struct _XfmpcPreferencesDialogPrivate XfmpcPreferencesDialogPrivate;
+#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type ())
+#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
+#define XFMPC_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+#define XFMPC_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+
+typedef struct _XfmpcPreferences XfmpcPreferences;
+typedef struct _XfmpcPreferencesClass XfmpcPreferencesClass;
+
+#define XFMPC_PREFERENCES_TYPE_SONG_FORMAT (xfmpc_preferences_song_format_get_type ())
+
struct _XfmpcPreferencesDialog {
XfceTitledDialog parent_instance;
XfmpcPreferencesDialogPrivate * priv;
@@ -62,27 +73,54 @@
GtkVBox* mpd_vbox;
};
+typedef enum {
+ XFMPC_PREFERENCES_SONG_FORMAT_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ALBUM_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE_DATE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM_FORMAT
+} XfmpcPreferencesSongFormat;
+
GType xfmpc_preferences_dialog_get_type (void);
+GType xfmpc_preferences_get_type (void);
#define XFMPC_PREFERENCES_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialogPrivate))
enum {
XFMPC_PREFERENCES_DIALOG_DUMMY_PROPERTY
};
static void xfmpc_preferences_dialog_cb_response (XfmpcPreferencesDialog* self, XfmpcPreferencesDialog* source, gint response);
static void xfmpc_preferences_dialog_cb_use_defaults_toggled (XfmpcPreferencesDialog* self, GtkCheckButton* source);
+void xfmpc_preferences_set_mpd_hostname (XfmpcPreferences* self, const char* value);
+void xfmpc_preferences_set_mpd_port (XfmpcPreferences* self, gint value);
+void xfmpc_preferences_set_mpd_password (XfmpcPreferences* self, const char* value);
+void xfmpc_preferences_set_mpd_use_defaults (XfmpcPreferences* self, gboolean value);
static void xfmpc_preferences_dialog_cb_update_mpd (XfmpcPreferencesDialog* self, GtkButton* source);
+void xfmpc_preferences_set_show_statusbar (XfmpcPreferences* self, gboolean value);
static void xfmpc_preferences_dialog_cb_show_statusbar_toggled (XfmpcPreferencesDialog* self, GtkCheckButton* source);
+GType xfmpc_preferences_song_format_get_type (void);
+void xfmpc_preferences_set_song_format (XfmpcPreferences* self, XfmpcPreferencesSongFormat value);
static void xfmpc_preferences_dialog_cb_combo_format_changed (XfmpcPreferencesDialog* self, GtkComboBox* source);
static gboolean xfmpc_preferences_dialog_timeout_format (XfmpcPreferencesDialog* self);
static gboolean _xfmpc_preferences_dialog_timeout_format_gsource_func (gpointer self);
static void xfmpc_preferences_dialog_cb_entry_custom_changed (XfmpcPreferencesDialog* self, GtkEntry* source);
+void xfmpc_preferences_set_song_format_custom (XfmpcPreferences* self, const char* value);
XfmpcPreferencesDialog* xfmpc_preferences_dialog_new (void);
XfmpcPreferencesDialog* xfmpc_preferences_dialog_construct (GType object_type);
XfmpcPreferencesDialog* xfmpc_preferences_dialog_new (void);
+XfmpcPreferences* xfmpc_preferences_get (void);
+gboolean xfmpc_preferences_get_mpd_use_defaults (XfmpcPreferences* self);
static void _xfmpc_preferences_dialog_cb_use_defaults_toggled_gtk_toggle_button_toggled (GtkCheckButton* _sender, gpointer self);
+const char* xfmpc_preferences_get_mpd_hostname (XfmpcPreferences* self);
+gint xfmpc_preferences_get_mpd_port (XfmpcPreferences* self);
+const char* xfmpc_preferences_get_mpd_password (XfmpcPreferences* self);
static void _xfmpc_preferences_dialog_cb_update_mpd_gtk_button_clicked (GtkButton* _sender, gpointer self);
+gboolean xfmpc_preferences_get_show_statusbar (XfmpcPreferences* self);
static void _xfmpc_preferences_dialog_cb_show_statusbar_toggled_gtk_toggle_button_toggled (GtkCheckButton* _sender, gpointer self);
+XfmpcPreferencesSongFormat xfmpc_preferences_get_song_format (XfmpcPreferences* self);
+const char* xfmpc_preferences_get_song_format_custom (XfmpcPreferences* self);
static void _xfmpc_preferences_dialog_cb_combo_format_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
static void _xfmpc_preferences_dialog_cb_entry_custom_changed_gtk_editable_changed (GtkEntry* _sender, gpointer self);
static void _xfmpc_preferences_dialog_cb_response_gtk_dialog_response (XfmpcPreferencesDialog* _sender, gint response_id, gpointer self);
@@ -142,42 +180,42 @@
switch (gtk_combo_box_get_active (self->priv->combo_format)) {
case 0:
{
- xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_TITLE);
+ xfmpc_preferences_set_song_format (self->priv->preferences, XFMPC_PREFERENCES_SONG_FORMAT_TITLE);
break;
}
case 1:
{
- xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ALBUM_TITLE);
+ xfmpc_preferences_set_song_format (self->priv->preferences, XFMPC_PREFERENCES_SONG_FORMAT_ALBUM_TITLE);
break;
}
case 2:
{
- xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ARTIST_TITLE);
+ xfmpc_preferences_set_song_format (self->priv->preferences, XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE);
break;
}
case 3:
{
- xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ARTIST_TITLE_DATE);
+ xfmpc_preferences_set_song_format (self->priv->preferences, XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE_DATE);
break;
}
case 4:
{
- xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ARTIST_ALBUM_TITLE);
+ xfmpc_preferences_set_song_format (self->priv->preferences, XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TITLE);
break;
}
case 5:
{
- xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE);
+ xfmpc_preferences_set_song_format (self->priv->preferences, XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE);
break;
}
case 6:
{
- xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_CUSTOM);
+ xfmpc_preferences_set_song_format (self->priv->preferences, XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM_FORMAT);
break;
}
default:
{
- xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_TITLE);
+ xfmpc_preferences_set_song_format (self->priv->preferences, XFMPC_PREFERENCES_SONG_FORMAT_TITLE);
break;
}
}
@@ -408,7 +446,7 @@
gtk_combo_box_append_text (self->priv->combo_format, _ ("Artist - Album - Title"));
gtk_combo_box_append_text (self->priv->combo_format, _ ("Artist - Album - Track. Title"));
gtk_combo_box_append_text (self->priv->combo_format, _ ("Custom..."));
- gtk_combo_box_set_active (self->priv->combo_format, xfmpc_preferences_get_song_format (self->priv->preferences));
+ gtk_combo_box_set_active (self->priv->combo_format, (gint) xfmpc_preferences_get_song_format (self->priv->preferences));
gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) hbox, TRUE, TRUE, (guint) 0);
_tmp22_ = NULL;
hbox = (_tmp22_ = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 2)), (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL)), _tmp22_);
Modified: xfmpc/trunk/src/preferences-dialog.vala
===================================================================
--- xfmpc/trunk/src/preferences-dialog.vala 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/preferences-dialog.vala 2009-06-16 19:25:03 UTC (rev 7600)
@@ -250,14 +250,14 @@
switch (combo_format.get_active ())
{
- case 0: this.preferences.song_format = Xfmpc.SongFormat.TITLE; break;
- case 1: this.preferences.song_format = Xfmpc.SongFormat.ALBUM_TITLE; break;
- case 2: this.preferences.song_format = Xfmpc.SongFormat.ARTIST_TITLE; break;
- case 3: this.preferences.song_format = Xfmpc.SongFormat.ARTIST_TITLE_DATE; break;
- case 4: this.preferences.song_format = Xfmpc.SongFormat.ARTIST_ALBUM_TITLE; break;
- case 5: this.preferences.song_format = Xfmpc.SongFormat.ARTIST_ALBUM_TRACK_TITLE; break;
- case 6: this.preferences.song_format = Xfmpc.SongFormat.CUSTOM; break;
- default: this.preferences.song_format = Xfmpc.SongFormat.TITLE; break;
+ case 0: this.preferences.song_format = Xfmpc.Preferences.SongFormat.TITLE; break;
+ case 1: this.preferences.song_format = Xfmpc.Preferences.SongFormat.ALBUM_TITLE; break;
+ case 2: this.preferences.song_format = Xfmpc.Preferences.SongFormat.ARTIST_TITLE; break;
+ case 3: this.preferences.song_format = Xfmpc.Preferences.SongFormat.ARTIST_TITLE_DATE; break;
+ case 4: this.preferences.song_format = Xfmpc.Preferences.SongFormat.ARTIST_ALBUM_TITLE; break;
+ case 5: this.preferences.song_format = Xfmpc.Preferences.SongFormat.ARTIST_ALBUM_TRACK_TITLE; break;
+ case 6: this.preferences.song_format = Xfmpc.Preferences.SongFormat.CUSTOM_FORMAT; break;
+ default: this.preferences.song_format = Xfmpc.Preferences.SongFormat.TITLE; break;
}
this.entry_custom.set_sensitive (this.combo_format.get_active () == 6);
Modified: xfmpc/trunk/src/preferences.c
===================================================================
--- xfmpc/trunk/src/preferences.c 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/preferences.c 2009-06-16 19:25:03 UTC (rev 7600)
@@ -1,10 +1,7 @@
/*
- * Copyright (c) 2008-2009 Mike Massonnet <mmassonnet at xfce.org>
+ * Copyright (c) 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>
- *
* 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
* the Free Software Foundation; either version 2 of the License, or
@@ -20,632 +17,671 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
+#include <glib.h>
#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
#include <libxfce4util/libxfce4util.h>
-#include "preferences.h"
+#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type ())
+#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
+#define XFMPC_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+#define XFMPC_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+typedef struct _XfmpcPreferences XfmpcPreferences;
+typedef struct _XfmpcPreferencesClass XfmpcPreferencesClass;
+typedef struct _XfmpcPreferencesPrivate XfmpcPreferencesPrivate;
-/* Enum types */
-GType
-xfmpc_song_format_get_type ()
-{
- static GType type = G_TYPE_INVALID;
+#define XFMPC_PREFERENCES_TYPE_SONG_FORMAT (xfmpc_preferences_song_format_get_type ())
- static const GEnumValue values[] = {
- { XFMPC_SONG_FORMAT_TITLE, "XFMPC_SONG_FORMAT_TITLE", N_("Title"), },
- { XFMPC_SONG_FORMAT_ALBUM_TITLE, "XFMPC_SONG_FORMAT_ALBUM_TITLE", N_("Album - Title"), },
- { XFMPC_SONG_FORMAT_ARTIST_TITLE, "XFMPC_SONG_FORMAT_ARTIST_TITLE", N_("Artist - 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 },
- };
+struct _XfmpcPreferences {
+ GObject parent_instance;
+ XfmpcPreferencesPrivate * priv;
+};
- if (type != G_TYPE_INVALID)
- return type;
+struct _XfmpcPreferencesClass {
+ GObjectClass parent_class;
+};
- type = g_enum_register_static ("XfmpcSongFormat", values);
- return type;
-}
+typedef enum {
+ XFMPC_PREFERENCES_SONG_FORMAT_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ALBUM_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE_DATE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM_FORMAT
+} XfmpcPreferencesSongFormat;
-/* Property identifiers */
-enum
-{
- PROP_0,
- PROP_LAST_WINDOW_POSX,
- PROP_LAST_WINDOW_POSY,
- PROP_LAST_WINDOW_WIDTH,
- PROP_LAST_WINDOW_HEIGHT,
- PROP_LAST_WINDOW_STATE_STICKY,
- PROP_PLAYLIST_AUTOCENTER,
- PROP_DBBROWSER_LAST_PATH,
- PROP_MPD_HOST,
- PROP_MPD_PORT,
- PROP_MPD_PASSWORD,
- PROP_MPD_USE_DEFAULTS,
- PROP_SHOW_STATUSBAR,
- PROP_SONG_FORMAT,
- PROP_SONG_FORMAT_CUSTOM,
- N_PROPERTIES,
+struct _XfmpcPreferencesPrivate {
+ gint _last_window_posx;
+ gint _last_window_posy;
+ gint _last_window_width;
+ gint _last_window_height;
+ gboolean _last_window_state_sticky;
+ gboolean _playlist_autocenter;
+ char* _dbbrowser_last_path;
+ char* _mpd_hostname;
+ gint _mpd_port;
+ char* _mpd_password;
+ gboolean _mpd_use_defaults;
+ gboolean _show_statusbar;
+ XfmpcPreferencesSongFormat _song_format;
+ char* _song_format_custom;
};
-static void xfmpc_preferences_class_init (XfmpcPreferencesClass *klass);
-static void xfmpc_preferences_init (XfmpcPreferences *preferences);
-static void xfmpc_preferences_finalize (GObject *object);
-static void xfmpc_preferences_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void xfmpc_preferences_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void xfmpc_preferences_load (XfmpcPreferences *preferences);
-
-static void xfmpc_preferences_store (XfmpcPreferences *preferences);
-
-static XfceRc * xfmpc_preferences_get_rc (XfmpcPreferences *preferences);
-
-
-
-
-struct _XfmpcPreferencesClass
-{
- GObjectClass parent_class;
+GType xfmpc_preferences_get_type (void);
+GType xfmpc_preferences_song_format_get_type (void);
+#define XFMPC_PREFERENCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesPrivate))
+enum {
+ XFMPC_PREFERENCES_DUMMY_PROPERTY,
+ XFMPC_PREFERENCES_LAST_WINDOW_POSX,
+ XFMPC_PREFERENCES_LAST_WINDOW_POSY,
+ XFMPC_PREFERENCES_LAST_WINDOW_WIDTH,
+ XFMPC_PREFERENCES_LAST_WINDOW_HEIGHT,
+ XFMPC_PREFERENCES_LAST_WINDOW_STATE_STICKY,
+ XFMPC_PREFERENCES_PLAYLIST_AUTOCENTER,
+ XFMPC_PREFERENCES_DBBROWSER_LAST_PATH,
+ XFMPC_PREFERENCES_MPD_HOSTNAME,
+ XFMPC_PREFERENCES_MPD_PORT,
+ XFMPC_PREFERENCES_MPD_PASSWORD,
+ XFMPC_PREFERENCES_MPD_USE_DEFAULTS,
+ XFMPC_PREFERENCES_SHOW_STATUSBAR,
+ XFMPC_PREFERENCES_SONG_FORMAT,
+ XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM
};
+static XfmpcPreferences* xfmpc_preferences_preferences;
+static XfmpcPreferences* xfmpc_preferences_preferences = NULL;
+static void xfmpc_preferences_load (XfmpcPreferences* self);
+XfmpcPreferences* xfmpc_preferences_new (void);
+XfmpcPreferences* xfmpc_preferences_construct (GType object_type);
+XfmpcPreferences* xfmpc_preferences_new (void);
+XfmpcPreferences* xfmpc_preferences_get (void);
+static void xfmpc_preferences_store (XfmpcPreferences* self);
+gint xfmpc_preferences_get_last_window_posx (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_posx (XfmpcPreferences* self, gint value);
+gint xfmpc_preferences_get_last_window_posy (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_posy (XfmpcPreferences* self, gint value);
+gint xfmpc_preferences_get_last_window_width (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_width (XfmpcPreferences* self, gint value);
+gint xfmpc_preferences_get_last_window_height (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_height (XfmpcPreferences* self, gint value);
+gboolean xfmpc_preferences_get_last_window_state_sticky (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_state_sticky (XfmpcPreferences* self, gboolean value);
+gboolean xfmpc_preferences_get_playlist_autocenter (XfmpcPreferences* self);
+void xfmpc_preferences_set_playlist_autocenter (XfmpcPreferences* self, gboolean value);
+const char* xfmpc_preferences_get_dbbrowser_last_path (XfmpcPreferences* self);
+void xfmpc_preferences_set_dbbrowser_last_path (XfmpcPreferences* self, const char* value);
+const char* xfmpc_preferences_get_mpd_hostname (XfmpcPreferences* self);
+void xfmpc_preferences_set_mpd_hostname (XfmpcPreferences* self, const char* value);
+gint xfmpc_preferences_get_mpd_port (XfmpcPreferences* self);
+void xfmpc_preferences_set_mpd_port (XfmpcPreferences* self, gint value);
+const char* xfmpc_preferences_get_mpd_password (XfmpcPreferences* self);
+void xfmpc_preferences_set_mpd_password (XfmpcPreferences* self, const char* value);
+gboolean xfmpc_preferences_get_mpd_use_defaults (XfmpcPreferences* self);
+void xfmpc_preferences_set_mpd_use_defaults (XfmpcPreferences* self, gboolean value);
+gboolean xfmpc_preferences_get_show_statusbar (XfmpcPreferences* self);
+void xfmpc_preferences_set_show_statusbar (XfmpcPreferences* self, gboolean value);
+XfmpcPreferencesSongFormat xfmpc_preferences_get_song_format (XfmpcPreferences* self);
+void xfmpc_preferences_set_song_format (XfmpcPreferences* self, XfmpcPreferencesSongFormat value);
+const char* xfmpc_preferences_get_song_format_custom (XfmpcPreferences* self);
+void xfmpc_preferences_set_song_format_custom (XfmpcPreferences* self, const char* value);
+static gpointer xfmpc_preferences_parent_class = NULL;
+static void xfmpc_preferences_finalize (GObject* obj);
+static void xfmpc_preferences_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
+static void xfmpc_preferences_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
+static int _vala_strcmp0 (const char * str1, const char * str2);
-struct _XfmpcPreferences
-{
- GObject parent;
- /*<private>*/
- GValue values[N_PROPERTIES];
-};
-static GObjectClass *parent_class = NULL;
+GType xfmpc_preferences_song_format_get_type (void) {
+ static GType xfmpc_preferences_song_format_type_id = 0;
+ if (G_UNLIKELY (xfmpc_preferences_song_format_type_id == 0)) {
+ static const GEnumValue values[] = {{XFMPC_PREFERENCES_SONG_FORMAT_TITLE, "XFMPC_PREFERENCES_SONG_FORMAT_TITLE", "title"}, {XFMPC_PREFERENCES_SONG_FORMAT_ALBUM_TITLE, "XFMPC_PREFERENCES_SONG_FORMAT_ALBUM_TITLE", "album-title"}, {XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE, "XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE", "artist-title"}, {XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE_DATE, "XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE_DATE", "artist-title-date"}, {XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TITLE, "XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TITLE", "artist-album-title"}, {XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE, "XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE", "artist-album-track-title"}, {XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM_FORMAT, "XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM_FORMAT", "custom-format"}, {0, NULL, NULL}};
+ xfmpc_preferences_song_format_type_id = g_enum_register_static ("XfmpcPreferencesSongFormat", values);
+ }
+ return xfmpc_preferences_song_format_type_id;
+}
+XfmpcPreferences* xfmpc_preferences_construct (GType object_type) {
+ XfmpcPreferences * self;
+ char* _tmp0_;
+ char* _tmp1_;
+ char* _tmp2_;
+ char* _tmp3_;
+ self = g_object_newv (object_type, 0, NULL);
+ self->priv->_last_window_posx = 200;
+ self->priv->_last_window_posy = 100;
+ self->priv->_last_window_width = 330;
+ self->priv->_last_window_height = 330;
+ self->priv->_last_window_state_sticky = TRUE;
+ self->priv->_playlist_autocenter = TRUE;
+ _tmp0_ = NULL;
+ self->priv->_dbbrowser_last_path = (_tmp0_ = g_strdup (""), self->priv->_dbbrowser_last_path = (g_free (self->priv->_dbbrowser_last_path), NULL), _tmp0_);
+ _tmp1_ = NULL;
+ self->priv->_mpd_hostname = (_tmp1_ = g_strdup ("localhost"), self->priv->_mpd_hostname = (g_free (self->priv->_mpd_hostname), NULL), _tmp1_);
+ self->priv->_mpd_port = 6600;
+ _tmp2_ = NULL;
+ self->priv->_mpd_password = (_tmp2_ = g_strdup (""), self->priv->_mpd_password = (g_free (self->priv->_mpd_password), NULL), _tmp2_);
+ self->priv->_mpd_use_defaults = TRUE;
+ self->priv->_show_statusbar = TRUE;
+ self->priv->_song_format = XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE;
+ _tmp3_ = NULL;
+ self->priv->_song_format_custom = (_tmp3_ = g_strdup (""), self->priv->_song_format_custom = (g_free (self->priv->_song_format_custom), NULL), _tmp3_);
+ xfmpc_preferences_load (self);
+ return self;
+}
-GType
-xfmpc_preferences_get_type ()
-{
- static GType xfmpc_preferences_type = G_TYPE_INVALID;
- if (G_UNLIKELY (xfmpc_preferences_type == G_TYPE_INVALID))
- {
- static const GTypeInfo xfmpc_preferences_info =
- {
- sizeof (XfmpcPreferencesClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) xfmpc_preferences_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (XfmpcPreferences),
- 0,
- (GInstanceInitFunc) xfmpc_preferences_init,
- NULL
- };
- xfmpc_preferences_type = g_type_register_static (G_TYPE_OBJECT, "XfmpcPreferences", &xfmpc_preferences_info, 0);
- }
-
- return xfmpc_preferences_type;
+XfmpcPreferences* xfmpc_preferences_new (void) {
+ return xfmpc_preferences_construct (XFMPC_TYPE_PREFERENCES);
}
+XfmpcPreferences* xfmpc_preferences_get (void) {
+ if (xfmpc_preferences_preferences == NULL) {
+ XfmpcPreferences* _tmp0_;
+ _tmp0_ = NULL;
+ xfmpc_preferences_preferences = (_tmp0_ = xfmpc_preferences_new (), (xfmpc_preferences_preferences == NULL) ? NULL : (xfmpc_preferences_preferences = (g_object_unref (xfmpc_preferences_preferences), NULL)), _tmp0_);
+ } else {
+ g_object_ref ((GObject*) xfmpc_preferences_preferences);
+ }
+ return xfmpc_preferences_preferences;
+}
-static void
-xfmpc_preferences_class_init (XfmpcPreferencesClass *klass)
-{
- GObjectClass *gobject_class;
- parent_class = g_type_class_peek_parent (klass);
+static void xfmpc_preferences_load (XfmpcPreferences* self) {
+ XfceRc* rc;
+ char* entry;
+ GValue _tmp0_ = {0};
+ GValue src;
+ g_return_if_fail (self != NULL);
+ rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "xfce4/xfmpcrc", FALSE);
+ if (rc == NULL) {
+ g_warning ("preferences.vala:142: Failed to load the preferences");
+ (rc == NULL) ? NULL : (rc = (xfce_rc_close (rc), NULL));
+ return;
+ }
+ g_object_freeze_notify ((GObject*) self);
+ xfce_rc_set_group (rc, "Configuration");
+ entry = NULL;
+ src = (g_value_init (&_tmp0_, G_TYPE_STRING), _tmp0_);
+ {
+ gint _tmp1_;
+ GParamSpec** spec_collection;
+ int spec_collection_length1;
+ int spec_it;
+ spec_collection = g_object_class_list_properties ((GObjectClass*) g_type_class_peek (G_TYPE_FROM_INSTANCE ((GObject*) self)), &_tmp1_);
+ spec_collection_length1 = _tmp1_;
+ for (spec_it = 0; spec_it < _tmp1_; spec_it = spec_it + 1) {
+ GParamSpec* _tmp4_;
+ GParamSpec* spec;
+ _tmp4_ = NULL;
+ spec = (_tmp4_ = spec_collection[spec_it], (_tmp4_ == NULL) ? NULL : g_param_spec_ref (_tmp4_));
+ {
+ char* _tmp3_;
+ const char* _tmp2_;
+ _tmp3_ = NULL;
+ _tmp2_ = NULL;
+ entry = (_tmp3_ = (_tmp2_ = xfce_rc_read_entry (rc, g_param_spec_get_nick (spec), ""), (_tmp2_ == NULL) ? NULL : g_strdup (_tmp2_)), entry = (g_free (entry), NULL), _tmp3_);
+ if (_vala_strcmp0 (entry, "") == 0) {
+ (spec == NULL) ? NULL : (spec = (g_param_spec_unref (spec), NULL));
+ continue;
+ }
+ g_value_set_static_string (&src, entry);
+ g_object_set_property ((GObject*) self, spec->name, &src);
+ (spec == NULL) ? NULL : (spec = (g_param_spec_unref (spec), NULL));
+ }
+ }
+ }
+ g_object_thaw_notify ((GObject*) self);
+ (rc == NULL) ? NULL : (rc = (xfce_rc_close (rc), NULL));
+ entry = (g_free (entry), NULL);
+ G_IS_VALUE (&src) ? (g_value_unset (&src), NULL) : NULL;
+}
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xfmpc_preferences_finalize;
- gobject_class->get_property = xfmpc_preferences_get_property;
- gobject_class->set_property = xfmpc_preferences_set_property;
- g_object_class_install_property (gobject_class,
- PROP_LAST_WINDOW_POSX,
- g_param_spec_int ("last-window-posx",
- "LastWindowPosx",
- "Window position on axis x",
- -1, G_MAXINT, -1,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_LAST_WINDOW_POSY,
- g_param_spec_int ("last-window-posy",
- "LastWindowPosy",
- "Window position on axis y",
- -1, G_MAXINT, -1,
- G_PARAM_READWRITE));
+static void xfmpc_preferences_store (XfmpcPreferences* self) {
+ XfceRc* rc;
+ char* entry;
+ GValue _tmp0_ = {0};
+ GValue dst;
+ g_return_if_fail (self != NULL);
+ rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "xfce4/xfmpcrc", FALSE);
+ if (rc == NULL) {
+ g_warning ("preferences.vala:171: Failed to save the preferences");
+ (rc == NULL) ? NULL : (rc = (xfce_rc_close (rc), NULL));
+ return;
+ }
+ xfce_rc_set_group (rc, "Configuration");
+ entry = NULL;
+ dst = (g_value_init (&_tmp0_, G_TYPE_STRING), _tmp0_);
+ {
+ gint _tmp1_;
+ GParamSpec** spec_collection;
+ int spec_collection_length1;
+ int spec_it;
+ spec_collection = g_object_class_list_properties ((GObjectClass*) g_type_class_peek (G_TYPE_FROM_INSTANCE ((GObject*) self)), &_tmp1_);
+ spec_collection_length1 = _tmp1_;
+ for (spec_it = 0; spec_it < _tmp1_; spec_it = spec_it + 1) {
+ GParamSpec* _tmp5_;
+ GParamSpec* spec;
+ _tmp5_ = NULL;
+ spec = (_tmp5_ = spec_collection[spec_it], (_tmp5_ == NULL) ? NULL : g_param_spec_ref (_tmp5_));
+ {
+ char* _tmp4_;
+ const char* _tmp3_;
+ if (spec->value_type == G_TYPE_STRING) {
+ g_object_get_property ((GObject*) self, spec->name, &dst);
+ } else {
+ GValue _tmp2_ = {0};
+ GValue src;
+ src = (g_value_init (&_tmp2_, spec->value_type), _tmp2_);
+ g_object_get_property ((GObject*) self, spec->name, &src);
+ g_value_transform (&src, &dst);
+ G_IS_VALUE (&src) ? (g_value_unset (&src), NULL) : NULL;
+ }
+ _tmp4_ = NULL;
+ _tmp3_ = NULL;
+ entry = (_tmp4_ = (_tmp3_ = g_value_get_string (&dst), (_tmp3_ == NULL) ? NULL : g_strdup (_tmp3_)), entry = (g_free (entry), NULL), _tmp4_);
+ if (entry != NULL) {
+ xfce_rc_write_entry (rc, g_param_spec_get_nick (spec), entry);
+ }
+ (spec == NULL) ? NULL : (spec = (g_param_spec_unref (spec), NULL));
+ }
+ }
+ }
+ (rc == NULL) ? NULL : (rc = (xfce_rc_close (rc), NULL));
+ entry = (g_free (entry), NULL);
+ G_IS_VALUE (&dst) ? (g_value_unset (&dst), NULL) : NULL;
+}
- g_object_class_install_property (gobject_class,
- PROP_LAST_WINDOW_WIDTH,
- g_param_spec_int ("last-window-width",
- "LastWindowWidth",
- "Window width",
- -1, G_MAXINT, -1,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_LAST_WINDOW_HEIGHT,
- g_param_spec_int ("last-window-height",
- "LastWindowHeight",
- "Window height",
- -1, G_MAXINT, -1,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_LAST_WINDOW_STATE_STICKY,
- g_param_spec_boolean ("last-window-state-sticky",
- "LastWindowStateSticky",
- "Sticky bit on window",
- FALSE,
- G_PARAM_READWRITE));
+gint xfmpc_preferences_get_last_window_posx (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, 0);
+ return self->priv->_last_window_posx;
+}
- g_object_class_install_property (gobject_class,
- PROP_PLAYLIST_AUTOCENTER,
- g_param_spec_boolean ("playlist-autocenter",
- "PlaylistAutocenter",
- "Auto-centers the current song in the playlist",
- TRUE,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_DBBROWSER_LAST_PATH,
- g_param_spec_string ("dbbrowser-last-path",
- "DbbrowserLastPath",
- "Restores the last path from the database browser",
- "",
- G_PARAM_READWRITE));
+void xfmpc_preferences_set_last_window_posx (XfmpcPreferences* self, gint value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_last_window_posx = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "last-window-posx");
+}
- g_object_class_install_property (gobject_class,
- PROP_MPD_HOST,
- g_param_spec_string ("mpd-hostname",
- "MpdHostname",
- "Hostname of the MPD server",
- "localhost",
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_MPD_PORT,
- g_param_spec_int ("mpd-port",
- "MpdPort",
- "Port of the MPD server",
- 0, 65536, 6600,
- G_PARAM_READWRITE));
+gint xfmpc_preferences_get_last_window_posy (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, 0);
+ return self->priv->_last_window_posy;
+}
- g_object_class_install_property (gobject_class,
- PROP_MPD_PASSWORD,
- g_param_spec_string ("mpd-password",
- "MpdPassword",
- "Password of the MPD server",
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_MPD_USE_DEFAULTS,
- g_param_spec_boolean ("mpd-use-defaults",
- "MpdUseDefaults",
- "Use default system settings for the MPD server (MPD_HOST/PORT environment variables)",
- TRUE,
- G_PARAM_READWRITE));
+void xfmpc_preferences_set_last_window_posy (XfmpcPreferences* self, gint value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_last_window_posy = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "last-window-posy");
+}
- g_object_class_install_property (gobject_class,
- PROP_SHOW_STATUSBAR,
- g_param_spec_boolean ("show-statusbar",
- "ShowStatusbar",
- "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_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));
+gint xfmpc_preferences_get_last_window_width (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, 0);
+ return self->priv->_last_window_width;
}
-static void
-xfmpc_preferences_init (XfmpcPreferences *preferences)
-{
- xfmpc_preferences_load (preferences);
-}
-static void
-xfmpc_preferences_finalize (GObject *object)
-{
- (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+void xfmpc_preferences_set_last_window_width (XfmpcPreferences* self, gint value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_last_window_width = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "last-window-width");
}
-static void
-xfmpc_preferences_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- XfmpcPreferences *preferences = XFMPC_PREFERENCES (object);
- GValue *src;
- src = preferences->values + prop_id;
- if (G_LIKELY (G_IS_VALUE (src)))
- g_value_copy (src, value);
- else
- g_param_value_set_default (pspec, value);
+gint xfmpc_preferences_get_last_window_height (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, 0);
+ return self->priv->_last_window_height;
}
-static void
-xfmpc_preferences_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- XfmpcPreferences *preferences = XFMPC_PREFERENCES (object);
- GValue *dst;
- dst = preferences->values + prop_id;
- if (G_UNLIKELY (!G_IS_VALUE (dst)))
- {
- g_value_init (dst, pspec->value_type);
- g_param_value_set_default (pspec, dst);
- }
-
- if (G_LIKELY (g_param_values_cmp (pspec, value, dst) != 0))
- {
- g_value_copy (value, dst);
- xfmpc_preferences_store (preferences);
- }
+void xfmpc_preferences_set_last_window_height (XfmpcPreferences* self, gint value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_last_window_height = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "last-window-height");
}
-XfmpcPreferences *
-xfmpc_preferences_get ()
-{
- static XfmpcPreferences *preferences = NULL;
- if (G_UNLIKELY (NULL == preferences))
- {
- preferences = g_object_new (XFMPC_TYPE_PREFERENCES, NULL);
- g_object_add_weak_pointer (G_OBJECT (preferences), (gpointer)&preferences);
- }
- else
- g_object_ref (G_OBJECT (preferences));
-
- return preferences;
+gboolean xfmpc_preferences_get_last_window_state_sticky (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ return self->priv->_last_window_state_sticky;
}
-static void
-xfmpc_preferences_load (XfmpcPreferences *preferences)
-{
- const gchar *string;
- GParamSpec **specs;
- GParamSpec *spec;
- GValue dst = { 0, };
- GValue src = { 0, };
- XfceRc *rc;
- guint nspecs;
- guint n;
- rc = xfmpc_preferences_get_rc (preferences);
- if (G_UNLIKELY (NULL == rc))
- {
- g_warning ("Failed to load the preferences");
- return;
- }
+void xfmpc_preferences_set_last_window_state_sticky (XfmpcPreferences* self, gboolean value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_last_window_state_sticky = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "last-window-state-sticky");
+}
- g_object_freeze_notify (G_OBJECT (preferences));
- xfce_rc_set_group (rc, "Configuration");
+gboolean xfmpc_preferences_get_playlist_autocenter (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ return self->priv->_playlist_autocenter;
+}
- specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
- for (n = 0; n < nspecs; ++n)
- {
- spec = specs[n];
- string = xfce_rc_read_entry (rc, g_param_spec_get_nick (spec), NULL);
+void xfmpc_preferences_set_playlist_autocenter (XfmpcPreferences* self, gboolean value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_playlist_autocenter = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "playlist-autocenter");
+}
- if (G_UNLIKELY (NULL == string))
- continue;
- g_value_init (&src, G_TYPE_STRING);
- g_value_set_static_string (&src, string);
+const char* xfmpc_preferences_get_dbbrowser_last_path (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, NULL);
+ return self->priv->_dbbrowser_last_path;
+}
- if (spec->value_type == G_TYPE_STRING)
- g_object_set_property (G_OBJECT (preferences), spec->name, &src);
- else if (g_value_type_transformable (G_TYPE_STRING, spec->value_type))
- {
- g_value_init (&dst, spec->value_type);
- if (g_value_transform (&src, &dst))
- g_object_set_property (G_OBJECT (preferences), spec->name, &dst);
- g_value_unset (&dst);
- }
- else
- g_warning ("Failed to load property \"%s\"", spec->name);
- g_value_unset (&src);
- }
- g_free (specs);
+void xfmpc_preferences_set_dbbrowser_last_path (XfmpcPreferences* self, const char* value) {
+ char* _tmp2_;
+ const char* _tmp1_;
+ g_return_if_fail (self != NULL);
+ _tmp2_ = NULL;
+ _tmp1_ = NULL;
+ self->priv->_dbbrowser_last_path = (_tmp2_ = (_tmp1_ = value, (_tmp1_ == NULL) ? NULL : g_strdup (_tmp1_)), self->priv->_dbbrowser_last_path = (g_free (self->priv->_dbbrowser_last_path), NULL), _tmp2_);
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "dbbrowser-last-path");
+}
- g_object_thaw_notify (G_OBJECT (preferences));
- xfce_rc_close (rc);
+const char* xfmpc_preferences_get_mpd_hostname (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, NULL);
+ return self->priv->_mpd_hostname;
}
-static void
-xfmpc_preferences_store (XfmpcPreferences *preferences)
-{
- const gchar *string;
- GParamSpec **specs;
- GParamSpec *spec;
- GValue dst = { 0, };
- GValue src = { 0, };
- XfceRc *rc;
- guint nspecs;
- guint n;
- rc = xfmpc_preferences_get_rc (preferences);
+void xfmpc_preferences_set_mpd_hostname (XfmpcPreferences* self, const char* value) {
+ char* _tmp2_;
+ const char* _tmp1_;
+ g_return_if_fail (self != NULL);
+ _tmp2_ = NULL;
+ _tmp1_ = NULL;
+ self->priv->_mpd_hostname = (_tmp2_ = (_tmp1_ = value, (_tmp1_ == NULL) ? NULL : g_strdup (_tmp1_)), self->priv->_mpd_hostname = (g_free (self->priv->_mpd_hostname), NULL), _tmp2_);
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "mpd-hostname");
+}
- if (G_UNLIKELY (NULL == rc))
- {
- g_warning ("Failed to save the preferences");
- return;
- }
- xfce_rc_set_group (rc, "Configuration");
+gint xfmpc_preferences_get_mpd_port (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, 0);
+ return self->priv->_mpd_port;
+}
- specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
- for (n = 0; n < nspecs; ++n)
- {
- spec = specs[n];
- g_value_init (&dst, G_TYPE_STRING);
+void xfmpc_preferences_set_mpd_port (XfmpcPreferences* self, gint value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_mpd_port = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "mpd-port");
+}
- if (spec->value_type == G_TYPE_STRING)
- g_object_get_property (G_OBJECT (preferences), spec->name, &dst);
- else
- {
- g_value_init (&src, spec->value_type);
- g_object_get_property (G_OBJECT (preferences), spec->name, &src);
- g_value_transform (&src, &dst);
- g_value_unset (&src);
- }
- string = g_value_get_string (&dst);
+const char* xfmpc_preferences_get_mpd_password (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, NULL);
+ return self->priv->_mpd_password;
+}
- if (G_LIKELY (NULL != string))
- xfce_rc_write_entry (rc, g_param_spec_get_nick (spec), string);
- g_value_unset (&dst);
- }
- g_free (specs);
-
- xfce_rc_close (rc);
+void xfmpc_preferences_set_mpd_password (XfmpcPreferences* self, const char* value) {
+ char* _tmp2_;
+ const char* _tmp1_;
+ g_return_if_fail (self != NULL);
+ _tmp2_ = NULL;
+ _tmp1_ = NULL;
+ self->priv->_mpd_password = (_tmp2_ = (_tmp1_ = value, (_tmp1_ == NULL) ? NULL : g_strdup (_tmp1_)), self->priv->_mpd_password = (g_free (self->priv->_mpd_password), NULL), _tmp2_);
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "mpd-password");
}
-static XfceRc *
-xfmpc_preferences_get_rc (XfmpcPreferences *preferences)
-{
- return xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "xfce4/xfmpcrc", FALSE);
+
+gboolean xfmpc_preferences_get_mpd_use_defaults (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ return self->priv->_mpd_use_defaults;
}
-
-gint
-xfmpc_preferences_get_last_window_posx (XfmpcPreferences *preferences)
-{
- gint dst;
- g_object_get (G_OBJECT (preferences), "last-window-posx", &dst, NULL);
- return dst;
+void xfmpc_preferences_set_mpd_use_defaults (XfmpcPreferences* self, gboolean value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_mpd_use_defaults = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "mpd-use-defaults");
}
-gint
-xfmpc_preferences_get_last_window_posy (XfmpcPreferences *preferences)
-{
- gint dst;
- g_object_get (G_OBJECT (preferences), "last-window-posy", &dst, NULL);
- return dst;
-}
-gint
-xfmpc_preferences_get_last_window_width (XfmpcPreferences *preferences)
-{
- gint dst;
- g_object_get (G_OBJECT (preferences), "last-window-width", &dst, NULL);
- return dst;
+gboolean xfmpc_preferences_get_show_statusbar (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ return self->priv->_show_statusbar;
}
-gint
-xfmpc_preferences_get_last_window_height (XfmpcPreferences *preferences)
-{
- gint dst;
- g_object_get (G_OBJECT (preferences), "last-window-width", &dst, NULL);
- return dst;
-}
-gboolean
-xfmpc_preferences_get_last_window_state_sticky (XfmpcPreferences *preferences)
-{
- gboolean dst;
- g_object_get (G_OBJECT (preferences), "last-window-state-sticky", &dst, NULL);
- return dst;
+void xfmpc_preferences_set_show_statusbar (XfmpcPreferences* self, gboolean value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_show_statusbar = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "show-statusbar");
}
-gboolean
-xfmpc_preferences_get_playlist_autocenter (XfmpcPreferences *preferences)
-{
- gboolean dst;
- g_object_get (G_OBJECT (preferences), "last-window-state-sticky", &dst, NULL);
- return dst;
-}
-gchar *
-xfmpc_preferences_get_dbbrowser_last_path (XfmpcPreferences *preferences)
-{
- gchar *dst;
- g_object_get (G_OBJECT (preferences), "dbbrowser-last-path", &dst, NULL);
- return dst;
+XfmpcPreferencesSongFormat xfmpc_preferences_get_song_format (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, 0);
+ return self->priv->_song_format;
}
-gchar *
-xfmpc_preferences_get_mpd_hostname (XfmpcPreferences *preferences)
-{
- gchar *dst;
- g_object_get (G_OBJECT (preferences), "mpd-hostname", &dst, NULL);
- return dst;
-}
-gint
-xfmpc_preferences_get_mpd_port (XfmpcPreferences *preferences)
-{
- gint dst;
- g_object_get (G_OBJECT (preferences), "mpd-port", &dst, NULL);
- return dst;
+void xfmpc_preferences_set_song_format (XfmpcPreferences* self, XfmpcPreferencesSongFormat value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_song_format = value;
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "song-format");
}
-gchar *
-xfmpc_preferences_get_mpd_password (XfmpcPreferences *preferences)
-{
- gchar *dst;
- g_object_get (G_OBJECT (preferences), "mpd-password", &dst, NULL);
- return dst;
-}
-gboolean
-xfmpc_preferences_get_mpd_use_defaults (XfmpcPreferences *preferences)
-{
- gboolean dst;
- g_object_get (G_OBJECT (preferences), "mpd-use-defaults", &dst, NULL);
- return dst;
+const char* xfmpc_preferences_get_song_format_custom (XfmpcPreferences* self) {
+ g_return_val_if_fail (self != NULL, NULL);
+ return self->priv->_song_format_custom;
}
-gboolean
-xfmpc_preferences_get_show_statusbar (XfmpcPreferences *preferences)
-{
- gboolean dst;
- g_object_get (G_OBJECT (preferences), "show-statusbar", &dst, NULL);
- return dst;
-}
-gint
-xfmpc_preferences_get_song_format (XfmpcPreferences *preferences)
-{
- gint dst;
- g_object_get (G_OBJECT (preferences), "song-format", &dst, NULL);
- return dst;
+void xfmpc_preferences_set_song_format_custom (XfmpcPreferences* self, const char* value) {
+ char* _tmp2_;
+ const char* _tmp1_;
+ g_return_if_fail (self != NULL);
+ _tmp2_ = NULL;
+ _tmp1_ = NULL;
+ self->priv->_song_format_custom = (_tmp2_ = (_tmp1_ = value, (_tmp1_ == NULL) ? NULL : g_strdup (_tmp1_)), self->priv->_song_format_custom = (g_free (self->priv->_song_format_custom), NULL), _tmp2_);
+ xfmpc_preferences_store (self);
+ g_object_notify ((GObject *) self, "song-format-custom");
}
-gchar *
-xfmpc_preferences_get_song_format_custom (XfmpcPreferences *preferences)
-{
- gchar *dst;
- g_object_get (G_OBJECT (preferences), "song-format-custom", &dst, NULL);
- return dst;
+
+static void xfmpc_preferences_class_init (XfmpcPreferencesClass * klass) {
+ xfmpc_preferences_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (XfmpcPreferencesPrivate));
+ G_OBJECT_CLASS (klass)->get_property = xfmpc_preferences_get_property;
+ G_OBJECT_CLASS (klass)->set_property = xfmpc_preferences_set_property;
+ G_OBJECT_CLASS (klass)->finalize = xfmpc_preferences_finalize;
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_LAST_WINDOW_POSX, g_param_spec_int ("last-window-posx", "last-window-posx", "last-window-posx", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_LAST_WINDOW_POSY, g_param_spec_int ("last-window-posy", "last-window-posy", "last-window-posy", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_LAST_WINDOW_WIDTH, g_param_spec_int ("last-window-width", "last-window-width", "last-window-width", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_LAST_WINDOW_HEIGHT, g_param_spec_int ("last-window-height", "last-window-height", "last-window-height", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_LAST_WINDOW_STATE_STICKY, g_param_spec_boolean ("last-window-state-sticky", "last-window-state-sticky", "last-window-state-sticky", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_PLAYLIST_AUTOCENTER, g_param_spec_boolean ("playlist-autocenter", "playlist-autocenter", "playlist-autocenter", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_DBBROWSER_LAST_PATH, g_param_spec_string ("dbbrowser-last-path", "dbbrowser-last-path", "dbbrowser-last-path", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_MPD_HOSTNAME, g_param_spec_string ("mpd-hostname", "mpd-hostname", "mpd-hostname", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_MPD_PORT, g_param_spec_int ("mpd-port", "mpd-port", "mpd-port", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_MPD_PASSWORD, g_param_spec_string ("mpd-password", "mpd-password", "mpd-password", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_MPD_USE_DEFAULTS, g_param_spec_boolean ("mpd-use-defaults", "mpd-use-defaults", "mpd-use-defaults", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_SHOW_STATUSBAR, g_param_spec_boolean ("show-statusbar", "show-statusbar", "show-statusbar", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_SONG_FORMAT, g_param_spec_enum ("song-format", "song-format", "song-format", XFMPC_PREFERENCES_TYPE_SONG_FORMAT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM, g_param_spec_string ("song-format-custom", "song-format-custom", "song-format-custom", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}
-
-void
-xfmpc_preferences_set_last_window_posx (XfmpcPreferences *preferences, gint src)
-{
- g_object_set (G_OBJECT (preferences), "last-window-posx", src, NULL);
+static void xfmpc_preferences_instance_init (XfmpcPreferences * self) {
+ self->priv = XFMPC_PREFERENCES_GET_PRIVATE (self);
}
-void
-xfmpc_preferences_set_last_window_posy (XfmpcPreferences *preferences, gint src)
-{
- g_object_set (G_OBJECT (preferences), "last-window-posy", src, NULL);
-}
-void
-xfmpc_preferences_set_last_window_width (XfmpcPreferences *preferences, gint src)
-{
- g_object_set (G_OBJECT (preferences), "last-window-width", src, NULL);
+static void xfmpc_preferences_finalize (GObject* obj) {
+ XfmpcPreferences * self;
+ self = XFMPC_PREFERENCES (obj);
+ self->priv->_dbbrowser_last_path = (g_free (self->priv->_dbbrowser_last_path), NULL);
+ self->priv->_mpd_hostname = (g_free (self->priv->_mpd_hostname), NULL);
+ self->priv->_mpd_password = (g_free (self->priv->_mpd_password), NULL);
+ self->priv->_song_format_custom = (g_free (self->priv->_song_format_custom), NULL);
+ G_OBJECT_CLASS (xfmpc_preferences_parent_class)->finalize (obj);
}
-void
-xfmpc_preferences_set_last_window_height (XfmpcPreferences *preferences, gint src)
-{
- g_object_set (G_OBJECT (preferences), "last-window-width", src, NULL);
-}
-void
-xfmpc_preferences_set_last_window_state_sticky (XfmpcPreferences *preferences, gboolean src)
-{
- g_object_set (G_OBJECT (preferences), "last-window-state-sticky", src, NULL);
+GType xfmpc_preferences_get_type (void) {
+ static GType xfmpc_preferences_type_id = 0;
+ if (xfmpc_preferences_type_id == 0) {
+ static const GTypeInfo g_define_type_info = { sizeof (XfmpcPreferencesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xfmpc_preferences_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XfmpcPreferences), 0, (GInstanceInitFunc) xfmpc_preferences_instance_init, NULL };
+ xfmpc_preferences_type_id = g_type_register_static (G_TYPE_OBJECT, "XfmpcPreferences", &g_define_type_info, 0);
+ }
+ return xfmpc_preferences_type_id;
}
-void
-xfmpc_preferences_set_playlist_autocenter (XfmpcPreferences *preferences, gboolean src)
-{
- g_object_set (G_OBJECT (preferences), "state-sticky", src, NULL);
-}
-void
-xfmpc_preferences_set_dbbrowser_last_path (XfmpcPreferences *preferences, gchar *src)
-{
- g_object_set (G_OBJECT (preferences), "dbbrowser-last-path", src, NULL);
+static void xfmpc_preferences_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
+ XfmpcPreferences * self;
+ gpointer boxed;
+ self = XFMPC_PREFERENCES (object);
+ switch (property_id) {
+ case XFMPC_PREFERENCES_LAST_WINDOW_POSX:
+ g_value_set_int (value, xfmpc_preferences_get_last_window_posx (self));
+ break;
+ case XFMPC_PREFERENCES_LAST_WINDOW_POSY:
+ g_value_set_int (value, xfmpc_preferences_get_last_window_posy (self));
+ break;
+ case XFMPC_PREFERENCES_LAST_WINDOW_WIDTH:
+ g_value_set_int (value, xfmpc_preferences_get_last_window_width (self));
+ break;
+ case XFMPC_PREFERENCES_LAST_WINDOW_HEIGHT:
+ g_value_set_int (value, xfmpc_preferences_get_last_window_height (self));
+ break;
+ case XFMPC_PREFERENCES_LAST_WINDOW_STATE_STICKY:
+ g_value_set_boolean (value, xfmpc_preferences_get_last_window_state_sticky (self));
+ break;
+ case XFMPC_PREFERENCES_PLAYLIST_AUTOCENTER:
+ g_value_set_boolean (value, xfmpc_preferences_get_playlist_autocenter (self));
+ break;
+ case XFMPC_PREFERENCES_DBBROWSER_LAST_PATH:
+ g_value_set_string (value, xfmpc_preferences_get_dbbrowser_last_path (self));
+ break;
+ case XFMPC_PREFERENCES_MPD_HOSTNAME:
+ g_value_set_string (value, xfmpc_preferences_get_mpd_hostname (self));
+ break;
+ case XFMPC_PREFERENCES_MPD_PORT:
+ g_value_set_int (value, xfmpc_preferences_get_mpd_port (self));
+ break;
+ case XFMPC_PREFERENCES_MPD_PASSWORD:
+ g_value_set_string (value, xfmpc_preferences_get_mpd_password (self));
+ break;
+ case XFMPC_PREFERENCES_MPD_USE_DEFAULTS:
+ g_value_set_boolean (value, xfmpc_preferences_get_mpd_use_defaults (self));
+ break;
+ case XFMPC_PREFERENCES_SHOW_STATUSBAR:
+ g_value_set_boolean (value, xfmpc_preferences_get_show_statusbar (self));
+ break;
+ case XFMPC_PREFERENCES_SONG_FORMAT:
+ g_value_set_enum (value, xfmpc_preferences_get_song_format (self));
+ break;
+ case XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM:
+ g_value_set_string (value, xfmpc_preferences_get_song_format_custom (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
-void
-xfmpc_preferences_set_mpd_hostname (XfmpcPreferences *preferences, gchar *src)
-{
- g_object_set (G_OBJECT (preferences), "mpd-hostname", src, NULL);
-}
-void
-xfmpc_preferences_set_mpd_port (XfmpcPreferences *preferences, gint src)
-{
- g_object_set (G_OBJECT (preferences), "mpd-port", src, NULL);
+static void xfmpc_preferences_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
+ XfmpcPreferences * self;
+ self = XFMPC_PREFERENCES (object);
+ switch (property_id) {
+ case XFMPC_PREFERENCES_LAST_WINDOW_POSX:
+ xfmpc_preferences_set_last_window_posx (self, g_value_get_int (value));
+ break;
+ case XFMPC_PREFERENCES_LAST_WINDOW_POSY:
+ xfmpc_preferences_set_last_window_posy (self, g_value_get_int (value));
+ break;
+ case XFMPC_PREFERENCES_LAST_WINDOW_WIDTH:
+ xfmpc_preferences_set_last_window_width (self, g_value_get_int (value));
+ break;
+ case XFMPC_PREFERENCES_LAST_WINDOW_HEIGHT:
+ xfmpc_preferences_set_last_window_height (self, g_value_get_int (value));
+ break;
+ case XFMPC_PREFERENCES_LAST_WINDOW_STATE_STICKY:
+ xfmpc_preferences_set_last_window_state_sticky (self, g_value_get_boolean (value));
+ break;
+ case XFMPC_PREFERENCES_PLAYLIST_AUTOCENTER:
+ xfmpc_preferences_set_playlist_autocenter (self, g_value_get_boolean (value));
+ break;
+ case XFMPC_PREFERENCES_DBBROWSER_LAST_PATH:
+ xfmpc_preferences_set_dbbrowser_last_path (self, g_value_get_string (value));
+ break;
+ case XFMPC_PREFERENCES_MPD_HOSTNAME:
+ xfmpc_preferences_set_mpd_hostname (self, g_value_get_string (value));
+ break;
+ case XFMPC_PREFERENCES_MPD_PORT:
+ xfmpc_preferences_set_mpd_port (self, g_value_get_int (value));
+ break;
+ case XFMPC_PREFERENCES_MPD_PASSWORD:
+ xfmpc_preferences_set_mpd_password (self, g_value_get_string (value));
+ break;
+ case XFMPC_PREFERENCES_MPD_USE_DEFAULTS:
+ xfmpc_preferences_set_mpd_use_defaults (self, g_value_get_boolean (value));
+ break;
+ case XFMPC_PREFERENCES_SHOW_STATUSBAR:
+ xfmpc_preferences_set_show_statusbar (self, g_value_get_boolean (value));
+ break;
+ case XFMPC_PREFERENCES_SONG_FORMAT:
+ xfmpc_preferences_set_song_format (self, g_value_get_enum (value));
+ break;
+ case XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM:
+ xfmpc_preferences_set_song_format_custom (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
-void
-xfmpc_preferences_set_mpd_password (XfmpcPreferences *preferences, gchar *src)
-{
- g_object_set (G_OBJECT (preferences), "mpd-password", src, NULL);
-}
-void
-xfmpc_preferences_set_mpd_use_defaults (XfmpcPreferences *preferences, gboolean src)
-{
- g_object_set (G_OBJECT (preferences), "mpd-use-defaults", src, NULL);
+static int _vala_strcmp0 (const char * str1, const char * str2) {
+ if (str1 == NULL) {
+ return -(str1 != str2);
+ }
+ if (str2 == NULL) {
+ return str1 != str2;
+ }
+ return strcmp (str1, str2);
}
-void
-xfmpc_preferences_set_show_statusbar (XfmpcPreferences *preferences, gboolean src)
-{
- g_object_set (G_OBJECT (preferences), "show-statusbar", src, NULL);
-}
-void
-xfmpc_preferences_set_song_format (XfmpcPreferences *preferences, gint src)
-{
- g_object_set (G_OBJECT (preferences), "song-format", src, NULL);
-}
-void
-xfmpc_preferences_set_song_format_custom (XfmpcPreferences *preferences, gchar *src)
-{
- g_object_set (G_OBJECT (preferences), "song-format-custom", src, NULL);
-}
+
Added: xfmpc/trunk/src/preferences.vala
===================================================================
--- xfmpc/trunk/src/preferences.vala (rev 0)
+++ xfmpc/trunk/src/preferences.vala 2009-06-16 19:25:03 UTC (rev 7600)
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using Gtk;
+
+namespace Xfmpc {
+
+ public class Preferences : GLib.Object {
+
+ static Preferences preferences;
+
+ public enum SongFormat
+ {
+ TITLE,
+ ALBUM_TITLE,
+ ARTIST_TITLE,
+ ARTIST_TITLE_DATE,
+ ARTIST_ALBUM_TITLE,
+ ARTIST_ALBUM_TRACK_TITLE,
+ CUSTOM_FORMAT,
+ }
+
+ private int _last_window_posx;
+ public int last_window_posx {
+ get { return _last_window_posx; }
+ set { _last_window_posx = value; store (); }
+ }
+ private int _last_window_posy;
+ public int last_window_posy {
+ get { return _last_window_posy; }
+ set { _last_window_posy = value; store (); }
+ }
+ private int _last_window_width;
+ public int last_window_width {
+ get { return _last_window_width; }
+ set { _last_window_width = value; store (); }
+ }
+ private int _last_window_height;
+ public int last_window_height {
+ get { return _last_window_height; }
+ set { _last_window_height = value; store (); }
+ }
+ private bool _last_window_state_sticky;
+ public bool last_window_state_sticky {
+ get { return _last_window_state_sticky; }
+ set { _last_window_state_sticky = value; store (); }
+ }
+ private bool _playlist_autocenter;
+ public bool playlist_autocenter {
+ get { return _playlist_autocenter; }
+ set { _playlist_autocenter = value; store (); }
+ }
+ private string _dbbrowser_last_path;
+ public string dbbrowser_last_path {
+ get { return _dbbrowser_last_path; }
+ set { _dbbrowser_last_path = value; store (); }
+ }
+ private string _mpd_hostname;
+ public string mpd_hostname {
+ get { return _mpd_hostname; }
+ set { _mpd_hostname = value; store (); }
+ }
+ private int _mpd_port;
+ public int mpd_port {
+ get { return _mpd_port; }
+ set { _mpd_port = value; store (); }
+ }
+ private string _mpd_password;
+ public string mpd_password {
+ get { return _mpd_password; }
+ set { _mpd_password = value; store (); }
+ }
+ private bool _mpd_use_defaults;
+ public bool mpd_use_defaults {
+ get { return _mpd_use_defaults; }
+ set { _mpd_use_defaults = value; store (); }
+ }
+ private bool _show_statusbar;
+ public bool show_statusbar {
+ get { return _show_statusbar; }
+ set { _show_statusbar = value; store (); }
+ }
+ private SongFormat _song_format;
+ public SongFormat song_format {
+ get { return _song_format; }
+ set { _song_format = value; store (); }
+ }
+ private string _song_format_custom;
+ public string song_format_custom {
+ get { return _song_format_custom; }
+ set { _song_format_custom = value; store (); }
+ }
+
+ public Preferences () {
+ _last_window_posx = 200;
+ _last_window_posy = 100;
+ _last_window_width = 330;
+ _last_window_height = 330;
+ _last_window_state_sticky = true;
+ _playlist_autocenter = true;
+ _dbbrowser_last_path = "";
+ _mpd_hostname = "localhost";
+ _mpd_port = 6600;
+ _mpd_password = "";
+ _mpd_use_defaults = true;
+ _show_statusbar = true;
+ _song_format = SongFormat.ARTIST_TITLE;
+ _song_format_custom = "";
+
+ load ();
+ }
+
+ public new static unowned Preferences get () {
+ if (preferences == null)
+ preferences = new Preferences ();
+ else
+ preferences.ref ();
+
+ return preferences;
+ }
+
+ private void load () {
+ Xfce.Rc rc = new Xfce.Rc.from_resource (Xfce.ResourceType.CONFIG, "xfce4/xfmpcrc", false);
+
+ if (rc == null) {
+ GLib.warning ("Failed to load the preferences");
+ return;
+ }
+
+ freeze_notify ();
+
+ rc.set_group ("Configuration");
+
+ string entry;
+ GLib.Value src = Value (typeof (string));
+
+ foreach (var spec in ((ObjectClass)(get_type ().class_peek ())).list_properties ())
+ {
+ entry = rc.read_entry (spec.get_nick (), "");
+ if (entry == "")
+ continue;
+
+ src.set_static_string (entry);
+ set_property (spec.name, src);
+ }
+
+ thaw_notify ();
+ }
+
+ private void store () {
+ Xfce.Rc rc = new Xfce.Rc.from_resource (Xfce.ResourceType.CONFIG, "xfce4/xfmpcrc", false);
+
+ if (rc == null) {
+ GLib.warning ("Failed to save the preferences");
+ return;
+ }
+
+ rc.set_group ("Configuration");
+
+ string entry;
+ GLib.Value dst = Value (typeof (string));
+
+ foreach (var spec in ((ObjectClass)(get_type ().class_peek ())).list_properties ())
+ {
+ if (spec.value_type == typeof (string))
+ get_property (spec.name, ref dst);
+ else
+ {
+ GLib.Value src = Value (spec.value_type);
+ get_property (spec.name, ref src);
+ src.transform (ref dst);
+ }
+
+ entry = dst.get_string ();
+ if (entry != null)
+ rc.write_entry (spec.get_nick (), entry);
+ }
+ }
+ }
+}
+
+/* vi:set ts=8 sw=8: */
Modified: xfmpc/trunk/src/xfmpc.h
===================================================================
--- xfmpc/trunk/src/xfmpc.h 2009-06-16 18:51:39 UTC (rev 7599)
+++ xfmpc/trunk/src/xfmpc.h 2009-06-16 19:25:03 UTC (rev 7600)
@@ -9,6 +9,7 @@
#include <string.h>
#include <float.h>
#include <math.h>
+#include <glib-object.h>
G_BEGIN_DECLS
@@ -103,6 +104,19 @@
typedef struct _XfmpcPlaylistClass XfmpcPlaylistClass;
typedef struct _XfmpcPlaylistPrivate XfmpcPlaylistPrivate;
+#define XFMPC_TYPE_PREFERENCES (xfmpc_preferences_get_type ())
+#define XFMPC_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferences))
+#define XFMPC_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+#define XFMPC_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES))
+#define XFMPC_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES, XfmpcPreferencesClass))
+
+typedef struct _XfmpcPreferences XfmpcPreferences;
+typedef struct _XfmpcPreferencesClass XfmpcPreferencesClass;
+typedef struct _XfmpcPreferencesPrivate XfmpcPreferencesPrivate;
+
+#define XFMPC_PREFERENCES_TYPE_SONG_FORMAT (xfmpc_preferences_song_format_get_type ())
+
struct _XfmpcPreferencesDialog {
XfceTitledDialog parent_instance;
XfmpcPreferencesDialogPrivate * priv;
@@ -180,7 +194,26 @@
GtkVBoxClass parent_class;
};
+struct _XfmpcPreferences {
+ GObject parent_instance;
+ XfmpcPreferencesPrivate * priv;
+};
+struct _XfmpcPreferencesClass {
+ GObjectClass parent_class;
+};
+
+typedef enum {
+ XFMPC_PREFERENCES_SONG_FORMAT_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ALBUM_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_TITLE_DATE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE,
+ XFMPC_PREFERENCES_SONG_FORMAT_CUSTOM_FORMAT
+} XfmpcPreferencesSongFormat;
+
+
GType xfmpc_preferences_dialog_get_type (void);
XfmpcPreferencesDialog* xfmpc_preferences_dialog_new (void);
XfmpcPreferencesDialog* xfmpc_preferences_dialog_construct (GType object_type);
@@ -227,6 +260,39 @@
void xfmpc_playlist_delete_selection (XfmpcPlaylist* self);
XfmpcPlaylist* xfmpc_playlist_new (void);
XfmpcPlaylist* xfmpc_playlist_construct (GType object_type);
+GType xfmpc_preferences_get_type (void);
+GType xfmpc_preferences_song_format_get_type (void);
+XfmpcPreferences* xfmpc_preferences_new (void);
+XfmpcPreferences* xfmpc_preferences_construct (GType object_type);
+XfmpcPreferences* xfmpc_preferences_get (void);
+gint xfmpc_preferences_get_last_window_posx (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_posx (XfmpcPreferences* self, gint value);
+gint xfmpc_preferences_get_last_window_posy (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_posy (XfmpcPreferences* self, gint value);
+gint xfmpc_preferences_get_last_window_width (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_width (XfmpcPreferences* self, gint value);
+gint xfmpc_preferences_get_last_window_height (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_height (XfmpcPreferences* self, gint value);
+gboolean xfmpc_preferences_get_last_window_state_sticky (XfmpcPreferences* self);
+void xfmpc_preferences_set_last_window_state_sticky (XfmpcPreferences* self, gboolean value);
+gboolean xfmpc_preferences_get_playlist_autocenter (XfmpcPreferences* self);
+void xfmpc_preferences_set_playlist_autocenter (XfmpcPreferences* self, gboolean value);
+const char* xfmpc_preferences_get_dbbrowser_last_path (XfmpcPreferences* self);
+void xfmpc_preferences_set_dbbrowser_last_path (XfmpcPreferences* self, const char* value);
+const char* xfmpc_preferences_get_mpd_hostname (XfmpcPreferences* self);
+void xfmpc_preferences_set_mpd_hostname (XfmpcPreferences* self, const char* value);
+gint xfmpc_preferences_get_mpd_port (XfmpcPreferences* self);
+void xfmpc_preferences_set_mpd_port (XfmpcPreferences* self, gint value);
+const char* xfmpc_preferences_get_mpd_password (XfmpcPreferences* self);
+void xfmpc_preferences_set_mpd_password (XfmpcPreferences* self, const char* value);
+gboolean xfmpc_preferences_get_mpd_use_defaults (XfmpcPreferences* self);
+void xfmpc_preferences_set_mpd_use_defaults (XfmpcPreferences* self, gboolean value);
+gboolean xfmpc_preferences_get_show_statusbar (XfmpcPreferences* self);
+void xfmpc_preferences_set_show_statusbar (XfmpcPreferences* self, gboolean value);
+XfmpcPreferencesSongFormat xfmpc_preferences_get_song_format (XfmpcPreferences* self);
+void xfmpc_preferences_set_song_format (XfmpcPreferences* self, XfmpcPreferencesSongFormat value);
+const char* xfmpc_preferences_get_song_format_custom (XfmpcPreferences* self);
+void xfmpc_preferences_set_song_format_custom (XfmpcPreferences* self, const char* value);
G_END_DECLS
More information about the Goodies-commits
mailing list