GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 23, 2014 2:23 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Data from one function avalible in another
PostPosted: Thu Apr 03, 2014 11:49 pm 
Offline
Familiar Face

Joined: Sat Mar 22, 2014 1:47 pm
Posts: 5
Hey guys,
So in my program I have one function which run filechooser dialg and after clicking Ok path to file is kept in filename, and thats all good but
right now I would like to pass that variable to another function and Im not sure how to do it, what I need to do, here is example

Code:
/*My main*/
    button = GTK_WIDGET( gtk_builder_get_object( builder, "button1" ) );
    g_signal_connect (button, "clicked", G_CALLBACK (show_dialog), &filename);


My show_dialog

Code:
static void
show_dialog ( GtkWidget *button,
                    gint       response_id,
                    gpointer   user_data )
{
    gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechoosedialog));
}


How can I store value of filename in a such way that I can have it available in another function ?


Top
 Profile  
 
 Post subject: Re: Data from one function avalible in another
PostPosted: Fri Apr 04, 2014 5:55 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 747
Location: UK
Hello,

This question appears fairly regularly under slightly different names.

You can store the variable as a global which is OK if your application is small. If you only need to pass a single variable to can pass a pointer to it, but you must make sure that the variable is always in scope.

This thread contains a similar question and answer
http://www.gtkforums.com/viewtopic.php?f=3&t=178690

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group