From: Axel S. <si...@co...> - 2008-07-09 00:11:23
|
Tue Jul 8 15:32:56 EDT 2008 A....@ke... * Make ComboBox entry work with the new tree stores. hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 42 --- The convenience API to construct simple text-only 'ComboBox'es can also --- be used with 'ComboBoxEntry's which have been constructed with --- 'comboBoxEntryNewText'. +-- The changed signal will be emitted while typing into a 'ComboBoxEntry', +-- as well as when selecting an item from the 'ComboBoxEntry''s list. Use +-- 'comboBoxGetActive' or 'comboBoxGetActiveIter' to discover whether an item +-- was actually selected from the list. +-- +-- Connect to the activate signal of the 'Entry' (use 'binGetChild') to +-- detect when the user actually finishes entering text. +-- hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 74 - comboBoxEntrySetTextModel hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 75 +-- * Methods + comboBoxEntrySetTextColumn, + comboBoxEntryGetTextColumn, + +-- * Attributes + comboBoxEntryTextColumn, hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 89 -{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.Types#} hiding ( ListStore ) hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 94 +{#import Graphics.UI.Gtk.ModelView.CustomStore#} +import Graphics.UI.Gtk.ModelView.ListStore ( ListStore, listStoreNew ) hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 118 -comboBoxEntryNewWithModel :: (TypedTreeModelClass model, - TreeModelClass (model String)) => [_$_] - model String -- ^ @model@ - A 'CustomStore'. +comboBoxEntryNewWithModel :: TreeModelClass model => [_$_] + model -- ^ @model@ - A 'CustomStore'. hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 127 --- which is a 'ComboBoxEntry' just displaying strings. If you use this function --- to create a text combo box, you should only manipulate its data source with --- the following convenience functions: 'comboBoxAppendText', --- 'comboBoxInsertText', 'comboBoxPrependText' and 'comboBoxRemoveText'. +-- which is a 'ComboBoxEntry' just displaying strings. Note that this +-- function does not setup any functionality to insert newly typed +-- text into the model. See the module introduction for information +-- about this. hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 132 -comboBoxEntryNewText :: IO ComboBoxEntry -comboBoxEntryNewText = - makeNewObject mkComboBoxEntry $ - liftM (castPtr :: Ptr Widget -> Ptr ComboBoxEntry) $ - {# call gtk_combo_box_entry_new_text #} +comboBoxEntryNewText :: + (a -> String) -- ^ a function to extract elements from a the store + -> [a] -- ^ the initial entries in the 'ComboBoxEntry' + -> IO (ComboBoxEntry, ListStore a) +comboBoxEntryNewText extract initial = do + store <- listStoreNew initial + let colId = makeColumnIdString 0 + treeModelSetColumn store colId extract + combo <- makeNewObject mkComboBoxEntry $ + liftM (castPtr :: Ptr Widget -> Ptr ComboBoxEntry) $ + {# call gtk_combo_box_entry_new_with_model #} + (toTreeModel store) + (fromIntegral (columnIdToNumber colId)) + return (combo, store) + +-------------------- +-- Methods hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 150 --- | Sets the model of 'String's, inserts a 'CellRendererText'. +-- %hash c:b7d7 d:2818 +-- | Sets the model column should be use to get strings from to +-- be @textColumn@. hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 154 -comboBoxEntrySetTextModel :: (TypedTreeModelClass model, - TreeModelClass (model String)) - => ComboBoxEntry - -> model String -- ^ @model@ - The model of 'String's. +comboBoxEntrySetTextColumn :: ComboBoxEntryClass self => self + -> ColumnId row String -- ^ @textColumn@ - A column in @model@ to get the strings from. hunk ./gtk/Graphics/UI/Gtk/ModelView/ComboBoxEntry.chs.pp 157 -comboBoxEntrySetTextModel self model = do - comboBoxSetModel self (Just model) - cell <- cellRendererTextNew - cellLayoutPackStart self cell True - cellLayoutSetAttributes self cell model (\str -> [cellText := str]) +comboBoxEntrySetTextColumn self textColumn = + {# call gtk_combo_box_entry_set_text_column #} + (toComboBoxEntry self) + (fromIntegral (columnIdToNumber textColumn)) + +-- %hash c:a3e3 d:6441 +-- | Returns the column which is used to get the strings from. +-- +comboBoxEntryGetTextColumn :: ComboBoxEntryClass self => self + -> IO (ColumnId row String) -- ^ returns A column in the data source model of @entryBox@. +comboBoxEntryGetTextColumn self = + liftM (makeColumnIdString . fromIntegral) $ + {# call gtk_combo_box_entry_get_text_column #} + (toComboBoxEntry self) + +-------------------- +-- Attributes + +-- %hash c:84ff d:be07 +-- | A column in the data source model to get the strings from. +-- +-- Allowed values: >= 0 +-- +-- Default value: 'Graphics.UI.Gtk.ModelView.CustomStore.invalidColumnId' +-- +comboBoxEntryTextColumn :: ComboBoxEntryClass self => Attr self (ColumnId row String) +comboBoxEntryTextColumn = newAttr + comboBoxEntryGetTextColumn + comboBoxEntrySetTextColumn |