Changeset 9c8b8080dc4d007fd27de778666221b86fe62b54
- Timestamp:
- 01/06/07 23:40:53 (6 years ago)
- Author:
- Philipp Kern <phil@…>
- Parents:
- 81402324f4abc1a14b70b14781657362fbea5269
- Children:
- 56383089e5ae1d12c04e5c0b67699e31eae062e0
- git-committer:
- Philipp Kern <phil@0x539.de> / 2007-01-06T22:40:53Z+0000
- Message:
-
[project @ Display current document in title bar]
Original author: Armin Burgmeier <armin@…>
Date: 2005-07-20 11:30:28+00:00
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r7a86085
|
r9c8b808
|
|
| 66 | 66 | unsigned int get_revision() const; |
| 67 | 67 | |
| | 68 | /** Returns the path to the file. |
| | 69 | */ |
| | 70 | const Glib::ustring& get_path() const; |
| | 71 | |
| | 72 | /** Changes the path to the file. |
| | 73 | */ |
| | 74 | void set_path(const Glib::ustring& new_path); |
| | 75 | |
| 68 | 76 | /** Returns whether the local user is subscribed to this document. |
| 69 | 77 | */ |
| … |
… |
|
| 196 | 204 | Gtk::Button m_btn_subscribe; |
| 197 | 205 | |
| | 206 | /** Path to the file on the local disc. |
| | 207 | */ |
| | 208 | Glib::ustring m_path; |
| | 209 | |
| 198 | 210 | signal_cursor_moved_type m_signal_cursor_moved; |
| 199 | 211 | signal_content_changed_type m_signal_content_changed; |
-
|
r8140232
|
r9c8b808
|
|
| 73 | 73 | #endif |
| 74 | 74 | |
| | 75 | void on_folder_tab_switched(Document& document); |
| | 76 | |
| 75 | 77 | void on_about(); |
| 76 | 78 | void on_quit(); |
| … |
… |
|
| 79 | 81 | |
| 80 | 82 | // Obby signal handlers |
| 81 | | void on_obby_login_failed(obby::login::error error); |
| 82 | | bool on_obby_global_password(std::string& password); |
| 83 | | bool on_obby_user_password(std::string& password); |
| 84 | 83 | void on_obby_close(); |
| 85 | | void on_obby_sync(); |
| 86 | 84 | |
| 87 | 85 | void on_obby_user_join(obby::user& user); |
-
|
r67ecf24
|
r9c8b808
|
|
| 192 | 192 | } |
| 193 | 193 | |
| | 194 | const Glib::ustring& Gobby::Document::get_path() const |
| | 195 | { |
| | 196 | return m_path; |
| | 197 | } |
| | 198 | |
| | 199 | void Gobby::Document::set_path(const Glib::ustring& new_path) |
| | 200 | { |
| | 201 | m_path = new_path; |
| | 202 | } |
| | 203 | |
| 194 | 204 | #ifdef WITH_GTKSOURCEVIEW |
| 195 | 205 | Glib::RefPtr<Gtk::SourceLanguage> Gobby::Document::get_language() const |
-
|
r8140232
|
r9c8b808
|
|
| 84 | 84 | sigc::mem_fun(*this, &Window::on_quit) ); |
| 85 | 85 | |
| | 86 | m_folder.tab_switched_event().connect( |
| | 87 | sigc::mem_fun(*this, &Window::on_folder_tab_switched) ); |
| | 88 | |
| 86 | 89 | // Build UI |
| 87 | 90 | add_accel_group(m_header.get_accel_group() ); |
| … |
… |
|
| 316 | 319 | } |
| 317 | 320 | |
| | 321 | void Gobby::Window::on_folder_tab_switched(Document& document) |
| | 322 | { |
| | 323 | const Glib::ustring& file = document.get_document().get_title(); |
| | 324 | Glib::ustring path = document.get_path(); |
| | 325 | |
| | 326 | if(!path.empty() ) |
| | 327 | { |
| | 328 | // Replace home dir by ~ |
| | 329 | Glib::ustring home = Glib::get_home_dir(); |
| | 330 | if(path.compare(0, home.length(), home) == 0) |
| | 331 | path.replace(0, home.length(), "~"); |
| | 332 | |
| | 333 | // Set title with file and path |
| | 334 | obby::format_string title_str("%0 (%1) - Gobby"); |
| | 335 | title_str << file << path; |
| | 336 | set_title(title_str.str() ); |
| | 337 | } |
| | 338 | else |
| | 339 | { |
| | 340 | // Path not known: Set title with file only |
| | 341 | obby::format_string title_str("%0 - Gobby"); |
| | 342 | title_str << file; |
| | 343 | set_title(title_str.str() ); |
| | 344 | } |
| | 345 | } |
| | 346 | |
| 318 | 347 | void Gobby::Window::on_document_create() |
| 319 | 348 | { |
| … |
… |
|
| 333 | 362 | if(dlg.run() == Gtk::RESPONSE_OK) |
| 334 | 363 | { |
| | 364 | // TODO: Set path in newly generated document |
| 335 | 365 | m_buffer->create_document( |
| 336 | 366 | Glib::path_get_basename(dlg.get_filename()), |
| … |
… |
|
| 357 | 387 | { |
| 358 | 388 | stream << doc.get_document().get_content() << std::endl; |
| | 389 | doc.get_document().set_path(dlg.get_filename() ); |
| | 390 | on_folder_tab_switched(doc.get_document() ); |
| 359 | 391 | } |
| 360 | 392 | else |
| 361 | 393 | { |
| 362 | | display_error( |
| 363 | | "Could not open file " + |
| 364 | | dlg.get_filename() + |
| 365 | | " for writing" |
| 366 | | ); |
| | 394 | obby::format_string str("Could not open file " |
| | 395 | "%0 for writing"); |
| | 396 | str << dlg.get_filename(); |
| | 397 | display_error(str.str() ); |
| 367 | 398 | } |
| 368 | 399 | } |
| … |
… |
|
| 473 | 504 | } |
| 474 | 505 | |
| | 506 | /* |
| 475 | 507 | void Gobby::Window::on_obby_login_failed(obby::login::error error) |
| 476 | 508 | { |
| … |
… |
|
| 530 | 562 | return false; |
| 531 | 563 | } |
| 532 | | } |
| | 564 | }*/ |
| 533 | 565 | |
| 534 | 566 | void Gobby::Window::on_obby_close() |
| … |
… |
|
| 538 | 570 | } |
| 539 | 571 | |
| 540 | | void Gobby::Window::on_obby_sync() |
| | 572 | /*void Gobby::Window::on_obby_sync() |
| 541 | 573 | { |
| 542 | 574 | // Send documents to components |
| … |
… |
|
| 548 | 580 | if(m_buffer->document_count() > 0) |
| 549 | 581 | m_folder.set_current_page(m_buffer->document_count() - 1); |
| 550 | | } |
| | 582 | }*/ |
| 551 | 583 | |
| 552 | 584 | void Gobby::Window::on_obby_chat(obby::user& user, const Glib::ustring& message) |
| … |
… |
|
| 602 | 634 | m_chat.obby_document_remove(local_doc); |
| 603 | 635 | m_statusbar.obby_document_remove(local_doc); |
| | 636 | |
| | 637 | // Reset title if last document has been closed |
| | 638 | if(m_buffer->document_count() == 1) |
| | 639 | set_title("Gobby"); |
| 604 | 640 | } |
| 605 | 641 | |