Changeset 6fbb20faf0c9263df082e566d81d646880948636

Show
Ignore:
Timestamp:
10/14/08 00:26:39 (5 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
1bd84c9d6dcc0de860310abca412cc2d271f2d41
Children:
09f550a23adf2adfddfdcf3bbc12cff6c1b1d669
git-committer:
Armin Burgmeier <armin@arbur.net> / 2008-10-14T00:26:39Z+0200
Message:

Show modification status in tab

2008-10-13 Armin Burgmeier <armin@…>

  • code/commands/browser-commands.hpp:
  • code/commands/browser-commands.cpp:
  • code/operations/operation-open.cpp:
  • code/operations/operation-save.cpp: Set the modified flag upon opening or saving a document correctly.
  • code/core/tablabel.hpp:
  • code/core/tablabel.cpp: Show the modify flag in the tab.
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rd759de2 r6fbb20f  
     12008-10-13  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * code/commands/browser-commands.hpp: 
     4        * code/commands/browser-commands.cpp: 
     5        * code/operations/operation-open.cpp: 
     6        * code/operations/operation-save.cpp: Set the modified flag upon 
     7        opening or saving a document correctly. 
     8 
     9        * code/core/tablabel.hpp: 
     10        * code/core/tablabel.cpp: Show the modify flag in the tab. 
     11 
    1122008-10-12  Armin Burgmeier  <armin@arbur.net> 
    213 
  • TODO

    r1bd84c9 r6fbb20f  
    1 Critical bugs: 
    2  - Gobby crashes when a document that is currently open gets deleted from the 
    3    server 
    4  
    51Some features that would be nice for a final Gobby 0.5 release. We could 
    62perhaps do pre-releases with some of these missing before: 
  • code/commands/browser-commands.cpp

    rbd34be3 r6fbb20f  
    1717 */ 
    1818 
     19// TODO: Split this file into multiple smaller files, 
     20// perhaps browser-commands.cpp (basically on_activate) 
     21// synchronization-commands.cpp (basically on_subscribe_session) 
     22// user-join-commands.cpp (basically join_user) 
     23 
    1924#include "commands/browser-commands.hpp" 
    2025#include "util/i18n.hpp" 
     
    139144                g_signal_handler_disconnect(proxy, notify_connection_id); 
    140145                g_signal_handler_disconnect(session, failed_id); 
    141                 g_signal_handler_disconnect(session, complete_id); 
     146                g_signal_handler_disconnect(session, complete_before_id); 
     147                g_signal_handler_disconnect(session, complete_after_id); 
    142148                g_signal_handler_disconnect(session, progress_id); 
    143149                g_signal_handler_disconnect(session, close_id); 
     
    317323        // AdoptedAlgorithm the default handler created to perform 
    318324        // the user join. 
    319         node.complete_id = g_signal_connect_after( 
     325        node.complete_before_id = g_signal_connect( 
    320326                session, "synchronization-complete", 
    321                 G_CALLBACK(on_synchronization_complete_static), this); 
     327                G_CALLBACK(on_synchronization_complete_before_static), this); 
     328        node.complete_after_id = g_signal_connect_after( 
     329                session, "synchronization-complete", 
     330                G_CALLBACK(on_synchronization_complete_after_static), this); 
    322331        node.progress_id = g_signal_connect( 
    323332                session, "synchronization-progress", 
     
    326335                session, "close", G_CALLBACK(on_close_static), this); 
    327336 
    328         // TODO: Connect to notify::status of subscription connection 
    329  
    330337        if(inf_session_get_status(session) == INF_SESSION_SYNCHRONIZING) 
    331338        { 
     
    383390                        Glib::ustring::compose("Synchronization failed: %1", 
    384391                                               error->message), SYNC_ERROR); 
    385         } 
    386 } 
    387  
    388 void Gobby::BrowserCommands::on_synchronization_complete(InfSession* session, 
    389                                                          InfXmlConnection* c) 
     392 
     393                // The document will be of no use anyway, so consider it not 
     394                // being modified. 
     395                gtk_text_buffer_set_modified( 
     396                        GTK_TEXT_BUFFER(window->get_text_buffer()), FALSE); 
     397        } 
     398} 
     399 
     400void Gobby::BrowserCommands:: 
     401        on_synchronization_complete_before(InfSession* session, 
     402                                           InfXmlConnection* connection) 
     403{ 
     404        SessionMap::iterator iter = m_session_map.find(session); 
     405        g_assert(iter != m_session_map.end()); 
     406 
     407        if(iter->second.status == INF_SESSION_SYNCHRONIZING) 
     408        { 
     409                // Unset modified flag after synchronization. 
     410                DocWindow* window = m_folder.lookup_document( 
     411                        INF_TEXT_SESSION(session)); 
     412                g_assert(window != NULL); 
     413 
     414                gtk_text_buffer_set_modified( 
     415                        GTK_TEXT_BUFFER(window->get_text_buffer()), FALSE); 
     416 
     417                // TODO: Actually we should always set the modified flag, 
     418                // except the document is either empty, or known in the 
     419                // document info storage and the version on disk is the same 
     420                // as the one we got synchronized. We could store a hash and 
     421                // modification time in the documentinfo storage for this. 
     422                // We should do this is another source file, such as 
     423                // synchronization-commands.cpp. 
     424        } 
     425} 
     426 
     427void Gobby::BrowserCommands:: 
     428        on_synchronization_complete_after(InfSession* session, 
     429                                          InfXmlConnection* connection) 
    390430{ 
    391431        SessionMap::iterator iter = m_session_map.find(session); 
  • code/commands/browser-commands.hpp

    rbd34be3 r6fbb20f  
    8686        } 
    8787 
    88         static void on_synchronization_complete_static(InfSession* session, 
    89                                                        InfXmlConnection* conn, 
    90                                                        gpointer user_data) 
    91         { 
    92                 static_cast<BrowserCommands*>(user_data)-> 
    93                         on_synchronization_complete(session, conn); 
     88        static void 
     89        on_synchronization_complete_before_static(InfSession* session, 
     90                                                  InfXmlConnection* conn, 
     91                                                  gpointer user_data) 
     92        { 
     93                static_cast<BrowserCommands*>(user_data)-> 
     94                        on_synchronization_complete_before(session, conn); 
     95        } 
     96 
     97        static void 
     98        on_synchronization_complete_after_static(InfSession* session, 
     99                                                 InfXmlConnection* conn, 
     100                                                 gpointer user_data) 
     101        { 
     102                static_cast<BrowserCommands*>(user_data)-> 
     103                        on_synchronization_complete_after(session, conn); 
    94104        } 
    95105 
     
    147157                                       InfXmlConnection* connection, 
    148158                                       const GError* error); 
    149         void on_synchronization_complete(InfSession* session, 
    150                                          InfXmlConnection* connection); 
     159        void on_synchronization_complete_before(InfSession* session, 
     160                                                InfXmlConnection* connection); 
     161        void on_synchronization_complete_after(InfSession* session, 
     162                                               InfXmlConnection* connection); 
    151163        void on_synchronization_progress(InfSession* session, 
    152164                                         InfXmlConnection* connection, 
     
    186198                gulong notify_connection_id; 
    187199                gulong failed_id; 
    188                 gulong complete_id; 
     200                gulong complete_before_id; 
     201                gulong complete_after_id; 
    189202                gulong progress_id; 
    190203                gulong close_id; 
  • code/core/tablabel.cpp

    r6cb2a94 r6fbb20f  
    2525        Gtk::HBox(false, 6), 
    2626        m_folder(folder), m_document(document), 
    27         m_title(document.get_title(), Gtk::ALIGN_LEFT), 
    2827        m_changed(false) 
    2928{ 
    30         update_icon(); 
     29        m_title.set_alignment(Gtk::ALIGN_LEFT); 
     30 
     31        update_icon(); 
     32        update_color(); 
     33        update_modified(); 
    3134 
    3235        m_icon.show(); 
     
    8285        update_icon(); 
    8386        update_color(); 
     87        update_modified(); 
    8488} 
    8589 
     
    9296void Gobby::TabLabel::on_modified_changed() 
    9397{ 
     98        update_modified(); 
    9499} 
    95100 
     
    184189        } 
    185190} 
     191 
     192void Gobby::TabLabel::update_modified() 
     193{ 
     194        InfSession* session = INF_SESSION(m_document.get_session()); 
     195        bool modified = gtk_text_buffer_get_modified( 
     196                GTK_TEXT_BUFFER(m_document.get_text_buffer())); 
     197 
     198        if(inf_session_get_status(session) == INF_SESSION_SYNCHRONIZING) 
     199                modified = false; 
     200 
     201        if(modified) 
     202                m_title.set_text("*" + m_document.get_title()); 
     203        else 
     204                m_title.set_text(m_document.get_title()); 
     205} 
  • code/core/tablabel.hpp

    r6cb2a94 r6fbb20f  
    9191        void update_icon(); 
    9292        void update_color(); 
     93        void update_modified(); 
    9394 
    9495        Folder& m_folder; 
  • code/operations/operation-open.cpp

    rd759de2 r6fbb20f  
    348348void Gobby::OperationOpen::read_finish() 
    349349{ 
     350        gtk_text_buffer_set_modified(m_content, FALSE); 
     351 
    350352        GtkTextIter insert_iter; 
    351353        GtkTextMark* insert = gtk_text_buffer_get_insert(m_content); 
  • code/operations/operation-save.cpp

    rbd34be3 r6fbb20f  
    8383        get_status_bar().remove_message(m_message_handle); 
    8484 
    85         // Reset file explicitenly before closing stream so that, on failure, 
     85        // Reset file explicitely before closing stream so that, on failure, 
    8686        // existing files are not overriden with the temporary files we 
    8787        // actually wrote to, at least for local files. 
     
    141141                if(m_document != NULL) 
    142142                { 
     143                        // TODO: Don't unset modified flag if the document has 
     144                        // changed in the meanwhile. 
    143145                        gtk_text_buffer_set_modified( 
    144146                                GTK_TEXT_BUFFER(