Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:44:41+00:00 2026-05-27T00:44:41+00:00

I am programming a card game in GTK. Is there a way to create

  • 0

I am programming a card game in GTK. Is there a way to create a loop that would not exit a function (the human_play function for example) until the user clicks on a card? I mean, it would be like waiting for the user to click a card (while doing so, not blocking the quit button and other event widgets) in order for the function to return and continue running subsequent code.

Let me know if I can be more clear. Responses will be very appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:44:42+00:00Added an answer on May 27, 2026 at 12:44 am

    It would seem at first that what you want is a GtkDialog widget to take the user input (choose a card). A GtkDialog would not return to the function that called it until the adequate response is given.

    It just a matter of coding your gtkdialog. The user_data gpointer given to the callback that calls the dialog can have a single pointer or a collection of pointers on a GPtrArray to manage the internal data structures of your program.

    If your program is purely reactive that should be enough.

    If you want the engine “thinking” while the user ponders its decision at the gtkdialog, then you need a separate thread and manage the communication with the callbacks. Byt that is far more complex.

    For more info:

    http://developer.gnome.org/gtk/2.24/GtkDialog.html

    http://xpt.sourceforge.net/techdocs/language/gtkdialog/gtkde02-GtkdialogExamples/

    Edit:

    I miss understood your initial post, hence the GtkDialog recomendation.

    Did you implement a working prototype? I mean for example a text version of your game engine?. Which seams turn based with no dice.

    If you have a proper working turn based engine, you should be able to use callbacks from the GTK UI to handle events.

    For example if you have some GtkButton with a card images to identify them, connecting a button clicked event to a corresponding callback which does 2 things in order

    1) Set the parts of the UI which you want to disable as insensitive while the computer thinks. This can be accomplished using the gtk_widget_set_sensitive(widget,FALSE) function with the relevant widgets. This includes the button just pressed/clicked.

    2)pass the data of which card was selected to the game engine, the game engine then retrieves the current game status and processes the information, while the engine does not return with an answer your callback will not return either.

    3) Once the engine return an answer/move/responde, show it to the user and use again gtk_widget_set_sensitive() to enable all the user widgets.

    void callback(GtkButton button,gpointer user_data){
    //pointers to a structure which holds game state, pointer to a list of widgets to disable temporarily, other pointers to useful data
      GPtrArray* gptr =  user_data;
      GameEngineResponse* res;
      set_UI_insensitive(..,FALSE);
      res = call_game_engine(selected *card,other_info,..);//while this functions does not return, the callback will wait here.
      set_UI_sensitive(..,TRUE;);
    // and now returns to the game everything ready for the user to play again if he did not loose
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to programming. I want to make a card game with C++ /
My father would like to use Ubuntu for LPT programming (via a relay card).
I mean in programming way. Like read contact details through SIM card.
Programming languages had several (r)evolutionary steps in their history. Some people argue that model-driven
Programming has come a long way. I am still relatively young (first Computer: C64),
I am programming a cards game, when i was doing the visual part i
I have the following scenario: I'm creating a card game, and as part of
Here is where I am at presently. I am designing a card game with
I've started programming on Mac OS X in Objective-C and decided to create a
I'm developing open source cross-platform platform for non-realtime multiplayer chat/game system. Like card games,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.