GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File Chooser Dialog

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
smaart



Joined: 01 Mar 2008
Posts: 1

PostPosted: Sat Mar 01, 2008 4:50 pm    Post subject: File Chooser Dialog Reply with quote

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: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP