PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : betr: gtk_buttons und while-loops (1)



nomad
13-06-2005, 15:16
betr: gtk_buttons und while-loops

hi leute,

hab folgendes problem:

moechte innerhalb eines gtk_toggle_buttons
einen while-loop ablaufen lassen,
in welchen dann einige funktionen ablaufen.

bis jetzt hab ich's nicht geschafft ohne endless-loop
das zeugs zu programmieren.
auch das buch von t.fischer "gui-programmierung mit gtk1"
war auch nicht gerade hilfreich.

waere um jeden tip und hilfestellung s e h r froh.....
mfg nomad

auszug aus code:
-----------------------------------------------------
source:

#include <gtk/gtk.h>
#include <glib.h>
#include <gdk/gdkkeysyms.h>

void togglebutton1_funk(GtkWidget *widget, gpointer daten);
void togglebutton2_funk(GtkWidget *widget, gpointer daten);
.................
................
// widgets:

GtkWidget *window;
....
GtkWidget *togglebutton1;
GtkWidget *togglebutton2;
GtkWidget *entry1;

int main(int argc, char *argv[])
{
gtk_set_locale();
gtk_init(&argc, &argv);
...............
..............

//ToggleGoButton_1
togglebutton1 = gtk_toggle_button_new_with_label("Starting");
..............
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (togglebutton1), FALSE);

// stopToggleButton2
togglebutton2 = gtk_toggle_button_new_with_label("Stop");
................
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (togglebutton2), FALSE);
.................
// goToggleButton1
gtk_signal_connect(GTK_OBJECT(togglebutton1),"toggled",GTK_SIGNAL_FUNC(togglebutton1_funk),(gpointer)&bdaten1);
// stopToggleButton2
gtk_signal_connect(GTK_OBJECT(togglebutton2),"toggled",GTK_SIGNAL_FUNC(togglebutton2_funk),(gpointer)&bdaten1);
.....................
gtk_widget_show (window);
....................
gtk_main ();

return 0;
} // end main

...........................
...........................

// Starting_ToggleButton 1
void togglebutton1_funk(GtkWidget *widget, gpointer zdaten)
{
int cnt;

printf("GO_ToggleButton1\n");
cnt = 0;

do
{
if(cnt == 0)
{
gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(toggle button1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tog glebutton2),TRUE);
gtk_entry_set_text(GTK_ENTRY(entry1),"Starting is active....");
}
if(cnt > 0)
{
gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(toggle button1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tog glebutton1),FALSE);
gtk_entry_set_text(GTK_ENTRY(entry1),"Starting is not active and stoped....");
break;
}
cnt++;
} while(1);
}

// StopToggleButton2
void togglebutton2_funk(GtkWidget *widget, gpointer zdaten)
{
printf("StopToggleButton2\n");
if(GTK_TOGGLE_BUTTON (togglebutton2)->active)
{
/* If control reaches here, the toggle button is down */
printf("StopToggleButton 2 is Active\n");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (togglebutton1), FALSE);
}
else
{
/* If control reaches here, the toggle button is up */
printf("StopToggleButton 2 is not Active\n");
}
}

..............................
..............................

end source
.................................................. ....................................