Changeset 3bb736dc8aaca0b06ecd8cd17b594c34c828759e

Show
Ignore:
Timestamp:
08/24/08 18:50:11 (5 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
cfeaba1cd10e7c3fa4201bfe898f2b6b17386cc0
Children:
092ccc37a6a943df09a8a3b83fa16f22cfed9c63
git-committer:
Armin Burgmeier <armin@arbur.net> / 2008-08-24T18:50:11Z+0200
Message:

Added FileChooser?, to store the current folder uri

2008-08-24 Armin Burgmeier <armin@…>

  • inc/core/filechooser.hpp:
  • src/core/filechooser.cpp: Added a new class that manages a "current folder uri" which specifies at which location the filechooser has been used the last time. This is used as default location for newly opened file chooser dialogs.
  • inc/core/Makefile.am:
  • src/core/Makefile.am: Add the new files to the build.
  • inc/commands/file-commands.hpp:
  • src/commands/file-commands.cpp: Use this when showing open or save dialogs.
Files:
2 added
7 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rcfeaba1 r3bb736dc  
     12008-08-24  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * inc/core/filechooser.hpp: 
     4        * src/core/filechooser.cpp: Added a new class that manages a "current 
     5        folder uri" which specifies at which location the filechooser has been 
     6        used the last time. This is used as default location for newly opened 
     7        file chooser dialogs. 
     8 
     9        * inc/core/Makefile.am: 
     10        * src/core/Makefile.am: Add the new files to the build. 
     11 
     12        * inc/commands/file-commands.hpp: 
     13        * src/commands/file-commands.cpp: Use this when showing open or save 
     14        dialogs. 
     15 
     16        * inc/window.hpp: 
     17        * src/window.cpp: Instantiate a FileChooser, pass to FileCommands. 
     18 
    1192008-08-24  Armin Burgmeier  <armin@arbur.net> 
    220 
  • inc/commands/file-commands.hpp

    r93f6a42 r3bb736dc  
    2424#include "core/header.hpp" 
    2525#include "core/browser.hpp" 
     26#include "core/filechooser.hpp" 
    2627 
     28#include <gtkmm/filechooserdialog.h> 
    2729#include <gtkmm/window.h> 
    28 #include <gtkmm/filechooserdialog.h> 
    2930#include <sigc++/trackable.h> 
    3031 
     
    3738        FileCommands(Gtk::Window& parent, Header& header, 
    3839                     const Browser& browser, Folder& folder, 
    39                      Operations& operations, 
     40                     FileChooser& file_chooser, Operations& operations, 
    4041                     const DocumentInfoStorage& info_storage, 
    4142                     Preferences& preferences); 
     
    5051 
    5152                void finish(); 
     53 
    5254                Gtk::Window& get_parent(); 
    5355                Folder& get_folder(); 
     56                FileChooser& get_file_chooser(); 
    5457                Operations& get_operations(); 
    5558                const DocumentInfoStorage& get_document_info_storage(); 
    5659                Preferences& get_preferences(); 
    5760                DocumentLocationDialog& get_document_location_dialog(); 
    58  
    59                 void set_current_folder_uri(const std::string& uri); 
    60                 const std::string& get_current_folder_uri() const; 
    6161 
    6262                SignalFinished signal_finished() const 
     
    8686        const Browser& m_browser; 
    8787        Folder& m_folder; 
     88        FileChooser& m_file_chooser; 
    8889        Operations& m_operations; 
    8990        const DocumentInfoStorage& m_document_info_storage; 
    9091        Preferences& m_preferences; 
    91  
    92         // TODO: This needs also to be available to BrowserCommands 
    93         std::string m_current_folder_uri; 
    9492 
    9593        std::auto_ptr<Task> m_task; 
  • inc/core/Makefile.am

    r9271fa8 r3bb736dc  
    55        docwindow.hpp \ 
    66        encodingselector.hpp \ 
     7        filechooser.hpp \ 
    78        folder.hpp \ 
    89        header.hpp \ 
  • inc/window.hpp

    rcd63729 r3bb736dc  
    3232#include "dialogs/initialdialog.hpp" 
    3333 
    34 #include "core/preferences.hpp" 
    3534#include "core/iconmanager.hpp" 
    3635#include "core/header.hpp" 
     
    3837#include "core/browser.hpp" 
    3938#include "core/statusbar.hpp" 
     39#include "core/preferences.hpp" 
     40#include "core/filechooser.hpp" 
    4041 
    4142#include "util/config.hpp" 
     
    8889        // Functionality 
    8990        DocumentInfoStorage m_info_storage; 
     91        FileChooser m_file_chooser; 
    9092        Operations m_operations; 
    9193 
  • src/commands/file-commands.cpp

    r93f6a42 r3bb736dc  
    7171        { 
    7272        private: 
    73                 Gtk::FileChooserDialog m_file_dialog; 
     73                FileChooser::Dialog m_file_dialog; 
    7474                std::string m_open_uri; 
    7575 
     
    7777                TaskOpen(FileCommands& file_commands): 
    7878                        Task(file_commands), 
    79                         m_file_dialog(get_parent(), 
     79                        m_file_dialog(get_file_chooser(), get_parent(), 
    8080                                      _("Choose a text file to open"), 
    8181                                      Gtk::FILE_CHOOSER_ACTION_OPEN) 
    8282                { 
    83                         m_file_dialog.add_button(Gtk::Stock::CANCEL, 
    84                                                  Gtk::RESPONSE_CANCEL); 
    85                         m_file_dialog.add_button(Gtk::Stock::OPEN, 
    86                                                  Gtk::RESPONSE_ACCEPT); 
    87  
    8883                        m_file_dialog.signal_response().connect(sigc::mem_fun( 
    8984                                *this, &TaskOpen::on_file_response)); 
    9085 
    91                         m_file_dialog.set_current_folder_uri( 
    92                                 get_current_folder_uri()); 
    9386                        m_file_dialog.present(); 
    9487                } 
     
    9689                virtual ~TaskOpen() 
    9790                { 
    98                         set_current_folder_uri( 
    99                                 m_file_dialog.get_current_folder_uri()); 
    100  
    10191                        get_document_location_dialog().hide(); 
    10292                } 
     
    156146        { 
    157147        private: 
    158                 Gtk::FileChooserDialog m_file_dialog; 
     148                FileChooser::Dialog m_file_dialog; 
    159149                DocWindow* m_document; 
    160150 
     
    163153                        Task(file_commands), 
    164154                        m_file_dialog( 
    165                                 get_parent(), Glib::ustring::compose(_( 
     155                                get_file_chooser(), get_parent(), 
     156                                Glib::ustring::compose(_( 
    166157                                        "Choose a location to save document " 
    167158                                        "\"%1\" to"), 
     
    171162                { 
    172163                         
    173                         m_file_dialog.add_button(Gtk::Stock::CANCEL, 
    174                                                  Gtk::RESPONSE_CANCEL); 
    175                         m_file_dialog.add_button(Gtk::Stock::SAVE, 
    176                                                   Gtk::RESPONSE_ACCEPT); 
    177                         m_file_dialog.set_do_overwrite_confirmation(true); 
    178  
    179164                        m_file_dialog.signal_response().connect(sigc::mem_fun( 
    180165                                *this, &TaskSave::on_response)); 
     
    192177                                m_file_dialog.set_uri(info->uri); 
    193178                        } 
    194                         else 
    195                         { 
    196                                 m_file_dialog.set_current_folder_uri( 
    197                                         get_current_folder_uri()); 
    198                         } 
    199179 
    200180                        m_file_dialog.present(); 
    201                 } 
    202  
    203                 virtual ~TaskSave() 
    204                 { 
    205                         set_current_folder_uri( 
    206                                 m_file_dialog.get_current_folder_uri()); 
    207181                } 
    208182 
     
    360334} 
    361335 
     336Gobby::FileChooser& Gobby::FileCommands::Task::get_file_chooser() 
     337{ 
     338        return m_file_commands.m_file_chooser; 
     339} 
     340 
    362341Gobby::Operations& Gobby::FileCommands::Task::get_operations() 
    363342{ 
     
    392371} 
    393372 
    394 void Gobby::FileCommands::Task::set_current_folder_uri(const std::string& uri) 
    395 { 
    396         m_file_commands.m_current_folder_uri = uri; 
    397 } 
    398  
    399 const std::string& Gobby::FileCommands::Task::get_current_folder_uri() const 
    400 { 
    401         return m_file_commands.m_current_folder_uri; 
    402 } 
    403  
    404373Gobby::FileCommands::FileCommands(Gtk::Window& parent, Header& header, 
    405374                                  const Browser& browser, Folder& folder, 
     375                                  FileChooser& file_chooser, 
    406376                                  Operations& operations, 
    407377                                  const DocumentInfoStorage& info_storage, 
    408378                                  Preferences& preferences): 
    409379        m_parent(parent), m_header(header), m_browser(browser), 
    410         m_folder(folder), m_operations(operations), 
    411         m_document_info_storage(info_storage), m_preferences(preferences), 
    412         m_current_folder_uri(Glib::filename_to_uri(Glib::get_current_dir())) 
     380        m_folder(folder), m_file_chooser(file_chooser), 
     381        m_operations(operations), m_document_info_storage(info_storage), 
     382        m_preferences(preferences) 
    413383{ 
    414384        header.action_file_new->signal_activate().connect( 
  • src/core/Makefile.am

    r9271fa8 r3bb736dc  
    66        docwindow.cpp \ 
    77        encodingselector.cpp \ 
     8        filechooser.cpp \ 
    89        folder.cpp \ 
    910        header.cpp \ 
  • src/window.cpp

    rcd63729 r3bb736dc  
    3535        m_commands_browser(m_browser, m_folder, m_info_storage, m_statusbar, 
    3636                           m_preferences), 
    37         m_commands_file(*this, m_header, m_browser, m_folder, m_operations, 
    38                         m_info_storage, m_preferences), 
     37        m_commands_file(*this, m_header, m_browser, m_folder, m_file_chooser, 
     38                        m_operations, m_info_storage, m_preferences), 
    3939        m_commands_edit(*this, m_header, m_folder, m_statusbar, 
    4040                        m_preferences),