Changeset 3bb736dc8aaca0b06ecd8cd17b594c34c828759e
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rcfeaba1
|
r3bb736dc
|
|
| | 1 | 2008-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 | |
| 1 | 19 | 2008-08-24 Armin Burgmeier <armin@arbur.net> |
| 2 | 20 | |
-
|
r93f6a42
|
r3bb736dc
|
|
| 24 | 24 | #include "core/header.hpp" |
| 25 | 25 | #include "core/browser.hpp" |
| | 26 | #include "core/filechooser.hpp" |
| 26 | 27 | |
| | 28 | #include <gtkmm/filechooserdialog.h> |
| 27 | 29 | #include <gtkmm/window.h> |
| 28 | | #include <gtkmm/filechooserdialog.h> |
| 29 | 30 | #include <sigc++/trackable.h> |
| 30 | 31 | |
| … |
… |
|
| 37 | 38 | FileCommands(Gtk::Window& parent, Header& header, |
| 38 | 39 | const Browser& browser, Folder& folder, |
| 39 | | Operations& operations, |
| | 40 | FileChooser& file_chooser, Operations& operations, |
| 40 | 41 | const DocumentInfoStorage& info_storage, |
| 41 | 42 | Preferences& preferences); |
| … |
… |
|
| 50 | 51 | |
| 51 | 52 | void finish(); |
| | 53 | |
| 52 | 54 | Gtk::Window& get_parent(); |
| 53 | 55 | Folder& get_folder(); |
| | 56 | FileChooser& get_file_chooser(); |
| 54 | 57 | Operations& get_operations(); |
| 55 | 58 | const DocumentInfoStorage& get_document_info_storage(); |
| 56 | 59 | Preferences& get_preferences(); |
| 57 | 60 | 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; |
| 61 | 61 | |
| 62 | 62 | SignalFinished signal_finished() const |
| … |
… |
|
| 86 | 86 | const Browser& m_browser; |
| 87 | 87 | Folder& m_folder; |
| | 88 | FileChooser& m_file_chooser; |
| 88 | 89 | Operations& m_operations; |
| 89 | 90 | const DocumentInfoStorage& m_document_info_storage; |
| 90 | 91 | Preferences& m_preferences; |
| 91 | | |
| 92 | | // TODO: This needs also to be available to BrowserCommands |
| 93 | | std::string m_current_folder_uri; |
| 94 | 92 | |
| 95 | 93 | std::auto_ptr<Task> m_task; |
-
|
r9271fa8
|
r3bb736dc
|
|
| 5 | 5 | docwindow.hpp \ |
| 6 | 6 | encodingselector.hpp \ |
| | 7 | filechooser.hpp \ |
| 7 | 8 | folder.hpp \ |
| 8 | 9 | header.hpp \ |
-
|
rcd63729
|
r3bb736dc
|
|
| 32 | 32 | #include "dialogs/initialdialog.hpp" |
| 33 | 33 | |
| 34 | | #include "core/preferences.hpp" |
| 35 | 34 | #include "core/iconmanager.hpp" |
| 36 | 35 | #include "core/header.hpp" |
| … |
… |
|
| 38 | 37 | #include "core/browser.hpp" |
| 39 | 38 | #include "core/statusbar.hpp" |
| | 39 | #include "core/preferences.hpp" |
| | 40 | #include "core/filechooser.hpp" |
| 40 | 41 | |
| 41 | 42 | #include "util/config.hpp" |
| … |
… |
|
| 88 | 89 | // Functionality |
| 89 | 90 | DocumentInfoStorage m_info_storage; |
| | 91 | FileChooser m_file_chooser; |
| 90 | 92 | Operations m_operations; |
| 91 | 93 | |
-
|
r93f6a42
|
r3bb736dc
|
|
| 71 | 71 | { |
| 72 | 72 | private: |
| 73 | | Gtk::FileChooserDialog m_file_dialog; |
| | 73 | FileChooser::Dialog m_file_dialog; |
| 74 | 74 | std::string m_open_uri; |
| 75 | 75 | |
| … |
… |
|
| 77 | 77 | TaskOpen(FileCommands& file_commands): |
| 78 | 78 | Task(file_commands), |
| 79 | | m_file_dialog(get_parent(), |
| | 79 | m_file_dialog(get_file_chooser(), get_parent(), |
| 80 | 80 | _("Choose a text file to open"), |
| 81 | 81 | Gtk::FILE_CHOOSER_ACTION_OPEN) |
| 82 | 82 | { |
| 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 | | |
| 88 | 83 | m_file_dialog.signal_response().connect(sigc::mem_fun( |
| 89 | 84 | *this, &TaskOpen::on_file_response)); |
| 90 | 85 | |
| 91 | | m_file_dialog.set_current_folder_uri( |
| 92 | | get_current_folder_uri()); |
| 93 | 86 | m_file_dialog.present(); |
| 94 | 87 | } |
| … |
… |
|
| 96 | 89 | virtual ~TaskOpen() |
| 97 | 90 | { |
| 98 | | set_current_folder_uri( |
| 99 | | m_file_dialog.get_current_folder_uri()); |
| 100 | | |
| 101 | 91 | get_document_location_dialog().hide(); |
| 102 | 92 | } |
| … |
… |
|
| 156 | 146 | { |
| 157 | 147 | private: |
| 158 | | Gtk::FileChooserDialog m_file_dialog; |
| | 148 | FileChooser::Dialog m_file_dialog; |
| 159 | 149 | DocWindow* m_document; |
| 160 | 150 | |
| … |
… |
|
| 163 | 153 | Task(file_commands), |
| 164 | 154 | m_file_dialog( |
| 165 | | get_parent(), Glib::ustring::compose(_( |
| | 155 | get_file_chooser(), get_parent(), |
| | 156 | Glib::ustring::compose(_( |
| 166 | 157 | "Choose a location to save document " |
| 167 | 158 | "\"%1\" to"), |
| … |
… |
|
| 171 | 162 | { |
| 172 | 163 | |
| 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 | | |
| 179 | 164 | m_file_dialog.signal_response().connect(sigc::mem_fun( |
| 180 | 165 | *this, &TaskSave::on_response)); |
| … |
… |
|
| 192 | 177 | m_file_dialog.set_uri(info->uri); |
| 193 | 178 | } |
| 194 | | else |
| 195 | | { |
| 196 | | m_file_dialog.set_current_folder_uri( |
| 197 | | get_current_folder_uri()); |
| 198 | | } |
| 199 | 179 | |
| 200 | 180 | m_file_dialog.present(); |
| 201 | | } |
| 202 | | |
| 203 | | virtual ~TaskSave() |
| 204 | | { |
| 205 | | set_current_folder_uri( |
| 206 | | m_file_dialog.get_current_folder_uri()); |
| 207 | 181 | } |
| 208 | 182 | |
| … |
… |
|
| 360 | 334 | } |
| 361 | 335 | |
| | 336 | Gobby::FileChooser& Gobby::FileCommands::Task::get_file_chooser() |
| | 337 | { |
| | 338 | return m_file_commands.m_file_chooser; |
| | 339 | } |
| | 340 | |
| 362 | 341 | Gobby::Operations& Gobby::FileCommands::Task::get_operations() |
| 363 | 342 | { |
| … |
… |
|
| 392 | 371 | } |
| 393 | 372 | |
| 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 | | |
| 404 | 373 | Gobby::FileCommands::FileCommands(Gtk::Window& parent, Header& header, |
| 405 | 374 | const Browser& browser, Folder& folder, |
| | 375 | FileChooser& file_chooser, |
| 406 | 376 | Operations& operations, |
| 407 | 377 | const DocumentInfoStorage& info_storage, |
| 408 | 378 | Preferences& preferences): |
| 409 | 379 | 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) |
| 413 | 383 | { |
| 414 | 384 | header.action_file_new->signal_activate().connect( |
-
|
r9271fa8
|
r3bb736dc
|
|
| 6 | 6 | docwindow.cpp \ |
| 7 | 7 | encodingselector.cpp \ |
| | 8 | filechooser.cpp \ |
| 8 | 9 | folder.cpp \ |
| 9 | 10 | header.cpp \ |
-
|
rcd63729
|
r3bb736dc
|
|
| 35 | 35 | m_commands_browser(m_browser, m_folder, m_info_storage, m_statusbar, |
| 36 | 36 | 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), |
| 39 | 39 | m_commands_edit(*this, m_header, m_folder, m_statusbar, |
| 40 | 40 | m_preferences), |