Changeset 23dfbe65f8e482280beffb5ea001f19bd33f4af5
- Timestamp:
- 11/09/09 10:27:41 (4 years ago)
- Author:
- Armin Burgmeier <armin@…>
- git-author:
- Gabríel A. Pétursson <gabrielp@simnet.is> / 2009-11-09T10:20:41Z+0100
- Parents:
- 91395eca1c2b5080c28f69b5efc2381d5977e555
- Children:
- 2edcdf470965d8e4ed377c45ea1a54fa61b97b7c
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2009-11-09T10:27:41Z+0100
- Message:
-
Add detailed status bar error messages
2009-11-09 Gabríel A. Pétursson <gabrielp@…>
- code/commands/browser-commands.cpp:
- code/commands/file-tasks/task-open.cpp:
- code/core/browser.cpp:
- code/core/statusbar.cpp:
- code/core/statusbar.hpp:
- code/dialogs/find-dialog.cpp:
- code/operations/operation-delete.cpp:
- code/operations/operation-export-html.cpp:
- code/operations/operation-new.cpp:
- code/operations/operation-open-multiple.cpp:
- code/operations/operation-open.cpp:
- code/operations/operation-save.cpp: Minor refactoring. Added detailed
status bar error messages.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r91395ec
|
r23dfbe6
|
|
| | 1 | 2009-11-09 GabrÃel A. Pétursson <gabrielp@simnet.is> |
| | 2 | |
| | 3 | * code/commands/browser-commands.cpp: |
| | 4 | * code/commands/file-tasks/task-open.cpp: |
| | 5 | * code/core/browser.cpp: |
| | 6 | * code/core/statusbar.cpp: |
| | 7 | * code/core/statusbar.hpp: |
| | 8 | * code/dialogs/find-dialog.cpp: |
| | 9 | * code/operations/operation-delete.cpp: |
| | 10 | * code/operations/operation-export-html.cpp: |
| | 11 | * code/operations/operation-new.cpp: |
| | 12 | * code/operations/operation-open-multiple.cpp: |
| | 13 | * code/operations/operation-open.cpp: |
| | 14 | * code/operations/operation-save.cpp: Minor refactoring. Added detailed |
| | 15 | status bar error messages. |
| | 16 | |
| 1 | 17 | 2009-11-07 Armin Burgmeier <armin@arbur.net> |
| 2 | 18 | |
-
|
r141ee66
|
r23dfbe6
|
|
| 250 | 250 | node.commands = this; |
| 251 | 251 | node.browser = browser; |
| 252 | | node.handle = m_status_bar.add_message( |
| 253 | | StatusBar::INFO, |
| | 252 | node.handle = m_status_bar.add_info_message( |
| 254 | 253 | Glib::ustring::compose( |
| 255 | 254 | _("Subscribing to %1..."), |
| 256 | 255 | Glib::ustring( |
| 257 | 256 | infc_browser_iter_get_name( |
| 258 | | browser, iter))), 0); |
| | 257 | browser, iter)))); |
| 259 | 258 | |
| 260 | 259 | g_signal_connect( |
| … |
… |
|
| 268 | 267 | else |
| 269 | 268 | { |
| 270 | | m_status_bar.add_message( |
| 271 | | StatusBar::INFO, |
| 272 | | _("Subscription already in progress"), 2); |
| | 269 | m_status_bar.add_info_message( |
| | 270 | _("Subscription already in progress")); |
| 273 | 271 | } |
| 274 | 272 | } |
| … |
… |
|
| 375 | 373 | m_request_map.erase(iter); |
| 376 | 374 | |
| 377 | | m_status_bar.add_message( |
| 378 | | StatusBar::ERROR, |
| 379 | | Glib::ustring::compose(_("Subscription failed: %1"), |
| 380 | | error->message), 5); |
| | 375 | m_status_bar.add_error_message( |
| | 376 | _("Subscription failed"), |
| | 377 | error->message); |
| 381 | 378 | } |
| 382 | 379 | |
-
|
rf6cd41b
|
r23dfbe6
|
|
| 44 | 44 | G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME); |
| 45 | 45 | |
| 46 | | m_handle = get_status_bar().add_message( |
| 47 | | StatusBar::INFO, Glib::ustring::compose( |
| | 46 | m_handle = get_status_bar().add_info_message( |
| | 47 | Glib::ustring::compose( |
| 48 | 48 | _("Querying \"%1\"..."), |
| 49 | | m_file->get_uri()), 0); |
| | 49 | m_file->get_uri())); |
| 50 | 50 | } |
| 51 | 51 | catch(const Gio::Error& ex) |
| … |
… |
|
| 101 | 101 | void Gobby::TaskOpen::error(const Glib::ustring& message) |
| 102 | 102 | { |
| 103 | | get_status_bar().add_message(StatusBar::ERROR, |
| | 103 | get_status_bar().add_error_message( |
| 104 | 104 | Glib::ustring::compose( |
| 105 | | _("Failed to open document \"%1\": %2"), |
| 106 | | m_file->get_uri(), message), 5); |
| | 105 | _("Failed to open document \"%1\""), |
| | 106 | m_file->get_uri()), |
| | 107 | message); |
| 107 | 108 | |
| 108 | 109 | finish(); |
-
|
r4e250df
|
r23dfbe6
|
|
| 274 | 274 | if(!inf_tcp_connection_open(connection, &error)) |
| 275 | 275 | { |
| 276 | | m_status_bar.add_message(StatusBar::ERROR, |
| 277 | | error->message, 5); |
| | 276 | m_status_bar.add_error_message( |
| | 277 | Glib::ustring::compose( |
| | 278 | _("Connection to \"%1\" failed"), |
| | 279 | hostname), error->message); |
| 278 | 280 | g_error_free(error); |
| 279 | 281 | } |
| … |
… |
|
| 313 | 315 | |
| 314 | 316 | void Gobby::Browser::on_resolv_error(ResolvHandle* handle, |
| 315 | | const std::runtime_error& error) |
| | 317 | const std::runtime_error& error, |
| | 318 | const Glib::ustring& hostname) |
| 316 | 319 | { |
| 317 | 320 | ResolvMap::iterator iter = m_resolv_map.find(handle); |
| … |
… |
|
| 321 | 324 | m_resolv_map.erase(iter); |
| 322 | 325 | |
| 323 | | m_status_bar.add_message(StatusBar::ERROR, error.what(), 5); |
| | 326 | m_status_bar.add_error_message( |
| | 327 | Glib::ustring::compose(_("Could not resolve \"%1\""), |
| | 328 | hostname), |
| | 329 | error.what()); |
| 324 | 330 | } |
| 325 | 331 | |
| … |
… |
|
| 388 | 394 | if(device_index == 0) |
| 389 | 395 | { |
| 390 | | m_status_bar.add_message( |
| 391 | | StatusBar::ERROR, |
| | 396 | m_status_bar.add_error_message( |
| | 397 | Glib::ustring::compose( |
| | 398 | _("Connection to \"%1\" failed"), |
| | 399 | host), |
| 392 | 400 | Glib::ustring::compose( |
| 393 | 401 | _("Device \"%1\" does not exist"), |
| 394 | | device_name), 5); |
| | 402 | device_name)); |
| 395 | 403 | } |
| 396 | 404 | #endif |
| … |
… |
|
| 421 | 429 | sigc::mem_fun(*this, &Browser::on_resolv_done), |
| 422 | 430 | host, device_index), |
| 423 | | sigc::mem_fun(*this, &Browser::on_resolv_error)); |
| | 431 | sigc::bind( |
| | 432 | sigc::mem_fun(*this, &Browser::on_resolv_error), |
| | 433 | host)); |
| 424 | 434 | |
| 425 | 435 | StatusBar::MessageHandle message_handle = |
| 426 | | m_status_bar.add_message( |
| 427 | | StatusBar::INFO, Glib::ustring::compose( |
| 428 | | _("Resolving %1..."), host), 0); |
| | 436 | m_status_bar.add_info_message( |
| | 437 | Glib::ustring::compose(_("Resolving \"%1\"..."), |
| | 438 | host)); |
| 429 | 439 | |
| 430 | 440 | m_resolv_map[resolv_handle].message_handle = message_handle; |
-
|
r4e250df
|
r23dfbe6
|
|
| 112 | 112 | unsigned int device_index); |
| 113 | 113 | void on_resolv_error(ResolvHandle* handle, |
| 114 | | const std::runtime_error& error); |
| | 114 | const std::runtime_error& error, |
| | 115 | const Glib::ustring& hostname); |
| 115 | 116 | |
| 116 | 117 | void on_security_policy_changed(); |
-
|
r6b79c69
|
r23dfbe6
|
|
| 53 | 53 | |
| 54 | 54 | Gtk::Widget* widget() const { return m_widget; } |
| | 55 | |
| | 56 | Glib::ustring m_simple_desc; |
| | 57 | Glib::ustring m_detail_desc; |
| 55 | 58 | protected: |
| 56 | 59 | Gtk::Widget* m_widget; |
| … |
… |
|
| 87 | 90 | Gobby::StatusBar::add_message(MessageType type, |
| 88 | 91 | const Glib::ustring& message, |
| 89 | | unsigned int timeout) |
| 90 | | { |
| | 92 | const Glib::ustring& dialog_message) |
| | 93 | { |
| | 94 | if (m_list.size() >= 12) |
| | 95 | Gobby::StatusBar::remove_message(m_list.begin()); |
| | 96 | |
| 91 | 97 | Gtk::HBox* bar = Gtk::manage(new Gtk::HBox); |
| 92 | 98 | |
| … |
… |
|
| 106 | 112 | "shadow-type", &shadow_type, NULL); |
| 107 | 113 | Gtk::Frame* frame = Gtk::manage(new Gtk::Frame); |
| | 114 | Gtk::EventBox *eventbox = Gtk::manage(new Gtk::EventBox); |
| | 115 | |
| 108 | 116 | frame->set_shadow_type(static_cast<Gtk::ShadowType>(shadow_type)); |
| 109 | | frame->add(*bar); |
| | 117 | frame->add(*eventbox); |
| | 118 | eventbox->add(*bar); |
| 110 | 119 | bar->show(); |
| 111 | 120 | |
| 112 | 121 | pack_start(*frame, Gtk::PACK_EXPAND_WIDGET); |
| 113 | 122 | reorder_child(*frame, 0); |
| 114 | | frame->show(); |
| 115 | 123 | |
| 116 | 124 | m_list.push_back(new Message(frame)); |
| 117 | | MessageHandle iter(m_list.end()); |
| 118 | | --iter; |
| 119 | | |
| 120 | | if(timeout) |
| 121 | | { |
| 122 | | sigc::slot<bool> slot(sigc::bind_return( |
| | 125 | Gobby::StatusBar::MessageHandle iter(--m_list.end()); |
| | 126 | (*iter)->m_simple_desc = message; |
| | 127 | (*iter)->m_detail_desc = dialog_message; |
| | 128 | |
| | 129 | eventbox->signal_button_press_event().connect( |
| | 130 | sigc::bind_return( |
| 123 | 131 | sigc::bind( |
| 124 | 132 | sigc::mem_fun( |
| 125 | 133 | *this, |
| 126 | | &StatusBar::remove_message), |
| | 134 | &StatusBar::on_message_clicked), |
| 127 | 135 | iter), |
| 128 | 136 | false)); |
| 129 | | |
| 130 | | sigc::connection timeout_conn = |
| 131 | | Glib::signal_timeout().connect_seconds(slot, timeout); |
| 132 | | |
| 133 | | (*iter)->set_timeout_connection(timeout_conn); |
| 134 | | } |
| | 137 | |
| | 138 | eventbox->show(); |
| | 139 | frame->show(); |
| 135 | 140 | |
| 136 | 141 | return iter; |
| | 142 | } |
| | 143 | |
| | 144 | Gobby::StatusBar::MessageHandle |
| | 145 | Gobby::StatusBar::add_info_message(const Glib::ustring& message) |
| | 146 | { |
| | 147 | return Gobby::StatusBar::add_message(INFO, message, ""); |
| | 148 | } |
| | 149 | |
| | 150 | Gobby::StatusBar::MessageHandle |
| | 151 | Gobby::StatusBar::add_error_message(const Glib::ustring& brief_desc, |
| | 152 | const Glib::ustring& detailed_desc) |
| | 153 | { |
| | 154 | return Gobby::StatusBar::add_message(ERROR, brief_desc, detailed_desc); |
| 137 | 155 | } |
| 138 | 156 | |
| … |
… |
|
| 147 | 165 | { |
| 148 | 166 | return m_list.end(); |
| | 167 | } |
| | 168 | |
| | 169 | void Gobby::StatusBar::on_message_clicked(GdkEventButton* button, |
| | 170 | const MessageHandle& handler) |
| | 171 | { |
| | 172 | const Glib::ustring& simple = (*handler)->m_simple_desc; |
| | 173 | const Glib::ustring& detail = (*handler)->m_detail_desc; |
| | 174 | |
| | 175 | if(!detail.empty()) |
| | 176 | { |
| | 177 | if (button->button == 1) |
| | 178 | { |
| | 179 | Gtk::MessageDialog *dialog = new Gtk::MessageDialog( |
| | 180 | simple, |
| | 181 | false, |
| | 182 | Gtk::MESSAGE_ERROR, |
| | 183 | Gtk::BUTTONS_CLOSE, |
| | 184 | false |
| | 185 | ); |
| | 186 | |
| | 187 | dialog->set_secondary_text(detail, false); |
| | 188 | dialog->run(); |
| | 189 | |
| | 190 | delete dialog; |
| | 191 | } |
| | 192 | |
| | 193 | remove_message(handler); |
| | 194 | } |
| 149 | 195 | } |
| 150 | 196 | |
-
|
r6b79c69
|
r23dfbe6
|
|
| 23 | 23 | |
| 24 | 24 | #include <gtkmm/box.h> |
| | 25 | #include <gtkmm/eventbox.h> |
| | 26 | #include <gtkmm/messagedialog.h> |
| 25 | 27 | #include <gtkmm/statusbar.h> |
| 26 | 28 | |
| … |
… |
|
| 54 | 56 | ~StatusBar(); |
| 55 | 57 | |
| 56 | | MessageHandle add_message(MessageType type, |
| 57 | | const Glib::ustring& message, |
| 58 | | unsigned int timeout); // timeout in seconds |
| | 58 | MessageHandle add_info_message(const Glib::ustring& message); |
| | 59 | |
| | 60 | MessageHandle add_error_message(const Glib::ustring& brief_desc, |
| | 61 | const Glib::ustring& detailed_desc); |
| 59 | 62 | |
| 60 | 63 | void remove_message(const MessageHandle& handle); |
| … |
… |
|
| 63 | 66 | |
| 64 | 67 | protected: |
| | 68 | MessageHandle add_message(MessageType type, |
| | 69 | const Glib::ustring& message, |
| | 70 | const Glib::ustring& dialog_message); |
| | 71 | |
| 65 | 72 | static void on_mark_set_static(GtkTextBuffer* buffer, |
| 66 | 73 | GtkTextIter* location, |
| … |
… |
|
| 76 | 83 | static_cast<StatusBar*>(user_data)->on_changed(); |
| 77 | 84 | } |
| | 85 | |
| | 86 | void on_message_clicked(GdkEventButton* button, |
| | 87 | const MessageHandle& message); |
| 78 | 88 | |
| 79 | 89 | void on_document_removed(DocWindow& document); |
-
|
rd9e7c10
|
r23dfbe6
|
|
| 164 | 164 | get_find_text()); |
| 165 | 165 | |
| 166 | | m_status_bar.add_message(StatusBar::INFO, str, 5); |
| | 166 | m_status_bar.add_info_message(str); |
| 167 | 167 | return false; |
| 168 | 168 | } |
| … |
… |
|
| 180 | 180 | get_find_text()); |
| 181 | 181 | |
| 182 | | m_status_bar.add_message(StatusBar::INFO, str, 5); |
| | 182 | m_status_bar.add_info_message(str); |
| 183 | 183 | return false; |
| 184 | 184 | } |
| … |
… |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | | m_status_bar.add_message(StatusBar::INFO, message, 5); |
| | 344 | m_status_bar.add_info_message(message); |
| 345 | 345 | return result; |
| 346 | 346 | } |
-
|
rfd2f104
|
r23dfbe6
|
|
| 39 | 39 | G_CALLBACK(on_request_finished_static), this); |
| 40 | 40 | |
| 41 | | m_message_handle = get_status_bar().add_message( |
| 42 | | StatusBar::INFO, |
| 43 | | Glib::ustring::compose(_("Removing node %1..."), m_name), 0); |
| | 41 | m_message_handle = get_status_bar().add_info_message( |
| | 42 | Glib::ustring::compose(_("Removing node %1..."), m_name)); |
| 44 | 43 | } |
| 45 | 44 | |
| … |
… |
|
| 55 | 54 | void Gobby::OperationDelete::on_request_failed(const GError* error) |
| 56 | 55 | { |
| 57 | | get_status_bar().add_message( |
| 58 | | StatusBar::ERROR, |
| 59 | | Glib::ustring::compose(_("Failed to delete node %1: %2"), |
| 60 | | m_name, error->message), 5); |
| | 56 | get_status_bar().add_error_message( |
| | 57 | Glib::ustring::compose(_("Failed to delete node %1"), m_name), |
| | 58 | error->message); |
| 61 | 59 | |
| 62 | 60 | fail(); |
-
|
r1f344e6
|
r23dfbe6
|
|
| 450 | 450 | sigc::mem_fun(*this, &OperationExportHtml::on_file_replace)); |
| 451 | 451 | |
| 452 | | m_message_handle = get_status_bar().add_message( |
| 453 | | StatusBar::INFO, |
| | 452 | m_message_handle = get_status_bar().add_info_message( |
| 454 | 453 | Glib::ustring::compose( |
| 455 | 454 | _("Exporting document %1 to %2 in HTML..."), |
| 456 | | document.get_title(), uri), 0); |
| | 455 | document.get_title(), uri)); |
| 457 | 456 | } |
| 458 | 457 | |
| … |
… |
|
| 523 | 522 | void Gobby::OperationExportHtml::error(const Glib::ustring& message) |
| 524 | 523 | { |
| 525 | | get_status_bar().add_message( |
| 526 | | StatusBar::ERROR, |
| | 524 | get_status_bar().add_error_message( |
| 527 | 525 | Glib::ustring::compose( |
| 528 | | _("Failed to export document %1 to HTML: %2"), |
| 529 | | m_file->get_uri(), message), 5); |
| | 526 | _("Failed to export document %1 to HTML"), m_file->get_uri()), |
| | 527 | message); |
| 530 | 528 | |
| 531 | 529 | fail(); |
-
|
rfd2f104
|
r23dfbe6
|
|
| 52 | 52 | G_CALLBACK(on_request_finished_static), this); |
| 53 | 53 | |
| 54 | | m_message_handle = get_status_bar().add_message( |
| 55 | | StatusBar::INFO, |
| | 54 | m_message_handle = get_status_bar().add_info_message( |
| 56 | 55 | Glib::ustring::compose( |
| 57 | 56 | directory ? _("Creating directory %1...") |
| 58 | | : _("Creating document %1..."), name), 0); |
| | 57 | : _("Creating document %1..."), name)); |
| 59 | 58 | } |
| 60 | 59 | |
| … |
… |
|
| 70 | 69 | void Gobby::OperationNew::on_request_failed(const GError* error) |
| 71 | 70 | { |
| 72 | | get_status_bar().add_message( |
| 73 | | StatusBar::ERROR, |
| | 71 | get_status_bar().add_error_message( |
| 74 | 72 | Glib::ustring::compose( |
| 75 | | m_directory ? _("Failed to create directory %1: %2") |
| 76 | | : _("Failed to create document %1: %2"), |
| 77 | | m_name, error->message), 5); |
| | 73 | m_directory ? _("Failed to create directory %1") |
| | 74 | : _("Failed to create document %1"), |
| | 75 | m_name), |
| | 76 | error->message); |
| 78 | 77 | |
| 79 | 78 | fail(); |
-
|
rfd2f104
|
r23dfbe6
|
|
| 155 | 155 | const Glib::ustring& message) |
| 156 | 156 | { |
| 157 | | get_status_bar().add_message(StatusBar::ERROR, |
| | 157 | get_status_bar().add_error_message( |
| 158 | 158 | Glib::ustring::compose( |
| 159 | | _("Failed to open document \"%1\": %2"), |
| 160 | | iter->uri, message), 5); |
| | 159 | _("Failed to open document \"%1\""), iter->uri), |
| | 160 | message); |
| 161 | 161 | |
| 162 | 162 | m_infos.erase(iter); |
| … |
… |
|
| 169 | 169 | void Gobby::OperationOpenMultiple::fatal_error(const Glib::ustring& message) |
| 170 | 170 | { |
| 171 | | get_status_bar().add_message(StatusBar::ERROR, |
| 172 | | Glib::ustring::compose( |
| 173 | | _("Failed to open multiple documents: %1"), |
| 174 | | message), 5); |
| | 171 | get_status_bar().add_error_message( |
| | 172 | _("Failed to open multiple documents"), |
| | 173 | message); |
| 175 | 174 | |
| 176 | 175 | fail(); |
-
|
r9b7fc95
|
r23dfbe6
|
|
| 85 | 85 | *this, &OperationOpen::on_file_read)); |
| 86 | 86 | |
| 87 | | m_message_handle = get_status_bar().add_message( |
| 88 | | StatusBar::INFO, |
| | 87 | m_message_handle = get_status_bar().add_info_message( |
| 89 | 88 | Glib::ustring::compose( |
| 90 | | _("Opening document %1..."), uri), 0); |
| | 89 | _("Opening document %1..."), uri)); |
| 91 | 90 | |
| 92 | 91 | m_parent.signal_node_removed().connect( |
| … |
… |
|
| 434 | 433 | void Gobby::OperationOpen::error(const Glib::ustring& message) |
| 435 | 434 | { |
| 436 | | get_status_bar().add_message( |
| 437 | | StatusBar::ERROR, |
| | 435 | get_status_bar().add_error_message( |
| 438 | 436 | Glib::ustring::compose( |
| 439 | | _("Failed to open document \"%1\": %2"), |
| 440 | | m_file->get_uri(), message), 5); |
| | 437 | _("Failed to open document \"%1\""), |
| | 438 | m_file->get_uri()), |
| | 439 | message); |
| 441 | 440 | |
| 442 | 441 | fail(); |
-
|
r6afa444
|
r23dfbe6
|
|
| 70 | 70 | &OperationSave::on_file_replace)); |
| 71 | 71 | |
| 72 | | m_message_handle = get_status_bar().add_message( |
| 73 | | StatusBar::INFO, |
| | 72 | m_message_handle = get_status_bar().add_info_message( |
| 74 | 73 | Glib::ustring::compose(_("Saving document %1 to %2..."), |
| 75 | | document.get_title(), uri), 0); |
| | 74 | document.get_title(), uri)); |
| 76 | 75 | |
| 77 | 76 | folder.signal_document_removed().connect( |
| … |
… |
|
| 286 | 285 | void Gobby::OperationSave::error(const Glib::ustring& message) |
| 287 | 286 | { |
| 288 | | get_status_bar().add_message( |
| 289 | | StatusBar::ERROR, |
| 290 | | Glib::ustring::compose(_("Failed to save document %1: %2"), |
| 291 | | m_file->get_uri(), message), 5); |
| | 287 | get_status_bar().add_error_message( |
| | 288 | Glib::ustring::compose(_("Failed to save document %1"), |
| | 289 | m_file->get_uri()), |
| | 290 | message); |
| 292 | 291 | |
| 293 | 292 | fail(); |