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

  • Home
  • SEARCH
  • 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 3486892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:05:06+00:00 2026-05-18T11:05:06+00:00

How do You determine what control/widget was clicked inside a dialog box by checking

  • 0

How do You determine what control/widget was clicked inside a dialog box by checking the return value of gtk_dialog_run()

This is what I have

/*toolbar test thingy*/
#include <gtk/gtk.h>
#define MESSAGE_OK 1001

void mymessage (void){
    GtkWidget *message = gtk_dialog_new_with_buttons("My dialog",
        NULL,
        GTK_DIALOG_MODAL,GTK_STOCK_OK,1001,NULL);

    gtk_window_set_default_size(GTK_WINDOW(message),200,200);

    gint result = gtk_dialog_run(GTK_DIALOG(message));
    switch(result){
        case MESSAGE_OK:
            gtk_widget_destroy(message);
            printf("you clicked message_ok");
        break;


    }
    gtk_widget_destroy(message);
}


int main(int argc,char *argv[]){

    GtkWidget *window;
    GtkWidget *vertical_box;
    GtkWidget *toolbar;
    //GtkWidget *message;

    GtkToolItem *tool_new;


    gtk_init(&argc,&argv);

    //setting up the main window.
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window),"rs-toolbar test");
    gtk_window_set_default_size(GTK_WINDOW(window),300,350);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER_ALWAYS);

    //setting up the layout using vbox.
    vertical_box = gtk_vbox_new(FALSE,0);
    //adding the vbox layout to the Container window, window
    gtk_container_add(GTK_CONTAINER(window),vertical_box);

    toolbar = gtk_toolbar_new();
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),GTK_TOOLBAR_ICONS);
    gtk_container_set_border_width(GTK_CONTAINER(toolbar),2);

    tool_new = gtk_tool_button_new_from_stock(GTK_STOCK_NEW);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),tool_new,-1);
    //************************************************************************





    //************************************************************************
    gtk_box_pack_start(GTK_BOX(vertical_box),toolbar,FALSE,FALSE,0);

    gtk_widget_show_all(window);

    g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit),NULL);
    g_signal_connect(tool_new,"clicked",G_CALLBACK(mymessage),NULL);

    gtk_main();



    return 0;

}

Is the use of the gtk_dialog_new_with_buttons() function correct?. I’m not entirely sure how to give a specific ID to a control. What I’ve tried to do there is make 1001 the ID of GTK_STOCK_OK.

  • 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-18T11:05:07+00:00Added an answer on May 18, 2026 at 11:05 am

    You’re comparing the response to the wrong thing. gtk_dialog_run returns one of the GTK_RESPONSE constants; try comparing against those in your switch to see which button was pressed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to determine if I'm going to use the calendar control that's out-of-the-box
I have a user control which I call like this: <MyNamespace:MyControl runAt=server ID=foo />
How can I determine when the control key is held down during button click
I need to be able to determine when ContainsFocus changes on a Control (specifically
We have a series of drop down controls that determine the sort order of
I have a widget that displays a filesystem hierarchy for convenient browsing (basically a
I have a simple GridView ; something like this for a regular Item or
I have a radiobuttonlist; when item[1] is clicked a textbox is displayed and my
I'm trying to implement a Widget control that exists on every page in the
RELATED Watch control to determine events being fired? I need to detect when an

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.