summaryrefslogtreecommitdiff
path: root/tests/test7
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-06-22 21:46:28 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-06-22 21:46:28 +0000
commit217df92d8936b397884c72a2f5f3419f0c4a165f (patch)
tree86be1f8bf76bf893bcca5c0a9f366292c887acc5 /tests/test7
parent46c20d816ed8db6c9a49cb0ff0ff521c37633afa (diff)
download2012-violon-leds-217df92d8936b397884c72a2f5f3419f0c4a165f.tar.gz
2012-violon-leds-217df92d8936b397884c72a2f5f3419f0c4a165f.tar.bz2
2012-violon-leds-217df92d8936b397884c72a2f5f3419f0c4a165f.zip
Version avec des ToggleButons (qui sont en fait des radiobuttons) qui marche
Reste à intégrer mes GtkProgressBar... git-svn-id: file:///var/svn/2012-violon-leds/trunk@27 6be1fa4d-33ac-4c33-becc-79fcb3794bb6
Diffstat (limited to 'tests/test7')
-rw-r--r--tests/test7/gui.glade31
-rw-r--r--tests/test7/test7.c52
2 files changed, 32 insertions, 51 deletions
diff --git a/tests/test7/gui.glade b/tests/test7/gui.glade
index 67819e8..f91b0d7 100644
--- a/tests/test7/gui.glade
+++ b/tests/test7/gui.glade
@@ -809,21 +809,24 @@ copy of the Program in return for a fee.
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
- <object class="GtkToggleButton" id="but_func1">
+ <object class="GtkRadioButton" id="radbut_func1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="receives_default">False</property>
<property name="related_action">action1</property>
- <signal name="realize" handler="on_but_func1_realize" swapped="no"/>
+ <property name="draw_indicator">True</property>
+ <signal name="realize" handler="on_radbut_func_realize" swapped="no"/>
</object>
</child>
<child>
- <object class="GtkToggleButton" id="but_func2">
+ <object class="GtkRadioButton" id="radbut_func2">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="receives_default">False</property>
<property name="related_action">action2</property>
- <signal name="realize" handler="on_but_func2_realize" swapped="no"/>
+ <property name="draw_indicator">True</property>
+ <property name="group">radbut_func1</property>
+ <signal name="realize" handler="on_radbut_func_realize" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -831,12 +834,14 @@ copy of the Program in return for a fee.
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="but_func3">
+ <object class="GtkRadioButton" id="radbut_func3">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="receives_default">False</property>
<property name="related_action">action3</property>
- <signal name="realize" handler="on_but_func3_realize" swapped="no"/>
+ <property name="draw_indicator">True</property>
+ <property name="group">radbut_func1</property>
+ <signal name="realize" handler="on_radbut_func_realize" swapped="no"/>
</object>
<packing>
<property name="top_attach">1</property>
@@ -844,12 +849,14 @@ copy of the Program in return for a fee.
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="but_func4">
+ <object class="GtkRadioButton" id="radbut_func4">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="receives_default">False</property>
<property name="related_action">action4</property>
- <signal name="realize" handler="on_but_func4_realize" swapped="no"/>
+ <property name="draw_indicator">True</property>
+ <property name="group">radbut_func1</property>
+ <signal name="realize" handler="on_radbut_func_realize" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/tests/test7/test7.c b/tests/test7/test7.c
index 158ead2..7f557ca 100644
--- a/tests/test7/test7.c
+++ b/tests/test7/test7.c
@@ -6,6 +6,12 @@
GtkBuilder *builder=NULL;
GtkToggleButton *buttons[FUNC_COUNT]={NULL};
+// 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();
}
@@ -22,47 +28,15 @@ void on_mi_about_activate(GtkObject *object, gpointer user_data) {
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) {
- switch_to_func(0);
-}
-
-void on_action2_activate(GtkObject *object, gpointer user_data) {
- switch_to_func(1);
-}
+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_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);
+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[]) {