summaryrefslogtreecommitdiff
path: root/tests/test7/test7.c
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-06-22 20:48:25 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-06-22 20:48:25 +0000
commit46c20d816ed8db6c9a49cb0ff0ff521c37633afa (patch)
treeeb9efa94653d10c90cbf1a445c8b84afb6544348 /tests/test7/test7.c
parente80a4a91ab8cd4721f5007c9d9eb8cfbe997155e (diff)
download2012-violon-leds-46c20d816ed8db6c9a49cb0ff0ff521c37633afa.tar.gz
2012-violon-leds-46c20d816ed8db6c9a49cb0ff0ff521c37633afa.tar.bz2
2012-violon-leds-46c20d816ed8db6c9a49cb0ff0ff521c37633afa.zip
Bon, l'IHM est faite. Le about dialog marche, la licence GPL3 est là, etc.
Par contre les toggle butons ne sont pas mutuellement exclusif (et j'ai tenté de bricoler et ça chie) git-svn-id: file:///var/svn/2012-violon-leds/trunk@26 6be1fa4d-33ac-4c33-becc-79fcb3794bb6
Diffstat (limited to 'tests/test7/test7.c')
-rw-r--r--tests/test7/test7.c92
1 files changed, 67 insertions, 25 deletions
diff --git a/tests/test7/test7.c b/tests/test7/test7.c
index 7a3ca63..158ead2 100644
--- a/tests/test7/test7.c
+++ b/tests/test7/test7.c
@@ -1,46 +1,88 @@
-/*
- First run tutorial.glade through gtk-builder-convert with this command:
- gtk-builder-convert tutorial.glade tutorial.xml
-
- Then save this file as main.c and compile it using this command
- (those are backticks, not single quotes):
- gcc -Wall -g -o tutorial main.c `pkg-config --cflags --libs gtk+-2.0` -export-dynamic
-
- Then execute it using:
- ./tutorial
- */
#include <gtk/gtk.h>
#include <stdio.h>
-void on_win_main_destroy (GtkObject *object, gpointer user_data) {
+#define FUNC_COUNT 4
+
+GtkBuilder *builder=NULL;
+GtkToggleButton *buttons[FUNC_COUNT]={NULL};
+
+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 switch_to_func(gint func_id) {
+ gint i;
+ // Toggle off all buttons but the active one
+ for (i=0;i<FUNC_COUNT;i++) {
+ if (i==func_id) continue;
+ gtk_toggle_button_set_active(buttons[i],FALSE);
+ printf("buttons[%i]==%p\n", i, buttons[i]);
+ }
+
+}
+
void on_action1_activate(GtkObject *object, gpointer user_data) {
- printf("action1\n");
+ 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_but_func1_realize(GtkObject *object, gpointer user_data) {
+ buttons[0]=GTK_TOGGLE_BUTTON(object);
+}
+
+void on_but_func2_realize(GtkObject *object, gpointer user_data) {
+ buttons[1]=GTK_TOGGLE_BUTTON(object);
+}
+
+void on_but_func3_realize(GtkObject *object, gpointer user_data) {
+ buttons[2]=GTK_TOGGLE_BUTTON(object);
+}
+
+void on_but_func4_realize(GtkObject *object, gpointer user_data) {
+ buttons[3]=GTK_TOGGLE_BUTTON(object);
}
int main (int argc, char *argv[]) {
- GtkBuilder *builder;
- GtkWidget *window;
+ GtkWidget *window;
// int res;
- gtk_init (&argc, &argv);
+ gtk_init(&argc, &argv);
- builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, "win_main.glade", NULL);
+ builder = gtk_builder_new();
+ gtk_builder_add_from_file(builder, "gui.glade", NULL);
- window = GTK_WIDGET (gtk_builder_get_object (builder, "win_main"));
- printf("window==%p\n", window);
- gtk_builder_connect_signals (builder, NULL);
-
- g_object_unref (G_OBJECT (builder));
+ window = GTK_WIDGET(gtk_builder_get_object(builder, "win_main"));
+ gtk_builder_connect_signals(builder, NULL);
+ gtk_widget_show(window);
- gtk_widget_show (window);
- gtk_main ();
+ gtk_main();
+ g_object_unref(G_OBJECT(builder));
return 0;
}