LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-06-2012, 01:48 AM   #1
RudraB
Member
 
Registered: Mar 2007
Distribution: Fedora
Posts: 264

Rep: Reputation: 23
GTK newbie help on G_CALLBACK


Dear Friends,
I have taken a project (my own, not homework) to develop a table. I generally work with fortran, dont know C that much.
What I want is a gtk clist to pop up when I press a button, via callback. The button widget in my code is

Code:
 /* Create first button */
    button = gtk_button_new_with_label ("B1");

    /* When the button is clicked, we call the "callback" function
     * with a pointer to "button 1" as its argument */
    g_signal_connect (button, "clicked",
                  G_CALLBACK (callback), (gpointer) "B1");


    /* Insert button 1 into the upper left quadrant of the table */
    gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1);

    gtk_widget_show (button);
The definations are mostly based on http://developer.gnome.org/gtk-tutorial/2.24/x344.html

What I want to do is callback to execute another gtk file, rather than what shown in the example

Code:
 static void callback( GtkWidget *widget,                       
gpointer   data ) {    
 g_print ("Hello again - %s was pressed\n", (gchar *) data);
 }
Can you please show me how I can get this?
 
Old 05-08-2012, 05:34 AM   #2
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
I'm not sure I understand. It sounds like you want to pass a function pointer when that function is in a different file. If that's what you want, you need to put a prototype for the function in the first file, or better, in a header file that's included in both source files.

There's also another detail. Anything that's declared static can't be referenced from another file.

I'm not familiar with GTK programming, but assuming you have the types and strategy right, try removing the keyword static and adding this prototype line:
Code:
void callback(GtkWidget *widget, gpointer data);
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] GTK newbie Netooo Programming 2 03-30-2011 08:27 AM
set variable in G_CALLBACK? bendeco13 Programming 2 05-12-2007 12:50 PM
Newbie Question - What is GTK Exactly? Zeraxeal Slackware 4 03-24-2004 07:27 PM
GTK Newbie tslugmo Linux - Newbie 8 06-19-2003 02:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration