Lars Gullik Bjønnes wrote:
Abdelrazak Younes <[EMAIL PROTECTED]> writes:

| Lars Gullik Bjønnes wrote:
| > Abdelrazak Younes <[EMAIL PROTECTED]> writes:
| > | the patch...
| > | | Abdelrazak Younes wrote:
| > | > Hello,
| > | > I am sure I implement that in the right way. Please someone who
| > | > knows about LFUNs, review the patch.
| > | > Abdel.
| > | >
| > | | Index: frontends/Application.h
| > | ===================================================================
| > | --- frontends/Application.h    (revision 15426)
| > | +++ frontends/Application.h    (working copy)
| > | @@ -111,8 +111,8 @@
| > |        virtual void unregisterSocketCallback(int fd) = 0;
| > |  |     /// Create the main window with given geometry
| > settings.
| > | -      LyXView & createView(unsigned int width, unsigned int height,
| > | -              int posx, int posy, bool maximize);
| > | +      LyXView & createView(unsigned int width = 0, unsigned int height = 
0,
| > | +              int posx = -1, int posy = -1, bool maximize = false);
| > Why the default arguments?
| | Because I wanted to use the default size define in the qt4 frontend. | | | > Default arguments often feels/looks nice, but they are a burden.
| > Two functions are often better.
| | No strong opinion about that...

Two funtions then.

I found a better solution...

Will commit soon.

Abdel.

Index: lib/ui/stdmenus.ui
===================================================================
--- lib/ui/stdmenus.ui  (revision 15426)
+++ lib/ui/stdmenus.ui  (working copy)
@@ -32,6 +32,7 @@
 #
 
        Menu "file"
+               Item "New Window|W" "window-new"
                Item "New|N" "buffer-new"
                Item "New from Template...|m" "buffer-new-template"
                Item "Open...|O" "file-open"
Index: src/lfuns.h
===================================================================
--- src/lfuns.h (revision 15426)
+++ src/lfuns.h (working copy)
@@ -369,6 +369,7 @@
        // 280
        LFUN_INSET_DISSOLVE,                 // jspitzm 20060807
        LFUN_CHANGE_NEXT,
+       LFUN_WINDOW_NEW,                 // Abdel 20062110
 
        LFUN_LASTACTION                  // end of the table
 };
Index: src/lyx_main.C
===================================================================
--- src/lyx_main.C      (revision 15426)
+++ src/lyx_main.C      (working copy)
@@ -492,6 +492,28 @@
 
 void LyX::restoreGuiSession(vector<string> const & files)
 {
+       LyXView * view = newLyXView();
+
+       // load files
+       for_each(files.begin(), files.end(),
+               bind(&LyXView::loadLyXFile, view, _1, true));
+
+       // if a file is specified, I assume that user wants to edit *that* file
+       if (files.empty() && lyxrc.load_session) {
+               vector<string> const & lastopened = 
pimpl_->session_->lastOpenedFiles();
+               // do not add to the lastfile list since these files are 
restored from
+               // last seesion, and should be already there (regular files), 
or should
+               // not be added at all (help files).
+               for_each(lastopened.begin(), lastopened.end(),
+                       bind(&LyXView::loadLyXFile, view, _1, false));
+       }
+       // clear this list to save a few bytes of RAM
+       pimpl_->session_->clearLastOpenedFiles();
+}
+
+
+LyXView * LyX::newLyXView()
+{
        // determine windows size and position, from lyxrc and/or session
        // initial geometry
        unsigned int width = 690;
@@ -513,6 +535,7 @@
                if (session().loadSessionInfo("WindowIsMaximized") == "yes")
                        maximize = true;
        }
+
        // if user wants to restore window position
        int posx = -1;
        int posy = -1;
@@ -533,24 +556,9 @@
        LyXView * view = &pimpl_->application_->createView(width, height, posx, 
posy, maximize);
        ref().addLyXView(view);
 
-       // load files
-       for_each(files.begin(), files.end(),
-               bind(&LyXView::loadLyXFile, view, _1, true));
-
-       // if a file is specified, I assume that user wants to edit *that* file
-       if (files.empty() && lyxrc.load_session) {
-               vector<string> const & lastopened = 
pimpl_->session_->lastOpenedFiles();
-               // do not add to the lastfile list since these files are 
restored from
-               // last seesion, and should be already there (regular files), 
or should
-               // not be added at all (help files).
-               for_each(lastopened.begin(), lastopened.end(),
-                       bind(&LyXView::loadLyXFile, view, _1, false));
-       }
-       // clear this list to save a few bytes of RAM
-       pimpl_->session_->clearLastOpenedFiles();
+       return view;
 }
 
-
 /*
 Signals and Windows
 ===================
Index: src/lyx_main.h
===================================================================
--- src/lyx_main.h      (revision 15426)
+++ src/lyx_main.h      (working copy)
@@ -93,7 +93,7 @@
        kb_keymap & topLevelKeymap();
        kb_keymap const & topLevelKeymap() const;
 
-       void addLyXView(LyXView * lyxview);
+       LyXView * newLyXView();
 
        /** redraw \c inset in all the BufferViews in which it is currently
         *  visible. If successful return a pointer to the owning Buffer.
@@ -123,6 +123,9 @@
        /// Create a View and restore GUI Session.
        void restoreGuiSession(std::vector<std::string> const & files);
 
+       ///
+       void addLyXView(LyXView * lyxview);
+
        /// Initialize RC font for the GUI.
        void initGuiFont();
 
Index: src/LyXAction.C
===================================================================
--- src/LyXAction.C     (revision 15426)
+++ src/LyXAction.C     (working copy)
@@ -362,6 +362,7 @@
                { LFUN_MOUSE_TRIPLE, "", ReadOnly },
                { LFUN_PARAGRAPH_MOVE_DOWN, "paragraph-move-down", Noop },
                { LFUN_PARAGRAPH_MOVE_UP, "paragraph-move-up", Noop },
+               { LFUN_WINDOW_NEW, "window-new", NoBuffer },
                { LFUN_NOACTION, "", Noop }
        };
 
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C       (revision 15426)
+++ src/lyxfunc.C       (working copy)
@@ -619,6 +619,7 @@
        case LFUN_LYXRC_APPLY:
        case LFUN_BUFFER_NEXT:
        case LFUN_BUFFER_PREVIOUS:
+       case LFUN_WINDOW_NEW:
                // these are handled in our dispatch()
                break;
 
@@ -1583,6 +1584,10 @@
                        break;
                }
 
+               case LFUN_WINDOW_NEW:
+                       BOOST_ASSERT(theApp);
+                       LyX::ref().newLyXView();
+
                default: {
                        view()->cursor().dispatch(cmd);
                        updateforce |= view()->cursor().result().update();

Reply via email to