Changeset 646a4f3c01880913367395f619aea3fe17d0cca5

Show
Ignore:
Timestamp:
11/09/09 10:53:11 (4 years ago)
Author:
Armin Burgmeier <armin@…>
git-author:
Armin Burgmeier <armin@arbur.net> / 2009-10-25T01:38:55Z+0200
Parents:
0e7581e018aad0a68e67e97779ea929e71c77463
Children:
877d3231c6feab2ff51abd8a53b79bf1ea6c7ad6
git-committer:
Armin Burgmeier <armin@arbur.net> / 2009-11-09T10:53:11Z+0100
Message:

Renamed DocWindow? to TextSessionView?, derive from SessionView?

2009-10-25 Armin Burgmeier <armin@…>

  • code/core/docwindow.hpp:
  • code/core/docwindow.cpp: Removed.
  • code/core/Makefile.am: Adapted the build.
  • code/core/sessionview.hpp:
  • code/core/sessionview.cpp: Added path & hostname to SessionView?.
  • code/core/folder.hpp:
  • code/core/folder.cpp:
  • code/core/statusbar.hpp:
  • code/core/statusbar.cpp:
  • code/core/tablabel.hpp:
  • code/core/tablabel.cpp:
  • code/core/titlebar.hpp:
  • code/core/titlebar.cpp:
  • code/core/userlist.cpp:
  • code/dialogs/find-dialog.hpp:
  • code/dialogs/find-dialog.cpp:
  • code/dialogs/goto-dialog.hpp:
  • code/dialogs/goto-dialog.cpp:
  • code/operations/operation-export-html.hpp:
  • code/operations/operation-export-html.cpp:
  • code/operations/operation-save.hpp:
  • code/operations/operation-save.cpp:
  • code/operations/operations.hpp:
  • code/operations/operations.cpp:
  • code/commands/autosave-commands.hpp:
  • code/commands/autosave-commands.cpp:
  • code/commands/browser-commands.cpp:
  • code/commands/edit-commands.hpp:
  • code/commands/edit-commands.cpp:
  • code/commands/file-commands.hpp:
  • code/commands/file-commands.cpp:
  • code/commands/folder-commands.hpp:
  • code/commands/folder-commands.cpp:
  • code/commands/view-commands.hpp:
  • code/commands/view-commands.cpp:
  • code/commands/file-tasks/task-export-html.hpp:
  • code/commands/file-tasks/task-export-html.cpp:
  • code/commands/file-tasks/task-save-all.hpp:
  • code/commands/file-tasks/task-save-all.cpp:
  • code/commands/file-tasks/task-save.hpp:
  • code/commands/file-tasks/task-save.cpp:
Files:
41 modified
2 moved

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r0e7581e r646a4f3  
     12009-10-25  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * code/core/textsessionview.hpp: 
     4        * code/core/textsessionview.cpp: Added TextSessionView, a 
     5        SessionView-deriving class showing a InfTextSession. 
     6 
     7        * code/core/docwindow.hpp: 
     8        * code/core/docwindow.cpp: Removed. 
     9 
     10        * code/core/Makefile.am: Adapted the build. 
     11 
     12        * code/core/sessionview.hpp: 
     13        * code/core/sessionview.cpp: Added path & hostname to SessionView. 
     14 
     15        * code/core/folder.hpp: 
     16        * code/core/folder.cpp: 
     17        * code/core/statusbar.hpp: 
     18        * code/core/statusbar.cpp: 
     19        * code/core/tablabel.hpp: 
     20        * code/core/tablabel.cpp: 
     21        * code/core/titlebar.hpp: 
     22        * code/core/titlebar.cpp: 
     23        * code/core/userlist.cpp: 
     24 
     25        * code/dialogs/find-dialog.hpp: 
     26        * code/dialogs/find-dialog.cpp: 
     27        * code/dialogs/goto-dialog.hpp: 
     28        * code/dialogs/goto-dialog.cpp: 
     29 
     30        * code/operations/operation-export-html.hpp: 
     31        * code/operations/operation-export-html.cpp: 
     32        * code/operations/operation-save.hpp: 
     33        * code/operations/operation-save.cpp: 
     34        * code/operations/operations.hpp: 
     35        * code/operations/operations.cpp: 
     36 
     37        * code/commands/autosave-commands.hpp: 
     38        * code/commands/autosave-commands.cpp: 
     39        * code/commands/browser-commands.cpp: 
     40        * code/commands/edit-commands.hpp: 
     41        * code/commands/edit-commands.cpp: 
     42        * code/commands/file-commands.hpp: 
     43        * code/commands/file-commands.cpp: 
     44        * code/commands/folder-commands.hpp: 
     45        * code/commands/folder-commands.cpp: 
     46        * code/commands/view-commands.hpp: 
     47        * code/commands/view-commands.cpp: 
     48        * code/commands/file-tasks/task-export-html.hpp: 
     49        * code/commands/file-tasks/task-export-html.cpp: 
     50        * code/commands/file-tasks/task-save-all.hpp: 
     51        * code/commands/file-tasks/task-save-all.cpp: 
     52        * code/commands/file-tasks/task-save.hpp: 
     53        * code/commands/file-tasks/task-save.cpp: 
     54 
     55        * code/window.cpp: Adapt for the DocWindow->TextSessionView API 
     56        change. 
     57 
    1582009-10-18  Armin Burgmeier  <armin@arbur.net> 
    259 
  • code/commands/autosave-commands.cpp

    rfd2f104 r646a4f3  
    2121#include "operations/operation-save.hpp" 
    2222 
     23#include "core/sessionuserview.hpp" 
     24 
    2325#include <ctime> 
    2426 
     
    2628{ 
    2729public: 
    28         Info(AutosaveCommands& commands, DocWindow& doc): 
    29                 m_commands(commands), m_document(doc), m_save_op(NULL) 
    30         { 
    31                 GtkSourceBuffer* buffer = m_document.get_text_buffer(); 
     30        Info(AutosaveCommands& commands, TextSessionView& view): 
     31                m_commands(commands), m_view(view), m_save_op(NULL) 
     32        { 
     33                GtkSourceBuffer* buffer = m_view.get_text_buffer(); 
    3234 
    3335                m_modified_changed_handler = g_signal_connect_after( 
     
    4244                Operations& operations = m_commands.m_operations; 
    4345                OperationSave* save_op = 
    44                         operations.get_save_operation_for_document(doc); 
     46                        operations.get_save_operation_for_document(view); 
    4547                if(save_op != NULL) 
    4648                        begin_save_operation(save_op); 
     
    5153        ~Info() 
    5254        { 
    53                 GtkSourceBuffer* buffer = m_document.get_text_buffer(); 
     55                GtkSourceBuffer* buffer = m_view.get_text_buffer(); 
    5456 
    5557                g_signal_handler_disconnect(G_OBJECT(buffer), 
     
    9597                { 
    9698                        GtkTextBuffer* buffer = 
    97                                 GTK_TEXT_BUFFER(m_document.get_text_buffer()); 
     99                                GTK_TEXT_BUFFER(m_view.get_text_buffer()); 
    98100 
    99101                        if(!gtk_text_buffer_get_modified(buffer)) 
     
    120122                // automatically retry when the document is assigned an URI, 
    121123                // since the modification flag will change with this anyway. 
    122                 const std::string& key = m_document.get_info_storage_key(); 
     124                const std::string& key = m_view.get_info_storage_key(); 
    123125                const DocumentInfoStorage::Info* info = 
    124126                        m_commands.m_info_storage.get_info(key); 
     
    147149        { 
    148150                GtkTextBuffer* buffer = 
    149                         GTK_TEXT_BUFFER(m_document.get_text_buffer()); 
     151                        GTK_TEXT_BUFFER(m_view.get_text_buffer()); 
    150152 
    151153                if(success) 
     
    162164        bool on_timeout() 
    163165        { 
    164                 const std::string& key = m_document.get_info_storage_key(); 
     166                const std::string& key = m_view.get_info_storage_key(); 
    165167                const DocumentInfoStorage::Info* info = 
    166168                        m_commands.m_info_storage.get_info(key); 
     
    171173                { 
    172174                        m_commands.m_operations.save_document( 
    173                                 m_document, m_commands.m_folder, 
     175                                m_view, m_commands.m_folder, 
    174176                                info->uri, info->encoding, info->eol_style); 
    175177 
     
    195197 
    196198        AutosaveCommands& m_commands; 
    197         DocWindow& m_document; 
     199        TextSessionView& m_view; 
    198200 
    199201        gulong m_modified_changed_handler; 
     
    245247} 
    246248 
    247 void Gobby::AutosaveCommands::on_document_added(DocWindow& document) 
     249void Gobby::AutosaveCommands::on_document_added(SessionView& view) 
    248250{ 
    249251        if(m_preferences.editor.autosave_enabled) 
    250252        { 
    251                 g_assert(m_info_map.find(&document) == m_info_map.end()); 
    252                 m_info_map[&document] = new Info(*this, document); 
    253         } 
    254 } 
    255  
    256 void Gobby::AutosaveCommands::on_document_removed(DocWindow& document) 
     253                // We can only save text views: 
     254                TextSessionView* text_view = 
     255                        dynamic_cast<TextSessionView*>(&view); 
     256                if(text_view) 
     257                { 
     258                        g_assert(m_info_map.find(text_view) == 
     259                                 m_info_map.end()); 
     260                        m_info_map[text_view] = new Info(*this, *text_view); 
     261                } 
     262        } 
     263} 
     264 
     265void Gobby::AutosaveCommands::on_document_removed(SessionView& view) 
    257266{ 
    258267        if(m_preferences.editor.autosave_enabled) 
    259268        { 
    260                 InfoMap::iterator iter = m_info_map.find(&document); 
    261                 g_assert(iter != m_info_map.end()); 
    262                 delete iter->second; 
    263                 m_info_map.erase(iter); 
     269                TextSessionView* text_view = 
     270                        dynamic_cast<TextSessionView*>(&view); 
     271 
     272                if(text_view) 
     273                { 
     274                        InfoMap::iterator iter = m_info_map.find(text_view); 
     275                        g_assert(iter != m_info_map.end()); 
     276                        delete iter->second; 
     277                        m_info_map.erase(iter); 
     278                } 
    264279        } 
    265280} 
     
    268283        OperationSave* operation) 
    269284{ 
    270         DocWindow* document = operation->get_document(); 
     285        TextSessionView* view = operation->get_view(); 
    271286        // Save operation just started, document must be present 
    272         g_assert(document != NULL); 
     287        g_assert(view != NULL); 
    273288 
    274289        if(m_preferences.editor.autosave_enabled) 
    275290        { 
    276                 InfoMap::iterator iter = m_info_map.find(document); 
     291                InfoMap::iterator iter = m_info_map.find(view); 
    277292                g_assert(iter != m_info_map.end()); 
    278293 
     
    289304                    ++i) 
    290305                { 
    291                         DocWindow* document = static_cast<DocWindow*>( 
    292                                 m_folder.get_nth_page(i)); 
    293                         m_info_map[document] = new Info(*this, *document); 
     306                        // TODO: Add convenience API to folder, so that we 
     307                        // don't need to know here that it actually contains 
     308                        // SessionUserViews. 
     309                        SessionUserView* userview = 
     310                                static_cast<SessionUserView*>( 
     311                                        m_folder.get_nth_page(i)); 
     312 
     313                        SessionView& view = userview->get_session_view(); 
     314                        TextSessionView* text_view = 
     315                                dynamic_cast<TextSessionView*>(&view); 
     316 
     317                        if(text_view) 
     318                        { 
     319                                m_info_map[text_view] = 
     320                                        new Info(*this, *text_view); 
     321                        } 
    294322                } 
    295323        } 
  • code/commands/autosave-commands.hpp

    r6b79c69 r646a4f3  
    4040 
    4141protected: 
    42         void on_document_added(DocWindow& document); 
    43         void on_document_removed(DocWindow& document); 
     42        void on_document_added(SessionView& view); 
     43        void on_document_removed(SessionView& view); 
    4444 
    4545        void on_begin_save_operation(OperationSave* operation); 
     
    5353 
    5454        class Info; 
    55         typedef std::map<DocWindow*, Info*> InfoMap; 
     55        typedef std::map<TextSessionView*, Info*> InfoMap; 
    5656        InfoMap m_info_map; 
    5757}; 
  • code/commands/browser-commands.cpp

    r23dfbe6 r646a4f3  
    4040        }; 
    4141 
    42         void set_error_text(Gobby::DocWindow& window, 
     42        void set_error_text(Gobby::SessionView& view, 
    4343                            const Glib::ustring& initial_text, 
    4444                            ErrorType type) 
     
    7474                          "Thank you."); 
    7575 
    76                 window.set_info( 
     76                view.set_info( 
    7777                        initial_text + "\n\n" + type_text + "\n\n" + 
    7878                        info_text, true); 
     
    218218        { 
    219219                InfSession* session = infc_session_proxy_get_session(proxy); 
    220                 InfTextSession* text_session = INF_TEXT_SESSION(session); 
    221                 DocWindow* window = m_folder.lookup_document(text_session); 
    222  
    223                 if(window != NULL) 
    224                 { 
    225                         m_folder.switch_to_document(*window); 
     220                //InfTextSession* text_session = INF_TEXT_SESSION(session); 
     221                SessionView* view = m_folder.lookup_document(session); 
     222                //DocWindow* window = m_folder.lookup_document(text_session); 
     223 
     224                if(view != NULL) 
     225                { 
     226                        m_folder.switch_to_document(*view); 
    226227                } 
    227228                else 
     
    230231                        // we subscribe to directly into the folder. 
    231232                        g_assert_not_reached(); 
    232                         /*folder.add_document( 
    233                                 text_session, 
    234                                 infc_browser_iter_get_name(browser, iter));*/ 
    235233                } 
    236234        } 
     
    293291                     "remote-hostname", &hostname, NULL); 
    294292 
    295         DocWindow& window = m_folder.add_document( 
     293        TextSessionView& view = m_folder.add_document( 
    296294                INF_TEXT_SESSION(session), 
    297295                infc_browser_iter_get_name(browser, iter), 
     
    306304        // then don't select the item, and if the user did issue other folder 
    307305        // events, then don't switch to the document in the folder. 
    308         m_folder.switch_to_document(window); 
    309         gtk_widget_grab_focus(GTK_WIDGET(window.get_text_view())); 
     306        m_folder.switch_to_document(view); 
     307        gtk_widget_grab_focus(GTK_WIDGET(view.get_text_view())); 
    310308        m_browser.set_selected(browser, iter); 
    311309 
     
    352350                g_object_unref(connection); 
    353351 
    354                 window.set_info( 
     352                view.set_info( 
    355353                        Glib::ustring::compose( 
    356354                                _("Synchronization in progress... %1%%"), 
     
    387385        if(iter->second.status == INF_SESSION_SYNCHRONIZING) 
    388386        { 
    389                 DocWindow* window = m_folder.lookup_document( 
    390                         INF_TEXT_SESSION(session)); 
    391                 g_assert(window != NULL); 
     387                SessionView* view = m_folder.lookup_document(session); 
     388                g_assert(view != NULL); 
    392389 
    393390                set_error_text( 
    394                         *window, 
     391                        *view, 
    395392                        Glib::ustring::compose("Synchronization failed: %1", 
    396393                                               error->message), SYNC_ERROR); 
     
    398395                // The document will be of no use anyway, so consider it not 
    399396                // being modified. 
    400                 gtk_text_buffer_set_modified( 
    401                         GTK_TEXT_BUFFER(window->get_text_buffer()), FALSE); 
     397                InfBuffer* buffer = inf_session_get_buffer(session); 
     398                inf_buffer_set_modified(buffer, FALSE); 
    402399 
    403400                // Don't wait until the session is closed because of this, 
     
    418415        { 
    419416                // Unset modified flag after synchronization. 
    420                 DocWindow* window = m_folder.lookup_document( 
    421                         INF_TEXT_SESSION(session)); 
    422                 g_assert(window != NULL); 
    423  
    424                 gtk_text_buffer_set_modified( 
    425                         GTK_TEXT_BUFFER(window->get_text_buffer()), FALSE); 
     417                SessionView* view = m_folder.lookup_document(session); 
     418                g_assert(view != NULL); 
     419 
     420                InfBuffer* buffer = inf_session_get_buffer(session); 
     421                inf_buffer_set_modified(buffer, FALSE); 
    426422 
    427423                // TODO: Actually we should always set the modified flag, 
     
    458454        if(iter->second.status == INF_SESSION_SYNCHRONIZING) 
    459455        { 
    460                 DocWindow* window = m_folder.lookup_document( 
    461                         INF_TEXT_SESSION(session)); 
    462  
    463                 g_assert(window != NULL); 
    464                 window->set_info( 
     456                SessionView* view = m_folder.lookup_document(session); 
     457 
     458                g_assert(view != NULL); 
     459                view->set_info( 
    465460                        Glib::ustring::compose( 
    466461                                _("Synchronization in progress... %1%%"), 
     
    485480        if(infc_session_proxy_get_connection(proxy) == NULL) 
    486481        { 
    487                 DocWindow* window = m_folder.lookup_document( 
    488                         INF_TEXT_SESSION(session)); 
    489                 g_assert(window != NULL); 
    490  
    491                 window->set_info(_( 
     482                SessionView* view = m_folder.lookup_document(session); 
     483                g_assert(view != NULL); 
     484 
     485                view->set_info(_( 
    492486                        "The connection to the publisher of this document " 
    493487                        "has been lost. Further changes to the document " 
     
    497491                        "of your latest changes have reached the " 
    498492                        "publisher before the connection was lost."), true); 
    499                 window->set_active_user(NULL); 
     493 
     494                TextSessionView* text_view = 
     495                        dynamic_cast<TextSessionView*>(view); 
     496                if(text_view) 
     497                        text_view->set_active_user(NULL); 
    500498        } 
    501499} 
     
    514512        if(user == NULL) 
    515513        { 
    516                 DocWindow* window = m_folder.lookup_document( 
    517                         INF_TEXT_SESSION(session)); 
    518                 g_assert(window != NULL); 
     514                // TODO: Make this work also for non-text views... should 
     515                // probably go into user-join-commands.cpp 
     516                SessionView* view = m_folder.lookup_document(session); 
     517                TextSessionView* text_view = 
     518                        dynamic_cast<TextSessionView*>(view); 
     519                g_assert(text_view != NULL); 
    519520 
    520521                // TODO: Automatically join with a different name if there is 
     
    545546 
    546547                GtkTextBuffer* buffer = 
    547                         GTK_TEXT_BUFFER(window->get_text_buffer()); 
     548                        GTK_TEXT_BUFFER(text_view->get_text_buffer()); 
    548549                GtkTextMark* mark = gtk_text_buffer_get_insert(buffer); 
    549550                GtkTextIter caret_iter; 
     
    552553                                 gtk_text_iter_get_offset(&caret_iter)); 
    553554 
    554                 if(m_folder.get_current_document() == window) 
     555                if(m_folder.get_current_document() == view) 
    555556                        g_value_set_enum(&params[4].value, INF_USER_ACTIVE); 
    556557                else 
     
    560561                InfcUserRequest* request = infc_session_proxy_join_user( 
    561562                        proxy, params, 5, &error); 
    562          
     563 
    563564                g_value_unset(&params[0].value); 
    564565                g_value_unset(&params[1].value); 
     
    570571                { 
    571572                        set_error_text( 
    572                                 *window, 
     573                                *view, 
    573574                                Glib::ustring::compose("User Join failed: %1", 
    574575                                                       error->message), 
     
    577578                else 
    578579                { 
    579                         window->set_info( 
     580                        view->set_info( 
    580581                                _("User Join in progress..."), false); 
    581582 
     
    608609 
    609610        InfcSessionProxy* proxy = static_cast<InfcSessionProxy*>(proxy_ptr); 
    610         DocWindow* window = m_folder.lookup_document( 
    611                 INF_TEXT_SESSION(infc_session_proxy_get_session(proxy))); 
    612         g_assert(window != NULL); 
     611        SessionView* view = m_folder.lookup_document( 
     612                infc_session_proxy_get_session(proxy)); 
     613        g_assert(view != NULL); 
    613614 
    614615        if(error->domain == inf_user_error_quark() && 
     
    643644 
    644645                set_error_text( 
    645                         *window, 
     646                        *view, 
    646647                        Glib::ustring::compose("User Join failed: %1", 
    647648                                               error->message), 
     
    672673                                         InfUser* user) 
    673674{ 
    674         DocWindow* window = m_folder.lookup_document( 
    675                 INF_TEXT_SESSION(infc_session_proxy_get_session(proxy))); 
    676         g_assert(window != NULL); 
     675        SessionView* view = m_folder.lookup_document( 
     676                infc_session_proxy_get_session(proxy)); 
     677        g_assert(view != NULL); 
    677678 
    678679        // TODO: Notify the user that he is using an alternative name if 
    679680        // inf_user_get_name(user) does not match m_preferences.user.name. 
    680681 
    681         window->unset_info();    
    682         window->set_active_user(INF_TEXT_USER(user)); 
    683 } 
     682        view->unset_info(); 
     683        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     684        if(text_view) 
     685                text_view->set_active_user(INF_TEXT_USER(user)); 
     686} 
  • code/commands/edit-commands.cpp

    r6b79c69 r646a4f3  
    3030        m_parent(parent), m_header(header), m_folder(folder), 
    3131        m_preferences(preferences), m_status_bar(status_bar), 
    32         m_current_document(NULL) 
     32        m_current_view(NULL) 
    3333{ 
    3434        m_header.action_edit_undo->signal_activate().connect( 
     
    6969} 
    7070 
    71 void Gobby::EditCommands::on_document_removed(DocWindow& document) 
    72 { 
    73         if(&document == m_current_document) 
     71void Gobby::EditCommands::on_document_removed(SessionView& view) 
     72{ 
     73        // TODO: Isn't this emitted by Folder already? 
     74        if(&view == m_current_view) 
    7475                on_document_changed(NULL); 
    7576} 
    7677 
    77 void Gobby::EditCommands::on_document_changed(DocWindow* document) 
    78 { 
    79         if(m_current_document != NULL) 
    80         { 
    81                 InfTextSession* session = m_current_document->get_session(); 
     78void Gobby::EditCommands::on_document_changed(SessionView* view) 
     79{ 
     80        if(m_current_view != NULL) 
     81        { 
     82                InfTextSession* session = m_current_view->get_session(); 
    8283                InfAdoptedAlgorithm* algorithm = 
    8384                        inf_adopted_session_get_algorithm( 
    8485                                INF_ADOPTED_SESSION(session)); 
    8586                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    86                         m_current_document->get_text_buffer()); 
     87                        m_current_view->get_text_buffer()); 
    8788 
    8889                if(m_synchronization_complete_handler != 0) 
     
    110111        } 
    111112 
    112         m_current_document = document; 
    113  
    114         if(document != NULL) 
    115         { 
    116                 InfTextSession* session = document->get_session(); 
    117                 InfTextUser* active_user = document->get_active_user(); 
     113        m_current_view = dynamic_cast<TextSessionView*>(view); 
     114 
     115        if(m_current_view != NULL) 
     116        { 
     117                InfTextSession* session = m_current_view->get_session(); 
     118                InfTextUser* active_user = m_current_view->get_active_user(); 
    118119                GtkTextBuffer* buffer = 
    119                         GTK_TEXT_BUFFER(document->get_text_buffer()); 
     120                        GTK_TEXT_BUFFER(m_current_view->get_text_buffer()); 
    120121 
    121122                m_active_user_changed_connection = 
    122                         document->signal_active_user_changed().connect( 
     123                        m_current_view->signal_active_user_changed().connect( 
    123124                                sigc::mem_fun( 
    124125                                        *this, 
     
    199200void Gobby::EditCommands::on_sync_complete() 
    200201{ 
    201         g_assert(m_current_document != NULL); 
    202         InfTextSession* session = m_current_document->get_session(); 
     202        g_assert(m_current_view != NULL); 
     203        InfTextSession* session = m_current_view->get_session(); 
    203204 
    204205        InfAdoptedAlgorithm* algorithm = inf_adopted_session_get_algorithm( 
     
    224225void Gobby::EditCommands::on_active_user_changed(InfTextUser* active_user) 
    225226{ 
    226         g_assert(m_current_document != NULL); 
     227        g_assert(m_current_view != NULL); 
    227228 
    228229        if(active_user != NULL) 
    229230        { 
    230                 InfTextSession* session = m_current_document->get_session(); 
     231                InfTextSession* session = m_current_view->get_session(); 
    231232                InfAdoptedAlgorithm* algorithm = 
    232233                        inf_adopted_session_get_algorithm( 
    233234                                INF_ADOPTED_SESSION(session)); 
    234235                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    235                         m_current_document->get_text_buffer()); 
     236                        m_current_view->get_text_buffer()); 
    236237 
    237238                m_header.action_edit_undo->set_sensitive( 
     
    257258void Gobby::EditCommands::on_mark_set() 
    258259{ 
    259         g_assert(m_current_document != NULL); 
     260        g_assert(m_current_view != NULL); 
    260261        GtkTextBuffer* buffer = 
    261                 GTK_TEXT_BUFFER(m_current_document->get_text_buffer()); 
     262                GTK_TEXT_BUFFER(m_current_view->get_text_buffer()); 
    262263 
    263264        m_header.action_edit_copy->set_sensitive( 
    264265                gtk_text_buffer_get_has_selection(buffer)); 
    265266 
    266         if(m_current_document->get_active_user() != NULL) 
     267        if(m_current_view->get_active_user() != NULL) 
    267268        { 
    268269                m_header.action_edit_cut->set_sensitive( 
     
    279280                                              bool can_undo) 
    280281{ 
    281         g_assert(m_current_document != NULL); 
    282         if(INF_ADOPTED_USER(m_current_document->get_active_user()) == user) 
     282        g_assert(m_current_view != NULL); 
     283        if(INF_ADOPTED_USER(m_current_view->get_active_user()) == user) 
    283284                m_header.action_edit_undo->set_sensitive(can_undo); 
    284285} 
     
    287288                                              bool can_redo) 
    288289{ 
    289         g_assert(m_current_document != NULL); 
    290         if(INF_ADOPTED_USER(m_current_document->get_active_user()) == user) 
     290        g_assert(m_current_view != NULL); 
     291        if(INF_ADOPTED_USER(m_current_view->get_active_user()) == user) 
    291292                m_header.action_edit_redo->set_sensitive(can_redo); 
    292293} 
     
    330331void Gobby::EditCommands::on_undo() 
    331332{ 
    332         g_assert(m_current_document != NULL); 
    333  
    334         gulong i_ = g_signal_connect_after(m_current_document->get_text_buffer(), "insert-text", G_CALLBACK(recaret_i), NULL); 
    335         gulong e_ = g_signal_connect_after(m_current_document->get_text_buffer(), "delete-range", G_CALLBACK(recaret_e), NULL); 
     333        g_assert(m_current_view != NULL); 
     334 
     335        gulong i_ = g_signal_connect_after(m_current_view->get_text_buffer(), "insert-text", G_CALLBACK(recaret_i), NULL); 
     336        gulong e_ = g_signal_connect_after(m_current_view->get_text_buffer(), "delete-range", G_CALLBACK(recaret_e), NULL); 
    336337 
    337338        inf_adopted_session_undo( 
    338                 INF_ADOPTED_SESSION(m_current_document->get_session()), 
    339                 INF_ADOPTED_USER(m_current_document->get_active_user()) 
     339                INF_ADOPTED_SESSION(m_current_view->get_session()), 
     340                INF_ADOPTED_USER(m_current_view->get_active_user()) 
    340341        ); 
    341342 
    342         g_signal_handler_disconnect(m_current_document->get_text_buffer(), i_); 
    343         g_signal_handler_disconnect(m_current_document->get_text_buffer(), e_); 
     343        g_signal_handler_disconnect(m_current_view->get_text_buffer(), i_); 
     344        g_signal_handler_disconnect(m_current_view->get_text_buffer(), e_); 
    344345 
    345346        if(check_set) 
    346                 gtk_text_buffer_select_range(GTK_TEXT_BUFFER(m_current_document->get_text_buffer()), &check, &check); 
     347                gtk_text_buffer_select_range(GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), &check, &check); 
    347348        check_set = false; 
    348         m_current_document->scroll_to_cursor_position(0.0); 
     349        m_current_view->scroll_to_cursor_position(0.0); 
    349350} 
    350351 
    351352void Gobby::EditCommands::on_redo() 
    352353{ 
    353         g_assert(m_current_document != NULL); 
    354  
    355         gulong i_ = g_signal_connect_after(m_current_document->get_text_buffer(), "insert-text", G_CALLBACK(recaret_i), NULL); 
    356         gulong e_ = g_signal_connect_after(m_current_document->get_text_buffer(), "delete-range", G_CALLBACK(recaret_e), NULL); 
     354        g_assert(m_current_view != NULL); 
     355 
     356        gulong i_ = g_signal_connect_after(m_current_view->get_text_buffer(), "insert-text", G_CALLBACK(recaret_i), NULL); 
     357        gulong e_ = g_signal_connect_after(m_current_view->get_text_buffer(), "delete-range", G_CALLBACK(recaret_e), NULL); 
    357358 
    358359        inf_adopted_session_redo( 
    359                 INF_ADOPTED_SESSION(m_current_document->get_session()), 
    360                 INF_ADOPTED_USER(m_current_document->get_active_user()) 
     360                INF_ADOPTED_SESSION(m_current_view->get_session()), 
     361                INF_ADOPTED_USER(m_current_view->get_active_user()) 
    361362        ); 
    362363 
    363         g_signal_handler_disconnect(m_current_document->get_text_buffer(), i_); 
    364         g_signal_handler_disconnect(m_current_document->get_text_buffer(), e_); 
     364        g_signal_handler_disconnect(m_current_view->get_text_buffer(), i_); 
     365        g_signal_handler_disconnect(m_current_view->get_text_buffer(), e_); 
    365366 
    366367        if(check_set) 
    367                 gtk_text_buffer_select_range(GTK_TEXT_BUFFER(m_current_document->get_text_buffer()), &check, &check); 
     368                gtk_text_buffer_select_range(GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), &check, &check); 
    368369        check_set = false; 
    369         m_current_document->scroll_to_cursor_position(0.0); 
     370        m_current_view->scroll_to_cursor_position(0.0); 
    370371} 
    371372 
    372373void Gobby::EditCommands::on_cut() 
    373374{ 
    374         g_assert(m_current_document != NULL); 
    375         g_assert(m_current_document->get_active_user() != NULL); 
     375        g_assert(m_current_view != NULL); 
     376        g_assert(m_current_view->get_active_user() != NULL); 
    376377 
    377378        gtk_text_buffer_cut_clipboard( 
    378                 GTK_TEXT_BUFFER(m_current_document->get_text_buffer()), 
     379                GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), 
    379380                gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), 
    380381                TRUE); 
    381382 
    382         m_current_document->scroll_to_cursor_position(0.0); 
     383        m_current_view->scroll_to_cursor_position(0.0); 
    383384} 
    384385 
    385386void Gobby::EditCommands::on_copy() 
    386387{ 
    387         g_assert(m_current_document != NULL); 
     388        g_assert(m_current_view != NULL); 
    388389 
    389390        gtk_text_buffer_copy_clipboard( 
    390                 GTK_TEXT_BUFFER(m_current_document->get_text_buffer()), 
     391                GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), 
    391392                gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); 
    392393} 
     
    394395void Gobby::EditCommands::on_paste() 
    395396{ 
    396         g_assert(m_current_document != NULL); 
    397         g_assert(m_current_document->get_active_user() != NULL); 
     397        g_assert(m_current_view != NULL); 
     398        g_assert(m_current_view->get_active_user() != NULL); 
    398399 
    399400        gtk_text_buffer_paste_clipboard( 
    400                 GTK_TEXT_BUFFER(m_current_document->get_text_buffer()), 
     401                GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), 
    401402                gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), 
    402403                NULL, TRUE); 
    403404 
    404         m_current_document->scroll_to_cursor_position(0.0); 
     405        m_current_view->scroll_to_cursor_position(0.0); 
    405406} 
    406407 
  • code/commands/edit-commands.hpp

    rd9e7c10 r646a4f3  
    4444 
    4545protected: 
    46         void on_document_removed(DocWindow& document); 
    47         void on_document_changed(DocWindow* document); 
     46        void on_document_removed(SessionView& view); 
     47        void on_document_changed(SessionView* view); 
    4848 
    4949        static void on_can_undo_changed_static(InfAdoptedAlgorithm* algorithm, 
     
    117117        std::auto_ptr<PreferencesDialog> m_preferences_dialog; 
    118118 
    119         DocWindow* m_current_document; 
     119        TextSessionView* m_current_view; 
    120120        // Only valid when m_current_document is nonzero: 
    121121        sigc::connection m_active_user_changed_connection; 
  • code/commands/file-commands.cpp

    r4e250df r646a4f3  
    153153} 
    154154 
    155 void Gobby::FileCommands::on_document_changed(DocWindow* document) 
     155void Gobby::FileCommands::on_document_changed(SessionView* view) 
    156156{ 
    157157        update_sensitivity(); 
     
    190190void Gobby::FileCommands::on_save() 
    191191{ 
    192         // TODO: Encoding selection in file chooser 
    193         DocWindow* document = m_folder.get_current_document(); 
    194         g_assert(document != NULL); 
     192        SessionView* view = m_folder.get_current_document(); 
     193        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     194        g_assert(text_view != NULL); 
    195195 
    196196        const DocumentInfoStorage::Info* info = 
    197197                m_document_info_storage.get_info( 
    198                         document->get_info_storage_key()); 
     198                        text_view->get_info_storage_key()); 
    199199 
    200200        if(info != NULL && !info->uri.empty()) 
    201201        { 
    202202                m_operations.save_document( 
    203                         *document, m_folder, info->uri, info->encoding, 
     203                        *text_view, m_folder, info->uri, info->encoding, 
    204204                        info->eol_style); 
    205205        } 
     
    212212void Gobby::FileCommands::on_save_as() 
    213213{ 
    214         DocWindow* document = m_folder.get_current_document(); 
    215         g_assert(document != NULL); 
    216  
    217         set_task(new TaskSave(*this, *document)); 
     214        SessionView* view = m_folder.get_current_document(); 
     215        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     216        g_assert(text_view != NULL); 
     217 
     218        set_task(new TaskSave(*this, *text_view)); 
    218219} 
    219220 
     
    223224} 
    224225 
    225 void Gobby::FileCommands::on_export_html() { 
    226         DocWindow* document = m_folder.get_current_document(); 
    227         g_assert(document != NULL); 
    228  
    229         set_task(new TaskExportHtml(*this, *document)); 
     226void Gobby::FileCommands::on_export_html() 
     227{ 
     228        SessionView* view = m_folder.get_current_document(); 
     229        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     230        g_assert(text_view != NULL); 
     231 
     232        set_task(new TaskExportHtml(*this, *text_view)); 
    230233} 
    231234 
    232235void Gobby::FileCommands::on_close() 
    233236{ 
    234         DocWindow* document = m_folder.get_current_document(); 
    235         g_assert(document != NULL); 
    236  
    237         m_folder.remove_document(*document); 
     237        SessionView* view = m_folder.get_current_document(); 
     238        g_assert(view != NULL); 
     239 
     240        m_folder.remove_document(*view); 
    238241} 
    239242 
     
    248251        bool create_sensitivity = gtk_tree_model_get_iter_first( 
    249252                GTK_TREE_MODEL(m_browser.get_store()), &dummy_iter); 
    250         gboolean active_sensitivity = m_folder.get_current_document() != NULL; 
     253 
     254        SessionView* view = m_folder.get_current_document(); 
     255        gboolean view_sensitivity = view != NULL; 
     256 
     257        // We can only save text documents currently 
     258        gboolean text_sensitivity = 
     259                dynamic_cast<TextSessionView*>(view) != NULL; 
    251260 
    252261        m_header.action_file_new->set_sensitive(create_sensitivity); 
     
    254263        m_header.action_file_open_location->set_sensitive(create_sensitivity); 
    255264 
    256         m_header.action_file_save->set_sensitive(active_sensitivity); 
    257         m_header.action_file_save_as->set_sensitive(active_sensitivity); 
    258         m_header.action_file_save_all->set_sensitive(active_sensitivity); 
    259         m_header.action_file_export_html->set_sensitive(active_sensitivity); 
    260         m_header.action_file_close->set_sensitive(active_sensitivity); 
    261 } 
     265        m_header.action_file_save->set_sensitive(text_sensitivity); 
     266        m_header.action_file_save_as->set_sensitive(text_sensitivity); 
     267        m_header.action_file_save_all->set_sensitive(text_sensitivity); 
     268        m_header.action_file_export_html->set_sensitive(text_sensitivity); 
     269        m_header.action_file_close->set_sensitive(view_sensitivity); 
     270} 
  • code/commands/file-commands.hpp

    r44f4113 r646a4f3  
    9393        } 
    9494 
    95         void on_document_changed(DocWindow* document); 
     95        void on_document_changed(SessionView* view); 
    9696        void on_row_inserted(); 
    9797        void on_row_deleted(); 
  • code/commands/file-tasks/task-export-html.cpp

    rb24d6e3 r646a4f3  
    2323 
    2424Gobby::TaskExportHtml::TaskExportHtml(FileCommands& file_commands, 
    25                                       DocWindow& document): 
     25                                      TextSessionView& view): 
    2626        Task(file_commands), 
    2727        m_file_dialog(get_file_chooser(), get_parent(), 
    2828                Glib::ustring::compose( 
    2929                        _("Choose a location to export document \"%1\" to"), 
    30                         document.get_title()), 
     30                        view.get_title()), 
    3131                Gtk::FILE_CHOOSER_ACTION_SAVE), 
    32         m_document(&document), 
    33         m_running(false) 
     32        m_view(&view), m_running(false) 
    3433{ 
    3534        get_folder().signal_document_removed().connect( 
     
    4140        // m_document will be set to NULL if it has been removed before run 
    4241        // was called. 
    43         if(!m_document) 
     42        if(!m_view) 
    4443        { 
    4544                finish(); 
     
    5251                *this, &TaskExportHtml::on_response)); 
    5352 
    54         m_file_dialog.set_current_name(m_document->get_title() + ".xhtml"); 
     53        m_file_dialog.set_current_name(m_view->get_title() + ".xhtml"); 
    5554        m_file_dialog.present(); 
    5655} 
     
    6160        { 
    6261                get_operations().export_html( 
    63                         *m_document, m_file_dialog.get_uri()); 
     62                        *m_view, m_file_dialog.get_uri()); 
    6463        } 
    6564 
     
    6766} 
    6867 
    69 void Gobby::TaskExportHtml::on_document_removed(DocWindow& document) 
     68void Gobby::TaskExportHtml::on_document_removed(SessionView& view) 
    7069{ 
    7170        // The document we are about to save was removed. 
    72         if(m_document == &document) 
     71        if(m_view == &view) 
    7372        { 
    7473                if(m_running) 
    7574                        finish(); 
    7675                else 
    77                         m_document = NULL; 
     76                        m_view = NULL; 
    7877        } 
    7978} 
  • code/commands/file-tasks/task-export-html.hpp

    rb24d6e3 r646a4f3  
    2929private: 
    3030        FileChooser::Dialog m_file_dialog; 
    31         DocWindow* m_document; 
     31        TextSessionView* m_view; 
    3232        bool m_running; 
    3333 
    3434public: 
    35         TaskExportHtml(FileCommands& file_commands, DocWindow& document); 
     35        TaskExportHtml(FileCommands& file_commands, TextSessionView& view); 
    3636        virtual void run(); 
    3737 
    3838        void on_response(int response_id); 
    39         void on_document_removed(DocWindow& document); 
     39        void on_document_removed(SessionView& view); 
    4040}; 
    4141 
  • code/commands/file-tasks/task-save-all.cpp

    r8bafce5 r646a4f3  
    3535            iter != pages.end(); ++ iter) 
    3636        { 
    37                 m_documents.push_back( 
    38                         static_cast<DocWindow*>(iter->get_child())); 
     37                SessionView* view = 
     38                        static_cast<SessionView*>(iter->get_child()); 
     39                TextSessionView* text_view = 
     40                        dynamic_cast<TextSessionView*>(view); 
     41 
     42                if(text_view) 
     43                        m_views.push_back(text_view); 
    3944        } 
    4045 
     
    4247                sigc::mem_fun(*this, &TaskSaveAll::on_document_removed)); 
    4348 
    44         m_current = m_documents.begin(); 
     49        m_current = m_views.begin(); 
    4550        process_current(); 
    4651} 
    4752 
    48 void Gobby::TaskSaveAll::on_document_removed(DocWindow& document) 
     53void Gobby::TaskSaveAll::on_document_removed(SessionView& view) 
    4954{ 
    50         std::list<DocWindow*>::iterator iter = std::find( 
    51                 m_documents.begin(), m_documents.end(), &document); 
     55        std::list<TextSessionView*>::iterator iter = std::find( 
     56                m_views.begin(), m_views.end(), &view); 
    5257 
    5358        if(iter == m_current) 
    5459        { 
    55                 m_current = m_documents.erase(m_current); 
     60                m_current = m_views.erase(m_current); 
    5661                // Go on with next 
    5762                process_current(); 
    5863        } 
    5964 
    60         if(iter != m_documents.end()) 
    61                 m_documents.erase(iter); 
     65        if(iter != m_views.end()) 
     66                m_views.erase(iter); 
    6267} 
    6368 
    6469void Gobby::TaskSaveAll::on_finished() 
    6570{ 
    66         m_current = m_documents.erase(m_current); 
     71        m_current = m_views.erase(m_current); 
    6772        process_current(); 
    6873} 
     
    7277        m_task.reset(NULL); 
    7378 
    74         if(m_current == m_documents.end()) 
     79        if(m_current == m_views.end()) 
    7580        { 
    7681                finish(); 
     
    7883        else 
    7984        { 
    80                 DocWindow& doc = **m_current; 
     85                TextSessionView& view = **m_current; 
    8186 
    8287                const DocumentInfoStorage::Info* info = 
    8388                        get_document_info_storage().get_info( 
    84                                 doc.get_info_storage_key()); 
     89                                view.get_info_storage_key()); 
    8590 
    8691                if(info != NULL && !info->uri.empty()) 
    8792                { 
    8893                        get_operations().save_document( 
    89                                 doc, get_folder(), info->uri, 
     94                                view, get_folder(), info->uri, 
    9095                                info->encoding, info->eol_style); 
    9196 
    92                         m_current = m_documents.erase(m_current); 
     97                        m_current = m_views.erase(m_current); 
    9398                        process_current(); 
    9499                } 
    95100                else 
    96101                { 
    97                         m_task.reset(new TaskSave(m_file_commands, doc)); 
     102                        m_task.reset(new TaskSave(m_file_commands, view)); 
    98103 
    99104                        m_task->signal_finished().connect(sigc::mem_fun( 
  • code/commands/file-tasks/task-save-all.hpp

    r3da60b7 r646a4f3  
    3434 
    3535private: 
    36         void on_document_removed(DocWindow& document); 
     36        void on_document_removed(SessionView& view); 
    3737        void on_finished(); 
    3838 
    3939        void process_current(); 
    4040 
    41         std::list<DocWindow*> m_documents; 
    42         std::list<DocWindow*>::iterator m_current; 
     41        std::list<TextSessionView*> m_views; 
     42        std::list<TextSessionView*>::iterator m_current; 
    4343        std::auto_ptr<TaskSave> m_task; 
    4444}; 
  • code/commands/file-tasks/task-save.cpp

    r83d4812 r646a4f3  
    2020#include "util/i18n.hpp" 
    2121 
    22 Gobby::TaskSave::TaskSave(FileCommands& file_commands, DocWindow& document): 
     22Gobby::TaskSave::TaskSave(FileCommands& file_commands, TextSessionView& view): 
    2323        Task(file_commands), 
    2424        m_file_dialog(get_file_chooser(), get_parent(), 
    2525                Glib::ustring::compose( 
    2626                        _("Choose a location to save document \"%1\" to"), 
    27                         document.get_title()), 
     27                        view.get_title()), 
    2828                Gtk::FILE_CHOOSER_ACTION_SAVE), 
    29         m_document(&document), 
     29        m_view(&view), 
    3030        m_running(false) 
    3131{ 
     
    3636void Gobby::TaskSave::run() 
    3737{ 
    38         // m_document will be set to NULL if it has been removed before run 
     38        // m_view will be set to NULL if it has been removed before run 
    3939        // was called. 
    40         if(!m_document) 
     40        if(!m_view) 
    4141        { 
    4242                finish(); 
     
    5151        const DocumentInfoStorage::Info* info = 
    5252                get_document_info_storage().get_info( 
    53                         m_document->get_info_storage_key()); 
     53                        m_view->get_info_storage_key()); 
    5454 
    5555        if(info != NULL && !info->uri.empty()) 
    56         { 
    5756                m_file_dialog.set_uri(info->uri); 
    58         } 
    5957        else 
    60         { 
    61                 m_file_dialog.set_current_name( 
    62                         m_document->get_title()); 
    63         } 
     58                m_file_dialog.set_current_name(m_view->get_title()); 
    6459 
    6560        m_file_dialog.present(); 
     
    7166        { 
    7267                const std::string& info_storage_key = 
    73                         m_document->get_info_storage_key(); 
     68                        m_view->get_info_storage_key(); 
    7469 
    7570                const DocumentInfoStorage::Info* info = 
     
    8075                // TODO: Default to CRLF on Windows 
    8176                get_operations().save_document( 
    82                         *m_document, get_folder(), m_file_dialog.get_uri(), 
     77                        *m_view, get_folder(), m_file_dialog.get_uri(), 
    8378                        info ? info->encoding : "UTF-8", 
    8479                        info ? info->eol_style : DocumentInfoStorage::EOL_LF); 
     
    8883} 
    8984 
    90 void Gobby::TaskSave::on_document_removed(DocWindow& document) 
     85void Gobby::TaskSave::on_document_removed(SessionView& view) 
    9186{ 
    9287        // The document we are about to save was removed. 
    93         if(m_document == &document) 
     88        if(m_view == &view) 
    9489        { 
    9590                if(m_running) 
    9691                        finish(); 
    9792                else 
    98                         m_document = NULL; 
     93                        m_view = NULL; 
    9994        } 
    10095} 
  • code/commands/file-tasks/task-save.hpp

    r3da60b7 r646a4f3  
    2929private: 
    3030        FileChooser::Dialog m_file_dialog; 
    31         DocWindow* m_document; 
     31        TextSessionView* m_view; 
    3232        bool m_running; 
    3333 
    3434public: 
    35         TaskSave(FileCommands& file_commands, DocWindow& document); 
     35        TaskSave(FileCommands& file_commands, TextSessionView& view); 
    3636        virtual void run(); 
    3737 
    3838        void on_response(int response_id); 
    39         void on_document_removed(DocWindow& document); 
     39        void on_document_removed(SessionView& view); 
    4040}; 
    4141 
  • code/commands/folder-commands.cpp

    raeee99c r646a4f3  
    1818 
    1919#include "commands/folder-commands.hpp" 
     20#include "core/sessionuserview.hpp" 
    2021 
    2122#include <libinftextgtk/inf-text-gtk-buffer.h> 
    2223 
     24// TODO: Make this work with non-text documents also... maybe split & 
     25// share a base class... or better: Move active user stuff to SessionView 
     26// base. All SessionView's should be modifyable by the user, and if there are 
     27// document types gobby only supports in a read-only kind of way the active 
     28// user can just be NULL all the time. 
    2329class Gobby::FolderCommands::DocInfo: public sigc::trackable 
    2430{ 
     
    2632        static const unsigned int ACTIVATION_DELAY = 1000; 
    2733 
    28         DocInfo(DocWindow& document): 
    29                 m_document(document), m_active_user(NULL), m_active(false) 
    30         { 
    31                 m_document.signal_active_user_changed().connect( 
     34        DocInfo(TextSessionView& view): 
     35                m_view(view), m_active_user(NULL), m_active(false) 
     36        { 
     37                m_view.signal_active_user_changed().connect( 
    3238                        sigc::mem_fun( 
    3339                                *this, &DocInfo::on_active_user_changed)); 
    3440 
    35                 on_active_user_changed(document.get_active_user()); 
     41                on_active_user_changed(view.get_active_user()); 
    3642        } 
    3743 
     
    5258                InfTextGtkBuffer* buffer = INF_TEXT_GTK_BUFFER( 
    5359                        inf_session_get_buffer( 
    54                                 INF_SESSION(m_document.get_session()))); 
     60                                INF_SESSION(m_view.get_session()))); 
    5561 
    5662                inf_text_gtk_buffer_set_wake_on_cursor_movement( 
     
    6571                InfTextGtkBuffer* buffer = INF_TEXT_GTK_BUFFER( 
    6672                        inf_session_get_buffer( 
    67                                 INF_SESSION(m_document.get_session()))); 
     73                                INF_SESSION(m_view.get_session()))); 
    6874 
    6975                inf_text_gtk_buffer_set_wake_on_cursor_movement( 
     
    98104                         * again later. */ 
    99105                        inf_text_session_flush_requests_for_user( 
    100                                 m_document.get_session(), 
     106                                m_view.get_session(), 
    101107                                INF_TEXT_USER(m_active_user)); 
    102108 
    103109                        inf_session_set_user_status( 
    104                                 INF_SESSION(m_document.get_session()), 
     110                                INF_SESSION(m_view.get_session()), 
    105111                                m_active_user, INF_USER_INACTIVE); 
    106112                        break; 
     
    191197 
    192198                inf_session_set_user_status( 
    193                         INF_SESSION(m_document.get_session()), m_active_user, 
     199                        INF_SESSION(m_view.get_session()), m_active_user, 
    194200                        INF_USER_ACTIVE); 
    195201 
     
    197203        } 
    198204 
    199         DocWindow& m_document; 
     205        TextSessionView& m_view; 
    200206        InfUser* m_active_user; 
    201207        bool m_active; 
     
    206212 
    207213Gobby::FolderCommands::FolderCommands(Folder& folder): 
    208         m_folder(folder), m_current_document(NULL) 
     214        m_folder(folder), m_current_view(NULL) 
    209215{ 
    210216        m_folder.signal_document_added().connect( 
     
    217223        for(unsigned int i = 0; i < m_folder.get_n_pages(); ++ i) 
    218224        { 
    219                 DocWindow* window = static_cast<DocWindow*>( 
     225                // TODO: Convenience API in Folder to retrieve SessionView, 
     226                // so that we don't need to know about SessionUserView here. 
     227                SessionUserView* user_view = static_cast<SessionUserView*>( 
    220228                        m_folder.get_nth_page(i)); 
    221                 g_assert(window != NULL); 
    222  
    223                 on_document_added(*window); 
     229                SessionView& view = user_view->get_session_view(); 
     230                TextSessionView* text_view = 
     231                        dynamic_cast<TextSessionView*>(&view); 
     232 
     233                if(text_view) 
     234                        on_document_added(*text_view); 
    224235        } 
    225236 
     
    236247} 
    237248 
    238 void Gobby::FolderCommands::on_document_added(DocWindow& document) 
    239 { 
    240         DocInfo* info = new DocInfo(document); 
    241         m_doc_map[&document] = info; 
    242 } 
    243  
    244 void Gobby::FolderCommands::on_document_removed(DocWindow& document) 
    245 { 
    246         DocumentMap::iterator iter = m_doc_map.find(&document); 
    247         g_assert(iter != m_doc_map.end()); 
    248  
    249         delete iter->second; 
    250         m_doc_map.erase(iter); 
    251  
    252         // on_document_changed is called when another document has 
    253         // been selected 
    254         if(&document == m_current_document) 
    255                 m_current_document = NULL; 
    256 } 
    257  
    258 void Gobby::FolderCommands::on_document_changed(DocWindow* document) 
    259 { 
    260         if(m_current_document != NULL) 
     249void Gobby::FolderCommands::on_document_added(SessionView& view) 
     250{ 
     251        TextSessionView* text_view = dynamic_cast<TextSessionView*>(&view); 
     252        if(text_view) 
     253        { 
     254                DocInfo* info = new DocInfo(*text_view); 
     255                m_doc_map[text_view] = info; 
     256        } 
     257} 
     258 
     259void Gobby::FolderCommands::on_document_removed(SessionView& view) 
     260{ 
     261        TextSessionView* text_view = dynamic_cast<TextSessionView*>(&view); 
     262        if(text_view) 
     263        { 
     264                DocumentMap::iterator iter = m_doc_map.find(text_view); 
     265                g_assert(iter != m_doc_map.end()); 
     266 
     267                delete iter->second; 
     268                m_doc_map.erase(iter); 
     269 
     270                // TODO: Isn't this called by Folder already? Would need to 
     271                // call changed first and then removed of course. We could 
     272                // then assert here. 
     273                if(text_view == m_current_view) 
     274                        m_current_view = NULL; 
     275        } 
     276} 
     277 
     278void Gobby::FolderCommands::on_document_changed(SessionView* view) 
     279{ 
     280        if(m_current_view != NULL) 
    261281        { 
    262282                DocumentMap::iterator iter = 
    263                         m_doc_map.find(m_current_document); 
     283                        m_doc_map.find(m_current_view); 
    264284                g_assert(iter != m_doc_map.end()); 
    265285 
     
    267287        } 
    268288 
    269         m_current_document = document; 
    270  
    271         if(document != NULL) 
    272         { 
    273                 DocumentMap::iterator iter = m_doc_map.find(document); 
     289        m_current_view = dynamic_cast<TextSessionView*>(view); 
     290 
     291        if(m_current_view != NULL) 
     292        { 
     293                DocumentMap::iterator iter = m_doc_map.find(m_current_view); 
    274294                g_assert(iter != m_doc_map.end()); 
    275295 
  • code/commands/folder-commands.hpp

    r6b79c69 r646a4f3  
    3535protected: 
    3636 
    37         void on_document_added(DocWindow& document); 
    38         void on_document_removed(DocWindow& document); 
    39         void on_document_changed(DocWindow* document); 
     37        void on_document_added(SessionView& view); 
     38        void on_document_removed(SessionView& view); 
     39        void on_document_changed(SessionView* view); 
    4040 
    4141        Folder& m_folder; 
    4242 
    43         DocWindow* m_current_document; 
     43        TextSessionView* m_current_view; 
    4444 
    4545        class DocInfo; 
    46         typedef std::map<DocWindow*, DocInfo*> DocumentMap; 
     46        typedef std::map<SessionView*, DocInfo*> DocumentMap; 
    4747        DocumentMap m_doc_map; 
    4848}; 
  • code/commands/view-commands.cpp

    r6b79c69 r646a4f3  
    2323                                  Preferences& preferences): 
    2424        m_header(header), m_folder(folder), m_preferences(preferences), 
    25         m_current_document(NULL) 
     25        m_current_view(NULL) 
    2626{ 
    2727        m_menu_view_toolbar_connection =  
     
    9292} 
    9393 
    94 void Gobby::ViewCommands::on_document_changed(DocWindow* document) 
    95 { 
    96         if(m_current_document != NULL) 
     94void Gobby::ViewCommands::on_document_changed(SessionView* view) 
     95{ 
     96        if(m_current_view != NULL) 
    9797                m_document_language_changed_connection.disconnect(); 
    9898 
    99         m_current_document = document; 
    100  
    101         if(document != NULL) 
     99        m_current_view = dynamic_cast<TextSessionView*>(view); 
     100 
     101        if(m_current_view != NULL) 
    102102        { 
    103103                m_header.action_view_highlight_mode->set_sensitive(true); 
     
    105105 
    106106                m_document_language_changed_connection = 
    107                         document->signal_language_changed().connect( 
     107                        m_current_view->signal_language_changed().connect( 
    108108                                sigc::mem_fun( 
    109109                                        *this, 
     
    118118                m_menu_language_changed_connection.unblock(); 
    119119 
    120                 m_header.action_view_userlist->set_sensitive(false); 
     120                // Can toggle userlist also if it's not a textsession: 
     121                m_header.action_view_userlist->set_sensitive(view != NULL); 
    121122        } 
    122123 
    123         on_doc_language_changed(document ? document->get_language() : NULL); 
     124        on_doc_language_changed( 
     125                m_current_view ? m_current_view->get_language() : NULL); 
    124126} 
    125127 
     
    194196                Glib::RefPtr<Header::LanguageAction>::cast_static(action); 
    195197 
    196         g_assert(m_current_document != NULL); 
     198        g_assert(m_current_view != NULL); 
    197199 
    198200        m_document_language_changed_connection.block(); 
    199         m_current_document->set_language(language_action->get_language()); 
     201        m_current_view->set_language(language_action->get_language()); 
    200202        m_document_language_changed_connection.unblock(); 
    201203} 
     
    207209                (language != NULL) ? 
    208210                        m_header.lookup_language_action( 
    209                                 m_current_document->get_language()) : 
     211                                m_current_view->get_language()) : 
    210212                        m_header.action_view_highlight_none; 
    211213 
  • code/commands/view-commands.hpp

    r6b79c69 r646a4f3  
    3636 
    3737protected: 
    38         void on_document_changed(DocWindow* document); 
     38        void on_document_changed(SessionView* view); 
    3939         
    4040        void on_menu_toolbar_toggled(); 
     
    5555        Preferences& m_preferences; 
    5656 
    57         DocWindow* m_current_document; 
     57        TextSessionView* m_current_view; 
    5858 
    5959        sigc::connection m_menu_language_changed_connection; 
  • code/core/Makefile.am

    r0e7581e r646a4f3  
    55        closableframe.cpp \ 
    66        documentinfostorage.cpp \ 
    7         docwindow.cpp \ 
    87        filechooser.cpp \ 
    98        folder.cpp \ 
     
    1817        statusbar.cpp \ 
    1918        tablabel.cpp \ 
     19        textsessionview.cpp \ 
    2020        titlebar.cpp \ 
    2121        userlist.cpp 
     
    2525        closableframe.hpp \ 
    2626        documentinfostorage.hpp \ 
    27         docwindow.hpp \ 
    2827        filechooser.hpp \ 
    2928        folder.hpp \ 
     
    3837        statusbar.hpp \ 
    3938        tablabel.hpp \ 
     39        textsessionview.hpp \ 
    4040        titlebar.hpp \ 
    4141        userlist.hpp 
  • code/core/folder.cpp

    re861d03 r646a4f3  
    1818 
    1919#include "core/folder.hpp" 
     20#include "core/sessionuserview.hpp" 
    2021#include "core/tablabel.hpp" 
    2122#include "util/closebutton.hpp" 
     
    112113        // and records finished. 
    113114        while(get_n_pages()) 
    114                 remove_document(*static_cast<DocWindow*>(get_nth_page(0))); 
    115 } 
    116  
    117 Gobby::DocWindow& 
     115                remove_document( 
     116                        static_cast<SessionUserView*>( 
     117                                get_nth_page(0))->get_session_view()); 
     118} 
     119 
     120Gobby::TextSessionView& 
    118121Gobby::Folder::add_document(InfTextSession* session, 
    119122                            const Glib::ustring& title, 
     
    122125                            const std::string& info_storage_key) 
    123126{ 
    124         Gobby::DocWindow* window = Gtk::manage( 
    125                 new DocWindow(session, title, path, hostname, 
    126                               info_storage_key, m_preferences, 
    127                               m_lang_manager)); 
    128         window->show(); 
    129         m_signal_document_added.emit(*window); 
    130  
    131         TabLabel* tablabel = Gtk::manage(new TabLabel(*this, *window)); 
     127        TextSessionView* view = Gtk::manage( 
     128                new TextSessionView(session, title, path, hostname, 
     129                                    info_storage_key, m_preferences, 
     130                                    m_lang_manager)); 
     131        view->show(); 
     132        m_signal_document_added.emit(*view); 
     133 
     134        SessionUserView* userview = Gtk::manage( 
     135                new SessionUserView( 
     136                        *view, 
     137                        m_preferences.appearance.show_userlist, 
     138                        m_preferences.appearance.userlist_width)); 
     139        userview->show(); 
     140 
     141        TabLabel* tablabel = Gtk::manage(new TabLabel(*this, *view)); 
    132142        tablabel->signal_close_request().connect( 
    133143                sigc::bind( 
    134144                        sigc::mem_fun(*this, &Folder::on_tab_close_request), 
    135                         sigc::ref(*window))); 
     145                        sigc::ref(*view))); 
    136146        tablabel->show(); 
    137         append_page(*window, *tablabel); 
    138  
    139         set_tab_reorderable(*window, true); 
     147        append_page(*userview, *tablabel); 
     148 
     149        set_tab_reorderable(*userview, true); 
    140150 
    141151        // Record the session, for debugging purposes: 
    142152        record(session, title); 
    143153 
    144         return *window; 
    145 } 
    146  
    147 void Gobby::Folder::remove_document(DocWindow& window) 
    148 { 
    149         m_signal_document_removed.emit(window); 
     154        return *view; 
     155} 
     156 
     157void Gobby::Folder::remove_document(SessionView& view) 
     158{ 
     159        m_signal_document_removed.emit(view); 
    150160 
    151161        // Finish the record 
    152         InfTextSession* session = window.get_session(); 
     162        InfSession* session = view.get_session(); 
    153163        g_object_set_data(G_OBJECT(session), "GOBBY_SESSION_RECORD", NULL); 
    154164 
    155165        g_object_ref(session); 
    156         inf_session_close(INF_SESSION(session)); 
    157         remove_page(window); 
     166        inf_session_close(session); 
     167        // This relies on the sessionuserview being the direct parent of 
     168        // view - maybe we should make a loop here instead which searches 
     169        // the folder in the widget hierarchy, to be more robust. 
     170        remove_page(*view.get_parent()); 
    158171        g_object_unref(session); 
    159172 
     
    162175} 
    163176 
    164 Gobby::DocWindow* 
    165 Gobby::Folder::lookup_document(InfTextSession* session) 
     177Gobby::SessionView* 
     178Gobby::Folder::lookup_document(InfSession* session) 
    166179{ 
    167180        const PageList& pagelist = pages(); 
     
    169182            iter != pagelist.end(); ++ iter) 
    170183        { 
    171                 DocWindow* window = 
    172                         static_cast<DocWindow*>(iter->get_child()); 
    173  
    174                 if(window->get_session() == session) 
    175                         return window; 
     184                SessionUserView* child = 
     185                        static_cast<SessionUserView*>(iter->get_child()); 
     186 
     187                if(child->get_session_view().get_session() == session) 
     188                        return &child->get_session_view(); 
    176189        } 
    177190 
     
    179192} 
    180193 
    181 Gobby::DocWindow* 
     194Gobby::SessionView* 
    182195Gobby::Folder::get_current_document() 
    183196{ 
    184         return static_cast<DocWindow*>(get_nth_page(get_current_page())); 
    185 } 
    186  
    187 const Gobby::DocWindow* 
     197        SessionUserView* child = static_cast<SessionUserView*>( 
     198                get_nth_page(get_current_page())); 
     199        if(!child) return NULL; 
     200 
     201        return &child->get_session_view(); 
     202} 
     203 
     204const Gobby::SessionView* 
    188205Gobby::Folder::get_current_document() const 
    189206{ 
    190         return static_cast<const DocWindow*>(get_nth_page(get_current_page())); 
    191 } 
    192  
    193 void Gobby::Folder::switch_to_document(DocWindow& document) 
    194 { 
    195         set_current_page(page_num(document)); 
    196 } 
    197  
    198 void Gobby::Folder::on_tab_close_request(DocWindow& window) 
    199 { 
    200         if(m_signal_document_close_request.emit(window)) 
    201                 remove_document(window); 
     207        const SessionUserView* child = static_cast<const SessionUserView*>( 
     208                get_nth_page(get_current_page())); 
     209        if(!child) return NULL; 
     210 
     211        return &child->get_session_view(); 
     212} 
     213 
     214void Gobby::Folder::switch_to_document(SessionView& document) 
     215{ 
     216        // Again, here we rely on document being the direct child of 
     217        // the SessionUserView... 
     218        set_current_page(page_num(*document.get_parent())); 
     219} 
     220 
     221void Gobby::Folder::on_tab_close_request(SessionView& view) 
     222{ 
     223        if(m_signal_document_close_request.emit(view)) 
     224                remove_document(view); 
    202225} 
    203226 
     
    205228{ 
    206229        Gtk::Notebook::on_switch_page(page, page_num); 
    207         DocWindow& window = *static_cast<DocWindow*>(get_nth_page(page_num)); 
    208         m_signal_document_changed.emit(&window); 
     230        SessionUserView& view = 
     231                *static_cast<SessionUserView*>(get_nth_page(page_num)); 
     232 
     233        m_signal_document_changed.emit(&view.get_session_view()); 
    209234} 
    210235 
  • code/core/folder.hpp

    re861d03 r646a4f3  
    2020#define _GOBBY_FOLDER_HPP_ 
    2121 
    22 #include "core/docwindow.hpp" 
     22#include "core/textsessionview.hpp" 
    2323#include "core/preferences.hpp" 
    2424#include "util/defaultaccumulator.hpp" 
     
    3535{ 
    3636public: 
    37         typedef sigc::signal<void, DocWindow&> SignalDocumentAdded; 
    38         typedef sigc::signal<void, DocWindow&> SignalDocumentRemoved; 
    39         typedef sigc::signal<void, DocWindow*> SignalDocumentChanged; 
     37        typedef sigc::signal<void, SessionView&> SignalDocumentAdded; 
     38        typedef sigc::signal<void, SessionView&> SignalDocumentRemoved; 
     39        typedef sigc::signal<void, SessionView*> SignalDocumentChanged; 
    4040 
    41         typedef sigc::signal<bool, DocWindow&>:: 
     41        typedef sigc::signal<bool, SessionView&>:: 
    4242                accumulated<default_accumulator<bool, true> > 
    4343                        SignalDocumentCloseRequest; 
     
    4747        ~Folder(); 
    4848 
    49         DocWindow& add_document(InfTextSession* session, 
    50                                 const Glib::ustring& title, 
    51                                 const Glib::ustring& path, 
    52                                 const Glib::ustring& hostname, 
    53                                 const std::string& info_storage_key); 
    54         void remove_document(DocWindow& document); 
     49        TextSessionView& add_document(InfTextSession* session, 
     50                                      const Glib::ustring& title, 
     51                                      const Glib::ustring& path, 
     52                                      const Glib::ustring& hostname, 
     53                                      const std::string& info_storage_key); 
     54        void remove_document(SessionView& view); 
    5555 
    56         DocWindow* lookup_document(InfTextSession* session); 
    57         DocWindow* get_current_document(); 
    58         const DocWindow* get_current_document() const; 
    59         void switch_to_document(DocWindow& document); 
     56        SessionView* lookup_document(InfSession* session); 
     57        SessionView* get_current_document(); 
     58        const SessionView* get_current_document() const; 
     59        void switch_to_document(SessionView& document); 
    6060 
    61         SignalDocumentAdded signal_document_added() const { 
     61        SignalDocumentAdded signal_document_added() const 
     62        { 
    6263                return m_signal_document_added; 
    6364        } 
    6465 
    65         SignalDocumentRemoved signal_document_removed() const { 
     66        SignalDocumentRemoved signal_document_removed() const 
     67        { 
    6668                return m_signal_document_removed; 
    6769        } 
    6870 
    69         SignalDocumentChanged signal_document_changed() const { 
     71        SignalDocumentChanged signal_document_changed() const 
     72        { 
    7073                return m_signal_document_changed; 
    7174        } 
    7275 
    73         SignalDocumentCloseRequest signal_document_close_request() const { 
     76        SignalDocumentCloseRequest signal_document_close_request() const 
     77        { 
    7478                return m_signal_document_close_request; 
    7579        } 
     
    7983        virtual bool on_key_press_event(GdkEventKey* event); 
    8084 
    81         void on_tab_close_request(DocWindow& window); 
     85        void on_tab_close_request(SessionView& window); 
    8286 
    8387        Preferences& m_preferences; 
  • code/core/sessionview.cpp

    r0e7581e r646a4f3  
    2222 
    2323Gobby::SessionView::SessionView(InfSession* session, 
    24                                 const Glib::ustring& title): 
    25         m_session(session), m_title(title), 
    26         m_info_box(false, 0), m_info_close_button_box(false, 6) 
     24                                const Glib::ustring& title, 
     25                                const Glib::ustring& path, 
     26                                const Glib::ustring& hostname): 
     27        m_session(session), m_title(title), m_path(path), 
     28        m_hostname(hostname), m_info_box(false, 0), 
     29        m_info_close_button_box(false, 6) 
    2730{ 
    2831        g_object_ref(m_session); 
  • code/core/sessionview.hpp

    r0e7581e r646a4f3  
    3434{ 
    3535public: 
    36         SessionView(InfSession* session, const Glib::ustring& title); 
     36        SessionView(InfSession* session, const Glib::ustring& title, 
     37                    const Glib::ustring& path, const Glib::ustring& hostname); 
    3738        virtual ~SessionView(); 
    3839 
    3940        const InfSession* get_session() const { return m_session; } 
    4041        InfSession* get_session() { return m_session; } 
     42 
    4143        const Glib::ustring& get_title() const { return m_title; } 
     44        const Glib::ustring& get_path() const { return m_path; } 
     45        const Glib::ustring& get_hostname() const { return m_hostname; } 
    4246 
    4347        void set_info(const Glib::ustring& info, bool closable); 
     
    4650protected: 
    4751        InfSession* m_session; 
    48         Glib::ustring m_title; 
     52 
     53        const Glib::ustring m_title; 
     54        const Glib::ustring m_path; 
     55        const Glib::ustring m_hostname; 
    4956 
    5057        Gtk::Frame m_info_frame; 
  • code/core/statusbar.cpp

    r23dfbe6 r646a4f3  
    6464                            const Preferences& preferences): 
    6565        Gtk::HBox(false, 2), m_folder(folder), m_preferences(preferences), 
    66         m_current_document(NULL), m_position_context_id(0) 
     66        m_current_view(NULL), m_position_context_id(0) 
    6767{ 
    6868        pack_end(m_bar_position, Gtk::PACK_SHRINK); 
     
    195195} 
    196196 
    197 void Gobby::StatusBar::on_document_removed(DocWindow& document) 
    198 { 
    199         if(m_current_document == &document) 
    200         { 
    201                 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    202                         m_current_document->get_text_buffer()); 
     197void Gobby::StatusBar::on_document_removed(SessionView& view) 
     198{ 
     199        if(m_current_view == &view) 
     200        { 
     201                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
     202                        m_current_view->get_text_buffer()); 
    203203 
    204204                g_signal_handler_disconnect(buffer, m_mark_set_handler); 
    205205                g_signal_handler_disconnect(buffer, m_changed_handler); 
    206206 
    207                 m_current_document = NULL; 
    208         } 
    209 } 
    210  
    211 void Gobby::StatusBar::on_document_changed(DocWindow* document) 
    212 { 
    213         if(m_current_document) 
    214         { 
    215                 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    216                         m_current_document->get_text_buffer()); 
     207                m_current_view = NULL; 
     208        } 
     209} 
     210 
     211void Gobby::StatusBar::on_document_changed(SessionView* view) 
     212{ 
     213        if(m_current_view) 
     214        { 
     215                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
     216                        m_current_view->get_text_buffer()); 
    217217 
    218218                g_signal_handler_disconnect(buffer, m_mark_set_handler); 
     
    220220        } 
    221221 
    222         m_current_document = document; 
    223  
    224         if(document) 
    225         { 
    226                 GtkTextBuffer* buffer = 
    227                         GTK_TEXT_BUFFER(document->get_text_buffer()); 
     222        m_current_view = dynamic_cast<TextSessionView*>(view); 
     223 
     224        if(m_current_view) 
     225        { 
     226                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
     227                        m_current_view->get_text_buffer()); 
    228228 
    229229                m_mark_set_handler = g_signal_connect_after( 
     
    249249{ 
    250250        GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    251                 m_current_document->get_text_buffer()); 
     251                m_current_view->get_text_buffer()); 
    252252 
    253253        if(mark == gtk_text_buffer_get_insert(buffer)) 
     
    265265                m_bar_position.remove_message(m_position_context_id); 
    266266 
    267         if(m_current_document != NULL) 
    268         { 
    269                 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    270                         m_current_document->get_text_buffer()); 
     267        if(m_current_view != NULL) 
     268        { 
     269                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
     270                        m_current_view->get_text_buffer()); 
    271271                GtkTextIter iter; 
    272272 
     273                // TODO: Use TextSessionView::get_cursor_position()? 
    273274                gtk_text_buffer_get_iter_at_mark( 
    274275                        buffer, &iter, gtk_text_buffer_get_insert(buffer)); 
  • code/core/statusbar.hpp

    r23dfbe6 r646a4f3  
    8787                                const MessageHandle& message); 
    8888 
    89         void on_document_removed(DocWindow& document); 
    90         void on_document_changed(DocWindow* document); 
     89        void on_document_removed(SessionView& view); 
     90        void on_document_changed(SessionView* view); 
    9191        void on_view_changed(); 
    9292         
     
    101101 
    102102        Gtk::Statusbar m_bar_position; 
    103         DocWindow* m_current_document; 
     103        TextSessionView* m_current_view; 
    104104        gulong m_mark_set_handler; 
    105105        gulong m_changed_handler; 
  • code/core/tablabel.cpp

    r1fe08b1 r646a4f3  
    6464 
    6565 
    66 Gobby::TabLabel::TabLabel(Folder& folder, DocWindow& document): 
     66Gobby::TabLabel::TabLabel(Folder& folder, TextSessionView& view): 
    6767        Gtk::HBox(false, 6), 
    68         m_folder(folder), m_document(document), 
     68        m_folder(folder), m_view(view), 
    6969        m_dot_char(0), m_changed(false) 
    7070{ 
     
    8080 
    8181        m_notify_editable_handle = g_signal_connect( 
    82                 G_OBJECT(document.get_text_view()), "notify::editable", 
     82                G_OBJECT(view.get_text_view()), "notify::editable", 
    8383                G_CALLBACK(on_notify_editable_static), this); 
    8484        m_notify_status_handle = g_signal_connect( 
    85                 G_OBJECT(document.get_session()), "notify::status", 
     85                G_OBJECT(view.get_session()), "notify::status", 
    8686                G_CALLBACK(on_notify_status_static), this); 
    8787        m_notify_subscription_group_handle = g_signal_connect( 
    88                 G_OBJECT(document.get_session()), 
     88                G_OBJECT(view.get_session()), 
    8989                "notify::subscription-group", 
    9090                G_CALLBACK(on_notify_subscription_group_static), this); 
    9191        m_modified_changed_handle = g_signal_connect_after( 
    92                 G_OBJECT(document.get_text_buffer()), "modified-changed", 
     92                G_OBJECT(view.get_text_buffer()), "modified-changed", 
    9393                G_CALLBACK(on_modified_changed_static), this); 
    9494 
     
    9696                INF_TEXT_BUFFER( 
    9797                        inf_session_get_buffer( 
    98                                 INF_SESSION(document.get_session()))); 
     98                                INF_SESSION(view.get_session()))); 
    9999        m_insert_text_handle = g_signal_connect_after( 
    100100                G_OBJECT(buffer), "insert-text", 
     
    115115Gobby::TabLabel::~TabLabel() 
    116116{ 
    117         g_signal_handler_disconnect(m_document.get_text_view(), 
     117        g_signal_handler_disconnect(m_view.get_text_view(), 
    118118                                    m_notify_editable_handle); 
    119         g_signal_handler_disconnect(m_document.get_session(), 
     119        g_signal_handler_disconnect(m_view.get_session(), 
    120120                                    m_notify_status_handle); 
    121         g_signal_handler_disconnect(m_document.get_session(), 
     121        g_signal_handler_disconnect(m_view.get_session(), 
    122122                                    m_notify_subscription_group_handle); 
    123         g_signal_handler_disconnect(m_document.get_text_buffer(), 
     123        g_signal_handler_disconnect(m_view.get_text_buffer(), 
    124124                                    m_modified_changed_handle); 
    125125        InfTextBuffer* buffer =  
    126126                INF_TEXT_BUFFER( 
    127127                        inf_session_get_buffer( 
    128                                 INF_SESSION(m_document.get_session()))); 
     128                                INF_SESSION(m_view.get_session()))); 
    129129        g_signal_handler_disconnect(buffer, m_erase_text_handle); 
    130130        g_signal_handler_disconnect(buffer, m_insert_text_handle); 
     
    183183void Gobby::TabLabel::on_changed(InfTextUser* author) 
    184184{ 
    185         if(m_folder.get_current_document() != &m_document) 
     185        if(m_folder.get_current_document() != &m_view) 
    186186        { 
    187187                // TODO: remove dot if all the user's 
    188188                // new contributions where undone 
    189                 if (std::find(m_changed_by.begin(), m_changed_by.end(), author) 
    190                     == m_changed_by.end()) 
     189                if(std::find(m_changed_by.begin(), m_changed_by.end(), author) 
     190                   == m_changed_by.end()) 
    191191                { 
    192192                        m_changed_by.push_back(UserWatcher(this, author)); 
     
    197197                { 
    198198                        InfSession* session = 
    199                                 INF_SESSION(m_document.get_session()); 
     199                                INF_SESSION(m_view.get_session()); 
    200200                        if(inf_session_get_status(session) == 
    201201                           INF_SESSION_RUNNING) 
     
    208208} 
    209209 
    210 void Gobby::TabLabel::on_folder_document_changed(DocWindow* document) 
    211 { 
    212         if(document == &m_document) 
     210void Gobby::TabLabel::on_folder_document_changed(SessionView* view) 
     211{ 
     212        if(view == &m_view) 
    213213        { 
    214214                m_changed_by.clear(); 
     
    221221void Gobby::TabLabel::update_icon() 
    222222{ 
    223         InfSession* session = INF_SESSION(m_document.get_session()); 
    224         GtkTextView* view = GTK_TEXT_VIEW(m_document.get_text_view()); 
     223        InfSession* session = INF_SESSION(m_view.get_session()); 
     224        GtkTextView* view = GTK_TEXT_VIEW(m_view.get_text_view()); 
    225225 
    226226        if(inf_session_get_subscription_group(session) == NULL) 
     
    257257void Gobby::TabLabel::update_color() 
    258258{ 
    259         InfSession* session = INF_SESSION(m_document.get_session()); 
     259        InfSession* session = INF_SESSION(m_view.get_session()); 
    260260 
    261261        if(m_changed) 
     
    290290void Gobby::TabLabel::update_modified() 
    291291{ 
    292         InfSession* session = INF_SESSION(m_document.get_session()); 
     292        InfSession* session = INF_SESSION(m_view.get_session()); 
    293293        bool modified = gtk_text_buffer_get_modified( 
    294                 GTK_TEXT_BUFFER(m_document.get_text_buffer())); 
     294                GTK_TEXT_BUFFER(m_view.get_text_buffer())); 
    295295 
    296296        if(inf_session_get_status(session) == INF_SESSION_SYNCHRONIZING) 
     
    298298 
    299299        if(modified) 
    300                 m_title.set_text("*" + m_document.get_title()); 
     300                m_title.set_text("*" + m_view.get_title()); 
    301301        else 
    302                 m_title.set_text(m_document.get_title()); 
     302                m_title.set_text(m_view.get_title()); 
    303303} 
    304304 
  • code/core/tablabel.hpp

    r6e7f073 r646a4f3  
    2020#define _GOBBY_TABLABEL_HPP_ 
    2121 
    22 #include "core/docwindow.hpp" 
     22#include "core/textsessionview.hpp" 
    2323#include "util/closebutton.hpp" 
    2424 
     
    3939        typedef Glib::SignalProxy0<void> SignalCloseRequest; 
    4040 
    41         TabLabel(Folder& folder, DocWindow& document); 
     41        TabLabel(Folder& folder, TextSessionView& view); 
    4242        ~TabLabel(); 
    4343 
     
    103103        void on_changed(InfTextUser* author); 
    104104 
    105         void on_folder_document_changed(DocWindow* document); 
     105        void on_folder_document_changed(SessionView* view); 
    106106 
    107107        void update_icon(); 
     
    111111 
    112112        Folder& m_folder; 
    113         DocWindow& m_document; 
     113        TextSessionView& m_view; 
    114114 
    115115        Gtk::Image m_icon; 
  • code/core/textsessionview.cpp

    r2edcdf4 r646a4f3  
    1717 */ 
    1818 
    19 #include "features.hpp" 
    20  
    21 #include "core/docwindow.hpp" 
    22 #include "core/preferences.hpp" 
    23 #include "core/closableframe.hpp" 
    24 #include "core/iconmanager.hpp" 
    25  
     19#include "core/textsessionview.hpp" 
    2620#include "util/i18n.hpp" 
    2721 
    2822#include <gtkmm/scrolledwindow.h> 
    29 #include <glibmm/pattern.h> 
     23#include <gtkmm/textiter.h> 
    3024 
    3125#include <libinftextgtk/inf-text-gtk-buffer.h> 
    32  
    33 #include <gtksourceview/gtksourcebuffer.h> 
    34  
    35 // TODO: Consider using a single user list for all DocWindows, reparenting 
    36 // into the current DocWindow's frame. Keep dummy widgets in other docwindows, 
    37 // so text does not resize. 
    3826 
    3927namespace 
     
    9785        } 
    9886 
    99         bool tags_priority_idle_func(Gobby::DocWindow& window) 
     87        bool tags_priority_idle_func(Gobby::TextSessionView& view) 
    10088        { 
    10189                InfTextGtkBuffer* buffer = INF_TEXT_GTK_BUFFER( 
    10290                        inf_session_get_buffer( 
    103                                 INF_SESSION(window.get_session()))); 
     91                                INF_SESSION(view.get_session()))); 
    10492 
    10593                inf_text_gtk_buffer_ensure_author_tags_priority(buffer); 
     
    10795                // I don't know why it does not redraw automatically, perhaps 
    10896                // this is a bug. 
    109                 gtk_widget_queue_draw(GTK_WIDGET(window.get_text_view())); 
     97                gtk_widget_queue_draw(GTK_WIDGET(view.get_text_view())); 
    11098                return false; 
    11199        } 
     
    120108                        sigc::bind( 
    121109                                sigc::ptr_fun(tags_priority_idle_func), 
    122                                 sigc::ref(*static_cast<Gobby::DocWindow*>( 
    123                                         user_data)))); 
    124         } 
    125 } 
    126  
    127 Gobby::DocWindow::DocWindow(InfTextSession* session, 
    128                             const Glib::ustring& title, 
    129                             const Glib::ustring& path, 
    130                             const Glib::ustring& hostname, 
    131                             const std::string& info_storage_key, 
    132                             Preferences& preferences, 
    133                             GtkSourceLanguageManager* manager): 
    134         m_session(session), m_title(title), m_path(path), 
    135         m_hostname(hostname), m_info_storage_key(info_storage_key), 
    136         m_preferences(preferences), 
    137         m_view(GTK_SOURCE_VIEW(gtk_source_view_new())), 
    138         m_userlist(inf_session_get_user_table(INF_SESSION(session))), 
    139         m_info_box(false, 0), m_info_close_button_box(false, 6) 
    140 { 
    141         g_object_ref(m_session); 
    142  
     110                                sigc::ref( 
     111                                        *static_cast<Gobby::TextSessionView*>( 
     112                                                user_data)))); 
     113        } 
     114} 
     115 
     116Gobby::TextSessionView::TextSessionView(InfTextSession* session, 
     117                                        const Glib::ustring& title, 
     118                                        const Glib::ustring& path, 
     119                                        const Glib::ustring& hostname, 
     120                                        const std::string& info_storage_key, 
     121                                        Preferences& preferences, 
     122                                        GtkSourceLanguageManager* manager): 
     123        SessionView(INF_SESSION(session), title, path, hostname), 
     124        m_info_storage_key(info_storage_key), m_preferences(preferences), 
     125        m_view(GTK_SOURCE_VIEW(gtk_source_view_new())) 
     126{ 
    143127        InfBuffer* buffer = inf_session_get_buffer(INF_SESSION(session)); 
    144128        m_buffer = GTK_SOURCE_BUFFER(inf_text_gtk_buffer_get_text_buffer( 
     
    162146                                 GTK_TEXT_BUFFER(m_buffer)); 
    163147        gtk_text_view_set_editable(GTK_TEXT_VIEW(m_view), FALSE); 
    164         set_language(get_language_for_title(manager, m_title.c_str())); 
     148        set_language(get_language_for_title(manager, title.c_str())); 
    165149 
    166150        m_preferences.user.hue.signal_changed().connect( 
    167                 sigc::mem_fun(*this, &DocWindow::on_user_color_changed)); 
     151                sigc::mem_fun( 
     152                        *this, &TextSessionView::on_user_color_changed)); 
    168153        m_preferences.editor.tab_width.signal_changed().connect( 
    169                 sigc::mem_fun(*this, &DocWindow::on_tab_width_changed)); 
     154                sigc::mem_fun( 
     155                        *this, &TextSessionView::on_tab_width_changed)); 
    170156        m_preferences.editor.tab_spaces.signal_changed().connect( 
    171                 sigc::mem_fun(*this, &DocWindow::on_tab_spaces_changed)); 
     157                sigc::mem_fun( 
     158                        *this, &TextSessionView::on_tab_spaces_changed)); 
    172159        m_preferences.editor.indentation_auto.signal_changed().connect( 
    173                 sigc::mem_fun(*this, &DocWindow::on_auto_indent_changed)); 
     160                sigc::mem_fun( 
     161                        *this, &TextSessionView::on_auto_indent_changed)); 
    174162        m_preferences.editor.homeend_smart.signal_changed().connect( 
    175                 sigc::mem_fun(*this, &DocWindow::on_homeend_smart_changed)); 
     163                sigc::mem_fun( 
     164                        *this, &TextSessionView::on_homeend_smart_changed)); 
    176165 
    177166        m_preferences.view.wrap_mode.signal_changed().connect( 
    178                 sigc::mem_fun(*this, &DocWindow::on_wrap_mode_changed)); 
     167                sigc::mem_fun( 
     168                        *this, &TextSessionView::on_wrap_mode_changed)); 
    179169        m_preferences.view.linenum_display.signal_changed().connect( 
    180                 sigc::mem_fun(*this, &DocWindow::on_linenum_display_changed)); 
     170                sigc::mem_fun( 
     171                        *this, &TextSessionView::on_linenum_display_changed)); 
    181172        m_preferences.view.curline_highlight.signal_changed().connect( 
    182                 sigc::mem_fun(*this, 
    183                               &DocWindow::on_curline_highlight_changed)); 
     173                sigc::mem_fun( 
     174                        *this, 
     175                        &TextSessionView::on_curline_highlight_changed)); 
    184176        m_preferences.view.margin_display.signal_changed().connect( 
    185                 sigc::mem_fun(*this, &DocWindow::on_margin_display_changed)); 
     177                sigc::mem_fun( 
     178                        *this, &TextSessionView::on_margin_display_changed)); 
    186179        m_preferences.view.margin_pos.signal_changed().connect( 
    187                 sigc::mem_fun(*this, &DocWindow::on_margin_pos_changed)); 
     180                sigc::mem_fun( 
     181                        *this, &TextSessionView::on_margin_pos_changed)); 
    188182        m_preferences.view.bracket_highlight.signal_changed().connect( 
    189                 sigc::mem_fun(*this, 
    190                               &DocWindow::on_bracket_highlight_changed)); 
     183                sigc::mem_fun( 
     184                        *this, 
     185                        &TextSessionView::on_bracket_highlight_changed)); 
    191186        m_preferences.view.whitespace_display.signal_changed().connect( 
    192                 sigc::mem_fun(*this, 
    193                               &DocWindow::on_whitespace_display_changed)); 
     187                sigc::mem_fun( 
     188                        *this, 
     189                        &TextSessionView::on_whitespace_display_changed)); 
    194190        m_preferences.appearance.font.signal_changed().connect( 
    195                 sigc::mem_fun(*this, &DocWindow::on_font_changed)); 
     191                sigc::mem_fun(*this, &TextSessionView::on_font_changed)); 
    196192 
    197193        gtk_source_view_set_tab_width(m_view, m_preferences.editor.tab_width); 
     
    224220                const_cast<PangoFontDescription*>(desc.gobj())); 
    225221 
    226         m_info_label.set_selectable(true); 
    227         m_info_label.set_line_wrap(true); 
    228         m_info_label.show(); 
    229  
    230         m_info_close_button.signal_clicked().connect( 
    231                 sigc::mem_fun(m_info_frame, &Gtk::Frame::hide)); 
    232         m_info_close_button.show(); 
    233  
    234         m_info_close_button_box.pack_end(m_info_close_button, Gtk::PACK_SHRINK); 
    235         // Don't show info close button box by default 
    236  
    237         m_info_box.pack_start(m_info_close_button_box, Gtk::PACK_SHRINK); 
    238         m_info_box.pack_start(m_info_label, Gtk::PACK_SHRINK); 
    239         m_info_box.set_border_width(6); 
    240         m_info_box.show(); 
    241  
    242         m_info_frame.set_shadow_type(Gtk::SHADOW_IN); 
    243         m_info_frame.add(m_info_box); 
    244         // Don't show infoframe by default 
    245  
    246222        gtk_widget_show(GTK_WIDGET(m_view)); 
    247223        Gtk::ScrolledWindow* scroll = Gtk::manage(new Gtk::ScrolledWindow); 
     
    251227        scroll->show(); 
    252228 
    253         Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox); 
    254         vbox->pack_start(m_info_frame, Gtk::PACK_SHRINK); 
    255         vbox->pack_start(*scroll, Gtk::PACK_EXPAND_WIDGET); 
    256         vbox->show(); 
    257  
    258         m_userlist.show(); 
    259         Gtk::Frame* frame = Gtk::manage(new ClosableFrame( 
    260                 _("User List"), IconManager::STOCK_USERLIST, 
    261                 m_preferences.appearance.show_userlist)); 
    262         frame->set_shadow_type(Gtk::SHADOW_IN); 
    263         frame->add(m_userlist); 
    264         // frame manages visibility itself 
    265  
    266         pack1(*vbox, true, false); 
    267         pack2(*frame, false, false); 
    268 } 
    269  
    270 Gobby::DocWindow::~DocWindow() 
    271 { 
    272         g_object_unref(m_session); 
    273         m_session = NULL; 
    274 } 
    275  
    276 void Gobby::DocWindow::get_cursor_position(unsigned int& row, 
    277                                            unsigned int& col) const 
     229        pack_start(*scroll, Gtk::PACK_EXPAND_WIDGET); 
     230} 
     231 
     232void Gobby::TextSessionView::get_cursor_position(unsigned int& row, 
     233                                                 unsigned int& col) const 
    278234{ 
    279235        GtkTextMark* insert_mark = 
     
    308264} 
    309265 
    310 void Gobby::DocWindow::set_selection(const GtkTextIter* begin, 
    311                                      const GtkTextIter* end) 
     266void Gobby::TextSessionView::set_selection(const GtkTextIter* begin, 
     267                                           const GtkTextIter* end) 
    312268{ 
    313269        gtk_text_buffer_select_range( 
     
    317273} 
    318274 
    319 Glib::ustring Gobby::DocWindow::get_selected_text() const 
     275Glib::ustring Gobby::TextSessionView::get_selected_text() const 
    320276{ 
    321277        GtkTextIter start, end; 
     
    328284} 
    329285 
    330 void Gobby::DocWindow::scroll_to_cursor_position(double within_margin) 
     286void Gobby::TextSessionView::scroll_to_cursor_position(double within_margin) 
    331287{ 
    332288        gtk_text_view_scroll_to_mark( 
     
    337293} 
    338294 
    339 void Gobby::DocWindow::set_info(const Glib::ustring& info, bool closable) 
    340 { 
    341         m_info_label.set_text(info); 
    342  
    343         if(closable) m_info_close_button_box.show(); 
    344         else m_info_close_button_box.hide(); 
    345  
    346         m_info_frame.show(); 
    347 } 
    348  
    349 void Gobby::DocWindow::unset_info() 
    350 { 
    351         m_info_frame.hide(); 
    352 } 
    353  
    354 InfTextUser* Gobby::DocWindow::get_active_user() const 
     295InfTextUser* Gobby::TextSessionView::get_active_user() const 
    355296{ 
    356297        InfTextGtkBuffer* buffer = INF_TEXT_GTK_BUFFER( 
     
    359300} 
    360301 
    361 void Gobby::DocWindow::set_active_user(InfTextUser* user) 
     302void Gobby::TextSessionView::set_active_user(InfTextUser* user) 
    362303{ 
    363304        g_assert( 
     
    384325} 
    385326 
    386 GtkSourceLanguage* Gobby::DocWindow::get_language() const 
     327GtkSourceLanguage* Gobby::TextSessionView::get_language() const 
    387328{ 
    388329        return gtk_source_buffer_get_language(m_buffer); 
    389330} 
    390331 
    391 void Gobby::DocWindow::set_language(GtkSourceLanguage* language) 
     332void Gobby::TextSessionView::set_language(GtkSourceLanguage* language) 
    392333{ 
    393334        gtk_source_buffer_set_language(m_buffer, language); 
     
    395336} 
    396337 
    397 void Gobby::DocWindow::on_size_allocate(Gtk::Allocation& allocation) 
    398 { 
    399         Gtk::HPaned::on_size_allocate(allocation); 
    400  
    401         // Setup initial paned position. We can't do this simply every time 
    402         // on_size_allocate() is called since this would lead to an endless 
    403         // loop somehow when the userlist width is changed forcefully  
    404         // (for example by a set_info() requiring much width). 
    405         if(!m_doc_userlist_width_changed_connection.connected()) 
    406         { 
    407                 Glib::SignalProxyProperty proxy = 
    408                         property_position().signal_changed(); 
    409  
    410                 m_doc_userlist_width_changed_connection = 
    411                         proxy.connect(sigc::mem_fun( 
    412                                 *this, 
    413                                 &DocWindow::on_doc_userlist_width_changed)); 
    414  
    415                 Preferences::Option<unsigned int>& option =  
    416                         m_preferences.appearance.userlist_width; 
    417  
    418                 m_pref_userlist_width_changed_connection = 
    419                         option.signal_changed().connect(sigc::mem_fun( 
    420                                 *this, 
    421                                 &DocWindow::on_pref_userlist_width_changed)); 
    422  
    423                 unsigned int desired_position = 
    424                         get_width() - m_preferences.appearance.userlist_width; 
    425                 desired_position = std::min<unsigned int>( 
    426                         desired_position, property_max_position()); 
    427  
    428                 if(get_position() != desired_position) 
    429                         set_position(desired_position); 
    430         } 
    431 } 
    432  
    433 void Gobby::DocWindow::on_user_color_changed() 
     338void Gobby::TextSessionView::on_user_color_changed() 
    434339{ 
    435340        InfTextUser* user = get_active_user(); 
     
    437342        if(user) 
    438343        { 
    439                 inf_text_session_set_user_color(m_session, user, 
     344                inf_text_session_set_user_color(get_session(), user, 
    440345                                                m_preferences.user.hue); 
    441346        } 
    442347} 
    443348 
    444 void Gobby::DocWindow::on_tab_width_changed() 
     349void Gobby::TextSessionView::on_tab_width_changed() 
    445350{ 
    446351        gtk_source_view_set_tab_width(m_view, m_preferences.editor.tab_width); 
    447352} 
    448353 
    449 void Gobby::DocWindow::on_tab_spaces_changed() 
     354void Gobby::TextSessionView::on_tab_spaces_changed() 
    450355{ 
    451356        gtk_source_view_set_insert_spaces_instead_of_tabs( 
     
    453358} 
    454359 
    455 void Gobby::DocWindow::on_auto_indent_changed() 
     360void Gobby::TextSessionView::on_auto_indent_changed() 
    456361{ 
    457362        gtk_source_view_set_auto_indent( 
     
    459364} 
    460365 
    461 void Gobby::DocWindow::on_homeend_smart_changed() 
     366void Gobby::TextSessionView::on_homeend_smart_changed() 
    462367{ 
    463368        gtk_source_view_set_smart_home_end( 
     
    467372} 
    468373 
    469 void Gobby::DocWindow::on_wrap_mode_changed() 
     374void Gobby::TextSessionView::on_wrap_mode_changed() 
    470375{ 
    471376        gtk_text_view_set_wrap_mode( 
     
    474379} 
    475380 
    476 void Gobby::DocWindow::on_linenum_display_changed() 
     381void Gobby::TextSessionView::on_linenum_display_changed() 
    477382{ 
    478383        gtk_source_view_set_show_line_numbers( 
     
    480385} 
    481386 
    482 void Gobby::DocWindow::on_curline_highlight_changed() 
     387void Gobby::TextSessionView::on_curline_highlight_changed() 
    483388{ 
    484389        gtk_source_view_set_highlight_current_line( 
     
    486391} 
    487392 
    488 void Gobby::DocWindow::on_margin_display_changed() 
     393void Gobby::TextSessionView::on_margin_display_changed() 
    489394{ 
    490395        gtk_source_view_set_show_right_margin( 
     
    492397} 
    493398 
    494 void Gobby::DocWindow::on_margin_pos_changed() 
     399void Gobby::TextSessionView::on_margin_pos_changed() 
    495400{ 
    496401        gtk_source_view_set_right_margin_position( 
     
    498403} 
    499404 
    500 void Gobby::DocWindow::on_bracket_highlight_changed() 
     405void Gobby::TextSessionView::on_bracket_highlight_changed() 
    501406{ 
    502407        gtk_source_buffer_set_highlight_matching_brackets( 
     
    504409} 
    505410 
    506 void Gobby::DocWindow::on_whitespace_display_changed() 
     411void Gobby::TextSessionView::on_whitespace_display_changed() 
    507412{ 
    508413        gtk_source_view_set_draw_spaces( 
     
    510415} 
    511416 
    512 void Gobby::DocWindow::on_font_changed() 
     417void Gobby::TextSessionView::on_font_changed() 
    513418{ 
    514419        const Pango::FontDescription& desc = m_preferences.appearance.font; 
     
    518423} 
    519424 
    520 void Gobby::DocWindow::on_doc_userlist_width_changed() 
    521 { 
    522         unsigned int userlist_width = get_width() - get_position(); 
    523  
    524         if(m_preferences.appearance.userlist_width != userlist_width) 
    525         { 
    526                 m_pref_userlist_width_changed_connection.block(); 
    527                 m_preferences.appearance.userlist_width = userlist_width; 
    528                 m_pref_userlist_width_changed_connection.unblock(); 
    529         } 
    530 } 
    531  
    532 void Gobby::DocWindow::on_pref_userlist_width_changed() 
    533 { 
    534         unsigned int position = 
    535                 get_width() - m_preferences.appearance.userlist_width; 
    536  
    537         if(get_position() != position) 
    538         { 
    539                 m_doc_userlist_width_changed_connection.block(); 
    540                 set_position(position); 
    541                 m_doc_userlist_width_changed_connection.unblock(); 
    542         } 
    543 } 
    544  
    545 bool 
    546 Gobby::DocWindow::on_query_tooltip(int x, int y, bool keyboard_mode, 
    547                                    const Glib::RefPtr<Gtk::Tooltip>& tooltip) 
     425bool Gobby::TextSessionView:: 
     426        on_query_tooltip(int x, int y, bool keyboard_mode, 
     427                         const Glib::RefPtr<Gtk::Tooltip>& tooltip) 
    548428{ 
    549429        if(keyboard_mode) return false; 
  • code/core/textsessionview.hpp

    r89522f2 r646a4f3  
    1717 */ 
    1818 
    19 #ifndef _GOBBY_DOCWINDOW_HPP_ 
    20 #define _GOBBY_DOCWINDOW_HPP_ 
     19#ifndef _GOBBY_TEXTSESSIONVIEW_HPP_ 
     20#define _GOBBY_TEXTSESSIONVIEW_HPP_ 
    2121 
    22 #include "core/userlist.hpp" 
     22#include "core/sessionview.hpp" 
    2323#include "core/preferences.hpp" 
    24 #include "util/closebutton.hpp" 
    25 #include "features.hpp" 
    2624 
    27 #include <gtkmm/box.h> 
    28 #include <gtkmm/frame.h> 
    29 #include <gtkmm/label.h> 
    30 #include <gtkmm/paned.h> 
    31 #include <gtkmm/textiter.h> 
     25#include <gtkmm/tooltip.h> 
    3226 
    3327#include <gtksourceview/gtksourceview.h> 
    3428#include <gtksourceview/gtksourcelanguagemanager.h> 
     29#include <gtksourceview/gtksourcelanguage.h> 
    3530 
    3631#include <libinftext/inf-text-session.h> 
     
    4035{ 
    4136 
    42 class DocWindow: public Gtk::HPaned 
     37class TextSessionView: public SessionView 
    4338{ 
    4439public: 
     
    4641        typedef sigc::signal<void, InfTextUser*> SignalActiveUserChanged; 
    4742 
    48         DocWindow(InfTextSession* session, const Glib::ustring& title, 
    49                   const Glib::ustring& path, const Glib::ustring& hostname, 
    50                   const std::string& info_storage_key, 
    51                   Preferences& preferences, 
    52                   GtkSourceLanguageManager* manager); 
    53         virtual ~DocWindow(); 
     43        TextSessionView(InfTextSession* session, const Glib::ustring& title, 
     44                        const Glib::ustring& path, 
     45                        const Glib::ustring& hostname, 
     46                        const std::string& info_storage_key, 
     47                        Preferences& preferences, 
     48                        GtkSourceLanguageManager* manager); 
    5449 
    55         const InfTextSession* get_session() const { return m_session; } 
    56         InfTextSession* get_session() { return m_session; } 
    57         const Glib::ustring& get_title() const { return m_title; } 
    58         const Glib::ustring& get_path() const { return m_path; } 
    59         const Glib::ustring& get_hostname() const { return m_hostname; } 
     50/*      const InfTextSession* get_session() const 
     51        { 
     52                return INF_TEXT_SESSION(m_session); 
     53        }*/ 
     54 
     55        // Override base class covariantly 
     56        InfTextSession* get_session() { return INF_TEXT_SESSION(m_session); } 
     57 
    6058        const std::string& get_info_storage_key() const 
    6159        { 
     
    7876        GtkSourceBuffer* get_text_buffer() { return m_buffer; } 
    7977 
    80         void set_info(const Glib::ustring& info, bool closable); 
    81         void unset_info(); 
    82  
    8378        SignalLanguageChanged signal_language_changed() const 
    8479        { 
     
    9287 
    9388protected: 
    94         virtual void on_size_allocate(Gtk::Allocation& allocation); 
    95  
    9689        void on_user_color_changed(); 
    9790 
     
    111104        void on_font_changed(); 
    112105 
    113         void on_doc_userlist_width_changed(); 
    114         void on_pref_userlist_width_changed(); 
    115  
    116106        bool on_query_tooltip(int x, int y, bool keyboard_mode, 
    117107                              const Glib::RefPtr<Gtk::Tooltip>& tooltip); 
     
    122112                                                gpointer user_data) 
    123113        { 
    124                 return static_cast<DocWindow*>(user_data)->on_query_tooltip( 
    125                         x, y, keyboard_mode, Glib::wrap(tooltip, true)); 
     114                return static_cast<TextSessionView*>(user_data)-> 
     115                        on_query_tooltip(x, y, keyboard_mode, 
     116                                         Glib::wrap(tooltip, true)); 
    126117        } 
    127118 
    128         InfTextSession* m_session; 
    129         Glib::ustring m_title; 
    130         Glib::ustring m_path; 
    131         Glib::ustring m_hostname; 
    132119        std::string m_info_storage_key; 
    133120        Preferences& m_preferences; 
     
    135122        GtkSourceView* m_view; 
    136123        GtkSourceBuffer* m_buffer; 
    137         UserList m_userlist; 
    138  
    139         Gtk::Frame m_info_frame; 
    140         Gtk::VBox m_info_box; 
    141         Gtk::HBox m_info_close_button_box; 
    142         CloseButton m_info_close_button; 
    143         Gtk::Label m_info_label; 
    144124 
    145125        SignalLanguageChanged m_signal_language_changed; 
    146126        SignalActiveUserChanged m_signal_active_user_changed; 
    147  
    148         sigc::connection m_doc_userlist_width_changed_connection; 
    149         sigc::connection m_pref_userlist_width_changed_connection; 
    150127}; 
    151128 
    152129} 
    153130 
    154 #endif // _GOBBY_DOCWINDOW_HPP_ 
     131#endif // _GOBBY_TEXTSESSIONVIEW_HPP_ 
  • code/core/titlebar.cpp

    r6b79c69 r646a4f3  
    2020 
    2121Gobby::TitleBar::TitleBar(Gtk::Window& window, Folder& folder): 
    22         m_window(window), m_folder(folder), m_current_document(NULL) 
     22        m_window(window), m_folder(folder), m_current_view(NULL) 
    2323{ 
    2424        folder.signal_document_removed().connect( 
     
    3030} 
    3131 
    32 void Gobby::TitleBar::on_document_removed(DocWindow& document) 
     32void Gobby::TitleBar::on_document_removed(SessionView& view) 
    3333{ 
    34         if(m_current_document == &document) 
     34        // TODO: Isn't this called by Folder already? 
     35        if(m_current_view == &view) 
    3536                on_document_changed(NULL); 
    3637} 
    3738 
    38 void Gobby::TitleBar::on_document_changed(DocWindow* document) 
     39void Gobby::TitleBar::on_document_changed(SessionView* view) 
    3940{ 
    40         if(m_current_document != NULL) 
     41        if(m_current_view != NULL) 
    4142        { 
    42                 InfSession* session = INF_SESSION( 
    43                         m_current_document->get_session()); 
    44                 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    45                         m_current_document->get_text_buffer()); 
     43                InfSession* session = m_current_view->get_session(); 
     44                InfBuffer* buffer = inf_session_get_buffer(session); 
    4645 
    4746                g_signal_handler_disconnect(G_OBJECT(session), 
     
    5150        } 
    5251 
    53         m_current_document = document; 
     52        m_current_view = view; 
    5453 
    55         if(document != NULL) 
     54        if(view != NULL) 
    5655        { 
    57                 InfSession* session = INF_SESSION(document->get_session()); 
    58                 GtkTextBuffer* buffer = 
    59                         GTK_TEXT_BUFFER(document->get_text_buffer()); 
     56                InfSession* session = view->get_session(); 
     57                InfBuffer* buffer = inf_session_get_buffer(session); 
    6058 
    6159                m_notify_status_handler = g_signal_connect( 
     
    6361                        G_CALLBACK(on_notify_status_static), this); 
    6462                m_modified_changed_handler = g_signal_connect( 
    65                         G_OBJECT(buffer), "modified-changed", 
    66                         G_CALLBACK(on_modified_changed_static), this); 
     63                        G_OBJECT(buffer), "notify::modified", 
     64                        G_CALLBACK(on_notify_modified_static), this); 
    6765        } 
    6866 
     
    7573} 
    7674 
    77 void Gobby::TitleBar::on_modified_changed() 
     75void Gobby::TitleBar::on_notify_modified() 
    7876{ 
    7977        update_title(); 
     
    8482        // TODO: Show path, as gedit does. This requires change notification 
    8583        // for document info storage. 
    86         if(m_current_document != NULL) 
     84        if(m_current_view != NULL) 
    8785        { 
    88                 InfSession* session = INF_SESSION( 
    89                         m_current_document->get_session()); 
    90                 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    91                         m_current_document->get_text_buffer()); 
     86                InfSession* session = m_current_view->get_session(); 
     87                InfBuffer* buffer = inf_session_get_buffer(session); 
    9288 
    9389                InfSessionStatus status = inf_session_get_status(session); 
    9490                if(status == INF_SESSION_SYNCHRONIZING || 
    95                    !gtk_text_buffer_get_modified(buffer)) 
     91                   !inf_buffer_get_modified(buffer)) 
    9692                { 
    9793                        m_window.set_title( 
    98                                 m_current_document->get_title() + " - Gobby"); 
     94                                m_current_view->get_title() + " - Gobby"); 
    9995                } 
    10096                else 
    10197                { 
    10298                        m_window.set_title( 
    103                                 "*" + m_current_document->get_title() + 
     99                                "*" + m_current_view->get_title() + 
    104100                                " - Gobby"); 
    105101                } 
  • code/core/titlebar.hpp

    r6b79c69 r646a4f3  
    2121 
    2222#include "core/folder.hpp" 
    23 #include "core/docwindow.hpp" 
     23#include "core/sessionview.hpp" 
    2424 
    2525#include <gtkmm/window.h> 
     
    4242        } 
    4343 
    44         static void on_modified_changed_static(GtkTextBuffer* buffer, 
    45                                                gpointer user_data) 
     44        static void on_notify_modified_static(InfBuffer* buffer, 
     45                                              GParamSpec* pspec, 
     46                                              gpointer user_data) 
    4647        { 
    47                 static_cast<TitleBar*>(user_data)->on_modified_changed(); 
     48                static_cast<TitleBar*>(user_data)->on_notify_modified(); 
    4849        } 
    4950 
    50         void on_document_removed(DocWindow& document); 
    51         void on_document_changed(DocWindow* document); 
     51        void on_document_removed(SessionView& view); 
     52        void on_document_changed(SessionView* view); 
    5253 
    5354        void on_notify_status(); 
    54         void on_modified_changed(); 
     55        void on_notify_modified(); 
    5556 
    5657        void update_title(); 
     
    5859        Gtk::Window& m_window; 
    5960        Folder& m_folder; 
    60         DocWindow* m_current_document; 
     61        SessionView* m_current_view; 
    6162 
    6263        gulong m_notify_status_handler; 
  • code/core/userlist.cpp

    r2edcdf4 r646a4f3  
    192192        if(pixbuf) 
    193193        { 
    194                 pixbuf_renderer->property_pixbuf(); 
     194                pixbuf_renderer->property_pixbuf() = pixbuf; 
    195195                pixbuf_renderer->property_visible() = true; 
    196196        } 
  • code/dialogs/find-dialog.cpp

    r23dfbe6 r646a4f3  
    214214} 
    215215 
    216 void Gobby::FindDialog::on_document_changed(DocWindow* document) 
     216void Gobby::FindDialog::on_document_changed(SessionView* view) 
    217217{ 
    218218        m_active_user_changed_connection.disconnect(); 
    219  
    220         if(document != NULL) 
     219        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     220 
     221        if(text_view != NULL) 
    221222        { 
    222223                m_active_user_changed_connection = 
    223                         document->signal_active_user_changed().connect( 
     224                        text_view->signal_active_user_changed().connect( 
    224225                                sigc::mem_fun( 
    225226                                        *this, 
     
    264265bool Gobby::FindDialog::replace() 
    265266{ 
    266         DocWindow* document = m_folder.get_current_document(); 
    267         g_assert(document != NULL); 
     267        SessionView* view = m_folder.get_current_document(); 
     268        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     269        g_assert(text_view != NULL); 
    268270 
    269271        // Get selected string 
    270         Glib::ustring sel_str = document->get_selected_text(); 
     272        Glib::ustring sel_str = text_view->get_selected_text(); 
    271273        Glib::ustring find_str = get_find_text(); 
    272274 
     
    282284        { 
    283285                GtkTextBuffer* buffer = 
    284                         GTK_TEXT_BUFFER(document->get_text_buffer()); 
     286                        GTK_TEXT_BUFFER(text_view->get_text_buffer()); 
    285287 
    286288                // Replace occurence 
     
    303305bool Gobby::FindDialog::replace_all() 
    304306{ 
    305         DocWindow* document = m_folder.get_current_document(); 
    306         g_assert(document != NULL); 
     307        // TODO: Add helper function to get textsessionview? Maybe even add 
     308        // to Folder? 
     309        SessionView* view = m_folder.get_current_document(); 
     310        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     311        g_assert(text_view != NULL); 
    307312 
    308313        GtkTextIter begin; 
    309         GtkTextBuffer* buffer = GTK_TEXT_BUFFER(document->get_text_buffer()); 
     314        GtkTextBuffer* buffer = GTK_TEXT_BUFFER(text_view->get_text_buffer()); 
    310315        gtk_text_buffer_get_start_iter(buffer, &begin); 
    311316 
     
    349354                                        SearchDirection direction) 
    350355{ 
    351         DocWindow* document = m_folder.get_current_document(); 
    352         g_assert(document != NULL); 
     356        SessionView* view = m_folder.get_current_document(); 
     357        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     358        g_assert(text_view != NULL); 
    353359 
    354360        const GtkTextIter* real_begin = from; 
     
    359365        { 
    360366                GtkTextBuffer* buffer = 
    361                         GTK_TEXT_BUFFER(document->get_text_buffer()); 
     367                        GTK_TEXT_BUFFER(text_view->get_text_buffer()); 
    362368                GtkTextMark* mark = gtk_text_buffer_get_insert(buffer); 
    363369                gtk_text_buffer_get_iter_at_mark(buffer, &insert_iter, mark); 
     
    369375        { 
    370376                if(direction == SEARCH_FORWARD) 
    371                         document->set_selection(&match_end, &match_start); 
     377                        text_view->set_selection(&match_end, &match_start); 
    372378                else 
    373                         document->set_selection(&match_start, &match_end); 
     379                        text_view->set_selection(&match_start, &match_end); 
    374380 
    375381                return true; 
     
    384390                                  GtkTextIter* match_end) 
    385391{ 
    386         DocWindow* document = m_folder.get_current_document(); 
    387         g_assert(document != NULL); 
     392        SessionView* view = m_folder.get_current_document(); 
     393        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
     394        g_assert(text_view != NULL); 
    388395 
    389396        GtkTextIter start_pos = *from; 
     
    397404        // Wrap around 
    398405        GtkTextIter restart_pos; 
    399         GtkTextBuffer* buffer = GTK_TEXT_BUFFER(document->get_text_buffer()); 
     406        GtkTextBuffer* buffer = GTK_TEXT_BUFFER(text_view->get_text_buffer()); 
    400407 
    401408        if(direction == SEARCH_FORWARD) 
     
    479486void Gobby::FindDialog::update_sensitivity() 
    480487{ 
    481         DocWindow* document = m_folder.get_current_document(); 
     488        SessionView* view = m_folder.get_current_document(); 
     489        TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 
    482490 
    483491        bool find_sensitivity = 
    484                 (!m_entry_find.get_text().empty() && document != NULL); 
     492                (!m_entry_find.get_text().empty() && text_view != NULL); 
    485493        bool replace_sensitivity = 
    486                 (find_sensitivity && document->get_active_user() != NULL); 
     494                (find_sensitivity && text_view->get_active_user() != NULL); 
    487495 
    488496        set_response_sensitive(RESPONSE_FIND, find_sensitivity); 
  • code/dialogs/find-dialog.hpp

    rd9e7c10 r646a4f3  
    2222#include "core/folder.hpp" 
    2323#include "core/statusbar.hpp" 
    24 #include "core/docwindow.hpp" 
     24#include "core/sessionview.hpp" 
    2525 
    2626#include <gtkmm/dialog.h> 
     
    7171        virtual void on_response(int id); 
    7272 
    73         void on_document_changed(DocWindow* document); 
     73        void on_document_changed(SessionView* view); 
    7474        void on_active_user_changed(InfTextUser* user); 
    7575        void on_find_text_changed(); 
  • code/dialogs/goto-dialog.cpp

    rd9e7c10 r646a4f3  
    3030        m_label_line(_("Line _number:"), Gtk::ALIGN_LEFT, 
    3131                     Gtk::ALIGN_CENTER, true), 
    32         m_current_document(NULL) 
     32        m_current_view(NULL) 
    3333{ 
    3434        m_label_line.set_mnemonic_widget(m_entry_line); 
     
    7575        m_entry_line.grab_focus(); 
    7676 
    77         if(m_current_document != NULL) 
     77        if(m_current_view != NULL) 
    7878        { 
    7979                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    80                         m_current_document->get_text_buffer()); 
     80                        m_current_view->get_text_buffer()); 
    8181                GtkTextIter cursor; 
    8282                gtk_text_buffer_get_iter_at_mark( 
     
    9393        if(id == Gtk::RESPONSE_ACCEPT) 
    9494        { 
    95                 g_assert(m_current_document != NULL); 
     95                g_assert(m_current_view != NULL); 
    9696 
    9797                int value = m_entry_line.get_value_as_int(); 
    9898                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    99                         m_current_document->get_text_buffer()); 
     99                        m_current_view->get_text_buffer()); 
    100100                GtkTextIter begin; 
    101101                gtk_text_buffer_get_iter_at_line(buffer, &begin, value - 1); 
    102                 m_current_document->set_selection(&begin, &begin); 
     102                m_current_view->set_selection(&begin, &begin); 
    103103        } 
    104104        else if(id == Gtk::RESPONSE_CLOSE) 
     
    110110} 
    111111 
    112 void Gobby::GotoDialog::on_document_changed(DocWindow* document) 
     112void Gobby::GotoDialog::on_document_changed(SessionView* view) 
    113113{ 
    114         if(m_current_document != NULL) 
     114        if(m_current_view != NULL) 
    115115        { 
    116116                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    117                         m_current_document->get_text_buffer()); 
     117                        m_current_view->get_text_buffer()); 
    118118                g_signal_handler_disconnect(buffer, m_changed_handler); 
    119119        } 
    120120 
    121         set_response_sensitive(Gtk::RESPONSE_ACCEPT, document != NULL); 
    122         m_entry_line.set_sensitive(document != NULL); 
    123         m_current_document = document; 
     121        m_current_view = dynamic_cast<TextSessionView*>(view); 
     122        set_response_sensitive(Gtk::RESPONSE_ACCEPT, m_current_view != NULL); 
     123        m_entry_line.set_sensitive(m_current_view != NULL); 
    124124 
    125         if(document != NULL) 
     125        if(m_current_view != NULL) 
    126126        { 
    127127                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    128                         document->get_text_buffer()); 
     128                        m_current_view->get_text_buffer()); 
    129129 
    130130                m_changed_handler = g_signal_connect_after( 
     
    138138void Gobby::GotoDialog::on_changed() 
    139139{ 
    140         g_assert(m_current_document != NULL); 
     140        g_assert(m_current_view != NULL); 
    141141        GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    142                 m_current_document->get_text_buffer()); 
     142                m_current_view->get_text_buffer()); 
    143143 
    144144        m_entry_line.set_range(1, gtk_text_buffer_get_line_count(buffer)); 
  • code/dialogs/goto-dialog.hpp

    rd9e7c10 r646a4f3  
    2121 
    2222#include "core/folder.hpp" 
    23 #include "core/docwindow.hpp" 
     23#include "core/sessionview.hpp" 
    2424 
    2525#include <gtkmm/dialog.h> 
     
    4747        virtual void on_response(int id); 
    4848 
    49         void on_document_changed(DocWindow* document); 
     49        void on_document_changed(SessionView* view); 
    5050        void on_changed(); 
    5151 
     
    5757        Gtk::SpinButton m_entry_line; 
    5858 
    59         DocWindow* m_current_document; 
     59        TextSessionView* m_current_view; 
    6060        gulong m_changed_handler; 
    6161}; 
  • code/operations/operation-export-html.cpp

    r23dfbe6 r646a4f3  
    105105        // save all users and tags encountered and the total number of 
    106106        // lines dumped 
    107         void dump_buffer(Gobby::DocWindow& document, 
     107        void dump_buffer(Gobby::TextSessionView& view, 
    108108                         xmlpp::Element* content, 
    109109                         std::set<InfTextUser*>& users, 
     
    121121 
    122122                GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 
    123                         document.get_text_buffer()); 
     123                        view.get_text_buffer()); 
    124124                InfTextGtkBuffer* inf_buffer 
    125125                        = INF_TEXT_GTK_BUFFER( 
    126126                                inf_session_get_buffer( 
    127                                         INF_SESSION(document.get_session()))); 
     127                                        INF_SESSION(view.get_session()))); 
    128128 
    129129                GtkTextIter begin; 
     
    223223        // some random interesting information/advertisement to be put at 
    224224        // the end of the html output 
    225         void dump_info(xmlpp::Element* node, Gobby::DocWindow& document) 
     225        void dump_info(xmlpp::Element* node, Gobby::TextSessionView& view) 
    226226        { 
    227227                using namespace Gobby; 
     
    240240                } 
    241241 
    242                 char const* hostname = document.get_hostname().c_str(); 
    243                 char const* path     = document.get_path().c_str(); 
     242                char const* hostname = view.get_hostname().c_str(); 
     243                char const* path     = view.get_path().c_str(); 
    244244 
    245245                // %1$s is session name/hostname 
     
    349349        // generate xhtml representation of the document and write it to the 
    350350        // specified location in the filesystem 
    351         std::string export_html(Gobby::DocWindow& document) 
     351        std::string export_html(Gobby::TextSessionView& view) 
    352352        { 
    353353                using namespace Gobby; 
     
    379379                icon->set_attribute("class",  "icon"); 
    380380 
    381                 const Glib::ustring& document_name = document.get_title(); 
     381                const Glib::ustring& document_name = view.get_title(); 
    382382                title->add_child_text(document_name + " - infinote document"); 
    383383 
     
    389389                priority_tag_set tags; 
    390390                unsigned int line_counter; 
    391                 dump_buffer(document, content, users, tags, line_counter); 
     391                dump_buffer(view, content, users, tags, line_counter); 
    392392 
    393393                h2->add_child_text(_("Participants")); 
    394394 
    395395                info->set_attribute("class", "info"); 
    396                 dump_info(info, document); 
     396                dump_info(info, view); 
    397397 
    398398                style->set_attribute("type", "text/css"); 
     
    441441 
    442442Gobby::OperationExportHtml::OperationExportHtml(Operations& operations, 
    443                                                 DocWindow& document, 
     443                                                TextSessionView& view, 
    444444                                                const std::string& uri): 
    445445        Operation(operations), m_index(0), 
    446         m_xml(export_html(document)) 
     446        m_xml(export_html(view)) 
    447447{ 
    448448        m_file = Gio::File::create_for_uri(uri); 
     
    453453                Glib::ustring::compose( 
    454454                        _("Exporting document %1 to %2 in HTML..."), 
    455                         document.get_title(), uri)); 
     455                        view.get_title(), uri)); 
    456456} 
    457457 
  • code/operations/operation-export-html.hpp

    re275a84 r646a4f3  
    3434{ 
    3535public: 
    36         OperationExportHtml(Operations& operations, DocWindow& document, 
     36        OperationExportHtml(Operations& operations, TextSessionView& view, 
    3737                            const std::string& uri); 
    3838 
  • code/operations/operation-save.cpp

    r23dfbe6 r646a4f3  
    2424 
    2525Gobby::OperationSave::OperationSave(Operations& operations, 
    26                                     DocWindow& document, 
     26                                    TextSessionView& view, 
    2727                                    Folder& folder, 
    2828                                    const std::string& uri, 
    2929                                    const std::string& encoding, 
    3030                                    DocumentInfoStorage::EolStyle eol_style): 
    31         Operation(operations), m_document(&document), 
     31        Operation(operations), m_view(&view), 
    3232        m_start_time(std::time(NULL)), m_current_line_index(0), 
    3333        m_iconv(encoding.c_str(), "UTF-8"), m_encoding(encoding), 
    3434        m_eol_style(eol_style), 
    35         m_storage_key(document.get_info_storage_key()), m_buffer_size(0), 
     35        m_storage_key(view.get_info_storage_key()), m_buffer_size(0), 
    3636        m_buffer_index(0) 
    3737{ 
    3838        // Load content so that the session can go on while saving 
    39         GtkTextBuffer* buffer = GTK_TEXT_BUFFER(document.get_text_buffer()); 
     39        GtkTextBuffer* buffer = GTK_TEXT_BUFFER(view.get_text_buffer()); 
    4040        GtkTextIter prev; 
    4141        GtkTextIter pos; 
     
    7272        m_message_handle = get_status_bar().add_info_message( 
    7373                Glib::ustring::compose(_("Saving document %1 to %2..."), 
    74                         document.get_title(), uri)); 
     74                        view.get_title(), uri)); 
    7575 
    7676        folder.signal_document_removed().connect( 
     
    9696} 
    9797 
    98 void Gobby::OperationSave::on_document_removed(DocWindow& document) 
     98void Gobby::OperationSave::on_document_removed(SessionView& view) 
    9999{ 
    100100        // We keep the document to unset the modified flag when the operation 
    101101        // is complete, however, if the document is removed in the meanwhile, 
    102102        // then we don't need to care anymore. 
    103         if(m_document == &document) 
    104                 m_document = NULL; 
     103        if(m_view == &view) 
     104                m_view = NULL; 
    105105} 
    106106 
     
    154154                m_stream->close(); 
    155155 
    156                 if(m_document != NULL) 
     156                if(m_view != NULL) 
    157157                { 
    158158                        // TODO: Don't unset modified flag if the document has 
     
    160160                        // buffer-modified-time in algorithm. 
    161161                        gtk_text_buffer_set_modified( 
    162                                 GTK_TEXT_BUFFER( 
    163                                         m_document->get_text_buffer()), 
     162                                GTK_TEXT_BUFFER(m_view->get_text_buffer()), 
    164163                                FALSE); 
    165164                } 
  • code/operations/operation-save.hpp

    r6b79c69 r646a4f3  
    3434{ 
    3535public: 
    36         OperationSave(Operations& operations, DocWindow& document, 
     36        // TODO: This should maybe just take a text buffer to save, not a 
     37        // textsessionview. 
     38        OperationSave(Operations& operations, TextSessionView& view, 
    3739                      Folder& folder, const std::string& uri, 
    3840                      const std::string& encoding, 
     
    4143        virtual ~OperationSave(); 
    4244 
    43         // Note these can return NULL in case the document has been removed 
     45        // Note these can return NULL in case the view has been closed 
    4446        // in the meanwhile. 
    45         DocWindow* get_document() { return m_document; } 
    46         const DocWindow* get_document() const { return m_document; } 
     47        TextSessionView* get_view() { return m_view; } 
     48        const TextSessionView* get_view() const { return m_view; } 
    4749 
    4850        std::time_t get_start_time() const { return m_start_time; } 
    4951 
    5052protected: 
    51         void on_document_removed(DocWindow& document); 
     53        void on_document_removed(SessionView& view); 
    5254        void on_file_replace(const Glib::RefPtr<Gio::AsyncResult>& result); 
    5355        void on_stream_write(const Glib::RefPtr<Gio::AsyncResult>& result); 
     
    5759        void error(const Glib::ustring& message); 
    5860protected: 
    59         DocWindow* m_document; 
     61        TextSessionView* m_view; 
    6062        std::time_t m_start_time; 
    6163 
  • code/operations/operations.cpp

    re275a84 r646a4f3  
    101101 
    102102Gobby::OperationSave* 
    103 Gobby::Operations::save_document(DocWindow& document, 
     103Gobby::Operations::save_document(TextSessionView& view, 
    104104                                 Folder& folder, 
    105105                                 const std::string& uri, 
     
    107107                                 DocumentInfoStorage::EolStyle eol_style) 
    108108{ 
    109         OperationSave* prev_op = get_save_operation_for_document(document); 
     109        OperationSave* prev_op = get_save_operation_for_document(view); 
    110110 
    111111        // Cancel previous save operation: 
     
    113113                fail_operation(prev_op); 
    114114 
    115         OperationSave* op = new OperationSave(*this, document, folder, uri, 
     115        OperationSave* op = new OperationSave(*this, view, folder, uri, 
    116116                                              encoding, eol_style); 
    117117 
     
    131131 
    132132Gobby::OperationExportHtml* 
    133 Gobby::Operations::export_html(DocWindow& document, 
     133Gobby::Operations::export_html(TextSessionView& view, 
    134134                               const std::string& uri) 
    135135{ 
    136136        OperationExportHtml* op = 
    137                 new OperationExportHtml(*this, document, uri); 
     137                new OperationExportHtml(*this, view, uri); 
    138138        m_operations.insert(op); 
    139139        return op; 
     
    141141 
    142142Gobby::OperationSave* 
    143 Gobby::Operations::get_save_operation_for_document(DocWindow& document) 
     143Gobby::Operations::get_save_operation_for_document(TextSessionView& view) 
    144144{ 
    145145        for(OperationSet::iterator iter = m_operations.begin(); 
     
    150150                if(save_op != NULL) 
    151151                { 
    152                         if(save_op->get_document() == &document) 
     152                        if(save_op->get_view() == &view) 
    153153                                return save_op; 
    154154                } 
  • code/operations/operations.hpp

    re275a84 r646a4f3  
    2222#include "core/documentinfostorage.hpp" 
    2323#include "core/statusbar.hpp" 
     24#include "core/textsessionview.hpp" 
    2425 
    2526#include <libinfinity/client/infc-browser.h> 
     
    109110                                                unsigned int num_uris); 
    110111 
    111         OperationSave* save_document(DocWindow& document, 
     112        OperationSave* save_document(TextSessionView& view, 
    112113                                     Folder& folder, 
    113114                                     const std::string& uri, 
     
    118119                                     const InfcBrowserIter* iter); 
    119120 
    120         OperationExportHtml* export_html(DocWindow& document, 
     121        OperationExportHtml* export_html(TextSessionView& view, 
    121122                                         const std::string& uri); 
    122123 
    123         OperationSave* get_save_operation_for_document(DocWindow& window); 
     124        OperationSave* get_save_operation_for_document(TextSessionView& view); 
    124125 
    125126        SignalBeginSaveOperation signal_begin_save_operation() const 
  • code/window.cpp

    rd26c3b9 r646a4f3  
    2222#include "commands/file-tasks/task-open.hpp" 
    2323#include "commands/file-tasks/task-open-multiple.hpp" 
    24 #include "core/docwindow.hpp" 
    2524#include "core/iconmanager.hpp" 
    2625#include "core/noteplugin.hpp"