From: Colin P. A. <co...@co...> - 2008-12-22 15:33:01
|
Hello, I cannot figure out a good way of doing the following: I have set up a menu item (named "rotate") so that the user can request the main widget is displayed upside-down (rotated 180 deg). But I can't figure out how to communicate this setting to the routine which redraws the canvas on an expose event. It seems to require shared global state (and I don't want to make this a gconf setting). I can't see a way to thread a state monad into a menu action. -- Colin Adams Preston Lancashire |
From: Ross M. <rmm-haskell@z.odi.ac> - 2008-12-22 15:40:26
|
I don't know if it's the right way or the best way (it's certainly not pretty), but the way I do things like this is to pass an IORef around, e.g. import Data.IORef import Graphics.UI.Gtk import Graphics.UI.Gtk.Gdk.EventM draw :: IORef Bool -> EventM EExpose Bool draw rotate_ior = do rotate <- liftIO $ readIORef rotate_ior -- render the widget return True doRotate :: Widget -> IORef Bool -> IO () doRotate w rotate_ior = do modifyIORef not rotate_ior widgetQueueDraw w setupUI :: IO () setupUI = do rotate_ior <- newIORef False -- do not start rotated -- set up other ui on myWidget exposeEvent (draw rotate_ior) on myMenuItem activateLeaf (doRotate myWidget rotate_ior) -Ross On Dec 22, 2008, at 10:32 AM, Colin Paul Adams wrote: > Hello, > > I cannot figure out a good way of doing the following: > > I have set up a menu item (named "rotate") so that the user can > request the main widget is displayed upside-down (rotated 180 deg). > > But I can't figure out how to communicate this setting to the routine > which redraws the canvas on an expose event. It seems to require > shared global state (and I don't want to make this a gconf setting). I > can't see a way to thread a state monad into a menu action. > -- > Colin Adams > Preston Lancashire > > ------------------------------------------------------------------------------ > _______________________________________________ > Gtk2hs-users mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users |
From: Brett G. <bre...@uc...> - 2008-12-22 22:53:52
|
Hi everyone I've spent the afternoon trying to get the darcs version of Gtk2HS, using GHC 6.10, to build in windows with little success. (Mac was sooooo easy - sigh). It appears that the gtk portion of the build depends on the pixman-1 library, which the gtk distributions of windows seem to lack. First, am I right that it does depend on it? Second, if so, is the only option to build it (and probably some other parts of gtk then...) from source? Brett Giles Ph.D. student, Formal methods, Category theory Department of Computer Science, University of Calgary http://pages.cpsc.ucalgary.ca/~gilesb |
From: Brett G. <bre...@uc...> - 2008-12-23 19:44:21
|
As a further note to this, I attempted to build using the cygwin libraries. The configure at least admits it will build gtk and some other usefull parts of the library, but fails after chugging away on the c2hs stuff, failing on the compile of System\Glib.hs with "Failed to load interface for 'System.Glib.UTFString'". I believe this stems from an earlier error where c2hsLocal.exe complains that "glib-object.h" can not be found (It isn't anywhere in the source tree). I did some searching about that but didn't find anything in the couple of trac tickets mentioning it that seemed applicable. Any suggestions (or an installable build ;) are more than welcome. > Hi everyone > > I've spent the afternoon trying to get the darcs version of Gtk2HS, using > GHC 6.10, to build in windows with little success. (Mac was sooooo easy - > sigh). > > It appears that the gtk portion of the build depends on the pixman-1 > library, which the gtk distributions of windows seem to lack. > > First, am I right that it does depend on it? > > Second, if so, is the only option to build it (and probably some other > parts of gtk then...) from source? > > Brett Giles > Ph.D. student, Formal methods, Category theory > Department of Computer Science, University of Calgary > http://pages.cpsc.ucalgary.ca/~gilesb > Brett Giles Ph.D. student, Formal methods, Category theory Department of Computer Science, University of Calgary http://pages.cpsc.ucalgary.ca/~gilesb |
From: Bertram F. <ber...@go...> - 2008-12-24 09:03:22
|
Brett Giles wrote: > I believe this stems from an earlier error where c2hsLocal.exe complains > that "glib-object.h" can not be found (It isn't anywhere in the source glib-object.h is not part of gtk2hs; it is one of the glib header files, and comes with the glib C library from www.gtk.org. Perhaps the header files are missing on your system? But configure must have found them - maybe cygwin and ghc disagree on the include search path? Bertram |
From: Axel S. <Axe...@en...> - 2008-12-25 12:27:47
|
On Dec 23, 2008, at 20:44, Brett Giles wrote: > As a further note to this, I attempted to build using the cygwin > libraries. The configure at least admits it will build gtk and some > other > usefull parts of the library, but fails after chugging away on the > c2hs > stuff, failing on the compile of System\Glib.hs with "Failed to load > interface for 'System.Glib.UTFString'". These errors always happen if you the dependencies are being built or are simply wrong (after an upgrade of Gtk2Hs or a change to source file, say). > I believe this stems from an earlier error where c2hsLocal.exe > complains > that "glib-object.h" can not be found (It isn't anywhere in the source > tree). I did some searching about that but didn't find anything in the > couple of trac tickets mentioning it that seemed applicable. > > Any suggestions (or an installable build ;) are more than welcome. First of all: all your directories should be free of spaces. You might be able to use the abbreviates DOS names (C:\Progra~1 or some such), mingw and Cygwin have their own weird translation scheme I think. The general environment for building Gtk2Hs looks as follows: - install Gtk and all its sub-libraries (glib, atk, cairo, pango, pixbuf, and other optional libraries). On Windows this is one big tar ball I believe. - install the header files If everything is working, you can run pkg-config --list-all and see gtk+-2.0 as a package. If this doesn't work, set $PATH such that pkg-config is found and set PKG_CONFIG_PATH to the [..]/lib/ pkgconfig path that contains the gtk+-2.0.pc file. - unpack the Gtk2Hs source tree - if it's the darcs source tree, you need to run autoconf which requires the autoconf tools - run ./configure - run make You can have all sorts of funky things that go wrong. For instance hsc2hs might not be able to find a gcc compiler. You need to scroll up in order to find out what the actual error is. Sometimes if c2hs or hsc2hs fail they produce an empty .hs file on which the ghc compiler gives a very interesting error message (I think: "Module name does not match file name"). If you need specific help, the error message of the output would be useful. Cheers, Axel. >> Hi everyone >> >> I've spent the afternoon trying to get the darcs version of >> Gtk2HS, using >> GHC 6.10, to build in windows with little success. (Mac was sooooo >> easy - >> sigh). >> >> It appears that the gtk portion of the build depends on the pixman-1 >> library, which the gtk distributions of windows seem to lack. >> >> First, am I right that it does depend on it? >> >> Second, if so, is the only option to build it (and probably some >> other >> parts of gtk then...) from source? >> >> Brett Giles >> Ph.D. student, Formal methods, Category theory >> Department of Computer Science, University of Calgary >> http://pages.cpsc.ucalgary.ca/~gilesb >> > > > Brett Giles > Ph.D. student, Formal methods, Category theory > Department of Computer Science, University of Calgary > http://pages.cpsc.ucalgary.ca/~gilesb > > > ---------------------------------------------------------------------- > -------- > _______________________________________________ > Gtk2hs-users mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users |