Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/MenuComboToolbar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1048/gtk/Graphics/UI/Gtk/MenuComboToolbar Added Files: OptionMenu.chs.pp Menu.chs.pp ComboBoxEntry.chs.pp ComboBox.chs.pp Combo.chs.pp CheckMenuItem.chs.pp Log Message: hierarchical namespace conversion --- NEW FILE: ComboBoxEntry.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) entry Widget ComboBoxEntry -- -- Author : Duncan Coutts -- Created: 25 April 2004 -- -- Copyright (c) 2004 Duncan Coutts -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Library General Public -- License as published by the Free Software Foundation; either -- version 2 of the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Library General Public License for more details. -- -- | -- -- A text entry field with a dropdown list -- -- * Added in gtk 2.4 -- module Graphics.UI.Gtk.MenuComboToolbar.ComboBoxEntry ( #if GTK_CHECK_VERSION(2,4,0) ComboBoxEntryClass, ComboBoxEntry, comboBoxEntryNew, comboBoxEntryNewWithModel, comboBoxEntryNewText, comboBoxEntrySetTextColumn, comboBoxEntryGetTextColumn, #endif ) where #if GTK_CHECK_VERSION(2,4,0) import Monad (liftM) import System.Glib.FFI import Graphics.UI.Gtk.Abstract.Object (makeNewObject) import System.Glib.GObject (makeNewGObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} {# context lib="gtk" prefix ="gtk" #} comboBoxEntryNew :: IO ComboBoxEntry comboBoxEntryNew = makeNewObject mkComboBoxEntry $ liftM castPtr $ {# call gtk_combo_box_entry_new #} comboBoxEntryNewWithModel :: TreeModel -> Int -> IO ComboBoxEntry comboBoxEntryNewWithModel model textColumn = makeNewObject mkComboBoxEntry $ liftM castPtr $ {# call gtk_combo_box_entry_new_with_model #} model (fromIntegral textColumn) comboBoxEntryNewText :: IO ComboBoxEntry comboBoxEntryNewText = makeNewObject mkComboBoxEntry $ liftM castPtr $ {# call gtk_combo_box_entry_new_text #} comboBoxEntrySetTextColumn :: ComboBoxEntryClass combo => combo -> Int -> IO () comboBoxEntrySetTextColumn combo textColumn = {# call gtk_combo_box_entry_set_text_column #} (toComboBoxEntry combo) (fromIntegral textColumn) comboBoxEntryGetTextColumn :: ComboBoxEntryClass combo => combo -> IO Int comboBoxEntryGetTextColumn combo = liftM fromIntegral $ {# call gtk_combo_box_entry_get_text_column #} (toComboBoxEntry combo) #endif --- NEW FILE: Menu.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Menu -- -- Author : Axel Simon -- -- Created: 21 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:25:36 $ -- -- Copyright (c) 1999..2002 Axel Simon -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- -- A Menu is a vertically aligned set of options that can be selected. There -- are two kinds: Those that are part of a 'MenuBar' and those -- that appear as a context menu (within the work space). -- -- TODO -- -- * The following not bound functions might be useful: -- menuSetAccelGroup, menuSetAccelGroup, menuReposition -- -- * The function menuPopup at a specific position is difficult to bind: -- The callback function that determines at which position the menu is -- to be shown is keept after the call returns. Maybe we could destroy -- this function pointer with a destory event? -- module Graphics.UI.Gtk.MenuComboToolbar.Menu ( Menu, MenuClass, castToMenu, menuNew, menuReorderChild, menuPopup, menuSetAccelGroup, menuGetAccelGroup, menuSetAccelPath, menuSetTitle, menuGetTitle, menuPopdown, menuReposition, menuGetActive, menuSetActive, menuSetTearoffState, menuGetTearoffState, menuAttachToWidget, menuDetach, menuGetAttachWidget, #if GTK_CHECK_VERSION(2,2,0) menuSetScreen, #endif #if GTK_CHECK_VERSION(2,4,0) menuSetMonitor, #endif ) where import Monad (liftM) import Maybe (fromMaybe) import System.Glib.FFI import System.Glib.UTFString import System.Glib.GObject (makeNewGObject) import Graphics.UI.Gtk.Abstract.Object (makeNewObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} import Graphics.UI.Gtk.Gdk.Events as Events (Event(Button), time, button) {# context lib="gtk" prefix="gtk" #} -- methods -- | Make an empty Menu. -- menuNew :: IO Menu menuNew = makeNewObject mkMenu $ liftM castPtr {#call unsafe menu_new#} -- | Move a child to a new position within the menu. -- -- * The position is counted from 0 to n-1 if the menu contains n entries. -- menuReorderChild :: (MenuClass m, MenuItemClass mi) => m -> mi -> Int -> IO () menuReorderChild m child pos = {#call menu_reorder_child#} (toMenu m) (toWidget child) (fromIntegral pos) -- | Popup a context menu where a button press occurred. -- -- menuPopup :: MenuClass m => m -> Event -> IO () menuPopup m (Events.Button { time=t, button=b }) = {#call menu_popup#} (toMenu m) (mkWidget nullForeignPtr) (mkWidget nullForeignPtr) nullFunPtr nullPtr ((fromIntegral.fromEnum) b) (fromIntegral t) menuPopup _ _ = error "menuPopup: Button event expected." -- | Set the "AccelGroup" which holds global accelerators for the menu. This -- accelerator group needs to also be added to all windows that this menu is -- being used in with 'windowAddAccelGroup', in order for those windows to -- support all the accelerators contained in this group. -- menuSetAccelGroup :: MenuClass m => m -> AccelGroup -> IO () menuSetAccelGroup m accel = {#call menu_set_accel_group#} (toMenu m) accel -- | Gets the "AccelGroup" which holds global accelerators for the menu. See -- 'menuSetAccelGroup'. -- menuGetAccelGroup :: MenuClass m => m -> IO AccelGroup menuGetAccelGroup m = makeNewGObject mkAccelGroup $ {#call unsafe menu_get_accel_group#} (toMenu m) -- | Sets an accelerator path for this menu from which accelerator paths for its -- immediate children, its menu items, can be constructed. The main purpose of -- this function is to spare the programmer the inconvenience of having to call -- 'menuItemSetAccelPath' on each menu item that should support runtime user -- changable accelerators. Instead, by just calling 'menuSetAccelPath' on their -- parent, each menu item of this menu, that contains a label describing its -- purpose, automatically gets an accel path assigned. -- -- For example, a menu containing menu items \"New\" and \"Exit\", will, after -- calling -- -- > menu `menuSetAccelPath` "<Gnumeric-Sheet>/File" -- -- assign its items the accel paths: \"<Gnumeric-Sheet>\/File\/New\" and -- \"<Gnumeric-Sheet>\/File\/Exit\". -- -- Assigning accel paths to menu items then enables the user to change their -- accelerators at runtime. More details about accelerator paths and their -- default setups can be found at 'accelMapAddEntry'. -- menuSetAccelPath :: MenuClass m => m -> String -> IO () menuSetAccelPath m accelPath = withUTFString accelPath $ \strPtr -> {#call menu_set_accel_path#} (toMenu m) strPtr -- | Set the title of the menu. It is displayed if the menu is shown as a -- tearoff menu. -- menuSetTitle :: MenuClass m => m -> String -> IO () menuSetTitle m title = withUTFString title $ \strPtr -> {#call unsafe menu_set_title#} (toMenu m) strPtr -- | Returns the title of the menu, orNothing if the menu has no title set on -- it. -- menuGetTitle :: MenuClass m => m -> IO (Maybe String) menuGetTitle m = {#call unsafe menu_get_title#} (toMenu m) >>= maybePeek peekUTFString -- | Remove a context or tearoff menu from the screen. -- menuPopdown :: MenuClass m => m -> IO () menuPopdown m = {#call menu_popdown#} (toMenu m) -- | Repositions the menu according to its position function. -- menuReposition :: MenuClass m => m -> IO () menuReposition m = {#call menu_reposition#} (toMenu m) -- | Return the currently selected menu item. -- menuGetActive :: MenuClass m => m -> IO MenuItem menuGetActive m = makeNewObject mkMenuItem $ throwIfNull "menuGetActive: menu contains no menu items." $ liftM castPtr $ {#call menu_get_active#} (toMenu m) -- | Select the @n@th item of the menu. -- menuSetActive :: MenuClass m => m -> Int -> IO () menuSetActive m n = {#call menu_set_active#} (toMenu m) (fromIntegral n) -- | Specify whether the menu is to be shown as a tearoff menu. -- menuSetTearoffState :: MenuClass m => m -> Bool -> IO () menuSetTearoffState m tornOff = {#call menu_set_tearoff_state#} (toMenu m) (fromBool tornOff) -- | Returns whether the menu is torn off. -- menuGetTearoffState :: MenuClass m => m -> IO Bool menuGetTearoffState m = liftM toBool $ {#call unsafe menu_get_tearoff_state#} (toMenu m) -- | Attach this menu to another widget. -- menuAttachToWidget :: (MenuClass m, WidgetClass w) => m -> w -> IO () menuAttachToWidget m w = {#call menu_attach_to_widget#} (toMenu m) (toWidget w) nullFunPtr -- | Detach this menu from the widget it is attached to. -- menuDetach :: MenuClass m => m -> IO () menuDetach m = {#call menu_detach#} (toMenu m) -- | Get the widget this menu is attached to. Returns Nothing if this is a -- tearoff (context) menu. -- menuGetAttachWidget :: MenuClass m => m -> IO (Maybe Widget) menuGetAttachWidget m = do wPtr <- {#call unsafe menu_get_attach_widget#} (toMenu m) if wPtr==nullPtr then return Nothing else liftM Just $ makeNewObject mkWidget (return wPtr) #if GTK_CHECK_VERSION(2,2,0) -- | Sets the "Screen" on which the menu will be displayed. -- menuSetScreen :: MenuClass m => m -> Maybe Screen -> IO () menuSetScreen m screen = {#call menu_set_screen#} (toMenu m) (fromMaybe (Screen nullForeignPtr) screen) #endif #if GTK_CHECK_VERSION(2,4,0) -- | Informs GTK+ on which monitor a menu should be popped up. -- menuSetMonitor :: MenuClass m => m -> Int -- ^ The number of the monitor on which the menu -- should be popped up -> IO () menuSetMonitor m monitorNum = {#call menu_set_monitor#} (toMenu m) (fromIntegral monitorNum) #endif --- NEW FILE: ComboBox.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) entry Widget ComboBox -- -- Author : Duncan Coutts -- Created: 25 April 2004 -- -- Copyright (c) 2004 Duncan Coutts -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Library General Public -- License as published by the Free Software Foundation; either -- version 2 of the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Library General Public License for more details. -- -- | -- -- A widget used to choose from a list of items. -- -- * Added in Gtk 2.4 -- module Graphics.UI.Gtk.MenuComboToolbar.ComboBox ( #if GTK_CHECK_VERSION(2,4,0) ComboBoxClass, ComboBox, comboBoxNew, comboBoxNewWithModel, comboBoxSetWrapWidth, comboBoxSetRowSpanColumn, comboBoxSetColumnSpanColumn, comboBoxGetActive, comboBoxSetActive, comboBoxGetActiveIter, comboBoxSetActiveIter, comboBoxGetModel, comboBoxSetModel, comboBoxNewText, comboBoxAppendText, comboBoxInsertText, comboBoxPrependText, comboBoxRemoveText, comboBoxPopup, comboBoxPopdown #endif ) where #if GTK_CHECK_VERSION(2,4,0) import Monad (liftM) import System.Glib.FFI import System.Glib.UTFString import Graphics.UI.Gtk.Abstract.Object (makeNewObject) import System.Glib.GObject (makeNewGObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} {#import Graphics.UI.Gtk.TreeList.TreeModel#} (TreeIter(..), createTreeIter) {# context lib="gtk" prefix ="gtk" #} comboBoxNew :: IO ComboBox comboBoxNew = makeNewObject mkComboBox $ liftM castPtr $ {# call gtk_combo_box_new #} comboBoxNewWithModel :: TreeModel -> IO ComboBox comboBoxNewWithModel model = makeNewObject mkComboBox $ liftM castPtr $ {# call gtk_combo_box_new_with_model #} model comboBoxSetWrapWidth :: ComboBoxClass combo => combo -> Int -> IO () comboBoxSetWrapWidth combo width = {# call gtk_combo_box_set_wrap_width #} (toComboBox combo) (fromIntegral width) comboBoxSetRowSpanColumn :: ComboBoxClass combo => combo -> Int -> IO () comboBoxSetRowSpanColumn combo rowSpan = {# call gtk_combo_box_set_row_span_column #} (toComboBox combo) (fromIntegral rowSpan) comboBoxSetColumnSpanColumn :: ComboBoxClass combo => combo -> Int -> IO () comboBoxSetColumnSpanColumn combo columnSpan = {# call gtk_combo_box_set_column_span_column #} (toComboBox combo) (fromIntegral columnSpan) comboBoxGetActive :: ComboBoxClass combo => combo -> IO (Maybe Int) comboBoxGetActive combo = do index <- {# call gtk_combo_box_get_active #} (toComboBox combo) if index == -1 then return Nothing else return (Just $ fromIntegral index) comboBoxSetActive :: ComboBoxClass combo => combo -> Int -> IO () comboBoxSetActive combo index = {# call gtk_combo_box_set_active #} (toComboBox combo) (fromIntegral index) comboBoxGetActiveIter :: ComboBoxClass combo => combo -> IO (Maybe TreeIter) comboBoxGetActiveIter combo = allocaBytes {# sizeof TreeIter #} $ \iterPtr -> do iter <- createTreeIter iterPtr wasSet <- liftM toBool $ {# call gtk_combo_box_get_active_iter #} (toComboBox combo) iter if wasSet then return (Just iter) else return Nothing comboBoxSetActiveIter :: ComboBoxClass combo => combo -> TreeIter -> IO () comboBoxSetActiveIter combo iter = {# call gtk_combo_box_set_active_iter #} (toComboBox combo) iter comboBoxGetModel :: ComboBoxClass combo => combo -> IO (Maybe TreeModel) comboBoxGetModel combo = do modelPtr <- {# call gtk_combo_box_get_model #} (toComboBox combo) if modelPtr == nullPtr then return Nothing else liftM Just $ makeNewGObject mkTreeModel (return modelPtr) comboBoxSetModel :: ComboBoxClass combo => combo -> TreeModel -> IO () comboBoxSetModel combo model = {# call gtk_combo_box_set_model #} (toComboBox combo) model comboBoxNewText :: IO ComboBox comboBoxNewText = makeNewObject mkComboBox $ liftM castPtr $ {# call gtk_combo_box_new_text #} comboBoxAppendText :: ComboBoxClass combo => combo -> String -> IO () comboBoxAppendText combo text = withUTFString text $ \strPtr -> {# call gtk_combo_box_append_text #} (toComboBox combo) strPtr comboBoxInsertText :: ComboBoxClass combo => combo -> Int -> String -> IO () comboBoxInsertText combo index text = withUTFString text $ \strPtr -> {# call gtk_combo_box_insert_text #} (toComboBox combo) (fromIntegral index) strPtr comboBoxPrependText :: ComboBoxClass combo => combo -> String -> IO () comboBoxPrependText combo text = withUTFString text $ \strPtr -> {# call gtk_combo_box_prepend_text #} (toComboBox combo) strPtr comboBoxRemoveText :: ComboBoxClass combo => combo -> Int -> IO () comboBoxRemoveText combo index = {# call gtk_combo_box_remove_text #} (toComboBox combo) (fromIntegral index) comboBoxPopup :: ComboBoxClass combo => combo -> IO () comboBoxPopup combo = {# call gtk_combo_box_popup #} (toComboBox combo) comboBoxPopdown :: ComboBoxClass combo => combo -> IO () comboBoxPopdown combo = {# call gtk_combo_box_popdown #} (toComboBox combo) #endif --- NEW FILE: Combo.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Combo -- -- Author : Axel Simon -- -- Created: 2 June 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:25:36 $ -- -- Copyright (c) 1999..2002 Axel Simon -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- -- A Combo box is a text entry field with a drop down list of predefined -- alternatives. -- -- * The Combo widget allows to insert arbitrary widgets as alternatives. Due -- to the deprecated ListItem object we currently make no use of this -- feature. -- -- TODO -- -- * The combo_set_item_string function is not bound as we do not handle -- arbitrary widgets yet. -- module Graphics.UI.Gtk.MenuComboToolbar.Combo ( #ifndef DISABLE_DEPRECATED Combo, ComboClass, castToCombo, comboNew, comboSetPopdownStrings, comboSetValueInList, comboSetUseArrows, comboSetUseArrowsAlways, comboSetCaseSensitive, comboDisableActivate #endif ) where #ifndef DISABLE_DEPRECATED import Monad (liftM, mapM_) import System.Glib.FFI import System.Glib.UTFString import Graphics.UI.Gtk.Abstract.Object (makeNewObject) import Graphics.UI.Gtk.Abstract.Widget (widgetShow) import Graphics.UI.Gtk.Abstract.Container (containerAdd) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} import Graphics.UI.Gtk.General.Structs (comboGetList) {# context lib="gtk" prefix="gtk" #} -- methods -- Create a new Combo text entry field. -- comboNew :: IO Combo comboNew = makeNewObject mkCombo $ liftM castPtr $ {#call unsafe combo_new#} -- | Insert a set of Strings into the -- 'Combo' drop down list. -- comboSetPopdownStrings :: ComboClass c => c -> [String] -> IO () comboSetPopdownStrings c strs = do list <- comboGetList (toCombo c) {#call list_clear_items#} list 0 (-1) mapM_ (\str -> do li <- makeNewObject mkWidget $ liftM castPtr $ withUTFString str {#call unsafe list_item_new_with_label#} widgetShow li containerAdd list li) strs -- | Specify whether the user may enter texts that -- are not in the list of alternatives and if empty entries are allowed. -- comboSetValueInList :: ComboClass c => c -> Bool -> Bool -> IO () comboSetValueInList c val okIfEmpty = {#call unsafe combo_set_value_in_list#} (toCombo c) (fromBool val) (fromBool okIfEmpty) -- | Specify if the user may use the cursor keys to -- navigate the list. -- comboSetUseArrows :: ComboClass c => c -> Bool -> IO () comboSetUseArrows c val = {#call unsafe combo_set_use_arrows#} (toCombo c) (fromBool val) -- | Specify if the content entered by the user -- will be replaced by a predefined alternative as soon as the user uses the -- cursor keys. -- comboSetUseArrowsAlways :: ComboClass c => c -> Bool -> IO () comboSetUseArrowsAlways c val = {#call unsafe combo_set_use_arrows_always#} (toCombo c) (fromBool val) -- | Specify whether the entered text is case -- sensitive when it comes to matching the users input with the predefined -- alternatives. -- comboSetCaseSensitive :: ComboClass c => c -> Bool -> IO () comboSetCaseSensitive c val = {#call unsafe combo_set_case_sensitive#} (toCombo c) (fromBool val) -- | Stops the GtkCombo widget from showing the -- popup list when the Entry emits the \"activate\" signal, i.e. when the Return -- key is pressed. This may be useful if, for example, if you want the Return -- key to close a dialog instead. -- comboDisableActivate :: ComboClass c => c -> IO () comboDisableActivate = {#call unsafe combo_disable_activate#}.toCombo #endif --- NEW FILE: CheckMenuItem.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget CheckMenuItem -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:25:36 $ -- -- Copyright (c) 1999..2002 Axel Simon -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- -- This widget implements a 'MenuItem' with a check next to it. -- module Graphics.UI.Gtk.MenuComboToolbar.CheckMenuItem ( CheckMenuItem, CheckMenuItemClass, checkMenuItemNew, checkMenuItemNewWithLabel, checkMenuItemNewWithMnemonic, checkMenuItemSetActive, checkMenuItemGetActive, checkMenuItemToggled, checkMenuItemSetInconsistent, checkMenuItemGetInconsistent #if GTK_CHECK_VERSION(2,4,0) ,checkMenuItemGetDrawAsRadio, checkMenuItemSetDrawAsRadio #endif ) where import Monad (liftM) import System.Glib.FFI import System.Glib.UTFString import Graphics.UI.Gtk.Abstract.Object (makeNewObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} {#context lib="gtk" prefix="gtk" #} -- methods -- | Create a new 'MenuItem' with a check next to it. -- checkMenuItemNew :: IO CheckMenuItem checkMenuItemNew = makeNewObject mkCheckMenuItem $ liftM castPtr $ {#call unsafe check_menu_item_new#} -- | Create a new 'CheckMenuItem' with a 'Label' inside. -- checkMenuItemNewWithLabel :: String -> IO CheckMenuItem checkMenuItemNewWithLabel str = withUTFString str $ \strPtr -> makeNewObject mkCheckMenuItem $ liftM castPtr $ {#call unsafe check_menu_item_new_with_label#} strPtr -- | Create a new 'CheckMenuItem' with a 'Label' inside. Underscores in the -- label string indicate the mnemonic for the menu item. -- checkMenuItemNewWithMnemonic :: String -> IO CheckMenuItem checkMenuItemNewWithMnemonic str = withUTFString str $ \strPtr -> makeNewObject mkCheckMenuItem $ liftM castPtr $ {#call unsafe check_menu_item_new_with_mnemonic#} strPtr -- | Sets the active state of the menu item's check box. -- checkMenuItemSetActive :: CheckMenuItemClass mi => mi -> Bool -> IO () checkMenuItemSetActive mi active = {#call check_menu_item_set_active#} (toCheckMenuItem mi) (fromBool active) -- | Returns whether the check menu item is active. -- checkMenuItemGetActive :: CheckMenuItemClass mi => mi -> IO Bool checkMenuItemGetActive mi = liftM toBool $ {#call unsafe check_menu_item_get_active#} (toCheckMenuItem mi) -- | Emits the toggled signal. -- checkMenuItemToggled :: CheckMenuItemClass mi => mi -> IO () checkMenuItemToggled mi = {#call check_menu_item_toggled#} (toCheckMenuItem mi) -- | Set the state of the menu item check to \`inconsistent'. -- checkMenuItemSetInconsistent :: CheckMenuItemClass mi => mi -> Bool -> IO () checkMenuItemSetInconsistent mi inconsistent = {#call check_menu_item_set_inconsistent#} (toCheckMenuItem mi) (fromBool inconsistent) -- | Query if the menu check is inconsistent (inbetween). -- checkMenuItemGetInconsistent :: CheckMenuItemClass mi => mi -> IO Bool checkMenuItemGetInconsistent mi = liftM toBool $ {#call unsafe check_menu_item_get_inconsistent#} (toCheckMenuItem mi) #if GTK_CHECK_VERSION(2,4,0) -- | Sets whether the menu item is drawn like a 'RadioMenuItem'. -- checkMenuItemSetDrawAsRadio :: CheckMenuItemClass mi => mi -> Bool -> IO () checkMenuItemSetDrawAsRadio mi asRadio = {#call check_menu_item_set_draw_as_radio#} (toCheckMenuItem mi) (fromBool asRadio) -- | Returns whether the menu item is drawn like a 'RadioMenuItem'. -- checkMenuItemGetDrawAsRadio :: CheckMenuItemClass mi => mi -> IO Bool checkMenuItemGetDrawAsRadio mi = liftM toBool $ {#call unsafe check_menu_item_get_draw_as_radio#} (toCheckMenuItem mi) #endif --- NEW FILE: OptionMenu.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget OptionMenu -- -- Author : Axel Simon -- -- Created: 15 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:25:36 $ -- -- Copyright (c) 1999..2002 Axel Simon -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- module Graphics.UI.Gtk.MenuComboToolbar.OptionMenu ( #ifndef DISABLE_DEPRECATED OptionMenu, OptionMenuClass, castToOptionMenu, optionMenuNew, optionMenuGetMenu, optionMenuSetMenu, optionMenuRemoveMenu, optionMenuSetHistory, optionMenuGetHistory, onOMChanged, afterOMChanged #endif ) where #ifndef DISABLE_DEPRECATED import Monad (liftM) import System.Glib.FFI import Graphics.UI.Gtk.Abstract.Object (makeNewObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} {# context lib="gtk" prefix="gtk" #} -- methods -- | Create a new option menu. -- optionMenuNew :: IO OptionMenu optionMenuNew = makeNewObject mkOptionMenu $ liftM castPtr {#call unsafe option_menu_new#} -- | Get the menu that should be associated with this -- option menu. -- optionMenuGetMenu :: OptionMenuClass om => om -> IO Menu optionMenuGetMenu om = makeNewObject mkMenu $ liftM castPtr $ throwIfNull "optionMenuGetMenu: no menu associated with this option menu." $ {#call unsafe option_menu_get_menu#} (toOptionMenu om) -- | Set a menu to associate with this option menu. -- optionMenuSetMenu :: (OptionMenuClass om, MenuClass m) => om -> m -> IO () optionMenuSetMenu om m = {#call option_menu_set_menu#} (toOptionMenu om) (toWidget m) -- | Remove the association the menu. -- optionMenuRemoveMenu :: OptionMenuClass om => om -> IO () optionMenuRemoveMenu om = {#call unsafe option_menu_remove_menu#} (toOptionMenu om) -- | Set the state of the option menu. The options -- are numbered from 0 up to n-1 for the nth item. -- optionMenuSetHistory :: OptionMenuClass om => om -> Int -> IO () optionMenuSetHistory om item = {#call option_menu_set_history#} (toOptionMenu om) (fromIntegral item) -- | Retrieve the index of the selected item. -- optionMenuGetHistory :: OptionMenuClass om => om -> IO Int optionMenuGetHistory om = liftM fromIntegral $ {#call unsafe option_menu_get_history#} (toOptionMenu om) -- signals -- | This signal is called if the selected option has changed. -- onOMChanged, afterOMChanged :: OptionMenuClass om => om -> IO () -> IO (ConnectId om) onOMChanged = connect_NONE__NONE "changed" False afterOMChanged = connect_NONE__NONE "changed" True #endif |