Changeset 9c8b8080dc4d007fd27de778666221b86fe62b54

Show
Ignore:
Timestamp:
01/06/07 23:40:53 (6 years ago)
Author:
Philipp Kern <phil@…>
Parents:
81402324f4abc1a14b70b14781657362fbea5269
Children:
56383089e5ae1d12c04e5c0b67699e31eae062e0
git-committer:
Philipp Kern <phil@0x539.de> / 2007-01-06T22:40:53Z+0000
Message:

[project @ Display current document in title bar]

Original author: Armin Burgmeier <armin@…>
Date: 2005-07-20 11:30:28+00:00

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • inc/document.hpp

    r7a86085 r9c8b808  
    6666        unsigned int get_revision() const; 
    6767 
     68        /** Returns the path to the file. 
     69         */ 
     70        const Glib::ustring& get_path() const; 
     71 
     72        /** Changes the path to the file. 
     73         */ 
     74        void set_path(const Glib::ustring& new_path); 
     75 
    6876        /** Returns whether the local user is subscribed to this document. 
    6977         */ 
     
    196204        Gtk::Button m_btn_subscribe; 
    197205 
     206        /** Path to the file on the local disc. 
     207         */ 
     208        Glib::ustring m_path; 
     209 
    198210        signal_cursor_moved_type m_signal_cursor_moved; 
    199211        signal_content_changed_type m_signal_content_changed; 
  • inc/window.hpp

    r8140232 r9c8b808  
    7373#endif 
    7474 
     75        void on_folder_tab_switched(Document& document); 
     76 
    7577        void on_about(); 
    7678        void on_quit(); 
     
    7981 
    8082        // Obby signal handlers 
    81         void on_obby_login_failed(obby::login::error error); 
    82         bool on_obby_global_password(std::string& password); 
    83         bool on_obby_user_password(std::string& password); 
    8483        void on_obby_close(); 
    85         void on_obby_sync(); 
    8684 
    8785        void on_obby_user_join(obby::user& user); 
  • src/document.cpp

    r67ecf24 r9c8b808  
    192192} 
    193193 
     194const Glib::ustring& Gobby::Document::get_path() const 
     195{ 
     196        return m_path; 
     197} 
     198 
     199void Gobby::Document::set_path(const Glib::ustring& new_path) 
     200{ 
     201        m_path = new_path; 
     202} 
     203 
    194204#ifdef WITH_GTKSOURCEVIEW 
    195205Glib::RefPtr<Gtk::SourceLanguage> Gobby::Document::get_language() const 
  • src/window.cpp

    r8140232 r9c8b808  
    8484                sigc::mem_fun(*this, &Window::on_quit) ); 
    8585 
     86        m_folder.tab_switched_event().connect( 
     87                sigc::mem_fun(*this, &Window::on_folder_tab_switched) ); 
     88 
    8689        // Build UI 
    8790        add_accel_group(m_header.get_accel_group() ); 
     
    316319} 
    317320 
     321void Gobby::Window::on_folder_tab_switched(Document& document) 
     322{ 
     323        const Glib::ustring& file = document.get_document().get_title(); 
     324        Glib::ustring path = document.get_path(); 
     325                 
     326        if(!path.empty() ) 
     327        { 
     328                // Replace home dir by ~ 
     329                Glib::ustring home = Glib::get_home_dir(); 
     330                if(path.compare(0, home.length(), home) == 0) 
     331                        path.replace(0, home.length(), "~"); 
     332 
     333                // Set title with file and path 
     334                obby::format_string title_str("%0 (%1) - Gobby"); 
     335                title_str << file << path; 
     336                set_title(title_str.str() ); 
     337        } 
     338        else 
     339        { 
     340                // Path not known: Set title with file only 
     341                obby::format_string title_str("%0 - Gobby"); 
     342                title_str << file; 
     343                set_title(title_str.str() ); 
     344        } 
     345} 
     346 
    318347void Gobby::Window::on_document_create() 
    319348{ 
     
    333362        if(dlg.run() == Gtk::RESPONSE_OK) 
    334363        { 
     364                // TODO: Set path in newly generated document 
    335365                m_buffer->create_document( 
    336366                        Glib::path_get_basename(dlg.get_filename()), 
     
    357387                { 
    358388                        stream << doc.get_document().get_content() << std::endl; 
     389                        doc.get_document().set_path(dlg.get_filename() ); 
     390                        on_folder_tab_switched(doc.get_document() ); 
    359391                } 
    360392                else 
    361393                { 
    362                         display_error( 
    363                                 "Could not open file " + 
    364                                 dlg.get_filename() + 
    365                                 " for writing" 
    366                         ); 
     394                        obby::format_string str("Could not open file " 
     395                                                "%0 for writing"); 
     396                        str << dlg.get_filename(); 
     397                        display_error(str.str() ); 
    367398                } 
    368399        } 
     
    473504} 
    474505 
     506/* 
    475507void Gobby::Window::on_obby_login_failed(obby::login::error error) 
    476508{ 
     
    530562                return false; 
    531563        } 
    532 } 
     564}*/ 
    533565 
    534566void Gobby::Window::on_obby_close() 
     
    538570} 
    539571 
    540 void Gobby::Window::on_obby_sync() 
     572/*void Gobby::Window::on_obby_sync() 
    541573{ 
    542574        // Send documents to components 
     
    548580        if(m_buffer->document_count() > 0) 
    549581                m_folder.set_current_page(m_buffer->document_count() - 1); 
    550 } 
     582}*/ 
    551583 
    552584void Gobby::Window::on_obby_chat(obby::user& user, const Glib::ustring& message) 
     
    602634        m_chat.obby_document_remove(local_doc); 
    603635        m_statusbar.obby_document_remove(local_doc); 
     636 
     637        // Reset title if last document has been closed 
     638        if(m_buffer->document_count() == 1) 
     639                set_title("Gobby"); 
    604640} 
    605641