Changeset a78113f8b06bcdc8bc7c7355d36814b7cc1145c7

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

[project @ Non-working FindDialog?]

Original author: Armin Burgmeier <armin@…>
Date: 2005-11-13 17:13:20+00:00

Files:
2 added
5 modified

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r5ca6548 ra78113f  
    2222noinst_HEADERS += inc/encoding.hpp 
    2323noinst_HEADERS += inc/mimemap.hpp 
     24noinst_HEADERS += inc/regex.hpp 
    2425noinst_HEADERS += inc/defaultdialog.hpp 
    2526noinst_HEADERS += inc/historyentry.hpp 
     
    4546noinst_HEADERS += inc/hostprogressdialog.hpp 
    4647noinst_HEADERS += inc/entrydialog.hpp 
     48noinst_HEADERS += inc/finddialog.hpp 
    4749noinst_HEADERS += inc/window.hpp  
    4850noinst_HEADERS += inc/sourceview/sourceview.hpp 
     
    7274gobby_SOURCES += src/encoding.cpp 
    7375gobby_SOURCES += src/mimemap.cpp 
     76gobby_SOURCES += src/regex.cpp 
    7477gobby_SOURCES += src/defaultdialog.cpp 
    7578gobby_SOURCES += src/historyentry.cpp 
     
    9598gobby_SOURCES += src/hostprogressdialog.cpp 
    9699gobby_SOURCES += src/entrydialog.cpp 
     100gobby_SOURCES += src/finddialog.cpp 
    97101gobby_SOURCES += src/window.cpp 
    98102gobby_SOURCES += src/main.cpp 
  • inc/header.hpp

    r02f4d24 ra78113f  
    101101 
    102102        const Glib::RefPtr<Gtk::Action> action_edit; 
     103        const Glib::RefPtr<Gtk::Action> action_edit_search; 
     104        const Glib::RefPtr<Gtk::Action> action_edit_search_replace; 
    103105        const Glib::RefPtr<Gtk::Action> action_edit_preferences; 
    104106 
  • inc/window.hpp

    re6056f8 ra78113f  
    2929#include "docwindow.hpp" 
    3030#include "folder.hpp" 
     31#include "finddialog.hpp" 
    3132#include "userlist.hpp" 
    3233#include "documentlist.hpp" 
     
    4748        ~Window(); 
    4849 
    49         Document& get_current_document(); 
     50        Document* get_current_document(); 
    5051protected: 
    5152        // Gtk::Window overrides 
     
    6869        void on_document_close(); 
    6970 
     71        void on_edit_search(); 
     72        void on_edit_search_replace(); 
    7073        void on_edit_preferences(); 
    7174 
     
    129132 
    130133        Header m_header; 
     134        FindDialog m_finddialog; 
    131135        UserList m_userlist; 
    132136        DocumentList m_documentlist; 
  • src/header.cpp

    r5ca6548 ra78113f  
    4444                "    </menu>" 
    4545                "    <menu action=\"MenuEdit\">" 
     46                "      <menuitem action=\"EditSearch\" />" 
     47                "      <menuitem action=\"EditSearchReplace\" />" 
     48                "      <separator />" 
    4649                "      <menuitem action=\"EditPreferences\" />" 
    4750                "    </menu>" 
     
    260263        action_edit(Gtk::Action::create("MenuEdit", _("Edit")) ), 
    261264 
     265        action_edit_search( 
     266                Gtk::Action::create( 
     267                        "EditSearch", 
     268                        Gtk::Stock::FIND, 
     269                        _("Find..."), 
     270                        _("Search for text in the a document") 
     271                ) 
     272        ), 
     273 
     274        action_edit_search_replace( 
     275                Gtk::Action::create( 
     276                        "EditSearchReplace", 
     277                        Gtk::Stock::FIND_AND_REPLACE, 
     278                        _("Find and replace..."), 
     279                        _("Search for text and replace it with another one") 
     280                ) 
     281        ), 
     282 
    262283        action_edit_preferences( 
    263284                Gtk::Action::create( 
     
    356377 
    357378        group_edit->add(action_edit); 
     379        group_edit->add(action_edit_search); 
     380        group_edit->add(action_edit_search_replace); 
    358381        group_edit->add(action_edit_preferences); 
    359382 
  • src/window.cpp

    re6056f8 ra78113f  
    5757#endif 
    5858   m_header(), 
     59   m_finddialog(*this), 
    5960   m_userlist(*this, m_header), 
    6061   m_documentlist(*this, m_header), 
     
    8586                sigc::mem_fun(*this, &Window::on_document_close) ); 
    8687 
     88        m_header.action_edit_search->signal_activate().connect( 
     89                sigc::mem_fun(*this, &Window::on_edit_search) ); 
     90        m_header.action_edit_search_replace->signal_activate().connect( 
     91                sigc::mem_fun(*this, &Window::on_edit_search_replace) ); 
    8792        m_header.action_edit_preferences->signal_activate().connect( 
    8893                sigc::mem_fun(*this, &Window::on_edit_preferences) ); 
     
    603608{ 
    604609        // Get page 
    605         Document& doc = get_current_document(); 
     610        Document* doc = get_current_document(); 
     611        if(doc == NULL) 
     612                throw std::logic_error("Gobby::Window::on_document_save"); 
    606613 
    607614        // Is there already a path for this document? 
    608         if(!doc.get_path().empty() ) 
     615        if(!doc->get_path().empty() ) 
    609616                // Yes, so save the document there 
    610                 save_local_file(doc, doc.get_path() ); 
     617                save_local_file(*doc, doc->get_path() ); 
    611618        else 
    612619                // Open save as dialog otherwise 
     
    617624{ 
    618625        // Get page 
    619         Document& doc = get_current_document(); 
     626        Document* doc = get_current_document(); 
     627        if(doc == NULL) 
     628                throw std::logic_error("Gobby::Window::on_document_save_as"); 
    620629 
    621630        // Setup dialog 
     
    628637 
    629638        // Does the document have already a path? 
    630         if(!doc.get_path().empty() ) 
     639        if(!doc->get_path().empty() ) 
    631640        { 
    632641                // Yes, so set it as filename 
    633                 dlg.set_filename(doc.get_path() ); 
     642                dlg.set_filename(doc->get_path() ); 
    634643        } 
    635644        else 
     
    639648                        dlg.set_current_folder(m_last_path); 
    640649                // Set current title as proposed file name 
    641                 dlg.set_current_name(doc.get_title() ); 
     650                dlg.set_current_name(doc->get_title() ); 
    642651        } 
    643652 
     
    651660                m_last_path = dlg.get_current_folder(); 
    652661                // Save document 
    653                 save_local_file(doc, dlg.get_filename() ); 
     662                save_local_file(*doc, dlg.get_filename() ); 
    654663        } 
    655664} 
     
    661670        // Close it 
    662671        close_document(*static_cast<DocWindow*>(page) ); 
     672} 
     673 
     674void Gobby::Window::on_edit_search() 
     675{ 
     676        m_finddialog.set_search_only(true); 
     677        m_finddialog.show(); 
     678        m_finddialog.grab_focus(); 
     679} 
     680 
     681void Gobby::Window::on_edit_search_replace() 
     682{ 
     683        m_finddialog.set_search_only(false); 
     684        m_finddialog.show(); 
     685        m_finddialog.grab_focus(); 
    663686} 
    664687 
     
    754777{ 
    755778        // Get current page 
    756         Document& doc = get_current_document(); 
     779        Document* doc = get_current_document(); 
     780        if(doc == NULL) 
     781                throw std::logic_error("Gobby::Window::on_view_preferences"); 
    757782 
    758783        // Add preferences dialog 
    759         PreferencesDialog dlg(*this, doc.get_preferences(), true); 
     784        PreferencesDialog dlg(*this, doc->get_preferences(), true); 
    760785 
    761786        // Label text 
     
    767792 
    768793        // Get title 
    769         str << doc.get_title(); 
     794        str << doc->get_title(); 
    770795 
    771796        // Info label 
     
    782807        { 
    783808                // Apply new preferences to the document 
    784                 doc.set_preferences(dlg.preferences() ); 
     809                doc->set_preferences(dlg.preferences() ); 
    785810        } 
    786811} 
     
    790815{ 
    791816        // Set language of current document 
    792         get_current_document().set_language(lang); 
     817        Document* doc = get_current_document(); 
     818        if(doc == NULL) 
     819                throw std::logic_error("Gobby::Window::on_view_language"); 
     820 
     821        doc->set_language(lang); 
    793822} 
    794823 
     
    900929} 
    901930 
    902 Gobby::Document& Gobby::Window::get_current_document() 
    903 { 
     931Gobby::Document* Gobby::Window::get_current_document() 
     932{ 
     933        // No document open 
     934        if(m_folder.get_n_pages() == 0) return NULL; 
     935 
    904936        // Get currently selected page 
    905937        Widget* page = m_folder.get_nth_page(m_folder.get_current_page() ); 
    906938        // Convert to document 
    907         return static_cast<DocWindow*>(page)->get_document(); 
     939        return &static_cast<DocWindow*>(page)->get_document(); 
    908940} 
    909941 
     
    924956 
    925957        // Get currently active document 
    926         const Document& document = get_current_document(); 
     958        const Document& document = *get_current_document(); 
    927959        // Get title of current document 
    928960        const Glib::ustring& file = document.get_document().get_title();