[Goodies-commits] r3837 - xfmpc/trunk/src
Mike Massonnet
mmassonnet at xfce.org
Mon Jan 21 16:51:05 CET 2008
Author: mmassonnet
Date: 2008-01-21 15:51:05 +0000 (Mon, 21 Jan 2008)
New Revision: 3837
Added:
xfmpc/trunk/src/interface-ui.h
xfmpc/trunk/src/interface-ui.xml
Modified:
xfmpc/trunk/src/interface.c
Log:
* src/interface-ui.h, src/interface-ui.xml:
- New files, XML reprensents the GtkUIManager, .h is auto-generated with
exo-csource
* src/interface.c:
- Add accelerators: Ctrl+B/P/S/F to respectively go backwards, play/pause,
stop, and go forward
Added: xfmpc/trunk/src/interface-ui.h
===================================================================
--- xfmpc/trunk/src/interface-ui.h (rev 0)
+++ xfmpc/trunk/src/interface-ui.h 2008-01-21 15:51:05 UTC (rev 3837)
@@ -0,0 +1,17 @@
+/* automatically generated from interface-ui.xml */
+#ifdef __SUNPRO_C
+#pragma align 4 (xfmpc_interface_ui)
+#endif
+#ifdef __GNUC__
+static const char xfmpc_interface_ui[] __attribute__ ((__aligned__ (4))) =
+#else
+static const char xfmpc_interface_ui[] =
+#endif
+{
+ "<ui>\n\n <accelerator action=\"previous\" />\n <accelerator action=\""
+ "pp\" />\n <accelerator action=\"stop\" />\n <accelerator action=\"nex"
+ "t\" />\n <accelerator action=\"quit\" />\n\n</ui>\n\n"
+};
+
+static const unsigned xfmpc_interface_ui_length = 176u;
+
Added: xfmpc/trunk/src/interface-ui.xml
===================================================================
--- xfmpc/trunk/src/interface-ui.xml (rev 0)
+++ xfmpc/trunk/src/interface-ui.xml 2008-01-21 15:51:05 UTC (rev 3837)
@@ -0,0 +1,10 @@
+<ui>
+
+ <accelerator action="previous" />
+ <accelerator action="pp" />
+ <accelerator action="stop" />
+ <accelerator action="next" />
+ <accelerator action="quit" />
+
+</ui>
+
Modified: xfmpc/trunk/src/interface.c
===================================================================
--- xfmpc/trunk/src/interface.c 2008-01-21 10:04:55 UTC (rev 3836)
+++ xfmpc/trunk/src/interface.c 2008-01-21 15:51:05 UTC (rev 3837)
@@ -25,6 +25,7 @@
#include <libxfce4util/libxfce4util.h>
#include "interface.h"
+#include "interface-ui.h"
#include "mpdclient.h"
#define BORDER 4
@@ -39,8 +40,17 @@
static gboolean xfmpc_interface_reconnect (XfmpcInterface *interface);
+static void xfmpc_interface_action_previous (GtkAction *action,
+ XfmpcInterface *interface);
+static void xfmpc_interface_action_pp (GtkAction *action,
+ XfmpcInterface *interface);
+static void xfmpc_interface_action_stop (GtkAction *action,
+ XfmpcInterface *interface);
+static void xfmpc_interface_action_next (GtkAction *action,
+ XfmpcInterface *interface);
+
struct _XfmpcInterfaceClass
{
GtkWindowClass parent_class;
@@ -68,6 +78,17 @@
+static const GtkActionEntry action_entries[] =
+{
+ { "previous", NULL, N_("Previous"), "<control>b", NULL, G_CALLBACK (xfmpc_interface_action_previous), },
+ { "pp", NULL, N_("Play/Pause"), "<control>p", NULL, G_CALLBACK (xfmpc_interface_action_pp), },
+ { "stop", NULL, N_("Stop"), "<control>s", NULL, G_CALLBACK (xfmpc_interface_action_stop), },
+ { "next", NULL, N_("Next"), "<control>f", NULL, G_CALLBACK (xfmpc_interface_action_next), },
+ { "quit", NULL, N_("Quit"), "<control>q", NULL, G_CALLBACK (gtk_main_quit), },
+};
+
+
+
static GObjectClass *parent_class = NULL;
@@ -124,10 +145,6 @@
gtk_container_set_border_width (GTK_CONTAINER (interface), BORDER);
g_signal_connect (G_OBJECT (interface), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
- /* === Accel group === */
- GtkAccelGroup *accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group (GTK_WINDOW (interface), accel_group);
-
/* === Interface widgets === */
GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PREVIOUS, GTK_ICON_SIZE_BUTTON);
GtkWidget *control = interface->priv->button_prev = gtk_button_new ();
@@ -201,6 +218,18 @@
gtk_container_add (GTK_CONTAINER (box), interface->priv->title);
gtk_container_add (GTK_CONTAINER (box), interface->priv->subtitle);
+ /* === Accelerators === */
+ GtkActionGroup *action_group = gtk_action_group_new ("XfmpcInterface");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group, action_entries, G_N_ELEMENTS (action_entries), GTK_WINDOW (interface));
+
+ GtkUIManager *ui_manager = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+ gtk_ui_manager_add_ui_from_string (ui_manager, xfmpc_interface_ui, xfmpc_interface_ui_length, NULL);
+
+ GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (ui_manager);
+ gtk_window_add_accel_group (GTK_WINDOW (interface), accel_group);
+
/* === Signals === */
g_signal_connect_swapped (interface->priv->button_prev, "clicked",
G_CALLBACK (xfmpc_mpdclient_previous), interface->priv->mpdclient);
@@ -412,3 +441,33 @@
return FALSE;
}
+
+
+static void
+xfmpc_interface_action_previous (GtkAction *action,
+ XfmpcInterface *interface)
+{
+ xfmpc_mpdclient_previous (interface->priv->mpdclient);
+}
+
+static void
+xfmpc_interface_action_pp (GtkAction *action,
+ XfmpcInterface *interface)
+{
+ xfmpc_interface_pp_clicked (interface);
+}
+
+static void
+xfmpc_interface_action_stop (GtkAction *action,
+ XfmpcInterface *interface)
+{
+ xfmpc_mpdclient_stop (interface->priv->mpdclient);
+}
+
+static void
+xfmpc_interface_action_next (GtkAction *action,
+ XfmpcInterface *interface)
+{
+ xfmpc_mpdclient_next (interface->priv->mpdclient);
+}
+
More information about the Goodies-commits
mailing list