From a5ec6dbcd260f5407fef5467807f7d812d221e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Sun, 1 Feb 2009 19:05:42 +0100 Subject: [PATCH] some more work on gui --- gui.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 128 insertions(+), 22 deletions(-) diff --git a/gui.c b/gui.c index 8bdcd7a..6026a26 100644 --- a/gui.c +++ b/gui.c @@ -51,9 +51,15 @@ static SettingsWidget wah_widgets[] = { {"Wah level", set_wah_level, NULL, 0.0, 12.0}, }; -static SettingsWidget comp_widgets[] = { +static SettingsWidget comp_digi_widgets[] = { + {"Compressor sustain", set_comp_sustain, NULL, 0.0, 99.0}, + {"Compressor tone", set_comp_tone, NULL, 0.0, 99.0}, + {"Compressor attack", set_comp_attack, NULL, 0.0, 99.0}, + {"Compressor level", set_comp_level, NULL, 0.0, 99.0}, +}; + +static SettingsWidget comp_cs_widgets[] = { {"Compressor sustain", set_comp_sustain, NULL, 0.0, 99.0}, - {"Compressor tone (digi only!)", set_comp_tone, NULL, 0.0, 99.0}, {"Compressor attack", set_comp_attack, NULL, 0.0, 99.0}, {"Compressor level", set_comp_level, NULL, 0.0, 99.0}, }; @@ -414,37 +420,137 @@ GtkWidget *create_on_off_button(const gchar *label, gboolean state, void (*callb return button; } +typedef struct { + gint id; + gchar *label; + void (*callback)(struct usb_dev_handle*, int); + SettingsWidget *widgets; + gint widgets_amt; + GtkWidget *child; /* child widget - set inside create_widget_container */ +} WidgetContainer; + +static WidgetContainer wah_container[] = { + {-1, NULL, NULL, wah_widgets, G_N_ELEMENTS(wah_widgets), NULL}, +}; + +static WidgetContainer comp_container[] = { + {COMP_TYPE_DIGI, "Digital compressor", set_comp_type, comp_digi_widgets, G_N_ELEMENTS(comp_digi_widgets), NULL}, + {COMP_TYPE_CS, "CS compressor", set_comp_type, comp_cs_widgets, G_N_ELEMENTS(comp_cs_widgets), NULL}, +}; + +void combo_box_changed_cb(GtkComboBox *widget, WidgetContainer *widgets) +{ + GtkWidget *child; + GtkWidget *vbox; + gint x; + g_object_get(G_OBJECT(widget), "active", &x, NULL); + + vbox = g_object_get_data(G_OBJECT(widget), "vbox"); + + if (x != -1) { + widgets[x].callback(handle, widgets[x].id); + child = g_object_get_data(G_OBJECT(widget), "active_child"); + if (child != NULL) { + gtk_container_remove(GTK_CONTAINER(vbox), child); + } + gtk_container_add(GTK_CONTAINER(vbox), widgets[x].child); + gtk_widget_show_all(vbox); + g_object_set_data(G_OBJECT(widget), "active_child", widgets[x].child); + } +} + +GtkWidget *create_widget_container(WidgetContainer *widgets, gint amt) +{ + GtkWidget *vbox; + GtkWidget *widget; + GtkWidget *combo_box = NULL; + gint x; + + vbox = gtk_vbox_new(FALSE, 0); + + for (x = 0; x