2
-- GIMP Toolkit (GTK) Widget RadioToolButton
4
-- Author : Duncan Coutts
6
-- Created: 7 April 2005
8
-- Version $Revision: 1.4 $ from $Date: 2005/10/19 12:57:37 $
10
-- Copyright (C) 2005 Duncan Coutts
12
-- This library is free software; you can redistribute it and/or
13
-- modify it under the terms of the GNU Lesser General Public
14
-- License as published by the Free Software Foundation; either
15
-- version 2.1 of the License, or (at your option) any later version.
17
-- This library is distributed in the hope that it will be useful,
18
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
-- Lesser General Public License for more details.
23
-- Maintainer : gtk2hs-users@lists.sourceforge.net
24
-- Stability : provisional
25
-- Portability : portable (depends on GHC)
27
-- A toolbar item that contains a radio button
29
-- * Module available since Gtk+ version 2.4
31
module Graphics.UI.Gtk.MenuComboToolbar.RadioToolButton (
34
-- | A 'RadioToolButton' is a 'ToolItem' that contains a radio button, that
35
-- is, a button that is part of a group of toggle buttons where only one button
36
-- can be active at a time.
38
-- Use 'radioToolButtonNew' to create a new 'RadioToolButton'. use
39
-- 'radioToolButtonNewFromWidget' to create a new 'RadioToolButton' that is
40
-- part of the same group as an existing 'RadioToolButton'. Use
41
-- 'radioToolButtonNewFromStock' or 'radioToolButtonNewFromWidgetWithStock' to
42
-- create a new 'RadioToolButton' containing a stock item.
53
-- | +----'ToolButton'
54
-- | +----'ToggleToolButton'
55
-- | +----RadioToolButton
58
#if GTK_CHECK_VERSION(2,4,0)
62
castToRadioToolButton,
67
radioToolButtonNewFromStock,
68
radioToolButtonNewFromWidget,
69
radioToolButtonNewWithStockFromWidget,
72
radioToolButtonGetGroup,
73
radioToolButtonSetGroup,
82
import System.Glib.FFI
83
import System.Glib.UTFString
84
import System.Glib.GList
85
import System.Glib.Attributes
86
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
87
{#import Graphics.UI.Gtk.Types#}
88
{#import Graphics.UI.Gtk.Signals#}
90
{# context lib="gtk" prefix="gtk" #}
92
#if GTK_CHECK_VERSION(2,4,0)
96
-- | Creates a new 'RadioToolButton', creating a new group.
98
radioToolButtonNew :: IO RadioToolButton
100
makeNewObject mkRadioToolButton $
101
liftM (castPtr :: Ptr ToolItem -> Ptr RadioToolButton) $
102
{# call gtk_radio_tool_button_new #}
105
-- | Creates a new 'RadioToolButton', creating a new group. The new
106
-- 'RadioToolButton' will contain an icon and label from the stock item
107
-- indicated by @stockId@.
109
radioToolButtonNewFromStock ::
110
String -- ^ @stockId@ - the name of a stock item
111
-> IO RadioToolButton
112
radioToolButtonNewFromStock stockId =
113
makeNewObject mkRadioToolButton $
114
liftM (castPtr :: Ptr ToolItem -> Ptr RadioToolButton) $
115
withUTFString stockId $ \stockIdPtr ->
116
{# call gtk_radio_tool_button_new_from_stock #}
120
-- | Creates a new 'RadioToolButton' adding it to the same group as
121
-- the group to which @groupMember@ belongs.
123
radioToolButtonNewFromWidget :: RadioToolButtonClass groupMember =>
124
groupMember -- ^ @groupMember@ - a member of an existing radio group,
125
-- to which the new radio tool button will be added.
126
-> IO RadioToolButton
127
radioToolButtonNewFromWidget group =
128
makeNewObject mkRadioToolButton $
129
liftM (castPtr :: Ptr ToolItem -> Ptr RadioToolButton) $
130
{# call gtk_radio_tool_button_new_from_widget #}
131
(toRadioToolButton group)
133
-- | Creates a new 'RadioToolButton' adding it to the same group as the group
134
-- to which @groupMember@ belongs. The new 'RadioToolButton' will contain an
135
-- icon and label from the stock item indicated by @stockId@.
137
radioToolButtonNewWithStockFromWidget :: RadioToolButtonClass groupMember =>
138
groupMember -- ^ @groupMember@ - a member of an existing radio group,
139
-- to which the new radio tool button will be added.
140
-> String -- ^ @stockId@ - the name of a stock item
141
-> IO RadioToolButton
142
radioToolButtonNewWithStockFromWidget group stockId =
143
makeNewObject mkRadioToolButton $
144
liftM (castPtr :: Ptr ToolItem -> Ptr RadioToolButton) $
145
withUTFString stockId $ \stockIdPtr ->
146
{# call gtk_radio_tool_button_new_with_stock_from_widget #}
147
(toRadioToolButton group)
153
-- | Returns the radio button group @button@ belongs to.
155
radioToolButtonGetGroup :: RadioToolButtonClass self => self
156
-> IO [RadioToolButton] -- ^ returns the group the button belongs to.
157
radioToolButtonGetGroup self =
158
{# call unsafe gtk_radio_tool_button_get_group #}
159
(toRadioToolButton self)
161
>>= mapM (\elemPtr -> makeNewObject mkRadioToolButton (return elemPtr))
163
-- | Adds @button@ to @group@, removing it from the group it belonged to
166
radioToolButtonSetGroup :: RadioToolButtonClass self => self
167
-> RadioToolButton -- ^ @groupMember@ - a member of an existing radio group,
168
-- to which the radio tool button will be added.
170
radioToolButtonSetGroup self group =
171
{# call unsafe gtk_radio_tool_button_get_group #} group >>= \groupGSList ->
172
{# call gtk_radio_tool_button_set_group #}
173
(toRadioToolButton self)
179
-- | Sets a new group for a radio tool button.
181
radioToolButtonGroup :: RadioToolButtonClass self => ReadWriteAttr self [RadioToolButton] RadioToolButton
182
radioToolButtonGroup = newAttr
183
radioToolButtonGetGroup
184
radioToolButtonSetGroup