[Goodies-commits] r7280 - in xfmpc/trunk: . src vapi
Vincent Legout
vincent at xfce.org
Thu Apr 23 13:11:40 CEST 2009
Author: vincent
Date: 2009-04-23 11:11:39 +0000 (Thu, 23 Apr 2009)
New Revision: 7280
Added:
xfmpc/trunk/src/dbbrowser.vala
xfmpc/trunk/src/extended-interface.vala
xfmpc/trunk/src/main-ui.h
xfmpc/trunk/src/playlist.vala
xfmpc/trunk/src/preferences-dialog.vala
xfmpc/trunk/src/song-dialog.vala
xfmpc/trunk/src/statusbar.vala
xfmpc/trunk/src/xfmpc.h
xfmpc/trunk/vapi/
xfmpc/trunk/vapi/config.vapi
xfmpc/trunk/vapi/libxfce4util-1.0.vapi
xfmpc/trunk/vapi/libxfcegui4-1.0.vapi
xfmpc/trunk/vapi/mpdclient.vapi
xfmpc/trunk/vapi/preferences.vapi
xfmpc/trunk/vapi/xfce-arrow-button.vapi
Removed:
xfmpc/trunk/src/dbbrowser.h
xfmpc/trunk/src/extended-interface.h
xfmpc/trunk/src/playlist.h
xfmpc/trunk/src/preferences-dialog.h
xfmpc/trunk/src/song-dialog.h
xfmpc/trunk/src/statusbar.h
Modified:
xfmpc/trunk/ChangeLog
xfmpc/trunk/configure.in.in
xfmpc/trunk/src/Makefile.am
xfmpc/trunk/src/dbbrowser.c
xfmpc/trunk/src/extended-interface.c
xfmpc/trunk/src/main-window.c
xfmpc/trunk/src/playlist.c
xfmpc/trunk/src/preferences-dialog.c
xfmpc/trunk/src/preferences.c
xfmpc/trunk/src/preferences.h
xfmpc/trunk/src/song-dialog.c
xfmpc/trunk/src/statusbar.c
Log:
Start to rewrite in vala
Modified: xfmpc/trunk/ChangeLog
===================================================================
--- xfmpc/trunk/ChangeLog 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/ChangeLog 2009-04-23 11:11:39 UTC (rev 7280)
@@ -1,3 +1,24 @@
+2009-04-22 Vincent Legout <vincent at legout.info>
+
+Start to rewrite in vala
+ * configure.in.in:
+ - Check for the program valac
+ * src/Makefile.am:
+ - When in maintainer mode, build the C source files with the valac
+ compiler
+ * src/:
+ - Add new vala files (dbbrowser.vala, extended-interface.vala,
+ playlist.vala, preferences-dialog.vala, song-dialog.vala and
+ statusbar.vala), keep the .c files and xfmpc.h generated by valac
+ * src/preferences.c, src/preferences.h:
+ - Add get/set methods for every property
+ - Drop the G_PARAM_CONSTRUCT flag for the song-format property
+ * vapi/:
+ - Add vapi files (config.vapi, libxfce4util-1.0.vapi,
+ libxfcegui4-1.0.vapi, mpdclient.vapi, preferences.vapi and
+ xfce-arrow-button.vapi). libxfce4util and libxfcegui4 bindings are
+ from xfce4-vala.
+
2009-03-29 Mike Massonnet <mmassonnet at xfce.org>
Be more careful with context menus
Modified: xfmpc/trunk/configure.in.in
===================================================================
--- xfmpc/trunk/configure.in.in 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/configure.in.in 2009-04-23 11:11:39 UTC (rev 7280)
@@ -64,6 +64,20 @@
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
XDT_CHECK_PACKAGE([LIBMPD], [libmpd], [0.15.0])
+dnl Check for valac
+valac_minimum_version=0.7.0
+if test "x$USE_MAINTAINER_MODE" = "xyes" ; then
+ AC_CHECK_PROG([has_valac], [valac], [yes], [no])
+ AC_PATH_PROG([VALAC], [valac], [valac])
+ AC_SUBST(VALAC)
+ if test "x$has_valac" != "xyes" ; then
+ echo "***"
+ echo "*** You need the valac compiler in order to compile parts of the project"
+ echo "***"
+ echo
+ fi
+fi
+
dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
@@ -91,7 +105,13 @@
dnl ***************************
echo
echo "Build Configuration:"
+echo
+echo "* Maintainer Mode: $USE_MAINTAINER_MODE"
+if test "x$USE_MAINTAINER_MODE" = "xyes" ; then
+echo " * Vala: $has_valac"
+echo " You need Vala $valac_minimum_version or higher (run $VALAC --version)"
echo
+fi
echo "* Debug Support: $enable_debug"
echo "* Funky Colors: $enable_funkycolors"
echo
Modified: xfmpc/trunk/src/Makefile.am
===================================================================
--- xfmpc/trunk/src/Makefile.am 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/Makefile.am 2009-04-23 11:11:39 UTC (rev 7280)
@@ -1,5 +1,31 @@
bin_PROGRAMS = xfmpc
+xfmpc_VALASOURCES = \
+ preferences-dialog.vala \
+ song-dialog.vala \
+ statusbar.vala \
+ dbbrowser.vala \
+ extended-interface.vala \
+ playlist.vala
+
+vala_built_SOURCES = \
+ $(xfmpc_VALASOURCES:.vala=.c)
+
+if MAINTAINER_MODE
+
+BUILT_SOURCES = \
+ main-ui.h \
+ vala.stamp
+
+vala.stamp: $(xfmpc_VALASOURCES)
+ $(VALAC) --vapidir=$(top_srcdir)/vapi --pkg=gtk+-2.0 --pkg=libxfce4util-1.0 --pkg=libxfcegui4-1.0 --pkg=config --pkg=mpdclient --pkg=preferences --pkg=xfce-arrow-button $^ -C -H xfmpc.h
+ touch $@
+
+main-ui.h: Makefile $(srcdir)/main-ui.xml
+ exo-csource --strip-comments --strip-content --static --name=main_ui $(srcdir)/main-ui.xml > main-ui.h
+
+endif
+
xfmpc_SOURCES = \
main.c \
main-ui.h \
@@ -7,24 +33,14 @@
main-window.h \
interface.c \
interface.h \
- extended-interface.c \
- extended-interface.h \
- playlist.c \
- playlist.h \
- dbbrowser.c \
- dbbrowser.h \
- statusbar.c \
- statusbar.h \
preferences.c \
preferences.h \
- preferences-dialog.c \
- preferences-dialog.h \
mpdclient.c \
mpdclient.h \
- song-dialog.c \
- song-dialog.h \
xfce-arrow-button.c \
- xfce-arrow-button.h
+ xfce-arrow-button.h \
+ xfmpc.h
+xfmpc_SOURCES += $(vala_built_SOURCES)
xfmpc_CFLAGS = \
@GTK_CFLAGS@ \
@@ -45,17 +61,12 @@
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-DLOCALEDIR=\"$(localedir)\"
-if MAINTAINER_MODE
+EXTRA_DIST = \
+ main-ui.xml \
+ $(xfce4_notes_plugin_VALASOURCES)
+
DISTCLEANFILES = \
- main-ui.h
+ main-ui.h \
+ $(BUILT_SOURCES) \
+ $(vala_built_SOURCES)
-BUILT_SOURCES = \
- main-ui.h
-
-main-ui.h: Makefile $(srcdir)/main-ui.xml
- exo-csource --strip-comments --strip-content --static --name=main_ui $(srcdir)/main-ui.xml > main-ui.h
-endif
-
-EXTRA_DIST = \
- main-ui.xml
-
Modified: xfmpc/trunk/src/dbbrowser.c
===================================================================
--- xfmpc/trunk/src/dbbrowser.c 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/dbbrowser.c 2009-04-23 11:11:39 UTC (rev 7280)
@@ -1,5 +1,6 @@
/*
- * 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>
*
* 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
@@ -16,772 +17,915 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifdef HAVE_CONFIG_H
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <mpdclient.h>
+#include <preferences.h>
+#include <stdlib.h>
+#include <string.h>
#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
+#include <gdk-pixbuf/gdk-pixdata.h>
+#include <pango/pango.h>
+#include <gdk/gdk.h>
#include <libxfce4util/libxfce4util.h>
+#include <glib/gi18n-lib.h>
-#include "dbbrowser.h"
-#include "preferences.h"
-#include "mpdclient.h"
-#define BORDER 4
+#define XFMPC_TYPE_DBBROWSER (xfmpc_dbbrowser_get_type ())
+#define XFMPC_DBBROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowser))
+#define XFMPC_DBBROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserClass))
+#define XFMPC_IS_DBBROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_DBBROWSER))
+#define XFMPC_IS_DBBROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_DBBROWSER))
+#define XFMPC_DBBROWSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserClass))
-#define GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserPrivate))
+typedef struct _XfmpcDbbrowser XfmpcDbbrowser;
+typedef struct _XfmpcDbbrowserClass XfmpcDbbrowserClass;
+typedef struct _XfmpcDbbrowserPrivate XfmpcDbbrowserPrivate;
+#define XFMPC_DBBROWSER_TYPE_COLUMNS (xfmpc_dbbrowser_columns_get_type ())
-
-static void xfmpc_dbbrowser_class_init (XfmpcDbbrowserClass *klass);
-static void xfmpc_dbbrowser_init (XfmpcDbbrowser *dbbrowser);
-static void xfmpc_dbbrowser_dispose (GObject *object);
-static void xfmpc_dbbrowser_finalize (GObject *object);
-
-static void cb_row_activated (XfmpcDbbrowser *dbbrowser,
- GtkTreePath *path,
- GtkTreeViewColumn *column);
-static gboolean cb_key_pressed (XfmpcDbbrowser *dbbrowser,
- GdkEventKey *event);
-static gboolean cb_button_released (XfmpcDbbrowser *dbbrowser,
- GdkEventButton *event);
-static gboolean cb_popup_menu (XfmpcDbbrowser *dbbrowser);
-static void popup_menu (XfmpcDbbrowser *dbbrowser);
-static void cb_browse (XfmpcDbbrowser *dbbrowser);
-
-static void cb_search_entry_activated (XfmpcDbbrowser *dbbrowser);
-static gboolean cb_search_entry_key_released (XfmpcDbbrowser *dbbrowser,
- GdkEventKey *event);
-static void cb_search_entry_changed (XfmpcDbbrowser *dbbrowser);
-static gboolean timeout_search (XfmpcDbbrowser *dbbrowser);
-static void timeout_search_destroy (XfmpcDbbrowser *dbbrowser);
-
-static void cb_playlist_changed (XfmpcDbbrowser *dbbrowser);
-
-
-
-/* List store identifiers */
-enum
-{
- COLUMN_ID,
- COLUMN_PIXBUF,
- COLUMN_FILENAME,
- COLUMN_BASENAME,
- COLUMN_IS_DIR,
- COLUMN_WEIGHT,
- N_COLUMNS,
+struct _XfmpcDbbrowser {
+ GtkVBox parent_instance;
+ XfmpcDbbrowserPrivate * priv;
};
-
-
-struct _XfmpcDbbrowserClass
-{
- GtkVBoxClass parent_class;
+struct _XfmpcDbbrowserClass {
+ GtkVBoxClass parent_class;
};
-struct _XfmpcDbbrowser
-{
- GtkVBox parent;
- XfmpcPreferences *preferences;
- XfmpcMpdclient *mpdclient;
- /*<private>*/
- XfmpcDbbrowserPrivate *priv;
+struct _XfmpcDbbrowserPrivate {
+ XfmpcMpdclient* mpdclient;
+ XfmpcPreferences* preferences;
+ char* gettext_package;
+ char* localedir;
+ GtkListStore* store;
+ GtkTreeView* treeview;
+ GtkMenu* menu;
+ GtkEntry* search_entry;
+ GtkImageMenuItem* mi_browse;
+ char* wdir;
+ char* last_wdir;
+ gboolean is_searching;
+ guint search_timeout;
};
-struct _XfmpcDbbrowserPrivate
-{
- GtkWidget *treeview;
- GtkListStore *store;
- GtkWidget *search_entry;
- GtkWidget *menu;
- GtkWidget *mi_browse;
+typedef enum {
+ XFMPC_DBBROWSER_COLUMNS_COLUMN_ID,
+ XFMPC_DBBROWSER_COLUMNS_COLUMN_PIXBUF,
+ XFMPC_DBBROWSER_COLUMNS_COLUMN_FILENAME,
+ XFMPC_DBBROWSER_COLUMNS_COLUMN_BASENAME,
+ XFMPC_DBBROWSER_COLUMNS_COLUMN_IS_DIR,
+ XFMPC_DBBROWSER_COLUMNS_COLUMN_WEIGHT,
+ XFMPC_DBBROWSER_COLUMNS_N_COLUMNS
+} XfmpcDbbrowserColumns;
- guint search_timeout;
- gboolean is_searching;
- gchar *wdir;
- gchar *last_wdir;
+
+GType xfmpc_dbbrowser_get_type (void);
+#define XFMPC_DBBROWSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserPrivate))
+enum {
+ XFMPC_DBBROWSER_DUMMY_PROPERTY
};
+static GType xfmpc_dbbrowser_columns_get_type (void);
+void xfmpc_dbbrowser_free (XfmpcDbbrowser* self);
+static void xfmpc_dbbrowser_clear (XfmpcDbbrowser* self);
+gboolean xfmpc_dbbrowser_wdir_is_root (XfmpcDbbrowser* self);
+char* xfmpc_dbbrowser_get_parent_wdir (XfmpcDbbrowser* self);
+void xfmpc_dbbrowser_append (XfmpcDbbrowser* self, const char* filename, const char* basename, gboolean is_dir, gboolean is_bold);
+void xfmpc_dbbrowser_reload (XfmpcDbbrowser* self);
+void xfmpc_dbbrowser_set_wdir (XfmpcDbbrowser* self, const char* dir);
+static void _g_list_free_gtk_tree_path_free (GList* self);
+void xfmpc_dbbrowser_add_selected_rows (XfmpcDbbrowser* self);
+void xfmpc_dbbrowser_search (XfmpcDbbrowser* self, const char* query);
+static void xfmpc_dbbrowser_menu_popup (XfmpcDbbrowser* self);
+static void xfmpc_dbbrowser_cb_playlist_changed (XfmpcDbbrowser* self);
+static gboolean xfmpc_dbbrowser_cb_popup_menu (XfmpcDbbrowser* self);
+static gboolean xfmpc_dbbrowser_cb_key_pressed (XfmpcDbbrowser* self, const GdkEventKey* event);
+static gboolean xfmpc_dbbrowser_cb_button_released (XfmpcDbbrowser* self, const GdkEventButton* event);
+static void xfmpc_dbbrowser_cb_row_activated (XfmpcDbbrowser* self, const GtkTreePath* path, GtkTreeViewColumn* column);
+static void xfmpc_dbbrowser_cb_replace_with_selected_rows (XfmpcDbbrowser* self);
+static void xfmpc_dbbrowser_cb_browse (XfmpcDbbrowser* self);
+static void xfmpc_dbbrowser_cb_search_entry_activated (XfmpcDbbrowser* self);
+static gboolean xfmpc_dbbrowser_cb_search_entry_key_released (XfmpcDbbrowser* self, const GdkEventKey* event);
+static gboolean xfmpc_dbbrowser_timeout_search (XfmpcDbbrowser* self);
+static gboolean _xfmpc_dbbrowser_timeout_search_gsource_func (gpointer self);
+static void xfmpc_dbbrowser_cb_search_entry_changed (XfmpcDbbrowser* self);
+XfmpcDbbrowser* xfmpc_dbbrowser_new (void);
+XfmpcDbbrowser* xfmpc_dbbrowser_construct (GType object_type);
+XfmpcDbbrowser* xfmpc_dbbrowser_new (void);
+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);
+static void _xfmpc_dbbrowser_reload_xfmpc_mpdclient_connected (XfmpcMpdclient* _sender, gpointer self);
+static void _xfmpc_dbbrowser_reload_xfmpc_mpdclient_database_changed (XfmpcMpdclient* _sender, gpointer self);
+static void _xfmpc_dbbrowser_cb_playlist_changed_xfmpc_mpdclient_playlist_changed (XfmpcMpdclient* _sender, gpointer self);
+static void _xfmpc_dbbrowser_cb_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, const GtkTreePath* path, GtkTreeViewColumn* column, gpointer self);
+static gboolean _xfmpc_dbbrowser_cb_key_pressed_gtk_widget_key_press_event (GtkTreeView* _sender, const GdkEventKey* event, gpointer self);
+static gboolean _xfmpc_dbbrowser_cb_button_released_gtk_widget_button_press_event (GtkTreeView* _sender, const GdkEventButton* event, gpointer self);
+static gboolean _xfmpc_dbbrowser_cb_popup_menu_gtk_widget_popup_menu (GtkTreeView* _sender, gpointer self);
+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 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);
+static int _vala_strcmp0 (const char * str1, const char * str2);
-static GObjectClass *parent_class = NULL;
+static GType xfmpc_dbbrowser_columns_get_type (void) {
+ static GType xfmpc_dbbrowser_columns_type_id = 0;
+ if (G_UNLIKELY (xfmpc_dbbrowser_columns_type_id == 0)) {
+ static const GEnumValue values[] = {{XFMPC_DBBROWSER_COLUMNS_COLUMN_ID, "XFMPC_DBBROWSER_COLUMNS_COLUMN_ID", "column-id"}, {XFMPC_DBBROWSER_COLUMNS_COLUMN_PIXBUF, "XFMPC_DBBROWSER_COLUMNS_COLUMN_PIXBUF", "column-pixbuf"}, {XFMPC_DBBROWSER_COLUMNS_COLUMN_FILENAME, "XFMPC_DBBROWSER_COLUMNS_COLUMN_FILENAME", "column-filename"}, {XFMPC_DBBROWSER_COLUMNS_COLUMN_BASENAME, "XFMPC_DBBROWSER_COLUMNS_COLUMN_BASENAME", "column-basename"}, {XFMPC_DBBROWSER_COLUMNS_COLUMN_IS_DIR, "XFMPC_DBBROWSER_COLUMNS_COLUMN_IS_DIR", "column-is-dir"}, {XFMPC_DBBROWSER_COLUMNS_COLUMN_WEIGHT, "XFMPC_DBBROWSER_COLUMNS_COLUMN_WEIGHT", "column-weight"}, {XFMPC_DBBROWSER_COLUMNS_N_COLUMNS, "XFMPC_DBBROWSER_COLUMNS_N_COLUMNS", "n-columns"}, {0, NULL, NULL}};
+ xfmpc_dbbrowser_columns_type_id = g_enum_register_static ("XfmpcDbbrowserColumns", values);
+ }
+ return xfmpc_dbbrowser_columns_type_id;
+}
-GType
-xfmpc_dbbrowser_get_type ()
-{
- static GType xfmpc_dbbrowser_type = G_TYPE_INVALID;
+void xfmpc_dbbrowser_free (XfmpcDbbrowser* self) {
+ g_return_if_fail (self != NULL);
+}
- if (G_UNLIKELY (xfmpc_dbbrowser_type == G_TYPE_INVALID))
- {
- static const GTypeInfo xfmpc_dbbrowser_info =
- {
- sizeof (XfmpcDbbrowserClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) xfmpc_dbbrowser_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (XfmpcDbbrowser),
- 0,
- (GInstanceInitFunc) xfmpc_dbbrowser_init,
- NULL
- };
- xfmpc_dbbrowser_type = g_type_register_static (GTK_TYPE_VBOX, "XfmpcDbbrowser", &xfmpc_dbbrowser_info, 0);
- }
- return xfmpc_dbbrowser_type;
+void xfmpc_dbbrowser_reload (XfmpcDbbrowser* self) {
+ char* filename;
+ char* basename;
+ gboolean is_dir;
+ gboolean is_bold;
+ gint i;
+ g_return_if_fail (self != NULL);
+ filename = g_strdup ("");
+ basename = g_strdup ("");
+ is_dir = FALSE;
+ is_bold = FALSE;
+ i = 0;
+ if (!xfmpc_mpdclient_is_connected (self->priv->mpdclient)) {
+ filename = (g_free (filename), NULL);
+ basename = (g_free (basename), NULL);
+ return;
+ }
+ if (self->priv->is_searching) {
+ filename = (g_free (filename), NULL);
+ basename = (g_free (basename), NULL);
+ return;
+ }
+ xfmpc_dbbrowser_clear (self);
+ if (!xfmpc_dbbrowser_wdir_is_root (self)) {
+ char* _tmp0;
+ _tmp0 = NULL;
+ filename = (_tmp0 = xfmpc_dbbrowser_get_parent_wdir (self), filename = (g_free (filename), NULL), _tmp0);
+ xfmpc_dbbrowser_append (self, filename, "..", TRUE, FALSE);
+ i++;
+ }
+ while (xfmpc_mpdclient_database_read (self->priv->mpdclient, self->priv->wdir, &filename, &basename, &is_dir)) {
+ is_bold = xfmpc_mpdclient_playlist_has_filename (self->priv->mpdclient, filename, is_dir);
+ xfmpc_dbbrowser_append (self, filename, basename, is_dir, is_bold);
+ if (g_utf8_collate (filename, self->priv->last_wdir) == 0) {
+ GtkTreePath* path;
+ path = gtk_tree_path_new_from_indices (i, -1, -1);
+ gtk_tree_view_set_cursor (self->priv->treeview, path, NULL, FALSE);
+ gtk_tree_view_scroll_to_cell (self->priv->treeview, path, NULL, TRUE, (float) 0.10, (float) 0);
+ i = -1;
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
+ } else {
+ i++;
+ }
+ }
+ filename = (g_free (filename), NULL);
+ basename = (g_free (basename), NULL);
}
+gboolean xfmpc_dbbrowser_wdir_is_root (XfmpcDbbrowser* self) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ return _vala_strcmp0 (self->priv->wdir, "") == 0;
+}
-static void
-xfmpc_dbbrowser_class_init (XfmpcDbbrowserClass *klass)
-{
- GObjectClass *gobject_class;
- g_type_class_add_private (klass, sizeof (XfmpcDbbrowserPrivate));
+char* xfmpc_dbbrowser_get_parent_wdir (XfmpcDbbrowser* self) {
+ const char* _tmp0;
+ char* filename;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0 = NULL;
+ filename = (_tmp0 = strstr (self->priv->wdir, "/"), (_tmp0 == NULL) ? NULL : g_strdup (_tmp0));
+ if (filename == NULL) {
+ char* _tmp1;
+ _tmp1 = NULL;
+ return (_tmp1 = g_strdup (""), filename = (g_free (filename), NULL), _tmp1);
+ } else {
+ char* _tmp2;
+ _tmp2 = NULL;
+ return (_tmp2 = g_path_get_dirname (self->priv->wdir), filename = (g_free (filename), NULL), _tmp2);
+ }
+ filename = (g_free (filename), NULL);
+}
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->dispose = xfmpc_dbbrowser_dispose;
- gobject_class->finalize = xfmpc_dbbrowser_finalize;
+void xfmpc_dbbrowser_append (XfmpcDbbrowser* self, const char* filename, const char* basename, gboolean is_dir, gboolean is_bold) {
+ GtkTreeIter iter = {0};
+ const char* _tmp0;
+ GdkPixbuf* pixbuf;
+ PangoWeight _tmp1;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (filename != NULL);
+ g_return_if_fail (basename != NULL);
+ _tmp0 = NULL;
+ if (is_dir) {
+ _tmp0 = GTK_STOCK_DIRECTORY;
+ } else {
+ _tmp0 = GTK_STOCK_FILE;
+ }
+ pixbuf = gtk_widget_render_icon ((GtkWidget*) self->priv->treeview, _tmp0, GTK_ICON_SIZE_MENU, NULL);
+ gtk_list_store_append (self->priv->store, &iter);
+ _tmp1 = 0;
+ if (is_bold) {
+ _tmp1 = PANGO_WEIGHT_BOLD;
+ } else {
+ _tmp1 = PANGO_WEIGHT_NORMAL;
+ }
+ gtk_list_store_set (self->priv->store, &iter, XFMPC_DBBROWSER_COLUMNS_COLUMN_PIXBUF, pixbuf, XFMPC_DBBROWSER_COLUMNS_COLUMN_FILENAME, filename, XFMPC_DBBROWSER_COLUMNS_COLUMN_BASENAME, basename, XFMPC_DBBROWSER_COLUMNS_COLUMN_IS_DIR, is_dir, XFMPC_DBBROWSER_COLUMNS_COLUMN_WEIGHT, _tmp1, -1, -1);
+ (pixbuf == NULL) ? NULL : (pixbuf = (g_object_unref (pixbuf), NULL));
}
-static void
-xfmpc_dbbrowser_init (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = dbbrowser->priv = GET_PRIVATE (dbbrowser);
- dbbrowser->preferences = xfmpc_preferences_get ();
- dbbrowser->mpdclient = xfmpc_mpdclient_get ();
+void xfmpc_dbbrowser_set_wdir (XfmpcDbbrowser* self, const char* dir) {
+ char* _tmp1;
+ const char* _tmp0;
+ char* _tmp3;
+ const char* _tmp2;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (dir != NULL);
+ _tmp1 = NULL;
+ _tmp0 = NULL;
+ self->priv->last_wdir = (_tmp1 = (_tmp0 = self->priv->wdir, (_tmp0 == NULL) ? NULL : g_strdup (_tmp0)), self->priv->last_wdir = (g_free (self->priv->last_wdir), NULL), _tmp1);
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ self->priv->wdir = (_tmp3 = (_tmp2 = dir, (_tmp2 == NULL) ? NULL : g_strdup (_tmp2)), self->priv->wdir = (g_free (self->priv->wdir), NULL), _tmp3);
+}
- g_object_get (G_OBJECT (dbbrowser->preferences),
- "dbbrowser-last-path", &priv->wdir,
- NULL);
- priv->last_wdir = g_strdup (priv->wdir);
- /* === Tree model === */
- priv->store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_INT,
- GDK_TYPE_PIXBUF,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- G_TYPE_INT);
+static void _g_list_free_gtk_tree_path_free (GList* self) {
+ g_list_foreach (self, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (self);
+}
- /* === Tree view === */
- priv->treeview = gtk_tree_view_new ();
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)), GTK_SELECTION_MULTIPLE);
- gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (priv->treeview), TRUE);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (priv->treeview), TRUE);
- gtk_tree_view_set_search_column (GTK_TREE_VIEW (priv->treeview), COLUMN_BASENAME);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE);
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->treeview), TRUE);
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), GTK_TREE_MODEL (priv->store));
- g_object_unref (priv->store);
- /* Columns */
- GtkCellRenderer *cell = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview),
- -1, "", cell,
- "pixbuf", COLUMN_PIXBUF,
- NULL);
+void xfmpc_dbbrowser_add_selected_rows (XfmpcDbbrowser* self) {
+ GtkTreeModel* _tmp0;
+ GtkTreeModel* model;
+ GtkTreeIter iter = {0};
+ char* filename;
+ GtkTreeModel* _tmp4;
+ GtkTreeModel* _tmp3;
+ GList* _tmp2;
+ GtkTreeModel* _tmp1;
+ GList* list;
+ g_return_if_fail (self != NULL);
+ _tmp0 = NULL;
+ model = (_tmp0 = (GtkTreeModel*) self->priv->store, (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ filename = g_strdup ("");
+ _tmp4 = NULL;
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ _tmp1 = NULL;
+ list = (_tmp2 = gtk_tree_selection_get_selected_rows (gtk_tree_view_get_selection (self->priv->treeview), &_tmp1), model = (_tmp3 = (_tmp4 = _tmp1, (_tmp4 == NULL) ? NULL : g_object_ref (_tmp4)), (model == NULL) ? NULL : (model = (g_object_unref (model), NULL)), _tmp3), _tmp2);
+ {
+ GList* path_collection;
+ GList* path_it;
+ path_collection = list;
+ for (path_it = path_collection; path_it != NULL; path_it = path_it->next) {
+ const GtkTreePath* _tmp5;
+ GtkTreePath* path;
+ _tmp5 = NULL;
+ path = (_tmp5 = (const GtkTreePath*) path_it->data, (_tmp5 == NULL) ? NULL : gtk_tree_path_copy (_tmp5));
+ {
+ if (gtk_tree_model_get_iter (model, &iter, path)) {
+ gtk_tree_model_get (model, &iter, XFMPC_DBBROWSER_COLUMNS_COLUMN_FILENAME, &filename, -1, -1);
+ xfmpc_mpdclient_queue_add (self->priv->mpdclient, filename);
+ }
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
+ }
+ }
+ }
+ xfmpc_mpdclient_queue_commit (self->priv->mpdclient);
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ filename = (g_free (filename), NULL);
+ (list == NULL) ? NULL : (list = (_g_list_free_gtk_tree_path_free (list), NULL));
+}
- cell = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (cell),
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview),
- -1, "Filename", cell,
- "text", COLUMN_BASENAME,
- "weight", COLUMN_WEIGHT,
- NULL);
- /* Scrolled window */
- GtkWidget *scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_ALWAYS);
+void xfmpc_dbbrowser_search (XfmpcDbbrowser* self, const char* query) {
+ char* filename;
+ char* basename;
+ gboolean is_bold;
+ gint i;
+ gboolean no_result_buf;
+ gboolean no_result;
+ GdkColor color = {0};
+ gboolean _tmp0;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (query != NULL);
+ filename = g_strdup ("");
+ basename = g_strdup ("");
+ is_bold = FALSE;
+ i = 0;
+ if (!xfmpc_mpdclient_is_connected (self->priv->mpdclient)) {
+ filename = (g_free (filename), NULL);
+ basename = (g_free (basename), NULL);
+ return;
+ }
+ self->priv->is_searching = TRUE;
+ xfmpc_dbbrowser_clear (self);
+ while (xfmpc_mpdclient_database_search (self->priv->mpdclient, query, &filename, &basename)) {
+ is_bold = xfmpc_mpdclient_playlist_has_filename (self->priv->mpdclient, filename, FALSE);
+ xfmpc_dbbrowser_append (self, filename, basename, FALSE, is_bold);
+ i++;
+ }
+ no_result_buf = FALSE;
+ no_result = FALSE;
+ gdk_color_parse ("white", &color);
+ color.red = (guint16) 0xFFFF;
+ color.green = (guint16) 0x6666;
+ color.blue = (guint16) 0x6666;
+ if (i == 0) {
+ no_result = TRUE;
+ } else {
+ if (no_result) {
+ no_result = FALSE;
+ }
+ }
+ _tmp0 = FALSE;
+ if (no_result == no_result_buf) {
+ _tmp0 = no_result;
+ } else {
+ _tmp0 = FALSE;
+ }
+ if (_tmp0) {
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_NORMAL, &color);
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_SELECTED, &color);
+ } else {
+ gboolean _tmp1;
+ _tmp1 = FALSE;
+ if (no_result == no_result_buf) {
+ _tmp1 = !no_result;
+ } else {
+ _tmp1 = FALSE;
+ }
+ if (_tmp1) {
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_SELECTED, NULL);
+ }
+ }
+ if (i == 0) {
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_NORMAL, &color);
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_SELECTED, &color);
+ } else {
+ if (no_result) {
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_SELECTED, NULL);
+ }
+ }
+ filename = (g_free (filename), NULL);
+ basename = (g_free (basename), NULL);
+}
- /* Menu */
- priv->menu = gtk_menu_new ();
- /* Menu -> Add */
- GtkWidget *mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_ADD, NULL);
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mi);
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (xfmpc_dbbrowser_add_selected_rows), dbbrowser);
+static void xfmpc_dbbrowser_clear (XfmpcDbbrowser* self) {
+ g_return_if_fail (self != NULL);
+ gtk_list_store_clear (self->priv->store);
+}
- /* Menu -> Replace */
- mi = gtk_image_menu_item_new_with_mnemonic (_("_Replace"));
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mi);
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (xfmpc_dbbrowser_replace_with_selected_rows), dbbrowser);
- GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_CUT, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
- /* Menu -> Browse (only shown on a search) */
- mi = priv->mi_browse = gtk_image_menu_item_new_with_mnemonic (_("_Browse"));
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mi);
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (cb_browse), dbbrowser);
- image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
+static void xfmpc_dbbrowser_menu_popup (XfmpcDbbrowser* self) {
+ GtkTreeSelection* _tmp0;
+ GtkTreeSelection* selection;
+ gint count;
+ g_return_if_fail (self != NULL);
+ _tmp0 = NULL;
+ selection = (_tmp0 = gtk_tree_view_get_selection (self->priv->treeview), (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ count = gtk_tree_selection_count_selected_rows (selection);
+ if (self->priv->is_searching) {
+ gboolean _tmp1;
+ gtk_widget_show ((GtkWidget*) self->priv->mi_browse);
+ _tmp1 = FALSE;
+ if (count == 1) {
+ _tmp1 = TRUE;
+ } else {
+ _tmp1 = FALSE;
+ }
+ gtk_widget_set_sensitive ((GtkWidget*) self->priv->mi_browse, _tmp1);
+ } else {
+ gtk_widget_hide ((GtkWidget*) self->priv->mi_browse);
+ }
+ gtk_menu_popup (self->priv->menu, NULL, NULL, NULL, NULL, (guint) 0, gtk_get_current_event_time ());
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+}
- gtk_widget_show_all (priv->menu);
- /* === Search entry === */
- priv->search_entry = gtk_entry_new ();
+/*
+ * Signal callbacks
+ */
+static void xfmpc_dbbrowser_cb_playlist_changed (XfmpcDbbrowser* self) {
+ GtkTreeModel* _tmp0;
+ GtkTreeModel* model;
+ GtkTreeIter iter = {0};
+ char* filename;
+ gboolean is_bold;
+ gboolean is_dir;
+ g_return_if_fail (self != NULL);
+ _tmp0 = NULL;
+ model = (_tmp0 = (GtkTreeModel*) self->priv->store, (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ filename = g_strdup ("");
+ is_bold = FALSE;
+ is_dir = FALSE;
+ if (!gtk_tree_model_get_iter_first (model, &iter)) {
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ filename = (g_free (filename), NULL);
+ return;
+ }
+ do {
+ PangoWeight _tmp1;
+ gtk_tree_model_get (model, &iter, XFMPC_DBBROWSER_COLUMNS_COLUMN_FILENAME, &filename, XFMPC_DBBROWSER_COLUMNS_COLUMN_IS_DIR, &is_dir, -1, -1);
+ is_bold = xfmpc_mpdclient_playlist_has_filename (self->priv->mpdclient, filename, is_dir);
+ _tmp1 = 0;
+ if (is_bold) {
+ _tmp1 = PANGO_WEIGHT_BOLD;
+ } else {
+ _tmp1 = PANGO_WEIGHT_NORMAL;
+ }
+ gtk_list_store_set (self->priv->store, &iter, XFMPC_DBBROWSER_COLUMNS_COLUMN_WEIGHT, _tmp1, -1, -1);
+ } while (gtk_tree_model_iter_next (model, &iter));
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ filename = (g_free (filename), NULL);
+}
- /* === Containers === */
- gtk_container_add (GTK_CONTAINER (scrolled), priv->treeview);
- gtk_box_pack_start (GTK_BOX (dbbrowser), scrolled, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (dbbrowser), priv->search_entry, FALSE, FALSE, 0);
- /* === Signals === */
- g_signal_connect_swapped (dbbrowser->mpdclient, "connected",
- G_CALLBACK (xfmpc_dbbrowser_reload), dbbrowser);
- g_signal_connect_swapped (dbbrowser->mpdclient, "database-changed",
- G_CALLBACK (xfmpc_dbbrowser_reload), dbbrowser);
- g_signal_connect_swapped (dbbrowser->mpdclient, "playlist-changed",
- G_CALLBACK (cb_playlist_changed), dbbrowser);
- /* Tree view */
- g_signal_connect_swapped (priv->treeview, "row-activated",
- G_CALLBACK (cb_row_activated), dbbrowser);
- g_signal_connect_swapped (priv->treeview, "key-press-event",
- G_CALLBACK (cb_key_pressed), dbbrowser);
- g_signal_connect_swapped (priv->treeview, "button-release-event",
- G_CALLBACK (cb_button_released), dbbrowser);
- g_signal_connect_swapped (priv->treeview, "popup-menu",
- G_CALLBACK (cb_popup_menu), dbbrowser);
- /* Search entry */
- g_signal_connect_swapped (priv->search_entry, "activate",
- G_CALLBACK (cb_search_entry_activated), dbbrowser);
- g_signal_connect_swapped (priv->search_entry, "key-release-event",
- G_CALLBACK (cb_search_entry_key_released), dbbrowser);
- g_signal_connect_swapped (priv->search_entry, "changed",
- G_CALLBACK (cb_search_entry_changed), dbbrowser);
- /* Preferences */
- g_signal_connect_swapped (dbbrowser->preferences, "notify::song-format",
- G_CALLBACK (xfmpc_dbbrowser_reload), dbbrowser);
- g_signal_connect_swapped (dbbrowser->preferences, "notify::song-format-custom",
- G_CALLBACK (xfmpc_dbbrowser_reload), dbbrowser);
+static gboolean xfmpc_dbbrowser_cb_popup_menu (XfmpcDbbrowser* self) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ xfmpc_dbbrowser_menu_popup (self);
+ return TRUE;
}
-static void
-xfmpc_dbbrowser_dispose (GObject *object)
-{
- (*G_OBJECT_CLASS (parent_class)->dispose) (object);
+
+static gboolean xfmpc_dbbrowser_cb_key_pressed (XfmpcDbbrowser* self, const GdkEventKey* event) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ if ((*event).type != GDK_KEY_PRESS) {
+ return FALSE;
+ }
+ switch ((*event).keyval) {
+ case 0xff0d:
+ {
+ GtkTreeSelection* _tmp1;
+ GtkTreeSelection* selection;
+ _tmp1 = NULL;
+ selection = (_tmp1 = gtk_tree_view_get_selection (self->priv->treeview), (_tmp1 == NULL) ? NULL : g_object_ref (_tmp1));
+ if (gtk_tree_selection_count_selected_rows (selection) > 1) {
+ xfmpc_dbbrowser_add_selected_rows (self);
+ } else {
+ gboolean _tmp2;
+ return (_tmp2 = FALSE, (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL)), _tmp2);
+ }
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ break;
+ }
+ case 0xff08:
+ {
+ char* filename;
+ filename = xfmpc_dbbrowser_get_parent_wdir (self);
+ xfmpc_dbbrowser_set_wdir (self, filename);
+ xfmpc_dbbrowser_reload (self);
+ filename = (g_free (filename), NULL);
+ break;
+ }
+ default:
+ {
+ return FALSE;
+ }
+ }
+ return TRUE;
}
-static void
-xfmpc_dbbrowser_finalize (GObject *object)
-{
- XfmpcDbbrowser *dbbrowser = XFMPC_DBBROWSER (object);
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- g_object_set (G_OBJECT (dbbrowser->preferences),
- "dbbrowser-last-path", priv->wdir,
- NULL);
-
- g_object_unref (G_OBJECT (dbbrowser->preferences));
- g_object_unref (G_OBJECT (dbbrowser->mpdclient));
- (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+static gboolean xfmpc_dbbrowser_cb_button_released (XfmpcDbbrowser* self, const GdkEventButton* event) {
+ gboolean _tmp0;
+ GtkTreePath* path;
+ GtkTreeSelection* _tmp2;
+ GtkTreeSelection* selection;
+ GtkTreePath* _tmp6;
+ gboolean _tmp5;
+ GtkTreePath* _tmp4;
+ gboolean _tmp7;
+ g_return_val_if_fail (self != NULL, FALSE);
+ _tmp0 = FALSE;
+ if ((*event).type != GDK_BUTTON_PRESS) {
+ _tmp0 = TRUE;
+ } else {
+ _tmp0 = (*event).button != 3;
+ }
+ if (_tmp0) {
+ return FALSE;
+ }
+ path = NULL;
+ _tmp2 = NULL;
+ selection = (_tmp2 = gtk_tree_view_get_selection (self->priv->treeview), (_tmp2 == NULL) ? NULL : g_object_ref (_tmp2));
+ if (gtk_tree_selection_count_selected_rows (selection) < 1) {
+ gboolean _tmp3;
+ return (_tmp3 = TRUE, (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL)), _tmp3);
+ }
+ _tmp6 = NULL;
+ _tmp4 = NULL;
+ if ((_tmp5 = gtk_tree_view_get_path_at_pos (self->priv->treeview, (gint) (*event).x, (gint) (*event).y, &_tmp4, NULL, NULL, NULL), path = (_tmp6 = _tmp4, (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), _tmp6), _tmp5)) {
+ if (!gtk_tree_selection_path_is_selected (selection, path)) {
+ gtk_tree_selection_unselect_all (selection);
+ gtk_tree_selection_select_path (selection, path);
+ }
+ }
+ xfmpc_dbbrowser_menu_popup (self);
+ return (_tmp7 = TRUE, (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL)), _tmp7);
}
-
-GtkWidget*
-xfmpc_dbbrowser_new ()
-{
- return g_object_new (XFMPC_TYPE_DBBROWSER, NULL);
+static void xfmpc_dbbrowser_cb_row_activated (XfmpcDbbrowser* self, const GtkTreePath* path, GtkTreeViewColumn* column) {
+ const GtkTreePath* _tmp0;
+ GtkTreePath* ppath;
+ GtkTreeModel* _tmp1;
+ GtkTreeModel* model;
+ GtkTreeIter iter = {0};
+ char* filename;
+ gboolean is_dir;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (path != NULL);
+ g_return_if_fail (column != NULL);
+ _tmp0 = NULL;
+ ppath = (_tmp0 = path, (_tmp0 == NULL) ? NULL : gtk_tree_path_copy (_tmp0));
+ _tmp1 = NULL;
+ model = (_tmp1 = (GtkTreeModel*) self->priv->store, (_tmp1 == NULL) ? NULL : g_object_ref (_tmp1));
+ filename = g_strdup ("");
+ is_dir = FALSE;
+ if (!gtk_tree_model_get_iter (model, &iter, ppath)) {
+ (ppath == NULL) ? NULL : (ppath = (gtk_tree_path_free (ppath), NULL));
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ filename = (g_free (filename), NULL);
+ return;
+ }
+ gtk_tree_model_get (model, &iter, XFMPC_DBBROWSER_COLUMNS_COLUMN_FILENAME, &filename, XFMPC_DBBROWSER_COLUMNS_COLUMN_IS_DIR, &is_dir, -1, -1);
+ if (is_dir) {
+ xfmpc_dbbrowser_set_wdir (self, filename);
+ xfmpc_dbbrowser_reload (self);
+ } else {
+ xfmpc_mpdclient_queue_add (self->priv->mpdclient, filename);
+ xfmpc_mpdclient_queue_commit (self->priv->mpdclient);
+ }
+ (ppath == NULL) ? NULL : (ppath = (gtk_tree_path_free (ppath), NULL));
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ filename = (g_free (filename), NULL);
}
-void
-xfmpc_dbbrowser_clear (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- gtk_list_store_clear (priv->store);
+
+static void xfmpc_dbbrowser_cb_replace_with_selected_rows (XfmpcDbbrowser* self) {
+ g_return_if_fail (self != NULL);
+ xfmpc_mpdclient_queue_clear (self->priv->mpdclient);
+ xfmpc_dbbrowser_add_selected_rows (self);
}
-void
-xfmpc_dbbrowser_append (XfmpcDbbrowser *dbbrowser,
- gchar *filename,
- gchar *basename,
- gboolean is_dir,
- gboolean is_bold)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- GdkPixbuf *pixbuf;
- GtkTreeIter iter;
- pixbuf = gtk_widget_render_icon (priv->treeview,
- is_dir ? GTK_STOCK_DIRECTORY : GTK_STOCK_FILE,
- GTK_ICON_SIZE_MENU,
- NULL);
-
- gtk_list_store_append (priv->store, &iter);
- gtk_list_store_set (priv->store, &iter,
- COLUMN_PIXBUF, pixbuf,
- COLUMN_FILENAME, filename,
- COLUMN_BASENAME, basename,
- COLUMN_IS_DIR, is_dir,
- COLUMN_WEIGHT, is_bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
- -1);
+static void xfmpc_dbbrowser_cb_browse (XfmpcDbbrowser* self) {
+ GtkTreeModel* _tmp0;
+ GtkTreeModel* model;
+ GtkTreeIter iter = {0};
+ GtkTreeSelection* _tmp1;
+ GtkTreeSelection* selection;
+ GtkTreeModel* _tmp5;
+ GtkTreeModel* _tmp4;
+ GList* _tmp3;
+ GtkTreeModel* _tmp2;
+ GList* list;
+ const GtkTreePath* _tmp6;
+ GtkTreePath* path;
+ g_return_if_fail (self != NULL);
+ _tmp0 = NULL;
+ model = (_tmp0 = (GtkTreeModel*) self->priv->store, (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ _tmp1 = NULL;
+ selection = (_tmp1 = gtk_tree_view_get_selection (self->priv->treeview), (_tmp1 == NULL) ? NULL : g_object_ref (_tmp1));
+ if (gtk_tree_selection_count_selected_rows (selection) > 1) {
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ return;
+ }
+ _tmp5 = NULL;
+ _tmp4 = NULL;
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ list = (_tmp3 = gtk_tree_selection_get_selected_rows (selection, &_tmp2), model = (_tmp4 = (_tmp5 = _tmp2, (_tmp5 == NULL) ? NULL : g_object_ref (_tmp5)), (model == NULL) ? NULL : (model = (g_object_unref (model), NULL)), _tmp4), _tmp3);
+ _tmp6 = NULL;
+ path = (_tmp6 = (const GtkTreePath*) g_list_nth_data (list, (guint) 0), (_tmp6 == NULL) ? NULL : gtk_tree_path_copy (_tmp6));
+ if (gtk_tree_model_get_iter (model, &iter, path)) {
+ char* filename;
+ char* dir;
+ filename = NULL;
+ gtk_tree_model_get (model, &iter, XFMPC_DBBROWSER_COLUMNS_COLUMN_FILENAME, &filename, -1, -1);
+ dir = g_path_get_dirname (filename);
+ xfmpc_dbbrowser_set_wdir (self, dir);
+ xfmpc_dbbrowser_reload (self);
+ filename = (g_free (filename), NULL);
+ dir = (g_free (dir), NULL);
+ }
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ (list == NULL) ? NULL : (list = (_g_list_free_gtk_tree_path_free (list), NULL));
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
}
-void
-xfmpc_dbbrowser_add_selected_rows (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- GtkTreeModel *store = GTK_TREE_MODEL (priv->store);
- GtkTreeIter iter;
- GList *l, *list;
- gchar *filename;
- list = gtk_tree_selection_get_selected_rows (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)), &store);
+static void xfmpc_dbbrowser_cb_search_entry_activated (XfmpcDbbrowser* self) {
+ const char* _tmp0;
+ char* entry_text;
+ g_return_if_fail (self != NULL);
+ _tmp0 = NULL;
+ entry_text = (_tmp0 = gtk_entry_get_text (self->priv->search_entry), (_tmp0 == NULL) ? NULL : g_strdup (_tmp0));
+ if (_vala_strcmp0 (entry_text, "") == 0) {
+ self->priv->is_searching = FALSE;
+ xfmpc_dbbrowser_reload (self);
+ /* revert possible previous applied color */
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_bg ((GtkWidget*) self->priv->search_entry, GTK_STATE_SELECTED, NULL);
+ entry_text = (g_free (entry_text), NULL);
+ return;
+ }
+ xfmpc_dbbrowser_search (self, entry_text);
+ entry_text = (g_free (entry_text), NULL);
+}
- for (l = list; l != NULL; l = l->next)
- {
- if (gtk_tree_model_get_iter (store, &iter, l->data))
- {
- gtk_tree_model_get (store, &iter,
- COLUMN_FILENAME, &filename,
- -1);
- xfmpc_mpdclient_queue_add (dbbrowser->mpdclient, filename);
- g_free (filename);
- }
- }
- xfmpc_mpdclient_queue_commit (dbbrowser->mpdclient);
-
- g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (list);
+static gboolean xfmpc_dbbrowser_cb_search_entry_key_released (XfmpcDbbrowser* self, const GdkEventKey* event) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ if ((*event).type != GDK_KEY_RELEASE) {
+ return FALSE;
+ }
+ /* Escape */
+ if ((*event).keyval == 0xff1b) {
+ gtk_entry_set_text (self->priv->search_entry, "");
+ }
+ return TRUE;
}
-void
-xfmpc_dbbrowser_replace_with_selected_rows (XfmpcDbbrowser *dbbrowser)
-{
- xfmpc_mpdclient_queue_clear (dbbrowser->mpdclient);
- xfmpc_dbbrowser_add_selected_rows (dbbrowser);
+
+static gboolean _xfmpc_dbbrowser_timeout_search_gsource_func (gpointer self) {
+ return xfmpc_dbbrowser_timeout_search (self);
}
-void
-xfmpc_dbbrowser_reload (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- gchar *filename;
- gchar *basename;
- gboolean is_dir;
- gboolean is_bold;
- gint i = 0;
- if (G_UNLIKELY (!xfmpc_mpdclient_is_connected (dbbrowser->mpdclient)))
- return;
- else if (priv->is_searching)
- return;
+static void xfmpc_dbbrowser_cb_search_entry_changed (XfmpcDbbrowser* self) {
+ g_return_if_fail (self != NULL);
+ if (self->priv->search_timeout > 0) {
+ g_source_remove (self->priv->search_timeout);
+ }
+ self->priv->search_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 642, _xfmpc_dbbrowser_timeout_search_gsource_func, g_object_ref (self), g_object_unref);
+}
- xfmpc_dbbrowser_clear (dbbrowser);
- if (!xfmpc_dbbrowser_wdir_is_root (dbbrowser))
- {
- filename = xfmpc_dbbrowser_get_parent_wdir (dbbrowser);
- xfmpc_dbbrowser_append (dbbrowser, filename, "..", TRUE, FALSE);
- g_free (filename);
- i++;
- }
+static gboolean xfmpc_dbbrowser_timeout_search (XfmpcDbbrowser* self) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ xfmpc_dbbrowser_cb_search_entry_activated (self);
+ return FALSE;
+}
- while (xfmpc_mpdclient_database_read (dbbrowser->mpdclient, priv->wdir,
- &filename, &basename, &is_dir))
- {
- is_bold = xfmpc_mpdclient_playlist_has_filename (dbbrowser->mpdclient, filename, is_dir);
- xfmpc_dbbrowser_append (dbbrowser, filename, basename, is_dir, is_bold);
- if (i >= 0)
- {
- if (0 == g_ascii_strcasecmp (filename, priv->last_wdir))
- {
- GtkTreePath *path = gtk_tree_path_new_from_indices (i, -1);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, NULL, FALSE);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->treeview), path, NULL, TRUE, 0.10, 0);
- gtk_tree_path_free (path);
+XfmpcDbbrowser* xfmpc_dbbrowser_construct (GType object_type) {
+ XfmpcDbbrowser * self;
+ self = g_object_newv (object_type, 0, NULL);
+ return self;
+}
- i = -1;
- }
- else
- i++;
- }
- g_free (filename);
- g_free (basename);
- }
+XfmpcDbbrowser* xfmpc_dbbrowser_new (void) {
+ return xfmpc_dbbrowser_construct (XFMPC_TYPE_DBBROWSER);
}
-void
-xfmpc_dbbrowser_search (XfmpcDbbrowser *dbbrowser,
- const gchar *query)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- gchar *filename;
- gchar *basename;
- gboolean is_bold;
- gint i = 0;
- static gboolean no_result, no_result_buf;
- GdkColor color = {0, 0xFFFF, 0x6666, 0x6666};
- if (G_UNLIKELY (!xfmpc_mpdclient_is_connected (dbbrowser->mpdclient)))
- return;
+static void _xfmpc_dbbrowser_add_selected_rows_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self) {
+ xfmpc_dbbrowser_add_selected_rows (self);
+}
- priv->is_searching = TRUE;
- xfmpc_dbbrowser_clear (dbbrowser);
- while (xfmpc_mpdclient_database_search (dbbrowser->mpdclient, query, &filename, &basename))
- {
- is_bold = xfmpc_mpdclient_playlist_has_filename (dbbrowser->mpdclient, filename, 0);
- xfmpc_dbbrowser_append (dbbrowser, filename, basename, FALSE, is_bold);
- g_free (filename);
- g_free (basename);
- i++;
- }
+static void _xfmpc_dbbrowser_cb_replace_with_selected_rows_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self) {
+ xfmpc_dbbrowser_cb_replace_with_selected_rows (self);
+}
- /* check the rightness of the query and then play with the colors */
- no_result_buf = no_result;
- if (i == 0)
- no_result = TRUE;
- else if (no_result)
- no_result = FALSE;
- if (no_result != no_result_buf)
- {
-#ifdef MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
- gtk_widget_modify_base (priv->search_entry, GTK_STATE_NORMAL, no_result ? &color : NULL);
-#endif
- gtk_widget_modify_bg (priv->search_entry, GTK_STATE_NORMAL, no_result ? &color : NULL);
- gtk_widget_modify_bg (priv->search_entry, GTK_STATE_SELECTED, no_result ? &color : NULL);
- }
- if (i == 0)
- {
-#ifdef MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
- gtk_widget_modify_base (priv->search_entry, GTK_STATE_NORMAL, &color);
-#endif
- gtk_widget_modify_bg (priv->search_entry, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_bg (priv->search_entry, GTK_STATE_SELECTED, &color);
- }
- else if (no_result)
- {
-#ifdef MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
- gtk_widget_modify_base (priv->search_entry, GTK_STATE_NORMAL, NULL);
-#endif
- gtk_widget_modify_bg (priv->search_entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_bg (priv->search_entry, GTK_STATE_SELECTED, NULL);
- }
+static void _xfmpc_dbbrowser_cb_browse_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self) {
+ xfmpc_dbbrowser_cb_browse (self);
}
+static void _xfmpc_dbbrowser_reload_xfmpc_mpdclient_connected (XfmpcMpdclient* _sender, gpointer self) {
+ xfmpc_dbbrowser_reload (self);
+}
-void
-xfmpc_dbbrowser_set_wdir (XfmpcDbbrowser *dbbrowser,
- const gchar *dir)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- g_free (priv->last_wdir);
- priv->last_wdir = priv->wdir;
- priv->wdir = g_strdup (dir);
+static void _xfmpc_dbbrowser_reload_xfmpc_mpdclient_database_changed (XfmpcMpdclient* _sender, gpointer self) {
+ xfmpc_dbbrowser_reload (self);
}
-gboolean
-xfmpc_dbbrowser_wdir_is_root (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- return priv->wdir[0] == '\0';
+
+static void _xfmpc_dbbrowser_cb_playlist_changed_xfmpc_mpdclient_playlist_changed (XfmpcMpdclient* _sender, gpointer self) {
+ xfmpc_dbbrowser_cb_playlist_changed (self);
}
-gchar *
-xfmpc_dbbrowser_get_parent_wdir (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- gchar *filename;
- filename = g_strrstr (priv->wdir, "/");
- if (NULL == filename)
- filename = g_strdup ("");
- else
- filename = g_strndup (priv->wdir, filename - priv->wdir);
-
- return filename;
+static void _xfmpc_dbbrowser_cb_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, const GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) {
+ xfmpc_dbbrowser_cb_row_activated (self, path, column);
}
+static gboolean _xfmpc_dbbrowser_cb_key_pressed_gtk_widget_key_press_event (GtkTreeView* _sender, const GdkEventKey* event, gpointer self) {
+ return xfmpc_dbbrowser_cb_key_pressed (self, event);
+}
-static void
-cb_row_activated (XfmpcDbbrowser *dbbrowser,
- GtkTreePath *path,
- GtkTreeViewColumn *column)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- GtkTreeIter iter;
- gchar *filename;
- gboolean is_dir;
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->store), &iter, path))
- return;
+static gboolean _xfmpc_dbbrowser_cb_button_released_gtk_widget_button_press_event (GtkTreeView* _sender, const GdkEventButton* event, gpointer self) {
+ return xfmpc_dbbrowser_cb_button_released (self, event);
+}
- gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
- COLUMN_FILENAME, &filename,
- COLUMN_IS_DIR, &is_dir,
- -1);
- if (is_dir)
- {
- xfmpc_dbbrowser_set_wdir (dbbrowser, filename);
- xfmpc_dbbrowser_reload (dbbrowser);
- }
- else
- {
- xfmpc_mpdclient_queue_add (dbbrowser->mpdclient, filename);
- xfmpc_mpdclient_queue_commit (dbbrowser->mpdclient);
- }
-
- g_free (filename);
+static gboolean _xfmpc_dbbrowser_cb_popup_menu_gtk_widget_popup_menu (GtkTreeView* _sender, gpointer self) {
+ return xfmpc_dbbrowser_cb_popup_menu (self);
}
-static gboolean
-cb_key_pressed (XfmpcDbbrowser *dbbrowser,
- GdkEventKey *event)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- GtkTreeSelection *selection;
- gchar *filename;
- if (event->type != GDK_KEY_PRESS)
- return FALSE;
+static void _xfmpc_dbbrowser_cb_search_entry_activated_gtk_entry_activate (GtkEntry* _sender, gpointer self) {
+ xfmpc_dbbrowser_cb_search_entry_activated (self);
+}
- switch (event->keyval)
- {
- case GDK_Return:
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
- if (gtk_tree_selection_count_selected_rows (selection) > 1)
- xfmpc_dbbrowser_add_selected_rows (dbbrowser);
- else
- return FALSE;
- break;
- case GDK_BackSpace:
- filename = xfmpc_dbbrowser_get_parent_wdir (dbbrowser);
- xfmpc_dbbrowser_set_wdir (dbbrowser, filename);
- g_free (filename);
- xfmpc_dbbrowser_reload (dbbrowser);
- break;
+static gboolean _xfmpc_dbbrowser_cb_search_entry_key_released_gtk_widget_key_release_event (GtkEntry* _sender, const GdkEventKey* event, gpointer self) {
+ return xfmpc_dbbrowser_cb_search_entry_key_released (self, event);
+}
- default:
- return FALSE;
- }
- return TRUE;
+static void _xfmpc_dbbrowser_cb_search_entry_changed_gtk_editable_changed (GtkEntry* _sender, gpointer self) {
+ xfmpc_dbbrowser_cb_search_entry_changed (self);
}
-static gboolean
-cb_button_released (XfmpcDbbrowser *dbbrowser,
- GdkEventButton *event)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- GtkTreeSelection *selection;
- GtkTreePath *path;
-
- if (event->type != GDK_BUTTON_RELEASE || event->button != 3)
- return FALSE;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
- if (gtk_tree_selection_count_selected_rows (selection) < 1)
- return TRUE;
-
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->treeview),
- event->x, event->y,
- &path, NULL, NULL, NULL))
- {
- if (!gtk_tree_selection_path_is_selected (selection, path))
- {
- gtk_tree_selection_unselect_all (selection);
- gtk_tree_selection_select_path (selection, path);
- }
- gtk_tree_path_free (path);
- }
-
- popup_menu (dbbrowser);
- return TRUE;
+static void _xfmpc_dbbrowser_reload_xfmpc_preferences_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self) {
+ xfmpc_dbbrowser_reload (self);
}
-static gboolean
-cb_popup_menu (XfmpcDbbrowser *dbbrowser)
-{
- popup_menu (dbbrowser);
- return TRUE;
-}
-static void
-popup_menu (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- GtkTreeSelection *selection;
- gint count;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
- count = gtk_tree_selection_count_selected_rows (selection);
-
- if (priv->is_searching)
- {
- gtk_widget_show (priv->mi_browse);
- gtk_widget_set_sensitive (priv->mi_browse, count == 1 ? TRUE : FALSE);
- }
- else
- gtk_widget_hide (priv->mi_browse);
-
- gtk_menu_popup (GTK_MENU (priv->menu),
- NULL, NULL,
- NULL, NULL,
- 0,
- gtk_get_current_event_time ());
+static GObject * xfmpc_dbbrowser_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ XfmpcDbbrowserClass * klass;
+ GObjectClass * parent_class;
+ XfmpcDbbrowser * self;
+ klass = XFMPC_DBBROWSER_CLASS (g_type_class_peek (XFMPC_TYPE_DBBROWSER));
+ parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = XFMPC_DBBROWSER (obj);
+ {
+ char* _tmp1;
+ const char* _tmp0;
+ char* _tmp2;
+ GtkListStore* _tmp3;
+ GtkTreeView* _tmp4;
+ GtkCellRendererPixbuf* cell_pixbuf;
+ GtkCellRendererText* cell_text;
+ GtkScrolledWindow* scrolled;
+ GtkMenu* _tmp5;
+ GtkImageMenuItem* mi;
+ GtkImageMenuItem* _tmp6;
+ GtkImage* image;
+ GtkImageMenuItem* _tmp7;
+ GtkImage* _tmp8;
+ GtkEntry* _tmp9;
+ xfce_textdomain (self->priv->gettext_package, self->priv->localedir, "UTF-8");
+ self->priv->mpdclient = xfmpc_mpdclient_get ();
+ self->priv->preferences = xfmpc_preferences_get ();
+ _tmp1 = NULL;
+ _tmp0 = NULL;
+ self->priv->wdir = (_tmp1 = (_tmp0 = xfmpc_preferences_get_dbbrowser_last_path (self->priv->preferences), (_tmp0 == NULL) ? NULL : g_strdup (_tmp0)), self->priv->wdir = (g_free (self->priv->wdir), NULL), _tmp1);
+ _tmp2 = NULL;
+ self->priv->last_wdir = (_tmp2 = g_strndup (self->priv->wdir, (gsize) g_utf8_strlen (self->priv->wdir, -1)), self->priv->last_wdir = (g_free (self->priv->last_wdir), NULL), _tmp2);
+ _tmp3 = NULL;
+ self->priv->store = (_tmp3 = gtk_list_store_new ((gint) XFMPC_DBBROWSER_COLUMNS_N_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT, NULL), (self->priv->store == NULL) ? NULL : (self->priv->store = (g_object_unref (self->priv->store), NULL)), _tmp3);
+ _tmp4 = NULL;
+ self->priv->treeview = (_tmp4 = g_object_ref_sink ((GtkTreeView*) gtk_tree_view_new ()), (self->priv->treeview == NULL) ? NULL : (self->priv->treeview = (g_object_unref (self->priv->treeview), NULL)), _tmp4);
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection (self->priv->treeview), GTK_SELECTION_MULTIPLE);
+ gtk_tree_view_set_rubber_banding (self->priv->treeview, TRUE);
+ gtk_tree_view_set_enable_search (self->priv->treeview, TRUE);
+ gtk_tree_view_set_search_column (self->priv->treeview, (gint) XFMPC_DBBROWSER_COLUMNS_COLUMN_BASENAME);
+ gtk_tree_view_set_headers_visible (self->priv->treeview, FALSE);
+ gtk_tree_view_set_rules_hint (self->priv->treeview, TRUE);
+ gtk_tree_view_set_model (self->priv->treeview, (GtkTreeModel*) self->priv->store);
+ cell_pixbuf = g_object_ref_sink ((GtkCellRendererPixbuf*) gtk_cell_renderer_pixbuf_new ());
+ gtk_tree_view_insert_column_with_attributes (self->priv->treeview, -1, "", (GtkCellRenderer*) cell_pixbuf, "pixbuf", XFMPC_DBBROWSER_COLUMNS_COLUMN_PIXBUF, NULL, NULL);
+ cell_text = g_object_ref_sink ((GtkCellRendererText*) gtk_cell_renderer_text_new ());
+ g_object_set (cell_text, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ gtk_tree_view_insert_column_with_attributes (self->priv->treeview, -1, "Filename", (GtkCellRenderer*) cell_text, "text", XFMPC_DBBROWSER_COLUMNS_COLUMN_BASENAME, "weight", XFMPC_DBBROWSER_COLUMNS_COLUMN_WEIGHT, NULL, NULL);
+ scrolled = g_object_ref_sink ((GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL));
+ gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+ _tmp5 = NULL;
+ self->priv->menu = (_tmp5 = g_object_ref_sink ((GtkMenu*) gtk_menu_new ()), (self->priv->menu == NULL) ? NULL : (self->priv->menu = (g_object_unref (self->priv->menu), NULL)), _tmp5);
+ mi = g_object_ref_sink ((GtkImageMenuItem*) gtk_image_menu_item_new_from_stock (GTK_STOCK_ADD, NULL));
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) mi));
+ g_signal_connect_object ((GtkMenuItem*) mi, "activate", (GCallback) _xfmpc_dbbrowser_add_selected_rows_gtk_menu_item_activate, self, 0);
+ _tmp6 = NULL;
+ mi = (_tmp6 = g_object_ref_sink ((GtkImageMenuItem*) gtk_image_menu_item_new_with_mnemonic (_ ("Replace"))), (mi == NULL) ? NULL : (mi = (g_object_unref (mi), NULL)), _tmp6);
+ image = g_object_ref_sink ((GtkImage*) gtk_image_new_from_stock (GTK_STOCK_CUT, GTK_ICON_SIZE_MENU));
+ gtk_image_menu_item_set_image (mi, (GtkWidget*) image);
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) mi));
+ g_signal_connect_object ((GtkMenuItem*) mi, "activate", (GCallback) _xfmpc_dbbrowser_cb_replace_with_selected_rows_gtk_menu_item_activate, self, 0);
+ _tmp7 = NULL;
+ self->priv->mi_browse = (_tmp7 = g_object_ref_sink ((GtkImageMenuItem*) gtk_image_menu_item_new_with_mnemonic (_ ("Browse"))), (self->priv->mi_browse == NULL) ? NULL : (self->priv->mi_browse = (g_object_unref (self->priv->mi_browse), NULL)), _tmp7);
+ _tmp8 = NULL;
+ image = (_tmp8 = g_object_ref_sink ((GtkImage*) gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU)), (image == NULL) ? NULL : (image = (g_object_unref (image), NULL)), _tmp8);
+ gtk_image_menu_item_set_image (self->priv->mi_browse, (GtkWidget*) image);
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) self->priv->mi_browse));
+ g_signal_connect_object ((GtkMenuItem*) self->priv->mi_browse, "activate", (GCallback) _xfmpc_dbbrowser_cb_browse_gtk_menu_item_activate, self, 0);
+ gtk_widget_show_all ((GtkWidget*) self->priv->menu);
+ _tmp9 = NULL;
+ self->priv->search_entry = (_tmp9 = g_object_ref_sink ((GtkEntry*) gtk_entry_new ()), (self->priv->search_entry == NULL) ? NULL : (self->priv->search_entry = (g_object_unref (self->priv->search_entry), NULL)), _tmp9);
+ gtk_container_add ((GtkContainer*) scrolled, (GtkWidget*) self->priv->treeview);
+ gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) scrolled, TRUE, TRUE, (guint) 0);
+ gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) self->priv->search_entry, FALSE, FALSE, (guint) 0);
+ /* Signals */
+ g_signal_connect_object (self->priv->mpdclient, "connected", (GCallback) _xfmpc_dbbrowser_reload_xfmpc_mpdclient_connected, self, 0);
+ g_signal_connect_object (self->priv->mpdclient, "database-changed", (GCallback) _xfmpc_dbbrowser_reload_xfmpc_mpdclient_database_changed, self, 0);
+ g_signal_connect_object (self->priv->mpdclient, "playlist-changed", (GCallback) _xfmpc_dbbrowser_cb_playlist_changed_xfmpc_mpdclient_playlist_changed, self, 0);
+ g_signal_connect_object (self->priv->treeview, "row-activated", (GCallback) _xfmpc_dbbrowser_cb_row_activated_gtk_tree_view_row_activated, self, 0);
+ g_signal_connect_object ((GtkWidget*) self->priv->treeview, "key-press-event", (GCallback) _xfmpc_dbbrowser_cb_key_pressed_gtk_widget_key_press_event, self, 0);
+ g_signal_connect_object ((GtkWidget*) self->priv->treeview, "button-press-event", (GCallback) _xfmpc_dbbrowser_cb_button_released_gtk_widget_button_press_event, self, 0);
+ g_signal_connect_object ((GtkWidget*) self->priv->treeview, "popup-menu", (GCallback) _xfmpc_dbbrowser_cb_popup_menu_gtk_widget_popup_menu, self, 0);
+ 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);
+ (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));
+ (mi == NULL) ? NULL : (mi = (g_object_unref (mi), NULL));
+ (image == NULL) ? NULL : (image = (g_object_unref (image), NULL));
+ }
+ return obj;
}
-static void
-cb_browse (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- GtkTreeSelection *selection;
- GtkTreeModel *store = GTK_TREE_MODEL (priv->store);
- GtkTreeIter iter;
- GList *list;
- gchar *dir, *filename;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
- if (gtk_tree_selection_count_selected_rows (selection) > 1)
- return;
-
- list = gtk_tree_selection_get_selected_rows (selection, &store);
- if (gtk_tree_model_get_iter (store, &iter, list->data))
- {
- gtk_tree_model_get (store, &iter,
- COLUMN_FILENAME, &filename,
- -1);
-
- priv->is_searching = FALSE;
- dir = g_path_get_dirname (filename);
- xfmpc_dbbrowser_set_wdir (dbbrowser, dir);
- xfmpc_dbbrowser_reload (dbbrowser);
-
- g_free (filename);
- g_free (dir);
- }
-
- g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (list);
+static void xfmpc_dbbrowser_class_init (XfmpcDbbrowserClass * klass) {
+ xfmpc_dbbrowser_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (XfmpcDbbrowserPrivate));
+ G_OBJECT_CLASS (klass)->constructor = xfmpc_dbbrowser_constructor;
+ G_OBJECT_CLASS (klass)->finalize = xfmpc_dbbrowser_finalize;
}
-
-static void
-cb_search_entry_activated (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- const gchar *entry_text = gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
-
- if (entry_text[0] == '\0')
- {
- priv->is_searching = FALSE;
- xfmpc_dbbrowser_reload (dbbrowser);
-
- /* revert possible previous applied color */
-#ifdef MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
- gtk_widget_modify_base (priv->search_entry, GTK_STATE_NORMAL, NULL);
-#endif
- gtk_widget_modify_bg (priv->search_entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_bg (priv->search_entry, GTK_STATE_SELECTED, NULL);
- return;
- }
-
- xfmpc_dbbrowser_search (dbbrowser, entry_text);
+static void xfmpc_dbbrowser_instance_init (XfmpcDbbrowser * self) {
+ self->priv = XFMPC_DBBROWSER_GET_PRIVATE (self);
+ self->priv->gettext_package = g_strdup (GETTEXT_PACKAGE);
+ self->priv->localedir = g_strdup (PACKAGE_LOCALE_DIR);
}
-static gboolean
-cb_search_entry_key_released (XfmpcDbbrowser *dbbrowser,
- GdkEventKey *event)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- if (event->type != GDK_KEY_RELEASE)
- return FALSE;
-
- if (event->keyval == GDK_Escape)
- {
- gtk_entry_set_text (GTK_ENTRY (priv->search_entry), "");
- }
-
- return TRUE;
+static void xfmpc_dbbrowser_finalize (GObject* obj) {
+ XfmpcDbbrowser * self;
+ self = XFMPC_DBBROWSER (obj);
+ self->priv->gettext_package = (g_free (self->priv->gettext_package), NULL);
+ self->priv->localedir = (g_free (self->priv->localedir), NULL);
+ (self->priv->store == NULL) ? NULL : (self->priv->store = (g_object_unref (self->priv->store), NULL));
+ (self->priv->treeview == NULL) ? NULL : (self->priv->treeview = (g_object_unref (self->priv->treeview), NULL));
+ (self->priv->menu == NULL) ? NULL : (self->priv->menu = (g_object_unref (self->priv->menu), NULL));
+ (self->priv->search_entry == NULL) ? NULL : (self->priv->search_entry = (g_object_unref (self->priv->search_entry), NULL));
+ (self->priv->mi_browse == NULL) ? NULL : (self->priv->mi_browse = (g_object_unref (self->priv->mi_browse), NULL));
+ self->priv->wdir = (g_free (self->priv->wdir), NULL);
+ self->priv->last_wdir = (g_free (self->priv->last_wdir), NULL);
+ G_OBJECT_CLASS (xfmpc_dbbrowser_parent_class)->finalize (obj);
}
-static void
-cb_search_entry_changed (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- if (priv->search_timeout > 0)
- g_source_remove (priv->search_timeout);
-
- priv->search_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT, 642,
- (GSourceFunc)timeout_search, dbbrowser,
- (GDestroyNotify)timeout_search_destroy);
+GType xfmpc_dbbrowser_get_type (void) {
+ static GType xfmpc_dbbrowser_type_id = 0;
+ if (xfmpc_dbbrowser_type_id == 0) {
+ static const GTypeInfo g_define_type_info = { sizeof (XfmpcDbbrowserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xfmpc_dbbrowser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XfmpcDbbrowser), 0, (GInstanceInitFunc) xfmpc_dbbrowser_instance_init, NULL };
+ xfmpc_dbbrowser_type_id = g_type_register_static (GTK_TYPE_VBOX, "XfmpcDbbrowser", &g_define_type_info, 0);
+ }
+ return xfmpc_dbbrowser_type_id;
}
-static gboolean
-timeout_search (XfmpcDbbrowser *dbbrowser)
-{
- cb_search_entry_activated (dbbrowser);
- return FALSE;
-}
-static void
-timeout_search_destroy (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- priv->search_timeout = 0;
+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);
}
-static void
-cb_playlist_changed (XfmpcDbbrowser *dbbrowser)
-{
- XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER (dbbrowser)->priv;
- GtkTreeModel *store = GTK_TREE_MODEL (priv->store);
- GtkTreeIter iter;
- gchar *filename;
- gboolean is_bold;
- gboolean is_dir;
- if (!gtk_tree_model_get_iter_first (store, &iter))
- return;
-
- do
- {
- gtk_tree_model_get (store, &iter,
- COLUMN_FILENAME, &filename,
- COLUMN_IS_DIR, &is_dir,
- -1);
-
- is_bold = xfmpc_mpdclient_playlist_has_filename (dbbrowser->mpdclient, filename, is_dir);
- gtk_list_store_set (GTK_LIST_STORE (store), &iter,
- COLUMN_WEIGHT, is_bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
- -1);
-
- g_free (filename);
- }
- while (gtk_tree_model_iter_next (store, &iter));
-}
-
Added: xfmpc/trunk/src/dbbrowser.vala
===================================================================
--- xfmpc/trunk/src/dbbrowser.vala (rev 0)
+++ xfmpc/trunk/src/dbbrowser.vala 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,477 @@
+/*
+ * 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 Dbbrowser : VBox {
+
+ private unowned Xfmpc.Mpdclient mpdclient;
+ private unowned Xfmpc.Preferences preferences;
+
+ private string gettext_package = Config.GETTEXT_PACKAGE;
+ private string localedir = Config.PACKAGE_LOCALE_DIR;
+
+ private ListStore store;
+ private TreeView treeview;
+ private Menu menu;
+ private Entry search_entry;
+ private ImageMenuItem mi_browse;
+
+ private string wdir;
+ private string last_wdir;
+
+ private bool is_searching;
+ private uint search_timeout;
+
+ private enum Columns {
+ COLUMN_ID,
+ COLUMN_PIXBUF,
+ COLUMN_FILENAME,
+ COLUMN_BASENAME,
+ COLUMN_IS_DIR,
+ COLUMN_WEIGHT,
+ N_COLUMNS,
+ }
+
+ construct {
+ Xfce.textdomain (gettext_package, localedir, "UTF-8");
+
+ mpdclient = Xfmpc.Mpdclient.get ();
+ preferences = Xfmpc.Preferences.get ();
+
+ wdir = preferences.dbbrowser_last_path;
+ last_wdir = wdir.ndup (wdir.len ());
+
+ store = new ListStore (Columns.N_COLUMNS,
+ typeof (int),
+ typeof (Gdk.Pixbuf),
+ typeof (string),
+ typeof (string),
+ typeof (bool),
+ typeof (int));
+
+ treeview = new TreeView ();
+ (treeview.get_selection ()).set_mode (SelectionMode.MULTIPLE);
+ treeview.set_rubber_banding (true);
+ treeview.set_enable_search (true);
+ treeview.set_search_column (Columns.COLUMN_BASENAME);
+ treeview.set_headers_visible (false);
+ treeview.set_rules_hint (true);
+ treeview.set_model (store);
+
+ var cell_pixbuf = new CellRendererPixbuf ();
+ treeview.insert_column_with_attributes (-1, "", cell_pixbuf,
+ "pixbuf", Columns.COLUMN_PIXBUF,
+ null);
+
+ var cell_text = new CellRendererText ();
+ cell_text.ellipsize = Pango.EllipsizeMode.END;
+ treeview.insert_column_with_attributes (-1, "Filename", cell_text,
+ "text", Columns.COLUMN_BASENAME,
+ "weight", Columns.COLUMN_WEIGHT,
+ null);
+
+ var scrolled = new ScrolledWindow (null, null);
+ scrolled.set_policy (PolicyType.AUTOMATIC, PolicyType.ALWAYS);
+
+ menu = new Menu ();
+
+ var mi = new ImageMenuItem.from_stock (STOCK_ADD, null);
+ menu.append (mi);
+ mi.activate += add_selected_rows;
+ mi = new ImageMenuItem.with_mnemonic (_("Replace"));
+ var image = new Image.from_stock (STOCK_CUT, IconSize.MENU);
+ mi.set_image (image);
+ menu.append (mi);
+ mi.activate += cb_replace_with_selected_rows;
+ mi_browse = new ImageMenuItem.with_mnemonic (_("Browse"));
+ image = new Image.from_stock (STOCK_OPEN, IconSize.MENU);
+ mi_browse.set_image (image);
+ menu.append (mi_browse);
+ mi_browse.activate += cb_browse;
+
+ menu.show_all ();
+
+ search_entry = new Entry ();
+
+ scrolled.add (treeview);
+ pack_start (scrolled, true, true, 0);
+ pack_start (search_entry, false, false, 0);
+
+ /* Signals */
+ mpdclient.connected += reload;
+ mpdclient.database_changed += reload;
+ mpdclient.playlist_changed += cb_playlist_changed;
+
+ treeview.row_activated += cb_row_activated;
+ treeview.key_press_event += cb_key_pressed;
+ treeview.button_press_event += cb_button_released;
+ treeview.popup_menu += cb_popup_menu;
+
+ search_entry.activate += cb_search_entry_activated;
+ search_entry.key_release_event += cb_search_entry_key_released;
+ search_entry.changed += cb_search_entry_changed;
+
+ preferences.notify["song-format"] += reload;
+ preferences.notify["song-format-custom"] += reload;
+ }
+
+ public void free () {
+ }
+
+ public void reload () {
+ string filename = "", basename = "";
+ bool is_dir = false, is_bold = false;
+ int i = 0;
+
+ if (!mpdclient.is_connected ())
+ return;
+ if (is_searching)
+ return;
+
+ clear ();
+
+ if (!wdir_is_root ()) {
+ filename = get_parent_wdir ();
+ append (filename, "..", true, false);
+ i ++;
+ }
+
+ while (mpdclient.database_read (wdir, &filename, &basename, &is_dir)) {
+ is_bold = mpdclient.playlist_has_filename (filename, is_dir);
+ append (filename, basename, is_dir, is_bold);
+
+ if (filename.collate (last_wdir) == 0) {
+ var path = new TreePath.from_indices (i, -1);
+ treeview.set_cursor (path, null, false);
+ treeview.scroll_to_cell (path, null, true, (float) 0.10, 0);
+ i = -1;
+ }
+ else
+ i++;
+ }
+ }
+
+ public bool wdir_is_root () {
+ return (wdir == "");
+ }
+
+ public string get_parent_wdir () {
+ string filename = wdir.str ("/");
+
+ if (filename == null)
+ return "";
+ else
+ return Path.get_dirname (wdir);
+ }
+
+ public void append (string filename, string basename, bool is_dir, bool is_bold) {
+ TreeIter iter;
+
+ var pixbuf = treeview.render_icon (is_dir ? STOCK_DIRECTORY : STOCK_FILE,
+ IconSize.MENU, null);
+
+ store.append (out iter);
+ store.set (iter,
+ Columns.COLUMN_PIXBUF, pixbuf,
+ Columns.COLUMN_FILENAME, filename,
+ Columns.COLUMN_BASENAME, basename,
+ Columns.COLUMN_IS_DIR, is_dir,
+ Columns.COLUMN_WEIGHT, is_bold ? Pango.Weight.BOLD : Pango.Weight.NORMAL,
+ -1);
+ }
+
+ public void set_wdir (string dir) {
+ last_wdir = wdir;
+ wdir = dir;
+ }
+
+ public void add_selected_rows () {
+ TreeModel model = store;
+ TreeIter iter;
+ string filename = "";
+
+ var list = (treeview.get_selection ()).get_selected_rows (out model);
+
+ foreach (TreePath path in list) {
+ if (model.get_iter (out iter, path)) {
+ model.get (iter, Columns.COLUMN_FILENAME, out filename, -1);
+ mpdclient.queue_add (filename);
+ }
+ }
+
+ mpdclient.queue_commit ();
+ }
+
+ public void search (string query) {
+ string filename = "", basename = "";
+ bool is_bold;
+ int i = 0;
+
+ if (!mpdclient.is_connected ())
+ return;
+
+ is_searching = true;
+ clear ();
+
+ while (mpdclient.database_search (query, &filename, &basename)) {
+ is_bold = mpdclient.playlist_has_filename (filename, false);
+ append (filename, basename, false, is_bold);
+ i++;
+ }
+
+ bool no_result_buf = false, no_result = false;
+
+ Gdk.Color color;
+ Gdk.Color.parse ("white", out color);
+ color.red = 0xFFFF;
+ color.green = 0x6666;
+ color.blue = 0x6666;
+
+ if (i == 0)
+ no_result = true;
+ else if (no_result)
+ no_result = false;
+
+ if (no_result == no_result_buf && no_result) {
+#if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
+ search_entry.modify_base (StateType.NORMAL, color);
+#endif
+ search_entry.modify_bg (StateType.NORMAL, color);
+ search_entry.modify_bg (StateType.SELECTED, color);
+ }
+ else if (no_result == no_result_buf && !no_result) {
+#if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
+ search_entry.modify_base (StateType.NORMAL, null);
+#endif
+ search_entry.modify_bg (StateType.NORMAL, null);
+ search_entry.modify_bg (StateType.SELECTED, null);
+ }
+
+ if (i == 0) {
+#if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
+ search_entry.modify_base (StateType.NORMAL, color);
+#endif
+ search_entry.modify_bg (StateType.NORMAL, color);
+ search_entry.modify_bg (StateType.SELECTED, color);
+ }
+ else if (no_result) {
+#if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
+ search_entry.modify_base (StateType.NORMAL, null);
+#endif
+ search_entry.modify_bg (StateType.NORMAL, null);
+ search_entry.modify_bg (StateType.SELECTED, null);
+ }
+ }
+
+ private void clear () {
+ store.clear ();
+ }
+
+ private void menu_popup () {
+ var selection = treeview.get_selection ();
+ int count = selection.count_selected_rows ();
+
+ if (is_searching) {
+ mi_browse.show ();
+ mi_browse.set_sensitive (count == 1 ? true : false);
+ }
+ else
+ mi_browse.hide ();
+
+ menu.popup (null, null, null, 0, get_current_event_time ());
+ }
+
+ /*
+ * Signal callbacks
+ */
+
+ private void cb_playlist_changed () {
+ TreeModel model = store;
+ TreeIter iter;
+ string filename = "";
+ bool is_bold = false, is_dir = false;
+
+ if (!model.get_iter_first (out iter))
+ return;
+
+ do {
+ model.get (iter,
+ Columns.COLUMN_FILENAME, out filename,
+ Columns.COLUMN_IS_DIR, out is_dir,
+ -1);
+
+ is_bold = mpdclient.playlist_has_filename (filename, is_dir);
+ store.set (iter,
+ Columns.COLUMN_WEIGHT,
+ is_bold ? Pango.Weight.BOLD : Pango.Weight.NORMAL,
+ -1);
+ } while (model.iter_next (ref iter));
+ }
+
+ private bool cb_popup_menu () {
+ menu_popup ();
+ return true;
+ }
+
+ private bool cb_key_pressed (Gdk.EventKey event) {
+ if (event.type != Gdk.EventType.KEY_PRESS)
+ return false;
+
+ switch (event.keyval) {
+ case 0xff0d:
+ var selection = treeview.get_selection ();
+ if (selection.count_selected_rows () > 1)
+ add_selected_rows ();
+ else
+ return false;
+ break;
+
+ case 0xff08:
+ string filename = get_parent_wdir ();
+ set_wdir (filename);
+ reload ();
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+ private bool cb_button_released (Gdk.EventButton event) {
+ if (event.type != Gdk.EventType.BUTTON_PRESS || event.button != 3)
+ return false;
+
+ TreePath path;
+ var selection = treeview.get_selection ();
+ if (selection.count_selected_rows () < 1)
+ return true;
+
+ if (treeview.get_path_at_pos ((int) event.x, (int) event.y,
+ out path, null, null, null))
+ {
+ if (!selection.path_is_selected (path)) {
+ selection.unselect_all ();
+ selection.select_path (path);
+ }
+ }
+
+ menu_popup ();
+
+ return true;
+ }
+
+ private void cb_row_activated (TreePath path, TreeViewColumn column) {
+ TreePath ppath = path;
+ TreeModel model = store;
+ TreeIter iter;
+ string filename = "";
+ bool is_dir = false;
+
+ if (!model.get_iter (out iter, ppath))
+ return;
+
+ model.get (iter,
+ Columns.COLUMN_FILENAME, out filename,
+ Columns.COLUMN_IS_DIR, out is_dir,
+ -1);
+
+ if (is_dir) {
+ set_wdir (filename);
+ reload ();
+ } else {
+ mpdclient.queue_add (filename);
+ mpdclient.queue_commit ();
+ }
+ }
+
+ private void cb_replace_with_selected_rows () {
+ mpdclient.queue_clear ();
+ add_selected_rows ();
+ }
+
+ private void cb_browse () {
+ TreeModel model = store;
+ TreeIter iter;
+
+ var selection = treeview.get_selection ();
+ if (selection.count_selected_rows () > 1)
+ return;
+
+ var list = selection.get_selected_rows (out model);
+ var path = list.nth_data (0);
+ if (model.get_iter (out iter, path)) {
+ string filename;
+ model.get (iter, Columns.COLUMN_FILENAME, out filename, -1);
+ string dir = Path.get_dirname (filename);
+ set_wdir (dir);
+ reload ();
+ }
+ }
+
+ private void cb_search_entry_activated () {
+ string entry_text = search_entry.get_text ();
+
+ if (entry_text == "") {
+ is_searching = false;
+ reload ();
+
+ /* revert possible previous applied color */
+#if MORE_FUNKY_COLOR_ON_SEARCH_ENTRY
+ search_entry.modify_base (StateType.NORMAL, null);
+#endif
+ search_entry.modify_bg (StateType.NORMAL, null);
+ search_entry.modify_bg (StateType.SELECTED, null);
+
+ return;
+ }
+
+ search (entry_text);
+ }
+
+ private bool cb_search_entry_key_released (Gdk.EventKey event) {
+ if (event.type != Gdk.EventType.KEY_RELEASE)
+ return false;
+
+ /* Escape */
+ if (event.keyval == 0xff1b)
+ search_entry.set_text ("");
+
+ return true;
+ }
+
+ private void cb_search_entry_changed () {
+ if (search_timeout > 0)
+ Source.remove (search_timeout);
+
+ search_timeout = Timeout.add_full (Priority.DEFAULT, 642, timeout_search);
+ }
+
+ private bool timeout_search () {
+ cb_search_entry_activated ();
+ return false;
+ }
+ }
+}
+
+/* vi:set ts=8 sw=8: */
Modified: xfmpc/trunk/src/extended-interface.c
===================================================================
--- xfmpc/trunk/src/extended-interface.c 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/extended-interface.c 2009-04-23 11:11:39 UTC (rev 7280)
@@ -1,5 +1,6 @@
/*
- * 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>
*
* 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
@@ -16,445 +17,561 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifdef HAVE_CONFIG_H
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <mpdclient.h>
+#include <preferences.h>
+#include <stdlib.h>
+#include <string.h>
#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <glib/gi18n-lib.h>
#include <libxfcegui4/libxfcegui4.h>
#include <libxfce4util/libxfce4util.h>
+#include <xfce-arrow-button.h>
-#include "extended-interface.h"
-#include "mpdclient.h"
-#include "playlist.h"
-#include "dbbrowser.h"
-#include "xfce-arrow-button.h"
-#include "preferences-dialog.h"
-#include "preferences.h"
-#define BORDER 4
+#define XFMPC_TYPE_EXTENDED_INTERFACE (xfmpc_extended_interface_get_type ())
+#define XFMPC_EXTENDED_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterface))
+#define XFMPC_EXTENDED_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfaceClass))
+#define XFMPC_IS_EXTENDED_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_EXTENDED_INTERFACE))
+#define XFMPC_IS_EXTENDED_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_EXTENDED_INTERFACE))
+#define XFMPC_EXTENDED_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfaceClass))
-#define GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfacePrivate))
+typedef struct _XfmpcExtendedInterface XfmpcExtendedInterface;
+typedef struct _XfmpcExtendedInterfaceClass XfmpcExtendedInterfaceClass;
+typedef struct _XfmpcExtendedInterfacePrivate XfmpcExtendedInterfacePrivate;
+#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 ())
-/* List store identifiers */
-enum
-{
- COLUMN_STRING,
- COLUMN_POINTER,
- N_COLUMNS,
-};
+#define XFMPC_TYPE_PREFERENCES_DIALOG (xfmpc_preferences_dialog_get_type ())
+#define XFMPC_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialog))
+#define XFMPC_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialogClass))
+#define XFMPC_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES_DIALOG))
+#define XFMPC_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES_DIALOG))
+#define XFMPC_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialogClass))
+typedef struct _XfmpcPreferencesDialog XfmpcPreferencesDialog;
+typedef struct _XfmpcPreferencesDialogClass XfmpcPreferencesDialogClass;
+#define XFMPC_TYPE_PLAYLIST (xfmpc_playlist_get_type ())
+#define XFMPC_PLAYLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PLAYLIST, XfmpcPlaylist))
+#define XFMPC_PLAYLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistClass))
+#define XFMPC_IS_PLAYLIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PLAYLIST))
+#define XFMPC_IS_PLAYLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PLAYLIST))
+#define XFMPC_PLAYLIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistClass))
-static void xfmpc_extended_interface_class_init (XfmpcExtendedInterfaceClass *klass);
-static void xfmpc_extended_interface_init (XfmpcExtendedInterface *extended_interface);
-static void xfmpc_extended_interface_dispose (GObject *object);
-static void xfmpc_extended_interface_finalize (GObject *object);
+typedef struct _XfmpcPlaylist XfmpcPlaylist;
+typedef struct _XfmpcPlaylistClass XfmpcPlaylistClass;
-static void xfmpc_extended_interface_context_menu_new (XfmpcExtendedInterface *extended_interface,
- GtkWidget *attach_widget);
+#define XFMPC_TYPE_DBBROWSER (xfmpc_dbbrowser_get_type ())
+#define XFMPC_DBBROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowser))
+#define XFMPC_DBBROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserClass))
+#define XFMPC_IS_DBBROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_DBBROWSER))
+#define XFMPC_IS_DBBROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_DBBROWSER))
+#define XFMPC_DBBROWSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserClass))
-static void cb_interface_changed (GtkComboBox *widget,
- XfmpcExtendedInterface *extended_interface);
-static void cb_repeat_switch (XfmpcExtendedInterface *extended_interface);
-static void cb_random_switch (XfmpcExtendedInterface *extended_interface);
-static void cb_context_menu_clicked (GtkToggleButton *button,
- XfmpcExtendedInterface *extended_interface);
-static void cb_preferences (XfmpcExtendedInterface *extended_interface);
-static void cb_about (XfmpcExtendedInterface *extended_interface);
-static void cb_context_menu_deactivate (GtkMenuShell *menu,
- GtkWidget *attach_widget);
-static void popup_context_menu (XfmpcExtendedInterface *extended_interface);
-static void position_context_menu (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- GtkWidget *widget);
+typedef struct _XfmpcDbbrowser XfmpcDbbrowser;
+typedef struct _XfmpcDbbrowserClass XfmpcDbbrowserClass;
-
-
-struct _XfmpcExtendedInterfaceClass
-{
- GtkVBoxClass parent_class;
+struct _XfmpcExtendedInterface {
+ GtkVBox parent_instance;
+ XfmpcExtendedInterfacePrivate * priv;
};
-struct _XfmpcExtendedInterface
-{
- GtkVBox parent;
- XfmpcMpdclient *mpdclient;
- XfmpcPreferences *preferences;
- /*<private>*/
- XfmpcExtendedInterfacePrivate *priv;
+struct _XfmpcExtendedInterfaceClass {
+ GtkVBoxClass parent_class;
};
-struct _XfmpcExtendedInterfacePrivate
-{
- GtkListStore *list_store;
- GtkWidget *combobox;
- GtkWidget *notebook;
- GtkWidget *context_button;
- GtkWidget *context_menu;
+struct _XfmpcExtendedInterfacePrivate {
+ XfmpcMpdclient* mpdclient;
+ XfmpcPreferences* preferences;
+ char* gettext_package;
+ char* localedir;
+ GtkListStore* list_store;
+ GtkComboBox* combobox;
+ GtkNotebook* notebook;
+ GtkMenu* context_menu;
};
+typedef enum {
+ XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_STRING,
+ XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_POINTER,
+ XFMPC_EXTENDED_INTERFACE_COLUMNS_N_COLUMNS
+} XfmpcExtendedInterfaceColumns;
+typedef enum {
+ XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_PLAYLIST,
+ XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_DBBROWSER
+} XfmpcExtendedInterfaceExtendedInterfaceWidget;
-static GObjectClass *parent_class = NULL;
+GType xfmpc_extended_interface_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
+};
+static GType xfmpc_extended_interface_columns_get_type (void);
+GType xfmpc_extended_interface_extended_interface_widget_get_type (void);
+static XfceArrowButton* xfmpc_extended_interface_context_button;
+static XfceArrowButton* xfmpc_extended_interface_context_button = NULL;
+void xfmpc_extended_interface_set_active (XfmpcExtendedInterface* self, XfmpcExtendedInterfaceExtendedInterfaceWidget active_widget);
+static void xfmpc_extended_interface_append_child (XfmpcExtendedInterface* self, GtkWidget* child, const char* title);
+static void xfmpc_extended_interface_context_menu_new (XfmpcExtendedInterface* self, GtkWidget* attach_widget);
+static void xfmpc_extended_interface_position_context_menu (GtkMenu* menu, gint x, gint y, gboolean push_in);
+static void xfmpc_extended_interface_popup_context_menu (XfmpcExtendedInterface* self);
+static void xfmpc_extended_interface_menu_detach (XfmpcExtendedInterface* self, GtkWidget* attach_widget, GtkMenu* menu);
+static void xfmpc_extended_interface_cb_context_menu_deactivate (XfmpcExtendedInterface* self);
+static void _xfmpc_extended_interface_cb_context_menu_deactivate_gtk_menu_shell_deactivate (GtkMenu* _sender, gpointer self);
+static void xfmpc_extended_interface_cb_repeat_switch (XfmpcExtendedInterface* self);
+static void _xfmpc_extended_interface_cb_repeat_switch_gtk_menu_item_activate (GtkCheckMenuItem* _sender, gpointer self);
+static void xfmpc_extended_interface_cb_random_switch (XfmpcExtendedInterface* self);
+static void _xfmpc_extended_interface_cb_random_switch_gtk_menu_item_activate (GtkCheckMenuItem* _sender, gpointer self);
+static void xfmpc_extended_interface_cb_preferences (XfmpcExtendedInterface* self);
+static void _xfmpc_extended_interface_cb_preferences_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self);
+static void xfmpc_extended_interface_cb_about (XfmpcExtendedInterface* self);
+static void _xfmpc_extended_interface_cb_about_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self);
+static void xfmpc_extended_interface_cb_playlist_clear (XfmpcExtendedInterface* self);
+static void xfmpc_extended_interface_cb_database_refresh (XfmpcExtendedInterface* self);
+static void xfmpc_extended_interface_cb_interface_changed (XfmpcExtendedInterface* self);
+static void xfmpc_extended_interface_cb_context_menu_clicked (XfmpcExtendedInterface* self);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_new (void);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_construct (GType object_type);
+GType xfmpc_preferences_dialog_get_type (void);
+XfmpcExtendedInterface* xfmpc_extended_interface_new (void);
+XfmpcExtendedInterface* xfmpc_extended_interface_construct (GType object_type);
+XfmpcExtendedInterface* xfmpc_extended_interface_new (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);
+static void _xfmpc_extended_interface_cb_context_menu_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self);
+static void _xfmpc_extended_interface_cb_interface_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
+XfmpcPlaylist* xfmpc_playlist_new (void);
+XfmpcPlaylist* xfmpc_playlist_construct (GType object_type);
+GType xfmpc_playlist_get_type (void);
+XfmpcDbbrowser* xfmpc_dbbrowser_new (void);
+XfmpcDbbrowser* xfmpc_dbbrowser_construct (GType object_type);
+GType xfmpc_dbbrowser_get_type (void);
+static GObject * xfmpc_extended_interface_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
+static gpointer xfmpc_extended_interface_parent_class = NULL;
+static void xfmpc_extended_interface_finalize (GObject* obj);
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
-GType
-xfmpc_extended_interface_get_type ()
-{
- static GType xfmpc_extended_interface_type = G_TYPE_INVALID;
- if (G_UNLIKELY (xfmpc_extended_interface_type == G_TYPE_INVALID))
- {
- static const GTypeInfo xfmpc_extended_interface_info =
- {
- sizeof (XfmpcExtendedInterfaceClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) xfmpc_extended_interface_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (XfmpcExtendedInterface),
- 0,
- (GInstanceInitFunc) xfmpc_extended_interface_init,
- NULL
- };
- xfmpc_extended_interface_type = g_type_register_static (GTK_TYPE_VBOX, "XfmpcExtendedInterface", &xfmpc_extended_interface_info, 0);
- }
- return xfmpc_extended_interface_type;
+
+static GType xfmpc_extended_interface_columns_get_type (void) {
+ static GType xfmpc_extended_interface_columns_type_id = 0;
+ if (G_UNLIKELY (xfmpc_extended_interface_columns_type_id == 0)) {
+ static const GEnumValue values[] = {{XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_STRING, "XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_STRING", "column-string"}, {XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_POINTER, "XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_POINTER", "column-pointer"}, {XFMPC_EXTENDED_INTERFACE_COLUMNS_N_COLUMNS, "XFMPC_EXTENDED_INTERFACE_COLUMNS_N_COLUMNS", "n-columns"}, {0, NULL, NULL}};
+ xfmpc_extended_interface_columns_type_id = g_enum_register_static ("XfmpcExtendedInterfaceColumns", values);
+ }
+ return xfmpc_extended_interface_columns_type_id;
}
-static void
-xfmpc_extended_interface_class_init (XfmpcExtendedInterfaceClass *klass)
-{
- GObjectClass *gobject_class;
+GType xfmpc_extended_interface_extended_interface_widget_get_type (void) {
+ static GType xfmpc_extended_interface_extended_interface_widget_type_id = 0;
+ if (G_UNLIKELY (xfmpc_extended_interface_extended_interface_widget_type_id == 0)) {
+ static const GEnumValue values[] = {{XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_PLAYLIST, "XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_PLAYLIST", "playlist"}, {XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_DBBROWSER, "XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_DBBROWSER", "dbbrowser"}, {0, NULL, NULL}};
+ xfmpc_extended_interface_extended_interface_widget_type_id = g_enum_register_static ("XfmpcExtendedInterfaceExtendedInterfaceWidget", values);
+ }
+ return xfmpc_extended_interface_extended_interface_widget_type_id;
+}
- g_type_class_add_private (klass, sizeof (XfmpcExtendedInterfacePrivate));
- parent_class = g_type_class_peek_parent (klass);
+void xfmpc_extended_interface_set_active (XfmpcExtendedInterface* self, XfmpcExtendedInterfaceExtendedInterfaceWidget active_widget) {
+ g_return_if_fail (self != NULL);
+ gtk_combo_box_set_active (self->priv->combobox, (gint) active_widget);
+}
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->dispose = xfmpc_extended_interface_dispose;
- gobject_class->finalize = xfmpc_extended_interface_finalize;
+
+static void xfmpc_extended_interface_append_child (XfmpcExtendedInterface* self, GtkWidget* child, const char* title) {
+ GtkTreeIter iter = {0};
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (child != NULL);
+ g_return_if_fail (title != NULL);
+ gtk_list_store_append (self->priv->list_store, &iter);
+ gtk_list_store_set (self->priv->list_store, &iter, XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_STRING, title, XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_POINTER, child, -1, -1);
+ if (gtk_combo_box_get_active (self->priv->combobox) == (-1)) {
+ gtk_combo_box_set_active (self->priv->combobox, 0);
+ }
+ gtk_notebook_append_page (self->priv->notebook, child, NULL);
+ gtk_notebook_set_tab_label_packing (self->priv->notebook, child, TRUE, TRUE, GTK_PACK_START);
}
-static void
-xfmpc_extended_interface_init (XfmpcExtendedInterface *extended_interface)
-{
- XfmpcExtendedInterfacePrivate *priv = extended_interface->priv = GET_PRIVATE (extended_interface);
- extended_interface->mpdclient = xfmpc_mpdclient_get ();
- extended_interface->preferences = xfmpc_preferences_get ();
+static void xfmpc_extended_interface_popup_context_menu (XfmpcExtendedInterface* self) {
+ g_return_if_fail (self != NULL);
+ if (self->priv->context_menu == NULL) {
+ xfmpc_extended_interface_context_menu_new (self, GTK_WIDGET (xfmpc_extended_interface_context_button));
+ }
+ gtk_menu_popup (self->priv->context_menu, NULL, NULL, (GtkMenuPositionFunc) xfmpc_extended_interface_position_context_menu, NULL, (guint) 0, gtk_get_current_event_time ());
+}
- /* Hbox */
- GtkWidget *hbox = gtk_hbox_new (FALSE, 2);
- gtk_box_pack_start (GTK_BOX (extended_interface), hbox, FALSE, FALSE, 2);
- /* Clear playlist */
- GtkWidget *widget = gtk_button_new ();
- gtk_widget_set_tooltip_text (widget, _("Clear Playlist"));
- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
- g_signal_connect_swapped (widget, "clicked",
- G_CALLBACK (xfmpc_mpdclient_playlist_clear), extended_interface->mpdclient);
+static void xfmpc_extended_interface_position_context_menu (GtkMenu* menu, gint x, gint y, gboolean push_in) {
+ GtkRequisition menu_req = {0};
+ gint root_x;
+ gint root_y;
+ g_return_if_fail (menu != NULL);
+ root_x = 0;
+ root_y = 0;
+ gtk_widget_size_request ((GtkWidget*) menu, &menu_req);
+ gdk_window_get_origin (GTK_WIDGET (xfmpc_extended_interface_context_button)->window, &root_x, &root_y);
+ x = root_x + GTK_WIDGET (xfmpc_extended_interface_context_button)->allocation.x;
+ y = root_y + GTK_WIDGET (xfmpc_extended_interface_context_button)->allocation.y;
+ if (y > (gdk_screen_height () - menu_req.height)) {
+ y = gdk_screen_height () - menu_req.height;
+ } else {
+ if (y < 0) {
+ y = 0;
+ }
+ }
+ push_in = FALSE;
+}
- GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (widget), image);
- /* Refresh database */
- widget = gtk_button_new ();
- gtk_widget_set_tooltip_text (widget, _("Refresh Database"));
- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
- g_signal_connect_swapped (widget, "clicked",
- G_CALLBACK (xfmpc_mpdclient_database_refresh), extended_interface->mpdclient);
+static void _xfmpc_extended_interface_cb_context_menu_deactivate_gtk_menu_shell_deactivate (GtkMenu* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_context_menu_deactivate (self);
+}
- image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (widget), image);
- /* Context menu */
- priv->context_button = GTK_WIDGET (xfce_arrow_button_new (GTK_ARROW_DOWN));
- gtk_widget_set_tooltip_text (priv->context_button, _("Context Menu"));
- gtk_box_pack_start (GTK_BOX (hbox), priv->context_button, FALSE, FALSE, 0);
- g_signal_connect_swapped (priv->context_button, "pressed",
- G_CALLBACK (popup_context_menu), extended_interface);
- g_signal_connect (priv->context_button, "clicked",
- G_CALLBACK (cb_context_menu_clicked), extended_interface);
+static void _xfmpc_extended_interface_cb_repeat_switch_gtk_menu_item_activate (GtkCheckMenuItem* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_repeat_switch (self);
+}
- /* Combo box */
- priv->list_store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_POINTER);
- priv->combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->list_store));
- gtk_box_pack_start (GTK_BOX (hbox), priv->combobox, TRUE, TRUE, 0);
- g_signal_connect (priv->combobox, "changed",
- G_CALLBACK (cb_interface_changed), extended_interface);
+static void _xfmpc_extended_interface_cb_random_switch_gtk_menu_item_activate (GtkCheckMenuItem* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_random_switch (self);
+}
- GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->combobox), cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->combobox),
- cell, "text", COLUMN_STRING,
- NULL);
- /* Notebook */
- priv->notebook = gtk_notebook_new ();
- gtk_box_pack_start (GTK_BOX (extended_interface), priv->notebook, TRUE, TRUE, 0);
+static void _xfmpc_extended_interface_cb_preferences_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_preferences (self);
+}
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
- /* Extended interface widgets ; added in the same order as the
- * XfmpcExtendedInterfaceWidget enum */
- GtkWidget *playlist = xfmpc_playlist_new ();
- xfmpc_extended_interface_append_child (extended_interface, playlist, _("Current Playlist"));
+static void _xfmpc_extended_interface_cb_about_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_about (self);
+}
- GtkWidget *dbbrowser = xfmpc_dbbrowser_new ();
- xfmpc_extended_interface_append_child (extended_interface, dbbrowser, _("Browse database"));
- g_object_set_data (G_OBJECT (playlist), "XfmpcDbbrowser", dbbrowser);
- g_object_set_data (G_OBJECT (playlist), "XfmpcExtendedInterface", extended_interface);
+static void xfmpc_extended_interface_context_menu_new (XfmpcExtendedInterface* self, GtkWidget* attach_widget) {
+ GtkMenu* _tmp0;
+ GtkCheckMenuItem* mi;
+ GtkCheckMenuItem* _tmp1;
+ GtkSeparatorMenuItem* separator;
+ GtkImageMenuItem* imi;
+ GtkImageMenuItem* _tmp2;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (attach_widget != NULL);
+ _tmp0 = NULL;
+ self->priv->context_menu = (_tmp0 = g_object_ref_sink ((GtkMenu*) gtk_menu_new ()), (self->priv->context_menu == NULL) ? NULL : (self->priv->context_menu = (g_object_unref (self->priv->context_menu), NULL)), _tmp0);
+ gtk_menu_set_screen (self->priv->context_menu, gtk_widget_get_screen (attach_widget));
+ gtk_menu_attach_to_widget (self->priv->context_menu, attach_widget, (GtkMenuDetachFunc) xfmpc_extended_interface_menu_detach);
+ g_signal_connect_object ((GtkMenuShell*) self->priv->context_menu, "deactivate", (GCallback) _xfmpc_extended_interface_cb_context_menu_deactivate_gtk_menu_shell_deactivate, self, 0);
+ mi = g_object_ref_sink ((GtkCheckMenuItem*) gtk_check_menu_item_new_with_label (_ ("Repeat")));
+ gtk_check_menu_item_set_active (mi, xfmpc_mpdclient_get_repeat (self->priv->mpdclient));
+ g_signal_connect_object ((GtkMenuItem*) mi, "activate", (GCallback) _xfmpc_extended_interface_cb_repeat_switch_gtk_menu_item_activate, self, 0);
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->context_menu, (GtkWidget*) ((GtkMenuItem*) mi));
+ _tmp1 = NULL;
+ mi = (_tmp1 = g_object_ref_sink ((GtkCheckMenuItem*) gtk_check_menu_item_new_with_label (_ ("Random"))), (mi == NULL) ? NULL : (mi = (g_object_unref (mi), NULL)), _tmp1);
+ gtk_check_menu_item_set_active (mi, xfmpc_mpdclient_get_random (self->priv->mpdclient));
+ g_signal_connect_object ((GtkMenuItem*) mi, "activate", (GCallback) _xfmpc_extended_interface_cb_random_switch_gtk_menu_item_activate, self, 0);
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->context_menu, (GtkWidget*) ((GtkMenuItem*) mi));
+ separator = g_object_ref_sink ((GtkSeparatorMenuItem*) gtk_separator_menu_item_new ());
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->context_menu, (GtkWidget*) ((GtkMenuItem*) separator));
+ imi = g_object_ref_sink ((GtkImageMenuItem*) gtk_image_menu_item_new_from_stock (GTK_STOCK_PREFERENCES, NULL));
+ g_signal_connect_object ((GtkMenuItem*) imi, "activate", (GCallback) _xfmpc_extended_interface_cb_preferences_gtk_menu_item_activate, self, 0);
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->context_menu, (GtkWidget*) ((GtkMenuItem*) imi));
+ _tmp2 = NULL;
+ imi = (_tmp2 = g_object_ref_sink ((GtkImageMenuItem*) gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL)), (imi == NULL) ? NULL : (imi = (g_object_unref (imi), NULL)), _tmp2);
+ g_signal_connect_object ((GtkMenuItem*) imi, "activate", (GCallback) _xfmpc_extended_interface_cb_about_gtk_menu_item_activate, self, 0);
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->context_menu, (GtkWidget*) ((GtkMenuItem*) imi));
+ gtk_widget_show_all ((GtkWidget*) self->priv->context_menu);
+ (mi == NULL) ? NULL : (mi = (g_object_unref (mi), NULL));
+ (separator == NULL) ? NULL : (separator = (g_object_unref (separator), NULL));
+ (imi == NULL) ? NULL : (imi = (g_object_unref (imi), NULL));
}
-static void
-xfmpc_extended_interface_dispose (GObject *object)
-{
- XfmpcExtendedInterfacePrivate *priv = XFMPC_EXTENDED_INTERFACE (object)->priv;
- if (GTK_IS_MENU (priv->context_menu))
- {
- gtk_menu_detach (GTK_MENU (priv->context_menu));
- priv->context_menu = NULL;
- }
+static void xfmpc_extended_interface_menu_detach (XfmpcExtendedInterface* self, GtkWidget* attach_widget, GtkMenu* menu) {
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (attach_widget != NULL);
+ g_return_if_fail (menu != NULL);
+}
- if (GTK_IS_WIDGET (priv->context_button))
- {
- gtk_widget_destroy (priv->context_button);
- priv->context_button = NULL;
- }
- (*G_OBJECT_CLASS (parent_class)->dispose) (object);
+/*
+ * Signal callbacks
+ */
+static void xfmpc_extended_interface_cb_playlist_clear (XfmpcExtendedInterface* self) {
+ g_return_if_fail (self != NULL);
+ xfmpc_mpdclient_playlist_clear (self->priv->mpdclient);
}
-static void
-xfmpc_extended_interface_finalize (GObject *object)
-{
- XfmpcExtendedInterface *extended_interface = XFMPC_EXTENDED_INTERFACE (object);
- g_object_unref (G_OBJECT (extended_interface->mpdclient));
- (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+
+static void xfmpc_extended_interface_cb_database_refresh (XfmpcExtendedInterface* self) {
+ g_return_if_fail (self != NULL);
+ xfmpc_mpdclient_database_refresh (self->priv->mpdclient);
}
+static void xfmpc_extended_interface_cb_interface_changed (XfmpcExtendedInterface* self) {
+ void* child;
+ GtkTreeIter iter = {0};
+ gint i;
+ g_return_if_fail (self != NULL);
+ child = NULL;
+ i = 0;
+ if (gtk_combo_box_get_active_iter (self->priv->combobox, &iter) == FALSE) {
+ return;
+ }
+ gtk_tree_model_get (GTK_TREE_MODEL (self->priv->list_store), &iter, XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_POINTER, &child, -1, -1);
+ i = gtk_notebook_page_num (self->priv->notebook, GTK_WIDGET (child));
+ gtk_notebook_set_current_page (self->priv->notebook, i);
+}
-GtkWidget*
-xfmpc_extended_interface_new ()
-{
- return g_object_new (XFMPC_TYPE_EXTENDED_INTERFACE, NULL);
+
+static void xfmpc_extended_interface_cb_context_menu_clicked (XfmpcExtendedInterface* self) {
+ g_return_if_fail (self != NULL);
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (xfmpc_extended_interface_context_button))) {
+ return;
+ }
+ xfmpc_extended_interface_popup_context_menu (self);
}
-void
-xfmpc_extended_interface_append_child (XfmpcExtendedInterface *extended_interface,
- GtkWidget *child,
- const gchar *title)
-{
- XfmpcExtendedInterfacePrivate *priv = XFMPC_EXTENDED_INTERFACE (extended_interface)->priv;
- GtkTreeIter iter;
- gtk_list_store_append (priv->list_store, &iter);
- gtk_list_store_set (priv->list_store, &iter,
- COLUMN_STRING, title,
- COLUMN_POINTER, child,
- -1);
+static void xfmpc_extended_interface_cb_context_menu_deactivate (XfmpcExtendedInterface* self) {
+ g_return_if_fail (self != NULL);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (xfmpc_extended_interface_context_button), FALSE);
+}
- if (gtk_combo_box_get_active(GTK_COMBO_BOX (priv->combobox)) == -1)
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox), 0);
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), child, NULL);
- gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (priv->notebook), child, TRUE, TRUE, GTK_PACK_START);
+static void xfmpc_extended_interface_cb_repeat_switch (XfmpcExtendedInterface* self) {
+ g_return_if_fail (self != NULL);
+ xfmpc_mpdclient_set_repeat (self->priv->mpdclient, !xfmpc_mpdclient_get_repeat (self->priv->mpdclient));
}
-void
-xfmpc_extended_interface_set_active (XfmpcExtendedInterface *extended_interface,
- XfmpcExtendedInterfaceWidget active_widget)
-{
- XfmpcExtendedInterfacePrivate *priv = extended_interface->priv;
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox), active_widget);
+
+static void xfmpc_extended_interface_cb_random_switch (XfmpcExtendedInterface* self) {
+ g_return_if_fail (self != NULL);
+ xfmpc_mpdclient_set_random (self->priv->mpdclient, !xfmpc_mpdclient_get_random (self->priv->mpdclient));
}
-static void
-xfmpc_extended_interface_context_menu_new (XfmpcExtendedInterface *extended_interface,
- GtkWidget *attach_widget)
-{
- XfmpcExtendedInterfacePrivate *priv = XFMPC_EXTENDED_INTERFACE (extended_interface)->priv;
- GtkWidget *menu = priv->context_menu = gtk_menu_new ();
- gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (GTK_WIDGET (attach_widget)));
- gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (attach_widget), NULL);
- g_signal_connect (menu, "deactivate",
- G_CALLBACK (cb_context_menu_deactivate), attach_widget);
+static void xfmpc_extended_interface_cb_preferences (XfmpcExtendedInterface* self) {
+ XfmpcPreferencesDialog* dialog;
+ g_return_if_fail (self != NULL);
+ dialog = g_object_ref_sink (xfmpc_preferences_dialog_new ());
+ gtk_widget_show ((GtkWidget*) dialog);
+ (dialog == NULL) ? NULL : (dialog = (g_object_unref (dialog), NULL));
+}
- GtkWidget *mi = gtk_check_menu_item_new_with_label (_("Repeat"));
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
- xfmpc_mpdclient_get_repeat (extended_interface->mpdclient));
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (cb_repeat_switch), extended_interface);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
- mi = gtk_check_menu_item_new_with_label (_("Random"));
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
- xfmpc_mpdclient_get_random (extended_interface->mpdclient));
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (cb_random_switch), extended_interface);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+static void xfmpc_extended_interface_cb_about (XfmpcExtendedInterface* self) {
+ char** _tmp1;
+ gint artists_size;
+ gint artists_length1;
+ char** _tmp0;
+ char** artists;
+ char** _tmp3;
+ gint authors_size;
+ gint authors_length1;
+ char** _tmp2;
+ char** authors;
+ char** _tmp5;
+ gint documenters_size;
+ gint documenters_length1;
+ char** _tmp4;
+ char** documenters;
+ g_return_if_fail (self != NULL);
+ _tmp1 = NULL;
+ _tmp0 = NULL;
+ artists = (_tmp1 = (_tmp0 = g_new0 (char*, 1 + 1), _tmp0[0] = NULL, _tmp0), artists_length1 = 1, artists_size = artists_length1, _tmp1);
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ authors = (_tmp3 = (_tmp2 = g_new0 (char*, 2 + 1), _tmp2[0] = g_strdup ("Mike Massonnet <mmassonnet at xfce.org>"), _tmp2[1] = g_strdup ("Vincent Legout <vincent at xfce.org>"), _tmp2), authors_length1 = 2, authors_size = authors_length1, _tmp3);
+ _tmp5 = NULL;
+ _tmp4 = NULL;
+ documenters = (_tmp5 = (_tmp4 = g_new0 (char*, 1 + 1), _tmp4[0] = NULL, _tmp4), documenters_length1 = 1, documenters_size = documenters_length1, _tmp5);
+ gtk_show_about_dialog (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))), "artists", artists, "authors", authors, "comments", _ ("MPD client written in GTK+ for Xfce"), "copyright", "Copyright \302\251 2008-2009 Mike Massonnet, Vincent Legout", "documenters", documenters, "license", xfce_get_license_text (XFCE_LICENSE_TEXT_GPL), "translator-credits", _ ("translator-credits"), "version", PACKAGE_VERSION, "website", "http://goodies.xfce.org/projects/applications/xfmpc", NULL, NULL);
+ artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
+ authors = (_vala_array_free (authors, authors_length1, (GDestroyNotify) g_free), NULL);
+ documenters = (_vala_array_free (documenters, documenters_length1, (GDestroyNotify) g_free), NULL);
+}
- mi = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
- mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_PREFERENCES, NULL);
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (cb_preferences), extended_interface);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+XfmpcExtendedInterface* xfmpc_extended_interface_construct (GType object_type) {
+ XfmpcExtendedInterface * self;
+ self = g_object_newv (object_type, 0, NULL);
+ return self;
+}
- mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (cb_about), extended_interface);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-
- gtk_widget_show_all (menu);
+XfmpcExtendedInterface* xfmpc_extended_interface_new (void) {
+ return xfmpc_extended_interface_construct (XFMPC_TYPE_EXTENDED_INTERFACE);
}
+static void _xfmpc_extended_interface_cb_playlist_clear_gtk_button_clicked (GtkButton* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_playlist_clear (self);
+}
-static void
-cb_interface_changed (GtkComboBox *widget,
- XfmpcExtendedInterface *extended_interface)
-{
- XfmpcExtendedInterfacePrivate *priv = XFMPC_EXTENDED_INTERFACE (extended_interface)->priv;
- GtkWidget *child;
- GtkTreeIter iter;
- gint i;
- if (gtk_combo_box_get_active_iter (widget, &iter) == FALSE)
- return;
+static void _xfmpc_extended_interface_cb_database_refresh_gtk_button_clicked (GtkButton* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_database_refresh (self);
+}
- gtk_tree_model_get (GTK_TREE_MODEL (priv->list_store), &iter,
- COLUMN_POINTER, &child,
- -1);
- g_return_if_fail (G_LIKELY (GTK_IS_WIDGET (child)));
- i = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), child);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i);
+static void _xfmpc_extended_interface_popup_context_menu_gtk_button_pressed (GtkButton* _sender, gpointer self) {
+ xfmpc_extended_interface_popup_context_menu (self);
}
-static void
-cb_repeat_switch (XfmpcExtendedInterface *extended_interface)
-{
- xfmpc_mpdclient_set_repeat (extended_interface->mpdclient,
- !xfmpc_mpdclient_get_repeat (extended_interface->mpdclient));
+
+static void _xfmpc_extended_interface_cb_context_menu_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_context_menu_clicked (self);
}
-static void
-cb_random_switch (XfmpcExtendedInterface *extended_interface)
-{
- xfmpc_mpdclient_set_random (extended_interface->mpdclient,
- !xfmpc_mpdclient_get_random (extended_interface->mpdclient));
+
+static void _xfmpc_extended_interface_cb_interface_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
+ xfmpc_extended_interface_cb_interface_changed (self);
}
-static void
-cb_context_menu_clicked (GtkToggleButton *button,
- XfmpcExtendedInterface *extended_interface)
-{
- if (!gtk_toggle_button_get_active (button))
- return;
- popup_context_menu (extended_interface);
+static GObject * xfmpc_extended_interface_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ XfmpcExtendedInterfaceClass * klass;
+ GObjectClass * parent_class;
+ XfmpcExtendedInterface * self;
+ klass = XFMPC_EXTENDED_INTERFACE_CLASS (g_type_class_peek (XFMPC_TYPE_EXTENDED_INTERFACE));
+ parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = XFMPC_EXTENDED_INTERFACE (obj);
+ {
+ GtkHBox* hbox;
+ GtkButton* button;
+ GtkImage* image;
+ GtkButton* _tmp0;
+ GtkImage* _tmp1;
+ XfceArrowButton* _tmp2;
+ GtkListStore* _tmp3;
+ GtkComboBox* _tmp4;
+ GtkCellRendererText* cell;
+ GtkNotebook* _tmp5;
+ GtkWidget* playlist;
+ GtkWidget* dbbrowser;
+ xfce_textdomain (self->priv->gettext_package, self->priv->localedir, "UTF-8");
+ self->priv->mpdclient = xfmpc_mpdclient_get ();
+ self->priv->preferences = xfmpc_preferences_get ();
+ hbox = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 2));
+ gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) hbox, FALSE, FALSE, (guint) 2);
+ button = g_object_ref_sink ((GtkButton*) gtk_button_new ());
+ gtk_widget_set_tooltip_text ((GtkWidget*) button, _ ("Clear Playlist"));
+ g_signal_connect_object (button, "clicked", (GCallback) _xfmpc_extended_interface_cb_playlist_clear_gtk_button_clicked, self, 0);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) button, FALSE, FALSE, (guint) 0);
+ image = g_object_ref_sink ((GtkImage*) gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU));
+ gtk_button_set_image (button, (GtkWidget*) image);
+ _tmp0 = NULL;
+ button = (_tmp0 = g_object_ref_sink ((GtkButton*) gtk_button_new ()), (button == NULL) ? NULL : (button = (g_object_unref (button), NULL)), _tmp0);
+ gtk_widget_set_tooltip_text ((GtkWidget*) button, _ ("Refresh Database"));
+ g_signal_connect_object (button, "clicked", (GCallback) _xfmpc_extended_interface_cb_database_refresh_gtk_button_clicked, self, 0);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) button, FALSE, FALSE, (guint) 0);
+ _tmp1 = NULL;
+ image = (_tmp1 = g_object_ref_sink ((GtkImage*) gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU)), (image == NULL) ? NULL : (image = (g_object_unref (image), NULL)), _tmp1);
+ gtk_button_set_image (button, (GtkWidget*) image);
+ _tmp2 = NULL;
+ xfmpc_extended_interface_context_button = (_tmp2 = (XfceArrowButton*) xfce_arrow_button_new (GTK_ARROW_DOWN), (xfmpc_extended_interface_context_button == NULL) ? NULL : (xfmpc_extended_interface_context_button = ( (xfmpc_extended_interface_context_button), NULL)), _tmp2);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (xfmpc_extended_interface_context_button), _ ("Context Menu"));
+ g_signal_connect_object (GTK_BUTTON (xfmpc_extended_interface_context_button), "pressed", (GCallback) _xfmpc_extended_interface_popup_context_menu_gtk_button_pressed, self, 0);
+ g_signal_connect_object (GTK_BUTTON (xfmpc_extended_interface_context_button), "clicked", (GCallback) _xfmpc_extended_interface_cb_context_menu_clicked_gtk_button_clicked, self, 0);
+ gtk_box_pack_start ((GtkBox*) hbox, GTK_WIDGET (xfmpc_extended_interface_context_button), FALSE, FALSE, (guint) 0);
+ _tmp3 = NULL;
+ self->priv->list_store = (_tmp3 = gtk_list_store_new ((gint) XFMPC_EXTENDED_INTERFACE_COLUMNS_N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER, NULL), (self->priv->list_store == NULL) ? NULL : (self->priv->list_store = (g_object_unref (self->priv->list_store), NULL)), _tmp3);
+ _tmp4 = NULL;
+ self->priv->combobox = (_tmp4 = g_object_ref_sink ((GtkComboBox*) gtk_combo_box_new_with_model ((GtkTreeModel*) self->priv->list_store)), (self->priv->combobox == NULL) ? NULL : (self->priv->combobox = (g_object_unref (self->priv->combobox), NULL)), _tmp4);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) self->priv->combobox, TRUE, TRUE, (guint) 0);
+ g_signal_connect_object (self->priv->combobox, "changed", (GCallback) _xfmpc_extended_interface_cb_interface_changed_gtk_combo_box_changed, self, 0);
+ cell = g_object_ref_sink ((GtkCellRendererText*) gtk_cell_renderer_text_new ());
+ gtk_cell_layout_pack_start ((GtkCellLayout*) self->priv->combobox, (GtkCellRenderer*) cell, TRUE);
+ gtk_cell_layout_set_attributes ((GtkCellLayout*) self->priv->combobox, (GtkCellRenderer*) cell, "text", XFMPC_EXTENDED_INTERFACE_COLUMNS_COLUMN_STRING, NULL, NULL);
+ _tmp5 = NULL;
+ self->priv->notebook = (_tmp5 = g_object_ref_sink ((GtkNotebook*) gtk_notebook_new ()), (self->priv->notebook == NULL) ? NULL : (self->priv->notebook = (g_object_unref (self->priv->notebook), NULL)), _tmp5);
+ gtk_notebook_set_show_tabs (self->priv->notebook, FALSE);
+ gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) self->priv->notebook, TRUE, TRUE, (guint) 0);
+ playlist = GTK_WIDGET (g_object_ref_sink (xfmpc_playlist_new ()));
+ xfmpc_extended_interface_append_child (self, playlist, _ ("Current Playlist"));
+ dbbrowser = GTK_WIDGET (g_object_ref_sink (xfmpc_dbbrowser_new ()));
+ xfmpc_extended_interface_append_child (self, dbbrowser, _ ("Browse database"));
+ g_object_set_data ((GObject*) playlist, "XfmpcDbbrowser", dbbrowser);
+ g_object_set_data ((GObject*) playlist, "XfmpcExtendedInterface", self);
+ (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL));
+ (button == NULL) ? NULL : (button = (g_object_unref (button), NULL));
+ (image == NULL) ? NULL : (image = (g_object_unref (image), NULL));
+ (cell == NULL) ? NULL : (cell = (g_object_unref (cell), NULL));
+ (playlist == NULL) ? NULL : (playlist = (g_object_unref (playlist), NULL));
+ (dbbrowser == NULL) ? NULL : (dbbrowser = (g_object_unref (dbbrowser), NULL));
+ }
+ return obj;
}
-static void
-cb_preferences (XfmpcExtendedInterface *extended_interface)
-{
- GtkWidget *dialog = xfmpc_preferences_dialog_new (NULL);
- gtk_widget_show (dialog);
+
+static void xfmpc_extended_interface_class_init (XfmpcExtendedInterfaceClass * klass) {
+ xfmpc_extended_interface_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (XfmpcExtendedInterfacePrivate));
+ G_OBJECT_CLASS (klass)->constructor = xfmpc_extended_interface_constructor;
+ G_OBJECT_CLASS (klass)->finalize = xfmpc_extended_interface_finalize;
}
-static void
-cb_about (XfmpcExtendedInterface *extended_interface)
-{
- static const gchar *artists[] = { NULL };
- static const gchar *authors[] = {
- "Mike Massonnet <mmassonnet at xfce.org>",
- "Vincent Legout <vincent at xfce.org>",
- NULL,
- };
- static const gchar *documenters[] = { NULL };
- gtk_show_about_dialog (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (extended_interface))),
- "artists", artists,
- "authors", authors,
- "comments", _("MPD client written in GTK+ for Xfce"),
- "copyright", "Copyright \302\251 2008-2009 Mike Massonnet, Vincent Legout",
- "documenters", documenters,
- "license", XFCE_LICENSE_GPL,
- "translator-credits", _("translator-credits"),
- "version", PACKAGE_VERSION,
- "website", "http://goodies.xfce.org/projects/applications/xfmpc",
- NULL);
+static void xfmpc_extended_interface_instance_init (XfmpcExtendedInterface * self) {
+ self->priv = XFMPC_EXTENDED_INTERFACE_GET_PRIVATE (self);
+ self->priv->gettext_package = g_strdup (GETTEXT_PACKAGE);
+ self->priv->localedir = g_strdup (PACKAGE_LOCALE_DIR);
}
-static void
-cb_context_menu_deactivate (GtkMenuShell *menu,
- GtkWidget *attach_widget)
-{
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (attach_widget), FALSE);
+
+static void xfmpc_extended_interface_finalize (GObject* obj) {
+ XfmpcExtendedInterface * self;
+ self = XFMPC_EXTENDED_INTERFACE (obj);
+ self->priv->gettext_package = (g_free (self->priv->gettext_package), NULL);
+ self->priv->localedir = (g_free (self->priv->localedir), NULL);
+ (self->priv->list_store == NULL) ? NULL : (self->priv->list_store = (g_object_unref (self->priv->list_store), NULL));
+ (self->priv->combobox == NULL) ? NULL : (self->priv->combobox = (g_object_unref (self->priv->combobox), NULL));
+ (self->priv->notebook == NULL) ? NULL : (self->priv->notebook = (g_object_unref (self->priv->notebook), NULL));
+ (self->priv->context_menu == NULL) ? NULL : (self->priv->context_menu = (g_object_unref (self->priv->context_menu), NULL));
+ G_OBJECT_CLASS (xfmpc_extended_interface_parent_class)->finalize (obj);
}
-static void
-popup_context_menu (XfmpcExtendedInterface *extended_interface)
-{
- XfmpcExtendedInterfacePrivate *priv = XFMPC_EXTENDED_INTERFACE (extended_interface)->priv;
- if (!GTK_IS_MENU (priv->context_menu))
- xfmpc_extended_interface_context_menu_new (extended_interface, priv->context_button);
-
- gtk_menu_popup (GTK_MENU (priv->context_menu),
- NULL,
- NULL,
- (GtkMenuPositionFunc) position_context_menu,
- GTK_WIDGET (priv->context_button),
- 0,
- gtk_get_current_event_time ());
+GType xfmpc_extended_interface_get_type (void) {
+ static GType xfmpc_extended_interface_type_id = 0;
+ if (xfmpc_extended_interface_type_id == 0) {
+ static const GTypeInfo g_define_type_info = { sizeof (XfmpcExtendedInterfaceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xfmpc_extended_interface_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XfmpcExtendedInterface), 0, (GInstanceInitFunc) xfmpc_extended_interface_instance_init, NULL };
+ xfmpc_extended_interface_type_id = g_type_register_static (GTK_TYPE_VBOX, "XfmpcExtendedInterface", &g_define_type_info, 0);
+ }
+ return xfmpc_extended_interface_type_id;
}
-static void
-position_context_menu (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- GtkWidget *widget)
-{
- GtkRequisition menu_req;
- gint root_x;
- gint root_y;
- gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
- gdk_window_get_origin (widget->window, &root_x, &root_y);
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+ if ((array != NULL) && (destroy_func != NULL)) {
+ int i;
+ for (i = 0; i < array_length; i = i + 1) {
+ if (((gpointer*) array)[i] != NULL) {
+ destroy_func (((gpointer*) array)[i]);
+ }
+ }
+ }
+ g_free (array);
+}
- *x = root_x + widget->allocation.x;
- /* TODO find the good way to add spacing to *y */
- *y = root_y + widget->allocation.y;
- if (*y > gdk_screen_height () - menu_req.height)
- *y = gdk_screen_height () - menu_req.height;
- else if (*y < 0)
- *y = 0;
- *push_in = FALSE;
-}
Added: xfmpc/trunk/src/extended-interface.vala
===================================================================
--- xfmpc/trunk/src/extended-interface.vala (rev 0)
+++ xfmpc/trunk/src/extended-interface.vala 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,258 @@
+/*
+ * 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 ExtendedInterface : VBox {
+
+ private unowned Xfmpc.Mpdclient mpdclient;
+ private unowned Xfmpc.Preferences preferences;
+
+ private string gettext_package = Config.GETTEXT_PACKAGE;
+ private string localedir = Config.PACKAGE_LOCALE_DIR;
+
+ private static Xfce.ArrowButton context_button;
+ private ListStore list_store;
+ private ComboBox combobox;
+ private Notebook notebook;
+ private Menu context_menu;
+
+ private enum Columns {
+ COLUMN_STRING,
+ COLUMN_POINTER,
+ N_COLUMNS,
+ }
+
+ public enum ExtendedInterfaceWidget {
+ PLAYLIST,
+ DBBROWSER,
+ }
+
+ construct {
+ Xfce.textdomain (gettext_package, localedir, "UTF-8");
+
+ mpdclient = Xfmpc.Mpdclient.get ();
+ preferences = Xfmpc.Preferences.get ();
+
+ var hbox = new HBox (false, 2);
+ pack_start (hbox, false, false, 2);
+
+ var button = new Button ();
+ button.set_tooltip_text (_("Clear Playlist"));
+ button.clicked += cb_playlist_clear;
+ hbox.pack_start (button, false, false, 0);
+
+ var image = new Image.from_stock (STOCK_NEW, IconSize.MENU);
+ button.set_image (image);
+
+ button = new Button ();
+ button.set_tooltip_text (_("Refresh Database"));
+ button.clicked += cb_database_refresh;
+ hbox.pack_start (button, false, false, 0);
+
+ image = new Image.from_stock (STOCK_REFRESH, IconSize.MENU);
+ button.set_image (image);
+
+ context_button = new Xfce.ArrowButton (ArrowType.DOWN);
+ ((Widget) context_button).set_tooltip_text (_("Context Menu"));
+ ((Button) context_button).pressed += popup_context_menu;
+ ((Button) context_button).clicked += cb_context_menu_clicked;
+ hbox.pack_start (((Widget) context_button), false, false, 0);
+
+ list_store = new ListStore (Columns.N_COLUMNS,
+ typeof (string),
+ typeof (void *));
+
+ combobox = new ComboBox.with_model (list_store);
+ hbox.pack_start (combobox, true, true, 0);
+ combobox.changed += cb_interface_changed;
+
+ var cell = new CellRendererText ();
+ combobox.pack_start (cell, true);
+ combobox.set_attributes (cell, "text", Columns.COLUMN_STRING, null);
+
+ notebook = new Notebook ();
+ notebook.set_show_tabs (false);
+ pack_start (notebook, true, true, 0);
+
+ Widget playlist = (Widget) new Playlist ();
+ append_child (playlist, _("Current Playlist"));
+
+ Widget dbbrowser = (Widget) new Dbbrowser ();
+ append_child (dbbrowser, _("Browse database"));
+
+ playlist.set_data ("XfmpcDbbrowser", dbbrowser);
+ playlist.set_data ("XfmpcExtendedInterface", this);
+ }
+
+ public void set_active (ExtendedInterfaceWidget active_widget) {
+ combobox.set_active (active_widget);
+ }
+
+ private void append_child (Widget child, string title) {
+ TreeIter iter;
+
+ list_store.append (out iter);
+ list_store.set (iter,
+ Columns.COLUMN_STRING, title,
+ Columns.COLUMN_POINTER, child,
+ -1);
+
+ if (combobox.get_active () == -1)
+ combobox.set_active (0);
+
+ notebook.append_page (child, null);
+ notebook.set_tab_label_packing (child, true, true, PackType.START);
+ }
+
+ private void popup_context_menu () {
+ if (context_menu == null)
+ context_menu_new ((Widget) context_button);
+
+ context_menu.popup (null, null,
+ (MenuPositionFunc) position_context_menu,
+ 0, get_current_event_time ());
+ }
+
+ private static void position_context_menu (Menu menu, int x, int y, bool push_in) {
+ Requisition menu_req;
+ int root_x;
+ int root_y;
+
+ menu.size_request (out menu_req);
+ (((Widget) context_button).window).get_origin (out root_x, out root_y);
+
+ x = root_x + (((Widget) context_button).allocation).x;
+ y = root_y + (((Widget) context_button).allocation).y;
+
+ if (y > Gdk.Screen.height () - menu_req.height)
+ y = Gdk.Screen.height () - menu_req.height;
+ else if (y < 0)
+ y = 0;
+
+ push_in = false;
+ }
+
+ private void context_menu_new (Widget attach_widget) {
+ context_menu = new Menu ();
+ context_menu.set_screen (attach_widget.get_screen ());
+ context_menu.attach_to_widget (attach_widget, (MenuDetachFunc) menu_detach);
+ context_menu.deactivate += cb_context_menu_deactivate;
+
+ var mi = new CheckMenuItem.with_label (_("Repeat"));
+ mi.set_active (mpdclient.get_repeat ());
+ mi.activate += cb_repeat_switch;
+ context_menu.append (mi);
+
+ mi = new CheckMenuItem.with_label (_("Random"));
+ mi.set_active (mpdclient.get_random ());
+ mi.activate += cb_random_switch;
+ context_menu.append (mi);
+
+ var separator = new SeparatorMenuItem ();
+ context_menu.append (separator);
+
+ var imi = new ImageMenuItem.from_stock (STOCK_PREFERENCES, null);
+ imi.activate += cb_preferences;
+ context_menu.append (imi);
+
+ imi = new ImageMenuItem.from_stock (STOCK_ABOUT, null);
+ imi.activate += cb_about;
+ context_menu.append (imi);
+
+ context_menu.show_all ();
+ }
+
+ private void menu_detach (Widget attach_widget, Menu menu) {
+ }
+
+ /*
+ * Signal callbacks
+ */
+
+ private void cb_playlist_clear () {
+ mpdclient.playlist_clear ();
+ }
+
+ private void cb_database_refresh () {
+ mpdclient.database_refresh ();
+ }
+
+ private void cb_interface_changed () {
+ void *child = null;
+ TreeIter iter;
+ int i = 0;
+
+ if (combobox.get_active_iter (out iter) == false)
+ return;
+
+ ((TreeModel) list_store).get (iter, Columns.COLUMN_POINTER, out child, -1);
+
+ i = notebook.page_num ((Widget) child);
+ notebook.set_current_page (i);
+ }
+
+ private void cb_context_menu_clicked () {
+ if (!((ToggleButton) context_button).get_active ())
+ return;
+
+ popup_context_menu ();
+ }
+
+ private void cb_context_menu_deactivate () {
+ ((ToggleButton) context_button).set_active (false);
+ }
+
+ private void cb_repeat_switch () {
+ mpdclient.set_repeat (!mpdclient.get_repeat ());
+ }
+
+ private void cb_random_switch () {
+ mpdclient.set_random (!mpdclient.get_random ());
+ }
+
+ private void cb_preferences () {
+ var dialog = new PreferencesDialog ();
+ dialog.show ();
+ }
+
+ private void cb_about () {
+ string[] artists = { null };
+ string[] authors = {"Mike Massonnet <mmassonnet at xfce.org>",
+ "Vincent Legout <vincent at xfce.org>"};
+ string[] documenters = { null };
+
+ show_about_dialog (((Window) ((Widget) this).get_toplevel ()),
+ "artists", artists,
+ "authors", authors,
+ "comments", _("MPD client written in GTK+ for Xfce"),
+ "copyright", "Copyright \302\251 2008-2009 Mike Massonnet, Vincent Legout",
+ "documenters", documenters,
+ "license", Xfce.get_license_text (Xfce.LicenseTextType.GPL),
+ "translator-credits", _("translator-credits"),
+ "version", Config.PACKAGE_VERSION,
+ "website", "http://goodies.xfce.org/projects/applications/xfmpc",
+ null);
+ }
+ }
+}
+
+/* vi:set ts=8 sw=8: */
Added: xfmpc/trunk/src/main-ui.h
===================================================================
--- xfmpc/trunk/src/main-ui.h (rev 0)
+++ xfmpc/trunk/src/main-ui.h 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,17 @@
+/* automatically generated from ./main-ui.xml */
+#ifdef __SUNPRO_C
+#pragma align 4 (main_ui)
+#endif
+#ifdef __GNUC__
+static const char main_ui[] __attribute__ ((__aligned__ (4))) =
+#else
+static const char main_ui[] =
+#endif
+{
+ "<ui><accelerator action=\"quit\" /><accelerator action=\"previous\" /><"
+ "accelerator action=\"pp\" /><accelerator action=\"stop\" /><accelerator"
+ " action=\"next\" /><accelerator action=\"volume\" /></ui>"
+};
+
+static const unsigned main_ui_length = 187u;
+
Modified: xfmpc/trunk/src/main-window.c
===================================================================
--- xfmpc/trunk/src/main-window.c 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/main-window.c 2009-04-23 11:11:39 UTC (rev 7280)
@@ -24,12 +24,11 @@
#include <gtk/gtk.h>
#include <libxfce4util/libxfce4util.h>
+#include "xfmpc.h"
#include "main-window.h"
#include "preferences.h"
#include "interface.h"
#include "main-ui.h"
-#include "extended-interface.h"
-#include "statusbar.h"
#define BORDER 4
@@ -207,7 +206,7 @@
gtk_box_pack_start (GTK_BOX (priv->vbox), separator, FALSE, FALSE, 0);
/* ExtendedInterface */
- GtkWidget *extended_interface = xfmpc_extended_interface_new ();
+ GtkWidget *extended_interface = GTK_WIDGET (xfmpc_extended_interface_new ());
gtk_box_pack_start (GTK_BOX (priv->vbox), extended_interface, TRUE, TRUE, 0);
/* Accelerators */
@@ -370,7 +369,7 @@
}
else if (active && priv->statusbar == NULL)
{
- priv->statusbar = xfmpc_statusbar_new ();
+ priv->statusbar = GTK_WIDGET (xfmpc_statusbar_new ());
gtk_widget_show (priv->statusbar);
gtk_box_pack_start (GTK_BOX (priv->vbox), priv->statusbar, FALSE, FALSE, 0);
}
Modified: xfmpc/trunk/src/playlist.c
===================================================================
--- xfmpc/trunk/src/playlist.c 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/playlist.c 2009-04-23 11:11:39 UTC (rev 7280)
@@ -1,5 +1,5 @@
/*
- * 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>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,698 +17,870 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifdef HAVE_CONFIG_H
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <mpdclient.h>
+#include <preferences.h>
+#include <stdlib.h>
+#include <string.h>
#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <gdk/gdk.h>
+#include <pango/pango.h>
#include <libxfce4util/libxfce4util.h>
+#include <glib/gi18n-lib.h>
-#include "playlist.h"
-#include "preferences.h"
-#include "mpdclient.h"
-#include "dbbrowser.h"
-#include "extended-interface.h"
-#include "song-dialog.h"
-#define BORDER 4
+#define XFMPC_TYPE_PLAYLIST (xfmpc_playlist_get_type ())
+#define XFMPC_PLAYLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PLAYLIST, XfmpcPlaylist))
+#define XFMPC_PLAYLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistClass))
+#define XFMPC_IS_PLAYLIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PLAYLIST))
+#define XFMPC_IS_PLAYLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PLAYLIST))
+#define XFMPC_PLAYLIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistClass))
-#define GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistPrivate))
+typedef struct _XfmpcPlaylist XfmpcPlaylist;
+typedef struct _XfmpcPlaylistClass XfmpcPlaylistClass;
+typedef struct _XfmpcPlaylistPrivate XfmpcPlaylistPrivate;
+#define XFMPC_PLAYLIST_TYPE_COLUMNS (xfmpc_playlist_columns_get_type ())
+#define XFMPC_TYPE_DBBROWSER (xfmpc_dbbrowser_get_type ())
+#define XFMPC_DBBROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowser))
+#define XFMPC_DBBROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserClass))
+#define XFMPC_IS_DBBROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_DBBROWSER))
+#define XFMPC_IS_DBBROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_DBBROWSER))
+#define XFMPC_DBBROWSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserClass))
-static void xfmpc_playlist_class_init (XfmpcPlaylistClass *klass);
-static void xfmpc_playlist_init (XfmpcPlaylist *playlist);
-static void xfmpc_playlist_dispose (GObject *object);
-static void xfmpc_playlist_finalize (GObject *object);
+typedef struct _XfmpcDbbrowser XfmpcDbbrowser;
+typedef struct _XfmpcDbbrowserClass XfmpcDbbrowserClass;
-static void cb_song_changed (XfmpcPlaylist *playlist);
-static void cb_playlist_changed (XfmpcPlaylist *playlist);
-static void cb_row_activated (XfmpcPlaylist *playlist,
- GtkTreePath *path,
- GtkTreeViewColumn *column);
-static gboolean cb_key_released (XfmpcPlaylist *playlist,
- GdkEventKey *event);
-static gboolean cb_button_released (XfmpcPlaylist *playlist,
- GdkEventButton *event);
-static gboolean cb_popup_menu (XfmpcPlaylist *playlist);
-static void popup_menu (XfmpcPlaylist *playlist);
+#define XFMPC_TYPE_EXTENDED_INTERFACE (xfmpc_extended_interface_get_type ())
+#define XFMPC_EXTENDED_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterface))
+#define XFMPC_EXTENDED_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfaceClass))
+#define XFMPC_IS_EXTENDED_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_EXTENDED_INTERFACE))
+#define XFMPC_IS_EXTENDED_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_EXTENDED_INTERFACE))
+#define XFMPC_EXTENDED_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfaceClass))
-static void cb_filter_entry_activated (XfmpcPlaylist *playlist);
-static gboolean cb_filter_entry_key_released (XfmpcPlaylist *playlist,
- GdkEventKey *event);
-static void cb_filter_entry_changed (XfmpcPlaylist *playlist);
-static gboolean visible_func_filter_tree (GtkTreeModel *filter,
- GtkTreeIter *iter,
- XfmpcPlaylist *playlist);
+typedef struct _XfmpcExtendedInterface XfmpcExtendedInterface;
+typedef struct _XfmpcExtendedInterfaceClass XfmpcExtendedInterfaceClass;
-void cb_browse_selection (XfmpcPlaylist *playlist);
-void cb_info_selection (XfmpcPlaylist *playlist);
+#define XFMPC_EXTENDED_INTERFACE_TYPE_EXTENDED_INTERFACE_WIDGET (xfmpc_extended_interface_extended_interface_widget_get_type ())
+#define XFMPC_TYPE_SONG_DIALOG (xfmpc_song_dialog_get_type ())
+#define XFMPC_SONG_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialog))
+#define XFMPC_SONG_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialogClass))
+#define XFMPC_IS_SONG_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_SONG_DIALOG))
+#define XFMPC_IS_SONG_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_SONG_DIALOG))
+#define XFMPC_SONG_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialogClass))
+typedef struct _XfmpcSongDialog XfmpcSongDialog;
+typedef struct _XfmpcSongDialogClass XfmpcSongDialogClass;
-/* List store identifiers */
-enum
-{
- COLUMN_ID,
- COLUMN_FILENAME,
- COLUMN_POSITION,
- COLUMN_SONG,
- COLUMN_LENGTH,
- COLUMN_WEIGHT,
- N_COLUMNS,
+struct _XfmpcPlaylist {
+ GtkVBox parent_instance;
+ XfmpcPlaylistPrivate * priv;
};
-
-
-struct _XfmpcPlaylistClass
-{
- GtkVBoxClass parent_class;
+struct _XfmpcPlaylistClass {
+ GtkVBoxClass parent_class;
};
-struct _XfmpcPlaylist
-{
- GtkVBox parent;
- XfmpcPreferences *preferences;
- XfmpcMpdclient *mpdclient;
- /*<private>*/
- XfmpcPlaylistPrivate *priv;
+struct _XfmpcPlaylistPrivate {
+ XfmpcMpdclient* mpdclient;
+ XfmpcPreferences* preferences;
+ char* gettext_package;
+ char* localedir;
+ GtkListStore* store;
+ GtkTreeModelFilter* filter;
+ GtkTreeView* treeview;
+ GtkMenu* menu;
+ GtkImageMenuItem* mi_browse;
+ GtkImageMenuItem* mi_information;
+ gint current;
+ gboolean autocenter;
};
-struct _XfmpcPlaylistPrivate
-{
- GtkWidget *treeview;
- GtkTreeModelFilter *filter;
- GtkListStore *store;
- GtkWidget *filter_entry;
- GtkWidget *menu;
- GtkWidget *mi_browse;
- GtkWidget *mi_information;
+typedef enum {
+ XFMPC_PLAYLIST_COLUMNS_COLUMN_ID,
+ XFMPC_PLAYLIST_COLUMNS_COLUMN_FILENAME,
+ XFMPC_PLAYLIST_COLUMNS_COLUMN_POSITION,
+ XFMPC_PLAYLIST_COLUMNS_COLUMN_SONG,
+ XFMPC_PLAYLIST_COLUMNS_COLUMN_LENGTH,
+ XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT,
+ XFMPC_PLAYLIST_COLUMNS_N_COLUMNS
+} XfmpcPlaylistColumns;
- gint current;
- gboolean autocenter;
-};
+typedef enum {
+ XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_PLAYLIST,
+ XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_DBBROWSER
+} XfmpcExtendedInterfaceExtendedInterfaceWidget;
-static GObjectClass *parent_class = NULL;
+GType xfmpc_playlist_get_type (void);
+#define XFMPC_PLAYLIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistPrivate))
+enum {
+ XFMPC_PLAYLIST_DUMMY_PROPERTY
+};
+static GType xfmpc_playlist_columns_get_type (void);
+static GtkEntry* xfmpc_playlist_filter_entry;
+static GtkEntry* xfmpc_playlist_filter_entry = NULL;
+static gboolean xfmpc_playlist_visible_func_filter_tree (GtkTreeModel* model, GtkTreeIter* iter);
+GType xfmpc_dbbrowser_get_type (void);
+GType xfmpc_extended_interface_get_type (void);
+static void _g_list_free_gtk_tree_path_free (GList* self);
+void xfmpc_dbbrowser_set_wdir (XfmpcDbbrowser* self, const char* dir);
+void xfmpc_dbbrowser_reload (XfmpcDbbrowser* self);
+GType xfmpc_extended_interface_extended_interface_widget_get_type (void);
+void xfmpc_extended_interface_set_active (XfmpcExtendedInterface* self, XfmpcExtendedInterfaceExtendedInterfaceWidget active_widget);
+static void xfmpc_playlist_cb_browse_selection (XfmpcPlaylist* self);
+XfmpcSongDialog* xfmpc_song_dialog_new (gint song_id);
+XfmpcSongDialog* xfmpc_song_dialog_construct (GType object_type, gint song_id);
+GType xfmpc_song_dialog_get_type (void);
+static void xfmpc_playlist_cb_info_selection (XfmpcPlaylist* self);
+static void xfmpc_playlist_menu_popup (XfmpcPlaylist* self);
+static gboolean xfmpc_playlist_cb_popup_menu (XfmpcPlaylist* self);
+void xfmpc_playlist_refresh_current_song (XfmpcPlaylist* self);
+void xfmpc_playlist_select_row (XfmpcPlaylist* self, gint i);
+static void xfmpc_playlist_cb_song_changed (XfmpcPlaylist* self);
+void xfmpc_playlist_append (XfmpcPlaylist* self, gint id, gint pos, const char* filename, const char* song, const char* length);
+static void xfmpc_playlist_cb_playlist_changed (XfmpcPlaylist* self);
+static void xfmpc_playlist_cb_row_activated (XfmpcPlaylist* self, const GtkTreePath* path, GtkTreeViewColumn* column);
+void xfmpc_playlist_delete_selection (XfmpcPlaylist* self);
+static gboolean xfmpc_playlist_cb_key_released (XfmpcPlaylist* self, const GdkEventKey* event);
+static gboolean xfmpc_playlist_cb_button_released (XfmpcPlaylist* self, const GdkEventButton* event);
+static void xfmpc_playlist_cb_filter_entry_activated (XfmpcPlaylist* self);
+static gboolean xfmpc_playlist_cb_filter_entry_key_released (XfmpcPlaylist* self, const GdkEventKey* event);
+static void xfmpc_playlist_cb_filter_entry_changed (XfmpcPlaylist* self);
+XfmpcPlaylist* xfmpc_playlist_new (void);
+XfmpcPlaylist* xfmpc_playlist_construct (GType object_type);
+XfmpcPlaylist* xfmpc_playlist_new (void);
+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);
+static void _xfmpc_playlist_cb_song_changed_xfmpc_mpdclient_song_changed (XfmpcMpdclient* _sender, gpointer self);
+static void _xfmpc_playlist_cb_playlist_changed_xfmpc_mpdclient_playlist_changed (XfmpcMpdclient* _sender, gpointer self);
+static void _xfmpc_playlist_cb_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, const GtkTreePath* path, GtkTreeViewColumn* column, gpointer self);
+static gboolean _xfmpc_playlist_cb_key_released_gtk_widget_key_release_event (GtkTreeView* _sender, const GdkEventKey* event, gpointer self);
+static gboolean _xfmpc_playlist_cb_button_released_gtk_widget_button_press_event (GtkTreeView* _sender, const GdkEventButton* event, gpointer self);
+static gboolean _xfmpc_playlist_cb_popup_menu_gtk_widget_popup_menu (GtkTreeView* _sender, gpointer self);
+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 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);
+static int _vala_strcmp0 (const char * str1, const char * str2);
-GType
-xfmpc_playlist_get_type ()
-{
- static GType xfmpc_playlist_type = G_TYPE_INVALID;
- if (G_UNLIKELY (xfmpc_playlist_type == G_TYPE_INVALID))
- {
- static const GTypeInfo xfmpc_playlist_info =
- {
- sizeof (XfmpcPlaylistClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) xfmpc_playlist_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (XfmpcPlaylist),
- 0,
- (GInstanceInitFunc) xfmpc_playlist_init,
- NULL
- };
- xfmpc_playlist_type = g_type_register_static (GTK_TYPE_VBOX, "XfmpcPlaylist", &xfmpc_playlist_info, 0);
- }
-
- return xfmpc_playlist_type;
+static GType xfmpc_playlist_columns_get_type (void) {
+ static GType xfmpc_playlist_columns_type_id = 0;
+ if (G_UNLIKELY (xfmpc_playlist_columns_type_id == 0)) {
+ static const GEnumValue values[] = {{XFMPC_PLAYLIST_COLUMNS_COLUMN_ID, "XFMPC_PLAYLIST_COLUMNS_COLUMN_ID", "column-id"}, {XFMPC_PLAYLIST_COLUMNS_COLUMN_FILENAME, "XFMPC_PLAYLIST_COLUMNS_COLUMN_FILENAME", "column-filename"}, {XFMPC_PLAYLIST_COLUMNS_COLUMN_POSITION, "XFMPC_PLAYLIST_COLUMNS_COLUMN_POSITION", "column-position"}, {XFMPC_PLAYLIST_COLUMNS_COLUMN_SONG, "XFMPC_PLAYLIST_COLUMNS_COLUMN_SONG", "column-song"}, {XFMPC_PLAYLIST_COLUMNS_COLUMN_LENGTH, "XFMPC_PLAYLIST_COLUMNS_COLUMN_LENGTH", "column-length"}, {XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT, "XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT", "column-weight"}, {XFMPC_PLAYLIST_COLUMNS_N_COLUMNS, "XFMPC_PLAYLIST_COLUMNS_N_COLUMNS", "n-columns"}, {0, NULL, NULL}};
+ xfmpc_playlist_columns_type_id = g_enum_register_static ("XfmpcPlaylistColumns", values);
+ }
+ return xfmpc_playlist_columns_type_id;
}
+static gboolean xfmpc_playlist_visible_func_filter_tree (GtkTreeModel* model, GtkTreeIter* iter) {
+ char* song;
+ char* search;
+ gboolean result;
+ char* _tmp2;
+ const char* _tmp1;
+ char* _tmp3;
+ gboolean _tmp5;
+ g_return_val_if_fail (model != NULL, FALSE);
+ song = g_strdup ("");
+ search = g_strdup ("");
+ result = TRUE;
+ gtk_tree_model_get (model, &(*iter), XFMPC_PLAYLIST_COLUMNS_COLUMN_SONG, &song, -1, -1);
+ if (_vala_strcmp0 (song, "") == 0) {
+ gboolean _tmp0;
+ return (_tmp0 = TRUE, song = (g_free (song), NULL), search = (g_free (search), NULL), _tmp0);
+ }
+ _tmp2 = NULL;
+ _tmp1 = NULL;
+ search = (_tmp2 = (_tmp1 = gtk_entry_get_text (xfmpc_playlist_filter_entry), (_tmp1 == NULL) ? NULL : g_strdup (_tmp1)), search = (g_free (search), NULL), _tmp2);
+ _tmp3 = NULL;
+ search = (_tmp3 = g_utf8_casefold (search, (glong) (-1)), search = (g_free (search), NULL), _tmp3);
+ if (_vala_strcmp0 (search, "") != 0) {
+ char* _tmp4;
+ _tmp4 = NULL;
+ song = (_tmp4 = g_utf8_casefold (song, (glong) (-1)), song = (g_free (song), NULL), _tmp4);
+ if (strstr (song, search) == NULL) {
+ result = FALSE;
+ }
+ }
+ return (_tmp5 = result, song = (g_free (song), NULL), search = (g_free (search), NULL), _tmp5);
+}
-static void
-xfmpc_playlist_class_init (XfmpcPlaylistClass *klass)
-{
- GObjectClass *gobject_class;
- g_type_class_add_private (klass, sizeof (XfmpcPlaylistPrivate));
+static void _g_list_free_gtk_tree_path_free (GList* self) {
+ g_list_foreach (self, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (self);
+}
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->dispose = xfmpc_playlist_dispose;
- gobject_class->finalize = xfmpc_playlist_finalize;
+/*
+ * Signal callbacks
+ */
+static void xfmpc_playlist_cb_browse_selection (XfmpcPlaylist* self) {
+ XfmpcDbbrowser* dbbrowser;
+ XfmpcExtendedInterface* extended_interface;
+ GtkTreeSelection* _tmp0;
+ GtkTreeSelection* selection;
+ GtkListStore* _tmp1;
+ GtkListStore* model;
+ GtkListStore* _tmp5;
+ GtkListStore* _tmp4;
+ GList* _tmp3;
+ GtkTreeModel* _tmp2;
+ GList* list;
+ GtkTreeIter iter = {0};
+ const GtkTreePath* _tmp6;
+ GtkTreePath* path;
+ g_return_if_fail (self != NULL);
+ dbbrowser = NULL;
+ extended_interface = NULL;
+ dbbrowser = XFMPC_DBBROWSER (g_object_get_data ((GObject*) self, "XfmpcDbbrowser"));
+ extended_interface = XFMPC_EXTENDED_INTERFACE (g_object_get_data ((GObject*) self, "XfmpcExtendedInterface"));
+ _tmp0 = NULL;
+ selection = (_tmp0 = gtk_tree_view_get_selection (self->priv->treeview), (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ if (gtk_tree_selection_count_selected_rows (selection) > 1) {
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ return;
+ }
+ _tmp1 = NULL;
+ model = (_tmp1 = self->priv->store, (_tmp1 == NULL) ? NULL : g_object_ref (_tmp1));
+ _tmp5 = NULL;
+ _tmp4 = NULL;
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ list = (_tmp3 = gtk_tree_selection_get_selected_rows (selection, &_tmp2), model = (_tmp4 = (_tmp5 = (GtkListStore*) _tmp2, (_tmp5 == NULL) ? NULL : g_object_ref (_tmp5)), (model == NULL) ? NULL : (model = (g_object_unref (model), NULL)), _tmp4), _tmp3);
+ if (g_list_length (list) == 0) {
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ (list == NULL) ? NULL : (list = (_g_list_free_gtk_tree_path_free (list), NULL));
+ return;
+ }
+ _tmp6 = NULL;
+ path = (_tmp6 = (const GtkTreePath*) g_list_nth_data (list, (guint) 0), (_tmp6 == NULL) ? NULL : gtk_tree_path_copy (_tmp6));
+ if (gtk_tree_model_get_iter ((GtkTreeModel*) self->priv->store, &iter, path)) {
+ char* filename;
+ char* dir;
+ char* _tmp7;
+ filename = g_strdup ("");
+ dir = NULL;
+ gtk_tree_model_get ((GtkTreeModel*) self->priv->store, &iter, XFMPC_PLAYLIST_COLUMNS_COLUMN_FILENAME, &filename, -1, -1);
+ _tmp7 = NULL;
+ dir = (_tmp7 = g_path_get_dirname (filename), dir = (g_free (dir), NULL), _tmp7);
+ xfmpc_dbbrowser_set_wdir (dbbrowser, dir);
+ xfmpc_dbbrowser_reload (dbbrowser);
+ xfmpc_extended_interface_set_active (extended_interface, XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_DBBROWSER);
+ filename = (g_free (filename), NULL);
+ dir = (g_free (dir), NULL);
+ }
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ (list == NULL) ? NULL : (list = (_g_list_free_gtk_tree_path_free (list), NULL));
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
}
-static void
-xfmpc_playlist_init (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = playlist->priv = GET_PRIVATE (playlist);
- playlist->preferences = xfmpc_preferences_get ();
- playlist->mpdclient = xfmpc_mpdclient_get ();
+static void xfmpc_playlist_cb_info_selection (XfmpcPlaylist* self) {
+ GtkTreeIter iter = {0};
+ gint id;
+ GtkTreeSelection* _tmp0;
+ GtkTreeSelection* selection;
+ GtkListStore* _tmp1;
+ GtkListStore* model;
+ GtkListStore* _tmp5;
+ GtkListStore* _tmp4;
+ GList* _tmp3;
+ GtkTreeModel* _tmp2;
+ GList* list;
+ const GtkTreePath* _tmp6;
+ GtkTreePath* path;
+ g_return_if_fail (self != NULL);
+ id = 0;
+ _tmp0 = NULL;
+ selection = (_tmp0 = gtk_tree_view_get_selection (self->priv->treeview), (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ if (gtk_tree_selection_count_selected_rows (selection) > 1) {
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ return;
+ }
+ _tmp1 = NULL;
+ model = (_tmp1 = self->priv->store, (_tmp1 == NULL) ? NULL : g_object_ref (_tmp1));
+ _tmp5 = NULL;
+ _tmp4 = NULL;
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ list = (_tmp3 = gtk_tree_selection_get_selected_rows (selection, &_tmp2), model = (_tmp4 = (_tmp5 = (GtkListStore*) _tmp2, (_tmp5 == NULL) ? NULL : g_object_ref (_tmp5)), (model == NULL) ? NULL : (model = (g_object_unref (model), NULL)), _tmp4), _tmp3);
+ if (g_list_length (list) == 0) {
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ (list == NULL) ? NULL : (list = (_g_list_free_gtk_tree_path_free (list), NULL));
+ return;
+ }
+ _tmp6 = NULL;
+ path = (_tmp6 = (const GtkTreePath*) g_list_nth_data (list, (guint) 0), (_tmp6 == NULL) ? NULL : gtk_tree_path_copy (_tmp6));
+ if (gtk_tree_model_get_iter ((GtkTreeModel*) self->priv->store, &iter, path)) {
+ XfmpcSongDialog* dialog;
+ gtk_tree_model_get ((GtkTreeModel*) self->priv->store, &iter, XFMPC_PLAYLIST_COLUMNS_COLUMN_ID, &id, -1, -1);
+ dialog = g_object_ref_sink (xfmpc_song_dialog_new (id));
+ gtk_widget_show_all ((GtkWidget*) dialog);
+ (dialog == NULL) ? NULL : (dialog = (g_object_unref (dialog), NULL));
+ }
+ (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL));
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ (list == NULL) ? NULL : (list = (_g_list_free_gtk_tree_path_free (list), NULL));
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
+}
- g_object_get (G_OBJECT (playlist->preferences),
- "playlist-autocenter", &priv->autocenter,
- NULL);
- /* === Tree model === */
- priv->store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_INT,
- G_TYPE_STRING,
- G_TYPE_INT,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INT);
+static gboolean xfmpc_playlist_cb_popup_menu (XfmpcPlaylist* self) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ xfmpc_playlist_menu_popup (self);
+ return TRUE;
+}
- /* === Filter === */
- priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (GTK_TREE_MODEL (priv->store), NULL));
- g_object_unref (priv->store);
- gtk_tree_model_filter_set_visible_func (priv->filter,
- (GtkTreeModelFilterVisibleFunc)visible_func_filter_tree,
- playlist,
- NULL);
- /* === Tree view === */
- priv->treeview = gtk_tree_view_new ();
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)), GTK_SELECTION_MULTIPLE);
- gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (priv->treeview), TRUE);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (priv->treeview), FALSE);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE);
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->treeview), TRUE);
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), GTK_TREE_MODEL (priv->filter));
- g_object_unref (priv->filter);
+static void xfmpc_playlist_cb_song_changed (XfmpcPlaylist* self) {
+ gboolean _tmp0;
+ g_return_if_fail (self != NULL);
+ xfmpc_playlist_refresh_current_song (self);
+ _tmp0 = FALSE;
+ if (_vala_strcmp0 (gtk_entry_get_text (xfmpc_playlist_filter_entry), "") == 0) {
+ _tmp0 = self->priv->autocenter;
+ } else {
+ _tmp0 = FALSE;
+ }
+ if (_tmp0) {
+ xfmpc_playlist_select_row (self, self->priv->current);
+ }
+}
- /* Column "position" */
- GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (cell),
- "xalign", 1.0,
- NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview),
- -1, "Length", cell,
- "text", COLUMN_POSITION,
- "weight", COLUMN_WEIGHT,
- NULL);
- /* Column "artist - title" */
- cell = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (cell),
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL);
- GtkTreeViewColumn *column =
- gtk_tree_view_column_new_with_attributes ("Song", cell,
- "text", COLUMN_SONG,
- "weight", COLUMN_WEIGHT,
- NULL);
- g_object_set (G_OBJECT (column),
- "expand", TRUE,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
+static void xfmpc_playlist_cb_playlist_changed (XfmpcPlaylist* self) {
+ char* filename;
+ char* song;
+ char* length;
+ gint id;
+ gint pos;
+ gboolean _tmp0;
+ g_return_if_fail (self != NULL);
+ filename = g_strdup ("");
+ song = g_strdup ("");
+ length = g_strdup ("");
+ id = 0;
+ pos = 0;
+ self->priv->current = xfmpc_mpdclient_get_id (self->priv->mpdclient);
+ gtk_list_store_clear (self->priv->store);
+ while (xfmpc_mpdclient_playlist_read (self->priv->mpdclient, &id, &pos, &filename, &song, &length)) {
+ xfmpc_playlist_append (self, id, pos, filename, song, length);
+ }
+ xfmpc_playlist_refresh_current_song (self);
+ _tmp0 = FALSE;
+ if (_vala_strcmp0 (gtk_entry_get_text (xfmpc_playlist_filter_entry), "") != 0) {
+ _tmp0 = self->priv->autocenter;
+ } else {
+ _tmp0 = FALSE;
+ }
+ if (_tmp0) {
+ xfmpc_playlist_select_row (self, self->priv->current);
+ }
+ filename = (g_free (filename), NULL);
+ song = (g_free (song), NULL);
+ length = (g_free (length), NULL);
+}
- /* Column "length" */
- cell = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (cell),
- "xalign", 1.0,
- NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview),
- -1, "Length", cell,
- "text", COLUMN_LENGTH,
- "weight", COLUMN_WEIGHT,
- NULL);
- /* Scrolled window */
- GtkWidget *scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_ALWAYS);
+static void xfmpc_playlist_cb_row_activated (XfmpcPlaylist* self, const GtkTreePath* path, GtkTreeViewColumn* column) {
+ GtkTreeIter iter = {0};
+ const GtkTreePath* _tmp0;
+ GtkTreePath* new_path;
+ gint id;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (path != NULL);
+ g_return_if_fail (column != NULL);
+ _tmp0 = NULL;
+ new_path = (_tmp0 = path, (_tmp0 == NULL) ? NULL : gtk_tree_path_copy (_tmp0));
+ id = 0;
+ if (!gtk_tree_model_get_iter ((GtkTreeModel*) self->priv->filter, &iter, new_path)) {
+ (new_path == NULL) ? NULL : (new_path = (gtk_tree_path_free (new_path), NULL));
+ return;
+ }
+ gtk_tree_model_get ((GtkTreeModel*) self->priv->filter, &iter, XFMPC_PLAYLIST_COLUMNS_COLUMN_ID, &id, -1, -1);
+ xfmpc_mpdclient_set_id (self->priv->mpdclient, id);
+ (new_path == NULL) ? NULL : (new_path = (gtk_tree_path_free (new_path), NULL));
+}
- /* Menu */
- priv->menu = gtk_menu_new ();
- GtkWidget *mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL);
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mi);
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (xfmpc_playlist_delete_selection), playlist);
+static gboolean xfmpc_playlist_cb_key_released (XfmpcPlaylist* self, const GdkEventKey* event) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ if ((*event).type != GDK_KEY_RELEASE) {
+ return FALSE;
+ }
+ /* Suppr key */
+ switch ((*event).keyval) {
+ case 0xffff:
+ {
+ xfmpc_playlist_delete_selection (self);
+ break;
+ }
+ default:
+ {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
- mi = priv->mi_browse = gtk_image_menu_item_new_with_mnemonic (_("_Browse"));
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mi);
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (cb_browse_selection), playlist);
- GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
- mi = priv->mi_information = gtk_image_menu_item_new_from_stock (GTK_STOCK_INFO, NULL);
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mi);
- g_signal_connect_swapped (mi, "activate",
- G_CALLBACK (cb_info_selection), playlist);
+static gboolean xfmpc_playlist_cb_button_released (XfmpcPlaylist* self, const GdkEventButton* event) {
+ GtkTreePath* path;
+ GtkTreeSelection* selection;
+ gboolean _tmp0;
+ GtkTreeSelection* _tmp3;
+ GtkTreeSelection* _tmp2;
+ gboolean sensitive;
+ GtkTreePath* _tmp7;
+ gboolean _tmp6;
+ GtkTreePath* _tmp5;
+ gboolean _tmp8;
+ g_return_val_if_fail (self != NULL, FALSE);
+ path = NULL;
+ selection = NULL;
+ _tmp0 = FALSE;
+ if ((*event).type != GDK_BUTTON_PRESS) {
+ _tmp0 = TRUE;
+ } else {
+ _tmp0 = (*event).button != 3;
+ }
+ if (_tmp0) {
+ gboolean _tmp1;
+ return (_tmp1 = FALSE, (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL)), _tmp1);
+ }
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ selection = (_tmp3 = (_tmp2 = gtk_tree_view_get_selection (self->priv->treeview), (_tmp2 == NULL) ? NULL : g_object_ref (_tmp2)), (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL)), _tmp3);
+ if (gtk_tree_selection_count_selected_rows (selection) < 1) {
+ gboolean _tmp4;
+ return (_tmp4 = TRUE, (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL)), _tmp4);
+ }
+ sensitive = gtk_tree_selection_count_selected_rows (selection) == 1;
+ gtk_widget_set_sensitive ((GtkWidget*) self->priv->mi_browse, sensitive);
+ gtk_widget_set_sensitive ((GtkWidget*) self->priv->mi_information, sensitive);
+ _tmp7 = NULL;
+ _tmp5 = NULL;
+ if ((_tmp6 = gtk_tree_view_get_path_at_pos (self->priv->treeview, (gint) (*event).x, (gint) (*event).y, &_tmp5, NULL, NULL, NULL), path = (_tmp7 = _tmp5, (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), _tmp7), _tmp6)) {
+ if (!gtk_tree_selection_path_is_selected (selection, path)) {
+ gtk_tree_selection_unselect_all (selection);
+ gtk_tree_selection_select_path (selection, path);
+ }
+ }
+ xfmpc_playlist_menu_popup (self);
+ return (_tmp8 = TRUE, (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), (selection == NULL) ? NULL : (selection = (g_object_unref (selection), NULL)), _tmp8);
+}
- gtk_widget_show_all (priv->menu);
- /* === Filter entry === */
- priv->filter_entry = gtk_entry_new ();
+static void xfmpc_playlist_menu_popup (XfmpcPlaylist* self) {
+ g_return_if_fail (self != NULL);
+ gtk_menu_popup (self->priv->menu, NULL, NULL, NULL, NULL, (guint) 0, gtk_get_current_event_time ());
+}
- /* === Containers === */
- gtk_container_add (GTK_CONTAINER (scrolled), priv->treeview);
- gtk_box_pack_start (GTK_BOX (playlist), scrolled, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (playlist), priv->filter_entry, FALSE, FALSE, 0);
- /* === Signals === */
- g_signal_connect_swapped (playlist->mpdclient, "song-changed",
- G_CALLBACK (cb_song_changed), playlist);
- g_signal_connect_swapped (playlist->mpdclient, "playlist-changed",
- G_CALLBACK (cb_playlist_changed), playlist);
- /* Tree view */
- g_signal_connect_swapped (priv->treeview, "row-activated",
- G_CALLBACK (cb_row_activated), playlist);
- g_signal_connect_swapped (priv->treeview, "key-release-event",
- G_CALLBACK (cb_key_released), playlist);
- g_signal_connect_swapped (priv->treeview, "button-release-event",
- G_CALLBACK (cb_button_released), playlist);
- g_signal_connect_swapped (priv->treeview, "popup-menu",
- G_CALLBACK (cb_popup_menu), playlist);
- /* Filter entry */
- g_signal_connect_swapped (priv->filter_entry, "activate",
- G_CALLBACK (cb_filter_entry_activated), playlist);
- g_signal_connect_swapped (priv->filter_entry, "key-release-event",
- G_CALLBACK (cb_filter_entry_key_released), playlist);
- g_signal_connect_swapped (priv->filter_entry, "changed",
- G_CALLBACK (cb_filter_entry_changed), playlist);
-
- /* Preferences */
- g_signal_connect_swapped (playlist->preferences, "notify::song-format",
- G_CALLBACK (cb_playlist_changed), playlist);
- g_signal_connect_swapped (playlist->preferences, "notify::song-format-custom",
- G_CALLBACK (cb_playlist_changed), playlist);
+static void xfmpc_playlist_cb_filter_entry_activated (XfmpcPlaylist* self) {
+ GtkTreeModelFilter* _tmp3;
+ GtkTreeModelFilter* _tmp2;
+ GList* _tmp1;
+ GtkTreeModel* _tmp0;
+ GList* list;
+ const GtkTreePath* _tmp4;
+ GtkTreePath* path;
+ g_return_if_fail (self != NULL);
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ _tmp1 = NULL;
+ _tmp0 = NULL;
+ list = (_tmp1 = gtk_tree_selection_get_selected_rows (gtk_tree_view_get_selection (self->priv->treeview), &_tmp0), self->priv->filter = (_tmp2 = (_tmp3 = (GtkTreeModelFilter*) _tmp0, (_tmp3 == NULL) ? NULL : g_object_ref (_tmp3)), (self->priv->filter == NULL) ? NULL : (self->priv->filter = (g_object_unref (self->priv->filter), NULL)), _tmp2), _tmp1);
+ _tmp4 = NULL;
+ path = (_tmp4 = (const GtkTreePath*) g_list_nth_data (list, (guint) 0), (_tmp4 == NULL) ? NULL : gtk_tree_path_copy (_tmp4));
+ if (g_list_length (list) > 0) {
+ gtk_tree_view_row_activated (self->priv->treeview, path, gtk_tree_view_get_column (self->priv->treeview, 0));
+ gtk_entry_set_text (xfmpc_playlist_filter_entry, "");
+ xfmpc_playlist_select_row (self, self->priv->current);
+ gtk_widget_grab_focus ((GtkWidget*) self->priv->treeview);
+ }
+ (list == NULL) ? NULL : (list = (_g_list_free_gtk_tree_path_free (list), NULL));
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
}
-static void
-xfmpc_playlist_dispose (GObject *object)
-{
- (*G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-static void
-xfmpc_playlist_finalize (GObject *object)
-{
- XfmpcPlaylist *playlist = XFMPC_PLAYLIST (object);
- g_object_unref (G_OBJECT (playlist->mpdclient));
- (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+static gboolean xfmpc_playlist_cb_filter_entry_key_released (XfmpcPlaylist* self, const GdkEventKey* event) {
+ g_return_val_if_fail (self != NULL, FALSE);
+ if ((*event).type != GDK_KEY_RELEASE) {
+ return FALSE;
+ }
+ /* Escape */
+ if ((*event).keyval == 0xff1b) {
+ gtk_entry_set_text (xfmpc_playlist_filter_entry, "");
+ xfmpc_playlist_select_row (self, self->priv->current);
+ gtk_widget_grab_focus ((GtkWidget*) self->priv->treeview);
+ } else {
+ if (_vala_strcmp0 (gtk_entry_get_text (xfmpc_playlist_filter_entry), "") != 0) {
+ xfmpc_playlist_select_row (self, 0);
+ } else {
+ xfmpc_playlist_select_row (self, self->priv->current);
+ }
+ }
+ return TRUE;
}
-
-GtkWidget*
-xfmpc_playlist_new ()
-{
- return g_object_new (XFMPC_TYPE_PLAYLIST, NULL);
+static void xfmpc_playlist_cb_filter_entry_changed (XfmpcPlaylist* self) {
+ g_return_if_fail (self != NULL);
+ gtk_tree_model_filter_refilter (self->priv->filter);
}
-void
-xfmpc_playlist_append (XfmpcPlaylist *playlist,
- gint id,
- gint pos,
- gchar *filename,
- gchar *song,
- gchar *length)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- GtkTreeIter iter;
- gtk_list_store_append (priv->store, &iter);
- gtk_list_store_set (priv->store, &iter,
- COLUMN_ID, id,
- COLUMN_FILENAME, filename,
- COLUMN_POSITION, pos + 1,
- COLUMN_SONG, song,
- COLUMN_LENGTH, length,
- COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
- -1);
+/*
+ * Public
+ */
+void xfmpc_playlist_append (XfmpcPlaylist* self, gint id, gint pos, const char* filename, const char* song, const char* length) {
+ GtkTreeIter iter = {0};
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (filename != NULL);
+ g_return_if_fail (song != NULL);
+ g_return_if_fail (length != NULL);
+ gtk_list_store_append (self->priv->store, &iter);
+ gtk_list_store_set (self->priv->store, &iter, XFMPC_PLAYLIST_COLUMNS_COLUMN_ID, id, XFMPC_PLAYLIST_COLUMNS_COLUMN_FILENAME, filename, XFMPC_PLAYLIST_COLUMNS_COLUMN_POSITION, pos + 1, XFMPC_PLAYLIST_COLUMNS_COLUMN_SONG, song, XFMPC_PLAYLIST_COLUMNS_COLUMN_LENGTH, length, XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL, -1, -1);
}
-void
-xfmpc_playlist_clear (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- gtk_list_store_clear (priv->store);
+
+void xfmpc_playlist_refresh_current_song (XfmpcPlaylist* self) {
+ GtkTreeIter iter = {0};
+ GtkTreePath* path;
+ GtkTreePath* _tmp0;
+ GtkTreePath* _tmp1;
+ g_return_if_fail (self != NULL);
+ path = NULL;
+ if (self->priv->current < 0) {
+ self->priv->current = 0;
+ }
+ _tmp0 = NULL;
+ path = (_tmp0 = gtk_tree_path_new_from_indices (self->priv->current, -1, -1), (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), _tmp0);
+ if (gtk_tree_model_get_iter ((GtkTreeModel*) self->priv->store, &iter, path)) {
+ gtk_list_store_set (self->priv->store, &iter, XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL, -1, -1);
+ }
+ self->priv->current = xfmpc_mpdclient_get_pos (self->priv->mpdclient);
+ _tmp1 = NULL;
+ path = (_tmp1 = gtk_tree_path_new_from_indices (self->priv->current, -1, -1), (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL)), _tmp1);
+ if (gtk_tree_model_get_iter ((GtkTreeModel*) self->priv->store, &iter, path)) {
+ gtk_list_store_set (self->priv->store, &iter, XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD, -1, -1);
+ }
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
}
-void
-xfmpc_playlist_delete_selection (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- GtkTreeModel *store = GTK_TREE_MODEL (priv->store);
- GtkTreeIter iter;
- GList *list;
- gint id;
- list = gtk_tree_selection_get_selected_rows (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)),
- &store);
- while (NULL != list)
- {
- if (gtk_tree_model_get_iter (store, &iter, list->data))
- {
- gtk_tree_model_get (store, &iter,
- COLUMN_ID, &id,
- -1);
- xfmpc_mpdclient_queue_remove_id (playlist->mpdclient, id);
- }
- list = g_list_next (list);
- }
+void xfmpc_playlist_select_row (XfmpcPlaylist* self, gint i) {
+ GtkTreePath* path;
+ g_return_if_fail (self != NULL);
+ if (self->priv->current < 0) {
+ return;
+ }
+ if (gtk_tree_model_iter_n_children ((GtkTreeModel*) self->priv->filter, NULL) == 0) {
+ return;
+ }
+ path = gtk_tree_path_new_from_indices (i, -1, -1);
+ gtk_tree_view_set_cursor (self->priv->treeview, path, NULL, FALSE);
+ gtk_tree_view_scroll_to_cell (self->priv->treeview, path, NULL, TRUE, (float) 0.42, (float) 0);
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
+}
- xfmpc_mpdclient_queue_commit (playlist->mpdclient);
- g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (list);
+void xfmpc_playlist_delete_selection (XfmpcPlaylist* self) {
+ gint id;
+ GtkTreeIter iter = {0};
+ GtkListStore* _tmp0;
+ GtkListStore* model;
+ GtkListStore* _tmp4;
+ GtkListStore* _tmp3;
+ GList* _tmp2;
+ GtkTreeModel* _tmp1;
+ GList* list;
+ g_return_if_fail (self != NULL);
+ id = 0;
+ _tmp0 = NULL;
+ model = (_tmp0 = self->priv->store, (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ _tmp4 = NULL;
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ _tmp1 = NULL;
+ list = (_tmp2 = gtk_tree_selection_get_selected_rows (gtk_tree_view_get_selection (self->priv->treeview), &_tmp1), model = (_tmp3 = (_tmp4 = (GtkListStore*) _tmp1, (_tmp4 == NULL) ? NULL : g_object_ref (_tmp4)), (model == NULL) ? NULL : (model = (g_object_unref (model), NULL)), _tmp3), _tmp2);
+ {
+ GList* path_collection;
+ GList* path_it;
+ path_collection = list;
+ for (path_it = path_collection; path_it != NULL; path_it = path_it->next) {
+ const GtkTreePath* _tmp5;
+ GtkTreePath* path;
+ _tmp5 = NULL;
+ path = (_tmp5 = (const GtkTreePath*) path_it->data, (_tmp5 == NULL) ? NULL : gtk_tree_path_copy (_tmp5));
+ {
+ if (gtk_tree_model_get_iter ((GtkTreeModel*) self->priv->store, &iter, path)) {
+ gtk_tree_model_get ((GtkTreeModel*) self->priv->store, &iter, XFMPC_PLAYLIST_COLUMNS_COLUMN_ID, &id, -1, -1);
+ xfmpc_mpdclient_queue_remove_id (self->priv->mpdclient, id);
+ }
+ (path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
+ }
+ }
+ }
+ xfmpc_mpdclient_queue_commit (self->priv->mpdclient);
+ (model == NULL) ? NULL : (model = (g_object_unref (model), NULL));
+ (list == NULL) ? NULL : (list = (_g_list_free_gtk_tree_path_free (list), NULL));
}
-void
-xfmpc_playlist_select_row (XfmpcPlaylist *playlist,
- gint i)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->filter), NULL) == 0)
- return;
-
- GtkTreePath *path = gtk_tree_path_new_from_indices (i, -1);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, NULL, FALSE);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->treeview), path, NULL, TRUE, 0.42, 0);
- gtk_tree_path_free (path);
+XfmpcPlaylist* xfmpc_playlist_construct (GType object_type) {
+ XfmpcPlaylist * self;
+ self = g_object_newv (object_type, 0, NULL);
+ return self;
}
-void
-xfmpc_playlist_refresh_current_song (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- /* Remove the bold from the "last" current song */
- GtkTreeIter iter;
- GtkTreePath *path = gtk_tree_path_new_from_indices (priv->current, -1);
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->store), &iter, path))
- gtk_list_store_set (priv->store, &iter,
- COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
- -1);
-
- /* Set the current song bold */
- priv->current = xfmpc_mpdclient_get_pos (playlist->mpdclient);
- path = gtk_tree_path_new_from_indices (priv->current, -1);
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->store), &iter, path))
- gtk_list_store_set (priv->store, &iter,
- COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
- -1);
+XfmpcPlaylist* xfmpc_playlist_new (void) {
+ return xfmpc_playlist_construct (XFMPC_TYPE_PLAYLIST);
}
+static void _xfmpc_playlist_delete_selection_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self) {
+ xfmpc_playlist_delete_selection (self);
+}
-static void
-cb_song_changed (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- xfmpc_playlist_refresh_current_song (playlist);
-
- /* don't autocenter if a filter is typped in */
- if (gtk_entry_get_text (GTK_ENTRY (priv->filter_entry))[0] == '\0' && priv->autocenter)
- xfmpc_playlist_select_row (playlist, priv->current);
+static void _xfmpc_playlist_cb_browse_selection_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self) {
+ xfmpc_playlist_cb_browse_selection (self);
}
-static void
-cb_playlist_changed (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- gchar *filename, *song, *length;
- gint id, pos, current;
- current = xfmpc_mpdclient_get_id (playlist->mpdclient);
+static void _xfmpc_playlist_cb_info_selection_gtk_menu_item_activate (GtkImageMenuItem* _sender, gpointer self) {
+ xfmpc_playlist_cb_info_selection (self);
+}
- xfmpc_playlist_clear (playlist);
- while (xfmpc_mpdclient_playlist_read (playlist->mpdclient, &id, &pos, &filename, &song, &length))
- {
- xfmpc_playlist_append (playlist, id, pos, filename, song, length);
- g_free (filename);
- g_free (song);
- g_free (length);
- }
- xfmpc_playlist_refresh_current_song (playlist);
-
- /* don't autocenter if a filter is typped in */
- if (gtk_entry_get_text (GTK_ENTRY (priv->filter_entry))[0] == '\0' && priv->autocenter)
- xfmpc_playlist_select_row (playlist, priv->current);
+static void _xfmpc_playlist_cb_song_changed_xfmpc_mpdclient_song_changed (XfmpcMpdclient* _sender, gpointer self) {
+ xfmpc_playlist_cb_song_changed (self);
}
-static void
-cb_row_activated (XfmpcPlaylist *playlist,
- GtkTreePath *path,
- GtkTreeViewColumn *column)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- GtkTreeIter iter;
- gint id;
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->filter), &iter, path))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (priv->filter), &iter,
- COLUMN_ID, &id,
- -1);
- xfmpc_mpdclient_set_id (playlist->mpdclient, id);
+static void _xfmpc_playlist_cb_playlist_changed_xfmpc_mpdclient_playlist_changed (XfmpcMpdclient* _sender, gpointer self) {
+ xfmpc_playlist_cb_playlist_changed (self);
}
-static gboolean
-cb_key_released (XfmpcPlaylist *playlist,
- GdkEventKey *event)
-{
- if (event->type != GDK_KEY_RELEASE)
- return FALSE;
- switch (event->keyval)
- {
- case GDK_Delete:
- xfmpc_playlist_delete_selection (playlist);
- break;
+static void _xfmpc_playlist_cb_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, const GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) {
+ xfmpc_playlist_cb_row_activated (self, path, column);
+}
- default:
- return FALSE;
- }
- return TRUE;
+static gboolean _xfmpc_playlist_cb_key_released_gtk_widget_key_release_event (GtkTreeView* _sender, const GdkEventKey* event, gpointer self) {
+ return xfmpc_playlist_cb_key_released (self, event);
}
-static gboolean
-cb_button_released (XfmpcPlaylist *playlist,
- GdkEventButton *event)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- GtkTreeSelection *selection;
- GtkTreePath *path;
- gboolean sensitive;
-
- if (event->type != GDK_BUTTON_RELEASE || event->button != 3)
- return FALSE;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
- if (gtk_tree_selection_count_selected_rows (selection) < 1)
- return TRUE;
+static gboolean _xfmpc_playlist_cb_button_released_gtk_widget_button_press_event (GtkTreeView* _sender, const GdkEventButton* event, gpointer self) {
+ return xfmpc_playlist_cb_button_released (self, event);
+}
- sensitive = gtk_tree_selection_count_selected_rows (selection) == 1;
- gtk_widget_set_sensitive (priv->mi_browse, sensitive);
- gtk_widget_set_sensitive (priv->mi_information, sensitive);
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->treeview),
- event->x, event->y,
- &path, NULL, NULL, NULL))
- {
- if (!gtk_tree_selection_path_is_selected (selection, path))
- {
- gtk_tree_selection_unselect_all (selection);
- gtk_tree_selection_select_path (selection, path);
- }
- gtk_tree_path_free (path);
- }
-
- popup_menu (playlist);
- return TRUE;
+static gboolean _xfmpc_playlist_cb_popup_menu_gtk_widget_popup_menu (GtkTreeView* _sender, gpointer self) {
+ return xfmpc_playlist_cb_popup_menu (self);
}
-static gboolean
-cb_popup_menu (XfmpcPlaylist *playlist)
-{
- popup_menu (playlist);
- return TRUE;
-}
-static void
-popup_menu (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- gtk_menu_popup (GTK_MENU (priv->menu),
- NULL, NULL,
- NULL, NULL,
- 0,
- gtk_get_current_event_time ());
+static void _xfmpc_playlist_cb_filter_entry_activated_gtk_entry_activate (GtkEntry* _sender, gpointer self) {
+ xfmpc_playlist_cb_filter_entry_activated (self);
}
+static gboolean _xfmpc_playlist_cb_filter_entry_key_released_gtk_widget_key_release_event (GtkEntry* _sender, const GdkEventKey* event, gpointer self) {
+ return xfmpc_playlist_cb_filter_entry_key_released (self, event);
+}
-static void
-cb_filter_entry_activated (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- GtkTreeModel *model = GTK_TREE_MODEL (priv->filter);
- GList *list;
- list = gtk_tree_selection_get_selected_rows (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)), &model);
- if (G_LIKELY (NULL != list))
- {
- gtk_tree_view_row_activated (GTK_TREE_VIEW (priv->treeview), list->data, NULL);
- gtk_entry_set_text (GTK_ENTRY (priv->filter_entry), "");
- xfmpc_playlist_select_row (playlist, priv->current);
- gtk_widget_grab_focus (priv->treeview);
- g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (list);
- }
+static void _xfmpc_playlist_cb_filter_entry_changed_gtk_editable_changed (GtkEntry* _sender, gpointer self) {
+ xfmpc_playlist_cb_filter_entry_changed (self);
}
-static gboolean
-cb_filter_entry_key_released (XfmpcPlaylist *playlist,
- GdkEventKey *event)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- if (event->type != GDK_KEY_RELEASE)
- return FALSE;
+static void _xfmpc_playlist_cb_playlist_changed_xfmpc_preferences_notify (XfmpcPreferences* _sender, GParamSpec* pspec, gpointer self) {
+ xfmpc_playlist_cb_playlist_changed (self);
+}
- if (event->keyval == GDK_Escape)
- {
- gtk_entry_set_text (GTK_ENTRY (priv->filter_entry), "");
- xfmpc_playlist_select_row (playlist, priv->current);
- gtk_widget_grab_focus (priv->treeview);
- }
- else
- {
- if (gtk_entry_get_text (GTK_ENTRY (priv->filter_entry))[0] != '\0')
- xfmpc_playlist_select_row (playlist, 0);
- else
- xfmpc_playlist_select_row (playlist, priv->current);
- }
- return TRUE;
+static GObject * xfmpc_playlist_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ XfmpcPlaylistClass * klass;
+ GObjectClass * parent_class;
+ XfmpcPlaylist * self;
+ klass = XFMPC_PLAYLIST_CLASS (g_type_class_peek (XFMPC_TYPE_PLAYLIST));
+ parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = XFMPC_PLAYLIST (obj);
+ {
+ GtkListStore* _tmp0;
+ GtkTreeModelFilter* _tmp1;
+ GtkTreeView* _tmp2;
+ GtkCellRendererText* cell;
+ GtkCellRendererText* _tmp3;
+ GtkTreeViewColumn* column;
+ GtkCellRendererText* _tmp4;
+ GtkAdjustment* _tmp6;
+ GtkAdjustment* _tmp5;
+ GtkScrolledWindow* _tmp7;
+ GtkScrolledWindow* scrolled;
+ GtkMenu* _tmp8;
+ GtkImageMenuItem* mi;
+ GtkImageMenuItem* _tmp9;
+ GtkImage* image;
+ GtkImageMenuItem* _tmp10;
+ GtkEntry* _tmp11;
+ xfce_textdomain (self->priv->gettext_package, self->priv->localedir, "UTF-8");
+ self->priv->mpdclient = xfmpc_mpdclient_get ();
+ self->priv->preferences = xfmpc_preferences_get ();
+ self->priv->autocenter = xfmpc_preferences_get_playlist_autocenter (self->priv->preferences);
+ _tmp0 = NULL;
+ self->priv->store = (_tmp0 = gtk_list_store_new ((gint) XFMPC_PLAYLIST_COLUMNS_N_COLUMNS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, NULL), (self->priv->store == NULL) ? NULL : (self->priv->store = (g_object_unref (self->priv->store), NULL)), _tmp0);
+ _tmp1 = NULL;
+ self->priv->filter = (_tmp1 = (GtkTreeModelFilter*) gtk_tree_model_filter_new ((GtkTreeModel*) self->priv->store, NULL), (self->priv->filter == NULL) ? NULL : (self->priv->filter = (g_object_unref (self->priv->filter), NULL)), _tmp1);
+ gtk_tree_model_filter_set_visible_func (self->priv->filter, (GtkTreeModelFilterVisibleFunc) xfmpc_playlist_visible_func_filter_tree, NULL, NULL);
+ _tmp2 = NULL;
+ self->priv->treeview = (_tmp2 = g_object_ref_sink ((GtkTreeView*) gtk_tree_view_new ()), (self->priv->treeview == NULL) ? NULL : (self->priv->treeview = (g_object_unref (self->priv->treeview), NULL)), _tmp2);
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection (self->priv->treeview), GTK_SELECTION_MULTIPLE);
+ gtk_tree_view_set_rubber_banding (self->priv->treeview, TRUE);
+ gtk_tree_view_set_enable_search (self->priv->treeview, FALSE);
+ gtk_tree_view_set_headers_visible (self->priv->treeview, FALSE);
+ gtk_tree_view_set_rules_hint (self->priv->treeview, TRUE);
+ gtk_tree_view_set_model (self->priv->treeview, (GtkTreeModel*) self->priv->filter);
+ cell = g_object_ref_sink ((GtkCellRendererText*) gtk_cell_renderer_text_new ());
+ g_object_set ((GtkCellRenderer*) cell, "xalign", (float) 1, NULL);
+ gtk_tree_view_insert_column_with_attributes (self->priv->treeview, -1, "Length", (GtkCellRenderer*) cell, "text", XFMPC_PLAYLIST_COLUMNS_COLUMN_POSITION, "weight", XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT, NULL, NULL);
+ _tmp3 = NULL;
+ cell = (_tmp3 = g_object_ref_sink ((GtkCellRendererText*) gtk_cell_renderer_text_new ()), (cell == NULL) ? NULL : (cell = (g_object_unref (cell), NULL)), _tmp3);
+ g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ column = g_object_ref_sink (gtk_tree_view_column_new_with_attributes ("Song", (GtkCellRenderer*) cell, "text", XFMPC_PLAYLIST_COLUMNS_COLUMN_SONG, "weight", XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT, NULL, NULL));
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_append_column (self->priv->treeview, column);
+ _tmp4 = NULL;
+ cell = (_tmp4 = g_object_ref_sink ((GtkCellRendererText*) gtk_cell_renderer_text_new ()), (cell == NULL) ? NULL : (cell = (g_object_unref (cell), NULL)), _tmp4);
+ g_object_set ((GtkCellRenderer*) cell, "xalign", (float) 1, NULL);
+ gtk_tree_view_insert_column_with_attributes (self->priv->treeview, -1, "Length", (GtkCellRenderer*) cell, "text", XFMPC_PLAYLIST_COLUMNS_COLUMN_LENGTH, "weight", XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT, NULL, NULL);
+ _tmp6 = NULL;
+ _tmp5 = NULL;
+ _tmp7 = NULL;
+ scrolled = (_tmp7 = g_object_ref_sink ((GtkScrolledWindow*) gtk_scrolled_window_new (_tmp5 = g_object_ref_sink ((GtkAdjustment*) gtk_adjustment_new ((double) 0, (double) 0, (double) 0, (double) 0, (double) 0, (double) 0)), _tmp6 = g_object_ref_sink ((GtkAdjustment*) gtk_adjustment_new ((double) 0, (double) 0, (double) 0, (double) 0, (double) 0, (double) 0)))), (_tmp6 == NULL) ? NULL : (_tmp6 = (g_object_unref (_tmp6), NULL)), (_tmp5 == NULL) ? NULL : (_tmp5 = (g_object_unref (_tmp5), NULL)), _tmp7);
+ gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+ _tmp8 = NULL;
+ self->priv->menu = (_tmp8 = g_object_ref_sink ((GtkMenu*) gtk_menu_new ()), (self->priv->menu == NULL) ? NULL : (self->priv->menu = (g_object_unref (self->priv->menu), NULL)), _tmp8);
+ mi = g_object_ref_sink ((GtkImageMenuItem*) gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL));
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) mi));
+ g_signal_connect_object ((GtkMenuItem*) mi, "activate", (GCallback) _xfmpc_playlist_delete_selection_gtk_menu_item_activate, self, 0);
+ _tmp9 = NULL;
+ self->priv->mi_browse = (_tmp9 = g_object_ref_sink ((GtkImageMenuItem*) gtk_image_menu_item_new_with_mnemonic (_ ("Browse"))), (self->priv->mi_browse == NULL) ? NULL : (self->priv->mi_browse = (g_object_unref (self->priv->mi_browse), NULL)), _tmp9);
+ image = g_object_ref_sink ((GtkImage*) gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU));
+ gtk_image_menu_item_set_image (self->priv->mi_browse, (GtkWidget*) image);
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) self->priv->mi_browse));
+ g_signal_connect_object ((GtkMenuItem*) self->priv->mi_browse, "activate", (GCallback) _xfmpc_playlist_cb_browse_selection_gtk_menu_item_activate, self, 0);
+ _tmp10 = NULL;
+ self->priv->mi_information = (_tmp10 = g_object_ref_sink ((GtkImageMenuItem*) gtk_image_menu_item_new_from_stock (GTK_STOCK_INFO, NULL)), (self->priv->mi_information == NULL) ? NULL : (self->priv->mi_information = (g_object_unref (self->priv->mi_information), NULL)), _tmp10);
+ gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) self->priv->mi_information));
+ g_signal_connect_object ((GtkMenuItem*) self->priv->mi_information, "activate", (GCallback) _xfmpc_playlist_cb_info_selection_gtk_menu_item_activate, self, 0);
+ gtk_widget_show_all ((GtkWidget*) self->priv->menu);
+ _tmp11 = NULL;
+ xfmpc_playlist_filter_entry = (_tmp11 = g_object_ref_sink ((GtkEntry*) gtk_entry_new ()), (xfmpc_playlist_filter_entry == NULL) ? NULL : (xfmpc_playlist_filter_entry = (g_object_unref (xfmpc_playlist_filter_entry), NULL)), _tmp11);
+ gtk_container_add ((GtkContainer*) scrolled, (GtkWidget*) self->priv->treeview);
+ gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) scrolled, TRUE, TRUE, (guint) 0);
+ gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) xfmpc_playlist_filter_entry, FALSE, FALSE, (guint) 0);
+ /* Signals */
+ g_signal_connect_object (self->priv->mpdclient, "song-changed", (GCallback) _xfmpc_playlist_cb_song_changed_xfmpc_mpdclient_song_changed, self, 0);
+ g_signal_connect_object (self->priv->mpdclient, "playlist-changed", (GCallback) _xfmpc_playlist_cb_playlist_changed_xfmpc_mpdclient_playlist_changed, self, 0);
+ g_signal_connect_object (self->priv->treeview, "row-activated", (GCallback) _xfmpc_playlist_cb_row_activated_gtk_tree_view_row_activated, self, 0);
+ g_signal_connect_object ((GtkWidget*) self->priv->treeview, "key-release-event", (GCallback) _xfmpc_playlist_cb_key_released_gtk_widget_key_release_event, self, 0);
+ g_signal_connect_object ((GtkWidget*) self->priv->treeview, "button-press-event", (GCallback) _xfmpc_playlist_cb_button_released_gtk_widget_button_press_event, self, 0);
+ g_signal_connect_object ((GtkWidget*) self->priv->treeview, "popup-menu", (GCallback) _xfmpc_playlist_cb_popup_menu_gtk_widget_popup_menu, self, 0);
+ 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);
+ (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));
+ (mi == NULL) ? NULL : (mi = (g_object_unref (mi), NULL));
+ (image == NULL) ? NULL : (image = (g_object_unref (image), NULL));
+ }
+ return obj;
}
-static void
-cb_filter_entry_changed (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- gtk_tree_model_filter_refilter (priv->filter);
+
+static void xfmpc_playlist_class_init (XfmpcPlaylistClass * klass) {
+ xfmpc_playlist_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (XfmpcPlaylistPrivate));
+ G_OBJECT_CLASS (klass)->constructor = xfmpc_playlist_constructor;
+ G_OBJECT_CLASS (klass)->finalize = xfmpc_playlist_finalize;
}
-static gboolean
-visible_func_filter_tree (GtkTreeModel *filter,
- GtkTreeIter *iter,
- XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- gchar *song, *song_tmp;
- gchar *search;
- gboolean result = TRUE;
- gtk_tree_model_get (GTK_TREE_MODEL (filter), iter,
- COLUMN_SONG, &song,
- -1);
- if (G_UNLIKELY (NULL == song))
- return TRUE;
+static void xfmpc_playlist_instance_init (XfmpcPlaylist * self) {
+ self->priv = XFMPC_PLAYLIST_GET_PRIVATE (self);
+ self->priv->gettext_package = g_strdup (GETTEXT_PACKAGE);
+ self->priv->localedir = g_strdup (PACKAGE_LOCALE_DIR);
+ self->priv->current = 0;
+}
- search = g_utf8_casefold (gtk_entry_get_text (GTK_ENTRY (priv->filter_entry)), -1);
- g_return_val_if_fail (G_LIKELY (NULL != search), TRUE);
- if (G_UNLIKELY (search[0] != '\0'))
- {
- song_tmp = g_utf8_casefold (song, -1);
- g_free (song);
- song = song_tmp;
+static void xfmpc_playlist_finalize (GObject* obj) {
+ XfmpcPlaylist * self;
+ self = XFMPC_PLAYLIST (obj);
+ self->priv->gettext_package = (g_free (self->priv->gettext_package), NULL);
+ self->priv->localedir = (g_free (self->priv->localedir), NULL);
+ (self->priv->store == NULL) ? NULL : (self->priv->store = (g_object_unref (self->priv->store), NULL));
+ (self->priv->filter == NULL) ? NULL : (self->priv->filter = (g_object_unref (self->priv->filter), NULL));
+ (self->priv->treeview == NULL) ? NULL : (self->priv->treeview = (g_object_unref (self->priv->treeview), NULL));
+ (self->priv->menu == NULL) ? NULL : (self->priv->menu = (g_object_unref (self->priv->menu), NULL));
+ (self->priv->mi_browse == NULL) ? NULL : (self->priv->mi_browse = (g_object_unref (self->priv->mi_browse), NULL));
+ (self->priv->mi_information == NULL) ? NULL : (self->priv->mi_information = (g_object_unref (self->priv->mi_information), NULL));
+ G_OBJECT_CLASS (xfmpc_playlist_parent_class)->finalize (obj);
+}
- if (NULL == g_strrstr (song, search))
- result = FALSE;
- }
- g_free (song);
- g_free (search);
-
- return result;
+GType xfmpc_playlist_get_type (void) {
+ static GType xfmpc_playlist_type_id = 0;
+ if (xfmpc_playlist_type_id == 0) {
+ static const GTypeInfo g_define_type_info = { sizeof (XfmpcPlaylistClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xfmpc_playlist_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XfmpcPlaylist), 0, (GInstanceInitFunc) xfmpc_playlist_instance_init, NULL };
+ xfmpc_playlist_type_id = g_type_register_static (GTK_TYPE_VBOX, "XfmpcPlaylist", &g_define_type_info, 0);
+ }
+ return xfmpc_playlist_type_id;
}
-void
-cb_browse_selection (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- XfmpcDbbrowser *dbbrowser;
- XfmpcExtendedInterface *extended_interface;
- GtkTreeModel *store = GTK_TREE_MODEL (priv->store);
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GList *list;
- gchar *filename, *dir;
- dbbrowser = g_object_get_data (G_OBJECT (playlist), "XfmpcDbbrowser");
- extended_interface = g_object_get_data (G_OBJECT (playlist), "XfmpcExtendedInterface");
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
- if (gtk_tree_selection_count_selected_rows (selection) > 1)
- return;
-
- list = gtk_tree_selection_get_selected_rows (selection, &store);
- if (list == NULL)
- return;
-
- if (gtk_tree_model_get_iter (store, &iter, list->data))
- {
- gtk_tree_model_get (store, &iter,
- COLUMN_FILENAME, &filename,
- -1);
-
- dir = g_path_get_dirname (filename);
- xfmpc_dbbrowser_set_wdir (dbbrowser, dir);
- xfmpc_dbbrowser_reload (dbbrowser);
- xfmpc_extended_interface_set_active (extended_interface, XFMPC_EXTENDED_INTERFACE_DBBROWSER);
-
- g_free (filename);
- g_free (dir);
- }
-
- g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (list);
+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
-cb_info_selection (XfmpcPlaylist *playlist)
-{
- XfmpcPlaylistPrivate *priv = XFMPC_PLAYLIST (playlist)->priv;
- GtkTreeModel *store = GTK_TREE_MODEL (priv->store);
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GList *list;
- gint id;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
- if (gtk_tree_selection_count_selected_rows (selection) > 1)
- return;
- list = gtk_tree_selection_get_selected_rows (selection, &store);
- if (list == NULL)
- return;
-
- if (gtk_tree_model_get_iter (store, &iter, list->data))
- {
- gtk_tree_model_get (store, &iter,
- COLUMN_ID, &id,
- -1);
-
- GtkWidget *dialog = xfmpc_song_dialog_new (id);
- gtk_widget_show (dialog);
- }
-
- g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (list);
-}
-
Added: xfmpc/trunk/src/playlist.vala
===================================================================
--- xfmpc/trunk/src/playlist.vala (rev 0)
+++ xfmpc/trunk/src/playlist.vala 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,414 @@
+/*
+ * 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 Playlist : VBox {
+
+ private unowned Xfmpc.Mpdclient mpdclient;
+ private unowned Xfmpc.Preferences preferences;
+
+ private string gettext_package = Config.GETTEXT_PACKAGE;
+ private string localedir = Config.PACKAGE_LOCALE_DIR;
+
+ private ListStore store;
+ private TreeModelFilter filter;
+ private TreeView treeview;
+ private Menu menu;
+ private static Entry filter_entry;
+
+ private ImageMenuItem mi_browse;
+ private ImageMenuItem mi_information;
+
+ private int current = 0;
+ private bool autocenter;
+
+ enum Columns {
+ COLUMN_ID,
+ COLUMN_FILENAME,
+ COLUMN_POSITION,
+ COLUMN_SONG,
+ COLUMN_LENGTH,
+ COLUMN_WEIGHT,
+ N_COLUMNS,
+ }
+
+ construct {
+ Xfce.textdomain (gettext_package, localedir, "UTF-8");
+
+ mpdclient = Xfmpc.Mpdclient.get ();
+ preferences = Xfmpc.Preferences.get ();
+
+ autocenter = preferences.playlist_autocenter;
+
+ store = new ListStore (Columns.N_COLUMNS,
+ typeof (int),
+ typeof (string),
+ typeof (int),
+ typeof (string),
+ typeof (string),
+ typeof (int));
+
+ filter = new TreeModelFilter (store, null);
+ filter.set_visible_func ((TreeModelFilterVisibleFunc) visible_func_filter_tree);
+
+ treeview = new TreeView ();
+ (treeview.get_selection ()).set_mode (SelectionMode.MULTIPLE);
+ treeview.set_rubber_banding (true);
+ treeview.set_enable_search (false);
+ treeview.set_headers_visible (false);
+ treeview.set_rules_hint (true);
+ treeview.set_model (filter);
+
+ var cell = new CellRendererText ();
+ cell.xalign = 1;
+ treeview.insert_column_with_attributes (-1, "Length", cell,
+ "text", Columns.COLUMN_POSITION,
+ "weight", Columns.COLUMN_WEIGHT,
+ null);
+ cell = new CellRendererText ();
+ cell.ellipsize = Pango.EllipsizeMode.END;
+ var column = new TreeViewColumn.with_attributes ("Song", cell,
+ "text", Columns.COLUMN_SONG,
+ "weight", Columns.COLUMN_WEIGHT,
+ null);
+ column.expand = true;
+ treeview.append_column (column);
+ cell = new CellRendererText ();
+ cell.xalign = 1;
+ treeview.insert_column_with_attributes (-1, "Length", cell,
+ "text", Columns.COLUMN_LENGTH,
+ "weight", Columns.COLUMN_WEIGHT,
+ null);
+
+ var scrolled = new ScrolledWindow (new Adjustment (0, 0, 0, 0, 0, 0),
+ new Adjustment (0, 0, 0, 0, 0, 0));
+ scrolled.set_policy (PolicyType.AUTOMATIC, PolicyType.ALWAYS);
+
+ menu = new Menu ();
+
+ var mi = new ImageMenuItem.from_stock (STOCK_REMOVE, null);
+ menu.append (mi);
+ mi.activate += delete_selection;
+ mi_browse = new ImageMenuItem.with_mnemonic (_("Browse"));
+ var image = new Image.from_stock (STOCK_OPEN, IconSize.MENU);
+ mi_browse.set_image (image);
+ menu.append (mi_browse);
+ mi_browse.activate += cb_browse_selection;
+ mi_information = new ImageMenuItem.from_stock (STOCK_INFO, null);
+ menu.append (mi_information);
+ mi_information.activate += cb_info_selection;
+
+ menu.show_all ();
+
+ filter_entry = new Entry ();
+
+ scrolled.add (treeview);
+ pack_start (scrolled, true, true, 0);
+ pack_start (filter_entry, false, false, 0);
+
+ /* Signals */
+ mpdclient.song_changed += cb_song_changed;
+ mpdclient.playlist_changed += cb_playlist_changed;
+
+ treeview.row_activated += cb_row_activated;
+ treeview.key_release_event += cb_key_released;
+ treeview.button_press_event += cb_button_released;
+ treeview.popup_menu += cb_popup_menu;
+
+ filter_entry.activate += cb_filter_entry_activated;
+ filter_entry.key_release_event += cb_filter_entry_key_released;
+ filter_entry.changed += cb_filter_entry_changed;
+
+ preferences.notify["song-format"] += cb_playlist_changed;
+ preferences.notify["song-format-custom"] += cb_playlist_changed;
+ }
+
+ private static bool visible_func_filter_tree (TreeModel model, out TreeIter iter) {
+ string song = "", search = "";
+ bool result = true;
+
+ model.get (iter, Columns.COLUMN_SONG, &song, -1);
+ if (song == "")
+ return true;
+
+ search = filter_entry.get_text ();
+ search = search.casefold (-1);
+
+ if (search != "") {
+ song = song.casefold (-1);
+
+ if (song.str (search) == null)
+ result = false;
+ }
+
+ return result;
+ }
+
+ /*
+ * Signal callbacks
+ */
+
+ private void cb_browse_selection () {
+ unowned Xfmpc.Dbbrowser dbbrowser;
+ unowned Xfmpc.ExtendedInterface extended_interface;
+
+ dbbrowser = (Xfmpc.Dbbrowser) get_data ("XfmpcDbbrowser");
+ extended_interface = (Xfmpc.ExtendedInterface) get_data ("XfmpcExtendedInterface");
+
+ var selection = treeview.get_selection ();
+ if (selection.count_selected_rows () > 1)
+ return;
+
+ var model = store;
+ var list = selection.get_selected_rows (out model);
+ if (list.length () == 0)
+ return;
+
+ TreeIter iter;
+ var path = list.nth_data (0);
+ if (store.get_iter (out iter, path)) {
+ string filename = "", dir;
+ store.get (iter, Columns.COLUMN_FILENAME, out filename, -1);
+ dir = Path.get_dirname (filename);
+ dbbrowser.set_wdir (dir);
+ dbbrowser.reload ();
+ extended_interface.set_active (ExtendedInterface.ExtendedInterfaceWidget.DBBROWSER);
+ }
+ }
+
+ private void cb_info_selection () {
+ TreeIter iter;
+ int id = 0;
+
+ var selection = treeview.get_selection ();
+ if (selection.count_selected_rows () > 1)
+ return;
+
+ var model = store;
+ var list = selection.get_selected_rows (out model);
+ if (list.length () == 0)
+ return;
+
+ var path = list.nth_data (0);
+
+ if (store.get_iter (out iter, path)) {
+ store.get (iter, Columns.COLUMN_ID, out id, -1);
+ var dialog = new SongDialog (id);
+ dialog.show_all ();
+ }
+ }
+
+ private bool cb_popup_menu () {
+ menu_popup ();
+ return true;
+ }
+
+ private void cb_song_changed () {
+ refresh_current_song ();
+
+ if (filter_entry.get_text () == "" && autocenter)
+ select_row (current);
+ }
+
+ private void cb_playlist_changed () {
+ string filename = "", song = "", length = "";
+ int id = 0, pos = 0;
+
+ current = mpdclient.get_id ();
+
+ store.clear ();
+
+ while (mpdclient.playlist_read (&id, &pos, &filename, &song, &length)) {
+ append (id, pos, filename, song, length);
+ }
+
+ refresh_current_song ();
+
+ if (filter_entry.get_text () != "" && autocenter)
+ select_row (current);
+ }
+
+ private void cb_row_activated (TreePath path, TreeViewColumn column) {
+ TreeIter iter;
+ TreePath new_path = path;
+ int id = 0;
+
+ if (!filter.get_iter (out iter, new_path))
+ return;
+
+ filter.get (iter, Columns.COLUMN_ID, out id, -1);
+ mpdclient.set_id (id);
+ }
+
+ private bool cb_key_released (Gdk.EventKey event) {
+ if (event.type != Gdk.EventType.KEY_RELEASE)
+ return false;
+
+ /* Suppr key */
+ switch (event.keyval)
+ {
+ case 0xffff:
+ delete_selection ();
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+ private bool cb_button_released (Gdk.EventButton event) {
+ TreePath path;
+ TreeSelection selection;
+
+ if (event.type != Gdk.EventType.BUTTON_PRESS || event.button != 3)
+ return false;
+
+ selection = treeview.get_selection ();
+ if (selection.count_selected_rows () < 1)
+ return true;
+
+ bool sensitive = selection.count_selected_rows () == 1;
+ mi_browse.set_sensitive (sensitive);
+ mi_information.set_sensitive (sensitive);
+
+ if (treeview.get_path_at_pos ((int) event.x, (int) event.y,
+ out path, null, null, null))
+ {
+ if (!selection.path_is_selected (path)) {
+ selection.unselect_all ();
+ selection.select_path (path);
+ }
+ }
+
+ menu_popup ();
+
+ return true;
+ }
+
+ private void menu_popup () {
+ menu.popup (null, null, null, 0, get_current_event_time ());
+ }
+
+ private void cb_filter_entry_activated () {
+ var list = (treeview.get_selection ()).get_selected_rows (out filter);
+ var path = list.nth_data (0);
+
+ if (list.length () > 0) {
+ treeview.row_activated (path, treeview.get_column (0));
+ filter_entry.set_text ("");
+ select_row (current);
+ treeview.grab_focus ();
+ }
+ }
+
+ private bool cb_filter_entry_key_released (Gdk.EventKey event) {
+ if (event.type != Gdk.EventType.KEY_RELEASE)
+ return false;
+
+ /* Escape */
+ if (event.keyval == 0xff1b) {
+ filter_entry.set_text ("");
+ select_row (current);
+ treeview.grab_focus ();
+ }
+ else {
+ if (filter_entry.get_text () != "")
+ select_row (0);
+ else
+ select_row (current);
+ }
+
+ return true;
+ }
+
+ private void cb_filter_entry_changed () {
+ filter.refilter ();
+ }
+
+ /*
+ * Public
+ */
+
+ public void append (int id, int pos, string filename, string song, string length) {
+ TreeIter iter;
+
+ store.append (out iter);
+ store.set (iter,
+ Columns.COLUMN_ID, id,
+ Columns.COLUMN_FILENAME, filename,
+ Columns.COLUMN_POSITION, pos + 1,
+ Columns.COLUMN_SONG, song,
+ Columns.COLUMN_LENGTH, length,
+ Columns.COLUMN_WEIGHT, Pango.Weight.NORMAL,
+ -1);
+ }
+
+ public void refresh_current_song () {
+ TreeIter iter;
+ TreePath path;
+
+ if (current < 0)
+ current = 0;
+
+ path = new TreePath.from_indices (current, -1);
+
+ if (store.get_iter (out iter, path))
+ store.set (iter, Columns.COLUMN_WEIGHT, Pango.Weight.NORMAL, -1);
+
+ current = mpdclient.get_pos ();
+ path = new TreePath.from_indices (current, -1);
+ if (store.get_iter (out iter, path))
+ store.set (iter, Columns.COLUMN_WEIGHT, Pango.Weight.BOLD, -1);
+ }
+
+ public void select_row (int i) {
+ if (current < 0)
+ return;
+ if (filter.iter_n_children (null) == 0)
+ return;
+
+ TreePath path = new TreePath.from_indices (i, -1);
+ treeview.set_cursor (path, null, false);
+ treeview.scroll_to_cell (path, null, true, (float) 0.42, 0);
+ }
+
+ public void delete_selection () {
+ int id = 0;
+ TreeIter iter;
+ var model = store;
+
+ var list = (treeview.get_selection ()).get_selected_rows (out model);
+
+ foreach (Gtk.TreePath path in list) {
+ if (store.get_iter (out iter, path)) {
+ store.get (iter, Columns.COLUMN_ID, out id, -1);
+ mpdclient.queue_remove_id (id);
+ }
+ }
+
+ mpdclient.queue_commit ();
+ }
+ }
+}
+
+/* vi:set ts=8 sw=8: */
Modified: xfmpc/trunk/src/preferences-dialog.c
===================================================================
--- xfmpc/trunk/src/preferences-dialog.c 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/preferences-dialog.c 2009-04-23 11:11:39 UTC (rev 7280)
@@ -1,10 +1,7 @@
/*
- * Copyright (c) 2009 Vincent Legout <vincent at legout.info>
* Copyright (c) 2009 Mike Massonnet <mmassonnet at xfce.org>
+ * Copyright (c) 2009 Vincent Legout <vincent at xfce.org>
*
- * Based on ThunarPreferencesDialog:
- * 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,484 +17,535 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifdef HAVE_CONFIG_H
+#include <glib.h>
+#include <glib-object.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <preferences.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gtk/gtk.h>
#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <mpdclient.h>
#include <libxfce4util/libxfce4util.h>
+#include <glib/gi18n-lib.h>
+#include <pango/pango.h>
-#include "mpdclient.h"
-#include "preferences-dialog.h"
-#include "preferences.h"
-#include "statusbar.h"
-#define GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialogPrivate))
+#define XFMPC_TYPE_PREFERENCES_DIALOG (xfmpc_preferences_dialog_get_type ())
+#define XFMPC_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialog))
+#define XFMPC_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialogClass))
+#define XFMPC_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES_DIALOG))
+#define XFMPC_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES_DIALOG))
+#define XFMPC_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialogClass))
+typedef struct _XfmpcPreferencesDialog XfmpcPreferencesDialog;
+typedef struct _XfmpcPreferencesDialogClass XfmpcPreferencesDialogClass;
+typedef struct _XfmpcPreferencesDialogPrivate XfmpcPreferencesDialogPrivate;
-
-static void xfmpc_preferences_dialog_class_init (XfmpcPreferencesDialogClass *klass);
-static void xfmpc_preferences_dialog_init (XfmpcPreferencesDialog *dialog);
-static void xfmpc_preferences_dialog_finalize (GObject *object);
-
-static void xfmpc_preferences_dialog_response (GtkDialog *dialog,
- gint response);
-static void cb_use_defaults_toggled (GtkToggleButton *button,
- GtkWidget *widget);
-static void cb_update_mpd (GtkButton *button,
- XfmpcPreferencesDialog *dialog);
-static void cb_show_statusbar_toggled (GtkToggleButton *button,
- XfmpcPreferencesDialog *dialog);
-
-static void cb_format_entry_activated (XfmpcPreferencesDialog *dialog);
-static void cb_format_entry_changed (GtkEntry *entry,
- XfmpcPreferencesDialog *dialog);
-static void cb_format_combo_changed (GtkComboBox *combo,
- XfmpcPreferencesDialog *dialog);
-
-static gboolean timeout_format (XfmpcPreferencesDialog *dialog);
-static void timeout_format_destroy (XfmpcPreferencesDialog *dialog);
-
-
-
-struct _XfmpcPreferencesDialogClass
-{
- XfceTitledDialogClass parent_class;
+struct _XfmpcPreferencesDialog {
+ XfceTitledDialog parent_instance;
+ XfmpcPreferencesDialogPrivate * priv;
};
-struct _XfmpcPreferencesDialog
-{
- XfceTitledDialog parent;
- XfmpcPreferences *preferences;
- /*<private>*/
- XfmpcPreferencesDialogPrivate *priv;
+struct _XfmpcPreferencesDialogClass {
+ XfceTitledDialogClass parent_class;
};
-struct _XfmpcPreferencesDialogPrivate
-{
- GtkWidget *entry_use_defaults;
- GtkWidget *entry_host;
- GtkWidget *entry_port;
- GtkWidget *entry_passwd;
- GtkWidget *statusbar_button;
- GtkWidget *entry_format;
- GtkWidget *combo_format;
-
- guint format_timeout;
- gboolean is_format;
+struct _XfmpcPreferencesDialogPrivate {
+ XfmpcPreferences* preferences;
+ char* gettext_package;
+ char* localedir;
+ GtkCheckButton* entry_use_defaults;
+ GtkEntry* entry_host;
+ GtkEntry* entry_passwd;
+ GtkSpinButton* entry_port;
+ GtkCheckButton* show_statusbar;
+ GtkComboBox* combo_format;
+ GtkEntry* entry_custom;
+ guint format_timeout;
+ GtkVBox* mpd_vbox;
};
-static GObjectClass *parent_class = NULL;
+GType xfmpc_preferences_dialog_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);
+static void xfmpc_preferences_dialog_cb_update_mpd (XfmpcPreferencesDialog* self, GtkButton* source);
+static void xfmpc_preferences_dialog_cb_show_statusbar_toggled (XfmpcPreferencesDialog* self, GtkCheckButton* source);
+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);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_new (void);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_construct (GType object_type);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_new (void);
+static void _xfmpc_preferences_dialog_cb_use_defaults_toggled_gtk_toggle_button_toggled (GtkCheckButton* _sender, gpointer self);
+static void _xfmpc_preferences_dialog_cb_update_mpd_gtk_button_clicked (GtkButton* _sender, gpointer self);
+static void _xfmpc_preferences_dialog_cb_show_statusbar_toggled_gtk_toggle_button_toggled (GtkCheckButton* _sender, gpointer 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);
+static GObject * xfmpc_preferences_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
+static gpointer xfmpc_preferences_dialog_parent_class = NULL;
+static void xfmpc_preferences_dialog_finalize (GObject* obj);
-GType
-xfmpc_preferences_dialog_get_type (void)
-{
- static GType xfmpc_preferences_dialog_type = G_TYPE_INVALID;
+/*
+ * Signal callbacks
+ */
+static void xfmpc_preferences_dialog_cb_response (XfmpcPreferencesDialog* self, XfmpcPreferencesDialog* source, gint response) {
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (source != NULL);
+ switch (response) {
+ case GTK_RESPONSE_CLOSE:
+ {
+ gtk_object_destroy ((GtkObject*) self);
+ break;
+ }
+ }
+}
- if (G_UNLIKELY (xfmpc_preferences_dialog_type == G_TYPE_INVALID))
- {
- static const GTypeInfo xfmpc_preferences_dialog_info =
- {
- sizeof (XfmpcPreferencesDialogClass),
- NULL,
- NULL,
- (GClassInitFunc) xfmpc_preferences_dialog_class_init,
- NULL,
- NULL,
- sizeof (XfmpcPreferencesDialog),
- 0,
- (GInstanceInitFunc) xfmpc_preferences_dialog_init,
- NULL,
- };
- xfmpc_preferences_dialog_type = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, "XfmpcPreferencesDialog", &xfmpc_preferences_dialog_info, 0);
- }
-
- return xfmpc_preferences_dialog_type;
+static void xfmpc_preferences_dialog_cb_use_defaults_toggled (XfmpcPreferencesDialog* self, GtkCheckButton* source) {
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (source != NULL);
+ gtk_widget_set_sensitive ((GtkWidget*) self->priv->mpd_vbox, !gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->entry_use_defaults));
}
+static void xfmpc_preferences_dialog_cb_update_mpd (XfmpcPreferencesDialog* self, GtkButton* source) {
+ XfmpcMpdclient* mpdclient;
+ const char* _tmp0;
+ char* mpd_hostname;
+ const char* _tmp1;
+ char* mpd_password;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (source != NULL);
+ mpdclient = xfmpc_mpdclient_get ();
+ _tmp0 = NULL;
+ mpd_hostname = (_tmp0 = gtk_entry_get_text (self->priv->entry_host), (_tmp0 == NULL) ? NULL : g_strdup (_tmp0));
+ _tmp1 = NULL;
+ mpd_password = (_tmp1 = gtk_entry_get_text (self->priv->entry_passwd), (_tmp1 == NULL) ? NULL : g_strdup (_tmp1));
+ xfmpc_preferences_set_mpd_hostname (self->priv->preferences, mpd_hostname);
+ xfmpc_preferences_set_mpd_port (self->priv->preferences, gtk_spin_button_get_value_as_int (self->priv->entry_port));
+ xfmpc_preferences_set_mpd_password (self->priv->preferences, mpd_password);
+ xfmpc_preferences_set_mpd_use_defaults (self->priv->preferences, gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->entry_use_defaults));
+ xfmpc_mpdclient_disconnect (mpdclient);
+ xfmpc_mpdclient_connect (mpdclient);
+ mpd_hostname = (g_free (mpd_hostname), NULL);
+ mpd_password = (g_free (mpd_password), NULL);
+}
-static void
-xfmpc_preferences_dialog_class_init (XfmpcPreferencesDialogClass *klass)
-{
- GtkDialogClass *gtkdialog_class;
- GObjectClass *gobject_class;
- g_type_class_add_private (klass, sizeof (XfmpcPreferencesDialogPrivate));
+static void xfmpc_preferences_dialog_cb_show_statusbar_toggled (XfmpcPreferencesDialog* self, GtkCheckButton* source) {
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (source != NULL);
+ xfmpc_preferences_set_show_statusbar (self->priv->preferences, gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->show_statusbar));
+}
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xfmpc_preferences_dialog_finalize;
-
- gtkdialog_class = GTK_DIALOG_CLASS (klass);
- gtkdialog_class->response = xfmpc_preferences_dialog_response;
+static void xfmpc_preferences_dialog_cb_combo_format_changed (XfmpcPreferencesDialog* self, GtkComboBox* source) {
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (source != NULL);
+ 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);
+ break;
+ }
+ case 1:
+ {
+ xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ALBUM_TITLE);
+ break;
+ }
+ case 2:
+ {
+ xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ARTIST_TITLE);
+ break;
+ }
+ case 3:
+ {
+ xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ARTIST_TITLE_DATE);
+ break;
+ }
+ case 4:
+ {
+ xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ARTIST_ALBUM_TITLE);
+ break;
+ }
+ case 5:
+ {
+ xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_ARTIST_ALBUM_TRACK_TITLE);
+ break;
+ }
+ case 6:
+ {
+ xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_CUSTOM);
+ break;
+ }
+ default:
+ {
+ xfmpc_preferences_set_song_format (self->priv->preferences, (gint) XFMPC_SONG_FORMAT_TITLE);
+ break;
+ }
+ }
+ gtk_widget_set_sensitive ((GtkWidget*) self->priv->entry_custom, gtk_combo_box_get_active (self->priv->combo_format) == 6);
}
-static void
-xfmpc_preferences_dialog_init (XfmpcPreferencesDialog *dialog)
-{
- XfmpcPreferencesDialogPrivate *priv = dialog->priv = GET_PRIVATE (dialog);
- GtkWidget *notebook;
- GtkWidget *vbox, *vbox2, *hbox;
- GtkWidget *mpd_vbox;
- GtkWidget *frame;
- GtkWidget *label;
- GtkWidget *button;
- GtkWidget *table;
+static gboolean _xfmpc_preferences_dialog_timeout_format_gsource_func (gpointer self) {
+ return xfmpc_preferences_dialog_timeout_format (self);
+}
- gchar *host, *passwd;
- guint port;
- gboolean use_defaults;
- gboolean statusbar;
- XfmpcSongFormat song_format;
- gchar *format_custom;
- dialog->preferences = xfmpc_preferences_get ();
+static void xfmpc_preferences_dialog_cb_entry_custom_changed (XfmpcPreferencesDialog* self, GtkEntry* source) {
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (source != NULL);
+ if (self->priv->format_timeout > 0) {
+ g_source_remove (self->priv->format_timeout);
+ }
+ self->priv->format_timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1, _xfmpc_preferences_dialog_timeout_format_gsource_func, g_object_ref (self), g_object_unref);
+}
- g_object_get (dialog->preferences,
- "mpd-hostname", &host,
- "mpd-port", &port,
- "mpd-password", &passwd,
- "mpd-use-defaults", &use_defaults,
- "show-statusbar", &statusbar,
- "song-format", &song_format,
- "song-format-custom", &format_custom,
- NULL);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "stock_volume");
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_window_set_title (GTK_WINDOW (dialog), _("Xfmpc Preferences"));
+static gboolean xfmpc_preferences_dialog_timeout_format (XfmpcPreferencesDialog* self) {
+ const char* _tmp0;
+ char* custom_format;
+ gboolean _tmp1;
+ g_return_val_if_fail (self != NULL, FALSE);
+ _tmp0 = NULL;
+ custom_format = (_tmp0 = gtk_entry_get_text (self->priv->entry_custom), (_tmp0 == NULL) ? NULL : g_strdup (_tmp0));
+ xfmpc_preferences_set_song_format_custom (self->priv->preferences, custom_format);
+ return (_tmp1 = FALSE, custom_format = (g_free (custom_format), NULL), _tmp1);
+}
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
- notebook = gtk_notebook_new ();
- gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
- gtk_widget_show (notebook);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_construct (GType object_type) {
+ XfmpcPreferencesDialog * self;
+ self = g_object_newv (object_type, 0, NULL);
+ return self;
+}
- /*
- MPD settings
- */
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
- label = gtk_label_new (_("MPD"));
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
- vbox2 = gtk_vbox_new (FALSE, 8);
- frame = xfce_create_framebox_with_content (_("Connection"), vbox2);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_new (void) {
+ return xfmpc_preferences_dialog_construct (XFMPC_TYPE_PREFERENCES_DIALOG);
+}
- priv->entry_use_defaults = gtk_check_button_new_with_mnemonic (_("Use _default system settings"));
- gtk_widget_set_tooltip_text (priv->entry_use_defaults,
- _("If checked, Xfmpc will try to read the environment "
- "variables MPD_HOST and MPD_PORT otherwise it will "
- "use localhost"));
- gtk_container_add (GTK_CONTAINER (vbox2), priv->entry_use_defaults);
- GtkWidget *alignment = gtk_alignment_new (0., 0., 1., 1.);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 8, 16, 0);
- gtk_container_add (GTK_CONTAINER (vbox2), alignment);
+static void _xfmpc_preferences_dialog_cb_use_defaults_toggled_gtk_toggle_button_toggled (GtkCheckButton* _sender, gpointer self) {
+ xfmpc_preferences_dialog_cb_use_defaults_toggled (self, _sender);
+}
- mpd_vbox = gtk_vbox_new (FALSE, 8);
- gtk_container_add (GTK_CONTAINER (alignment), mpd_vbox);
- g_signal_connect (priv->entry_use_defaults, "toggled",
- G_CALLBACK (cb_use_defaults_toggled), mpd_vbox);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->entry_use_defaults), use_defaults);
+static void _xfmpc_preferences_dialog_cb_update_mpd_gtk_button_clicked (GtkButton* _sender, gpointer self) {
+ xfmpc_preferences_dialog_cb_update_mpd (self, _sender);
+}
- hbox = gtk_hbox_new (FALSE, 2);
- gtk_container_add (GTK_CONTAINER (mpd_vbox), hbox);
- label = gtk_label_new (_("Hostname:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- priv->entry_host = gtk_entry_new ();
- gtk_entry_set_width_chars (GTK_ENTRY (priv->entry_host), 15);
- gtk_entry_set_text (GTK_ENTRY (priv->entry_host), host);
- gtk_box_pack_start (GTK_BOX (hbox), priv->entry_host, TRUE, TRUE, 0);
+static void _xfmpc_preferences_dialog_cb_show_statusbar_toggled_gtk_toggle_button_toggled (GtkCheckButton* _sender, gpointer self) {
+ xfmpc_preferences_dialog_cb_show_statusbar_toggled (self, _sender);
+}
- label = gtk_label_new (_("Port:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- priv->entry_port = gtk_spin_button_new_with_range (0, 65536, 1);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (priv->entry_port), 0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->entry_port), port);
- gtk_box_pack_start (GTK_BOX (hbox), priv->entry_port, FALSE, FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 2);
- gtk_container_add (GTK_CONTAINER (mpd_vbox), hbox);
+static void _xfmpc_preferences_dialog_cb_combo_format_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
+ xfmpc_preferences_dialog_cb_combo_format_changed (self, _sender);
+}
- label = gtk_label_new (_("Password:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- priv->entry_passwd = gtk_entry_new ();
- gtk_entry_set_visibility (GTK_ENTRY (priv->entry_passwd), FALSE);
- if (passwd != NULL)
- gtk_entry_set_text (GTK_ENTRY (priv->entry_passwd), passwd);
- gtk_box_pack_start (GTK_BOX (hbox), priv->entry_passwd, TRUE, TRUE, 0);
- button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
- g_signal_connect (button, "clicked",
- G_CALLBACK (cb_update_mpd), dialog);
- gtk_container_add (GTK_CONTAINER (vbox2), button);
-
- /*
- Display
- */
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
- label = gtk_label_new (_("Appearance"));
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
-
- vbox2 = gtk_vbox_new (FALSE, 6);
- frame = xfce_create_framebox_with_content (_("Statusbar"), vbox2);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-
- priv->statusbar_button = gtk_check_button_new_with_mnemonic (_("Show _statusbar"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->statusbar_button), statusbar);
- g_signal_connect (priv->statusbar_button, "toggled",
- G_CALLBACK (cb_show_statusbar_toggled), dialog);
- gtk_container_add (GTK_CONTAINER (vbox2), priv->statusbar_button);
-
- vbox2 = gtk_vbox_new (FALSE, 6);
- frame = xfce_create_framebox_with_content (_("Song Format"), vbox2);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-
- hbox = gtk_hbox_new (FALSE, 2);
-
- label = gtk_label_new (_("Song format:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- priv->combo_format = gtk_combo_box_new_text ();
- gtk_box_pack_start (GTK_BOX (hbox), priv->combo_format, TRUE, TRUE, 0);
-
- gint i;
- GEnumClass *klass = g_type_class_ref (XFMPC_TYPE_SONG_FORMAT);
- for (i = 0; i < klass->n_values; i++)
- {
- gtk_combo_box_append_text (GTK_COMBO_BOX (priv->combo_format),
- _(klass->values[i].value_nick));
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combo_format), song_format);
- g_type_class_unref (klass);
-
- gtk_container_add (GTK_CONTAINER (vbox2), hbox);
-
- hbox = gtk_hbox_new (FALSE, 2);
-
- label = gtk_label_new (_("Custom format:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- priv->entry_format = gtk_entry_new ();
- gtk_entry_set_width_chars (GTK_ENTRY (priv->entry_format), 15);
- gtk_entry_set_max_length (GTK_ENTRY (priv->entry_format), 30);
- gtk_entry_set_text (GTK_ENTRY (priv->entry_format), format_custom);
- gtk_box_pack_start (GTK_BOX (hbox), priv->entry_format, TRUE, TRUE, 0);
- g_signal_connect (priv->entry_format, "changed",
- G_CALLBACK (cb_format_entry_changed), dialog);
- g_signal_connect (priv->combo_format, "changed",
- G_CALLBACK (cb_format_combo_changed), dialog);
- gtk_widget_set_sensitive (priv->entry_format,
- song_format == XFMPC_SONG_FORMAT_CUSTOM);
-
- gtk_container_add (GTK_CONTAINER (vbox2), hbox);
-
- label = gtk_label_new (_("Available parameters:"));
- gtk_container_add (GTK_CONTAINER (vbox2), label);
-
- table = gtk_table_new (4, 6, TRUE);
-
- PangoAttrList *attrs = pango_attr_list_new ();
- PangoAttribute *attr = pango_attr_scale_new (PANGO_SCALE_SMALL);
- pango_attr_list_insert (attrs, attr);
-
- label = gtk_label_new (_("%a: Artist"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 3, 0, 1);
- label = gtk_label_new (_("%A: Album"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 6, 0, 1);
-
- label = gtk_label_new (_("%d: Date"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 3, 1, 2);
- label = gtk_label_new (_("%D: Disc"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 6, 1, 2);
-
- label = gtk_label_new (_("%f: File"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 3, 2, 3);
- label = gtk_label_new (_("%g: Genre"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 6, 2, 3);
-
- label = gtk_label_new (_("%t: Title"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 3, 3, 4);
- label = gtk_label_new (_("%T: Track"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 6, 3, 4);
-
- pango_attr_list_unref (attrs);
-
- gtk_container_add (GTK_CONTAINER (vbox2), table);
-
- gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
-
- g_free (host);
- g_free (passwd);
- g_free (format_custom);
+static void _xfmpc_preferences_dialog_cb_entry_custom_changed_gtk_editable_changed (GtkEntry* _sender, gpointer self) {
+ xfmpc_preferences_dialog_cb_entry_custom_changed (self, _sender);
}
-static void
-xfmpc_preferences_dialog_finalize (GObject *object)
-{
- XfmpcPreferencesDialog *dialog = XFMPC_PREFERENCES_DIALOG (object);
- g_object_unref (G_OBJECT (dialog->preferences));
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
-static void
-xfmpc_preferences_dialog_response (GtkDialog *dialog,
- gint response)
-{
- XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
- XfmpcPreferences *preferences = XFMPC_PREFERENCES_DIALOG (dialog)->preferences;
-
- if (priv->format_timeout > 0)
- {
- g_source_remove (priv->format_timeout);
-
- g_object_set (G_OBJECT (preferences),
- "song-format-custom", gtk_entry_get_text (GTK_ENTRY (priv->entry_format)),
- NULL);
- }
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
+static void _xfmpc_preferences_dialog_cb_response_gtk_dialog_response (XfmpcPreferencesDialog* _sender, gint response_id, gpointer self) {
+ xfmpc_preferences_dialog_cb_response (self, _sender, response_id);
}
-
-GtkWidget*
-xfmpc_preferences_dialog_new ()
-{
- return g_object_new (XFMPC_TYPE_PREFERENCES_DIALOG, NULL);
+static GObject * xfmpc_preferences_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ XfmpcPreferencesDialogClass * klass;
+ GObjectClass * parent_class;
+ XfmpcPreferencesDialog * self;
+ klass = XFMPC_PREFERENCES_DIALOG_CLASS (g_type_class_peek (XFMPC_TYPE_PREFERENCES_DIALOG));
+ parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = XFMPC_PREFERENCES_DIALOG (obj);
+ {
+ GtkNotebook* notebook;
+ GtkVBox* vbox;
+ GtkLabel* label;
+ GtkVBox* vbox2;
+ GtkWidget* _tmp0;
+ GtkWidget* frame;
+ GtkCheckButton* _tmp1;
+ GtkVBox* _tmp2;
+ GtkHBox* hbox;
+ GtkLabel* _tmp3;
+ GtkEntry* _tmp4;
+ GtkLabel* _tmp5;
+ GtkSpinButton* _tmp6;
+ GtkHBox* _tmp7;
+ GtkLabel* _tmp8;
+ GtkEntry* _tmp9;
+ GtkButton* button;
+ GtkVBox* _tmp10;
+ GtkLabel* _tmp11;
+ GtkVBox* _tmp12;
+ GtkWidget* _tmp14;
+ GtkWidget* _tmp13;
+ GtkCheckButton* _tmp15;
+ GtkVBox* _tmp16;
+ GtkWidget* _tmp18;
+ GtkWidget* _tmp17;
+ GtkHBox* _tmp19;
+ GtkLabel* _tmp20;
+ GtkComboBox* _tmp21;
+ GtkHBox* _tmp22;
+ GtkLabel* _tmp23;
+ GtkEntry* _tmp24;
+ GtkLabel* _tmp25;
+ GtkTable* table;
+ PangoAttrList* attrs;
+ GtkLabel* _tmp26;
+ GtkLabel* _tmp27;
+ GtkLabel* _tmp28;
+ GtkLabel* _tmp29;
+ GtkLabel* _tmp30;
+ GtkLabel* _tmp31;
+ GtkLabel* _tmp32;
+ GtkLabel* _tmp33;
+ xfce_textdomain (self->priv->gettext_package, self->priv->localedir, "UTF-8");
+ gtk_dialog_set_has_separator ((GtkDialog*) self, TRUE);
+ gtk_window_set_skip_taskbar_hint ((GtkWindow*) self, TRUE);
+ gtk_window_set_icon_name ((GtkWindow*) self, "stock_volume");
+ gtk_window_set_resizable ((GtkWindow*) self, FALSE);
+ gtk_window_set_title ((GtkWindow*) self, "Xfmpc Preferences");
+ self->priv->preferences = xfmpc_preferences_get ();
+ notebook = g_object_ref_sink ((GtkNotebook*) gtk_notebook_new ());
+ gtk_container_set_border_width ((GtkContainer*) notebook, (guint) 6);
+ gtk_box_pack_start ((GtkBox*) ((GtkDialog*) self)->vbox, (GtkWidget*) notebook, TRUE, TRUE, (guint) 0);
+ /* Mpd Settings */
+ vbox = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 6));
+ gtk_container_set_border_width ((GtkContainer*) vbox, (guint) 6);
+ label = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("MPD")));
+ gtk_notebook_append_page (notebook, (GtkWidget*) vbox, (GtkWidget*) label);
+ vbox2 = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 6));
+ _tmp0 = NULL;
+ frame = (_tmp0 = xfce_create_framebox_with_content (_ ("Connection"), (GtkWidget*) vbox2), (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ gtk_box_pack_start ((GtkBox*) vbox, frame, FALSE, FALSE, (guint) 0);
+ _tmp1 = NULL;
+ self->priv->entry_use_defaults = (_tmp1 = g_object_ref_sink ((GtkCheckButton*) gtk_check_button_new_with_mnemonic (_ ("Use _default system settings"))), (self->priv->entry_use_defaults == NULL) ? NULL : (self->priv->entry_use_defaults = (g_object_unref (self->priv->entry_use_defaults), NULL)), _tmp1);
+ gtk_widget_set_tooltip_text ((GtkWidget*) self->priv->entry_use_defaults, _ ("If checked, Xfmpc will try to read the environment variables MPD_HOST and MPD_PORT otherwise it will use localhost"));
+ gtk_toggle_button_set_active ((GtkToggleButton*) self->priv->entry_use_defaults, xfmpc_preferences_get_mpd_use_defaults (self->priv->preferences));
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) self->priv->entry_use_defaults, FALSE, FALSE, (guint) 0);
+ _tmp2 = NULL;
+ self->priv->mpd_vbox = (_tmp2 = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 6)), (self->priv->mpd_vbox == NULL) ? NULL : (self->priv->mpd_vbox = (g_object_unref (self->priv->mpd_vbox), NULL)), _tmp2);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) self->priv->mpd_vbox, FALSE, FALSE, (guint) 0);
+ g_signal_connect_object ((GtkToggleButton*) self->priv->entry_use_defaults, "toggled", (GCallback) _xfmpc_preferences_dialog_cb_use_defaults_toggled_gtk_toggle_button_toggled, self, 0);
+ gtk_widget_set_sensitive ((GtkWidget*) self->priv->mpd_vbox, !gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->entry_use_defaults));
+ hbox = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 2));
+ gtk_box_pack_start ((GtkBox*) self->priv->mpd_vbox, (GtkWidget*) hbox, FALSE, FALSE, (guint) 0);
+ _tmp3 = NULL;
+ label = (_tmp3 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Hostname:"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp3);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 0);
+ _tmp4 = NULL;
+ self->priv->entry_host = (_tmp4 = g_object_ref_sink ((GtkEntry*) gtk_entry_new ()), (self->priv->entry_host == NULL) ? NULL : (self->priv->entry_host = (g_object_unref (self->priv->entry_host), NULL)), _tmp4);
+ gtk_entry_set_width_chars (self->priv->entry_host, 15);
+ gtk_entry_set_text (self->priv->entry_host, xfmpc_preferences_get_mpd_hostname (self->priv->preferences));
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) self->priv->entry_host, TRUE, TRUE, (guint) 0);
+ _tmp5 = NULL;
+ label = (_tmp5 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Port:"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp5);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 0);
+ _tmp6 = NULL;
+ self->priv->entry_port = (_tmp6 = g_object_ref_sink ((GtkSpinButton*) gtk_spin_button_new_with_range ((double) 0, (double) 65536, (double) 1)), (self->priv->entry_port == NULL) ? NULL : (self->priv->entry_port = (g_object_unref (self->priv->entry_port), NULL)), _tmp6);
+ gtk_spin_button_set_digits (self->priv->entry_port, (guint) 0);
+ gtk_spin_button_set_value (self->priv->entry_port, (double) xfmpc_preferences_get_mpd_port (self->priv->preferences));
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) self->priv->entry_port, TRUE, TRUE, (guint) 0);
+ _tmp7 = NULL;
+ hbox = (_tmp7 = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 2)), (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL)), _tmp7);
+ gtk_box_pack_start ((GtkBox*) self->priv->mpd_vbox, (GtkWidget*) hbox, FALSE, FALSE, (guint) 0);
+ _tmp8 = NULL;
+ label = (_tmp8 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Password:"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp8);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 0);
+ _tmp9 = NULL;
+ self->priv->entry_passwd = (_tmp9 = g_object_ref_sink ((GtkEntry*) gtk_entry_new ()), (self->priv->entry_passwd == NULL) ? NULL : (self->priv->entry_passwd = (g_object_unref (self->priv->entry_passwd), NULL)), _tmp9);
+ gtk_entry_set_visibility (self->priv->entry_passwd, FALSE);
+ if (xfmpc_preferences_get_mpd_password (self->priv->preferences) != NULL) {
+ gtk_entry_set_text (self->priv->entry_passwd, xfmpc_preferences_get_mpd_password (self->priv->preferences));
+ }
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) self->priv->entry_passwd, TRUE, TRUE, (guint) 0);
+ button = g_object_ref_sink ((GtkButton*) gtk_button_new_from_stock (GTK_STOCK_APPLY));
+ g_signal_connect_object (button, "clicked", (GCallback) _xfmpc_preferences_dialog_cb_update_mpd_gtk_button_clicked, self, 0);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) button, TRUE, TRUE, (guint) 0);
+ /* Display */
+ _tmp10 = NULL;
+ vbox = (_tmp10 = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 6)), (vbox == NULL) ? NULL : (vbox = (g_object_unref (vbox), NULL)), _tmp10);
+ gtk_container_set_border_width ((GtkContainer*) vbox, (guint) 6);
+ _tmp11 = NULL;
+ label = (_tmp11 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Appearance"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp11);
+ gtk_notebook_append_page (notebook, (GtkWidget*) vbox, (GtkWidget*) label);
+ _tmp12 = NULL;
+ vbox2 = (_tmp12 = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 6)), (vbox2 == NULL) ? NULL : (vbox2 = (g_object_unref (vbox2), NULL)), _tmp12);
+ _tmp14 = NULL;
+ _tmp13 = NULL;
+ frame = (_tmp14 = (_tmp13 = xfce_create_framebox_with_content (_ ("Statusbar"), (GtkWidget*) vbox2), (_tmp13 == NULL) ? NULL : g_object_ref (_tmp13)), (frame == NULL) ? NULL : (frame = (g_object_unref (frame), NULL)), _tmp14);
+ gtk_box_pack_start ((GtkBox*) vbox, frame, FALSE, FALSE, (guint) 0);
+ _tmp15 = NULL;
+ self->priv->show_statusbar = (_tmp15 = g_object_ref_sink ((GtkCheckButton*) gtk_check_button_new_with_mnemonic (_ ("Show _stastusbar"))), (self->priv->show_statusbar == NULL) ? NULL : (self->priv->show_statusbar = (g_object_unref (self->priv->show_statusbar), NULL)), _tmp15);
+ gtk_toggle_button_set_active ((GtkToggleButton*) self->priv->show_statusbar, xfmpc_preferences_get_show_statusbar (self->priv->preferences));
+ g_signal_connect_object ((GtkToggleButton*) self->priv->show_statusbar, "toggled", (GCallback) _xfmpc_preferences_dialog_cb_show_statusbar_toggled_gtk_toggle_button_toggled, self, 0);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) self->priv->show_statusbar, FALSE, FALSE, (guint) 0);
+ _tmp16 = NULL;
+ vbox2 = (_tmp16 = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 6)), (vbox2 == NULL) ? NULL : (vbox2 = (g_object_unref (vbox2), NULL)), _tmp16);
+ _tmp18 = NULL;
+ _tmp17 = NULL;
+ frame = (_tmp18 = (_tmp17 = xfce_create_framebox_with_content (_ ("Song Format"), (GtkWidget*) vbox2), (_tmp17 == NULL) ? NULL : g_object_ref (_tmp17)), (frame == NULL) ? NULL : (frame = (g_object_unref (frame), NULL)), _tmp18);
+ gtk_box_pack_start ((GtkBox*) vbox, frame, FALSE, FALSE, (guint) 0);
+ _tmp19 = NULL;
+ hbox = (_tmp19 = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 2)), (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL)), _tmp19);
+ _tmp20 = NULL;
+ label = (_tmp20 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Song Format:"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp20);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 0);
+ _tmp21 = NULL;
+ self->priv->combo_format = (_tmp21 = g_object_ref_sink ((GtkComboBox*) gtk_combo_box_new_text ()), (self->priv->combo_format == NULL) ? NULL : (self->priv->combo_format = (g_object_unref (self->priv->combo_format), NULL)), _tmp21);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) self->priv->combo_format, TRUE, TRUE, (guint) 0);
+ gtk_combo_box_append_text (self->priv->combo_format, _ ("Title"));
+ gtk_combo_box_append_text (self->priv->combo_format, _ ("Album - Title"));
+ gtk_combo_box_append_text (self->priv->combo_format, _ ("Artist - Title"));
+ gtk_combo_box_append_text (self->priv->combo_format, _ ("Artist - Title (Date)"));
+ 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_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);
+ _tmp23 = NULL;
+ label = (_tmp23 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Custom format:"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp23);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 0);
+ _tmp24 = NULL;
+ self->priv->entry_custom = (_tmp24 = g_object_ref_sink ((GtkEntry*) gtk_entry_new ()), (self->priv->entry_custom == NULL) ? NULL : (self->priv->entry_custom = (g_object_unref (self->priv->entry_custom), NULL)), _tmp24);
+ gtk_entry_set_width_chars (self->priv->entry_custom, 15);
+ gtk_entry_set_max_length (self->priv->entry_custom, 30);
+ gtk_entry_set_text (self->priv->entry_custom, xfmpc_preferences_get_song_format_custom (self->priv->preferences));
+ gtk_widget_set_sensitive ((GtkWidget*) self->priv->entry_custom, gtk_combo_box_get_active (self->priv->combo_format) == 6);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) self->priv->entry_custom, TRUE, TRUE, (guint) 0);
+ g_signal_connect_object (self->priv->combo_format, "changed", (GCallback) _xfmpc_preferences_dialog_cb_combo_format_changed_gtk_combo_box_changed, self, 0);
+ g_signal_connect_object ((GtkEditable*) self->priv->entry_custom, "changed", (GCallback) _xfmpc_preferences_dialog_cb_entry_custom_changed_gtk_editable_changed, self, 0);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) hbox, TRUE, TRUE, (guint) 0);
+ _tmp25 = NULL;
+ label = (_tmp25 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Available parameters:"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp25);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) label, TRUE, TRUE, (guint) 0);
+ table = g_object_ref_sink ((GtkTable*) gtk_table_new ((guint) 4, (guint) 6, TRUE));
+ attrs = pango_attr_list_new ();
+ pango_attr_list_insert (attrs, pango_attr_scale_new ((double) PANGO_SCALE_SMALL));
+ _tmp26 = NULL;
+ label = (_tmp26 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("%a: Artist"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp26);
+ gtk_label_set_attributes (label, attrs);
+ gtk_misc_set_alignment ((GtkMisc*) label, (float) 0, (float) 0.5);
+ gtk_table_attach_defaults (table, (GtkWidget*) label, (guint) 1, (guint) 3, (guint) 0, (guint) 1);
+ _tmp27 = NULL;
+ label = (_tmp27 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("%A: Album"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp27);
+ gtk_label_set_attributes (label, attrs);
+ gtk_misc_set_alignment ((GtkMisc*) label, (float) 0, (float) 0.5);
+ gtk_table_attach_defaults (table, (GtkWidget*) label, (guint) 4, (guint) 6, (guint) 0, (guint) 1);
+ _tmp28 = NULL;
+ label = (_tmp28 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("%d: Date"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp28);
+ gtk_label_set_attributes (label, attrs);
+ gtk_misc_set_alignment ((GtkMisc*) label, (float) 0, (float) 0.5);
+ gtk_table_attach_defaults (table, (GtkWidget*) label, (guint) 1, (guint) 3, (guint) 1, (guint) 2);
+ _tmp29 = NULL;
+ label = (_tmp29 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("%D: Disc"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp29);
+ gtk_label_set_attributes (label, attrs);
+ gtk_misc_set_alignment ((GtkMisc*) label, (float) 0, (float) 0.5);
+ gtk_table_attach_defaults (table, (GtkWidget*) label, (guint) 4, (guint) 6, (guint) 1, (guint) 2);
+ _tmp30 = NULL;
+ label = (_tmp30 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("%f: File"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp30);
+ gtk_label_set_attributes (label, attrs);
+ gtk_misc_set_alignment ((GtkMisc*) label, (float) 0, (float) 0.5);
+ gtk_table_attach_defaults (table, (GtkWidget*) label, (guint) 1, (guint) 3, (guint) 2, (guint) 3);
+ _tmp31 = NULL;
+ label = (_tmp31 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("%g: Genre"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp31);
+ gtk_label_set_attributes (label, attrs);
+ gtk_misc_set_alignment ((GtkMisc*) label, (float) 0, (float) 0.5);
+ gtk_table_attach_defaults (table, (GtkWidget*) label, (guint) 4, (guint) 6, (guint) 2, (guint) 3);
+ _tmp32 = NULL;
+ label = (_tmp32 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("%t: Title"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp32);
+ gtk_label_set_attributes (label, attrs);
+ gtk_misc_set_alignment ((GtkMisc*) label, (float) 0, (float) 0.5);
+ gtk_table_attach_defaults (table, (GtkWidget*) label, (guint) 1, (guint) 3, (guint) 3, (guint) 4);
+ _tmp33 = NULL;
+ label = (_tmp33 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("%T: Track"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp33);
+ gtk_label_set_attributes (label, attrs);
+ gtk_misc_set_alignment ((GtkMisc*) label, (float) 0, (float) 0.5);
+ gtk_table_attach_defaults (table, (GtkWidget*) label, (guint) 4, (guint) 6, (guint) 3, (guint) 4);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) table, TRUE, TRUE, (guint) 0);
+ gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_CLOSE, (gint) GTK_RESPONSE_CLOSE);
+ gtk_widget_show_all ((GtkWidget*) self);
+ /* Signals */
+ g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) _xfmpc_preferences_dialog_cb_response_gtk_dialog_response, self, 0);
+ (notebook == NULL) ? NULL : (notebook = (g_object_unref (notebook), NULL));
+ (vbox == NULL) ? NULL : (vbox = (g_object_unref (vbox), NULL));
+ (label == NULL) ? NULL : (label = (g_object_unref (label), NULL));
+ (vbox2 == NULL) ? NULL : (vbox2 = (g_object_unref (vbox2), NULL));
+ (frame == NULL) ? NULL : (frame = (g_object_unref (frame), NULL));
+ (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL));
+ (button == NULL) ? NULL : (button = (g_object_unref (button), NULL));
+ (table == NULL) ? NULL : (table = (g_object_unref (table), NULL));
+ (attrs == NULL) ? NULL : (attrs = (pango_attr_list_unref (attrs), NULL));
+ }
+ return obj;
}
-static void
-cb_use_defaults_toggled (GtkToggleButton *button,
- GtkWidget *widget)
-{
- gboolean sensitive;
- sensitive = gtk_toggle_button_get_active (button);
- gtk_widget_set_sensitive (widget, !sensitive);
-}
-static void
-cb_update_mpd (GtkButton *button,
- XfmpcPreferencesDialog *dialog)
-{
- XfmpcPreferencesDialogPrivate *priv = dialog->priv;
- XfmpcMpdclient *mpdclient = xfmpc_mpdclient_get ();
-
- g_object_set (G_OBJECT (dialog->preferences),
- "mpd-hostname", gtk_entry_get_text (GTK_ENTRY (priv->entry_host)),
- "mpd-port", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->entry_port)),
- "mpd-password", gtk_entry_get_text (GTK_ENTRY (priv->entry_passwd)),
- "mpd-use-defaults", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->entry_use_defaults)),
- NULL);
-
- xfmpc_mpdclient_disconnect (mpdclient);
- xfmpc_mpdclient_connect (mpdclient);
+static void xfmpc_preferences_dialog_class_init (XfmpcPreferencesDialogClass * klass) {
+ xfmpc_preferences_dialog_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (XfmpcPreferencesDialogPrivate));
+ G_OBJECT_CLASS (klass)->constructor = xfmpc_preferences_dialog_constructor;
+ G_OBJECT_CLASS (klass)->finalize = xfmpc_preferences_dialog_finalize;
}
-static void
-cb_show_statusbar_toggled (GtkToggleButton *button,
- XfmpcPreferencesDialog *dialog)
-{
- XfmpcPreferencesDialogPrivate *priv = dialog->priv;
- g_object_set (G_OBJECT (dialog->preferences),
- "show-statusbar", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->statusbar_button)),
- NULL);
+static void xfmpc_preferences_dialog_instance_init (XfmpcPreferencesDialog * self) {
+ self->priv = XFMPC_PREFERENCES_DIALOG_GET_PRIVATE (self);
+ self->priv->gettext_package = g_strdup (GETTEXT_PACKAGE);
+ self->priv->localedir = g_strdup (PACKAGE_LOCALE_DIR);
}
-static void
-cb_format_entry_activated (XfmpcPreferencesDialog *dialog)
-{
- XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
- const gchar *entry_text = gtk_entry_get_text (GTK_ENTRY (priv->entry_format));
- if (entry_text[0] == '\0')
- {
- priv->is_format = FALSE;
- }
-
- g_object_set (G_OBJECT (dialog->preferences),
- "song-format-custom", gtk_entry_get_text (GTK_ENTRY (priv->entry_format)),
- NULL);
+static void xfmpc_preferences_dialog_finalize (GObject* obj) {
+ XfmpcPreferencesDialog * self;
+ self = XFMPC_PREFERENCES_DIALOG (obj);
+ self->priv->gettext_package = (g_free (self->priv->gettext_package), NULL);
+ self->priv->localedir = (g_free (self->priv->localedir), NULL);
+ (self->priv->entry_use_defaults == NULL) ? NULL : (self->priv->entry_use_defaults = (g_object_unref (self->priv->entry_use_defaults), NULL));
+ (self->priv->entry_host == NULL) ? NULL : (self->priv->entry_host = (g_object_unref (self->priv->entry_host), NULL));
+ (self->priv->entry_passwd == NULL) ? NULL : (self->priv->entry_passwd = (g_object_unref (self->priv->entry_passwd), NULL));
+ (self->priv->entry_port == NULL) ? NULL : (self->priv->entry_port = (g_object_unref (self->priv->entry_port), NULL));
+ (self->priv->show_statusbar == NULL) ? NULL : (self->priv->show_statusbar = (g_object_unref (self->priv->show_statusbar), NULL));
+ (self->priv->combo_format == NULL) ? NULL : (self->priv->combo_format = (g_object_unref (self->priv->combo_format), NULL));
+ (self->priv->entry_custom == NULL) ? NULL : (self->priv->entry_custom = (g_object_unref (self->priv->entry_custom), NULL));
+ (self->priv->mpd_vbox == NULL) ? NULL : (self->priv->mpd_vbox = (g_object_unref (self->priv->mpd_vbox), NULL));
+ G_OBJECT_CLASS (xfmpc_preferences_dialog_parent_class)->finalize (obj);
}
-static void
-cb_format_entry_changed (GtkEntry *entry,
- XfmpcPreferencesDialog *dialog)
-{
- XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
- if (priv->format_timeout > 0)
- g_source_remove (priv->format_timeout);
-
- priv->format_timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 1,
- (GSourceFunc)timeout_format, dialog,
- (GDestroyNotify)timeout_format_destroy);
+GType xfmpc_preferences_dialog_get_type (void) {
+ static GType xfmpc_preferences_dialog_type_id = 0;
+ if (xfmpc_preferences_dialog_type_id == 0) {
+ static const GTypeInfo g_define_type_info = { sizeof (XfmpcPreferencesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xfmpc_preferences_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XfmpcPreferencesDialog), 0, (GInstanceInitFunc) xfmpc_preferences_dialog_instance_init, NULL };
+ xfmpc_preferences_dialog_type_id = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, "XfmpcPreferencesDialog", &g_define_type_info, 0);
+ }
+ return xfmpc_preferences_dialog_type_id;
}
-static void
-cb_format_combo_changed (GtkComboBox *combo,
- XfmpcPreferencesDialog *dialog)
-{
- XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
- XfmpcSongFormat song_format;
- song_format = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->combo_format));
- g_object_set (G_OBJECT (dialog->preferences), "song-format", song_format, NULL);
- gtk_widget_set_sensitive (priv->entry_format, song_format == XFMPC_SONG_FORMAT_CUSTOM);
-}
-static gboolean
-timeout_format (XfmpcPreferencesDialog *dialog)
-{
- cb_format_entry_activated (dialog);
- return FALSE;
-}
-
-static void
-timeout_format_destroy (XfmpcPreferencesDialog *dialog)
-{
- XfmpcPreferencesDialogPrivate *priv = XFMPC_PREFERENCES_DIALOG (dialog)->priv;
- priv->format_timeout = 0;
-}
-
Added: xfmpc/trunk/src/preferences-dialog.vala
===================================================================
--- xfmpc/trunk/src/preferences-dialog.vala (rev 0)
+++ xfmpc/trunk/src/preferences-dialog.vala 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,288 @@
+/*
+ * 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 PreferencesDialog : Xfce.TitledDialog {
+
+ private unowned Xfmpc.Preferences preferences;
+
+ private string gettext_package = Config.GETTEXT_PACKAGE;
+ private string localedir = Config.PACKAGE_LOCALE_DIR;
+
+ private CheckButton entry_use_defaults;
+ private Entry entry_host;
+ private Entry entry_passwd;
+ private SpinButton entry_port;
+ private CheckButton show_statusbar;
+ private ComboBox combo_format;
+ private Entry entry_custom;
+
+ private uint format_timeout;
+
+ private VBox mpd_vbox;
+
+ construct {
+ Xfce.textdomain (gettext_package, localedir, "UTF-8");
+
+ has_separator = true;
+ skip_taskbar_hint = true;
+ icon_name = "stock_volume";
+ resizable = false;
+ title = "Xfmpc Preferences";
+
+ preferences = Xfmpc.Preferences.get ();
+
+ var notebook = new Notebook ();
+ notebook.set_border_width (6);
+ vbox.pack_start (notebook, true, true, 0);
+
+ /* Mpd Settings */
+ var vbox = new VBox (false, 6);
+ vbox.set_border_width (6);
+ var label = new Label (_("MPD"));
+ notebook.append_page (vbox, label);
+
+ var vbox2 = new VBox (false, 6);
+ var frame = Xfce.create_framebox_with_content (_("Connection"), vbox2);
+ vbox.pack_start (frame, false, false, 0);
+
+ entry_use_defaults = new CheckButton.with_mnemonic (_("Use _default system settings"));
+ entry_use_defaults.set_tooltip_text (_("If checked, Xfmpc will try to read the environment variables MPD_HOST and MPD_PORT otherwise it will use localhost"));
+ entry_use_defaults.set_active (preferences.mpd_use_defaults);
+
+ vbox2.pack_start (entry_use_defaults, false, false, 0);
+
+ mpd_vbox = new VBox (false, 6);
+ vbox2.pack_start (mpd_vbox, false, false, 0);
+
+ entry_use_defaults.toggled += cb_use_defaults_toggled;
+ mpd_vbox.set_sensitive (!entry_use_defaults.get_active ());
+
+ var hbox = new HBox (false, 2);
+ mpd_vbox.pack_start (hbox, false, false, 0);
+
+ label = new Label (_("Hostname:"));
+ hbox.pack_start (label, false, false, 0);
+ entry_host = new Entry ();
+ entry_host.set_width_chars (15);
+ entry_host.set_text (preferences.mpd_hostname);
+ hbox.pack_start (entry_host, true, true, 0);
+
+ label = new Label (_("Port:"));
+ hbox.pack_start (label, false, false, 0);
+ entry_port = new SpinButton.with_range (0, 65536, 1);
+ entry_port.set_digits (0);
+ entry_port.set_value (preferences.mpd_port);
+ hbox.pack_start (entry_port, true, true, 0);
+
+ hbox = new HBox (false, 2);
+ mpd_vbox.pack_start (hbox, false, false, 0);
+
+ label = new Label (_("Password:"));
+ hbox.pack_start (label, false, false, 0);
+ entry_passwd = new Entry ();
+ entry_passwd.set_visibility (false);
+ if (preferences.mpd_password != null)
+ entry_passwd.set_text (preferences.mpd_password);
+ hbox.pack_start (entry_passwd, true, true, 0);
+
+ var button = new Button.from_stock (Gtk.STOCK_APPLY);
+ button.clicked += cb_update_mpd;
+ vbox2.pack_start (button, true, true, 0);
+
+ /* Display */
+ vbox = new VBox (false, 6);
+ vbox.set_border_width (6);
+ label = new Label (_("Appearance"));
+ notebook.append_page (vbox, label);
+
+ vbox2 = new VBox (false, 6);
+ frame = Xfce.create_framebox_with_content (_("Statusbar"), vbox2);
+ vbox.pack_start (frame, false, false, 0);
+
+ show_statusbar = new CheckButton.with_mnemonic (_("Show _stastusbar"));
+ show_statusbar.set_active (preferences.show_statusbar);
+ show_statusbar.toggled += cb_show_statusbar_toggled;
+ vbox2.pack_start (show_statusbar, false, false, 0);
+
+ vbox2 = new VBox (false, 6);
+ frame = Xfce.create_framebox_with_content (_("Song Format"), vbox2);
+ vbox.pack_start (frame, false, false, 0);
+
+ hbox = new HBox (false, 2);
+
+ label = new Label (_("Song Format:"));
+ hbox.pack_start (label, false, false, 0);
+
+ combo_format = new ComboBox.text ();
+ hbox.pack_start (combo_format, true, true, 0);
+
+ combo_format.append_text (_("Title"));
+ combo_format.append_text (_("Album - Title"));
+ combo_format.append_text (_("Artist - Title"));
+ combo_format.append_text (_("Artist - Title (Date)"));
+ combo_format.append_text (_("Artist - Album - Title"));
+ combo_format.append_text (_("Artist - Album - Track. Title"));
+ combo_format.append_text (_("Custom..."));
+
+ combo_format.set_active (preferences.song_format);
+
+ vbox2.pack_start (hbox, true, true, 0);
+
+ hbox = new HBox (false, 2);
+
+ label = new Label (_("Custom format:"));
+ hbox.pack_start (label, false, false, 0);
+
+ entry_custom = new Entry ();
+ entry_custom.set_width_chars (15);
+ entry_custom.set_max_length (30);
+ entry_custom.set_text (preferences.song_format_custom);
+ entry_custom.set_sensitive (combo_format.get_active () == 6);
+ hbox.pack_start (entry_custom, true, true, 0);
+
+ combo_format.changed += cb_combo_format_changed;
+ entry_custom.changed += cb_entry_custom_changed;
+
+ vbox2.pack_start (hbox, true, true, 0);
+
+ label = new Label (_("Available parameters:"));
+ vbox2.pack_start (label, true, true, 0);
+
+ var table = new Table (4, 6, true);
+
+ var attrs = new Pango.AttrList ();
+ attrs.insert (Pango.attr_scale_new ((double) Pango.Scale.SMALL));
+
+ label = new Label (_("%a: Artist"));
+ label.set_attributes (attrs);
+ label.set_alignment (0, (float) 0.5);
+ table.attach_defaults (label, 1, 3, 0, 1);
+ label = new Label (_("%A: Album"));
+ label.set_attributes (attrs);
+ label.set_alignment (0, (float) 0.5);
+ table.attach_defaults (label, 4, 6, 0, 1);
+
+ label = new Label (_("%d: Date"));
+ label.set_attributes (attrs);
+ label.set_alignment (0, (float) 0.5);
+ table.attach_defaults (label, 1, 3, 1, 2);
+ label = new Label (_("%D: Disc"));
+ label.set_attributes (attrs);
+ label.set_alignment (0, (float) 0.5);
+ table.attach_defaults (label, 4, 6, 1, 2);
+
+ label = new Label (_("%f: File"));
+ label.set_attributes (attrs);
+ label.set_alignment (0, (float) 0.5);
+ table.attach_defaults (label, 1, 3, 2, 3);
+ label = new Label (_("%g: Genre"));
+ label.set_attributes (attrs);
+ label.set_alignment (0, (float) 0.5);
+ table.attach_defaults (label, 4, 6, 2, 3);
+
+ label = new Label (_("%t: Title"));
+ label.set_attributes (attrs);
+ label.set_alignment (0, (float) 0.5);
+ table.attach_defaults (label, 1, 3, 3, 4);
+ label = new Label (_("%T: Track"));
+ label.set_attributes (attrs);
+ label.set_alignment (0, (float) 0.5);
+ table.attach_defaults (label, 4, 6, 3, 4);
+
+ vbox2.pack_start (table, true, true, 0);
+
+ add_button (STOCK_CLOSE, ResponseType.CLOSE);
+
+ show_all ();
+
+ /* Signals */
+ response += cb_response;
+ }
+
+ /*
+ * Signal callbacks
+ */
+
+ private void cb_response (PreferencesDialog source, int response) {
+ switch (response) {
+ case ResponseType.CLOSE:
+ destroy ();
+ break;
+ }
+ }
+
+ private void cb_use_defaults_toggled (CheckButton source) {
+ mpd_vbox.set_sensitive (!entry_use_defaults.get_active ());
+ }
+
+ private void cb_update_mpd (Button source) {
+ unowned Xfmpc.Mpdclient mpdclient = Xfmpc.Mpdclient.get ();
+ string mpd_hostname = entry_host.get_text ();
+ string mpd_password = entry_passwd.get_text ();
+
+ preferences.mpd_hostname = mpd_hostname;
+ preferences.mpd_port = entry_port.get_value_as_int ();
+ preferences.mpd_password = mpd_password;
+ preferences.mpd_use_defaults = entry_use_defaults.get_active ();
+
+ mpdclient.disconnect ();
+ mpdclient.connect ();
+ }
+
+ private void cb_show_statusbar_toggled (CheckButton source) {
+ preferences.show_statusbar = show_statusbar.get_active ();
+ }
+
+ private void cb_combo_format_changed (ComboBox source) {
+
+ switch (combo_format.get_active ())
+ {
+ case 0: preferences.song_format = Xfmpc.SongFormat.TITLE; break;
+ case 1: preferences.song_format = Xfmpc.SongFormat.ALBUM_TITLE; break;
+ case 2: preferences.song_format = Xfmpc.SongFormat.ARTIST_TITLE; break;
+ case 3: preferences.song_format = Xfmpc.SongFormat.ARTIST_TITLE_DATE; break;
+ case 4: preferences.song_format = Xfmpc.SongFormat.ARTIST_ALBUM_TITLE; break;
+ case 5: preferences.song_format = Xfmpc.SongFormat.ARTIST_ALBUM_TRACK_TITLE; break;
+ case 6: preferences.song_format = Xfmpc.SongFormat.CUSTOM; break;
+ default: preferences.song_format = Xfmpc.SongFormat.TITLE; break;
+ }
+
+ entry_custom.set_sensitive (combo_format.get_active () == 6);
+ }
+
+ private void cb_entry_custom_changed (Entry source) {
+ if (format_timeout > 0)
+ Source.remove (format_timeout);
+
+ format_timeout = Timeout.add_seconds_full (Priority.DEFAULT, 1, timeout_format);
+ }
+
+ private bool timeout_format () {
+ string custom_format = entry_custom.get_text ();
+ preferences.song_format_custom = custom_format;
+ return false;
+ }
+ }
+}
+
+/* vi:set ts=8 sw=8: */
Modified: xfmpc/trunk/src/preferences.c
===================================================================
--- xfmpc/trunk/src/preferences.c 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/preferences.c 2009-04-23 11:11:39 UTC (rev 7280)
@@ -258,7 +258,7 @@
"Song Format",
XFMPC_TYPE_SONG_FORMAT,
XFMPC_SONG_FORMAT_ARTIST_TITLE,
- G_PARAM_CONSTRUCT|G_PARAM_READWRITE));
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SONG_FORMAT_CUSTOM,
@@ -450,3 +450,202 @@
return xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "xfce4/xfmpcrc", FALSE);
}
+
+
+gint
+xfmpc_preferences_get_last_window_posx (XfmpcPreferences *preferences)
+{
+ gint dst;
+ g_object_get (G_OBJECT (preferences), "last-window-posx", &dst, NULL);
+ return dst;
+}
+
+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;
+}
+
+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;
+}
+
+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;
+}
+
+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;
+}
+
+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;
+}
+
+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;
+}
+
+gchar *
+xfmpc_preferences_get_song_format_custom (XfmpcPreferences *preferences)
+{
+ gchar *dst;
+ g_object_get (G_OBJECT (preferences), "song-format-custom", &dst, NULL);
+ return dst;
+}
+
+
+
+void
+xfmpc_preferences_set_last_window_posx (XfmpcPreferences *preferences, gint src)
+{
+ g_object_set (G_OBJECT (preferences), "last-window-posx", src, NULL);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
Modified: xfmpc/trunk/src/preferences.h
===================================================================
--- xfmpc/trunk/src/preferences.h 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/preferences.h 2009-04-23 11:11:39 UTC (rev 7280)
@@ -19,6 +19,8 @@
#ifndef __XFMPC_PREFERENCES_H__
#define __XFMPC_PREFERENCES_H__
+#include <glib-object.h>
+
G_BEGIN_DECLS
typedef enum
@@ -49,10 +51,40 @@
typedef struct _XfmpcPreferences XfmpcPreferences;
typedef struct _XfmpcPreferencesPriv XfmpcPreferencesPriv;
-GType xfmpc_preferences_get_type () G_GNUC_CONST;
+GType xfmpc_preferences_get_type () G_GNUC_CONST;
-XfmpcPreferences * xfmpc_preferences_get ();
+XfmpcPreferences * xfmpc_preferences_get ();
+gint xfmpc_preferences_get_last_window_posx (XfmpcPreferences *preferences);
+gint xfmpc_preferences_get_last_window_posy (XfmpcPreferences *preferences);
+gint xfmpc_preferences_get_last_window_width (XfmpcPreferences *preferences);
+gint xfmpc_preferences_get_last_window_height (XfmpcPreferences *preferences);
+gboolean xfmpc_preferences_get_last_window_state_sticky (XfmpcPreferences *preferences);
+gboolean xfmpc_preferences_get_playlist_autocenter (XfmpcPreferences *preferences);
+gchar * xfmpc_preferences_get_dbbrowser_last_path (XfmpcPreferences *preferences);
+gchar * xfmpc_preferences_get_mpd_hostname (XfmpcPreferences *preferences);
+gint xfmpc_preferences_get_mpd_port (XfmpcPreferences *preferences);
+gchar * xfmpc_preferences_get_mpd_password (XfmpcPreferences *preferences);
+gboolean xfmpc_preferences_get_mpd_use_defaults (XfmpcPreferences *preferences);
+gboolean xfmpc_preferences_get_show_statusbar (XfmpcPreferences *preferences);
+gint xfmpc_preferences_get_song_format (XfmpcPreferences *preferences);
+gchar * xfmpc_preferences_get_song_format_custom (XfmpcPreferences *preferences);
+
+void xfmpc_preferences_set_last_window_posx (XfmpcPreferences *preferences, gint src);
+void xfmpc_preferences_set_last_window_posy (XfmpcPreferences *preferences, gint src);
+void xfmpc_preferences_set_last_window_width (XfmpcPreferences *preferences, gint src);
+void xfmpc_preferences_set_last_window_height (XfmpcPreferences *preferences, gint src);
+void xfmpc_preferences_set_last_window_state_sticky (XfmpcPreferences *preferences, gboolean src);
+void xfmpc_preferences_set_playlist_autocenter (XfmpcPreferences *preferences, gboolean src);
+void xfmpc_preferences_set_dbbrowser_last_path (XfmpcPreferences *preferences, gchar *src);
+void xfmpc_preferences_set_mpd_hostname (XfmpcPreferences *preferences, gchar *src);
+void xfmpc_preferences_set_mpd_port (XfmpcPreferences *preferences, gint src);
+void xfmpc_preferences_set_mpd_password (XfmpcPreferences *preferences, gchar *src) ;
+void xfmpc_preferences_set_mpd_use_defaults (XfmpcPreferences *preferences, gboolean src);
+void xfmpc_preferences_set_show_statusbar (XfmpcPreferences *preferences, gboolean src);
+void xfmpc_preferences_set_song_format (XfmpcPreferences *preferences, gint src);
+void xfmpc_preferences_set_song_format_custom (XfmpcPreferences *preferences, gchar *src);
+
G_END_DECLS
#endif
Modified: xfmpc/trunk/src/song-dialog.c
===================================================================
--- xfmpc/trunk/src/song-dialog.c 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/song-dialog.c 2009-04-23 11:11:39 UTC (rev 7280)
@@ -17,294 +17,243 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
+#include <glib.h>
+#include <glib-object.h>
#include <libxfcegui4/libxfcegui4.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mpdclient.h>
+#include <config.h>
#include <libxfce4util/libxfce4util.h>
+#include <gtk/gtk.h>
+#include <pango/pango.h>
+#include <glib/gi18n-lib.h>
-#include "song-dialog.h"
-#include "mpdclient.h"
-#define GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialogPrivate))
+#define XFMPC_TYPE_SONG_DIALOG (xfmpc_song_dialog_get_type ())
+#define XFMPC_SONG_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialog))
+#define XFMPC_SONG_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialogClass))
+#define XFMPC_IS_SONG_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_SONG_DIALOG))
+#define XFMPC_IS_SONG_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_SONG_DIALOG))
+#define XFMPC_SONG_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialogClass))
+typedef struct _XfmpcSongDialog XfmpcSongDialog;
+typedef struct _XfmpcSongDialogClass XfmpcSongDialogClass;
+typedef struct _XfmpcSongDialogPrivate XfmpcSongDialogPrivate;
-
-static void xfmpc_song_dialog_class_init (XfmpcSongDialogClass *klass);
-static void xfmpc_song_dialog_init (XfmpcSongDialog *dialog);
-static void xfmpc_song_dialog_finalize (GObject *object);
-
-static void xfmpc_song_dialog_response (GtkDialog *dialog,
- gint response);
-
-static void xfmpc_song_dialog_set_song_info (XfmpcSongDialog *dialog,
- XfmpcSongInfo *song_info);
-
-
-
-struct _XfmpcSongDialogClass
-{
- XfceTitledDialogClass parent_class;
+struct _XfmpcSongDialog {
+ XfceTitledDialog parent_instance;
+ XfmpcSongDialogPrivate * priv;
};
-struct _XfmpcSongDialog
-{
- XfceTitledDialog parent;
- /*<private>*/
- XfmpcSongDialogPrivate *priv;
+struct _XfmpcSongDialogClass {
+ XfceTitledDialogClass parent_class;
};
-struct _XfmpcSongDialogPrivate
-{
- GtkWidget *label_file;
- GtkWidget *label_artist;
- GtkWidget *label_title;
- GtkWidget *label_album;
- GtkWidget *label_date;
- GtkWidget *label_track;
- GtkWidget *label_genre;
-
- GtkWidget *hbox_artist;
- GtkWidget *hbox_title;
- GtkWidget *hbox_album;
- GtkWidget *hbox_date;
- GtkWidget *hbox_track;
- GtkWidget *hbox_genre;
+struct _XfmpcSongDialogPrivate {
+ char* gettext_package;
+ char* localedir;
+ XfmpcMpdclient* mpdclient;
+ XfmpcSongInfo* song;
};
-static GObjectClass *parent_class = NULL;
+GType xfmpc_song_dialog_get_type (void);
+#define XFMPC_SONG_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialogPrivate))
+enum {
+ XFMPC_SONG_DIALOG_DUMMY_PROPERTY
+};
+static void xfmpc_song_dialog_cb_response (XfmpcSongDialog* self, XfmpcSongDialog* source, gint response);
+static void _xfmpc_song_dialog_cb_response_gtk_dialog_response (XfmpcSongDialog* _sender, gint response_id, gpointer self);
+XfmpcSongDialog* xfmpc_song_dialog_new (gint song_id);
+XfmpcSongDialog* xfmpc_song_dialog_construct (GType object_type, gint song_id);
+XfmpcSongDialog* xfmpc_song_dialog_new (gint song_id);
+static gpointer xfmpc_song_dialog_parent_class = NULL;
+static void xfmpc_song_dialog_finalize (GObject* obj);
-GType
-xfmpc_song_dialog_get_type (void)
-{
- static GType xfmpc_song_dialog_type = G_TYPE_INVALID;
+static void _xfmpc_song_dialog_cb_response_gtk_dialog_response (XfmpcSongDialog* _sender, gint response_id, gpointer self) {
+ xfmpc_song_dialog_cb_response (self, _sender, response_id);
+}
- if (G_UNLIKELY (xfmpc_song_dialog_type == G_TYPE_INVALID))
- {
- static const GTypeInfo xfmpc_song_dialog_info =
- {
- sizeof (XfmpcSongDialogClass),
- NULL,
- NULL,
- (GClassInitFunc) xfmpc_song_dialog_class_init,
- NULL,
- NULL,
- sizeof (XfmpcSongDialog),
- 0,
- (GInstanceInitFunc) xfmpc_song_dialog_init,
- NULL,
- };
- xfmpc_song_dialog_type = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, "XfmpcSongDialog", &xfmpc_song_dialog_info, 0);
- }
-
- return xfmpc_song_dialog_type;
+XfmpcSongDialog* xfmpc_song_dialog_construct (GType object_type, gint song_id) {
+ XfmpcSongDialog * self;
+ GtkVBox* vbox2;
+ GtkWidget* _tmp0;
+ GtkWidget* frame;
+ PangoAttrList* attrs;
+ GtkHBox* hbox;
+ GtkLabel* label;
+ GtkLabel* _tmp2;
+ char* _tmp1;
+ GtkHBox* _tmp3;
+ GtkLabel* _tmp4;
+ GtkLabel* _tmp5;
+ GtkHBox* _tmp6;
+ GtkLabel* _tmp7;
+ GtkLabel* _tmp8;
+ GtkHBox* _tmp9;
+ GtkLabel* _tmp10;
+ GtkLabel* _tmp11;
+ GtkHBox* _tmp12;
+ GtkLabel* _tmp13;
+ GtkLabel* _tmp14;
+ GtkLabel* _tmp15;
+ GtkLabel* _tmp16;
+ GtkHBox* _tmp17;
+ GtkLabel* _tmp18;
+ GtkLabel* _tmp19;
+ self = g_object_newv (object_type, 0, NULL);
+ xfce_textdomain (self->priv->gettext_package, self->priv->localedir, "UTF-8");
+ gtk_dialog_set_has_separator ((GtkDialog*) self, TRUE);
+ gtk_window_set_skip_taskbar_hint ((GtkWindow*) self, TRUE);
+ gtk_window_set_icon_name ((GtkWindow*) self, "stock_volume");
+ gtk_window_set_resizable ((GtkWindow*) self, FALSE);
+ self->priv->mpdclient = xfmpc_mpdclient_get ();
+ self->priv->song = xfmpc_mpdclient_get_song_info (self->priv->mpdclient, song_id);
+ gtk_window_set_title ((GtkWindow*) self, self->priv->song->title);
+ gtk_box_set_spacing ((GtkBox*) ((GtkDialog*) self)->vbox, 0);
+ vbox2 = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 0));
+ _tmp0 = NULL;
+ frame = (_tmp0 = xfce_create_framebox_with_content ("", (GtkWidget*) vbox2), (_tmp0 == NULL) ? NULL : g_object_ref (_tmp0));
+ attrs = pango_attr_list_new ();
+ pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
+ hbox = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 0));
+ label = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("File")));
+ gtk_label_set_attributes (label, attrs);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ _tmp2 = NULL;
+ _tmp1 = NULL;
+ label = (_tmp2 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_tmp1 = g_path_get_basename (self->priv->song->filename))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp2);
+ _tmp1 = (g_free (_tmp1), NULL);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) hbox, FALSE, FALSE, (guint) 6);
+ _tmp3 = NULL;
+ hbox = (_tmp3 = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 0)), (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL)), _tmp3);
+ _tmp4 = NULL;
+ label = (_tmp4 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Artist"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp4);
+ gtk_label_set_attributes (label, attrs);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ _tmp5 = NULL;
+ label = (_tmp5 = g_object_ref_sink ((GtkLabel*) gtk_label_new (self->priv->song->artist)), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp5);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) hbox, FALSE, FALSE, (guint) 6);
+ _tmp6 = NULL;
+ hbox = (_tmp6 = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 0)), (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL)), _tmp6);
+ _tmp7 = NULL;
+ label = (_tmp7 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Title"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp7);
+ gtk_label_set_attributes (label, attrs);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ _tmp8 = NULL;
+ label = (_tmp8 = g_object_ref_sink ((GtkLabel*) gtk_label_new (self->priv->song->title)), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp8);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) hbox, FALSE, FALSE, (guint) 6);
+ _tmp9 = NULL;
+ hbox = (_tmp9 = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 0)), (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL)), _tmp9);
+ _tmp10 = NULL;
+ label = (_tmp10 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Album"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp10);
+ gtk_label_set_attributes (label, attrs);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ _tmp11 = NULL;
+ label = (_tmp11 = g_object_ref_sink ((GtkLabel*) gtk_label_new (self->priv->song->album)), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp11);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) hbox, FALSE, FALSE, (guint) 6);
+ _tmp12 = NULL;
+ hbox = (_tmp12 = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 0)), (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL)), _tmp12);
+ _tmp13 = NULL;
+ label = (_tmp13 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Date"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp13);
+ gtk_label_set_attributes (label, attrs);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ _tmp14 = NULL;
+ label = (_tmp14 = g_object_ref_sink ((GtkLabel*) gtk_label_new (self->priv->song->date)), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp14);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ _tmp15 = NULL;
+ label = (_tmp15 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Track"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp15);
+ gtk_label_set_attributes (label, attrs);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 15);
+ _tmp16 = NULL;
+ label = (_tmp16 = g_object_ref_sink ((GtkLabel*) gtk_label_new (self->priv->song->track)), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp16);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) hbox, FALSE, FALSE, (guint) 6);
+ _tmp17 = NULL;
+ hbox = (_tmp17 = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 0)), (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL)), _tmp17);
+ _tmp18 = NULL;
+ label = (_tmp18 = g_object_ref_sink ((GtkLabel*) gtk_label_new (_ ("Genre"))), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp18);
+ gtk_label_set_attributes (label, attrs);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ _tmp19 = NULL;
+ label = (_tmp19 = g_object_ref_sink ((GtkLabel*) gtk_label_new (self->priv->song->genre)), (label == NULL) ? NULL : (label = (g_object_unref (label), NULL)), _tmp19);
+ gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 5);
+ gtk_box_pack_start ((GtkBox*) vbox2, (GtkWidget*) hbox, FALSE, FALSE, (guint) 6);
+ gtk_box_pack_start ((GtkBox*) ((GtkDialog*) self)->vbox, frame, TRUE, TRUE, (guint) 0);
+ gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_CLOSE, (gint) GTK_RESPONSE_CLOSE);
+ gtk_widget_show_all ((GtkWidget*) self);
+ g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) _xfmpc_song_dialog_cb_response_gtk_dialog_response, self, 0);
+ (vbox2 == NULL) ? NULL : (vbox2 = (g_object_unref (vbox2), NULL));
+ (frame == NULL) ? NULL : (frame = (g_object_unref (frame), NULL));
+ (attrs == NULL) ? NULL : (attrs = (pango_attr_list_unref (attrs), NULL));
+ (hbox == NULL) ? NULL : (hbox = (g_object_unref (hbox), NULL));
+ (label == NULL) ? NULL : (label = (g_object_unref (label), NULL));
+ return self;
}
+XfmpcSongDialog* xfmpc_song_dialog_new (gint song_id) {
+ return xfmpc_song_dialog_construct (XFMPC_TYPE_SONG_DIALOG, song_id);
+}
-static void
-xfmpc_song_dialog_class_init (XfmpcSongDialogClass *klass)
-{
- GtkDialogClass *gtkdialog_class;
- GObjectClass *gobject_class;
- g_type_class_add_private (klass, sizeof (XfmpcSongDialogPrivate));
+/*
+ * Signal callbacks
+ */
+static void xfmpc_song_dialog_cb_response (XfmpcSongDialog* self, XfmpcSongDialog* source, gint response) {
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (source != NULL);
+ switch (response) {
+ case GTK_RESPONSE_CLOSE:
+ {
+ gtk_object_destroy ((GtkObject*) self);
+ break;
+ }
+ }
+}
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xfmpc_song_dialog_finalize;
-
- gtkdialog_class = GTK_DIALOG_CLASS (klass);
- gtkdialog_class->response = xfmpc_song_dialog_response;
+static void xfmpc_song_dialog_class_init (XfmpcSongDialogClass * klass) {
+ xfmpc_song_dialog_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (XfmpcSongDialogPrivate));
+ G_OBJECT_CLASS (klass)->finalize = xfmpc_song_dialog_finalize;
}
-static void
-xfmpc_song_dialog_init (XfmpcSongDialog *dialog)
-{
- XfmpcSongDialogPrivate *priv = dialog->priv = GET_PRIVATE (dialog);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "stock_volume");
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_window_set_title (GTK_WINDOW (dialog), PACKAGE_NAME);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
-
- PangoAttrList *attrs = pango_attr_list_new ();
- PangoAttribute *attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- pango_attr_list_insert (attrs, attr);
-
- GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
- gtk_widget_show (vbox);
-
- GtkWidget *vbox2 = gtk_vbox_new (FALSE, 0);
- GtkWidget *frame = xfce_create_framebox_with_content (NULL, vbox2);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-
- /* File */
- GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 6);
- GtkWidget *label = gtk_label_new (_("File"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
- label = priv->label_file = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
-
- /* Artist */
- hbox = priv->hbox_artist = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 6);
- label = gtk_label_new (_("Artist"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
- label = priv->label_artist = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
-
- /* Title */
- hbox = priv->hbox_title = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 6);
- label = gtk_label_new (_("Title"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
- label = priv->label_title = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
-
- /* Album */
- hbox = priv->hbox_album = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 6);
- label = gtk_label_new (_("Album"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
- label = priv->label_album = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
-
- /* Date */
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 6);
- priv->hbox_date = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), priv->hbox_date, FALSE, FALSE, 0);
- label = gtk_label_new (_("Date"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_box_pack_start (GTK_BOX (priv->hbox_date), label, FALSE, FALSE, 5);
- label = priv->label_date = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (priv->hbox_date), label, FALSE, FALSE, 5);
-
- /* Track */
- priv->hbox_track = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), priv->hbox_track, FALSE, FALSE, 15);
- label = gtk_label_new (_("Track"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_box_pack_start (GTK_BOX (priv->hbox_track), label, FALSE, FALSE, 5);
- label = priv->label_track = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (priv->hbox_track), label, FALSE, FALSE, 5);
-
- /* Genre */
- hbox = priv->hbox_genre = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 6);
- label = gtk_label_new (_("Genre"));
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
- label = priv->label_genre = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0);
- gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
+static void xfmpc_song_dialog_instance_init (XfmpcSongDialog * self) {
+ self->priv = XFMPC_SONG_DIALOG_GET_PRIVATE (self);
+ self->priv->gettext_package = g_strdup (GETTEXT_PACKAGE);
+ self->priv->localedir = g_strdup (PACKAGE_LOCALE_DIR);
}
-static void
-xfmpc_song_dialog_finalize (GObject *object)
-{
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
-static void
-xfmpc_song_dialog_response (GtkDialog *dialog,
- gint response)
-{
- gtk_widget_destroy (GTK_WIDGET (dialog));
+static void xfmpc_song_dialog_finalize (GObject* obj) {
+ XfmpcSongDialog * self;
+ self = XFMPC_SONG_DIALOG (obj);
+ self->priv->gettext_package = (g_free (self->priv->gettext_package), NULL);
+ self->priv->localedir = (g_free (self->priv->localedir), NULL);
+ G_OBJECT_CLASS (xfmpc_song_dialog_parent_class)->finalize (obj);
}
-
-GtkWidget *
-xfmpc_song_dialog_new (gint id)
-{
- XfmpcMpdclient *mpdclient = xfmpc_mpdclient_get ();
-
- XfmpcSongInfo *song_info = xfmpc_mpdclient_get_song_info (mpdclient, id);
-
- GtkWidget *dialog = g_object_new (XFMPC_TYPE_SONG_DIALOG, NULL);
- xfmpc_song_dialog_set_song_info (XFMPC_SONG_DIALOG (dialog), song_info);
-
- return dialog;
+GType xfmpc_song_dialog_get_type (void) {
+ static GType xfmpc_song_dialog_type_id = 0;
+ if (xfmpc_song_dialog_type_id == 0) {
+ static const GTypeInfo g_define_type_info = { sizeof (XfmpcSongDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xfmpc_song_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XfmpcSongDialog), 0, (GInstanceInitFunc) xfmpc_song_dialog_instance_init, NULL };
+ xfmpc_song_dialog_type_id = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, "XfmpcSongDialog", &g_define_type_info, 0);
+ }
+ return xfmpc_song_dialog_type_id;
}
-static void
-xfmpc_song_dialog_set_song_info (XfmpcSongDialog *dialog,
- XfmpcSongInfo *song_info)
-{
- XfmpcSongDialogPrivate *priv = dialog->priv = GET_PRIVATE (dialog);
- gtk_label_set_text (GTK_LABEL (priv->label_file), g_path_get_basename (song_info->filename));
- gtk_label_set_text (GTK_LABEL (priv->label_artist), song_info->artist);
- gtk_label_set_text (GTK_LABEL (priv->label_album), song_info->album);
- gtk_label_set_text (GTK_LABEL (priv->label_title), song_info->title);
- gtk_label_set_text (GTK_LABEL (priv->label_date), song_info->date);
- gtk_label_set_text (GTK_LABEL (priv->label_track), song_info->track);
- gtk_label_set_text (GTK_LABEL (priv->label_genre), song_info->genre);
- if (song_info->artist == NULL)
- gtk_widget_hide (priv->hbox_artist);
- else
- gtk_widget_show (priv->hbox_artist);
- if (song_info->album == NULL)
- gtk_widget_hide (priv->hbox_album);
- else
- gtk_widget_show (priv->hbox_album);
-
- if (song_info->title == NULL)
- gtk_widget_hide (priv->hbox_title);
- else
- gtk_widget_show (priv->hbox_title);
-
- if (song_info->date == NULL)
- gtk_widget_hide (priv->hbox_date);
- else
- gtk_widget_show (priv->hbox_date);
-
- if (song_info->track == NULL)
- gtk_widget_hide (priv->hbox_track);
- else
- gtk_widget_show (priv->hbox_track);
-
- if (song_info->genre == NULL)
- gtk_widget_hide (priv->hbox_genre);
- else
- gtk_widget_show (priv->hbox_genre);
-
- gtk_window_set_title (GTK_WINDOW (dialog), song_info->title);
-}
-
Added: xfmpc/trunk/src/song-dialog.vala
===================================================================
--- xfmpc/trunk/src/song-dialog.vala (rev 0)
+++ xfmpc/trunk/src/song-dialog.vala 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,131 @@
+/*
+ * 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 SongDialog : Xfce.TitledDialog {
+
+ private string gettext_package = Config.GETTEXT_PACKAGE;
+ private string localedir = Config.PACKAGE_LOCALE_DIR;
+
+ private unowned Xfmpc.Mpdclient mpdclient;
+ private unowned Xfmpc.SongInfo song;
+
+ public SongDialog (int song_id) {
+ Xfce.textdomain (gettext_package, localedir, "UTF-8");
+
+ has_separator = true;
+ skip_taskbar_hint = true;
+ icon_name = "stock_volume";
+ resizable = false;
+
+ mpdclient = Xfmpc.Mpdclient.get ();
+ song = mpdclient.get_song_info (song_id);
+
+ title = song.title;
+
+ vbox.set_spacing (0);
+
+ var vbox2 = new VBox (false, 0);
+ var frame = Xfce.create_framebox_with_content ("", vbox2);
+
+ var attrs = new Pango.AttrList ();
+ attrs.insert (Pango.attr_weight_new (Pango.Weight.BOLD));
+
+ var hbox = new HBox (false, 0);
+ var label = new Label (_("File"));
+ label.set_attributes (attrs);
+ hbox.pack_start (label, false, false, 5);
+ label = new Label (Path.get_basename (song.filename));
+ hbox.pack_start (label, false, false, 5);
+ vbox2.pack_start (hbox, false, false, 6);
+
+ hbox = new HBox (false, 0);
+ label = new Label (_("Artist"));
+ label.set_attributes (attrs);
+ hbox.pack_start (label, false, false, 5);
+ label = new Label (song.artist);
+ hbox.pack_start (label, false, false, 5);
+ vbox2.pack_start (hbox, false, false, 6);
+
+ hbox = new HBox (false, 0);
+ label = new Label (_("Title"));
+ label.set_attributes (attrs);
+ hbox.pack_start (label, false, false, 5);
+ label = new Label (song.title);
+ hbox.pack_start (label, false, false, 5);
+ vbox2.pack_start (hbox, false, false, 6);
+
+ hbox = new HBox (false, 0);
+ label = new Label (_("Album"));
+ label.set_attributes (attrs);
+ hbox.pack_start (label, false, false, 5);
+ label = new Label (song.album);
+ hbox.pack_start (label, false, false, 5);
+ vbox2.pack_start (hbox, false, false, 6);
+
+ hbox = new HBox (false, 0);
+ label = new Label (_("Date"));
+ label.set_attributes (attrs);
+ hbox.pack_start (label, false, false, 5);
+ label = new Label (song.date);
+ hbox.pack_start (label, false, false, 5);
+ label = new Label (_("Track"));
+ label.set_attributes (attrs);
+ hbox.pack_start (label, false, false, 15);
+ label = new Label (song.track);
+ hbox.pack_start (label, false, false, 5);
+ vbox2.pack_start (hbox, false, false, 6);
+
+ hbox = new HBox (false, 0);
+ label = new Label (_("Genre"));
+ label.set_attributes (attrs);
+ hbox.pack_start (label, false, false, 5);
+ label = new Label (song.genre);
+ hbox.pack_start (label, false, false, 5);
+ vbox2.pack_start (hbox, false, false, 6);
+
+ vbox.pack_start (frame, true, true, 0);
+
+ add_button (STOCK_CLOSE, ResponseType.CLOSE);
+
+ show_all ();
+
+ /* Signals */
+ response += cb_response;
+ }
+
+ /*
+ * Signal callbacks
+ */
+
+ private void cb_response (SongDialog source, int response) {
+ switch (response) {
+ case ResponseType.CLOSE:
+ destroy ();
+ break;
+ }
+ }
+ }
+
+}
+
+/* vi:set ts=8 sw=8: */
Modified: xfmpc/trunk/src/statusbar.c
===================================================================
--- xfmpc/trunk/src/statusbar.c 2009-04-23 07:49:16 UTC (rev 7279)
+++ xfmpc/trunk/src/statusbar.c 2009-04-23 11:11:39 UTC (rev 7280)
@@ -1,10 +1,7 @@
/*
- * Copyright (c) 2009 Vincent Legout <vincent at legout.info>
* Copyright (c) 2009 Mike Massonnet <mmassonnet at xfce.org>
+ * Copyright (c) 2009 Vincent Legout <vincent at xfce.org>
*
- * Based on ThunarStatus:
- * Copyright (c) 2005-2006 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,156 +17,144 @@
* 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 <gtk/gtk.h>
+#include <stdlib.h>
+#include <string.h>
-#include "statusbar.h"
-#define GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_STATUSBAR, XfmpcStatusbarPrivate))
+#define XFMPC_TYPE_STATUSBAR (xfmpc_statusbar_get_type ())
+#define XFMPC_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_STATUSBAR, XfmpcStatusbar))
+#define XFMPC_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_STATUSBAR, XfmpcStatusbarClass))
+#define XFMPC_IS_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_STATUSBAR))
+#define XFMPC_IS_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_STATUSBAR))
+#define XFMPC_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_STATUSBAR, XfmpcStatusbarClass))
+typedef struct _XfmpcStatusbar XfmpcStatusbar;
+typedef struct _XfmpcStatusbarClass XfmpcStatusbarClass;
+typedef struct _XfmpcStatusbarPrivate XfmpcStatusbarPrivate;
-
-static void xfmpc_statusbar_class_init (XfmpcStatusbarClass *klass);
-static void xfmpc_statusbar_init (XfmpcStatusbar *statusbar);
-static void xfmpc_statusbar_finalize (GObject *object);
-static void xfmpc_statusbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-
-
-enum
-{
- TEXT = 1,
+struct _XfmpcStatusbar {
+ GtkStatusbar parent_instance;
+ XfmpcStatusbarPrivate * priv;
};
-
-
-struct _XfmpcStatusbarClass
-{
- GtkStatusbarClass parent;
+struct _XfmpcStatusbarClass {
+ GtkStatusbarClass parent_class;
};
-struct _XfmpcStatusbar
-{
- GtkStatusbar parent;
- /*<private>*/
- XfmpcStatusbarPrivate *priv;
+struct _XfmpcStatusbarPrivate {
+ guint context_id;
+ char* _text;
};
-struct _XfmpcStatusbarPrivate
-{
- guint context_id;
-};
+GType xfmpc_statusbar_get_type (void);
+#define XFMPC_STATUSBAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_STATUSBAR, XfmpcStatusbarPrivate))
+enum {
+ XFMPC_STATUSBAR_DUMMY_PROPERTY,
+ XFMPC_STATUSBAR_TEXT
+};
+XfmpcStatusbar* xfmpc_statusbar_new (void);
+XfmpcStatusbar* xfmpc_statusbar_construct (GType object_type);
+XfmpcStatusbar* xfmpc_statusbar_new (void);
+void xfmpc_statusbar_set_text (XfmpcStatusbar* self, const char* value);
+static GObject * xfmpc_statusbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
+static gpointer xfmpc_statusbar_parent_class = NULL;
+static void xfmpc_statusbar_finalize (GObject* obj);
-static GObjectClass *parent_class = NULL;
+XfmpcStatusbar* xfmpc_statusbar_construct (GType object_type) {
+ XfmpcStatusbar * self;
+ self = g_object_newv (object_type, 0, NULL);
+ return self;
+}
-GType
-xfmpc_statusbar_get_type (void)
-{
- static GType xfmpc_statusbar_type = G_TYPE_INVALID;
- if (G_UNLIKELY (xfmpc_statusbar_type == G_TYPE_INVALID))
- {
- static const GTypeInfo xfmpc_statusbar_info =
- {
- sizeof (XfmpcStatusbarClass),
- NULL,
- NULL,
- (GClassInitFunc) xfmpc_statusbar_class_init,
- NULL,
- NULL,
- sizeof (XfmpcStatusbar),
- 0,
- (GInstanceInitFunc) xfmpc_statusbar_init,
- NULL,
- };
+XfmpcStatusbar* xfmpc_statusbar_new (void) {
+ return xfmpc_statusbar_construct (XFMPC_TYPE_STATUSBAR);
+}
- xfmpc_statusbar_type = g_type_register_static (GTK_TYPE_STATUSBAR, "XfmpcStatusbar", &xfmpc_statusbar_info, 0);
- }
- return xfmpc_statusbar_type;
+void xfmpc_statusbar_set_text (XfmpcStatusbar* self, const char* value) {
+ char* _tmp1;
+ const char* _tmp0;
+ g_return_if_fail (self != NULL);
+ _tmp1 = NULL;
+ _tmp0 = NULL;
+ self->priv->_text = (_tmp1 = (_tmp0 = value, (_tmp0 == NULL) ? NULL : g_strdup (_tmp0)), self->priv->_text = (g_free (self->priv->_text), NULL), _tmp1);
+ gtk_statusbar_pop ((GtkStatusbar*) self, self->priv->context_id);
+ gtk_statusbar_push ((GtkStatusbar*) self, self->priv->context_id, self->priv->_text);
+ g_object_notify ((GObject *) self, "text");
}
-static void
-xfmpc_statusbar_class_init (XfmpcStatusbarClass *klass)
-{
- GObjectClass *gobject_class;
- g_type_class_add_private (klass, sizeof (XfmpcStatusbarPrivate));
+static GObject * xfmpc_statusbar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ XfmpcStatusbarClass * klass;
+ GObjectClass * parent_class;
+ XfmpcStatusbar * self;
+ klass = XFMPC_STATUSBAR_CLASS (g_type_class_peek (XFMPC_TYPE_STATUSBAR));
+ parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = XFMPC_STATUSBAR (obj);
+ {
+ gtk_statusbar_set_has_resize_grip ((GtkStatusbar*) self, FALSE);
+ self->priv->context_id = gtk_statusbar_get_context_id ((GtkStatusbar*) self, "Main text");
+ }
+ return obj;
+}
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xfmpc_statusbar_finalize;
- gobject_class->set_property = xfmpc_statusbar_set_property;
-
- g_object_class_install_property (gobject_class,
- TEXT,
- g_param_spec_string ("text",
- "Text",
- "Text in the statusbar",
- NULL,
- G_PARAM_WRITABLE));
+static void xfmpc_statusbar_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
+ XfmpcStatusbar * self;
+ self = XFMPC_STATUSBAR (object);
+ switch (property_id) {
+ case XFMPC_STATUSBAR_TEXT:
+ xfmpc_statusbar_set_text (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
-static void
-xfmpc_statusbar_init (XfmpcStatusbar *statusbar)
-{
- XfmpcStatusbarPrivate *priv = statusbar->priv = GET_PRIVATE (statusbar);
- priv->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "Main text");
- gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar), FALSE);
+static void xfmpc_statusbar_class_init (XfmpcStatusbarClass * klass) {
+ xfmpc_statusbar_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (XfmpcStatusbarPrivate));
+ G_OBJECT_CLASS (klass)->set_property = xfmpc_statusbar_set_property;
+ G_OBJECT_CLASS (klass)->constructor = xfmpc_statusbar_constructor;
+ G_OBJECT_CLASS (klass)->finalize = xfmpc_statusbar_finalize;
+ g_object_class_install_property (G_OBJECT_CLASS (klass), XFMPC_STATUSBAR_TEXT, g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE));
}
-static void
-xfmpc_statusbar_finalize (GObject *object)
-{
- G_OBJECT_CLASS (parent_class)->finalize (object);
+
+static void xfmpc_statusbar_instance_init (XfmpcStatusbar * self) {
+ self->priv = XFMPC_STATUSBAR_GET_PRIVATE (self);
}
-static void
-xfmpc_statusbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- XfmpcStatusbar *statusbar = XFMPC_STATUSBAR (object);
- switch (prop_id)
- {
- case TEXT:
- xfmpc_statusbar_set_text (statusbar, g_value_get_string (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+static void xfmpc_statusbar_finalize (GObject* obj) {
+ XfmpcStatusbar * self;
+ self = XFMPC_STATUSBAR (obj);
+ self->priv->_text = (g_free (self->priv->_text), NULL);
+ G_OBJECT_CLASS (xfmpc_statusbar_parent_class)->finalize (obj);
}
-GtkWidget*
-xfmpc_statusbar_new (void)
-{
- return g_object_new (XFMPC_TYPE_STATUSBAR, NULL);
+
+GType xfmpc_statusbar_get_type (void) {
+ static GType xfmpc_statusbar_type_id = 0;
+ if (xfmpc_statusbar_type_id == 0) {
+ static const GTypeInfo g_define_type_info = { sizeof (XfmpcStatusbarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xfmpc_statusbar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XfmpcStatusbar), 0, (GInstanceInitFunc) xfmpc_statusbar_instance_init, NULL };
+ xfmpc_statusbar_type_id = g_type_register_static (GTK_TYPE_STATUSBAR, "XfmpcStatusbar", &g_define_type_info, 0);
+ }
+ return xfmpc_statusbar_type_id;
}
-void
-xfmpc_statusbar_set_text (XfmpcStatusbar *statusbar,
- const gchar *text)
-{
- XfmpcStatusbarPrivate *priv = statusbar->priv = GET_PRIVATE (statusbar);
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar), priv->context_id);
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), priv->context_id, text);
-}
+
Added: xfmpc/trunk/src/statusbar.vala
===================================================================
--- xfmpc/trunk/src/statusbar.vala (rev 0)
+++ xfmpc/trunk/src/statusbar.vala 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,45 @@
+/*
+ * 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 Statusbar : Gtk.Statusbar {
+
+ private uint context_id;
+
+ private string _text;
+ public string text {
+ set {
+ _text = value;
+ pop (context_id);
+ push (context_id, _text);
+ }
+ }
+
+ construct {
+ set_has_resize_grip (false);
+ context_id = get_context_id ("Main text");
+ }
+ }
+
+}
+
+/* vi:set ts=8 sw=8: */
Added: xfmpc/trunk/src/xfmpc.h
===================================================================
--- xfmpc/trunk/src/xfmpc.h (rev 0)
+++ xfmpc/trunk/src/xfmpc.h 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,179 @@
+
+#ifndef __XFMPC_H__
+#define __XFMPC_H__
+
+#include <glib.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <gtk/gtk.h>
+#include <stdlib.h>
+#include <string.h>
+
+G_BEGIN_DECLS
+
+
+#define XFMPC_TYPE_PREFERENCES_DIALOG (xfmpc_preferences_dialog_get_type ())
+#define XFMPC_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialog))
+#define XFMPC_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialogClass))
+#define XFMPC_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PREFERENCES_DIALOG))
+#define XFMPC_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PREFERENCES_DIALOG))
+#define XFMPC_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PREFERENCES_DIALOG, XfmpcPreferencesDialogClass))
+
+typedef struct _XfmpcPreferencesDialog XfmpcPreferencesDialog;
+typedef struct _XfmpcPreferencesDialogClass XfmpcPreferencesDialogClass;
+typedef struct _XfmpcPreferencesDialogPrivate XfmpcPreferencesDialogPrivate;
+
+#define XFMPC_TYPE_SONG_DIALOG (xfmpc_song_dialog_get_type ())
+#define XFMPC_SONG_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialog))
+#define XFMPC_SONG_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialogClass))
+#define XFMPC_IS_SONG_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_SONG_DIALOG))
+#define XFMPC_IS_SONG_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_SONG_DIALOG))
+#define XFMPC_SONG_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_SONG_DIALOG, XfmpcSongDialogClass))
+
+typedef struct _XfmpcSongDialog XfmpcSongDialog;
+typedef struct _XfmpcSongDialogClass XfmpcSongDialogClass;
+typedef struct _XfmpcSongDialogPrivate XfmpcSongDialogPrivate;
+
+#define XFMPC_TYPE_STATUSBAR (xfmpc_statusbar_get_type ())
+#define XFMPC_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_STATUSBAR, XfmpcStatusbar))
+#define XFMPC_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_STATUSBAR, XfmpcStatusbarClass))
+#define XFMPC_IS_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_STATUSBAR))
+#define XFMPC_IS_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_STATUSBAR))
+#define XFMPC_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_STATUSBAR, XfmpcStatusbarClass))
+
+typedef struct _XfmpcStatusbar XfmpcStatusbar;
+typedef struct _XfmpcStatusbarClass XfmpcStatusbarClass;
+typedef struct _XfmpcStatusbarPrivate XfmpcStatusbarPrivate;
+
+#define XFMPC_TYPE_DBBROWSER (xfmpc_dbbrowser_get_type ())
+#define XFMPC_DBBROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowser))
+#define XFMPC_DBBROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserClass))
+#define XFMPC_IS_DBBROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_DBBROWSER))
+#define XFMPC_IS_DBBROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_DBBROWSER))
+#define XFMPC_DBBROWSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_DBBROWSER, XfmpcDbbrowserClass))
+
+typedef struct _XfmpcDbbrowser XfmpcDbbrowser;
+typedef struct _XfmpcDbbrowserClass XfmpcDbbrowserClass;
+typedef struct _XfmpcDbbrowserPrivate XfmpcDbbrowserPrivate;
+
+#define XFMPC_TYPE_EXTENDED_INTERFACE (xfmpc_extended_interface_get_type ())
+#define XFMPC_EXTENDED_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterface))
+#define XFMPC_EXTENDED_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfaceClass))
+#define XFMPC_IS_EXTENDED_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_EXTENDED_INTERFACE))
+#define XFMPC_IS_EXTENDED_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_EXTENDED_INTERFACE))
+#define XFMPC_EXTENDED_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfaceClass))
+
+typedef struct _XfmpcExtendedInterface XfmpcExtendedInterface;
+typedef struct _XfmpcExtendedInterfaceClass XfmpcExtendedInterfaceClass;
+typedef struct _XfmpcExtendedInterfacePrivate XfmpcExtendedInterfacePrivate;
+
+#define XFMPC_EXTENDED_INTERFACE_TYPE_EXTENDED_INTERFACE_WIDGET (xfmpc_extended_interface_extended_interface_widget_get_type ())
+
+#define XFMPC_TYPE_PLAYLIST (xfmpc_playlist_get_type ())
+#define XFMPC_PLAYLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_PLAYLIST, XfmpcPlaylist))
+#define XFMPC_PLAYLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistClass))
+#define XFMPC_IS_PLAYLIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_PLAYLIST))
+#define XFMPC_IS_PLAYLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_PLAYLIST))
+#define XFMPC_PLAYLIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_PLAYLIST, XfmpcPlaylistClass))
+
+typedef struct _XfmpcPlaylist XfmpcPlaylist;
+typedef struct _XfmpcPlaylistClass XfmpcPlaylistClass;
+typedef struct _XfmpcPlaylistPrivate XfmpcPlaylistPrivate;
+
+struct _XfmpcPreferencesDialog {
+ XfceTitledDialog parent_instance;
+ XfmpcPreferencesDialogPrivate * priv;
+};
+
+struct _XfmpcPreferencesDialogClass {
+ XfceTitledDialogClass parent_class;
+};
+
+struct _XfmpcSongDialog {
+ XfceTitledDialog parent_instance;
+ XfmpcSongDialogPrivate * priv;
+};
+
+struct _XfmpcSongDialogClass {
+ XfceTitledDialogClass parent_class;
+};
+
+struct _XfmpcStatusbar {
+ GtkStatusbar parent_instance;
+ XfmpcStatusbarPrivate * priv;
+};
+
+struct _XfmpcStatusbarClass {
+ GtkStatusbarClass parent_class;
+};
+
+struct _XfmpcDbbrowser {
+ GtkVBox parent_instance;
+ XfmpcDbbrowserPrivate * priv;
+};
+
+struct _XfmpcDbbrowserClass {
+ GtkVBoxClass parent_class;
+};
+
+struct _XfmpcExtendedInterface {
+ GtkVBox parent_instance;
+ XfmpcExtendedInterfacePrivate * priv;
+};
+
+struct _XfmpcExtendedInterfaceClass {
+ GtkVBoxClass parent_class;
+};
+
+typedef enum {
+ XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_PLAYLIST,
+ XFMPC_EXTENDED_INTERFACE_EXTENDED_INTERFACE_WIDGET_DBBROWSER
+} XfmpcExtendedInterfaceExtendedInterfaceWidget;
+
+struct _XfmpcPlaylist {
+ GtkVBox parent_instance;
+ XfmpcPlaylistPrivate * priv;
+};
+
+struct _XfmpcPlaylistClass {
+ GtkVBoxClass parent_class;
+};
+
+
+GType xfmpc_preferences_dialog_get_type (void);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_new (void);
+XfmpcPreferencesDialog* xfmpc_preferences_dialog_construct (GType object_type);
+GType xfmpc_song_dialog_get_type (void);
+XfmpcSongDialog* xfmpc_song_dialog_new (gint song_id);
+XfmpcSongDialog* xfmpc_song_dialog_construct (GType object_type, gint song_id);
+GType xfmpc_statusbar_get_type (void);
+XfmpcStatusbar* xfmpc_statusbar_new (void);
+XfmpcStatusbar* xfmpc_statusbar_construct (GType object_type);
+void xfmpc_statusbar_set_text (XfmpcStatusbar* self, const char* value);
+GType xfmpc_dbbrowser_get_type (void);
+void xfmpc_dbbrowser_free (XfmpcDbbrowser* self);
+void xfmpc_dbbrowser_reload (XfmpcDbbrowser* self);
+gboolean xfmpc_dbbrowser_wdir_is_root (XfmpcDbbrowser* self);
+char* xfmpc_dbbrowser_get_parent_wdir (XfmpcDbbrowser* self);
+void xfmpc_dbbrowser_append (XfmpcDbbrowser* self, const char* filename, const char* basename, gboolean is_dir, gboolean is_bold);
+void xfmpc_dbbrowser_set_wdir (XfmpcDbbrowser* self, const char* dir);
+void xfmpc_dbbrowser_add_selected_rows (XfmpcDbbrowser* self);
+void xfmpc_dbbrowser_search (XfmpcDbbrowser* self, const char* query);
+XfmpcDbbrowser* xfmpc_dbbrowser_new (void);
+XfmpcDbbrowser* xfmpc_dbbrowser_construct (GType object_type);
+GType xfmpc_extended_interface_get_type (void);
+GType xfmpc_extended_interface_extended_interface_widget_get_type (void);
+void xfmpc_extended_interface_set_active (XfmpcExtendedInterface* self, XfmpcExtendedInterfaceExtendedInterfaceWidget active_widget);
+XfmpcExtendedInterface* xfmpc_extended_interface_new (void);
+XfmpcExtendedInterface* xfmpc_extended_interface_construct (GType object_type);
+GType xfmpc_playlist_get_type (void);
+void xfmpc_playlist_append (XfmpcPlaylist* self, gint id, gint pos, const char* filename, const char* song, const char* length);
+void xfmpc_playlist_refresh_current_song (XfmpcPlaylist* self);
+void xfmpc_playlist_select_row (XfmpcPlaylist* self, gint i);
+void xfmpc_playlist_delete_selection (XfmpcPlaylist* self);
+XfmpcPlaylist* xfmpc_playlist_new (void);
+XfmpcPlaylist* xfmpc_playlist_construct (GType object_type);
+
+
+G_END_DECLS
+
+#endif
Added: xfmpc/trunk/vapi/config.vapi
===================================================================
--- xfmpc/trunk/vapi/config.vapi (rev 0)
+++ xfmpc/trunk/vapi/config.vapi 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+[CCode (cprefix="", lower_case_prefix="", cheader_filename="config.h")]
+namespace Config {
+ [CCode (cname = "GETTEXT_PACKAGE")]
+ public const string GETTEXT_PACKAGE;
+ [CCode (cname = "PACKAGE_LOCALE_DIR")]
+ public const string PACKAGE_LOCALE_DIR;
+ [CCode (cname = "PACKAGE_VERSION")]
+ public const string PACKAGE_VERSION;
+}
Added: xfmpc/trunk/vapi/libxfce4util-1.0.vapi
===================================================================
--- xfmpc/trunk/vapi/libxfce4util-1.0.vapi (rev 0)
+++ xfmpc/trunk/vapi/libxfce4util-1.0.vapi 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,84 @@
+/* libxfce4util-1.0.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "Xfce", lower_case_cprefix = "xfce_")]
+namespace Xfce {
+ [Compact]
+ [CCode (cheader_filename = "libxfce4util/libxfce4util.h")]
+ public class Kiosk {
+ [CCode (has_construct_function = false)]
+ public Kiosk (string module);
+ public bool query (string capability);
+ }
+ [Compact]
+ [CCode (cheader_filename = "libxfce4util/libxfce4util.h")]
+ public class PosixSignalHandler {
+ [CCode (cheader_filename = "libxfce4util/libxfce4util.h")]
+ public delegate void Callback (int @signal);
+ public static bool init () throws GLib.Error;
+ public static void restore_handler (int @signal);
+ public static bool set_handler (int @signal, Xfce.PosixSignalHandler.Callback handler) throws GLib.Error;
+ public static void shutdown ();
+ }
+ [Compact]
+ [CCode (free_function = "xfce_rc_close", cheader_filename = "libxfce4util/libxfce4util.h")]
+ public class Rc {
+ public void delete_entry (string key, bool global);
+ public void delete_group (string group, bool global);
+ public void flush ();
+ [CCode (cname = "xfce_rc_config_open", has_construct_function = false)]
+ public Rc.from_resource (Xfce.ResourceType type, string resource, bool readonly);
+ public unowned string get_entries (string group);
+ public unowned string get_group ();
+ public unowned string get_groups ();
+ public unowned string get_locale ();
+ public bool has_entry (string key);
+ public bool has_group (string group);
+ public bool is_dirty ();
+ public bool is_readonly ();
+ [CCode (cname = "xfce_rc_simple_open", has_construct_function = false)]
+ public Rc (string filename, bool readonly);
+ public bool read_bool_entry (string key, bool fallback);
+ public unowned string read_entry (string key, string fallback);
+ public unowned string read_entry_untranslated (string key, string fallback);
+ public int read_int_entry (string key, int fallback);
+ public unowned string read_list_entry (string key, string delimiter);
+ public void rollback ();
+ public void set_group (string group);
+ public void write_bool_entry (string key, bool value);
+ public void write_entry (string key, string value);
+ public void write_int_entry (string key, int value);
+ public void write_list_entry (string key, string value, string separator);
+ }
+ [Compact]
+ [CCode (cheader_filename = "libxfce4util/libxfce4util.h")]
+ public class Resource {
+ [CCode (array_length = false)]
+ public static string[] dirs (Xfce.ResourceType type);
+ public static unowned string lookup (Xfce.ResourceType type, string filename);
+ [CCode (array_length = false)]
+ public static string[] lookup_all (Xfce.ResourceType type, string filename);
+ [CCode (array_length = false)]
+ public static string[] match (Xfce.ResourceType type, string pattern, bool unique);
+ public static unowned string save_location (Xfce.ResourceType type, string relpath, bool create);
+ }
+ [CCode (cprefix = "XFCE_LICENSE_TEXT_", cheader_filename = "libxfce4util/libxfce4util.h")]
+ public enum LicenseTextType {
+ BSD,
+ GPL,
+ LGPL
+ }
+ [CCode (cprefix = "XFCE_RESOURCE_", cheader_filename = "libxfce4util/libxfce4util.h")]
+ public enum ResourceType {
+ DATA,
+ CONFIG,
+ CACHE,
+ ICONS,
+ THEMES
+ }
+ [CCode (cheader_filename = "libxfce4util/libxfce4util.h")]
+ public static unowned string get_license_text (Xfce.LicenseTextType type);
+ [CCode (cname = "xfce_version_string", cheader_filename = "libxfce4util/libxfce4util.h")]
+ public static unowned string get_version_string ();
+ [CCode (cheader_filename = "libxfce4util/libxfce4util.h")]
+ public static void textdomain (string package, string localedir, string? encoding);
+}
Added: xfmpc/trunk/vapi/libxfcegui4-1.0.vapi
===================================================================
--- xfmpc/trunk/vapi/libxfcegui4-1.0.vapi (rev 0)
+++ xfmpc/trunk/vapi/libxfcegui4-1.0.vapi 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,512 @@
+/* libxfcegui4-1.0.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "Xfce", lower_case_cprefix = "xfce_")]
+namespace Xfce {
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class AboutDialog : Gtk.Dialog, Gtk.Buildable, Atk.Implementor {
+ public void add_credit (string name, string mail, string task);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public AboutDialog.empty ();
+ public unowned string get_copyright ();
+ public unowned string get_description ();
+ public unowned string get_homepage ();
+ public unowned Gdk.Pixbuf get_icon ();
+ public unowned string get_license ();
+ public unowned string get_program ();
+ public unowned string get_version ();
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public AboutDialog (Gtk.Window parent, Xfce.AboutInfo info, Gdk.Pixbuf icon);
+ public void set_copyright (string value);
+ public void set_description (string value);
+ public void set_homepage (string value);
+ public void set_icon (Gdk.Pixbuf icon);
+ public void set_license (string value);
+ public void set_program (string value);
+ public void set_version (string value);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public AboutDialog.with_values (Gtk.Window parent, Xfce.AboutInfo info, Gdk.Pixbuf icon);
+ public string copyright { get; set; }
+ public string description { get; set; }
+ public string homepage { get; set; }
+ public Gdk.Pixbuf icon { get; set; }
+ public string license { get; set; }
+ public string program { get; set; }
+ public string version { get; set; }
+ }
+ [Compact]
+ [CCode (copy_function = "xfce_about_info_copy", type_id = "XFCE_TYPE_ABOUT_INFO", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class AboutInfo {
+ public void add_credit (string name, string mail, string task);
+ public unowned Xfce.AboutInfo copy ();
+ public unowned string get_copyright ();
+ public unowned string get_description ();
+ public unowned string get_homepage ();
+ public unowned string get_license ();
+ public unowned string get_program ();
+ public unowned string get_version ();
+ [CCode (has_construct_function = false)]
+ public AboutInfo (string program, string version, string description, string copyright, string license);
+ public void set_copyright (string copyright);
+ public void set_description (string description);
+ public void set_homepage (string homepage);
+ public void set_license (string license);
+ public void set_program (string program);
+ public void set_version (string version);
+ }
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class AppMenuItem : Gtk.ImageMenuItem, Gtk.Buildable, Atk.Implementor {
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public AppMenuItem.full (string label, string command, string icon_filename, bool needs_term, bool snotify);
+ public unowned string get_command ();
+ public unowned string get_icon_name ();
+ public bool get_needs_term ();
+ public bool get_startup_notification ();
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public AppMenuItem ();
+ public void set_command (string command);
+ public void set_icon_name (string filename);
+ public static void set_icon_theme_name (string theme_name);
+ public void set_needs_term (bool needs_term);
+ public void set_startup_notification (bool snotify);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public AppMenuItem.with_command (string label, string command);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public AppMenuItem.with_label (string label);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public AppMenuItem.with_mnemonic (string label);
+ public string command { get; set; }
+ public string icon_name { get; set; }
+ [NoAccessorMethod]
+ public string label { owned get; set; }
+ public bool needs_term { get; set; }
+ [NoAccessorMethod]
+ public bool snotify { get; set; }
+ [NoAccessorMethod]
+ public bool use_underline { get; set; }
+ }
+ [Compact]
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class AppMenuItemPriv {
+ }
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class Heading : Gtk.Widget, Gtk.Buildable, Atk.Implementor {
+ public unowned Gdk.Pixbuf get_icon ();
+ public unowned string get_icon_name ();
+ public unowned string get_subtitle ();
+ public unowned string get_title ();
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public Heading ();
+ [NoWrapper]
+ public virtual void reserved0 ();
+ [NoWrapper]
+ public virtual void reserved1 ();
+ [NoWrapper]
+ public virtual void reserved2 ();
+ [NoWrapper]
+ public virtual void reserved3 ();
+ [NoWrapper]
+ public virtual void reserved4 ();
+ [NoWrapper]
+ public virtual void reserved5 ();
+ public void set_icon (Gdk.Pixbuf icon);
+ public void set_icon_name (string icon_name);
+ public void set_subtitle (string subtitle);
+ public void set_title (string title);
+ public Gdk.Pixbuf icon { get; set; }
+ public string icon_name { get; set; }
+ public string subtitle { get; set; }
+ public string title { get; set; }
+ }
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class Iconbutton : Gtk.Button, Gtk.Buildable, Atk.Implementor {
+ public int icon_height;
+ public int icon_width;
+ public weak Gtk.Widget image;
+ public weak Gdk.Pixbuf pb;
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public Iconbutton.from_pixbuf (Gdk.Pixbuf pb);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public Iconbutton ();
+ public void set_pixbuf (Gdk.Pixbuf pixbuf);
+ }
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class Menubutton : Gtk.Button, Gtk.Buildable, Atk.Implementor {
+ public weak Gtk.Widget hbox;
+ public int icon_size;
+ public weak Gtk.Widget image;
+ public weak Gtk.Widget label;
+ public weak Gdk.Pixbuf pb;
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public Menubutton (string text);
+ public void set_pixbuf (Gdk.Pixbuf pixbuf);
+ public void set_stock_icon (string stock);
+ public void set_text (string text);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public Menubutton.with_pixbuf (string text, Gdk.Pixbuf pb);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public Menubutton.with_stock_icon (string text, string stock);
+ }
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class ScaledImage : Gtk.Image, Gtk.Buildable, Atk.Implementor {
+ public int height;
+ public weak Gdk.Pixbuf pb;
+ public int width;
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public ScaledImage.from_pixbuf (Gdk.Pixbuf pb);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public ScaledImage ();
+ public void set_from_pixbuf (Gdk.Pixbuf pixbuf);
+ }
+ [Compact]
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class SessionClient {
+ public weak string client_id;
+ public weak string clone_command;
+ public weak string current_directory;
+ public Xfce.SessionClientState current_state;
+ public void* data;
+ public weak Xfce.die_callback die;
+ public weak string discard_command;
+ public weak string given_client_id;
+ public int interact;
+ public Xfce.SessionInteractStyle interact_style;
+ public char priority;
+ public weak string program;
+ public weak string resign_command;
+ public weak string restart_command;
+ public Xfce.SessionRestartStyle restart_style;
+ public weak Xfce.save_complete_callback save_complete;
+ public weak Xfce.save_phase_2_callback save_phase_2;
+ public weak Xfce.save_yourself_callback save_yourself;
+ public void* session_connection;
+ public bool shutdown;
+ public weak Xfce.shutdown_cancelled_callback shutdown_cancelled;
+ public weak string shutdown_command;
+ }
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class TitledDialog : Gtk.Dialog, Gtk.Buildable, Atk.Implementor {
+ public unowned string get_subtitle ();
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public TitledDialog ();
+ [NoWrapper]
+ public virtual void reserved0 ();
+ [NoWrapper]
+ public virtual void reserved1 ();
+ [NoWrapper]
+ public virtual void reserved2 ();
+ [NoWrapper]
+ public virtual void reserved3 ();
+ [NoWrapper]
+ public virtual void reserved4 ();
+ [NoWrapper]
+ public virtual void reserved5 ();
+ public void set_subtitle (string subtitle);
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public TitledDialog.with_buttons (string title, Gtk.Window parent, Gtk.DialogFlags flags, ...);
+ public string subtitle { get; set; }
+ }
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public class Togglebutton : Gtk.ToggleButton, Gtk.Buildable, Atk.Implementor {
+ public weak Gtk.Widget decortoggle;
+ public Gtk.ArrowType get_arrow_type ();
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public Togglebutton (Gtk.ArrowType arrow_type);
+ public void set_arrow_type (Gtk.ArrowType arrow_type);
+ }
+ [CCode (cprefix = "DIGIT_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum ClockLedSize {
+ SMALL,
+ MEDIUM,
+ LARGE,
+ HUGE
+ }
+ [CCode (cprefix = "XFCE_CLOCK_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum ClockMode {
+ ANALOG,
+ DIGITAL,
+ LEDS
+ }
+ [CCode (cprefix = "XFCE_DECORBUTTON_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum DecorbuttonType {
+ CLOSE,
+ HIDE
+ }
+ [CCode (cprefix = "XFCE_FILE_CHOOSER_ACTION_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum FileChooserAction {
+ OPEN,
+ SAVE,
+ SELECT_FOLDER,
+ CREATE_FOLDER
+ }
+ [CCode (cprefix = "XEV_FILTER_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum FilterStatus {
+ STOP,
+ CONTINUE
+ }
+ [CCode (cprefix = "XFCE_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum IconThemeCategory {
+ ICON_CATEGORY_UNKNOWN,
+ ICON_CATEGORY_EDITOR,
+ ICON_CATEGORY_FILEMAN,
+ ICON_CATEGORY_UTILITY,
+ ICON_CATEGORY_GAME,
+ ICON_CATEGORY_HELP,
+ ICON_CATEGORY_MULTIMEDIA,
+ ICON_CATEGORY_NETWORK,
+ ICON_CATEGORY_GRAPHICS,
+ ICON_CATEGORY_PRINTER,
+ ICON_CATEGORY_PRODUCTIVITY,
+ ICON_CATEGORY_OFFICE,
+ ICON_CATEGORY_SOUND,
+ ICON_CATEGORY_TERMINAL,
+ ICON_CATEGORY_DEVELOPMENT,
+ ICON_CATEGORY_SETTINGS,
+ ICON_CATEGORY_SYSTEM,
+ ICON_CATEGORY_WINE,
+ ICON_CATEGORY_ACCESSORIES,
+ N_BUILTIN_ICON_CATEGORIES
+ }
+ [CCode (cprefix = "SESSION_CLIENT_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum SessionClientState {
+ IDLE,
+ SAVING_PHASE_1,
+ WAITING_FOR_PHASE_2,
+ SAVING_PHASE_2,
+ WAITING_FOR_INTERACT,
+ DONE_WITH_INTERACT,
+ FROZEN,
+ DISCONNECTED,
+ REGISTERING
+ }
+ [CCode (cprefix = "SESSION_INTERACT_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum SessionInteractStyle {
+ NONE,
+ ERRORS,
+ ANY
+ }
+ [CCode (cprefix = "SESSION_RESTART_", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public enum SessionRestartStyle {
+ IF_RUNNING,
+ ANYWAY,
+ IMMEDIATELY,
+ NEVER
+ }
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static delegate void die_callback (void* client_data);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static delegate void interact_callback (void* client_data, Xfce.SessionInteractStyle interact_style);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static delegate void save_complete_callback (void* client_data);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static delegate void save_phase_2_callback (void* client_data);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static delegate void save_yourself_callback (void* client_data, int save_style, bool shutdown, int interact_style, bool fast);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static delegate void shutdown_cancelled_callback (void* client_data);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const string CUSTOM_BUTTON;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const string CUSTOM_PIXBUF_BUTTON;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const string CUSTOM_STOCK_BUTTON;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const int LIBXFCEGUI4_MAJOR_VERSION;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const int LIBXFCEGUI4_MICRO_VERSION;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const int LIBXFCEGUI4_MINOR_VERSION;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const string STARTUP_NOTIFICATION_ENVIRONMENT_DESKTOP_STARTUP_ID;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const int SYSTEM_TRAY_BEGIN_MESSAGE;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const int SYSTEM_TRAY_CANCEL_MESSAGE;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const int SYSTEM_TRAY_REQUEST_DOCK;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public const int UPDATE_DELAY_LENGTH;
+ [CCode (cname = "client_session_free", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_free (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_client_id", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_client_id (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_clone_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_clone_command (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_current_directory", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_current_directory (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_current_state", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static Xfce.SessionClientState client_session_get_current_state (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_data", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void* client_session_get_data (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_die_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Xfce.die_callback client_session_get_die_callback (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_discard_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_discard_command (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_given_client_id", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_given_client_id (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_interact_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static int client_session_get_interact_callback (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_interact_style", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static Xfce.SessionInteractStyle client_session_get_interact_style (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_priority", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static char client_session_get_priority (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_program", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_program (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_resign_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_resign_command (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_restart_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_restart_command (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_restart_style", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static Xfce.SessionRestartStyle client_session_get_restart_style (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_save_complete_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Xfce.save_complete_callback client_session_get_save_complete_callback (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_save_phase_2_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Xfce.save_phase_2_callback client_session_get_save_phase_2_callback (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_save_yourself_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Xfce.save_yourself_callback client_session_get_save_yourself_callback (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_session_connection", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void* client_session_get_session_connection (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_shutdown_cancelled_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Xfce.shutdown_cancelled_callback client_session_get_shutdown_cancelled_callback (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_get_shutdown_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string client_session_get_shutdown_command (Xfce.SessionClient session_client);
+ [CCode (cname = "client_session_new", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Xfce.SessionClient client_session_new (int argc, string[] argv, void* data, Xfce.SessionRestartStyle restart_style, char priority);
+ [CCode (cname = "client_session_new_full", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Xfce.SessionClient client_session_new_full (void* data, Xfce.SessionRestartStyle restart_style, char priority, string client_id, string program, string current_directory, string restart_command, string clone_command, string discard_command, string resign_command, string shutdown_command);
+ [CCode (cname = "client_session_set_client_id", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_client_id (Xfce.SessionClient session_client, string value);
+ [CCode (cname = "client_session_set_clone_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_clone_command (Xfce.SessionClient session_client, string value);
+ [CCode (cname = "client_session_set_current_directory", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_current_directory (Xfce.SessionClient session_client, string value);
+ [CCode (cname = "client_session_set_data", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_data (Xfce.SessionClient session_client, void* value);
+ [CCode (cname = "client_session_set_die_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_die_callback (Xfce.SessionClient session_client, Xfce.die_callback value);
+ [CCode (cname = "client_session_set_discard_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_discard_command (Xfce.SessionClient session_client, string value);
+ [CCode (cname = "client_session_set_interact_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_interact_callback (Xfce.SessionClient session_client, int value);
+ [CCode (cname = "client_session_set_priority", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_priority (Xfce.SessionClient session_client, char value);
+ [CCode (cname = "client_session_set_program", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_program (Xfce.SessionClient session_client, string value);
+ [CCode (cname = "client_session_set_resign_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_resign_command (Xfce.SessionClient session_client, string value);
+ [CCode (cname = "client_session_set_restart_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_restart_command (Xfce.SessionClient session_client, string value);
+ [CCode (cname = "client_session_set_restart_style", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_restart_style (Xfce.SessionClient session_client, Xfce.SessionRestartStyle value);
+ [CCode (cname = "client_session_set_save_complete_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_save_complete_callback (Xfce.SessionClient session_client, Xfce.save_complete_callback value);
+ [CCode (cname = "client_session_set_save_phase_2_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_save_phase_2_callback (Xfce.SessionClient session_client, Xfce.save_phase_2_callback value);
+ [CCode (cname = "client_session_set_save_yourself_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_save_yourself_callback (Xfce.SessionClient session_client, Xfce.save_yourself_callback value);
+ [CCode (cname = "client_session_set_shutdown_cancelled_callback", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_shutdown_cancelled_callback (Xfce.SessionClient session_client, Xfce.shutdown_cancelled_callback value);
+ [CCode (cname = "client_session_set_shutdown_command", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void client_session_set_shutdown_command (Xfce.SessionClient session_client, string value);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool confirm (string text, string stock_id, string action);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gtk.Widget create_framebox (string title, out unowned Gtk.Widget frame_bin);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gtk.Widget create_framebox_with_content (string title, Gtk.Widget content);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gtk.Widget create_header (Gdk.Pixbuf icon, string text);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gtk.Widget create_header_with_image (Gtk.Widget image, string text);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gtk.Widget create_mixed_button (string stock, string text);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gtk.Widget create_small_label (string text);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void err (string format);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec (string cmd, bool in_terminal, bool use_sn) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_argv (out unowned string argv, bool in_terminal, bool use_sn) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_argv_on_screen (Gdk.Screen screen, out unowned string argv, bool in_terminal, bool use_sn) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_argv_with_envp (out unowned string argv, bool in_terminal, bool use_sn, out unowned string envp) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_argv_with_envp_on_screen (Gdk.Screen screen, out unowned string argv, bool in_terminal, bool use_sn, out unowned string envp) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_on_screen (Gdk.Screen screen, string cmd, bool in_terminal, bool use_sn) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_sync (string cmd, bool in_terminal, bool use_sn) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_sync_with_envp (string cmd, bool in_terminal, bool use_sn, out unowned string envp) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_with_envp (string cmd, bool in_terminal, bool use_sn, out unowned string envp) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool exec_with_envp_on_screen (Gdk.Screen screen, string cmd, bool in_terminal, bool use_sn, out unowned string envp) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string gdk_display_get_fullname (Gdk.Display display);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gdk.Screen gdk_display_locate_monitor_with_pointer (Gdk.Display display, int monitor_return);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string gdk_screen_get_fullname (Gdk.Screen screen);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool gdk_spawn_command_line_on_screen (Gdk.Screen screen, string command_line) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool gdk_spawn_on_screen (Gdk.Screen screen, string working_directory, string argv, string envp, GLib.SpawnFlags flags, GLib.SpawnChildSetupFunc child_setup, int child_pid) throws GLib.Error;
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool gdk_spawn_on_screen_with_pipes (Gdk.Screen screen, string working_directory, string argv, string envp, GLib.SpawnFlags flags, GLib.SpawnChildSetupFunc child_setup, int child_pid, int standard_input, int standard_output, int standard_error) throws GLib.Error;
+ [CCode (cname = "get_font_desc", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Pango.FontDescription get_font_desc (Gtk.Widget widget);
+ [CCode (cname = "get_style", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string get_style (Gtk.Widget widget, string name, string state);
+ [CCode (cname = "get_style_gc", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gdk.GC get_style_gc (Gtk.Widget widget, string state, string style);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void gtk_window_center_on_monitor (Gtk.Window window, Gdk.Screen screen, int monitor);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void gtk_window_center_on_monitor_with_pointer (Gtk.Window window);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void info (string format);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gdk.Pixbuf inline_icon_at_size (uchar data, int width, int height);
+ [CCode (cname = "logout_session", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void logout_session (Xfce.SessionClient session_client);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static int message_dialog (Gtk.Window parent, string title, string icon_id, string primary_text, string secondary_text, ...);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gtk.Widget message_dialog_new (Gtk.Window parent, string title, string icon_id, string primary_text, string secondary_text, ...);
+ [CCode (cname = "pango_get_context", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Pango.Context pango_get_context (Gtk.Widget widget);
+ [CCode (cname = "session_init", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static bool session_init (Xfce.SessionClient session_client);
+ [CCode (cname = "session_shutdown", cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void session_shutdown (Xfce.SessionClient session_client);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void startup_notification_cancel (string id);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string startup_notification_cleanup_environment (out unowned string envp);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string startup_notification_modify_environment (out unowned string envp, string id);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string startup_notification_start (Gdk.Screen screen, string path);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gdk.Pixbuf themed_icon_load (string name, int size);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gdk.Pixbuf themed_icon_load_category (Xfce.IconThemeCategory category, int size);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned Gdk.Pixbuf themed_icon_load_list (GLib.List names, int size);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string themed_icon_lookup (string name, int size);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string themed_icon_lookup_category (Xfce.IconThemeCategory category, int size);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static unowned string themed_icon_lookup_list (GLib.List names, int size);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void verr (string format, void* ap);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void vinfo (string format, void* ap);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void vwarn (string format, void* ap);
+ [CCode (cheader_filename = "libxfcegui4/libxfcegui4.h")]
+ public static void warn (string format);
+}
Added: xfmpc/trunk/vapi/mpdclient.vapi
===================================================================
--- xfmpc/trunk/vapi/mpdclient.vapi (rev 0)
+++ xfmpc/trunk/vapi/mpdclient.vapi 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,72 @@
+/* mpdclient.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "Xfmpc", lower_case_cprefix = "xfmpc_")]
+namespace Xfmpc {
+ [Compact]
+ [CCode (cheader_filename = "mpdclient.h")]
+ public class Mpdclient {
+ public bool connect ();
+ public bool database_read (string dir, string *filename, string *basename, bool *is_dir);
+ public bool database_refresh ();
+ public bool database_search (string query, string *filename, string *basename);
+ public void disconnect ();
+ public static unowned Xfmpc.Mpdclient get ();
+ public unowned string get_album ();
+ public unowned string get_artist ();
+ public unowned string get_date ();
+ public int get_id ();
+ public int get_pos ();
+ public bool get_random ();
+ public bool get_repeat ();
+ public unowned Xfmpc.SongInfo get_song_info (int id);
+ public int get_time ();
+ public unowned string get_title ();
+ public int get_total_time ();
+ public uchar get_volume ();
+ public bool is_connected ();
+ public bool is_playing ();
+ public bool is_stopped ();
+ public bool next ();
+ public bool pause ();
+ public bool play ();
+ public bool playlist_clear ();
+ public int playlist_get_length ();
+ public int playlist_get_total_time ();
+ public bool playlist_has_filename (string filename, bool is_dir);
+ public bool playlist_read (int *id, int *pos, string *filename, string *song, string *length);
+ public bool pp ();
+ public bool previous ();
+ public bool queue_add (string path);
+ public bool queue_clear ();
+ public bool queue_commit ();
+ public bool queue_remove_id (int id);
+ public bool set_id (int id);
+ public bool set_random (bool random);
+ public bool set_repeat (bool repeat);
+ public bool set_song_time (uint time);
+ public bool set_volume (uchar volume);
+ public bool stop ();
+ public void update_status ();
+ public virtual signal void connected ();
+ public virtual signal void song_changed ();
+ public virtual signal void pp_changed ();
+ public virtual signal void time_changed ();
+ public virtual signal void volume_changed ();
+ public virtual signal void stopped ();
+ public virtual signal void database_changed ();
+ public virtual signal void playlist_changed ();
+ public virtual signal void repeat ();
+ public virtual signal void random ();
+ }
+ [Compact]
+ [CCode (cheader_filename = "mpdclient.h")]
+ public class SongInfo {
+ public weak string album;
+ public weak string artist;
+ public weak string date;
+ public weak string filename;
+ public weak string genre;
+ public weak string title;
+ public weak string track;
+ }
+}
Added: xfmpc/trunk/vapi/preferences.vapi
===================================================================
--- xfmpc/trunk/vapi/preferences.vapi (rev 0)
+++ xfmpc/trunk/vapi/preferences.vapi 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,37 @@
+/* preferences.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "Xfmpc", lower_case_cprefix = "xfmpc_")]
+namespace Xfmpc {
+ [Compact]
+ [CCode (cheader_filename = "preferences.h")]
+ public class Preferences {
+ public static unowned Xfmpc.Preferences get ();
+ public int last_window_posx;
+ public int last_window_posy { get; set; }
+ public int last_window_width { get; set; }
+ public int last_window_height { get; set; }
+ public bool last_window_state_sticky { get; set; }
+ public bool playlist_autocenter { get; set; }
+ public string dbbrowser_last_path { get; set; }
+ public string mpd_hostname { get; set; }
+ public int mpd_port { get; set; }
+ public string mpd_password { get; set; }
+ public bool mpd_use_defaults { get; set; }
+ public bool show_statusbar { get; set; }
+ public int song_format { get; set; }
+ public string song_format_custom { get; set; }
+ public virtual signal void notify (GLib.ParamSpec pspec);
+ }
+ [CCode (cprefix = "XFMPC_SONG_FORMAT_", has_type_id = "0", cheader_filename = "preferences.h")]
+ public enum SongFormat {
+ TITLE,
+ ALBUM_TITLE,
+ ARTIST_TITLE,
+ ARTIST_TITLE_DATE,
+ ARTIST_ALBUM_TITLE,
+ ARTIST_ALBUM_TRACK_TITLE,
+ CUSTOM
+ }
+ [CCode (cheader_filename = "preferences.h")]
+ public static GLib.Type song_format_get_type ();
+}
Added: xfmpc/trunk/vapi/xfce-arrow-button.vapi
===================================================================
--- xfmpc/trunk/vapi/xfce-arrow-button.vapi (rev 0)
+++ xfmpc/trunk/vapi/xfce-arrow-button.vapi 2009-04-23 11:11:39 UTC (rev 7280)
@@ -0,0 +1,16 @@
+/* xfce-arrow-button.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "Xfce", lower_case_cprefix = "xfce_")]
+namespace Xfce {
+ [CCode (free_function = "")]
+ [Compact]
+ [CCode (cheader_filename = "xfce-arrow-button.h")]
+ public class ArrowButton {
+ public Gtk.ArrowType arrow_type;
+ public weak Gtk.ToggleButton parent;
+ public Gtk.ArrowType get_arrow_type ();
+ [CCode (type = "GtkWidget*", has_construct_function = false)]
+ public ArrowButton (Gtk.ArrowType type);
+ public void set_arrow_type (Gtk.ArrowType type);
+ }
+}
More information about the Goodies-commits
mailing list