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 Dec 01, 2015 2:42 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: File Chooser Dialog
PostPosted: Sat Mar 01, 2008 4:50 pm 

Joined: Sat Mar 01, 2008 4:16 pm
Posts: 1
Hi there, i have following problem.
I have main window and there is button (GTK_STOCK_OPEN). The click calls the open function, where the file chooser dialog is made. I know how to get the filename and how to print it to standard output (terminal window). I also know how to pass the filename to system() command, This is my open function:

static void open(void)
GtkWidget *filechooser;

filechooser = gtk_file_chooser_dialog_new ("Open File",
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filechooser), "/home/smaart/music");

if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
  gchar *filename;
  char cmd [100];
  filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
sprintf (GString *cmd, "mplayer \"%s\"\n",filename);
system (cmd);


But my task is to choose file, close the file chooser dialog and from the main window click on the play button, read the selected filename (e.g. from filename variable i have in open function) and run command mplayer "some filename". I'm beginner :) so be kind to me.
Thank you for your hints.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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