From: Maurício <bri...@ya...> - 2009-03-17 15:13:11
|
Hi, I see that widget classes have a 'castTo' member, like, say, castToPaned or castToWidget. Using those functions, what happens if an object can not be casted into such class? Say, if I apply castToPaned to a Widget? Is it possible to check if such cast is possible before calling that function? Thanks, Maurício |
From: Axel S. <Axe...@en...> - 2009-03-17 17:55:50
|
On Mar 17, 2009, at 16:12, Maurí cio wrote: > Hi, > > I see that widget classes have a 'castTo' member, > like, say, castToPaned or castToWidget. Yes, but you only need them if you want to cast an object to a more derived instance, e.g. a widget to a Paned. > Using those functions, what happens if an object > can not be casted into such class? Say, if I > apply castToPaned to a Widget? If the widget is a Paned then it's ok. If not, the resulting value is a call to error. > Is it possible to > check if such cast is possible before calling that > function? Yes, there is a function called 'isA' in System.Glib.GObject that takes a type value (which are also exported by Gtk). Cheers, Axel. |
From: Maurício <bri...@ya...> - 2009-03-17 19:56:42
|
>> I see that widget classes have a 'castTo' member, >> like, say, castToPaned or castToWidget.(...) > > If the widget is a Paned then it's ok. If not, the resulting value is > a call to error. > >> Is it possible to >> check if such cast is possible before calling that >> function? > > Yes, there is a function called 'isA' in System.Glib.GObject (...) Checking your sugestion, I also found the function below that also uses GType. But, as in 'isA', I could not found (even in Gtk+) how to get values of GType for a given class. The code below mentions 'gTypeBox' as a GType for Box, but it has no link and haddock index have nothing begging with 'gType'. How can I get those? widgetGetAncestor :: WidgetClass self => self -> GType widgetType - ancestor type -> IO (Maybe Widget) returns the ancestor widget, or Nothing if not found Gets the first ancestor of widget with type widgetType. For example, widgetGetAncestor widget gTypeBox gets the first Box that's an ancestor of widget. See note about checking for a toplevel Window in the docs for widgetGetToplevel. Thanks, Maurício |
From: Axel S. <Axe...@en...> - 2009-03-17 20:30:19
|
On Mar 17, 2009, at 20:56, Maurí cio wrote: >>> I see that widget classes have a 'castTo' member, >>> like, say, castToPaned or castToWidget.(...) >> >> If the widget is a Paned then it's ok. If not, the resulting value is >> a call to error. >> >>> Is it possible to >>> check if such cast is possible before calling that >>> function? >> >> Yes, there is a function called 'isA' in System.Glib.GObject (...) > > Checking your sugestion, I also found the function below that > also uses GType. But, as in 'isA', I could not found (even > in Gtk+) how to get values of GType for a given class. The > code below mentions 'gTypeBox' as a GType for Box, but it has > no link and haddock index have nothing begging with 'gType'. > How can I get those? Uh, yes, these are not exported by default. They can be found in Graphics.UI.Gtk.Types Cheers, Axel. > widgetGetAncestor > :: WidgetClass self > => self > -> GType widgetType - ancestor type > -> IO (Maybe Widget) returns the ancestor widget, or Nothing > if not found > Gets the first ancestor of widget with type widgetType. For > example, widgetGetAncestor > widget gTypeBox gets the first Box that's an ancestor of widget. > See note about checking > for a toplevel Window in the docs for widgetGetToplevel. > > Thanks, > Maurício > > > ---------------------------------------------------------------------- > -------- > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) > are > powering Web 2.0 with engaging, cross-platform capabilities. > Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based > development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > Gtk2hs-users mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users |
From: Maurício <bri...@ya...> - 2009-03-17 22:03:17
|
>> Checking your sugestion, I also found the function below that >> also uses GType. But, as in 'isA', I could not found (even >> in Gtk+) how to get values of GType for a given class. (...) > > Uh, yes, these are not exported by default. They can be found in > > Graphics.UI.Gtk.Types Can't find that either. 'www.haskell.org/gtk2hs/docs/current' shows no module named Types, and 'find . | grep -i /Types' in gtk2hs 0.10 source tree shows: ./gnomevfs/System/Gnome/VFS/Types.chs.pp ./cairo/Graphics/Rendering/Cairo/Types.chs ./glib/System/Glib/Types.chs ./gtk/Graphics/UI/Gtk/ModelView/Types.chs ./gtk/Graphics/UI/Gtk/Multiline/Types.chs.pp ./gtk/Graphics/UI/Gtk/Pango/Types.chs.pp ./gstreamer/Media/Streaming/GStreamer/Base/Types.chs ./gstreamer/Media/Streaming/GStreamer/Audio/Types.chs ./gstreamer/Media/Streaming/GStreamer/Net/Types.chs ./gstreamer/Media/Streaming/GStreamer/Controller/Types.chs ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp Using 'grep -l -i gtype' in those files I only get: ./gnomevfs/System/Gnome/VFS/Types.chs.pp ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp Thanks, Maurício |
From: Axel S. <Axe...@en...> - 2009-03-17 22:09:42
|
On Mar 17, 2009, at 23:02, Maurí cio wrote: >>> Checking your sugestion, I also found the function below that >>> also uses GType. But, as in 'isA', I could not found (even >>> in Gtk+) how to get values of GType for a given class. (...) >> >> Uh, yes, these are not exported by default. They can be found in >> >> Graphics.UI.Gtk.Types > > Can't find that either. 'www.haskell.org/gtk2hs/docs/current' > shows no module named Types, and 'find . | grep -i /Types' > in gtk2hs 0.10 source tree shows: Hm, it's not haddock'd but the file needs to be there as it contains all the type definitions of all normal widgets. You should be able to get it using import Graphics.UI.Gtk.Types then the names are gBlah where Blah is the widget name. I realize this isn't really the best way of documenting these constants... Axel. > ./gnomevfs/System/Gnome/VFS/Types.chs.pp > ./cairo/Graphics/Rendering/Cairo/Types.chs > ./glib/System/Glib/Types.chs > ./gtk/Graphics/UI/Gtk/ModelView/Types.chs > ./gtk/Graphics/UI/Gtk/Multiline/Types.chs.pp > ./gtk/Graphics/UI/Gtk/Pango/Types.chs.pp > ./gstreamer/Media/Streaming/GStreamer/Base/Types.chs > ./gstreamer/Media/Streaming/GStreamer/Audio/Types.chs > ./gstreamer/Media/Streaming/GStreamer/Net/Types.chs > ./gstreamer/Media/Streaming/GStreamer/Controller/Types.chs > ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp > > Using 'grep -l -i gtype' in those files I only get: > > ./gnomevfs/System/Gnome/VFS/Types.chs.pp > ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp > > Thanks, > Maurício > > > ---------------------------------------------------------------------- > -------- > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) > are > powering Web 2.0 with engaging, cross-platform capabilities. > Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based > development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > Gtk2hs-users mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users |
From: Maurício <bri...@ya...> - 2009-03-18 02:47:50
|
>>> Graphics.UI.Gtk.Types >> Can't find that either. > Hm, it's not haddock'd but the file needs to be there as it contains > all the type definitions of all normal widgets. You should be able to > get it using > > import Graphics.UI.Gtk.Types In the source tree I found that everytime some module imports that module, they use {# #}: {#import Graphics.UI.Gtk.Types#} What does that mean? I can do this in ghci: :m +Graphics.UI.Gtk.Types but it doesn't seem to contain any exported name starting with 'g'. Where the is the source for that Types modules? Maybe reading it I can understand better how to use it. Thanks, Maurício |
From: Axel S. <Axe...@en...> - 2009-03-18 07:22:24
|
On Mar 18, 2009, at 3:47, Maurí cio wrote: >>>> Graphics.UI.Gtk.Types > >>> Can't find that either. > >> Hm, it's not haddock'd but the file needs to be there as it contains >> all the type definitions of all normal widgets. You should be able to >> get it using >> >> import Graphics.UI.Gtk.Types > > In the source tree I found that everytime some module > imports that module, they use {# #}: > > {#import Graphics.UI.Gtk.Types#} Oh, this is c2hs stuff (which is a preprocessor). > What does that mean? I can do this in ghci: > > :m +Graphics.UI.Gtk.Types > > but it doesn't seem to contain any exported name > starting with 'g'. But it should: module Graphics.UI.Gtk.Types ( module System.Glib.GObject, Drawable(Drawable), DrawableClass, toDrawable, mkDrawable, unDrawable, castToDrawable, gTypeDrawable, ^^^^^^^^^^^^^ > Where the is the source for that Types modules? Maybe > reading it I can understand better how to use it. > > It's under: gtk/Graphics/UI/Gtk/Types.chs but reading it will probably confuse you more. Try this: ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.6.1, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. Prelude> :m Graphics.UI.Gtk Graphics.UI.Gtk.Types Prelude Graphics.UI.Gtk.Types Graphics.UI.Gtk> initGUI Loading package glib-0.10.0 ... linking ... done. Loading package mtl-1.0.1 ... linking ... done. Loading package cairo-0.10.0 ... linking ... done. Loading package gtk-0.10.0 ... linking ... done. [] Prelude Graphics.UI.Gtk.Types Graphics.UI.Gtk> gTypeDrawable 13760304 Cheers, Axel. |
From: Maurício <bri...@ya...> - 2009-03-18 11:12:04
|
>> Where the is the source for that Types modules? Maybe >> reading it I can understand better how to use it. >> > It's under: > > gtk/Graphics/UI/Gtk/Types.chs > > but reading it will probably confuse you more. > What is really confusing me is that I just can't find that file. What can be happening? Under gtk gtk/Graphics/UI/Gtk (from tar ball and darcs) the only non-directory files I found are: ./TreeList.hs ./ModelView.hs ./Cairo.chs.pp Maurício |
From: Axel S. <Axe...@en...> - 2009-03-18 13:15:54
|
On Wed, 2009-03-18 at 08:11 -0300, Maurício wrote: > >> Where the is the source for that Types modules? Maybe > >> reading it I can understand better how to use it. > >> > > It's under: > > > > gtk/Graphics/UI/Gtk/Types.chs > > > > but reading it will probably confuse you more. > > > > What is really confusing me is that I just can't find > that file. What can be happening? Under gtk gtk/Graphics/UI/Gtk > (from tar ball and darcs) the only non-directory files I > found are: > > ./TreeList.hs > ./ModelView.hs > ./Cairo.chs.pp > Oh, now I understand. You haven't built the whole thing yet! The Types.chs file is auto-generated from the file tools/typeGen/hierarchy.list . Axel. |
From: Maurício <bri...@ya...> - 2009-03-18 14:00:45
|
> Oh, now I understand. You haven't built the whole thing yet! The > Types.chs file is auto-generated from the file > tools/typeGen/hierarchy.list . > You're rignt... Now I see it. And, actually, it's quite readable! Is there an alternative to those using gtk2hs 0.9.13 (not important, just for easier portability)? I see that 0.9 doesn't seem to have 'isA' or 'widgetGetAncestor'. Thanks, Maurício |
From: Axel S. <Axe...@en...> - 2009-03-18 14:17:18
|
On Wed, 2009-03-18 at 11:00 -0300, Maurício wrote: > > Oh, now I understand. You haven't built the whole thing yet! The > > Types.chs file is auto-generated from the file > > tools/typeGen/hierarchy.list . > > > > You're rignt... Now I see it. And, actually, it's > quite readable! > > Is there an alternative to those using gtk2hs 0.9.13 > (not important, just for easier portability)? I see > that 0.9 doesn't seem to have 'isA' or 'widgetGetAncestor'. No. While these functions are actually there (see castTo... in Types.chs in 0.9.13) I think the function isA was only added after 0.9.13. You could maybe copy the definition from GObject in 0.10.0. Axel. |