Ejemplo n.º 1
0
void
file_chooser::on_single_file_toggled ()
{
  std::string name (get_current_name ());
  smatch m;

  if (regex_match (name, m, filename_re))
    {
      if (!single_file_.get_active ()) return;

      set_current_name (m.str (1) + m.str (5));
    }
  else
    {
      if (single_file_.get_active ()) return;

      fs::path path (get_current_name ());
      fs::path stem (path.stem ());
      fs::path ext  (path.extension ());

      path = stem;
      path = path.native () + default_pattern_;
      path.replace_extension (ext);

      set_current_name (path.string ());
    }
}
Ejemplo n.º 2
0
void ChooseFileWindow::on_change_filename()
{
  string filename = (string) get_current_name();
  if (!(ends_with(filename, ".obj") || ends_with(filename, ".OBJ")))
  {
    set_current_name(filename + ".obj");
  }
}
Ejemplo n.º 3
0
void
file_chooser::set_current_extension (const std::string& extension)
{
  if (extension == get_current_extension ()) return;

  set_current_name (fs::path (get_current_name ())
                    .replace_extension (extension).string ());
}
Ejemplo n.º 4
0
void
file_chooser::on_file_type_changed ()
{
  Glib::RefPtr< Gtk::TreeSelection > s (file_type_.get_selection ());
  if (!s) return;

  Gtk::TreeModel::iterator it (s->get_selected ());
  if (!it) return;

  Gtk::TreeModel::Row r (*it);
  extension_list      l (r[column->exts]);

  if (l.empty ())
    {
      expander_.set_label (_("File Type"));
    }
  else
    {
      expander_.set_label ((format (_("File type: %1%"))
                            % r.get_value (column->text)).str ());

      if (!count (l.begin (), l.end (), get_current_extension ()))
        set_current_extension (l.front ());
    }

  if (!single_image_mode_)
    {
      single_file_.set_sensitive (supports_multi_image (get_current_name ()));
      if (!supports_multi_image (get_current_name ()))
        {
          if (!regex_match (get_current_name (), filename_re))
            {
              fs::path path (get_current_name ());
              fs::path stem (path.stem ());
              fs::path ext  (path.extension ());

              path = stem;
              path = path.native () + default_pattern_;
              path.replace_extension (ext);

              set_current_name (path.string ());
            }
        }
      single_file_.set_active (requests_single_file (get_current_name ()));
    }
}