summaryrefslogtreecommitdiff
path: root/tests/test7/test7.c
blob: adaf2c8d4a21ecc15f8d90c8efff4069c54c0691 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <gtk/gtk.h>
#include <stdio.h>
#include "gtkvumeter.h"

#define FUNC_COUNT 4

GtkBuilder *builder=NULL;
GtkToggleButton *buttons[FUNC_COUNT]={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);
}

int main (int argc, char *argv[]) {
	GtkWidget *window;

	gtk_init(&argc, &argv);

	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();
	gtk_widget_show_all(window);                

	gtk_main();

	g_object_unref(G_OBJECT(builder));
	return 0;
}

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}};
	GdkColor b_gradient_green[2] = {{0,0,49151,0},{0,0,24575,0}};
	GdkColor f_gradient_blue[2] = {{0,0,0,65535},{0,0,0,32767}};
	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}};

	vumeter_sound = gtk_vu_meter_new(TRUE);
	gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_sound), -50, 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);
	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_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_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);
	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);
	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);
	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);
}