summaryrefslogtreecommitdiff
path: root/src/win_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/win_main.c')
-rw-r--r--src/win_main.c112
1 files changed, 87 insertions, 25 deletions
diff --git a/src/win_main.c b/src/win_main.c
index 08e6b4a..01d5561 100644
--- a/src/win_main.c
+++ b/src/win_main.c
@@ -1,11 +1,80 @@
+/*
+ Instru2Light - Illumine un instrument de musique en temps réel
+ Copyright (C) 2012 Ludovic Pouzenc <lpouzenc@gmail.com>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
#include "win_main.h"
#include "gtkvumeter.h"
+#define FUNC_COUNT 4
+
+GtkBuilder *builder=NULL;
GtkWidget *vumeter_sound, *vumeter_r, *vumeter_g, *vumeter_b, *vumeter_h, *vumeter_s, *vumeter_v;
+void add_custom_widgets();
+
+// Applicative actions
+void switch_to_func(gint func_id) {
+ printf("switch_to_func(%i)\n", func_id);
+}
+
+// GUI events
+void on_win_main_destroy(GtkObject *object, gpointer user_data) {
+ gtk_main_quit();
+}
+
+void on_mi_about_activate(GtkObject *object, gpointer user_data) {
+ GtkDialog *dialog;
+
+ g_return_if_fail(builder!=NULL);
+
+ dialog = GTK_DIALOG(gtk_builder_get_object(builder, "win_about"));
+ g_return_if_fail(dialog!=NULL);
+
+ g_signal_connect_swapped (dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
+ gtk_widget_show_all(GTK_WIDGET(dialog));
+}
+
+void on_action1_activate(GtkObject *object, gpointer user_data) { switch_to_func(0); }
+void on_action2_activate(GtkObject *object, gpointer user_data) { switch_to_func(1); }
+void on_action3_activate(GtkObject *object, gpointer user_data) { switch_to_func(2); }
+void on_action4_activate(GtkObject *object, gpointer user_data) { switch_to_func(3); }
+
+
+void on_radbut_func_realize(GtkObject *object, gpointer user_data) {
+ // This makes the radio buttons look like a Toogle Button (that's a fucking trick)
+ gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(object),FALSE);
+}
+
GtkWidget *win_main_build() {
- GtkWidget *win, *hbox1;
+ GtkWidget *window;
+
+ builder = gtk_builder_new();
+ gtk_builder_add_from_file(builder, "gui.glade", NULL);
+
+ window = GTK_WIDGET(gtk_builder_get_object(builder, "win_main"));
+ gtk_builder_connect_signals(builder, NULL);
+
+ add_custom_widgets();
+ //FIXME : to be done at the right place
+ //g_object_unref(G_OBJECT(builder));
+ return window;
+}
+void add_custom_widgets() {
+ GtkContainer *c;
GdkColor f_gradient_red[2] = {{0,65535,0,0},{0,32767,0,0}};
GdkColor b_gradient_red[2] = {{0,49151,0,0},{0,24575,0,0}};
GdkColor f_gradient_green[2] = {{0,0,65535,0},{0,0,32767,0}};
@@ -14,50 +83,43 @@ GtkWidget *win_main_build() {
GdkColor b_gradient_blue[2] = {{0,0,0,49151},{0,0,0,24575}};
GdkColor f_gradient_hue[7] = {{0,65535,0,0},{0,65535,0,65535},{0,0,0,65535},{0,0,65535,65535},{0,0,65535,0},{0,65535,65535,0},{0,65535,0,0}};
GdkColor b_gradient_hue[7] = {{0,49151,0,0},{0,49151,0,49151},{0,0,0,49151},{0,0,49151,49151},{0,0,49151,0},{0,49151,49151,0},{0,49151,0,0}};
+ GdkColor f_gradient_value[2] = {{0,65535,0,0},{0,16384,0,0}};
+ GdkColor b_gradient_value[2] = {{0,49151,0,0},{0,0,0,0}};
+ GdkColor f_gradient_saturation[2] = {{0,32767,0,0},{0,32767,32767,32767}};
+ GdkColor b_gradient_saturation[2] = {{0,24575,0,0},{0,24575,24575,24575}};
- win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
- hbox1 = gtk_hbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(win), hbox1);
- gtk_container_set_border_width(GTK_CONTAINER(hbox1), 5);
-
-//TODO : gtk_vumeter_set_min_max (GTK_VU_METER(vumeter), min, max);
- vumeter_sound = gtk_vu_meter_new (TRUE);
+ vumeter_sound = gtk_vu_meter_new(TRUE);
gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_sound), -50, 0);
- gtk_box_pack_start(GTK_BOX(hbox1), vumeter_sound, FALSE, FALSE, 0);
+ c=GTK_CONTAINER(gtk_builder_get_object(builder, "a_in_sound"));
+ gtk_container_add(c,vumeter_sound);
vumeter_h = gtk_vu_meter_new (TRUE);
gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_h), 0, 255);
gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_h), 7, f_gradient_hue, 7, b_gradient_hue);
- gtk_box_pack_start(GTK_BOX(hbox1), vumeter_h, FALSE, FALSE, 0);
-
vumeter_s = gtk_vu_meter_new (TRUE);
gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_s), 0, 255);
- gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_s), 2, f_gradient_red, 2, b_gradient_red);
- gtk_box_pack_start(GTK_BOX(hbox1), vumeter_s, FALSE, FALSE, 0);
-
+ gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_s), 2, f_gradient_value, 2, b_gradient_value);
vumeter_v = gtk_vu_meter_new (TRUE);
gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_v), 0, 255);
- gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_v), 2, f_gradient_red, 2, b_gradient_red);
- gtk_box_pack_start(GTK_BOX(hbox1), vumeter_v, FALSE, FALSE, 0);
-
+ gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_v), 2, f_gradient_saturation, 2, b_gradient_saturation);
+ c=GTK_CONTAINER(gtk_builder_get_object(builder, "hb_out_hsv"));
+ gtk_container_add(c,vumeter_h);
+ gtk_container_add(c,vumeter_s);
+ gtk_container_add(c,vumeter_v);
vumeter_r = gtk_vu_meter_new (TRUE);
gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_r), 0, 255);
gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_r), 2, f_gradient_red, 2, b_gradient_red);
- gtk_box_pack_start(GTK_BOX(hbox1), vumeter_r, FALSE, FALSE, 0);
-
vumeter_g = gtk_vu_meter_new (TRUE);
gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_g), 0, 255);
gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_g), 2, f_gradient_green, 2, b_gradient_green);
- gtk_box_pack_start(GTK_BOX(hbox1), vumeter_g, FALSE, FALSE, 0);
-
vumeter_b = gtk_vu_meter_new (TRUE);
gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_b), 0, 255);
gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_b), 2, f_gradient_blue, 2, b_gradient_blue);
- gtk_box_pack_start(GTK_BOX(hbox1), vumeter_b, FALSE, FALSE, 0);
-
- return win;
+ c=GTK_CONTAINER(gtk_builder_get_object(builder, "hb_out_rgb"));
+ gtk_container_add(c,vumeter_r);
+ gtk_container_add(c,vumeter_g);
+ gtk_container_add(c,vumeter_b);
}
gboolean win_main_update_vumeters(gpointer vals) {