Changeset e51abc748ac27b1dfa0fccd9de3ba9cdecb743f0
- Timestamp:
- 01/06/07 23:33:33 (6 years ago)
- Author:
- Philipp Kern <phil@…>
- Parents:
- 93ca35407082705407d4ec2fb58c684dab77407d
- Children:
- 0f676825acafe08500114fc64f438732f780fb0a
- git-committer:
- Philipp Kern <phil@0x539.de> / 2007-01-06T22:33:33Z+0000
- Message:
-
[project @ StatusBar? showing cursor position and current language]
Original author: Armin Burgmeier <armin@…>
Date: 2005-05-06 19:48:57+00:00
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r623510b
|
re51abc7
|
|
| 26 | 26 | noinst_HEADERS += inc/logview.hpp |
| 27 | 27 | noinst_HEADERS += inc/document.hpp |
| | 28 | noinst_HEADERS += inc/statusbar.hpp |
| 28 | 29 | noinst_HEADERS += inc/header.hpp |
| 29 | 30 | noinst_HEADERS += inc/folder.hpp |
| … |
… |
|
| 56 | 57 | gobby_SOURCES += src/logview.cpp |
| 57 | 58 | gobby_SOURCES += src/document.cpp |
| | 59 | gobby_SOURCES += src/statusbar.cpp |
| 58 | 60 | gobby_SOURCES += src/header.cpp |
| 59 | 61 | gobby_SOURCES += src/folder.cpp |
-
|
r93ca354
|
re51abc7
|
|
| 14 | 14 | * Initialise size of paned widgets |
| 15 | 15 | * configure should detect the presence of gtksourceview automatically |
| 16 | | * Implement a statusbar |
| 17 | | - Cursor position |
| 18 | | - Current highlighting scheme |
| 19 | | - Current syncronisation state |
| 20 | 16 | * Prompt before overwriting existing files when explicitly choosing path |
| 21 | 17 | * Chat command infrastructure (/me, /ignore) |
-
|
rfa007f9
|
re51abc7
|
|
| 33 | 33 | { |
| 34 | 34 | |
| | 35 | class Folder; |
| | 36 | |
| 35 | 37 | class Document : public Gtk::ScrolledWindow |
| 36 | 38 | { |
| 37 | 39 | public: |
| 38 | 40 | typedef std::map<Glib::ustring, Glib::ustring> MimeMap; |
| | 41 | typedef sigc::signal<void> signal_update_type; |
| 39 | 42 | |
| 40 | | Document(obby::document& doc); |
| | 43 | Document(obby::document& doc, const Folder& folder); |
| 41 | 44 | virtual ~Document(); |
| 42 | 45 | |
| … |
… |
|
| 44 | 47 | obby::document& get_document(); |
| 45 | 48 | |
| | 49 | // Statusbar information |
| | 50 | void get_cursor_position(unsigned int& row, unsigned int& col); |
| | 51 | unsigned int get_unsynced_changes_count() const; |
| | 52 | #ifdef WITH_GTKSOURCEVIEW |
| | 53 | Glib::RefPtr<Gtk::SourceLanguage> get_language() const; |
| | 54 | #endif |
| | 55 | |
| | 56 | /** Signal which will be emitted if the document gets updated in a way |
| | 57 | * that is interesting for the status bar. |
| | 58 | */ |
| | 59 | signal_update_type update_event() const; |
| | 60 | |
| 46 | 61 | protected: |
| 47 | | void on_insert(const Gtk::TextBuffer::iterator& begin, |
| 48 | | const Glib::ustring& text, |
| 49 | | int bytes); |
| 50 | | void on_erase(const Gtk::TextBuffer::iterator& begin, |
| 51 | | const Gtk::TextBuffer::iterator& end); |
| | 62 | void on_insert_before(const Gtk::TextBuffer::iterator& begin, |
| | 63 | const Glib::ustring& text, |
| | 64 | int bytes); |
| | 65 | void on_erase_before(const Gtk::TextBuffer::iterator& begin, |
| | 66 | const Gtk::TextBuffer::iterator& end); |
| 52 | 67 | |
| 53 | 68 | void on_obby_insert(const obby::insert_record& record); |
| 54 | 69 | void on_obby_delete(const obby::delete_record& record); |
| 55 | 70 | |
| | 71 | void on_insert_after(const Gtk::TextBuffer::iterator& begin, |
| | 72 | const Glib::ustring& text, |
| | 73 | int bytes); |
| | 74 | void on_erase_after(const Gtk::TextBuffer::iterator& begin, |
| | 75 | const Gtk::TextBuffer::iterator& end); |
| | 76 | |
| | 77 | void on_cursor_changed(const Gtk::TextBuffer::iterator& location, |
| | 78 | const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark); |
| | 79 | |
| 56 | 80 | obby::document& m_doc; |
| | 81 | const Folder& m_folder; |
| | 82 | |
| 57 | 83 | #ifdef WITH_GTKSOURCEVIEW |
| 58 | 84 | Gtk::SourceView m_view; |
| … |
… |
|
| 62 | 88 | #endif |
| 63 | 89 | bool m_editing; |
| | 90 | |
| | 91 | signal_update_type m_signal_update; |
| 64 | 92 | |
| 65 | 93 | public: |
| … |
… |
|
| 68 | 96 | static const MimeMap& m_mime_map; |
| 69 | 97 | #endif |
| 70 | | |
| 71 | 98 | }; |
| 72 | 99 | |
-
|
raf22cb3
|
re51abc7
|
|
| 20 | 20 | #define _GOBBY_FOLDER_HPP_ |
| 21 | 21 | |
| | 22 | #include <sigc++/signal.h> |
| 22 | 23 | #include <gtkmm/notebook.h> |
| 23 | 24 | #include <obby/user.hpp> |
| 24 | 25 | #include <obby/document.hpp> |
| | 26 | #include "document.hpp" |
| | 27 | #include "sourceview/sourcelanguage.hpp" |
| 25 | 28 | |
| 26 | 29 | namespace Gobby |
| … |
… |
|
| 33 | 36 | { |
| 34 | 37 | public: |
| | 38 | typedef sigc::signal<void, Document&> signal_document_update_type; |
| | 39 | |
| 35 | 40 | Folder(); |
| 36 | 41 | ~Folder(); |
| … |
… |
|
| 44 | 49 | void obby_document_remove(obby::document& document); |
| 45 | 50 | |
| | 51 | signal_document_update_type document_update_event() const; |
| | 52 | |
| 46 | 53 | protected: |
| | 54 | // Signal handlers |
| | 55 | virtual void on_switch_page(GtkNotebookPage* page, guint page_num); |
| | 56 | virtual void on_document_update(Document& document); |
| | 57 | |
| | 58 | signal_document_update_type m_signal_document_update; |
| 47 | 59 | }; |
| 48 | 60 | |
-
|
r1d79f14
|
re51abc7
|
|
| 47 | 47 | private: |
| 48 | 48 | friend class SourceLanguage_Class; |
| 49 | | static CppClassType sourcelanguage_class_; |
| 50 | 49 | |
| 51 | 50 | // noncopyable |
| … |
… |
|
| 57 | 56 | // though... |
| 58 | 57 | public: |
| | 58 | static CppClassType sourcelanguage_class_; |
| 59 | 59 | SourceLanguage(); |
| 60 | 60 | explicit SourceLanguage(const Glib::ConstructParams& construct_params); |
-
|
ra0556f0
|
re51abc7
|
|
| 29 | 29 | #include "userlist.hpp" |
| 30 | 30 | #include "chat.hpp" |
| | 31 | #include "statusbar.hpp" |
| 31 | 32 | |
| 32 | 33 | namespace Gobby |
| … |
… |
|
| 54 | 55 | |
| 55 | 56 | void on_chat(const Glib::ustring& message); |
| | 57 | void on_document_update(Document& document); |
| 56 | 58 | |
| 57 | 59 | // Obby signal handlers |
| … |
… |
|
| 77 | 79 | Gtk::VBox m_mainbox; |
| 78 | 80 | Header m_header; |
| | 81 | StatusBar m_statusbar; |
| 79 | 82 | |
| 80 | 83 | Gtk::VPaned m_mainpaned; |
-
|
r6c9d740
|
re51abc7
|
|
| 17 | 17 | */ |
| 18 | 18 | |
| | 19 | #include <obby/client_document.hpp> |
| 19 | 20 | #ifdef WITH_GTKSOURCEVIEW |
| 20 | 21 | #include "sourceview/sourcelanguagesmanager.hpp" |
| 21 | 22 | #endif |
| 22 | 23 | #include "document.hpp" |
| | 24 | #include "folder.hpp" |
| 23 | 25 | |
| 24 | 26 | #ifdef WITH_GTKSOURCEVIEW |
| … |
… |
|
| 27 | 29 | #endif |
| 28 | 30 | |
| 29 | | Gobby::Document::Document(obby::document& doc) |
| 30 | | : Gtk::ScrolledWindow(), m_doc(doc), m_editing(true) |
| | 31 | Gobby::Document::Document(obby::document& doc, const Folder& folder) |
| | 32 | : Gtk::ScrolledWindow(), m_doc(doc), m_folder(folder), m_editing(true) |
| 31 | 33 | #ifdef WITH_GTKSOURCEVIEW |
| 32 | 34 | ,m_lang_manager(Gtk::SourceLanguagesManager::create() ) |
| … |
… |
|
| 84 | 86 | // Textbuffer signal handlers |
| 85 | 87 | buf->signal_insert().connect( |
| 86 | | sigc::mem_fun(*this, &Document::on_insert), false); |
| | 88 | sigc::mem_fun(*this, &Document::on_insert_before), false); |
| 87 | 89 | buf->signal_erase().connect( |
| 88 | | sigc::mem_fun(*this, &Document::on_erase), false); |
| | 90 | sigc::mem_fun(*this, &Document::on_erase_before), false); |
| | 91 | buf->signal_insert().connect( |
| | 92 | sigc::mem_fun(*this, &Document::on_insert_after), true); |
| | 93 | buf->signal_erase().connect( |
| | 94 | sigc::mem_fun(*this, &Document::on_erase_after), true); |
| | 95 | buf->signal_mark_set().connect( |
| | 96 | sigc::mem_fun(*this, &Document::on_cursor_changed) ); |
| 89 | 97 | |
| 90 | 98 | // Obby signal handlers |
| … |
… |
|
| 117 | 125 | } |
| 118 | 126 | |
| 119 | | void Gobby::Document::on_insert(const Gtk::TextBuffer::iterator& begin, |
| 120 | | const Glib::ustring& text, |
| 121 | | int bytes) |
| | 127 | Gobby::Document::signal_update_type Gobby::Document::update_event() const |
| | 128 | { |
| | 129 | return m_signal_update; |
| | 130 | } |
| | 131 | |
| | 132 | void Gobby::Document::get_cursor_position(unsigned int& row, |
| | 133 | unsigned int& col) |
| | 134 | { |
| | 135 | // Get insert mark |
| | 136 | Glib::RefPtr<Gtk::TextBuffer::Mark> mark = |
| | 137 | m_view.get_buffer()->get_mark("insert"); |
| | 138 | |
| | 139 | // Get corresponding iterator |
| | 140 | // Gtk::TextBuffer::Mark::get_iter is not const. Why not? It prevents |
| | 141 | // this function from being const. |
| | 142 | const Gtk::TextBuffer::iterator iter = mark->get_iter(); |
| | 143 | |
| | 144 | // Read line and column |
| | 145 | row = iter.get_line(); |
| | 146 | col = iter.get_line_offset(); |
| | 147 | } |
| | 148 | |
| | 149 | unsigned int Gobby::Document::get_unsynced_changes_count() const |
| | 150 | { |
| | 151 | obby::client_document* doc = |
| | 152 | dynamic_cast<obby::client_document*>(&m_doc); |
| | 153 | |
| | 154 | // Changes in Server/Host documents are always synced |
| | 155 | if(doc == NULL) |
| | 156 | return 0; |
| | 157 | |
| | 158 | return doc->get_unsynced_changes_count(); |
| | 159 | } |
| | 160 | |
| | 161 | #ifdef WITH_GTKSOURCEVIEW |
| | 162 | Glib::RefPtr<Gtk::SourceLanguage> Gobby::Document::get_language() const |
| | 163 | { |
| | 164 | return m_view.get_buffer()->get_language(); |
| | 165 | } |
| | 166 | #endif |
| | 167 | |
| | 168 | void Gobby::Document::on_insert_before(const Gtk::TextBuffer::iterator& begin, |
| | 169 | const Glib::ustring& text, |
| | 170 | int bytes) |
| 122 | 171 | { |
| 123 | 172 | if(m_editing) return; |
| … |
… |
|
| 135 | 184 | } |
| 136 | 185 | |
| 137 | | void Gobby::Document::on_erase(const Gtk::TextBuffer::iterator& begin, |
| 138 | | const Gtk::TextBuffer::iterator& end) |
| | 186 | void Gobby::Document::on_erase_before(const Gtk::TextBuffer::iterator& begin, |
| | 187 | const Gtk::TextBuffer::iterator& end) |
| 139 | 188 | { |
| 140 | 189 | if(m_editing) return; |
| … |
… |
|
| 190 | 239 | } |
| 191 | 240 | |
| | 241 | void Gobby::Document::on_insert_after(const Gtk::TextBuffer::iterator& begin, |
| | 242 | const Glib::ustring& text, |
| | 243 | int bytes) |
| | 244 | { |
| | 245 | // Document changed: Update statusbar |
| | 246 | m_signal_update.emit(); |
| | 247 | } |
| | 248 | |
| | 249 | void Gobby::Document::on_erase_after(const Gtk::TextBuffer::iterator& begin, |
| | 250 | const Gtk::TextBuffer::iterator& end) |
| | 251 | { |
| | 252 | // Document changed: Update statusbar |
| | 253 | m_signal_update.emit(); |
| | 254 | } |
| | 255 | |
| | 256 | void Gobby::Document::on_cursor_changed( |
| | 257 | const Gtk::TextBuffer::iterator& location, |
| | 258 | const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark |
| | 259 | ) |
| | 260 | { |
| | 261 | // Insert mark changed position: Update status bar |
| | 262 | if(mark->get_name() == "insert") |
| | 263 | m_signal_update.emit(); |
| | 264 | } |
| | 265 | |
| 192 | 266 | #ifdef WITH_GTKSOURCEVIEW |
| 193 | 267 | const Gobby::Document::MimeMap& Gobby::Document::create_mime_map() |
| … |
… |
|
| 204 | 278 | map["cc"] = "text/x-c++"; |
| 205 | 279 | map["css"] = "text/css"; |
| | 280 | map["cs"] = "text/x-csharp"; |
| 206 | 281 | map["diff"] = "text/x-diff"; |
| 207 | 282 | map["f"] = "text/x-fortran"; |
-
|
r81f826c
|
re51abc7
|
|
| 61 | 61 | void Gobby::Folder::obby_document_insert(obby::document& document) |
| 62 | 62 | { |
| 63 | | Document* new_doc = new Document(document); |
| | 63 | Document* new_doc = new Document(document, *this); |
| | 64 | new_doc->update_event().connect( |
| | 65 | sigc::bind( |
| | 66 | sigc::mem_fun(*this, &Folder::on_document_update), |
| | 67 | sigc::ref(*new_doc) |
| | 68 | ) |
| | 69 | ); |
| | 70 | |
| 64 | 71 | append_page(*new_doc, document.get_title()); |
| 65 | 72 | new_doc->show_all(); |
| … |
… |
|
| 80 | 87 | } |
| 81 | 88 | |
| | 89 | Gobby::Folder::signal_document_update_type |
| | 90 | Gobby::Folder::document_update_event() const |
| | 91 | { |
| | 92 | return m_signal_document_update; |
| | 93 | } |
| | 94 | |
| | 95 | void Gobby::Folder::on_switch_page(GtkNotebookPage* page, guint page_num) |
| | 96 | { |
| | 97 | m_signal_document_update.emit( |
| | 98 | *static_cast<Document*>(get_nth_page(page_num)) |
| | 99 | ); |
| | 100 | Gtk::Notebook::on_switch_page(page, page_num); |
| | 101 | } |
| | 102 | |
| | 103 | void Gobby::Folder::on_document_update(Document& document) |
| | 104 | { |
| | 105 | if(get_current_page() == page_num(document) ) |
| | 106 | m_signal_document_update.emit(document); |
| | 107 | } |
| | 108 | |
-
|
r1d79f14
|
re51abc7
|
|
| 525 | 525 | Glib::RefPtr<Gtk::SourceLanguage> Gtk::SourceBuffer::get_language() const |
| 526 | 526 | { |
| 527 | | return Glib::wrap(gtk_source_buffer_get_language( |
| 528 | | const_cast<GtkSourceBuffer*>(gobj()) |
| 529 | | ) ); |
| | 527 | GtkSourceBuffer* self = const_cast<GtkSourceBuffer*>(gobj() ); |
| | 528 | if(gtk_source_buffer_get_language(self) == NULL) |
| | 529 | return Glib::RefPtr<Gtk::SourceLanguage>(NULL); |
| | 530 | |
| | 531 | return Glib::wrap(gtk_source_buffer_get_language(self), true); |
| 530 | 532 | } |
| 531 | 533 | |
-
|
r1d79f14
|
re51abc7
|
|
| 29 | 29 | class_init_func_ = &SourceLanguage_Class::class_init_function; |
| 30 | 30 | register_derived_type(gtk_source_language_get_type() ); |
| | 31 | |
| | 32 | Glib::wrap_register( |
| | 33 | GTK_TYPE_SOURCE_LANGUAGE, |
| | 34 | &Gtk::SourceLanguage_Class::wrap_new |
| | 35 | ); |
| 31 | 36 | } |
| 32 | 37 | |
| … |
… |
|
| 146 | 151 | Glib::wrap(GtkSourceLanguage* object, bool take_copy) |
| 147 | 152 | { |
| 148 | | // The Code below does not work - don't know why |
| 149 | | return Glib::RefPtr<Gtk::SourceLanguage>(new Gtk::SourceLanguage(GTK_SOURCE_LANGUAGE( (GObject*)(object)))); |
| 150 | | /* return Glib::RefPtr<Gtk::SourceLanguage>( |
| | 153 | Gtk::SourceLanguage::sourcelanguage_class_.init(); |
| | 154 | return Glib::RefPtr<Gtk::SourceLanguage>( |
| 151 | 155 | dynamic_cast<Gtk::SourceLanguage*>(Glib::wrap_auto( |
| 152 | 156 | reinterpret_cast<GObject*>(object), |
| 153 | 157 | take_copy |
| 154 | 158 | ) ) |
| 155 | | );*/ |
| | 159 | ); |
| 156 | 160 | } |
-
|
r623510b
|
re51abc7
|
|
| 65 | 65 | m_chat.chat_event().connect( |
| 66 | 66 | sigc::mem_fun(*this, &Window::on_chat) ); |
| | 67 | m_folder.document_update_event().connect( |
| | 68 | sigc::mem_fun(*this, &Window::on_document_update) ); |
| 67 | 69 | |
| 68 | 70 | m_frame_chat.set_shadow_type(Gtk::SHADOW_IN); |
| … |
… |
|
| 83 | 85 | m_mainbox.pack_start(m_header, Gtk::PACK_SHRINK); |
| 84 | 86 | m_mainbox.pack_start(m_mainpaned, Gtk::PACK_EXPAND_WIDGET); |
| | 87 | m_mainbox.pack_start(m_statusbar, Gtk::PACK_SHRINK); |
| 85 | 88 | |
| 86 | 89 | add(m_mainbox); |
| … |
… |
|
| 138 | 141 | m_userlist.obby_start(); |
| 139 | 142 | m_chat.obby_start(); |
| | 143 | m_statusbar.obby_start(); |
| 140 | 144 | |
| 141 | 145 | // Let the local user join |
| … |
… |
|
| 231 | 235 | m_userlist.obby_end(); |
| 232 | 236 | m_chat.obby_end(); |
| | 237 | m_statusbar.obby_end(); |
| 233 | 238 | |
| 234 | 239 | m_running = false; |
| … |
… |
|
| 336 | 341 | } |
| 337 | 342 | |
| | 343 | void Gobby::Window::on_document_update(Document& document) |
| | 344 | { |
| | 345 | // Update statusbar |
| | 346 | m_statusbar.update(document); |
| | 347 | } |
| | 348 | |
| 338 | 349 | void Gobby::Window::on_obby_login_failed(const std::string& reason) |
| 339 | 350 | { |
| … |
… |
|
| 352 | 363 | // Send documents to components |
| 353 | 364 | obby::buffer::document_iterator iter = m_buffer->document_begin(); |
| 354 | | for(iter; iter != m_buffer->document_end(); ++ iter) |
| | 365 | for(; iter != m_buffer->document_end(); ++ iter) |
| 355 | 366 | on_obby_document_insert(*iter); |
| 356 | 367 | } |
| … |
… |
|
| 379 | 390 | m_userlist.obby_start(); |
| 380 | 391 | m_chat.obby_start(); |
| | 392 | m_statusbar.obby_start(); |
| 381 | 393 | |
| 382 | 394 | m_running = true; |
| … |
… |
|
| 389 | 401 | m_userlist.obby_user_join(user); |
| 390 | 402 | m_chat.obby_user_join(user); |
| | 403 | m_statusbar.obby_user_join(user); |
| 391 | 404 | } |
| 392 | 405 | |
| … |
… |
|
| 398 | 411 | m_userlist.obby_user_part(user); |
| 399 | 412 | m_chat.obby_user_part(user); |
| | 413 | m_statusbar.obby_user_part(user); |
| 400 | 414 | } |
| 401 | 415 | |
| … |
… |
|
| 406 | 420 | m_userlist.obby_document_insert(document); |
| 407 | 421 | m_chat.obby_document_insert(document); |
| | 422 | m_statusbar.obby_document_insert(document); |
| 408 | 423 | } |
| 409 | 424 | |
| … |
… |
|
| 414 | 429 | m_userlist.obby_document_remove(document); |
| 415 | 430 | m_chat.obby_document_remove(document); |
| | 431 | m_statusbar.obby_document_remove(document); |
| 416 | 432 | } |
| 417 | 433 | |