Changeset d685cc7b132dc9471218349ddee02b64b209a7c9

Show
Ignore:
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:
10 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rb1ca4c9 rd685cc7  
     12008-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 
    1242008-06-27  Armin Burgmeier  <armin@0x539.de> 
    225 
  • inc/commands/browser-commands.hpp

    rb1ca4c9 rd685cc7  
    170170        struct SessionNode { 
    171171                InfcSessionProxy* proxy; 
     172                InfSessionStatus status; 
    172173 
    173174                gulong failed_id; 
  • inc/core/preferences.hpp

    rdddf956 rd685cc7  
    5353                } 
    5454 
     55                const Type& get() const 
     56                { 
     57                        return m_value; 
     58                } 
     59 
    5560                operator const Type&() const 
    5661                { 
     
    5863                } 
    5964 
    60                 operator Type&() 
     65                /*operator Type&() 
    6166                { 
    6267                        return m_value; 
    63                 } 
     68                }*/ 
    6469 
    6570                signal_changed_type signal_changed() const 
  • inc/operations/operation-open.hpp

    r883ac1c rd685cc7  
    3232{ 
    3333public: 
    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, 
    3737                      const char* encoding /* NULL means auto-detect */); 
    3838 
     
    8181        void error(const Glib::ustring& message); 
    8282protected: 
     83        const Preferences& m_preferences; 
    8384        std::string m_name; 
    8485        InfcBrowser* m_browser; 
  • inc/operations/operations.hpp

    r883ac1c rd685cc7  
    5858        }; 
    5959 
    60         Operations(DocumentInfoStorage& info_storage, StatusBar& status_bar); 
     60        Operations(DocumentInfoStorage& info_storage, 
     61                   Preferences& preferences, StatusBar& status_bar); 
    6162        ~Operations(); 
    6263 
     
    7576 
    7677        DocumentInfoStorage& m_info_storage; 
     78        Preferences& m_preferences; 
    7779        StatusBar& m_status_bar; 
    7880 
  • src/commands/browser-commands.cpp

    rb1ca4c9 rd685cc7  
    124124 
    125125Gobby::BrowserCommands::SessionNode::SessionNode(const SessionNode& node): 
    126         proxy(node.proxy) 
     126        proxy(node.proxy), status(node.status) 
    127127{ 
    128128        g_assert(proxy == NULL); 
     
    283283                INF_TEXT_SESSION(session), 
    284284                infc_browser_iter_get_name(browser, iter)); 
     285        m_folder.switch_to_document(window); 
    285286 
    286287        SessionNode& node = m_session_map[session]; 
    287288        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); 
    288294        g_object_ref(proxy); 
    289295 
     
    350356        g_assert(iter != m_session_map.end()); 
    351357 
    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        } 
    360369} 
    361370 
     
    366375        g_assert(iter != m_session_map.end()); 
    367376 
    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        } 
    369382} 
    370383 
     
    376389        g_assert(iter != m_session_map.end()); 
    377390 
    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        } 
    386402} 
    387403 
  • src/operations/operation-new.cpp

    r91aa9b2 rd685cc7  
    3030        // TODO: Use TRUE here as soon as BrowserCommands handles it 
    3131        m_request = infc_browser_add_note(browser, parent, name.c_str(), 
    32                                           Plugins::TEXT, FALSE); 
     32                                          Plugins::TEXT, TRUE); 
    3333        // Note infc_browser_add_note does not return a 
    3434        // new reference. 
  • src/operations/operation-open.cpp

    ra978dfc rd685cc7  
    5151 
    5252Gobby::OperationOpen::OperationOpen(Operations& operations, 
     53                                    const Preferences& preferences, 
    5354                                    InfcBrowser* browser, 
    5455                                    InfcBrowserIter* parent, 
     
    5657                                    const std::string& uri, 
    5758                                    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), 
    6062        m_eol_style(DocumentInfoStorage::EOL_CR), m_request(NULL), 
    6163        m_finished_id(0), m_failed_id(0), m_raw_pos(0) 
     
    346348void Gobby::OperationOpen::read_finish() 
    347349{ 
     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 
    348364        InfUserTable* user_table = inf_user_table_new(); 
     365        inf_user_table_add_user(user_table, user); 
     366        g_object_unref(user); 
     367 
    349368        InfTextGtkBuffer* text_gtk_buffer = 
    350369                inf_text_gtk_buffer_new(m_content, user_table); 
     
    365384 
    366385        g_object_unref(io); 
    367         // TODO: Use TRUE here as soon as BrowserCommands handles it 
    368386        m_request = infc_browser_add_note_with_content( 
    369387                m_browser, &m_parent, m_name.c_str(), Plugins::TEXT, 
    370                 INF_SESSION(session), FALSE); 
     388                INF_SESSION(session), TRUE); 
    371389        g_object_unref(session); 
    372390 
  • src/operations/operations.cpp

    r883ac1c rd685cc7  
    2727 
    2828Gobby::Operations::Operations(DocumentInfoStorage& info_storage, 
     29                              Preferences& preferences, 
    2930                              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) 
    3133{ 
    3234} 
     
    5456                                        const char* encoding) 
    5557{ 
    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)); 
    5861} 
    5962 
  • src/window.cpp

    r883ac1c rd685cc7  
    3232        m_browser(*this, Plugins::TEXT, m_statusbar, m_preferences), 
    3333        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),  
    3535        m_commands_browser(m_browser, m_folder, m_statusbar, m_preferences), 
    3636        m_commands_file(*this, m_header, m_browser, m_folder, m_operations)