To demonstrate what I mean, I wrote up this code without most of the gtk mess:
//more gtk declaration stuff above
int access;
access = 0;
int tries;
tries = 0;
string input;
input = "";
string code;
code = "";
while(access != 1 && tries < 4){
directions((gpointer)lbl); //change label to "type 'finger'"
cin >> input;
if(input.compare("finger") = 0){
while(code.compare("1") != 0 && tries < 4){
fpcheck((gpointer)lbl); //change label "Enter the secret code ('1')"
cin >> code;
if(code.compare("1") != 0){
retry((gpointer) lbl);//change label "Try again!"
tries ++;
}
else{
fprecog((gpointer) lbl); //change label "Recognized!"
access = 1;
}
}
}
}
if(access = 1)
//change label "Access Granted!"
else
//change label "No access."
gtk_main();
return 0;
Clearly this won't exactly work, since gtk_main() isn't called to the end. The console stuff will run fine, but the window won't pop up until the very end so the user won't know what to do, and if I put gtk_main() early on, the program is stuck in the gtk_main() loop so nothing will happen.
How is this sort of flow typically accomplished in GTK? I've tried some gtk_thread stuff to break out of main, but that's apparently deprecated so I'm trying not to use that.
The input has to be read by a thread that's not gtk_main(), since the input isn't coming from the GUI. In reality, it'll be a device plugged into a beaglebone black, but I think this is a simpler similar situation.
The actual input methods that will be used are 1) a finger print sensor that does actions based on sent and received bytes through a UART channel, and 2) a usb camera and facial recognition scripts using OpenCV methods on a BeagleBone Black running Debian, networked to a laptop to do the intensive opencv stuff. For the moment I'm just trying to get it going with the FP sensor. With our interface, we can call an FP sensor method, which returns an int, and do something depending on that int.
I need to be able to change the GTK label depending on what int is returned, then call another method after the label displays.
Here's a snippet of what the code I'm trying to integrate with looks like:
while(key != 'x')
{
imshow("main_display", welcome);
key = waitKey(1); //poll keyboard at active screen
//key = getkey(); //TODO: poll from TFT instead
switch(key)
{
case 'i': //Identify User
imshow("main_display", press_finger);
waitKey(1);
printf("\n---IDENTIFY USER---\n");
post_log(1, 0);
do_reg = true;
Ret = GT_LED_On(LS);
printf("\nPress Finger");
//something to force console text before loop starts...?
Timer.InitTimer();
while(GT_IsPressFinger(LS) == 0 && ((Timer.ElapsedTime_ms() < TIMEOUT))) {}
if(Timer.ElapsedTime_ms() >= TIMEOUT)
{
printf("\nCapture TIMEOUT\n");
Ret = GT_LED_Off(LS);
post_log(6, user_id);
imshow("main_display", fps_timeout);
waitKey(1000);
do_reg = false;
break; //??????????????????????????? GOTO???
}
printf("\nCapturing...Standby...\n");
imshow("main_display", hold_finger);
waitKey(1);
Ret = GT_CaptureFinger(LS, 0);
Basically instead of the imshow() we're trying to use an actual GUI framework, and since the device already has GTK going due to OpenCV, it would be nice to stick with GTK. This console question is trying to figure out how to replace imshow() with a label change of a gtk window in a simple context.