Esempio n. 1
0
void Window::vOnFileLoad()
{
  std::string sSaveDir = m_poDirConfig->sGetKey("saves");

  Gtk::FileChooserDialog oDialog(*this, _("Load game"));
  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  oDialog.add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);

  if (sSaveDir == "")
  {
    oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
  }
  else
  {
    oDialog.set_current_folder(sSaveDir);
    oDialog.add_shortcut_folder(sSaveDir);
  }

  Gtk::FileFilter oSaveFilter;
  oSaveFilter.set_name(_("VisualBoyAdvance save game"));
  oSaveFilter.add_pattern("*.[sS][gG][mM]");

  oDialog.add_filter(oSaveFilter);

  while (oDialog.run() == Gtk::RESPONSE_OK)
  {
    if (m_stEmulator.emuReadState(oDialog.get_filename().c_str()))
    {
      break;
    }
  }
}
Esempio n. 2
0
static void SetFilter(Gtk::FileChooserWidget& fcw, FCWFilterType typ)
{
    Gtk::FileFilter ff;
    //ff.set_name(combo.get_active_text());
    switch( typ )
    {
    case fftALL_FORMATS:
        AddAllFormatsFilter(ff);
        break;
    case fftVIDEO:
        AddVideoFilter(ff);
        break;
    case fftDVD_SOUND:
        FillSoundFilter(ff);
        break;
    case fftIMAGES:
        AddImagesFilter(ff);
        break;
    case fftALL:
        ff.add_pattern("*");
        break;
    default:
        ASSERT(0);
    }
    fcw.set_filter(ff);
}
Esempio n. 3
0
static void AddImagesFilter(Gtk::FileFilter& ff)
{
    ff.add_pattern("*.png");
    ff.add_pattern("*.jpg");
    ff.add_pattern("*.jpeg");
    ff.add_pattern("*.bmp");
}
Esempio n. 4
0
void FillSoundFilter(Gtk::FileFilter& ff)
{
    ff.add_pattern("*.mp2");
    ff.add_pattern("*.mpa");
    ff.add_pattern("*.ac3");
    ff.add_pattern("*.dts");
    ff.add_pattern("*.lpcm");
}
Esempio n. 5
0
void Window::vOnFileScreenCapture()
{
  std::string sCaptureDir = m_poDirConfig->sGetKey("captures");

  Gtk::FileChooserDialog oDialog(*this, _("Save screenshot"),
                                 Gtk::FILE_CHOOSER_ACTION_SAVE);
  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  oDialog.add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK);

  if (sCaptureDir == "")
  {
    oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
  }
  else
  {
    oDialog.set_current_folder(sCaptureDir);
    oDialog.add_shortcut_folder(sCaptureDir);
  }
  oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));

  Gtk::FileFilter oPngFilter;
  oPngFilter.set_name(_("PNG image"));
  oPngFilter.add_pattern("*.[pP][nN][gG]");

  oDialog.add_filter(oPngFilter);

  while (oDialog.run() == Gtk::RESPONSE_OK)
  {
    Glib::ustring sFile = oDialog.get_filename();
    Glib::ustring sExt = ".png";

    if (! bHasSuffix(sFile, sExt, false))
    {
      sFile += sExt;
    }

    if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
    {
      Gtk::MessageDialog oConfirmDialog(*this,
                                        _("File already exists. Overwrite it?"),
                                        false,
                                        Gtk::MESSAGE_QUESTION,
                                        Gtk::BUTTONS_YES_NO);
      if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
      {
        continue;
      }
    }

    if (m_stEmulator.emuWritePNG(sFile.c_str()))
    {
      break;
    }
  }
}
Esempio n. 6
0
void Window::vOnFileSave()
{
  Glib::ustring sSaveDir = m_poDirConfig->sGetKey("saves");

  Gtk::FileChooserDialog oDialog(*this, _("Save game"),
                                 Gtk::FILE_CHOOSER_ACTION_SAVE);
  oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  oDialog.add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK);

  if (sSaveDir == "")
  {
    oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
  }
  else
  {
    oDialog.set_current_folder(sSaveDir);
    oDialog.add_shortcut_folder(sSaveDir);
  }
  oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));

  Gtk::FileFilter oSaveFilter;
  oSaveFilter.set_name(_("VisualBoyAdvance save game"));
  oSaveFilter.add_pattern("*.[sS][gG][mM]");

  oDialog.add_filter(oSaveFilter);

  while (oDialog.run() == Gtk::RESPONSE_OK)
  {
    Glib::ustring sFile = oDialog.get_filename();
    if (! bHasSuffix(sFile, ".sgm", false))
    {
      sFile += ".sgm";
    }

    if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
    {
      Gtk::MessageDialog oConfirmDialog(*this,
                                        _("File already exists. Overwrite it?"),
                                        false,
                                        Gtk::MESSAGE_QUESTION,
                                        Gtk::BUTTONS_YES_NO);
      if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
      {
        continue;
      }
    }

    if (m_stEmulator.emuWriteState(sFile.c_str()))
    {
      break;
    }
  }
}
Esempio n. 7
0
static void AddVideoFilter(Gtk::FileFilter& ff)
{
#ifdef FFMPEG_IMPORT_POLICY
    boost_foreach( const char* ext, video_extensions )
        AddGlobFilter(ff, std::string("*.") + ext);
#else
    ff.add_pattern("*.m2v");
    ff.add_pattern("*.mpeg");
    ff.add_pattern("*.mpg");
    //ff.add_pattern("*.vob");
    //ff.add_pattern("*.VOB");
    AddGlobFilter(ff, "*.vob");
#endif
}
Esempio n. 8
0
void Window::vCreateFileOpenDialog()
{
    if (m_poFileOpenDialog != NULL) {
        return;
    }

    std::string sGBDir = m_poDirConfig->sGetKey("gb_roms");
    std::string sGBADir = m_poDirConfig->sGetKey("gba_roms");

    Gtk::FileChooserDialog* poDialog = new Gtk::FileChooserDialog(*this, _("Open"));
    poDialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    poDialog->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);

    try {
        if (sGBDir != "") {
            poDialog->add_shortcut_folder(sGBDir);
            poDialog->set_current_folder(sGBDir);
        }

        if (sGBADir != "" && sGBADir != sGBDir) {
            poDialog->add_shortcut_folder(sGBADir);
            poDialog->set_current_folder(sGBADir);
        }
    } catch (const Gtk::FileChooserError& e) {
        // Most likely the shortcut already exists, so do nothing
    }

    const char* acsPattern[] = {
        // GBA
        "*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
        // GB
        "*.[gG][bB]", "*.[sS][gG][bB]", "*.[cC][gG][bB]", "*.[gG][bB][cC]",
        // Both
        "*.[mM][bB]", "*.[eE][lL][fF]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]",
        "*.7[zZ]",
    };

#if !GTK_CHECK_VERSION(3, 0, 0)
    Gtk::FileFilter oAllGBAFilter;
    oAllGBAFilter.set_name(_("All Gameboy Advance files"));
    for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
        oAllGBAFilter.add_pattern(acsPattern[i]);
    }

    Gtk::FileFilter oGBAFilter;
    oGBAFilter.set_name(_("Gameboy Advance files"));
    for (int i = 0; i < 3; i++) {
        oGBAFilter.add_pattern(acsPattern[i]);
    }

    Gtk::FileFilter oGBFilter;
    oGBFilter.set_name(_("Gameboy files"));
    for (int i = 3; i < 7; i++) {
        oGBFilter.add_pattern(acsPattern[i]);
    }
#else
    const Glib::RefPtr<Gtk::FileFilter> oAllGBAFilter = Gtk::FileFilter::create();
    oAllGBAFilter->set_name(_("All Gameboy Advance files"));
    for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
        oAllGBAFilter->add_pattern(acsPattern[i]);
    }

    const Glib::RefPtr<Gtk::FileFilter> oGBAFilter = Gtk::FileFilter::create();
    oGBAFilter->set_name(_("Gameboy Advance files"));
    for (int i = 0; i < 3; i++) {
        oGBAFilter->add_pattern(acsPattern[i]);
    }

    const Glib::RefPtr<Gtk::FileFilter> oGBFilter = Gtk::FileFilter::create();
    oGBFilter->set_name(_("Gameboy files"));
    for (int i = 3; i < 7; i++) {
        oGBFilter->add_pattern(acsPattern[i]);
    }
#endif

    poDialog->add_filter(oAllGBAFilter);
    poDialog->add_filter(oGBAFilter);
    poDialog->add_filter(oGBFilter);

    m_poFileOpenDialog = poDialog;
}
void SaveImageFileChooserDialog::Run( 
    std::string& filename, 
    FlyCapture2::ImageFileFormat& format, 
    std::string& saveImageLocation )
{
    Gtk::FileChooserDialog dialog( 
        "Please enter a filename", 
        Gtk::FILE_CHOOSER_ACTION_SAVE );

    if ( m_pParentWindow != NULL )
    {
        dialog.set_transient_for( *m_pParentWindow );
    }

    // Add response buttons to the dialog:
    dialog.add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
    dialog.add_button( Gtk::Stock::SAVE_AS, Gtk::RESPONSE_OK );        

    // Set the default filename that appears
    dialog.set_current_name( m_defaultFileName );

    // Move to the save image location folder if available
    if ( m_saveImageLocation.length() != 0 )
    {
        dialog.set_current_folder(m_saveImageLocation);
    }

    // Prompt to overwrite an existing file
    dialog.set_do_overwrite_confirmation( true );

    // Only allow single selection of files
    dialog.set_select_multiple( false );

    Gtk::FileFilter bmpFilter;
    bmpFilter.set_name("Windows Bitmap (*.bmp)");
    bmpFilter.add_pattern("*.bmp");

    Gtk::FileFilter ppmFilter;
    ppmFilter.set_name("Portable Pixelmap (*.ppm)");
    ppmFilter.add_pattern("*.ppm");

    Gtk::FileFilter pgmFilter;
    pgmFilter.set_name("Portable Greymap (*.pgm)");
    pgmFilter.add_pattern("*.pgm");

    Gtk::FileFilter jpgFilter;
    jpgFilter.set_name("JPEG (*.jpg, *.jpeg)");
    jpgFilter.add_pattern("*.jpg");
    jpgFilter.add_pattern("*.jpeg");

    Gtk::FileFilter tiffFilter;
    tiffFilter.set_name("Tagged Image File Format (*.tiff)");
    tiffFilter.add_pattern("*.tiff");

    Gtk::FileFilter pngFilter;
    pngFilter.set_name("Portable Network Graphics (*.png)");
    pngFilter.add_pattern("*.png");

    Gtk::FileFilter rawFilter;
    rawFilter.set_name("Raw data (*.raw)");
    rawFilter.add_pattern("*.raw");

    Gtk::FileFilter allFilter;
    allFilter.set_name("All files (*.*)");
    allFilter.add_pattern("*");

    dialog.add_filter(bmpFilter);
    dialog.add_filter(ppmFilter);
    dialog.add_filter(pgmFilter);
    dialog.add_filter(jpgFilter);
    dialog.add_filter(tiffFilter);
    dialog.add_filter(pngFilter);
    dialog.add_filter(rawFilter);
    dialog.add_filter(allFilter);

    switch (m_format)
    {
    case FlyCapture2::FROM_FILE_EXT: dialog.set_filter(allFilter); break;
    case FlyCapture2::PGM: dialog.set_filter(pgmFilter); break;
    case FlyCapture2::PPM: dialog.set_filter(ppmFilter); break;
    case FlyCapture2::BMP: dialog.set_filter(bmpFilter); break;
    case FlyCapture2::JPEG: dialog.set_filter(jpgFilter); break;
    case FlyCapture2::JPEG2000: dialog.set_filter(jpgFilter); break;
    case FlyCapture2::TIFF: dialog.set_filter(tiffFilter); break;
    case FlyCapture2::PNG: dialog.set_filter(pngFilter); break;
    case FlyCapture2::RAW: dialog.set_filter(rawFilter); break;
    default: dialog.set_filter(allFilter); break;
    }
    
    const int result = dialog.run();    

    if ( result != Gtk::RESPONSE_OK )
    {
        filename = "";
        format = FlyCapture2::FROM_FILE_EXT;
        return;
    }

    filename = dialog.get_filename();  
    saveImageLocation = dialog.get_current_folder();

    const Gtk::FileFilter* pSelectedFilter = dialog.get_filter();
    Glib::ustring selectedFilterName = pSelectedFilter->get_name();

    bool foundFilter = false;

    for ( unsigned int i=0; i < m_vecFilters.size(); i++ )
    {
        if ( m_vecFilters[i].name == selectedFilterName )
        {
            // Assign the format that was found
            format = m_vecFilters[i].format;

            // Append the extension on to the filename
            filename += m_vecFilters[i].extension;

            foundFilter = true;
            break;
        }
    }        

    if ( foundFilter == false )
    {
        // Didn't find an extension
        if ( filename.find(".bmp") != std::string::npos )
        {
            format = FlyCapture2::BMP;
        }
        else if ( filename.find(".ppm") != std::string::npos)
        {
            format = FlyCapture2::PPM;
        }
        else if ( filename.find(".pgm") != std::string::npos)
        {
            format = FlyCapture2::PGM;
        }
        else if ( ( filename.find(".jpg") != std::string::npos) || 
            ( filename.find(".jpeg") != std::string::npos) )
        {
            format = FlyCapture2::JPEG;
        }
        else if ( filename.find(".tiff") != std::string::npos)
        {
            format = FlyCapture2::TIFF;
        }
        else if ( filename.find(".png") != std::string::npos)
        {
            format = FlyCapture2::PNG;
        }
        else if ( filename.find(".raw") != std::string::npos)
        {
            format = FlyCapture2::RAW;
        }    
        else
        {
            // No extension and no file format.
            // If we get here, save it as .png
            format = FlyCapture2::PNG;
        }
    }    
}
Esempio n. 10
0
void
file_chooser::common_ctor_logic_()
{
  do_overwrite_confirmation_ = true;
  single_image_mode_         = false;

  if (!column) column = new model_columns;

  Glib::RefPtr< Gtk::ListStore > types;
  types = Gtk::ListStore::create (*column);
  {
    Gtk::TreeModel::Row r;
    extension_list      l;

    r = *(types->append ());
    r[column->text] = _("By extension");
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("JPEG");
#if __cplusplus >= 201103L
    l = {".jpeg", ".jpg"};
#else
    l = list_of (".jpeg")(".jpg");
#endif
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("PDF");
#if __cplusplus >= 201103L
    l = {".pdf"};
#else
    l = list_of (".pdf");
#endif
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("PNG");
#if __cplusplus >= 201103L
    l = {".png"};
#else
    l = list_of (".png");
#endif
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("PNM");
#if __cplusplus >= 201103L
    l = {".pnm"};
#else
    l = list_of (".pnm");
#endif
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("TIFF");
#if __cplusplus >= 201103L
    l = {".tiff", ".tif"};
#else
    l = list_of (".tiff")(".tif");
#endif
    r[column->exts] = l;
  }

  file_type_.set_model (types);
  file_type_.set_headers_visible (false);
  file_type_.append_column ("", column->text);
  file_type_.set_rules_hint ();
  file_type_.get_selection ()->signal_changed ()
    .connect (sigc::mem_fun (*this, &file_chooser::on_file_type_changed));

  expander_.set_label (_("File Type"));
  expander_.add (file_type_);

  single_file_.set_label (_("Save all images in a single file"));
  single_file_.signal_toggled ()
    .connect (sigc::mem_fun (*this, &file_chooser::on_single_file_toggled));

  Gtk::VBox *extras (Gtk::manage (new Gtk::VBox));
  extras->pack_start (expander_);
  extras->pack_start (single_file_);

  // Set up the dialog, using layout values from Gtk::FileChooserDialog
  set_has_separator (false);
  set_border_width (5);
  get_action_area ()->set_border_width (5);

  Gtk::Box *content_area = get_vbox ();
  content_area->set_spacing (2);
  content_area->pack_start (impl_  , Gtk::PACK_EXPAND_WIDGET);
  content_area->pack_start (*extras, Gtk::PACK_SHRINK);
  content_area->show_all ();
  {
    // FIXME determine the default width and height in a way similar
    //       to how Gtk::FileChooserDialog does.  Its implementation
    //       uses an internal function which takes font information
    //       and numbers of characters and lines into account.
    //       See file_chooser_widget_default_size_changed()
    int width = 800, height = 600;
    set_default_size (width, height);
  }

  add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  add_button (Gtk::Stock::OK    , Gtk::RESPONSE_ACCEPT);

  // FIXME leave this to the "application" or tie it to file_type_
  {
    Gtk::FileFilter filter;
    filter.add_mime_type ("application/pdf");
    filter.add_mime_type ("image/*");
    filter.set_name (_("PDFs and Image Files"));
    add_filter (filter);
  }
  {
    Gtk::FileFilter filter;
    filter.add_mime_type ("image/*");
    filter.set_name (_("Image Files"));
    add_filter (filter);
  }
  {
    Gtk::FileFilter filter;
    filter.add_pattern ("*");
    filter.set_name (_("All Files"));
    add_filter (filter);
  }

  gui_name_change_dispatch_
    .connect (sigc::mem_fun (*this, &file_chooser::signal_name_change_));
  signal_name_change ()
    .connect (sigc::mem_fun (*this, &file_chooser::on_name_change_));

  cancel_watch_ = false;
  watch_thread_ = new thread (&file_chooser::watch_, this);
}
Esempio n. 11
0
bool MuxStreams(std::string& dest_fname, const std::string& src_fname)
{
    Gtk::Dialog dlg(_("Mux streams"));
    SetDialogStrict(dlg, 400, -1);
    SaveChooser& sc = NewManaged<SaveChooser>(SMCLN_("Output"));
    Gtk::FileChooserButton& v_btn = NewManaged<Gtk::FileChooserButton>(_("Select elementary video"), Gtk::FILE_CHOOSER_ACTION_OPEN);
    Gtk::FileChooserButton& a_btn = NewManaged<Gtk::FileChooserButton>(_("Select audio"),            Gtk::FILE_CHOOSER_ACTION_OPEN);
    {
        DialogVBox& vbox = AddHIGedVBox(dlg);

        AppendWithLabel(vbox, v_btn, SMCLN_("Video"));
        {
            Gtk::FileFilter f;
            f.set_name(_("MPEG2 elementary video (m2v)"));
            f.add_pattern("*.m2v");
            v_btn.add_filter(f);
        }

        AppendWithLabel(vbox, a_btn, SMCLN_("Audio"));
        {
            Gtk::FileFilter f;
            f.set_name(_("Audio for DVD") + std::string(" (mp2/mpa, ac3, dts or 16bit lpcm)"));
            FillSoundFilter(f);
            a_btn.add_filter(f);
        }

        PackStart(vbox, sc);

        CompleteDialog(dlg);
    }

    v_btn.signal_selection_changed().connect(bb::bind(&OnVideoSelected, boost::ref(v_btn), boost::ref(a_btn), boost::ref(sc)));
    if( !src_fname.empty() )
    {
        if( get_extension(src_fname) == "m2v" )
            v_btn.set_filename(src_fname);
        else
            a_btn.set_filename(src_fname);
    }

    bool res = false;
    for( ; res = Gtk::RESPONSE_OK == dlg.run(), res; )
    {
        dest_fname = GetFilename(sc);

        if( v_btn.get_filename().empty() )
            ErrorBox(_("Elementary video file is not selected."));
        else if( a_btn.get_filename().empty() )
            ErrorBox(_("Audio file is not selected."));
        else if( dest_fname.empty() )
            ErrorBox(_("Output file name is empty."));
        else if( CheckKeepOrigin(dest_fname) )
            ;
        else
            break;
    }

    if( res )
    {
        dlg.hide();
        res = RunMuxing(dest_fname, boost::format("%1% %2%") % v_btn.get_filename() % a_btn.get_filename() % bf::stop );
    }

    return res;
}
Esempio n. 12
0
int fcd__(std::deque<Glib::ustring>* p,Gtk::Window* win,char*buf,long siz){
	Gtk::FileChooserAction fca;
	Gtk::StockID ok=Gtk::Stock::OPEN;
	if((*p)[1]=="打开"){
		fca=Gtk::FILE_CHOOSER_ACTION_OPEN;
	}else if((*p)[1]=="保存"){
		fca=Gtk::FILE_CHOOSER_ACTION_SAVE;
		ok=Gtk::Stock::SAVE;
	}else if((*p)[1]=="文件夹"){
		fca=Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER;
	}else if((*p)[1]=="建立文件夹"){
		fca=Gtk::FILE_CHOOSER_ACTION_CREATE_FOLDER;
	}else
		return 1;
	if(p->size()<=2)
		return 2;
	Gtk::FileChooserDialog dialog((*p)[2],fca);
	dialog.set_transient_for(*win);

	dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	dialog.add_button(ok, Gtk::RESPONSE_OK);

	for(unsigned int i=3;i<p->size();i++){
		const Glib::ustring& pi=(*p)[i];
		if(pi=="预选"){
			if(++i>=p->size())
				return 2;
			Glib::ustring& name=(*p)[i];
			if(name.length()>0){
				size_t i1=name.rfind('/');
				if(i1!=Glib::ustring::npos){
					dialog.set_current_folder(name.substr(0,i1));
				}
				if(i1!=name.length()-1){
					dialog.set_filename(name);
					dialog.select_filename(name);
					//dialog.set_current_name(name.substr(i1+1));
				}
			}
			continue;
		}
		if(pi=="类型"){
			if(++i>=p->size())
				return 2;
			Gtk::FileFilter filter;
			filter.set_name((*p)[i]);
			/*filter.add_mime_type("text/x-c");
			filter.add_mime_type("text/x-c++");
			filter.add_mime_type("text/x-c-header");*/
			if(++i>=p->size())
				return 2;
			filter.add_pattern((*p)[i]);
			dialog.add_filter(filter);
			continue;
		}
		if(pi=="覆盖确认"){
			dialog.set_do_overwrite_confirmation(true);
			continue;
		}
		return i;
	}

	switch(dialog.run()){
	case(Gtk::RESPONSE_OK):
		cpy__(buf,dialog.get_filename().c_str(),siz);
		break;
	}
	return 0;
}
Esempio n. 13
0
void AddGlobFilter(Gtk::FileFilter& ff, const std::string& pat)
{
    ff.add_custom(Gtk::FILE_FILTER_DISPLAY_NAME, 
                  wrap_return<bool>(bb::bind(&OnGlobMatch, _1, pat)));
}