GTK+ 文件对话框 添加文件类型过滤

 

p->filechooser = gtk_file_chooser_dialog_new ("Save Beam Data",
          GTK_WINDOW (p->window),
          GTK_FILE_CHOOSER_ACTION_SAVE,
          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
          GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
          NULL);
   
    gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (p->filechooser), TRUE);
    //*****************文件选择类型过滤************************
    /*所有文件*/
    filter = gtk_file_filter_new();
    gtk_file_filter_set_name (filter, "*.All");
    gtk_file_filter_add_pattern(filter,"*");
    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (p->filechooser),filter);
 
    gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (p->filechooser), "beamdata1.BeamData");

    if (gtk_dialog_run (GTK_DIALOG (p->filechooser)) == GTK_RESPONSE_ACCEPT)//捕捉保存按钮信号
      {
        gchar *filename ;//= g_malloc0(sizeof(gchar))
        filename = g_locale_from_utf8( gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (p->filechooser)),-1,NULL,NULL,NULL );
       }
    gtk_widget_destroy (p->filechooser);
}

 


你可能感兴趣的:(File,filter,null,dialog,action,gtk)