Author: kitone
Date: Sun Apr 12 12:16:44 2015
New Revision: 899

URL: http://svn.gna.org/viewcvs/subtitleeditor?rev=899&view=rev
Log:
Add the ability to setup uri from another one using dialogfilechooser.

Modified:
    trunk/ChangeLog
    trunk/src/gui/dialogfilechooser.cc
    trunk/src/gui/dialogfilechooser.h

Modified: trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/subtitleeditor/trunk/ChangeLog?rev=899&r1=898&r2=899&view=diff
==============================================================================
--- trunk/ChangeLog     (original)
+++ trunk/ChangeLog     Sun Apr 12 12:16:44 2015
@@ -1,3 +1,9 @@
+2015-04-12  kitone  <[email protected]>
+
+       * src/gui/dialogfilechooser.cc:
+       * src/gui/dialogfilechooser.h:
+       Add the ability to setup uri from another one using dialogfilechooser.
+
 2015-04-12  kitone  <[email protected]>
 
        * src/gui/dialogfilechooser.cc:

Modified: trunk/src/gui/dialogfilechooser.cc
URL: 
http://svn.gna.org/viewcvs/subtitleeditor/trunk/src/gui/dialogfilechooser.cc?rev=899&r1=898&r2=899&view=diff
==============================================================================
--- trunk/src/gui/dialogfilechooser.cc  (original)
+++ trunk/src/gui/dialogfilechooser.cc  Sun Apr 12 12:16:44 2015
@@ -98,6 +98,18 @@
 }
 
 /*
+ */
+DialogFileChooser::DialogFileChooser(const Glib::ustring &title, 
Gtk::FileChooserAction action, const Glib::ustring &name)
+:Gtk::FileChooserDialog(title, action), m_name(name)
+{
+       Glib::ustring last;
+       if(Config::getInstance().get_value_string("dialog-last-folder", m_name, 
last))
+               set_current_folder_uri(last);
+
+       utility::set_transient_parent(*this);
+}
+
+/*
  *
  */
 DialogFileChooser::~DialogFileChooser()
@@ -122,6 +134,29 @@
                return;
        }
 }
+
+/*
+ * This can be use to setup the document name based on video uri
+ */
+void DialogFileChooser::set_filename_from_another_uri(const Glib::ustring 
&another_uri, const Glib::ustring &ext)
+{
+       try
+       {
+               Glib::ustring filename = Glib::filename_from_uri(another_uri);
+               Glib::ustring pathname = Glib::path_get_dirname(filename);
+               Glib::ustring basename = Glib::path_get_basename(filename);
+
+               basename = utility::add_or_replace_extension(basename, ext);
+
+               set_current_folder(pathname); // set_current_folder_uri ?
+               set_current_name(basename);
+       }
+       catch(const Glib::Exception &ex)
+       {
+               std::cerr << "set_filename_from_another_uri failed : " << 
ex.what() << std::endl;
+       }
+}
+
 
 
 /*

Modified: trunk/src/gui/dialogfilechooser.h
URL: 
http://svn.gna.org/viewcvs/subtitleeditor/trunk/src/gui/dialogfilechooser.h?rev=899&r1=898&r2=899&view=diff
==============================================================================
--- trunk/src/gui/dialogfilechooser.h   (original)
+++ trunk/src/gui/dialogfilechooser.h   Sun Apr 12 12:16:44 2015
@@ -52,6 +52,11 @@
        DialogFileChooser(BaseObjectType* cobject, const Glib::ustring &name);
 
        /*
+        */
+       DialogFileChooser(const Glib::ustring &title, Gtk::FileChooserAction 
action, const Glib::ustring &name);
+
+
+       /*
         *
         */
        virtual ~DialogFileChooser();
@@ -61,6 +66,11 @@
         * ex: 'Subtitle Editor Project', 'SubRip', 'MicroDVD' ...
         */
        void set_current_filter(const Glib::ustring &subtitleformat_name);
+
+       /*
+        * This can be use to setup the document name based on video uri
+        */
+       void set_filename_from_another_uri(const Glib::ustring &another_uri, 
const Glib::ustring &ext);
 
 protected:
        Glib::ustring m_name;


_______________________________________________
Subtitleeditor-commits mailing list
[email protected]
https://mail.gna.org/listinfo/subtitleeditor-commits

Reply via email to