Mercurial > audlegacy-plugins
changeset 2409:f67bdd91620a
Add some UI niceities.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Mon, 18 Feb 2008 02:57:17 -0600 |
parents | 88168440e223 |
children | d0c5974cad17 |
files | src/projectm-1.0/gtk_projectm_impl.cxx src/projectm-1.0/gtk_projectm_impl.h src/projectm-1.0/main.c |
diffstat | 3 files changed, 87 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/projectm-1.0/gtk_projectm_impl.cxx Mon Feb 18 02:03:54 2008 -0600 +++ b/src/projectm-1.0/gtk_projectm_impl.cxx Mon Feb 18 02:57:17 2008 -0600 @@ -21,6 +21,7 @@ #include <math.h> #include <libprojectM/projectM.hpp> +#include <libprojectM/event.h> #include <GL/gl.h> #define CONFIG_FILE "/share/projectM/config.inp" @@ -88,6 +89,39 @@ priv->pm->pcm->addPCM16(pcm_data); } +extern "C" void +gtk_projectm_toggle_preset_lock(GtkWidget *widget) +{ + struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); + + g_return_if_fail(priv != NULL); + g_return_if_fail(priv->pm != NULL); + + priv->pm->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_l, PROJECTM_KMOD_LSHIFT); +} + +extern "C" void +gtk_projectm_preset_prev(GtkWidget *widget) +{ + struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); + + g_return_if_fail(priv != NULL); + g_return_if_fail(priv->pm != NULL); + + priv->pm->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_p, PROJECTM_KMOD_LSHIFT); +} + +extern "C" void +gtk_projectm_preset_next(GtkWidget *widget) +{ + struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); + + g_return_if_fail(priv != NULL); + g_return_if_fail(priv->pm != NULL); + + priv->pm->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_n, PROJECTM_KMOD_LSHIFT); +} + static void _gtk_projectm_realize_impl(GtkWidget *widget, gpointer data) {
--- a/src/projectm-1.0/gtk_projectm_impl.h Mon Feb 18 02:03:54 2008 -0600 +++ b/src/projectm-1.0/gtk_projectm_impl.h Mon Feb 18 02:57:17 2008 -0600 @@ -20,5 +20,8 @@ GtkWidget *gtk_projectm_new(void); void gtk_projectm_add_pcm_data(GtkWidget *widget, gint16 pcm_data[2][512]); +void gtk_projectm_toggle_preset_lock(GtkWidget *widget); +void gtk_projectm_preset_prev(GtkWidget *widget); +void gtk_projectm_preset_next(GtkWidget *widget); G_END_DECLS
--- a/src/projectm-1.0/main.c Mon Feb 18 02:03:54 2008 -0600 +++ b/src/projectm-1.0/main.c Mon Feb 18 02:57:17 2008 -0600 @@ -1,13 +1,15 @@ /* * main.cxx: plugin glue to libprojectm * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk> - * Portions copyright (c) 2004-2006 Peter Sperl * * This program is free software; you may distribute it under the terms * of the GNU General Public License; version 2. */ +#include "config.h" + #include <audacious/plugin.h> +#include <audacious/i18n.h> #include "gtk_projectm_impl.h" @@ -15,9 +17,35 @@ GtkWidget *window = NULL; void +projectM_toggle_random(GtkToggleButton *button, gpointer unused) +{ + g_return_if_fail(projectm != NULL); + + gtk_projectm_toggle_preset_lock(projectm); +} + +void +projectM_preset_prev(void) +{ + g_return_if_fail(projectm != NULL); + + gtk_projectm_preset_prev(projectm); +} + +void +projectM_preset_next(void) +{ + g_return_if_fail(projectm != NULL); + + gtk_projectm_preset_next(projectm); +} + +void projectM_init(void) { GtkWidget *vbox; + GtkWidget *bbox; + GtkWidget *button; if (window) return; @@ -34,6 +62,27 @@ gtk_box_pack_start(GTK_BOX(vbox), projectm, TRUE, TRUE, 0); gtk_widget_show(projectm); + bbox = gtk_hbutton_box_new(); + gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_START); + gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0); + gtk_widget_show(bbox); + + button = gtk_toggle_button_new_with_mnemonic(_("_Random")); + gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); + g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(projectM_toggle_random), NULL); + gtk_widget_show(button); + + button = gtk_button_new_from_stock(GTK_STOCK_GO_BACK); + gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(projectM_preset_prev), NULL); + gtk_widget_show(button); + + button = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD); + gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(projectM_preset_next), NULL); + gtk_widget_show(button); + gtk_widget_show(window); }