]> git.lyx.org Git - lyx.git/commitdiff
make it compile again
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 22 Sep 2006 21:00:42 +0000 (21:00 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 22 Sep 2006 21:00:42 +0000 (21:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15132 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/frontends/gtk/GView.C
src/frontends/gtk/GView.h
src/frontends/gtk/GWorkArea.C
src/frontends/gtk/GWorkArea.h
src/frontends/gtk/GuiApplication.C [new file with mode: 0644]
src/frontends/gtk/GuiApplication.h [new file with mode: 0644]
src/frontends/gtk/GuiImplementation.C
src/frontends/gtk/GuiImplementation.h
src/frontends/gtk/GuiSelection.C
src/frontends/gtk/GuiSelection.h
src/frontends/gtk/Makefile.am
src/frontends/gtk/lyx_gui.C

index d38a91ac463d9364b627fa17ef7757d65e81776f..dae159db6a2f9c853f5bc74e0eb1be3a54e95f16 100644 (file)
@@ -59,7 +59,7 @@ void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
 } // namespace anon
 
 
-GView::GView(Gui & owner) : LyXView(owner)
+GView::GView() : LyXView()
 {
        // The physical store for the boxes making up the layout.
        box_store_.push_back(BoxPtr(new Gtk::VBox));
index e73b45eafd846d3110a314f8578ef876c8f9f973..655cdb4646b4cf99424d900efe6623f2a480deaf 100644 (file)
@@ -35,7 +35,7 @@ public:
                Center
        };
 
-       GView(Gui & owner);
+       GView();
        ~GView();
 
        Gtk::Box & getBox(Position pos);
index 3867841a25708c5104ad9a1f417841998abde050..9b4e3585fbe2d00fcd1b4607e2101c5348414422 100644 (file)
@@ -493,36 +493,5 @@ bool GWorkArea::onKeyPress(GdkEventKey * event)
        return true;
 }
 
-
-void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
-                              guint /*info*/)
-{
-       lyx::docstring const sel = view_.view()->requestSelection();
-       if (!sel.empty())
-               view_.gui().selection().put(sel);
-}
-
-
-void GWorkArea::onClipboardClear()
-{
-//     clearSelection();
-}
-
-
-void GWorkArea::haveSelection(bool toHave)
-{
-       if (toHave) {
-               Glib::RefPtr<Gtk::Clipboard> clipboard =
-                       Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
-               std::vector<Gtk::TargetEntry> listTargets;
-               listTargets.push_back(Gtk::TargetEntry("UTF8_STRING"));
-               clipboard->set(listTargets,
-                              sigc::mem_fun(const_cast<GWorkArea&>(*this),
-                                         &GWorkArea::onClipboardGet),
-                              sigc::mem_fun(const_cast<GWorkArea&>(*this),
-                                         &GWorkArea::onClipboardClear));
-       }
-}
-
 } // namespace frontend
 } // namespace lyx
index 3ee079c23a3b0a8e5cb9456935c57d605bd54f62..aef07a43495124da0af9c64d234c8411bda529d3 100644 (file)
@@ -82,8 +82,6 @@ public:
        ColorHandler & getColorHandler();
 
        virtual void setScrollbarParams(int height, int pos, int line_height);
-       /// a selection exists
-       virtual void haveSelection(bool);
        void inputCommit(gchar * str);
 
        LyXView & view()
@@ -100,8 +98,6 @@ private:
        bool onButtonRelease(GdkEventButton * event);
        bool onMotionNotify(GdkEventMotion * event);
        bool onKeyPress(GdkEventKey * event);
-       void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
-       void onClipboardClear();
        LyXView & view_;
        Gtk::HBox hbox_;
        Gtk::DrawingArea workArea_;
diff --git a/src/frontends/gtk/GuiApplication.C b/src/frontends/gtk/GuiApplication.C
new file mode 100644 (file)
index 0000000..6ef58f0
--- /dev/null
@@ -0,0 +1,125 @@
+/**
+ * \file qt4/GuiApplication.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author unknown
+ * \author John Levon
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiApplication.h"
+
+#include "GView.h"
+#include "GuiWorkArea.h"
+#include "GtkmmX.h"
+
+#include "BufferView.h"
+
+#include "graphics/LoaderQueue.h"
+
+#include "support/lstrings.h"
+#include "support/os.h"
+#include "support/package.h"
+
+#include "lyx_main.h"
+#include "lyxrc.h"
+#include "debug.h"
+
+#include <gtkmm.h>
+
+#include "LyXGdkImage.h"
+
+
+using lyx::support::subst;
+
+using std::string;
+using std::endl;
+
+
+namespace {
+
+/// estimate DPI from X server
+int getDPI()
+{
+       //TODO use GDK instead
+       Screen * scr = ScreenOfDisplay(getDisplay(), getScreen());
+       return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
+               (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2);
+}
+
+} // namespace anon
+
+
+namespace lyx {
+namespace frontend {
+
+GuiApplication::GuiApplication(int & argc, char ** argv)
+       : Gtk::Main(argc, argv), Application(argc, argv)
+{
+       using namespace lyx::graphics;
+       Image::newImage = boost::bind(&LyXGdkImage::newImage);
+       Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
+
+       // needs to be done before reading lyxrc
+       lyxrc.dpi = getDPI();
+
+       LoaderQueue::setPriority(10,100);
+}
+
+
+Clipboard& GuiApplication::clipboard()
+{
+       return clipboard_;
+}
+
+
+Selection& GuiApplication::selection()
+{
+       return selection_;
+}
+
+
+int const GuiApplication::exec()
+{
+       run();
+       return EXIT_SUCCESS;
+}
+
+
+void GuiApplication::exit(int /*status*/)
+{
+       // FIXME: Don't ignore status
+       guiApp->quit();
+}
+
+
+// FIXME: this whole method needs to be moved to Application.
+LyXView & GuiApplication::createView(unsigned int width,
+                                                                         unsigned int height,
+                                                                         int posx, int posy,
+                                                                         bool maximize)
+{
+       // FIXME: for now we assume that there is only one LyXView with id = 0.
+       /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
+       //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
+
+       int view_id = gui().newView(width, height);
+       GView & view = static_cast<GView &>(gui().view(view_id));
+
+       lyxfunc_.reset(new LyXFunc(&view));
+
+       LyX::ref().addLyXView(&view);
+
+       view.show();
+       view.init();
+
+       return view;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/gtk/GuiApplication.h b/src/frontends/gtk/GuiApplication.h
new file mode 100644 (file)
index 0000000..c90bfa6
--- /dev/null
@@ -0,0 +1,80 @@
+/**
+ * \file gtk/GuiApplication.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author unknown
+ * \author John Levon
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef GTK_APPLICATION_H
+#define GTK_APPLICATION_H
+
+#include "GuiClipboard.h"
+#include "GuiImplementation.h"
+#include "GuiSelection.h"
+#include "xftFontLoader.h"
+
+#include "frontends/Application.h"
+
+#include <gtkmm.h>
+
+///////////////////////////////////////////////////////////////
+
+class BufferView;
+
+namespace lyx {
+namespace frontend {
+
+class GuiWorkArea;
+
+/// The Gtk main application class
+/**
+There should be only one instance of this class. No Gtk object
+initialisation should be done before the instanciation of this class.
+
+\todo The work areas handling could be moved to a base virtual class
+comon to all frontends.
+*/
+class GuiApplication : public Gtk::Main, public Application
+{
+public:
+       GuiApplication(int & argc, char ** argv);
+
+       /// Method inherited from \c Application class
+       //@{
+       virtual Clipboard& clipboard();
+       virtual Selection& selection();
+       virtual int const exec();
+       virtual Gui & gui() { return gui_; }
+       virtual void exit(int status);
+       //@}
+
+       ///
+       xftFontLoader & fontLoader() { return font_loader_; }
+
+       ///
+       LyXView & createView(unsigned int width, unsigned int height,
+               int posx, int posy, bool maximize);
+
+private:
+       ///
+       GuiImplementation gui_;
+       ///
+       GuiClipboard clipboard_;
+       ///
+       GuiSelection selection_;
+       ///
+       xftFontLoader font_loader_;
+}; // GuiApplication
+
+} // namespace frontend
+} // namespace lyx
+
+extern lyx::frontend::GuiApplication * guiApp;
+
+
+#endif // GTK_APPLICATION_H
index 6a350c9e78103c0a6148c88f8d33e36731bf17b4..1e903216d8ba9411bdc8c963539b7d0a26f543f7 100644 (file)
@@ -32,7 +32,7 @@ namespace frontend {
 
 int GuiImplementation::newView(unsigned int /*w*/, unsigned int /*h*/)
 {
-       view_.reset(new GView(*this));
+       view_.reset(new GView);
        return 0;
 }
 
@@ -42,7 +42,6 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id
        old_work_area_.reset(new GWorkArea(*view_.get(), w, h));
        old_screen_.reset(new GScreen(*old_work_area_.get()));
        work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get()));
-       selection_.reset(new GuiSelection(old_work_area_.get()));
 
        // FIXME BufferView creation should be independant of WorkArea creation
        buffer_views_[0].reset(new BufferView(view_.get()));
@@ -54,7 +53,6 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id
 
 void GuiImplementation::destroyWorkArea(int /*id*/)
 {
-       selection_.reset();
        work_area_.reset();
        old_work_area_.reset();
        old_screen_.reset();
index c102bf50e3aae653420633fd62e5de56ff78940c..e18a760678e96e4fb2654b36d1321f64ccf5c815 100644 (file)
@@ -18,8 +18,6 @@
 #include "GScreen.h"
 #include "GWorkArea.h"
 
-#include "GuiClipboard.h"
-#include "GuiSelection.h"
 #include "GuiWorkArea.h"
 
 #include <boost/shared_ptr.hpp>
@@ -41,16 +39,6 @@ public:
        {
        }
 
-       lyx::frontend::Clipboard & clipboard()
-       {
-               return clipboard_;
-       }
-
-       lyx::frontend::Selection & selection()
-       {
-               return *selection_;
-       }
-
        int newView(unsigned int w, unsigned int h);
 
        LyXView & view(int /*id*/)
@@ -73,10 +61,6 @@ public:
        void destroyWorkArea(int /*id*/);
 
 private:
-       ///
-       GuiClipboard clipboard_;
-       ///
-       boost::shared_ptr<GuiSelection> selection_;
        ///
        boost::shared_ptr<GuiWorkArea> work_area_;
        ///
index 350c08ccdd736bf96b99ce006613c472a6cd1b09..c1193f1ece1736a53ae9326178a5ecdce82c2b9b 100644 (file)
 #endif
 
 #include "GuiSelection.h"
+
+#include "BufferView.h"
 #include "debug.h"
 
+#include "frontends/Application.h"
+#include "frontends/Gui.h"
+#include "frontends/LyXView.h"
+
 #include <gtkmm.h>
 
 using std::endl;
@@ -50,5 +56,38 @@ void GuiSelection::put(docstring const & str)
        clipboard->set_text(utf8);
 }
 
+
+void GuiSelection::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
+               guint /*info*/)
+{
+       // FIXME: This assumes only one LyXView
+       lyx::docstring const sel = theApp->gui().view(0).view()->requestSelection();
+       if (!sel.empty())
+               put(sel);
+}
+
+
+void GuiSelection::onClipboardClear()
+{
+       // FIXME: This assumes only one LyXView
+       theApp->gui().view(0).view()->clearSelection();
+}
+
+
+void GuiSelection::haveSelection(bool toHave)
+{
+       if (toHave) {
+               Glib::RefPtr<Gtk::Clipboard> clipboard =
+                       Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
+               std::vector<Gtk::TargetEntry> listTargets;
+               listTargets.push_back(Gtk::TargetEntry("UTF8_STRING"));
+               clipboard->set(listTargets,
+                               sigc::mem_fun(const_cast<GuiSelection&>(*this),
+                                       &GuiSelection::onClipboardGet),
+                               sigc::mem_fun(const_cast<GuiSelection&>(*this),
+                                       &GuiSelection::onClipboardClear));
+       }
+}
+
 } // namespace frontend
 } // namespace lyx
index 6d2118deab601b9acda49c5aeb62475263c9717e..544605507cc0405bcfce076a7773ac8bcfcbed85 100644 (file)
@@ -14,7 +14,8 @@
 
 #include "frontends/Selection.h"
 
-#include "GWorkArea.h"
+#include <gtkmm.h>
+#include <gtk/gtk.h>
 
 namespace lyx {
 namespace frontend {
@@ -25,28 +26,22 @@ namespace frontend {
 class GuiSelection: public lyx::frontend::Selection
 {
 public:
-       GuiSelection(GWorkArea * work_area)
-               : old_work_area_(work_area)
-       {
-       }
+       GuiSelection() {}
 
        virtual ~GuiSelection() {}
 
        /** Selection overloaded methods
         */
        //@{
-       void haveSelection(bool own)
-       {
-               old_work_area_->haveSelection(own);
-       }
+       void haveSelection(bool own);
 
        docstring const get() const;
 
        void put(docstring const & str);
        //@}
-
 private:
-       GWorkArea * old_work_area_;
+       void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
+       void onClipboardClear();
 };
 
 } // namespace frontend
index 7351f5798a94081662736c33c0786803b6d0b3d2..718f4bc1ecfa1eb3930e346637ea1d24a6830ae7 100644 (file)
@@ -138,6 +138,8 @@ libgtk_la_SOURCES = \
        LyXKeySymFactory.C \
        ghelpers.C \
        ghelpers.h \
+       GuiApplication.C \
+       GuiApplication.h \
        GuiImplementation.h \
        GuiImplementation.C \
        io_callback.C \
index 3076e741f8afa1b3794781a75e637e5f0df656e6..23d3de2c878fbbf317217222d57df5192350571b 100644 (file)
 #include "io_callback.h"
 
 // FIXME: move this stuff out again
-#include "bufferlist.h"
 #include "lyxfunc.h"
 #include "lyxserver.h"
 #include "lyxsocket.h"
 #include "BufferView.h"
 
+#include "GuiApplication.h"
 #include "GuiImplementation.h"
 #include "GView.h"
 #include "GtkmmX.h"
 
-#include "xftFontLoader.h"
 #include "GWorkArea.h"
 
 #include "support/lyxlib.h"
@@ -57,8 +56,6 @@
 
 #include <gtkmm.h>
 
-#include "LyXGdkImage.h"
-
 #include <boost/bind.hpp>
 #include <boost/function.hpp>
 #include <boost/shared_ptr.hpp>
@@ -77,16 +74,11 @@ using lyx::support::package;
 
 using lyx::frontend::colorCache;
 using lyx::frontend::Gui;
+using lyx::frontend::GuiApplication;
 using lyx::frontend::GuiImplementation;
 using lyx::frontend::GView;
 
 
-extern BufferList bufferlist;
-
-// FIXME: wrong place !
-LyXServer * lyxserver;
-LyXServerSocket * lyxsocket;
-
 bool lyx_gui::use_gui = true;
 
 namespace {
@@ -102,34 +94,13 @@ int getDPI()
 
 } // namespace anon
 
-class Application: public Gtk::Main
-{
-public:
-       ///
-       Application(int & argc, char * argv[]): Gtk::Main(argc, argv)
-       {}
-       ///
-       Gui & gui() { return gui_; }
-
-private:
-       ///
-       GuiImplementation gui_;
-};
-
-Application * theApp;
+lyx::frontend::Application * theApp;
+GuiApplication * guiApp;
 
 int lyx_gui::exec(int & argc, char * argv[])
 {
-       theApp = new Application(argc, argv);
-
-       using namespace lyx::graphics;
-       Image::newImage = boost::bind(&LyXGdkImage::newImage);
-       Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
-
-       locale_init();
-
-       // must do this /before/ lyxrc gets read
-       lyxrc.dpi = getDPI();
+       guiApp = new GuiApplication(argc, argv);
+       theApp = guiApp;
 
        return LyX::ref().exec2(argc, argv);
 }
@@ -141,47 +112,21 @@ void lyx_gui::parse_lyxrc()
 
 
 LyXView * lyx_gui::create_view(unsigned int width, unsigned int height,
-                  int /*posx*/, int /*posy*/, bool)
+               int posx, int posy, bool maximize)
 {
-       int view_id = theApp->gui().newView(width, height);
-       GView & view = static_cast<GView &> (theApp->gui().view(view_id));
-       theApp->gui().newWorkArea(width, height, 0);
-
-       LyX::ref().addLyXView(&view);
-
-       view.show();
-       view.init();
-
-       return &view;
+       return &guiApp->createView(width, height, posx, posy, maximize);
 }
 
 
-int lyx_gui::start(LyXView * view, string const & batch)
+int lyx_gui::start(LyXView *, string const & batch)
 {
-       // FIXME: server code below needs moving
-
-       lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
-       lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
-                         os::internal_path(package().temp_dir() + "/lyxsocket"));
-
-       // handle the batch commands the user asked for
-       if (!batch.empty()) {
-               view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
-       }
-
-       theApp->run();
-
-       // FIXME: breaks emergencyCleanup
-       delete lyxsocket;
-       delete lyxserver;
-       return EXIT_SUCCESS;
+       return guiApp->start(batch);
 }
 
 
-void lyx_gui::exit(int /*status*/)
+void lyx_gui::exit(int status)
 {
-       // FIXME: Don't ignore status
-       theApp->quit();
+       guiApp->exit(status);
 }