Changeset 646a4f3c01880913367395f619aea3fe17d0cca5
- Timestamp:
- 11/09/09 10:53:11 (4 years ago)
- 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
- Files:
-
- 41 modified
- 2 moved
-
ChangeLog (modified) (1 diff)
-
code/commands/autosave-commands.cpp (modified) (13 diffs)
-
code/commands/autosave-commands.hpp (modified) (2 diffs)
-
code/commands/browser-commands.cpp (modified) (22 diffs)
-
code/commands/edit-commands.cpp (modified) (10 diffs)
-
code/commands/edit-commands.hpp (modified) (2 diffs)
-
code/commands/file-commands.cpp (modified) (6 diffs)
-
code/commands/file-commands.hpp (modified) (1 diff)
-
code/commands/file-tasks/task-export-html.cpp (modified) (5 diffs)
-
code/commands/file-tasks/task-export-html.hpp (modified) (1 diff)
-
code/commands/file-tasks/task-save-all.cpp (modified) (4 diffs)
-
code/commands/file-tasks/task-save-all.hpp (modified) (1 diff)
-
code/commands/file-tasks/task-save.cpp (modified) (6 diffs)
-
code/commands/file-tasks/task-save.hpp (modified) (1 diff)
-
code/commands/folder-commands.cpp (modified) (11 diffs)
-
code/commands/folder-commands.hpp (modified) (1 diff)
-
code/commands/view-commands.cpp (modified) (6 diffs)
-
code/commands/view-commands.hpp (modified) (2 diffs)
-
code/core/Makefile.am (modified) (4 diffs)
-
code/core/folder.cpp (modified) (7 diffs)
-
code/core/folder.hpp (modified) (4 diffs)
-
code/core/sessionview.cpp (modified) (1 diff)
-
code/core/sessionview.hpp (modified) (2 diffs)
-
code/core/statusbar.cpp (modified) (5 diffs)
-
code/core/statusbar.hpp (modified) (2 diffs)
-
code/core/tablabel.cpp (modified) (11 diffs)
-
code/core/tablabel.hpp (modified) (4 diffs)
-
code/core/textsessionview.cpp (moved) (moved from code/core/docwindow.cpp) (26 diffs)
-
code/core/textsessionview.hpp (moved) (moved from code/core/docwindow.hpp) (8 diffs)
-
code/core/titlebar.cpp (modified) (6 diffs)
-
code/core/titlebar.hpp (modified) (3 diffs)
-
code/core/userlist.cpp (modified) (1 diff)
-
code/dialogs/find-dialog.cpp (modified) (10 diffs)
-
code/dialogs/find-dialog.hpp (modified) (2 diffs)
-
code/dialogs/goto-dialog.cpp (modified) (5 diffs)
-
code/dialogs/goto-dialog.hpp (modified) (3 diffs)
-
code/operations/operation-export-html.cpp (modified) (9 diffs)
-
code/operations/operation-export-html.hpp (modified) (1 diff)
-
code/operations/operation-save.cpp (modified) (5 diffs)
-
code/operations/operation-save.hpp (modified) (3 diffs)
-
code/operations/operations.cpp (modified) (6 diffs)
-
code/operations/operations.hpp (modified) (3 diffs)
-
code/window.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r0e7581e r646a4f3 1 2009-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 1 58 2009-10-18 Armin Burgmeier <armin@arbur.net> 2 59 -
code/commands/autosave-commands.cpp
rfd2f104 r646a4f3 21 21 #include "operations/operation-save.hpp" 22 22 23 #include "core/sessionuserview.hpp" 24 23 25 #include <ctime> 24 26 … … 26 28 { 27 29 public: 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(); 32 34 33 35 m_modified_changed_handler = g_signal_connect_after( … … 42 44 Operations& operations = m_commands.m_operations; 43 45 OperationSave* save_op = 44 operations.get_save_operation_for_document( doc);46 operations.get_save_operation_for_document(view); 45 47 if(save_op != NULL) 46 48 begin_save_operation(save_op); … … 51 53 ~Info() 52 54 { 53 GtkSourceBuffer* buffer = m_ document.get_text_buffer();55 GtkSourceBuffer* buffer = m_view.get_text_buffer(); 54 56 55 57 g_signal_handler_disconnect(G_OBJECT(buffer), … … 95 97 { 96 98 GtkTextBuffer* buffer = 97 GTK_TEXT_BUFFER(m_ document.get_text_buffer());99 GTK_TEXT_BUFFER(m_view.get_text_buffer()); 98 100 99 101 if(!gtk_text_buffer_get_modified(buffer)) … … 120 122 // automatically retry when the document is assigned an URI, 121 123 // 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(); 123 125 const DocumentInfoStorage::Info* info = 124 126 m_commands.m_info_storage.get_info(key); … … 147 149 { 148 150 GtkTextBuffer* buffer = 149 GTK_TEXT_BUFFER(m_ document.get_text_buffer());151 GTK_TEXT_BUFFER(m_view.get_text_buffer()); 150 152 151 153 if(success) … … 162 164 bool on_timeout() 163 165 { 164 const std::string& key = m_ document.get_info_storage_key();166 const std::string& key = m_view.get_info_storage_key(); 165 167 const DocumentInfoStorage::Info* info = 166 168 m_commands.m_info_storage.get_info(key); … … 171 173 { 172 174 m_commands.m_operations.save_document( 173 m_ document, m_commands.m_folder,175 m_view, m_commands.m_folder, 174 176 info->uri, info->encoding, info->eol_style); 175 177 … … 195 197 196 198 AutosaveCommands& m_commands; 197 DocWindow& m_document;199 TextSessionView& m_view; 198 200 199 201 gulong m_modified_changed_handler; … … 245 247 } 246 248 247 void Gobby::AutosaveCommands::on_document_added( DocWindow& document)249 void Gobby::AutosaveCommands::on_document_added(SessionView& view) 248 250 { 249 251 if(m_preferences.editor.autosave_enabled) 250 252 { 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 265 void Gobby::AutosaveCommands::on_document_removed(SessionView& view) 257 266 { 258 267 if(m_preferences.editor.autosave_enabled) 259 268 { 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 } 264 279 } 265 280 } … … 268 283 OperationSave* operation) 269 284 { 270 DocWindow* document = operation->get_document();285 TextSessionView* view = operation->get_view(); 271 286 // Save operation just started, document must be present 272 g_assert( document!= NULL);287 g_assert(view != NULL); 273 288 274 289 if(m_preferences.editor.autosave_enabled) 275 290 { 276 InfoMap::iterator iter = m_info_map.find( document);291 InfoMap::iterator iter = m_info_map.find(view); 277 292 g_assert(iter != m_info_map.end()); 278 293 … … 289 304 ++i) 290 305 { 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 } 294 322 } 295 323 } -
code/commands/autosave-commands.hpp
r6b79c69 r646a4f3 40 40 41 41 protected: 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); 44 44 45 45 void on_begin_save_operation(OperationSave* operation); … … 53 53 54 54 class Info; 55 typedef std::map< DocWindow*, Info*> InfoMap;55 typedef std::map<TextSessionView*, Info*> InfoMap; 56 56 InfoMap m_info_map; 57 57 }; -
code/commands/browser-commands.cpp
r23dfbe6 r646a4f3 40 40 }; 41 41 42 void set_error_text(Gobby:: DocWindow& window,42 void set_error_text(Gobby::SessionView& view, 43 43 const Glib::ustring& initial_text, 44 44 ErrorType type) … … 74 74 "Thank you."); 75 75 76 window.set_info(76 view.set_info( 77 77 initial_text + "\n\n" + type_text + "\n\n" + 78 78 info_text, true); … … 218 218 { 219 219 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); 226 227 } 227 228 else … … 230 231 // we subscribe to directly into the folder. 231 232 g_assert_not_reached(); 232 /*folder.add_document(233 text_session,234 infc_browser_iter_get_name(browser, iter));*/235 233 } 236 234 } … … 293 291 "remote-hostname", &hostname, NULL); 294 292 295 DocWindow& window = m_folder.add_document(293 TextSessionView& view = m_folder.add_document( 296 294 INF_TEXT_SESSION(session), 297 295 infc_browser_iter_get_name(browser, iter), … … 306 304 // then don't select the item, and if the user did issue other folder 307 305 // 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())); 310 308 m_browser.set_selected(browser, iter); 311 309 … … 352 350 g_object_unref(connection); 353 351 354 window.set_info(352 view.set_info( 355 353 Glib::ustring::compose( 356 354 _("Synchronization in progress... %1%%"), … … 387 385 if(iter->second.status == INF_SESSION_SYNCHRONIZING) 388 386 { 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); 392 389 393 390 set_error_text( 394 * window,391 *view, 395 392 Glib::ustring::compose("Synchronization failed: %1", 396 393 error->message), SYNC_ERROR); … … 398 395 // The document will be of no use anyway, so consider it not 399 396 // 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); 402 399 403 400 // Don't wait until the session is closed because of this, … … 418 415 { 419 416 // 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); 426 422 427 423 // TODO: Actually we should always set the modified flag, … … 458 454 if(iter->second.status == INF_SESSION_SYNCHRONIZING) 459 455 { 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( 465 460 Glib::ustring::compose( 466 461 _("Synchronization in progress... %1%%"), … … 485 480 if(infc_session_proxy_get_connection(proxy) == NULL) 486 481 { 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(_( 492 486 "The connection to the publisher of this document " 493 487 "has been lost. Further changes to the document " … … 497 491 "of your latest changes have reached the " 498 492 "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); 500 498 } 501 499 } … … 514 512 if(user == NULL) 515 513 { 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); 519 520 520 521 // TODO: Automatically join with a different name if there is … … 545 546 546 547 GtkTextBuffer* buffer = 547 GTK_TEXT_BUFFER( window->get_text_buffer());548 GTK_TEXT_BUFFER(text_view->get_text_buffer()); 548 549 GtkTextMark* mark = gtk_text_buffer_get_insert(buffer); 549 550 GtkTextIter caret_iter; … … 552 553 gtk_text_iter_get_offset(&caret_iter)); 553 554 554 if(m_folder.get_current_document() == window)555 if(m_folder.get_current_document() == view) 555 556 g_value_set_enum(¶ms[4].value, INF_USER_ACTIVE); 556 557 else … … 560 561 InfcUserRequest* request = infc_session_proxy_join_user( 561 562 proxy, params, 5, &error); 562 563 563 564 g_value_unset(¶ms[0].value); 564 565 g_value_unset(¶ms[1].value); … … 570 571 { 571 572 set_error_text( 572 * window,573 *view, 573 574 Glib::ustring::compose("User Join failed: %1", 574 575 error->message), … … 577 578 else 578 579 { 579 window->set_info(580 view->set_info( 580 581 _("User Join in progress..."), false); 581 582 … … 608 609 609 610 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); 613 614 614 615 if(error->domain == inf_user_error_quark() && … … 643 644 644 645 set_error_text( 645 * window,646 *view, 646 647 Glib::ustring::compose("User Join failed: %1", 647 648 error->message), … … 672 673 InfUser* user) 673 674 { 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); 677 678 678 679 // TODO: Notify the user that he is using an alternative name if 679 680 // inf_user_get_name(user) does not match m_preferences.user.name. 680 681 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 30 30 m_parent(parent), m_header(header), m_folder(folder), 31 31 m_preferences(preferences), m_status_bar(status_bar), 32 m_current_ document(NULL)32 m_current_view(NULL) 33 33 { 34 34 m_header.action_edit_undo->signal_activate().connect( … … 69 69 } 70 70 71 void Gobby::EditCommands::on_document_removed(DocWindow& document) 72 { 73 if(&document == m_current_document) 71 void Gobby::EditCommands::on_document_removed(SessionView& view) 72 { 73 // TODO: Isn't this emitted by Folder already? 74 if(&view == m_current_view) 74 75 on_document_changed(NULL); 75 76 } 76 77 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();78 void Gobby::EditCommands::on_document_changed(SessionView* view) 79 { 80 if(m_current_view != NULL) 81 { 82 InfTextSession* session = m_current_view->get_session(); 82 83 InfAdoptedAlgorithm* algorithm = 83 84 inf_adopted_session_get_algorithm( 84 85 INF_ADOPTED_SESSION(session)); 85 86 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 86 m_current_ document->get_text_buffer());87 m_current_view->get_text_buffer()); 87 88 88 89 if(m_synchronization_complete_handler != 0) … … 110 111 } 111 112 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(); 118 119 GtkTextBuffer* buffer = 119 GTK_TEXT_BUFFER( document->get_text_buffer());120 GTK_TEXT_BUFFER(m_current_view->get_text_buffer()); 120 121 121 122 m_active_user_changed_connection = 122 document->signal_active_user_changed().connect(123 m_current_view->signal_active_user_changed().connect( 123 124 sigc::mem_fun( 124 125 *this, … … 199 200 void Gobby::EditCommands::on_sync_complete() 200 201 { 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(); 203 204 204 205 InfAdoptedAlgorithm* algorithm = inf_adopted_session_get_algorithm( … … 224 225 void Gobby::EditCommands::on_active_user_changed(InfTextUser* active_user) 225 226 { 226 g_assert(m_current_ document!= NULL);227 g_assert(m_current_view != NULL); 227 228 228 229 if(active_user != NULL) 229 230 { 230 InfTextSession* session = m_current_ document->get_session();231 InfTextSession* session = m_current_view->get_session(); 231 232 InfAdoptedAlgorithm* algorithm = 232 233 inf_adopted_session_get_algorithm( 233 234 INF_ADOPTED_SESSION(session)); 234 235 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 235 m_current_ document->get_text_buffer());236 m_current_view->get_text_buffer()); 236 237 237 238 m_header.action_edit_undo->set_sensitive( … … 257 258 void Gobby::EditCommands::on_mark_set() 258 259 { 259 g_assert(m_current_ document!= NULL);260 g_assert(m_current_view != NULL); 260 261 GtkTextBuffer* buffer = 261 GTK_TEXT_BUFFER(m_current_ document->get_text_buffer());262 GTK_TEXT_BUFFER(m_current_view->get_text_buffer()); 262 263 263 264 m_header.action_edit_copy->set_sensitive( 264 265 gtk_text_buffer_get_has_selection(buffer)); 265 266 266 if(m_current_ document->get_active_user() != NULL)267 if(m_current_view->get_active_user() != NULL) 267 268 { 268 269 m_header.action_edit_cut->set_sensitive( … … 279 280 bool can_undo) 280 281 { 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) 283 284 m_header.action_edit_undo->set_sensitive(can_undo); 284 285 } … … 287 288 bool can_redo) 288 289 { 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) 291 292 m_header.action_edit_redo->set_sensitive(can_redo); 292 293 } … … 330 331 void Gobby::EditCommands::on_undo() 331 332 { 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); 336 337 337 338 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()) 340 341 ); 341 342 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_); 344 345 345 346 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); 347 348 check_set = false; 348 m_current_ document->scroll_to_cursor_position(0.0);349 m_current_view->scroll_to_cursor_position(0.0); 349 350 } 350 351 351 352 void Gobby::EditCommands::on_redo() 352 353 { 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); 357 358 358 359 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()) 361 362 ); 362 363 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_); 365 366 366 367 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); 368 369 check_set = false; 369 m_current_ document->scroll_to_cursor_position(0.0);370 m_current_view->scroll_to_cursor_position(0.0); 370 371 } 371 372 372 373 void Gobby::EditCommands::on_cut() 373 374 { 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); 376 377 377 378 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()), 379 380 gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), 380 381 TRUE); 381 382 382 m_current_ document->scroll_to_cursor_position(0.0);383 m_current_view->scroll_to_cursor_position(0.0); 383 384 } 384 385 385 386 void Gobby::EditCommands::on_copy() 386 387 { 387 g_assert(m_current_ document!= NULL);388 g_assert(m_current_view != NULL); 388 389 389 390 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()), 391 392 gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); 392 393 } … … 394 395 void Gobby::EditCommands::on_paste() 395 396 { 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); 398 399 399 400 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()), 401 402 gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), 402 403 NULL, TRUE); 403 404 404 m_current_ document->scroll_to_cursor_position(0.0);405 m_current_view->scroll_to_cursor_position(0.0); 405 406 } 406 407 -
code/commands/edit-commands.hpp
rd9e7c10 r646a4f3 44 44 45 45 protected: 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); 48 48 49 49 static void on_can_undo_changed_static(InfAdoptedAlgorithm* algorithm, … … 117 117 std::auto_ptr<PreferencesDialog> m_preferences_dialog; 118 118 119 DocWindow* m_current_document;119 TextSessionView* m_current_view; 120 120 // Only valid when m_current_document is nonzero: 121 121 sigc::connection m_active_user_changed_connection; -
code/commands/file-commands.cpp
r4e250df r646a4f3 153 153 } 154 154 155 void Gobby::FileCommands::on_document_changed( DocWindow* document)155 void Gobby::FileCommands::on_document_changed(SessionView* view) 156 156 { 157 157 update_sensitivity(); … … 190 190 void Gobby::FileCommands::on_save() 191 191 { 192 // TODO: Encoding selection in file chooser193 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); 195 195 196 196 const DocumentInfoStorage::Info* info = 197 197 m_document_info_storage.get_info( 198 document->get_info_storage_key());198 text_view->get_info_storage_key()); 199 199 200 200 if(info != NULL && !info->uri.empty()) 201 201 { 202 202 m_operations.save_document( 203 * document, m_folder, info->uri, info->encoding,203 *text_view, m_folder, info->uri, info->encoding, 204 204 info->eol_style); 205 205 } … … 212 212 void Gobby::FileCommands::on_save_as() 213 213 { 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)); 218 219 } 219 220 … … 223 224 } 224 225 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)); 226 void 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)); 230 233 } 231 234 232 235 void Gobby::FileCommands::on_close() 233 236 { 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); 238 241 } 239 242 … … 248 251 bool create_sensitivity = gtk_tree_model_get_iter_first( 249 252 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; 251 260 252 261 m_header.action_file_new->set_sensitive(create_sensitivity); … … 254 263 m_header.action_file_open_location->set_sensitive(create_sensitivity); 255 264 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 93 93 } 94 94 95 void on_document_changed( DocWindow* document);95 void on_document_changed(SessionView* view); 96 96 void on_row_inserted(); 97 97 void on_row_deleted(); -
code/commands/file-tasks/task-export-html.cpp
rb24d6e3 r646a4f3 23 23 24 24 Gobby::TaskExportHtml::TaskExportHtml(FileCommands& file_commands, 25 DocWindow& document):25 TextSessionView& view): 26 26 Task(file_commands), 27 27 m_file_dialog(get_file_chooser(), get_parent(), 28 28 Glib::ustring::compose( 29 29 _("Choose a location to export document \"%1\" to"), 30 document.get_title()),30 view.get_title()), 31 31 Gtk::FILE_CHOOSER_ACTION_SAVE), 32 m_document(&document), 33 m_running(false) 32 m_view(&view), m_running(false) 34 33 { 35 34 get_folder().signal_document_removed().connect( … … 41 40 // m_document will be set to NULL if it has been removed before run 42 41 // was called. 43 if(!m_ document)42 if(!m_view) 44 43 { 45 44 finish(); … … 52 51 *this, &TaskExportHtml::on_response)); 53 52 54 m_file_dialog.set_current_name(m_ document->get_title() + ".xhtml");53 m_file_dialog.set_current_name(m_view->get_title() + ".xhtml"); 55 54 m_file_dialog.present(); 56 55 } … … 61 60 { 62 61 get_operations().export_html( 63 *m_ document, m_file_dialog.get_uri());62 *m_view, m_file_dialog.get_uri()); 64 63 } 65 64 … … 67 66 } 68 67 69 void Gobby::TaskExportHtml::on_document_removed( DocWindow& document)68 void Gobby::TaskExportHtml::on_document_removed(SessionView& view) 70 69 { 71 70 // The document we are about to save was removed. 72 if(m_ document == &document)71 if(m_view == &view) 73 72 { 74 73 if(m_running) 75 74 finish(); 76 75 else 77 m_ document= NULL;76 m_view = NULL; 78 77 } 79 78 } -
code/commands/file-tasks/task-export-html.hpp
rb24d6e3 r646a4f3 29 29 private: 30 30 FileChooser::Dialog m_file_dialog; 31 DocWindow* m_document;31 TextSessionView* m_view; 32 32 bool m_running; 33 33 34 34 public: 35 TaskExportHtml(FileCommands& file_commands, DocWindow& document);35 TaskExportHtml(FileCommands& file_commands, TextSessionView& view); 36 36 virtual void run(); 37 37 38 38 void on_response(int response_id); 39 void on_document_removed( DocWindow& document);39 void on_document_removed(SessionView& view); 40 40 }; 41 41 -
code/commands/file-tasks/task-save-all.cpp
r8bafce5 r646a4f3 35 35 iter != pages.end(); ++ iter) 36 36 { 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); 39 44 } 40 45 … … 42 47 sigc::mem_fun(*this, &TaskSaveAll::on_document_removed)); 43 48 44 m_current = m_ documents.begin();49 m_current = m_views.begin(); 45 50 process_current(); 46 51 } 47 52 48 void Gobby::TaskSaveAll::on_document_removed( DocWindow& document)53 void Gobby::TaskSaveAll::on_document_removed(SessionView& view) 49 54 { 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); 52 57 53 58 if(iter == m_current) 54 59 { 55 m_current = m_ documents.erase(m_current);60 m_current = m_views.erase(m_current); 56 61 // Go on with next 57 62 process_current(); 58 63 } 59 64 60 if(iter != m_ documents.end())61 m_ documents.erase(iter);65 if(iter != m_views.end()) 66 m_views.erase(iter); 62 67 } 63 68 64 69 void Gobby::TaskSaveAll::on_finished() 65 70 { 66 m_current = m_ documents.erase(m_current);71 m_current = m_views.erase(m_current); 67 72 process_current(); 68 73 } … … 72 77 m_task.reset(NULL); 73 78 74 if(m_current == m_ documents.end())79 if(m_current == m_views.end()) 75 80 { 76 81 finish(); … … 78 83 else 79 84 { 80 DocWindow& doc= **m_current;85 TextSessionView& view = **m_current; 81 86 82 87 const DocumentInfoStorage::Info* info = 83 88 get_document_info_storage().get_info( 84 doc.get_info_storage_key());89 view.get_info_storage_key()); 85 90 86 91 if(info != NULL && !info->uri.empty()) 87 92 { 88 93 get_operations().save_document( 89 doc, get_folder(), info->uri,94 view, get_folder(), info->uri, 90 95 info->encoding, info->eol_style); 91 96 92 m_current = m_ documents.erase(m_current);97 m_current = m_views.erase(m_current); 93 98 process_current(); 94 99 } 95 100 else 96 101 { 97 m_task.reset(new TaskSave(m_file_commands, doc));102 m_task.reset(new TaskSave(m_file_commands, view)); 98 103 99 104 m_task->signal_finished().connect(sigc::mem_fun( -
code/commands/file-tasks/task-save-all.hpp
r3da60b7 r646a4f3 34 34 35 35 private: 36 void on_document_removed( DocWindow& document);36 void on_document_removed(SessionView& view); 37 37 void on_finished(); 38 38 39 39 void process_current(); 40 40 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; 43 43 std::auto_ptr<TaskSave> m_task; 44 44 }; -
code/commands/file-tasks/task-save.cpp
r83d4812 r646a4f3 20 20 #include "util/i18n.hpp" 21 21 22 Gobby::TaskSave::TaskSave(FileCommands& file_commands, DocWindow& document):22 Gobby::TaskSave::TaskSave(FileCommands& file_commands, TextSessionView& view): 23 23 Task(file_commands), 24 24 m_file_dialog(get_file_chooser(), get_parent(), 25 25 Glib::ustring::compose( 26 26 _("Choose a location to save document \"%1\" to"), 27 document.get_title()),27 view.get_title()), 28 28 Gtk::FILE_CHOOSER_ACTION_SAVE), 29 m_ document(&document),29 m_view(&view), 30 30 m_running(false) 31 31 { … … 36 36 void Gobby::TaskSave::run() 37 37 { 38 // m_ documentwill be set to NULL if it has been removed before run38 // m_view will be set to NULL if it has been removed before run 39 39 // was called. 40 if(!m_ document)40 if(!m_view) 41 41 { 42 42 finish(); … … 51 51 const DocumentInfoStorage::Info* info = 52 52 get_document_info_storage().get_info( 53 m_ document->get_info_storage_key());53 m_view->get_info_storage_key()); 54 54 55 55 if(info != NULL && !info->uri.empty()) 56 {57 56 m_file_dialog.set_uri(info->uri); 58 }59 57 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()); 64 59 65 60 m_file_dialog.present(); … … 71 66 { 72 67 const std::string& info_storage_key = 73 m_ document->get_info_storage_key();68 m_view->get_info_storage_key(); 74 69 75 70 const DocumentInfoStorage::Info* info = … … 80 75 // TODO: Default to CRLF on Windows 81 76 get_operations().save_document( 82 *m_ document, get_folder(), m_file_dialog.get_uri(),77 *m_view, get_folder(), m_file_dialog.get_uri(), 83 78 info ? info->encoding : "UTF-8", 84 79 info ? info->eol_style : DocumentInfoStorage::EOL_LF); … … 88 83 } 89 84 90 void Gobby::TaskSave::on_document_removed( DocWindow& document)85 void Gobby::TaskSave::on_document_removed(SessionView& view) 91 86 { 92 87 // The document we are about to save was removed. 93 if(m_ document == &document)88 if(m_view == &view) 94 89 { 95 90 if(m_running) 96 91 finish(); 97 92 else 98 m_ document= NULL;93 m_view = NULL; 99 94 } 100 95 } -
code/commands/file-tasks/task-save.hpp
r3da60b7 r646a4f3 29 29 private: 30 30 FileChooser::Dialog m_file_dialog; 31 DocWindow* m_document;31 TextSessionView* m_view; 32 32 bool m_running; 33 33 34 34 public: 35 TaskSave(FileCommands& file_commands, DocWindow& document);35 TaskSave(FileCommands& file_commands, TextSessionView& view); 36 36 virtual void run(); 37 37 38 38 void on_response(int response_id); 39 void on_document_removed( DocWindow& document);39 void on_document_removed(SessionView& view); 40 40 }; 41 41 -
code/commands/folder-commands.cpp
raeee99c r646a4f3 18 18 19 19 #include "commands/folder-commands.hpp" 20 #include "core/sessionuserview.hpp" 20 21 21 22 #include <libinftextgtk/inf-text-gtk-buffer.h> 22 23 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. 23 29 class Gobby::FolderCommands::DocInfo: public sigc::trackable 24 30 { … … 26 32 static const unsigned int ACTIVATION_DELAY = 1000; 27 33 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( 32 38 sigc::mem_fun( 33 39 *this, &DocInfo::on_active_user_changed)); 34 40 35 on_active_user_changed( document.get_active_user());41 on_active_user_changed(view.get_active_user()); 36 42 } 37 43 … … 52 58 InfTextGtkBuffer* buffer = INF_TEXT_GTK_BUFFER( 53 59 inf_session_get_buffer( 54 INF_SESSION(m_ document.get_session())));60 INF_SESSION(m_view.get_session()))); 55 61 56 62 inf_text_gtk_buffer_set_wake_on_cursor_movement( … … 65 71 InfTextGtkBuffer* buffer = INF_TEXT_GTK_BUFFER( 66 72 inf_session_get_buffer( 67 INF_SESSION(m_ document.get_session())));73 INF_SESSION(m_view.get_session()))); 68 74 69 75 inf_text_gtk_buffer_set_wake_on_cursor_movement( … … 98 104 * again later. */ 99 105 inf_text_session_flush_requests_for_user( 100 m_ document.get_session(),106 m_view.get_session(), 101 107 INF_TEXT_USER(m_active_user)); 102 108 103 109 inf_session_set_user_status( 104 INF_SESSION(m_ document.get_session()),110 INF_SESSION(m_view.get_session()), 105 111 m_active_user, INF_USER_INACTIVE); 106 112 break; … … 191 197 192 198 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, 194 200 INF_USER_ACTIVE); 195 201 … … 197 203 } 198 204 199 DocWindow& m_document;205 TextSessionView& m_view; 200 206 InfUser* m_active_user; 201 207 bool m_active; … … 206 212 207 213 Gobby::FolderCommands::FolderCommands(Folder& folder): 208 m_folder(folder), m_current_ document(NULL)214 m_folder(folder), m_current_view(NULL) 209 215 { 210 216 m_folder.signal_document_added().connect( … … 217 223 for(unsigned int i = 0; i < m_folder.get_n_pages(); ++ i) 218 224 { 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*>( 220 228 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); 224 235 } 225 236 … … 236 247 } 237 248 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) 249 void 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 259 void 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 278 void Gobby::FolderCommands::on_document_changed(SessionView* view) 279 { 280 if(m_current_view != NULL) 261 281 { 262 282 DocumentMap::iterator iter = 263 m_doc_map.find(m_current_ document);283 m_doc_map.find(m_current_view); 264 284 g_assert(iter != m_doc_map.end()); 265 285 … … 267 287 } 268 288 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); 274 294 g_assert(iter != m_doc_map.end()); 275 295 -
code/commands/folder-commands.hpp
r6b79c69 r646a4f3 35 35 protected: 36 36 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); 40 40 41 41 Folder& m_folder; 42 42 43 DocWindow* m_current_document;43 TextSessionView* m_current_view; 44 44 45 45 class DocInfo; 46 typedef std::map< DocWindow*, DocInfo*> DocumentMap;46 typedef std::map<SessionView*, DocInfo*> DocumentMap; 47 47 DocumentMap m_doc_map; 48 48 }; -
code/commands/view-commands.cpp
r6b79c69 r646a4f3 23 23 Preferences& preferences): 24 24 m_header(header), m_folder(folder), m_preferences(preferences), 25 m_current_ document(NULL)25 m_current_view(NULL) 26 26 { 27 27 m_menu_view_toolbar_connection = … … 92 92 } 93 93 94 void Gobby::ViewCommands::on_document_changed( DocWindow* document)95 { 96 if(m_current_ document!= NULL)94 void Gobby::ViewCommands::on_document_changed(SessionView* view) 95 { 96 if(m_current_view != NULL) 97 97 m_document_language_changed_connection.disconnect(); 98 98 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) 102 102 { 103 103 m_header.action_view_highlight_mode->set_sensitive(true); … … 105 105 106 106 m_document_language_changed_connection = 107 document->signal_language_changed().connect(107 m_current_view->signal_language_changed().connect( 108 108 sigc::mem_fun( 109 109 *this, … … 118 118 m_menu_language_changed_connection.unblock(); 119 119 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); 121 122 } 122 123 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); 124 126 } 125 127 … … 194 196 Glib::RefPtr<Header::LanguageAction>::cast_static(action); 195 197 196 g_assert(m_current_ document!= NULL);198 g_assert(m_current_view != NULL); 197 199 198 200 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()); 200 202 m_document_language_changed_connection.unblock(); 201 203 } … … 207 209 (language != NULL) ? 208 210 m_header.lookup_language_action( 209 m_current_ document->get_language()) :211 m_current_view->get_language()) : 210 212 m_header.action_view_highlight_none; 211 213 -
code/commands/view-commands.hpp
r6b79c69 r646a4f3 36 36 37 37 protected: 38 void on_document_changed( DocWindow* document);38 void on_document_changed(SessionView* view); 39 39 40 40 void on_menu_toolbar_toggled(); … … 55 55 Preferences& m_preferences; 56 56 57 DocWindow* m_current_document;57 TextSessionView* m_current_view; 58 58 59 59 sigc::connection m_menu_language_changed_connection; -
code/core/Makefile.am
r0e7581e r646a4f3 5 5 closableframe.cpp \ 6 6 documentinfostorage.cpp \ 7 docwindow.cpp \8 7 filechooser.cpp \ 9 8 folder.cpp \ … … 18 17 statusbar.cpp \ 19 18 tablabel.cpp \ 19 textsessionview.cpp \ 20 20 titlebar.cpp \ 21 21 userlist.cpp … … 25 25 closableframe.hpp \ 26 26 documentinfostorage.hpp \ 27 docwindow.hpp \28 27 filechooser.hpp \ 29 28 folder.hpp \ … … 38 37 statusbar.hpp \ 39 38 tablabel.hpp \ 39 textsessionview.hpp \ 40 40 titlebar.hpp \ 41 41 userlist.hpp -
code/core/folder.cpp
re861d03 r646a4f3 18 18 19 19 #include "core/folder.hpp" 20 #include "core/sessionuserview.hpp" 20 21 #include "core/tablabel.hpp" 21 22 #include "util/closebutton.hpp" … … 112 113 // and records finished. 113 114 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 120 Gobby::TextSessionView& 118 121 Gobby::Folder::add_document(InfTextSession* session, 119 122 const Glib::ustring& title, … … 122 125 const std::string& info_storage_key) 123 126 { 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)); 132 142 tablabel->signal_close_request().connect( 133 143 sigc::bind( 134 144 sigc::mem_fun(*this, &Folder::on_tab_close_request), 135 sigc::ref(* window)));145 sigc::ref(*view))); 136 146 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); 140 150 141 151 // Record the session, for debugging purposes: 142 152 record(session, title); 143 153 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 157 void Gobby::Folder::remove_document(SessionView& view) 158 { 159 m_signal_document_removed.emit(view); 150 160 151 161 // Finish the record 152 Inf TextSession* session = window.get_session();162 InfSession* session = view.get_session(); 153 163 g_object_set_data(G_OBJECT(session), "GOBBY_SESSION_RECORD", NULL); 154 164 155 165 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()); 158 171 g_object_unref(session); 159 172 … … 162 175 } 163 176 164 Gobby:: DocWindow*165 Gobby::Folder::lookup_document(Inf TextSession* session)177 Gobby::SessionView* 178 Gobby::Folder::lookup_document(InfSession* session) 166 179 { 167 180 const PageList& pagelist = pages(); … … 169 182 iter != pagelist.end(); ++ iter) 170 183 { 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(); 176 189 } 177 190 … … 179 192 } 180 193 181 Gobby:: DocWindow*194 Gobby::SessionView* 182 195 Gobby::Folder::get_current_document() 183 196 { 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 204 const Gobby::SessionView* 188 205 Gobby::Folder::get_current_document() const 189 206 { 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 214 void 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 221 void Gobby::Folder::on_tab_close_request(SessionView& view) 222 { 223 if(m_signal_document_close_request.emit(view)) 224 remove_document(view); 202 225 } 203 226 … … 205 228 { 206 229 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()); 209 234 } 210 235 -
code/core/folder.hpp
re861d03 r646a4f3 20 20 #define _GOBBY_FOLDER_HPP_ 21 21 22 #include "core/ docwindow.hpp"22 #include "core/textsessionview.hpp" 23 23 #include "core/preferences.hpp" 24 24 #include "util/defaultaccumulator.hpp" … … 35 35 { 36 36 public: 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; 40 40 41 typedef sigc::signal<bool, DocWindow&>::41 typedef sigc::signal<bool, SessionView&>:: 42 42 accumulated<default_accumulator<bool, true> > 43 43 SignalDocumentCloseRequest; … … 47 47 ~Folder(); 48 48 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); 55 55 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); 60 60 61 SignalDocumentAdded signal_document_added() const { 61 SignalDocumentAdded signal_document_added() const 62 { 62 63 return m_signal_document_added; 63 64 } 64 65 65 SignalDocumentRemoved signal_document_removed() const { 66 SignalDocumentRemoved signal_document_removed() const 67 { 66 68 return m_signal_document_removed; 67 69 } 68 70 69 SignalDocumentChanged signal_document_changed() const { 71 SignalDocumentChanged signal_document_changed() const 72 { 70 73 return m_signal_document_changed; 71 74 } 72 75 73 SignalDocumentCloseRequest signal_document_close_request() const { 76 SignalDocumentCloseRequest signal_document_close_request() const 77 { 74 78 return m_signal_document_close_request; 75 79 } … … 79 83 virtual bool on_key_press_event(GdkEventKey* event); 80 84 81 void on_tab_close_request( DocWindow& window);85 void on_tab_close_request(SessionView& window); 82 86 83 87 Preferences& m_preferences; -
code/core/sessionview.cpp
r0e7581e r646a4f3 22 22 23 23 Gobby::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) 27 30 { 28 31 g_object_ref(m_session); -
code/core/sessionview.hpp
r0e7581e r646a4f3 34 34 { 35 35 public: 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); 37 38 virtual ~SessionView(); 38 39 39 40 const InfSession* get_session() const { return m_session; } 40 41 InfSession* get_session() { return m_session; } 42 41 43 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; } 42 46 43 47 void set_info(const Glib::ustring& info, bool closable); … … 46 50 protected: 47 51 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; 49 56 50 57 Gtk::Frame m_info_frame; -
code/core/statusbar.cpp
r23dfbe6 r646a4f3 64 64 const Preferences& preferences): 65 65 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) 67 67 { 68 68 pack_end(m_bar_position, Gtk::PACK_SHRINK); … … 195 195 } 196 196 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());197 void 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()); 203 203 204 204 g_signal_handler_disconnect(buffer, m_mark_set_handler); 205 205 g_signal_handler_disconnect(buffer, m_changed_handler); 206 206 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 211 void 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()); 217 217 218 218 g_signal_handler_disconnect(buffer, m_mark_set_handler); … … 220 220 } 221 221 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()); 228 228 229 229 m_mark_set_handler = g_signal_connect_after( … … 249 249 { 250 250 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 251 m_current_ document->get_text_buffer());251 m_current_view->get_text_buffer()); 252 252 253 253 if(mark == gtk_text_buffer_get_insert(buffer)) … … 265 265 m_bar_position.remove_message(m_position_context_id); 266 266 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()); 271 271 GtkTextIter iter; 272 272 273 // TODO: Use TextSessionView::get_cursor_position()? 273 274 gtk_text_buffer_get_iter_at_mark( 274 275 buffer, &iter, gtk_text_buffer_get_insert(buffer)); -
code/core/statusbar.hpp
r23dfbe6 r646a4f3 87 87 const MessageHandle& message); 88 88 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); 91 91 void on_view_changed(); 92 92 … … 101 101 102 102 Gtk::Statusbar m_bar_position; 103 DocWindow* m_current_document;103 TextSessionView* m_current_view; 104 104 gulong m_mark_set_handler; 105 105 gulong m_changed_handler; -
code/core/tablabel.cpp
r1fe08b1 r646a4f3 64 64 65 65 66 Gobby::TabLabel::TabLabel(Folder& folder, DocWindow& document):66 Gobby::TabLabel::TabLabel(Folder& folder, TextSessionView& view): 67 67 Gtk::HBox(false, 6), 68 m_folder(folder), m_ document(document),68 m_folder(folder), m_view(view), 69 69 m_dot_char(0), m_changed(false) 70 70 { … … 80 80 81 81 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", 83 83 G_CALLBACK(on_notify_editable_static), this); 84 84 m_notify_status_handle = g_signal_connect( 85 G_OBJECT( document.get_session()), "notify::status",85 G_OBJECT(view.get_session()), "notify::status", 86 86 G_CALLBACK(on_notify_status_static), this); 87 87 m_notify_subscription_group_handle = g_signal_connect( 88 G_OBJECT( document.get_session()),88 G_OBJECT(view.get_session()), 89 89 "notify::subscription-group", 90 90 G_CALLBACK(on_notify_subscription_group_static), this); 91 91 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", 93 93 G_CALLBACK(on_modified_changed_static), this); 94 94 … … 96 96 INF_TEXT_BUFFER( 97 97 inf_session_get_buffer( 98 INF_SESSION( document.get_session())));98 INF_SESSION(view.get_session()))); 99 99 m_insert_text_handle = g_signal_connect_after( 100 100 G_OBJECT(buffer), "insert-text", … … 115 115 Gobby::TabLabel::~TabLabel() 116 116 { 117 g_signal_handler_disconnect(m_ document.get_text_view(),117 g_signal_handler_disconnect(m_view.get_text_view(), 118 118 m_notify_editable_handle); 119 g_signal_handler_disconnect(m_ document.get_session(),119 g_signal_handler_disconnect(m_view.get_session(), 120 120 m_notify_status_handle); 121 g_signal_handler_disconnect(m_ document.get_session(),121 g_signal_handler_disconnect(m_view.get_session(), 122 122 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(), 124 124 m_modified_changed_handle); 125 125 InfTextBuffer* buffer = 126 126 INF_TEXT_BUFFER( 127 127 inf_session_get_buffer( 128 INF_SESSION(m_ document.get_session())));128 INF_SESSION(m_view.get_session()))); 129 129 g_signal_handler_disconnect(buffer, m_erase_text_handle); 130 130 g_signal_handler_disconnect(buffer, m_insert_text_handle); … … 183 183 void Gobby::TabLabel::on_changed(InfTextUser* author) 184 184 { 185 if(m_folder.get_current_document() != &m_ document)185 if(m_folder.get_current_document() != &m_view) 186 186 { 187 187 // TODO: remove dot if all the user's 188 188 // 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()) 191 191 { 192 192 m_changed_by.push_back(UserWatcher(this, author)); … … 197 197 { 198 198 InfSession* session = 199 INF_SESSION(m_ document.get_session());199 INF_SESSION(m_view.get_session()); 200 200 if(inf_session_get_status(session) == 201 201 INF_SESSION_RUNNING) … … 208 208 } 209 209 210 void Gobby::TabLabel::on_folder_document_changed( DocWindow* document)211 { 212 if( document == &m_document)210 void Gobby::TabLabel::on_folder_document_changed(SessionView* view) 211 { 212 if(view == &m_view) 213 213 { 214 214 m_changed_by.clear(); … … 221 221 void Gobby::TabLabel::update_icon() 222 222 { 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()); 225 225 226 226 if(inf_session_get_subscription_group(session) == NULL) … … 257 257 void Gobby::TabLabel::update_color() 258 258 { 259 InfSession* session = INF_SESSION(m_ document.get_session());259 InfSession* session = INF_SESSION(m_view.get_session()); 260 260 261 261 if(m_changed) … … 290 290 void Gobby::TabLabel::update_modified() 291 291 { 292 InfSession* session = INF_SESSION(m_ document.get_session());292 InfSession* session = INF_SESSION(m_view.get_session()); 293 293 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())); 295 295 296 296 if(inf_session_get_status(session) == INF_SESSION_SYNCHRONIZING) … … 298 298 299 299 if(modified) 300 m_title.set_text("*" + m_ document.get_title());300 m_title.set_text("*" + m_view.get_title()); 301 301 else 302 m_title.set_text(m_ document.get_title());302 m_title.set_text(m_view.get_title()); 303 303 } 304 304 -
code/core/tablabel.hpp
r6e7f073 r646a4f3 20 20 #define _GOBBY_TABLABEL_HPP_ 21 21 22 #include "core/ docwindow.hpp"22 #include "core/textsessionview.hpp" 23 23 #include "util/closebutton.hpp" 24 24 … … 39 39 typedef Glib::SignalProxy0<void> SignalCloseRequest; 40 40 41 TabLabel(Folder& folder, DocWindow& document);41 TabLabel(Folder& folder, TextSessionView& view); 42 42 ~TabLabel(); 43 43 … … 103 103 void on_changed(InfTextUser* author); 104 104 105 void on_folder_document_changed( DocWindow* document);105 void on_folder_document_changed(SessionView* view); 106 106 107 107 void update_icon(); … … 111 111 112 112 Folder& m_folder; 113 DocWindow& m_document;113 TextSessionView& m_view; 114 114 115 115 Gtk::Image m_icon; -
code/core/textsessionview.cpp
r2edcdf4 r646a4f3 17 17 */ 18 18 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" 26 20 #include "util/i18n.hpp" 27 21 28 22 #include <gtkmm/scrolledwindow.h> 29 #include <g libmm/pattern.h>23 #include <gtkmm/textiter.h> 30 24 31 25 #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, reparenting36 // into the current DocWindow's frame. Keep dummy widgets in other docwindows,37 // so text does not resize.38 26 39 27 namespace … … 97 85 } 98 86 99 bool tags_priority_idle_func(Gobby:: DocWindow& window)87 bool tags_priority_idle_func(Gobby::TextSessionView& view) 100 88 { 101 89 InfTextGtkBuffer* buffer = INF_TEXT_GTK_BUFFER( 102 90 inf_session_get_buffer( 103 INF_SESSION( window.get_session())));91 INF_SESSION(view.get_session()))); 104 92 105 93 inf_text_gtk_buffer_ensure_author_tags_priority(buffer); … … 107 95 // I don't know why it does not redraw automatically, perhaps 108 96 // 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())); 110 98 return false; 111 99 } … … 120 108 sigc::bind( 121 109 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 116 Gobby::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 { 143 127 InfBuffer* buffer = inf_session_get_buffer(INF_SESSION(session)); 144 128 m_buffer = GTK_SOURCE_BUFFER(inf_text_gtk_buffer_get_text_buffer( … … 162 146 GTK_TEXT_BUFFER(m_buffer)); 163 147 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())); 165 149 166 150 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)); 168 153 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)); 170 156 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)); 172 159 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)); 174 162 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)); 176 165 177 166 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)); 179 169 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)); 181 172 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)); 184 176 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)); 186 179 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)); 188 182 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)); 191 186 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)); 194 190 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)); 196 192 197 193 gtk_source_view_set_tab_width(m_view, m_preferences.editor.tab_width); … … 224 220 const_cast<PangoFontDescription*>(desc.gobj())); 225 221 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 default236 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 default245 246 222 gtk_widget_show(GTK_WIDGET(m_view)); 247 223 Gtk::ScrolledWindow* scroll = Gtk::manage(new Gtk::ScrolledWindow); … … 251 227 scroll->show(); 252 228 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 232 void Gobby::TextSessionView::get_cursor_position(unsigned int& row, 233 unsigned int& col) const 278 234 { 279 235 GtkTextMark* insert_mark = … … 308 264 } 309 265 310 void Gobby:: DocWindow::set_selection(const GtkTextIter* begin,311 const GtkTextIter* end)266 void Gobby::TextSessionView::set_selection(const GtkTextIter* begin, 267 const GtkTextIter* end) 312 268 { 313 269 gtk_text_buffer_select_range( … … 317 273 } 318 274 319 Glib::ustring Gobby:: DocWindow::get_selected_text() const275 Glib::ustring Gobby::TextSessionView::get_selected_text() const 320 276 { 321 277 GtkTextIter start, end; … … 328 284 } 329 285 330 void Gobby:: DocWindow::scroll_to_cursor_position(double within_margin)286 void Gobby::TextSessionView::scroll_to_cursor_position(double within_margin) 331 287 { 332 288 gtk_text_view_scroll_to_mark( … … 337 293 } 338 294 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 295 InfTextUser* Gobby::TextSessionView::get_active_user() const 355 296 { 356 297 InfTextGtkBuffer* buffer = INF_TEXT_GTK_BUFFER( … … 359 300 } 360 301 361 void Gobby:: DocWindow::set_active_user(InfTextUser* user)302 void Gobby::TextSessionView::set_active_user(InfTextUser* user) 362 303 { 363 304 g_assert( … … 384 325 } 385 326 386 GtkSourceLanguage* Gobby:: DocWindow::get_language() const327 GtkSourceLanguage* Gobby::TextSessionView::get_language() const 387 328 { 388 329 return gtk_source_buffer_get_language(m_buffer); 389 330 } 390 331 391 void Gobby:: DocWindow::set_language(GtkSourceLanguage* language)332 void Gobby::TextSessionView::set_language(GtkSourceLanguage* language) 392 333 { 393 334 gtk_source_buffer_set_language(m_buffer, language); … … 395 336 } 396 337 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() 338 void Gobby::TextSessionView::on_user_color_changed() 434 339 { 435 340 InfTextUser* user = get_active_user(); … … 437 342 if(user) 438 343 { 439 inf_text_session_set_user_color( m_session, user,344 inf_text_session_set_user_color(get_session(), user, 440 345 m_preferences.user.hue); 441 346 } 442 347 } 443 348 444 void Gobby:: DocWindow::on_tab_width_changed()349 void Gobby::TextSessionView::on_tab_width_changed() 445 350 { 446 351 gtk_source_view_set_tab_width(m_view, m_preferences.editor.tab_width); 447 352 } 448 353 449 void Gobby:: DocWindow::on_tab_spaces_changed()354 void Gobby::TextSessionView::on_tab_spaces_changed() 450 355 { 451 356 gtk_source_view_set_insert_spaces_instead_of_tabs( … … 453 358 } 454 359 455 void Gobby:: DocWindow::on_auto_indent_changed()360 void Gobby::TextSessionView::on_auto_indent_changed() 456 361 { 457 362 gtk_source_view_set_auto_indent( … … 459 364 } 460 365 461 void Gobby:: DocWindow::on_homeend_smart_changed()366 void Gobby::TextSessionView::on_homeend_smart_changed() 462 367 { 463 368 gtk_source_view_set_smart_home_end( … … 467 372 } 468 373 469 void Gobby:: DocWindow::on_wrap_mode_changed()374 void Gobby::TextSessionView::on_wrap_mode_changed() 470 375 { 471 376 gtk_text_view_set_wrap_mode( … … 474 379 } 475 380 476 void Gobby:: DocWindow::on_linenum_display_changed()381 void Gobby::TextSessionView::on_linenum_display_changed() 477 382 { 478 383 gtk_source_view_set_show_line_numbers( … … 480 385 } 481 386 482 void Gobby:: DocWindow::on_curline_highlight_changed()387 void Gobby::TextSessionView::on_curline_highlight_changed() 483 388 { 484 389 gtk_source_view_set_highlight_current_line( … … 486 391 } 487 392 488 void Gobby:: DocWindow::on_margin_display_changed()393 void Gobby::TextSessionView::on_margin_display_changed() 489 394 { 490 395 gtk_source_view_set_show_right_margin( … … 492 397 } 493 398 494 void Gobby:: DocWindow::on_margin_pos_changed()399 void Gobby::TextSessionView::on_margin_pos_changed() 495 400 { 496 401 gtk_source_view_set_right_margin_position( … … 498 403 } 499 404 500 void Gobby:: DocWindow::on_bracket_highlight_changed()405 void Gobby::TextSessionView::on_bracket_highlight_changed() 501 406 { 502 407 gtk_source_buffer_set_highlight_matching_brackets( … … 504 409 } 505 410 506 void Gobby:: DocWindow::on_whitespace_display_changed()411 void Gobby::TextSessionView::on_whitespace_display_changed() 507 412 { 508 413 gtk_source_view_set_draw_spaces( … … 510 415 } 511 416 512 void Gobby:: DocWindow::on_font_changed()417 void Gobby::TextSessionView::on_font_changed() 513 418 { 514 419 const Pango::FontDescription& desc = m_preferences.appearance.font; … … 518 423 } 519 424 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) 425 bool Gobby::TextSessionView:: 426 on_query_tooltip(int x, int y, bool keyboard_mode, 427 const Glib::RefPtr<Gtk::Tooltip>& tooltip) 548 428 { 549 429 if(keyboard_mode) return false; -
code/core/textsessionview.hpp
r89522f2 r646a4f3 17 17 */ 18 18 19 #ifndef _GOBBY_ DOCWINDOW_HPP_20 #define _GOBBY_ DOCWINDOW_HPP_19 #ifndef _GOBBY_TEXTSESSIONVIEW_HPP_ 20 #define _GOBBY_TEXTSESSIONVIEW_HPP_ 21 21 22 #include "core/ userlist.hpp"22 #include "core/sessionview.hpp" 23 23 #include "core/preferences.hpp" 24 #include "util/closebutton.hpp"25 #include "features.hpp"26 24 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> 32 26 33 27 #include <gtksourceview/gtksourceview.h> 34 28 #include <gtksourceview/gtksourcelanguagemanager.h> 29 #include <gtksourceview/gtksourcelanguage.h> 35 30 36 31 #include <libinftext/inf-text-session.h> … … 40 35 { 41 36 42 class DocWindow: public Gtk::HPaned37 class TextSessionView: public SessionView 43 38 { 44 39 public: … … 46 41 typedef sigc::signal<void, InfTextUser*> SignalActiveUserChanged; 47 42 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); 54 49 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 60 58 const std::string& get_info_storage_key() const 61 59 { … … 78 76 GtkSourceBuffer* get_text_buffer() { return m_buffer; } 79 77 80 void set_info(const Glib::ustring& info, bool closable);81 void unset_info();82 83 78 SignalLanguageChanged signal_language_changed() const 84 79 { … … 92 87 93 88 protected: 94 virtual void on_size_allocate(Gtk::Allocation& allocation);95 96 89 void on_user_color_changed(); 97 90 … … 111 104 void on_font_changed(); 112 105 113 void on_doc_userlist_width_changed();114 void on_pref_userlist_width_changed();115 116 106 bool on_query_tooltip(int x, int y, bool keyboard_mode, 117 107 const Glib::RefPtr<Gtk::Tooltip>& tooltip); … … 122 112 gpointer user_data) 123 113 { 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)); 126 117 } 127 118 128 InfTextSession* m_session;129 Glib::ustring m_title;130 Glib::ustring m_path;131 Glib::ustring m_hostname;132 119 std::string m_info_storage_key; 133 120 Preferences& m_preferences; … … 135 122 GtkSourceView* m_view; 136 123 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;144 124 145 125 SignalLanguageChanged m_signal_language_changed; 146 126 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;150 127 }; 151 128 152 129 } 153 130 154 #endif // _GOBBY_ DOCWINDOW_HPP_131 #endif // _GOBBY_TEXTSESSIONVIEW_HPP_ -
code/core/titlebar.cpp
r6b79c69 r646a4f3 20 20 21 21 Gobby::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) 23 23 { 24 24 folder.signal_document_removed().connect( … … 30 30 } 31 31 32 void Gobby::TitleBar::on_document_removed( DocWindow& document)32 void Gobby::TitleBar::on_document_removed(SessionView& view) 33 33 { 34 if(m_current_document == &document) 34 // TODO: Isn't this called by Folder already? 35 if(m_current_view == &view) 35 36 on_document_changed(NULL); 36 37 } 37 38 38 void Gobby::TitleBar::on_document_changed( DocWindow* document)39 void Gobby::TitleBar::on_document_changed(SessionView* view) 39 40 { 40 if(m_current_ document!= NULL)41 if(m_current_view != NULL) 41 42 { 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); 46 45 47 46 g_signal_handler_disconnect(G_OBJECT(session), … … 51 50 } 52 51 53 m_current_ document = document;52 m_current_view = view; 54 53 55 if( document!= NULL)54 if(view != NULL) 56 55 { 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); 60 58 61 59 m_notify_status_handler = g_signal_connect( … … 63 61 G_CALLBACK(on_notify_status_static), this); 64 62 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); 67 65 } 68 66 … … 75 73 } 76 74 77 void Gobby::TitleBar::on_ modified_changed()75 void Gobby::TitleBar::on_notify_modified() 78 76 { 79 77 update_title(); … … 84 82 // TODO: Show path, as gedit does. This requires change notification 85 83 // for document info storage. 86 if(m_current_ document!= NULL)84 if(m_current_view != NULL) 87 85 { 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); 92 88 93 89 InfSessionStatus status = inf_session_get_status(session); 94 90 if(status == INF_SESSION_SYNCHRONIZING || 95 ! gtk_text_buffer_get_modified(buffer))91 !inf_buffer_get_modified(buffer)) 96 92 { 97 93 m_window.set_title( 98 m_current_ document->get_title() + " - Gobby");94 m_current_view->get_title() + " - Gobby"); 99 95 } 100 96 else 101 97 { 102 98 m_window.set_title( 103 "*" + m_current_ document->get_title() +99 "*" + m_current_view->get_title() + 104 100 " - Gobby"); 105 101 } -
code/core/titlebar.hpp
r6b79c69 r646a4f3 21 21 22 22 #include "core/folder.hpp" 23 #include "core/ docwindow.hpp"23 #include "core/sessionview.hpp" 24 24 25 25 #include <gtkmm/window.h> … … 42 42 } 43 43 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) 46 47 { 47 static_cast<TitleBar*>(user_data)->on_ modified_changed();48 static_cast<TitleBar*>(user_data)->on_notify_modified(); 48 49 } 49 50 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); 52 53 53 54 void on_notify_status(); 54 void on_ modified_changed();55 void on_notify_modified(); 55 56 56 57 void update_title(); … … 58 59 Gtk::Window& m_window; 59 60 Folder& m_folder; 60 DocWindow* m_current_document;61 SessionView* m_current_view; 61 62 62 63 gulong m_notify_status_handler; -
code/core/userlist.cpp
r2edcdf4 r646a4f3 192 192 if(pixbuf) 193 193 { 194 pixbuf_renderer->property_pixbuf() ;194 pixbuf_renderer->property_pixbuf() = pixbuf; 195 195 pixbuf_renderer->property_visible() = true; 196 196 } -
code/dialogs/find-dialog.cpp
r23dfbe6 r646a4f3 214 214 } 215 215 216 void Gobby::FindDialog::on_document_changed( DocWindow* document)216 void Gobby::FindDialog::on_document_changed(SessionView* view) 217 217 { 218 218 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) 221 222 { 222 223 m_active_user_changed_connection = 223 document->signal_active_user_changed().connect(224 text_view->signal_active_user_changed().connect( 224 225 sigc::mem_fun( 225 226 *this, … … 264 265 bool Gobby::FindDialog::replace() 265 266 { 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); 268 270 269 271 // Get selected string 270 Glib::ustring sel_str = document->get_selected_text();272 Glib::ustring sel_str = text_view->get_selected_text(); 271 273 Glib::ustring find_str = get_find_text(); 272 274 … … 282 284 { 283 285 GtkTextBuffer* buffer = 284 GTK_TEXT_BUFFER( document->get_text_buffer());286 GTK_TEXT_BUFFER(text_view->get_text_buffer()); 285 287 286 288 // Replace occurence … … 303 305 bool Gobby::FindDialog::replace_all() 304 306 { 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); 307 312 308 313 GtkTextIter begin; 309 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( document->get_text_buffer());314 GtkTextBuffer* buffer = GTK_TEXT_BUFFER(text_view->get_text_buffer()); 310 315 gtk_text_buffer_get_start_iter(buffer, &begin); 311 316 … … 349 354 SearchDirection direction) 350 355 { 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); 353 359 354 360 const GtkTextIter* real_begin = from; … … 359 365 { 360 366 GtkTextBuffer* buffer = 361 GTK_TEXT_BUFFER( document->get_text_buffer());367 GTK_TEXT_BUFFER(text_view->get_text_buffer()); 362 368 GtkTextMark* mark = gtk_text_buffer_get_insert(buffer); 363 369 gtk_text_buffer_get_iter_at_mark(buffer, &insert_iter, mark); … … 369 375 { 370 376 if(direction == SEARCH_FORWARD) 371 document->set_selection(&match_end, &match_start);377 text_view->set_selection(&match_end, &match_start); 372 378 else 373 document->set_selection(&match_start, &match_end);379 text_view->set_selection(&match_start, &match_end); 374 380 375 381 return true; … … 384 390 GtkTextIter* match_end) 385 391 { 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); 388 395 389 396 GtkTextIter start_pos = *from; … … 397 404 // Wrap around 398 405 GtkTextIter restart_pos; 399 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( document->get_text_buffer());406 GtkTextBuffer* buffer = GTK_TEXT_BUFFER(text_view->get_text_buffer()); 400 407 401 408 if(direction == SEARCH_FORWARD) … … 479 486 void Gobby::FindDialog::update_sensitivity() 480 487 { 481 DocWindow* document = m_folder.get_current_document(); 488 SessionView* view = m_folder.get_current_document(); 489 TextSessionView* text_view = dynamic_cast<TextSessionView*>(view); 482 490 483 491 bool find_sensitivity = 484 (!m_entry_find.get_text().empty() && document!= NULL);492 (!m_entry_find.get_text().empty() && text_view != NULL); 485 493 bool replace_sensitivity = 486 (find_sensitivity && document->get_active_user() != NULL);494 (find_sensitivity && text_view->get_active_user() != NULL); 487 495 488 496 set_response_sensitive(RESPONSE_FIND, find_sensitivity); -
code/dialogs/find-dialog.hpp
rd9e7c10 r646a4f3 22 22 #include "core/folder.hpp" 23 23 #include "core/statusbar.hpp" 24 #include "core/ docwindow.hpp"24 #include "core/sessionview.hpp" 25 25 26 26 #include <gtkmm/dialog.h> … … 71 71 virtual void on_response(int id); 72 72 73 void on_document_changed( DocWindow* document);73 void on_document_changed(SessionView* view); 74 74 void on_active_user_changed(InfTextUser* user); 75 75 void on_find_text_changed(); -
code/dialogs/goto-dialog.cpp
rd9e7c10 r646a4f3 30 30 m_label_line(_("Line _number:"), Gtk::ALIGN_LEFT, 31 31 Gtk::ALIGN_CENTER, true), 32 m_current_ document(NULL)32 m_current_view(NULL) 33 33 { 34 34 m_label_line.set_mnemonic_widget(m_entry_line); … … 75 75 m_entry_line.grab_focus(); 76 76 77 if(m_current_ document!= NULL)77 if(m_current_view != NULL) 78 78 { 79 79 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 80 m_current_ document->get_text_buffer());80 m_current_view->get_text_buffer()); 81 81 GtkTextIter cursor; 82 82 gtk_text_buffer_get_iter_at_mark( … … 93 93 if(id == Gtk::RESPONSE_ACCEPT) 94 94 { 95 g_assert(m_current_ document!= NULL);95 g_assert(m_current_view != NULL); 96 96 97 97 int value = m_entry_line.get_value_as_int(); 98 98 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 99 m_current_ document->get_text_buffer());99 m_current_view->get_text_buffer()); 100 100 GtkTextIter begin; 101 101 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); 103 103 } 104 104 else if(id == Gtk::RESPONSE_CLOSE) … … 110 110 } 111 111 112 void Gobby::GotoDialog::on_document_changed( DocWindow* document)112 void Gobby::GotoDialog::on_document_changed(SessionView* view) 113 113 { 114 if(m_current_ document!= NULL)114 if(m_current_view != NULL) 115 115 { 116 116 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 117 m_current_ document->get_text_buffer());117 m_current_view->get_text_buffer()); 118 118 g_signal_handler_disconnect(buffer, m_changed_handler); 119 119 } 120 120 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); 124 124 125 if( document!= NULL)125 if(m_current_view != NULL) 126 126 { 127 127 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 128 document->get_text_buffer());128 m_current_view->get_text_buffer()); 129 129 130 130 m_changed_handler = g_signal_connect_after( … … 138 138 void Gobby::GotoDialog::on_changed() 139 139 { 140 g_assert(m_current_ document!= NULL);140 g_assert(m_current_view != NULL); 141 141 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 142 m_current_ document->get_text_buffer());142 m_current_view->get_text_buffer()); 143 143 144 144 m_entry_line.set_range(1, gtk_text_buffer_get_line_count(buffer)); -
code/dialogs/goto-dialog.hpp
rd9e7c10 r646a4f3 21 21 22 22 #include "core/folder.hpp" 23 #include "core/ docwindow.hpp"23 #include "core/sessionview.hpp" 24 24 25 25 #include <gtkmm/dialog.h> … … 47 47 virtual void on_response(int id); 48 48 49 void on_document_changed( DocWindow* document);49 void on_document_changed(SessionView* view); 50 50 void on_changed(); 51 51 … … 57 57 Gtk::SpinButton m_entry_line; 58 58 59 DocWindow* m_current_document;59 TextSessionView* m_current_view; 60 60 gulong m_changed_handler; 61 61 }; -
code/operations/operation-export-html.cpp
r23dfbe6 r646a4f3 105 105 // save all users and tags encountered and the total number of 106 106 // lines dumped 107 void dump_buffer(Gobby:: DocWindow& document,107 void dump_buffer(Gobby::TextSessionView& view, 108 108 xmlpp::Element* content, 109 109 std::set<InfTextUser*>& users, … … 121 121 122 122 GtkTextBuffer* buffer = GTK_TEXT_BUFFER( 123 document.get_text_buffer());123 view.get_text_buffer()); 124 124 InfTextGtkBuffer* inf_buffer 125 125 = INF_TEXT_GTK_BUFFER( 126 126 inf_session_get_buffer( 127 INF_SESSION( document.get_session())));127 INF_SESSION(view.get_session()))); 128 128 129 129 GtkTextIter begin; … … 223 223 // some random interesting information/advertisement to be put at 224 224 // 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) 226 226 { 227 227 using namespace Gobby; … … 240 240 } 241 241 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(); 244 244 245 245 // %1$s is session name/hostname … … 349 349 // generate xhtml representation of the document and write it to the 350 350 // specified location in the filesystem 351 std::string export_html(Gobby:: DocWindow& document)351 std::string export_html(Gobby::TextSessionView& view) 352 352 { 353 353 using namespace Gobby; … … 379 379 icon->set_attribute("class", "icon"); 380 380 381 const Glib::ustring& document_name = document.get_title();381 const Glib::ustring& document_name = view.get_title(); 382 382 title->add_child_text(document_name + " - infinote document"); 383 383 … … 389 389 priority_tag_set tags; 390 390 unsigned int line_counter; 391 dump_buffer( document, content, users, tags, line_counter);391 dump_buffer(view, content, users, tags, line_counter); 392 392 393 393 h2->add_child_text(_("Participants")); 394 394 395 395 info->set_attribute("class", "info"); 396 dump_info(info, document);396 dump_info(info, view); 397 397 398 398 style->set_attribute("type", "text/css"); … … 441 441 442 442 Gobby::OperationExportHtml::OperationExportHtml(Operations& operations, 443 DocWindow& document,443 TextSessionView& view, 444 444 const std::string& uri): 445 445 Operation(operations), m_index(0), 446 m_xml(export_html( document))446 m_xml(export_html(view)) 447 447 { 448 448 m_file = Gio::File::create_for_uri(uri); … … 453 453 Glib::ustring::compose( 454 454 _("Exporting document %1 to %2 in HTML..."), 455 document.get_title(), uri));455 view.get_title(), uri)); 456 456 } 457 457 -
code/operations/operation-export-html.hpp
re275a84 r646a4f3 34 34 { 35 35 public: 36 OperationExportHtml(Operations& operations, DocWindow& document,36 OperationExportHtml(Operations& operations, TextSessionView& view, 37 37 const std::string& uri); 38 38 -
code/operations/operation-save.cpp
r23dfbe6 r646a4f3 24 24 25 25 Gobby::OperationSave::OperationSave(Operations& operations, 26 DocWindow& document,26 TextSessionView& view, 27 27 Folder& folder, 28 28 const std::string& uri, 29 29 const std::string& encoding, 30 30 DocumentInfoStorage::EolStyle eol_style): 31 Operation(operations), m_ document(&document),31 Operation(operations), m_view(&view), 32 32 m_start_time(std::time(NULL)), m_current_line_index(0), 33 33 m_iconv(encoding.c_str(), "UTF-8"), m_encoding(encoding), 34 34 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), 36 36 m_buffer_index(0) 37 37 { 38 38 // 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()); 40 40 GtkTextIter prev; 41 41 GtkTextIter pos; … … 72 72 m_message_handle = get_status_bar().add_info_message( 73 73 Glib::ustring::compose(_("Saving document %1 to %2..."), 74 document.get_title(), uri));74 view.get_title(), uri)); 75 75 76 76 folder.signal_document_removed().connect( … … 96 96 } 97 97 98 void Gobby::OperationSave::on_document_removed( DocWindow& document)98 void Gobby::OperationSave::on_document_removed(SessionView& view) 99 99 { 100 100 // We keep the document to unset the modified flag when the operation 101 101 // is complete, however, if the document is removed in the meanwhile, 102 102 // 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; 105 105 } 106 106 … … 154 154 m_stream->close(); 155 155 156 if(m_ document!= NULL)156 if(m_view != NULL) 157 157 { 158 158 // TODO: Don't unset modified flag if the document has … … 160 160 // buffer-modified-time in algorithm. 161 161 gtk_text_buffer_set_modified( 162 GTK_TEXT_BUFFER( 163 m_document->get_text_buffer()), 162 GTK_TEXT_BUFFER(m_view->get_text_buffer()), 164 163 FALSE); 165 164 } -
code/operations/operation-save.hpp
r6b79c69 r646a4f3 34 34 { 35 35 public: 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, 37 39 Folder& folder, const std::string& uri, 38 40 const std::string& encoding, … … 41 43 virtual ~OperationSave(); 42 44 43 // Note these can return NULL in case the document has been removed45 // Note these can return NULL in case the view has been closed 44 46 // 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; } 47 49 48 50 std::time_t get_start_time() const { return m_start_time; } 49 51 50 52 protected: 51 void on_document_removed( DocWindow& document);53 void on_document_removed(SessionView& view); 52 54 void on_file_replace(const Glib::RefPtr<Gio::AsyncResult>& result); 53 55 void on_stream_write(const Glib::RefPtr<Gio::AsyncResult>& result); … … 57 59 void error(const Glib::ustring& message); 58 60 protected: 59 DocWindow* m_document;61 TextSessionView* m_view; 60 62 std::time_t m_start_time; 61 63 -
code/operations/operations.cpp
re275a84 r646a4f3 101 101 102 102 Gobby::OperationSave* 103 Gobby::Operations::save_document( DocWindow& document,103 Gobby::Operations::save_document(TextSessionView& view, 104 104 Folder& folder, 105 105 const std::string& uri, … … 107 107 DocumentInfoStorage::EolStyle eol_style) 108 108 { 109 OperationSave* prev_op = get_save_operation_for_document( document);109 OperationSave* prev_op = get_save_operation_for_document(view); 110 110 111 111 // Cancel previous save operation: … … 113 113 fail_operation(prev_op); 114 114 115 OperationSave* op = new OperationSave(*this, document, folder, uri,115 OperationSave* op = new OperationSave(*this, view, folder, uri, 116 116 encoding, eol_style); 117 117 … … 131 131 132 132 Gobby::OperationExportHtml* 133 Gobby::Operations::export_html( DocWindow& document,133 Gobby::Operations::export_html(TextSessionView& view, 134 134 const std::string& uri) 135 135 { 136 136 OperationExportHtml* op = 137 new OperationExportHtml(*this, document, uri);137 new OperationExportHtml(*this, view, uri); 138 138 m_operations.insert(op); 139 139 return op; … … 141 141 142 142 Gobby::OperationSave* 143 Gobby::Operations::get_save_operation_for_document( DocWindow& document)143 Gobby::Operations::get_save_operation_for_document(TextSessionView& view) 144 144 { 145 145 for(OperationSet::iterator iter = m_operations.begin(); … … 150 150 if(save_op != NULL) 151 151 { 152 if(save_op->get_ document() == &document)152 if(save_op->get_view() == &view) 153 153 return save_op; 154 154 } -
code/operations/operations.hpp
re275a84 r646a4f3 22 22 #include "core/documentinfostorage.hpp" 23 23 #include "core/statusbar.hpp" 24 #include "core/textsessionview.hpp" 24 25 25 26 #include <libinfinity/client/infc-browser.h> … … 109 110 unsigned int num_uris); 110 111 111 OperationSave* save_document( DocWindow& document,112 OperationSave* save_document(TextSessionView& view, 112 113 Folder& folder, 113 114 const std::string& uri, … … 118 119 const InfcBrowserIter* iter); 119 120 120 OperationExportHtml* export_html( DocWindow& document,121 OperationExportHtml* export_html(TextSessionView& view, 121 122 const std::string& uri); 122 123 123 OperationSave* get_save_operation_for_document( DocWindow& window);124 OperationSave* get_save_operation_for_document(TextSessionView& view); 124 125 125 126 SignalBeginSaveOperation signal_begin_save_operation() const -
code/window.cpp
rd26c3b9 r646a4f3 22 22 #include "commands/file-tasks/task-open.hpp" 23 23 #include "commands/file-tasks/task-open-multiple.hpp" 24 #include "core/docwindow.hpp"25 24 #include "core/iconmanager.hpp" 26 25 #include "core/noteplugin.hpp"
