I attach a patch. Please let me know if it is suitable.
Tim
On 28/01/12 00:19, Axel Simon wrote:
Hi Tim,
On 27.01.2012, at 13:42, Tim Docker wrote:
Hi,
I am attempting to use widgetModifyBase to change the background of a
text entry, and then restore it again later. It's not clear to me how
the restore should be done. It looks like the function should be taking
(Maybe Color), and indeed the comment suggests this - see below.
According to the gtk c library documentation, a null pointer for color
should be passed in to undo previous calls.
Am I missing something, or is this an oversight in the implementation?
Yes, this is an oversight. The right thing would be to add
widgetRestoreBase, widgetRestoreText, widgetRestoreFg, widgetRestorBg
in order not to break the existing API. In case you feel like
implementing them (with docs, please) then we'll gladly apply a patch.
Cheers,
Axel
Thanks,
Tim
widgetModifyBase :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the base color.
-> Color -- ^ @color@ - the color to assign (does not need to be
-- allocated), or @Nothing@ to undo the effect of
previous calls
-- to of 'widgetModifyBase'.
-> IO ()
widgetModifyBase self state color =
with color $ \colorPtr ->
{# call gtk_widget_modify_base #}
(toWidget self)
((fromIntegral . fromEnum) state)
(castPtr colorPtr)
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel
1 patch for repository http://code.haskell.org/gtk2hs:
Mon Jan 30 08:38:06 EST 2012 t...@dockerz.net
* added widgetRestoreFg, widgetRestoreBg, widgetRestoreText, widgetRestoreBase
These new functions undo the effects of previous calls are to
widgetModifyFg, widgetModifyBg, widgetModifyText, and
widgetModifyBase. Whilst it may have been preferable to implement this
behaviour by having the existing functions take a Maybe type (as this
would be consitent with both widgetModifyFont and the underlying gtk
API), new functions were added so as to preserve the current API.
New patches:
[added widgetRestoreFg, widgetRestoreBg, widgetRestoreText, widgetRestoreBase
t...@dockerz.net**20120129213806
Ignore-this: dc8a919c680a57799abbd1f19b40825d
These new functions undo the effects of previous calls are to
widgetModifyFg, widgetModifyBg, widgetModifyText, and
widgetModifyBase. Whilst it may have been preferable to implement this
behaviour by having the existing functions take a Maybe type (as this
would be consitent with both widgetModifyFont and the underlying gtk
API), new functions were added so as to preserve the current API.
] hunk ./gtk/Graphics/UI/Gtk/Abstract/Widget.chs 161
widgetModifyText,
widgetModifyBase,
widgetModifyFont,
+ widgetRestoreFg,
+ widgetRestoreBg,
+ widgetRestoreText,
+ widgetRestoreBase,
widgetCreatePangoContext,
widgetGetPangoContext,
widgetCreateLayout,
hunk ./gtk/Graphics/UI/Gtk/Abstract/Widget.chs 1391
widgetModifyFg :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the foreground color.
-> Color -- ^ @color@ - the color to assign (does not need to be
- -- allocated), or @Nothing@ to undo the effect of previous calls
- -- to of 'widgetModifyFg'.
+ -- allocated)
-> IO ()
widgetModifyFg self state color =
with color $ \colorPtr ->
hunk ./gtk/Graphics/UI/Gtk/Abstract/Widget.chs 1400
((fromIntegral . fromEnum) state)
(castPtr colorPtr)
+-- | Restores the foreground color for a widget in a particular state. This
+-- undoes the effects of previous calls to `widgetModifyFg'.
+--
+widgetRestoreFg :: WidgetClass self => self
+ -> StateType -- ^ @state@ - the state for which to restore the foreground color.
+ -> IO ()
+widgetRestoreFg self state =
+ {# call gtk_widget_modify_fg #}
+(toWidget self)
+((fromIntegral . fromEnum) state)
+nullPtr
+
-- %hash c:2c5
-- | Sets the background color for a widget in a particular state. All other
-- style values are left untouched. See also 'widgetModifyStyle'.
hunk ./gtk/Graphics/UI/Gtk/Abstract/Widget.chs 1426
widgetModifyBg :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the background color.
-> Color -- ^ @color@ - the color to assign (does not need to be
- -- allocated), or @Nothing@ to undo the e