]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gtk/GView.C
make it compile again
[lyx.git] / src / frontends / gtk / GView.C
index 7b46f51b9046c5e9f1368fc4d21e5f9d83a2d53d..dae159db6a2f9c853f5bc74e0eb1be3a54e95f16 100644 (file)
@@ -9,20 +9,34 @@
  */
 
 #include <config.h>
-#include <gtkmm.h>
+
+// Too hard to make concept checks work with this file
+#ifdef _GLIBCXX_CONCEPT_CHECKS
+#undef _GLIBCXX_CONCEPT_CHECKS
+#endif
+#ifdef _GLIBCPP_CONCEPT_CHECKS
+#undef _GLIBCPP_CONCEPT_CHECKS
+#endif
 
 #include "GView.h"
 #include "GMenubar.h"
+#include "GToolbar.h"
 #include "GMiniBuffer.h"
 
 #include "BufferView.h"
 #include "lyx_cb.h"
+#include "lyxrc.h"
+#include "lyx_main.h"
+#include "session.h"
 #include "lyxfunc.h"
 #include "MenuBackend.h"
+#include "funcrequest.h"
 
 #include "frontends/Toolbars.h"
+#include "frontends/WorkArea.h"
 
 #include "support/filetools.h"
+#include "support/convert.h"
 
 #include <boost/bind.hpp>
 
@@ -45,22 +59,22 @@ void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
 } // namespace anon
 
 
-GView::GView()
+GView::GView() : LyXView()
 {
        // The physical store for the boxes making up the layout.
-       box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
-       box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
-       box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
-       box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
-       box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
-       box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
+       box_store_.push_back(BoxPtr(new Gtk::VBox));
+       box_store_.push_back(BoxPtr(new Gtk::HBox));
+       box_store_.push_back(BoxPtr(new Gtk::VBox));
+       box_store_.push_back(BoxPtr(new Gtk::HBox));
+       box_store_.push_back(BoxPtr(new Gtk::HBox));
+       box_store_.push_back(BoxPtr(new Gtk::HBox));
 
        // Lay them out correctly.
        add(top_box_);
 
        Gtk::Box::BoxList & layout1 = top_box_.children();
        add_el(layout1, *box_store_[0], true);
-       add_el(layout1, *box_store_[1], true);
+       add_el(layout1, *box_store_[1], false);
        add_el(layout1, *box_store_[2], true);
 
        Gtk::Box::BoxList & layout2 = box_store_[1]->children();
@@ -76,27 +90,38 @@ GView::GView()
        box_map_[Right]  = box_store_[5];
 
        // Make all Boxes visible.
-       top_box_.show();
-       BoxStore::iterator it = box_store_.begin();
-       BoxStore::iterator const end = box_store_.end();
-       for (; it != end; ++it)
-               (*it)->show();
+       top_box_.show_all();
 
        // Define the components making up the window.
        menubar_.reset(new GMenubar(this, menubackend));
        getToolbars().init();
-       bufferview_.reset(new BufferView(this, 300, 300));
        minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
 
        focus_command_buffer.connect(
                boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
-       view_state_changed.connect(boost::bind(&GView::showViewState, this));
-       signal_focus_in_event().connect(SigC::slot(*this, &GView::onFocusIn));
-       set_default_size(500, 550);
+       signal_focus_in_event().connect(sigc::mem_fun(*this, &GView::onFocusIn));
+       //
+       int width = 750;
+       int height = 550;
+       // first try lyxrc
+       if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
+               width = lyxrc.geometry_width;
+               height = lyxrc.geometry_height;
+       }
+       // if lyxrc returns (0,0), then use session info
+       else {
+               string val = LyX::ref().session().loadSessionInfo("WindowWidth");
+               if (val != "")
+                       width = convert<unsigned int>(val);
+               val = LyX::ref().session().loadSessionInfo("WindowHeight");
+               if (val != "")
+                       height = convert<unsigned int>(val);
+       }
+       set_default_size(width, height);
        // Make sure the buttons are disabled if needed.
-       updateToolbars();
+       //updateToolbars();
        string const iconName =
-               support::LibFileSearch("images", "lyx", "xpm");
+               support::libFileSearch("images", "lyx", "xpm");
        if (!iconName.empty())
                set_icon_from_file(iconName);
 }
@@ -114,7 +139,14 @@ Gtk::Box & GView::getBox(Position pos)
 
 bool GView::on_delete_event(GdkEventAny * /*event*/)
 {
-       QuitLyX();
+       // save windows size and position
+       Gtk::Requisition req = workArea_->size_request();
+       LyX::ref().session().saveSessionInfo("WindowWidth", convert<string>(req.width));
+       LyX::ref().session().saveSessionInfo("WindowHeight", convert<string>(req.height));
+       // trigger LFUN_LYX_QUIT instead of quit directly
+       // since LFUN_LYX_QUIT may have more cleanup stuff
+       //
+       getLyXFunc().dispatch(FuncRequest(LFUN_LYX_QUIT));
        return true;
 }
 
@@ -128,7 +160,9 @@ bool GView::onFocusIn(GdkEventFocus * /*event*/)
 
 void GView::prohibitInput() const
 {
-       view()->hideCursor();
+       // FIXME: Why is prohibitInput const?
+       // FIXME: hideCursor is protected
+       //const_cast<GView*>(this)->workArea()->hideCursor();
        const_cast<GView*>(this)->set_sensitive(false);
 }
 
@@ -139,28 +173,30 @@ void GView::allowInput() const
 }
 
 
-void GView::message(string const & msg)
+void GView::message(docstring const & msg)
 {
-       minibuffer_->message(msg);
+       minibuffer_->message(lyx::to_utf8(msg));
 }
 
 
-void GView::showViewState()
+void GView::updateStatusBar()
 {
-       message(getLyXFunc().viewStatusMessage());
+       message(lyx::from_utf8(getLyXFunc().viewStatusMessage()));
 }
 
 
-void GView::setWindowTitle(string const & t, string const & /*it*/)
+void GView::setWindowTitle(docstring const & t, docstring const & /*it*/)
 {
-       set_title(Glib::locale_to_utf8(t));
+       set_title(lyx::to_utf8(t));
 }
 
 
 void GView::busy(bool yes) const
 {
-       if (yes ) {
-               view()->hideCursor();
+       // FIXME: Why is busy const?
+       if (yes) {
+               // FIXME: hideCursor is protected
+               //const_cast<GView*>(this)->workArea()->hideCursor();
                Gdk::Cursor cursor(Gdk::WATCH);
                const_cast<GView *>(this)->get_window()->set_cursor(cursor);
                const_cast<GView *>(this)->set_sensitive(false);
@@ -173,7 +209,20 @@ void GView::busy(bool yes) const
 
 void GView::clearMessage()
 {
-       message(getLyXFunc().viewStatusMessage());
+       message(lyx::from_utf8(getLyXFunc().viewStatusMessage()));
+}
+
+
+bool GView::hasFocus() const
+{
+       // No real implementation needed for now
+       return true;
+}
+
+
+Toolbars::ToolbarPtr GView::makeToolbar(ToolbarBackend::Toolbar const & tbb)
+{
+       return make_toolbar(tbb, *this);
 }
 
 } // namespace frontend