GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Oct 26, 2014 9:32 am

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 
Offline

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:

Code:
static void open(void)
{
GtkWidget *filechooser;


filechooser = gtk_file_chooser_dialog_new ("Open File",
                  NULL,
                  GTK_FILE_CHOOSER_ACTION_OPEN,
                  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                  GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                  NULL);
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);
g_free(filename);
}

gtk_widget_destroy(filechooser);


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.


Top
 Profile  
 
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: No registered users and 2 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group