Changeset d685cc7b132dc9471218349ddee02b64b209a7c9
- Timestamp:
- 06/27/08 21:46:39 (5 years ago)
- Author:
- Armin Burgmeier <armin@…>
- Parents:
- b1ca4c933b03b9223f71cf8ab5a68a0e17c18515
- Children:
- e4e679ae7ba627bb42375a3343fa8182c2cf68c6
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2008-06-27T21:46:39Z+0200
- Message:
-
Automatically subscribe to newly created documents.
2008-06-27 Armin Burgmeier <armin@…>
- inc/commands/browser-commands.hpp:
- src/commands/browser-commands.cpp: Make sure subscription progress
is only shown for sessions that are synchronized, not for sync-ins.
- inc/core/preferences.hpp: Removed the non-const operator Type& since
it allows changing the Properties content without notification. Also
added get() in analogy to set().
- inc/operations/operation-open.hpp:
- src/operations/operation-open.cpp: Take a Preferences in the
constructor, add a user to the session before synchronizing it to the
server so that we can start editing the document before the
synchronization is complete.
- inc/operations/operations.hpp:
- src/operations/operations.cpp:
- src/window.cpp: Pass the Preferences object to OperationOpen?.
- src/operations/operation-new.cpp: Automatically Subscribe to newly
created documents.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rb1ca4c9
|
rd685cc7
|
|
| | 1 | 2008-06-27 Armin Burgmeier <armin@0x539.de> |
| | 2 | |
| | 3 | * inc/commands/browser-commands.hpp: |
| | 4 | * src/commands/browser-commands.cpp: Make sure subscription progress |
| | 5 | is only shown for sessions that are synchronized, not for sync-ins. |
| | 6 | |
| | 7 | * inc/core/preferences.hpp: Removed the non-const operator Type& since |
| | 8 | it allows changing the Properties content without notification. Also |
| | 9 | added get() in analogy to set(). |
| | 10 | |
| | 11 | * inc/operations/operation-open.hpp: |
| | 12 | * src/operations/operation-open.cpp: Take a Preferences in the |
| | 13 | constructor, add a user to the session before synchronizing it to the |
| | 14 | server so that we can start editing the document before the |
| | 15 | synchronization is complete. |
| | 16 | |
| | 17 | * inc/operations/operations.hpp: |
| | 18 | * src/operations/operations.cpp: |
| | 19 | * src/window.cpp: Pass the Preferences object to OperationOpen. |
| | 20 | |
| | 21 | * src/operations/operation-new.cpp: Automatically Subscribe to newly |
| | 22 | created documents. |
| | 23 | |
| 1 | 24 | 2008-06-27 Armin Burgmeier <armin@0x539.de> |
| 2 | 25 | |
-
|
rb1ca4c9
|
rd685cc7
|
|
| 170 | 170 | struct SessionNode { |
| 171 | 171 | InfcSessionProxy* proxy; |
| | 172 | InfSessionStatus status; |
| 172 | 173 | |
| 173 | 174 | gulong failed_id; |
-
|
rdddf956
|
rd685cc7
|
|
| 53 | 53 | } |
| 54 | 54 | |
| | 55 | const Type& get() const |
| | 56 | { |
| | 57 | return m_value; |
| | 58 | } |
| | 59 | |
| 55 | 60 | operator const Type&() const |
| 56 | 61 | { |
| … |
… |
|
| 58 | 63 | } |
| 59 | 64 | |
| 60 | | operator Type&() |
| | 65 | /*operator Type&() |
| 61 | 66 | { |
| 62 | 67 | return m_value; |
| 63 | | } |
| | 68 | }*/ |
| 64 | 69 | |
| 65 | 70 | signal_changed_type signal_changed() const |
-
|
r883ac1c
|
rd685cc7
|
|
| 32 | 32 | { |
| 33 | 33 | public: |
| 34 | | OperationOpen(Operations& operations, InfcBrowser* browser, |
| 35 | | InfcBrowserIter* parent, const std::string& name, |
| 36 | | const std::string& uri, |
| | 34 | OperationOpen(Operations& operations, const Preferences& preferences, |
| | 35 | InfcBrowser* browser, InfcBrowserIter* parent, |
| | 36 | const std::string& name, const std::string& uri, |
| 37 | 37 | const char* encoding /* NULL means auto-detect */); |
| 38 | 38 | |
| … |
… |
|
| 81 | 81 | void error(const Glib::ustring& message); |
| 82 | 82 | protected: |
| | 83 | const Preferences& m_preferences; |
| 83 | 84 | std::string m_name; |
| 84 | 85 | InfcBrowser* m_browser; |
-
|
r883ac1c
|
rd685cc7
|
|
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | | Operations(DocumentInfoStorage& info_storage, StatusBar& status_bar); |
| | 60 | Operations(DocumentInfoStorage& info_storage, |
| | 61 | Preferences& preferences, StatusBar& status_bar); |
| 61 | 62 | ~Operations(); |
| 62 | 63 | |
| … |
… |
|
| 75 | 76 | |
| 76 | 77 | DocumentInfoStorage& m_info_storage; |
| | 78 | Preferences& m_preferences; |
| 77 | 79 | StatusBar& m_status_bar; |
| 78 | 80 | |
-
|
rb1ca4c9
|
rd685cc7
|
|
| 124 | 124 | |
| 125 | 125 | Gobby::BrowserCommands::SessionNode::SessionNode(const SessionNode& node): |
| 126 | | proxy(node.proxy) |
| | 126 | proxy(node.proxy), status(node.status) |
| 127 | 127 | { |
| 128 | 128 | g_assert(proxy == NULL); |
| … |
… |
|
| 283 | 283 | INF_TEXT_SESSION(session), |
| 284 | 284 | infc_browser_iter_get_name(browser, iter)); |
| | 285 | m_folder.switch_to_document(window); |
| 285 | 286 | |
| 286 | 287 | SessionNode& node = m_session_map[session]; |
| 287 | 288 | node.proxy = proxy; |
| | 289 | |
| | 290 | /* We cache this for the synchronization-complete signal handler, |
| | 291 | * since the session already changed to RUNNING before the signal |
| | 292 | * handler is run: */ |
| | 293 | node.status = inf_session_get_status(session); |
| 288 | 294 | g_object_ref(proxy); |
| 289 | 295 | |
| … |
… |
|
| 350 | 356 | g_assert(iter != m_session_map.end()); |
| 351 | 357 | |
| 352 | | DocWindow* window = m_folder.lookup_document( |
| 353 | | INF_TEXT_SESSION(session)); |
| 354 | | g_assert(window != NULL); |
| 355 | | |
| 356 | | set_error_text( |
| 357 | | *window, |
| 358 | | Glib::ustring::compose("Synchronization failed: %1", |
| 359 | | error->message), SYNC_ERROR); |
| | 358 | if(iter->second.status == INF_SESSION_SYNCHRONIZING) |
| | 359 | { |
| | 360 | DocWindow* window = m_folder.lookup_document( |
| | 361 | INF_TEXT_SESSION(session)); |
| | 362 | g_assert(window != NULL); |
| | 363 | |
| | 364 | set_error_text( |
| | 365 | *window, |
| | 366 | Glib::ustring::compose("Synchronization failed: %1", |
| | 367 | error->message), SYNC_ERROR); |
| | 368 | } |
| 360 | 369 | } |
| 361 | 370 | |
| … |
… |
|
| 366 | 375 | g_assert(iter != m_session_map.end()); |
| 367 | 376 | |
| 368 | | join_user(iter->second.proxy); |
| | 377 | if(iter->second.status == INF_SESSION_SYNCHRONIZING) |
| | 378 | { |
| | 379 | iter->second.status = INF_SESSION_RUNNING; |
| | 380 | join_user(iter->second.proxy); |
| | 381 | } |
| 369 | 382 | } |
| 370 | 383 | |
| … |
… |
|
| 376 | 389 | g_assert(iter != m_session_map.end()); |
| 377 | 390 | |
| 378 | | DocWindow* window = m_folder.lookup_document( |
| 379 | | INF_TEXT_SESSION(session)); |
| 380 | | |
| 381 | | g_assert(window != NULL); |
| 382 | | window->set_info( |
| 383 | | Glib::ustring::compose( |
| 384 | | _("Synchronization in progress⊠%1%%"), |
| 385 | | static_cast<unsigned int>(percentage * 100))); |
| | 391 | if(iter->second.status == INF_SESSION_SYNCHRONIZING) |
| | 392 | { |
| | 393 | DocWindow* window = m_folder.lookup_document( |
| | 394 | INF_TEXT_SESSION(session)); |
| | 395 | |
| | 396 | g_assert(window != NULL); |
| | 397 | window->set_info( |
| | 398 | Glib::ustring::compose( |
| | 399 | _("Synchronization in progress⊠%1%%"), |
| | 400 | static_cast<unsigned int>(percentage * 100))); |
| | 401 | } |
| 386 | 402 | } |
| 387 | 403 | |
-
|
r91aa9b2
|
rd685cc7
|
|
| 30 | 30 | // TODO: Use TRUE here as soon as BrowserCommands handles it |
| 31 | 31 | m_request = infc_browser_add_note(browser, parent, name.c_str(), |
| 32 | | Plugins::TEXT, FALSE); |
| | 32 | Plugins::TEXT, TRUE); |
| 33 | 33 | // Note infc_browser_add_note does not return a |
| 34 | 34 | // new reference. |
-
|
ra978dfc
|
rd685cc7
|
|
| 51 | 51 | |
| 52 | 52 | Gobby::OperationOpen::OperationOpen(Operations& operations, |
| | 53 | const Preferences& preferences, |
| 53 | 54 | InfcBrowser* browser, |
| 54 | 55 | InfcBrowserIter* parent, |
| … |
… |
|
| 56 | 57 | const std::string& uri, |
| 57 | 58 | const char* encoding): |
| 58 | | Operation(operations), m_name(name), m_browser(browser), |
| 59 | | m_parent(*parent), m_encoding_auto_detect_index(-1), |
| | 59 | Operation(operations), m_preferences(preferences), m_name(name), |
| | 60 | m_browser(browser), m_parent(*parent), |
| | 61 | m_encoding_auto_detect_index(-1), |
| 60 | 62 | m_eol_style(DocumentInfoStorage::EOL_CR), m_request(NULL), |
| 61 | 63 | m_finished_id(0), m_failed_id(0), m_raw_pos(0) |
| … |
… |
|
| 346 | 348 | void Gobby::OperationOpen::read_finish() |
| 347 | 349 | { |
| | 350 | GtkTextIter insert_iter; |
| | 351 | GtkTextMark* insert = gtk_text_buffer_get_insert(m_content); |
| | 352 | gtk_text_buffer_get_iter_at_mark(m_content, &insert_iter, insert); |
| | 353 | |
| | 354 | InfUser* user = INF_USER(g_object_new( |
| | 355 | INF_TEXT_TYPE_USER, |
| | 356 | "id", 1, |
| | 357 | "flags", INF_USER_LOCAL, |
| | 358 | "name", m_preferences.user.name.get().c_str(), |
| | 359 | "status", INF_USER_AVAILABLE, |
| | 360 | "hue", m_preferences.user.hue.get(), |
| | 361 | "caret-position", gtk_text_iter_get_offset(&insert_iter), |
| | 362 | static_cast<void*>(NULL))); |
| | 363 | |
| 348 | 364 | InfUserTable* user_table = inf_user_table_new(); |
| | 365 | inf_user_table_add_user(user_table, user); |
| | 366 | g_object_unref(user); |
| | 367 | |
| 349 | 368 | InfTextGtkBuffer* text_gtk_buffer = |
| 350 | 369 | inf_text_gtk_buffer_new(m_content, user_table); |
| … |
… |
|
| 365 | 384 | |
| 366 | 385 | g_object_unref(io); |
| 367 | | // TODO: Use TRUE here as soon as BrowserCommands handles it |
| 368 | 386 | m_request = infc_browser_add_note_with_content( |
| 369 | 387 | m_browser, &m_parent, m_name.c_str(), Plugins::TEXT, |
| 370 | | INF_SESSION(session), FALSE); |
| | 388 | INF_SESSION(session), TRUE); |
| 371 | 389 | g_object_unref(session); |
| 372 | 390 | |
-
|
r883ac1c
|
rd685cc7
|
|
| 27 | 27 | |
| 28 | 28 | Gobby::Operations::Operations(DocumentInfoStorage& info_storage, |
| | 29 | Preferences& preferences, |
| 29 | 30 | StatusBar& status_bar): |
| 30 | | m_info_storage(info_storage), m_status_bar(status_bar) |
| | 31 | m_info_storage(info_storage), m_preferences(preferences), |
| | 32 | m_status_bar(status_bar) |
| 31 | 33 | { |
| 32 | 34 | } |
| … |
… |
|
| 54 | 56 | const char* encoding) |
| 55 | 57 | { |
| 56 | | m_operations.insert(new OperationOpen(*this, browser, parent, name, |
| 57 | | from_uri, encoding)); |
| | 58 | m_operations.insert( |
| | 59 | new OperationOpen(*this, m_preferences, browser, parent, name, |
| | 60 | from_uri, encoding)); |
| 58 | 61 | } |
| 59 | 62 | |
-
|
r883ac1c
|
rd685cc7
|
|
| 32 | 32 | m_browser(*this, Plugins::TEXT, m_statusbar, m_preferences), |
| 33 | 33 | m_info_storage(INF_GTK_BROWSER_MODEL(m_browser.get_store())), |
| 34 | | m_operations(m_info_storage, m_statusbar), |
| | 34 | m_operations(m_info_storage, m_preferences, m_statusbar), |
| 35 | 35 | m_commands_browser(m_browser, m_folder, m_statusbar, m_preferences), |
| 36 | 36 | m_commands_file(*this, m_header, m_browser, m_folder, m_operations) |