]> git.lyx.org Git - lyx.git/commitdiff
Move connection of the image loader signals to the frontends.
authorAngus Leeming <leeming@lyx.org>
Thu, 28 Feb 2002 18:07:15 +0000 (18:07 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 28 Feb 2002 18:07:15 +0000 (18:07 +0000)
Small fix to GImageXPM.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3616 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/graphics/ChangeLog
src/graphics/GraphicsCache.C
src/graphics/GraphicsImageXPM.C

index 1a7e761c38358e4015f6ef0fe99cc83907d8862a..12dd2598396b4861399746c47ed60463b740bc68 100644 (file)
@@ -1,6 +1,8 @@
 2002-02-28  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * Dialogs.C (initialiseGraphics): a new static method.
+       Remove Allan's venerable description as I think it's past its sell-by
+       date.
 
 2002-02-28  John Levon  <moz@compsoc.man.ac.uk>
 
index 421e3cd9992851324821ee16c4348ac7b1fd2162..724d978da7c803448ddd734a1d28957fa7c95e18 100644 (file)
@@ -81,6 +81,9 @@
 #include "FormPreferences.h"
 #include "FormTabular.h"
 
+#include "graphics/GraphicsImageXPM.h"
+//#include "xformsGraphicsImage.h"
+
 // Signal enabling all visible dialogs to be redrawn if so desired.
 // E.g., when the GUI colours have been remapped.
 SigC::Signal0<void> Dialogs::redrawGUI;
@@ -132,76 +135,13 @@ Dialogs::Dialogs(LyXView * lv)
 // image loading routines to the LyX kernel.
 void Dialogs::initialiseGraphics()
 {
+       using namespace grfx;
+       using SigC::slot;
+    
+       // connect the image loader based on the XPM library
+       GImage::newImage.connect(slot(&GImageXPM::newImage));
+       GImage::loadableFormats.connect(slot(&GImageXPM::loadableFormats));
+       // connect the image loader based on the xforms library
+//     GImage::newImage.connect(slot(&xformsGImage::newImage));
+//     GImage::loadableFormats.connect(slot(&xformsGImage::loadableFormats));
 }
-
-/*****************************************************************************
-
-Q.  WHY does Dialogs::Dialogs pass `this' to dialog constructors?
-
-A.  To avoid a segfault.
-    The dialog constructors need to connect to their
-    respective showSomeDialog signal(*) but in order to do
-    that they need to get the address of the Dialogs instance
-    from LyXView::getDialogs().  However, since the Dialogs
-    instance is still being constructed at that time
-    LyXView::getDialogs() will *not* return the correct
-    address because it hasn't finished being constructed.
-    A Catch-22 situation (or is that the chicken and the egg...).
-    So to get around the problem we pass the address of
-    the newly created Dialogs instance using `this'.
-
-(*) -- I'm using signals exclusively to guarantee that the gui code
-       remains hidden from the rest of the system.  In fact the only 
-       header related to dialogs that anything in the non-gui-specific
-       code gets to see is Dialogs.h!  Even Dialogs.h doesn't know what a 
-       FormCopyright class looks like or that its even going to be used!
-
-       No other gui dialog headers are seen outside of the gui-specific
-       directories!  This ensures that the gui is completely separate from
-       the rest of LyX.  All this through the use of a few simple signals.
-       BUT, the price is that during construction we need to connect the
-       implementations show() method to the showSomeDialog signal and this
-       requires that we have an instance of Dialogs and the problem mentioned
-       above.
-
-       Almost all other dialogs should be able to operate using the same style
-       of signalling used for Copyright.  Exceptions should be handled
-       by adding a specific show or update signal.  For example, spellchecker
-       needs to set the next suspect word and its options/replacements so we
-       need a:
-                 Signal0<void> updateSpellChecker;
-
-       Since we would have to have a
-                 Signal0<void> showSpellChecker;
-
-       in order to just see the spellchecker and let the user push the [Start]
-       button then the updateSpellChecker signal will make the SpellChecker
-       dialog get the new word and replacements list from LyX.  If you really,
-       really wanted to you could define a signal that would pass the new
-       word and replacements:
-                 Signal2<void, string, vector<string> > updateSpellChecker;
-
-       (or something similar) but, why bother when the spellchecker can get
-       it anyway with a LyXFunc call or two.  Besides if someone extends
-       what a dialog does then they also have to change code in the rest of 
-       LyX to pass more parameters or get the extra info via a function 
-       call anyway.  Thus reducing the independence of the two code bases.
-
-       We don't need a separate update signal for each dialog because most of 
-       them will be changed only when the buffer is changed (either by closing
-       the current open buffer or switching to another buffer in the current
-       LyXView -- different BufferView same LyXView or same BufferView same
-       LyXView).
-
-       So we minimise signals but maximise independence and programming 
-       simplicity, understandability and maintainability.  It's also
-       extremely easy to add support for Qt or gtk-- because they use
-       signals already. Guis that use callbacks, like xforms, must have their
-       code wrapped up like that in the form_copyright.[Ch] which is awkward
-       but will at least allow multiple instances of the same dialog.
-
-       LyXFuncs will be used for requesting/setting LyX internal info.  This
-       will ensure that scripts or LyXServer-connected applications can all
-       have access to the same calls as the internal user-interface.
-
-******************************************************************************/
index 790b7c77a9618641593a515efbe47dd5d25d0bb5..ba63ef609331f96344c416daf8882ce57deb6617 100644 (file)
@@ -7,6 +7,11 @@
 
        * Makefile.am: add GraphicsTypes.h which I'd carelessly left out.
 
+       * GraphicsCache.C: move connections to the GImage-derived classes to
+       the frontends.
+
+       * GraphicsImageXPM.C (copy c-tor): don't copy pixmap.
+
 2002-02-27  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * GraphicsCache.C: improve commentary to graphicsInit and where it
index 6930359c7c7d78f1b1e494ba64bd85db6e423715..1380bf4adc3714598a794a0da8126cfeb70e478f 100644 (file)
 #include "GraphicsImage.h"
 #include "GraphicsParams.h"
 #include "insets/insetgraphics.h"
+#include "frontends/Dialogs.h"
 
 
-// I think that graphicsInit should become a new Dialogs::graphicsInit 
-// static method.
-// These #includes would then be moved to Dialogs.C.
-// Angus 25 Feb 2002
-#include "GraphicsImageXPM.h"
-//#include "xformsGraphicsImage.h"
-
-namespace {
-
-void graphicsInit() 
-{
-       using namespace grfx;
-       using SigC::slot;
-    
-       // connect the image loader based on the XPM library
-       GImage::newImage.connect(slot(&GImageXPM::newImage));
-       GImage::loadableFormats.connect(slot(&GImageXPM::loadableFormats));
-       // connect the image loader based on the xforms library
-//     GImage::newImage.connect(slot(&xformsGImage::newImage));
-//     GImage::loadableFormats.connect(slot(&xformsGImage::loadableFormats));
-}
-    
-} // namespace anon
-
 namespace grfx {
 
 GCache & GCache::get()
@@ -52,7 +28,7 @@ GCache & GCache::get()
        static bool start = true;
        if (start) {
                start = false;
-               graphicsInit();
+               Dialogs::initialiseGraphics();
        }
 
        // Now return the cache
index 592586a1a3377ee15fc91ff16b8b19358e948bd2..fb6df44881aa93f8f4ed41a526afc610e6587191 100644 (file)
@@ -17,7 +17,7 @@
 #include "GraphicsParams.h"
 #include "ColorHandler.h"
 #include "debug.h"
-#include "frontends/GUIRunTime.h" // x11Display
+#include "frontends/GUIRunTime.h" // x11Display, x11Screen
 #include "support/filetools.h"    // IsFileReadable
 #include "support/lstrings.h"
 #include "Lsstream.h"
@@ -54,14 +54,14 @@ GImageXPM::GImageXPM()
 GImageXPM::GImageXPM(GImageXPM const & other)
        : GImage(other),
          image_(other.image_),
-         pixmap_(other.pixmap_),
-         pixmap_status_(other.pixmap_status_)
+         pixmap_(0),
+         pixmap_status_(PIXMAP_UNINITIALISED)
 {}
 
 
 GImageXPM::~GImageXPM()
 {
-       if (pixmap_ && pixmap_status_ == PIXMAP_SUCCESS)
+       if (pixmap_)
                XFreePixmap(GUIRunTime::x11Display(), pixmap_);
 }