Alexander McPhail | 1 Oct 2010 10:45
Picon

GHC 7 and cairo-0.11.1

Hi,

To get Gtk2HsSetup.hs to compile with the release candidate 7.0.0.20100929 requires

s/\[packageDb\]/packageDb/ on line 190.

Vivian

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Gtk2hs-users mailing list
Gtk2hs-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-users
Axel Simon | 1 Oct 2010 13:11
Picon
Favicon

Re: GHC 7 and cairo-0.11.1

Hi Vivian,

On 01.10.2010, at 10:45, Alexander McPhail wrote:

> Hi,
>
> To get Gtk2HsSetup.hs to compile with the release candidate  
> 7.0.0.20100929 requires
>
> s/\[packageDb\]/packageDb/ on line 190.
>

Thanks for the report. What Cabal version is shipped with ghc 7.0?

Axel

> Vivian
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev_______________________________________________
> Gtk2hs-users mailing list
> Gtk2hs-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gtk2hs-users

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
Tom Ostojich | 4 Oct 2010 01:14
Picon

Creating Widgets While Inside the EventM Monad

Hello all,

A recurring problem in my code is that I want to bind a key event to
the creation of, say, a dialog window. Usually, binding the key event
isn't that hard, since you can do the following:

    window `on` keyPressEvent $ tryEvent $ do
        [Control] <- eventModifier
        "r"       <- eventKeyName
        liftIO $ ioFunction

However, since the monad expects for the function to essentially
return a type of (), it becomes very difficult to create a dialog
window while you're in the EventM monad, since the following code
would give a type error:

    window `on` keyPressEvent $ tryEvent $ do
        [Control] <- eventModifier
        "t"       <- eventKeyName
        liftIO $ functionThatInstansiatesAWidget

Reading up various pages on the Reader monad and available GTK
documentation doesn't seem to handle these kinds of situations. Is
there any way (preferably one that involves the least number of
mutations) that I could use that will allow me to bind a key event to
the creation of a dialog window (or any widget for that matter)?

Thanks in advance,

Tom Ostojich

------------------------------------------------------------------------------
Virtualization is moving to the mainstream and overtaking non-virtualized
environment for deploying applications. Does it make network security 
easier or more difficult to achieve? Read this whitepaper to separate the 
two and get a better understanding.
http://p.sf.net/sfu/hp-phase2-d2d
Andy Stewart | 4 Oct 2010 04:23
Picon

Re: Creating Widgets While Inside the EventM Monad

Hi Tom,

When you use EventM, you must end with 'IO ()', otherwise mismatch.

Whatever use Events or EventM, the return value of 'signal handler' is
for signal, and not use for return value *outside* signal handler.

I suggest you use IORef or TVar build [DialogWidget] or something,
example like :

   dialogList <- newIORef []
   window `on` keyPressEvent $ tryEvent $ do
       [Control] <- eventModifier
       "t"       <- eventKeyName
       -- When match "Ctrl + t", you can do any action for new dialog here.
       liftIO $ do
           dialog <- dialogNew
           modifyIORef dialogList (\x -> dialog : x)
           ...
           -- Action for new dialog ...
           ...

Cheers,

  -- Andy

Tom Ostojich <tostojich <at> gmail.com> writes:

> Hello all,
>
> A recurring problem in my code is that I want to bind a key event to
> the creation of, say, a dialog window. Usually, binding the key event
> isn't that hard, since you can do the following:
>
>     window `on` keyPressEvent $ tryEvent $ do
>         [Control] <- eventModifier
>         "r"       <- eventKeyName
>         liftIO $ ioFunction
>
> However, since the monad expects for the function to essentially
> return a type of (), it becomes very difficult to create a dialog
> window while you're in the EventM monad, since the following code
> would give a type error:
>
>     window `on` keyPressEvent $ tryEvent $ do
>         [Control] <- eventModifier
>         "t"       <- eventKeyName
>         liftIO $ functionThatInstansiatesAWidget
>
> Reading up various pages on the Reader monad and available GTK
> documentation doesn't seem to handle these kinds of situations. Is
> there any way (preferably one that involves the least number of
> mutations) that I could use that will allow me to bind a key event to
> the creation of a dialog window (or any widget for that matter)?
>
> Thanks in advance,
>
> Tom Ostojich
>
> ------------------------------------------------------------------------------
> Virtualization is moving to the mainstream and overtaking non-virtualized
> environment for deploying applications. Does it make network security 
> easier or more difficult to achieve? Read this whitepaper to separate the 
> two and get a better understanding.
> http://p.sf.net/sfu/hp-phase2-d2d

------------------------------------------------------------------------------
Virtualization is moving to the mainstream and overtaking non-virtualized
environment for deploying applications. Does it make network security 
easier or more difficult to achieve? Read this whitepaper to separate the 
two and get a better understanding.
http://p.sf.net/sfu/hp-phase2-d2d
Tim Docker | 7 Oct 2010 06:07

Re: unicode strings and cairo

On 27/09/10 08:08, Axel Simon wrote:

> There is a demo in the pango package which renders some text using
> Cairo. The key is 'showLayout' which renders a PangoContext in a Cairo
> Render monad.

Actually, I've one more question on this. I need to find out the width 
and height of string as it will be rendered by "showLayout". In the 
basic cairo font api, I write:

-- | Return the bounding rectangle for a text string rendered
--   in the current context.
textSize :: String -> CRender RectSize
textSize s = c $ do
     te <- C.textExtents s
     fe <- C.fontExtents
     return (C.textExtentsWidth te, C.fontExtentsHeight fe)

What are the equivalent functions in the pango world?

Thanks,

Tim

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
Axel Simon | 6 Oct 2010 19:01
Picon
Favicon

Re: unicode strings and cairo

Hi Tim,

On Oct 7, 2010, at 6:07, Tim Docker wrote:

> On 27/09/10 08:08, Axel Simon wrote:
>
>> There is a demo in the pango package which renders some text using
>> Cairo. The key is 'showLayout' which renders a PangoContext in a  
>> Cairo
>> Render monad.
>
> Actually, I've one more question on this. I need to find out the  
> width and height of string as it will be rendered by "showLayout".  
> In the basic cairo font api, I write:
>
> -- | Return the bounding rectangle for a text string rendered
> --   in the current context.
> textSize :: String -> CRender RectSize
> textSize s = c $ do
>    te <- C.textExtents s
>    fe <- C.fontExtents
>    return (C.textExtentsWidth te, C.fontExtentsHeight fe)
>
> What are the equivalent functions in the pango world?
>

You would create a Layout and then use layoutGetExtends (or something  
like this). The unit of measure is determined by pt/unit ratio which  
can be set for each cairo context.

You'll find these functions somewhere in Pango.Cairo.

Cheers,
Axel
> Thanks,
>
> Tim

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
Tim Docker | 7 Oct 2010 12:40

Re: unicode strings and cairo

On 06/10/10 12:01, Axel Simon wrote:

> You would create a Layout and then use layoutGetExtends (or something
> like this). The unit of measure is determined by pt/unit ratio which can
> be set for each cairo context.
>
> You'll find these functions somewhere in Pango.Cairo.

Got it. Thanks. I was confused because I was searching for functions in 
the cairo Render monad. Is there a way to run this function:

layoutGetExtents :: PangoLayout	-> IO (PangoRectangle, PangoRectangle)

in the render monad? Is there a general lifting function to run any
io action within Render?

Tim

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
Axel Simon | 6 Oct 2010 22:12
Picon
Favicon

Re: unicode strings and cairo


On Oct 7, 2010, at 12:40, Tim Docker wrote:

> On 06/10/10 12:01, Axel Simon wrote:
>
>> You would create a Layout and then use layoutGetExtends (or something
>> like this). The unit of measure is determined by pt/unit ratio  
>> which can
>> be set for each cairo context.
>>
>> You'll find these functions somewhere in Pango.Cairo.
>
> Got it. Thanks. I was confused because I was searching for functions  
> in the cairo Render monad. Is there a way to run this function:
>
> layoutGetExtents :: PangoLayout	-> IO (PangoRectangle, PangoRectangle)
>
> in the render monad? Is there a general lifting function to run any
> io action within Render?
>

Yes, RenderM has a MonadIO instance, so you can just use liftIO to  
execute any IO function.

Axel

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
Eugene Kirpichov | 12 Oct 2010 12:49
Picon
Gravatar

gtk2hs-buildtools dependencies in cabal

Hello.

Is there any reason why the packages like "cairo" don't list
gtk2hs-buildtools in their cabal dependencies?
This seems quite confusing; for example, I had a hard time figuring
out myself what I have to install to get rid of this error:

Configuring cairo-0.11.1...
setup: gtk2hsC2hs is required but it could not be found.

I also had to explain my friends to install this package when they
tried to use my application which required cairo (the app is
"timeplot").

Could this installation process of gtk2hs, cairo et al. be streamlined
to "one-click"?

--

-- 
Eugene Kirpichov
Senior Software Engineer,
Grid Dynamics http://www.griddynamics.com/

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
Axel Simon | 12 Oct 2010 14:25
Picon
Favicon

Re: gtk2hs-buildtools dependencies in cabal

Hi Eugene,

On Oct 12, 2010, at 12:49, Eugene Kirpichov wrote:

> Hello.
>
> Is there any reason why the packages like "cairo" don't list
> gtk2hs-buildtools in their cabal dependencies?
> This seems quite confusing; for example, I had a hard time figuring
> out myself what I have to install to get rid of this error:
>
> Configuring cairo-0.11.1...
> setup: gtk2hsC2hs is required but it could not be found.
>
> I also had to explain my friends to install this package when they
> tried to use my application which required cairo (the app is
> "timeplot").
>
> Could this installation process of gtk2hs, cairo et al. be streamlined
> to "one-click"?
>

No, unfortunately we can't. Cabal will call these tools before it  
inferes dependencies. So even if we add a dependency on gtk2hs- 
buildtools, you would still see the same error message. I don't know  
if Cabal will or can change this behaviour in the future.

Sorry, there's nothing we can do...

Axel

> -- 
> Eugene Kirpichov
> Senior Software Engineer,
> Grid Dynamics http://www.griddynamics.com/
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating  
> great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Gtk2hs-users mailing list
> Gtk2hs-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gtk2hs-users

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb

Gmane