File: IconView.chs

package info (click to toggle)
haskell-gtk 0.11.0-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,920 kB
  • ctags: 82
  • sloc: haskell: 1,929; ansic: 714; sh: 5; makefile: 3
file content (997 lines) | stat: -rw-r--r-- 32,975 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Widget IconView
--
--  Author : Duncan Coutts
--
--  Created: 25 March 2005
--
--  Copyright (C) 2005-2007 Duncan Coutts, Axel Simon
--
--  This library is free software; you can redistribute it and/or
--  modify it under the terms of the GNU Lesser General Public
--  License as published by the Free Software Foundation; either
--  version 2.1 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
--  Lesser General Public License for more details.
--
-- |
-- Maintainer  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
-- A widget which displays a list of icons in a grid
--
-- * Module available since Gtk+ version 2.6
--
module Graphics.UI.Gtk.ModelView.IconView (
-- * Detail
--
-- | 'IconView' provides an alternative view on a list model. It displays the
-- model as a grid of icons with labels. Like 'TreeView', it allows to select
-- one or multiple items (depending on the selection mode, see
-- 'iconViewSetSelectionMode'). In addition to selection with the arrow keys,
-- 'IconView' supports rubberband selection, which is controlled by dragging
-- the pointer.

-- * Class Hierarchy
--
-- |
-- @
-- |  'GObject'
-- |   +----'Object'
-- |         +----'Widget'
-- |               +----'Container'
-- |                     +----IconView
-- @

#if GTK_CHECK_VERSION(2,6,0)
-- * Types
  IconView,
  IconViewClass,
  castToIconView, gTypeIconView,
  toIconView,

-- * Constructors
  iconViewNew,
  iconViewNewWithModel,

-- * Methods
  iconViewSetModel,
  iconViewGetModel,
  iconViewSetTextColumn,
  iconViewGetTextColumn,
  iconViewSetMarkupColumn,
  iconViewGetMarkupColumn,
  iconViewSetPixbufColumn,
  iconViewGetPixbufColumn,
  iconViewGetPathAtPos,
  iconViewSelectedForeach,
  iconViewSetSelectionMode,
  iconViewGetSelectionMode,
  iconViewSetOrientation,
  iconViewGetOrientation,
  iconViewSetColumns,
  iconViewGetColumns,
  iconViewSetItemWidth,
  iconViewGetItemWidth,
  iconViewSetSpacing,
  iconViewGetSpacing,
  iconViewSetRowSpacing,
  iconViewGetRowSpacing,
  iconViewSetColumnSpacing,
  iconViewGetColumnSpacing,
  iconViewSetMargin,
  iconViewGetMargin,
  iconViewSelectPath,
  iconViewUnselectPath,
  iconViewPathIsSelected,
  iconViewGetSelectedItems,
  iconViewSelectAll,
  iconViewUnselectAll,
  iconViewItemActivated,
#if GTK_CHECK_VERSION(2,8,0)
  iconViewGetItemAtPos,
  iconViewSetCursor,
  iconViewGetCursor,
  iconViewScrollToPath,
  iconViewGetVisibleRange,
#if GTK_CHECK_VERSION(2,10,0)
  iconViewEnableModelDragSource,
  iconViewEnableModelDragDest,
  iconViewUnsetModelDragSource,
  iconViewUnsetModelDragDest,
#endif
  iconViewSetReorderable,
  iconViewGetReorderable,
#endif

-- * Attributes
  iconViewSelectionMode,
  iconViewTextColumn,
  iconViewMarkupColumn,
  iconViewPixbufColumn,
  iconViewModel,
  iconViewColumns,
  iconViewItemWidth,
  iconViewSpacing,
  iconViewRowSpacing,
  iconViewColumnSpacing,
  iconViewMargin,
  iconViewOrientation,
#if GTK_CHECK_VERSION(2,8,0)
  iconViewReorderable,
#endif

-- * Signals
  setIconViewScrollAdjustments,
  itemActivated,
  selectionChanged
#endif
  ) where

import Control.Monad    (liftM)

import System.Glib.FFI
import System.Glib.Attributes
import System.Glib.Properties
import System.Glib.GList                        (fromGList)
import System.Glib.Flags
import System.Glib.GObject                      (makeNewGObject, constructNewGObject)
import Graphics.UI.Gtk.Abstract.Object          (makeNewObject)
import Graphics.UI.Gtk.Gdk.Enums                (DragAction(..))
import Graphics.UI.Gtk.Gdk.Events               (Modifier(..))
{#import Graphics.UI.Gtk.Types#}
{#import Graphics.UI.Gtk.Signals#}
{#import Graphics.UI.Gtk.General.Enums#}        (Orientation, SelectionMode)
{#import Graphics.UI.Gtk.ModelView.TreeModel#}
{#import Graphics.UI.Gtk.ModelView.CustomStore#}
{#import Graphics.UI.Gtk.ModelView.Types#}
{#import Graphics.UI.Gtk.General.DNDTypes#}     (TargetList(..))
import Graphics.Rendering.Pango.Markup          (Markup)

{# context lib="gtk" prefix="gtk" #}

#if GTK_CHECK_VERSION(2,6,0)
--------------------
-- Interfaces

-- %hash c:4792
instance CellLayoutClass IconView

--------------------
-- Constructors

-- | Creates a new 'IconView' widget
--
iconViewNew :: IO IconView
iconViewNew =
  makeNewObject mkIconView $
  liftM (castPtr :: Ptr Widget -> Ptr IconView) $
  {# call gtk_icon_view_new #}

-- %hash c:dbf4
-- | Creates a new 'IconView' widget with the model @model@ and defines
--   how to extract a string and a pixbuf from the model.
--
iconViewNewWithModel :: TreeModelClass model =>
    model -- ^ @model@ - The model.
 -> IO IconView
iconViewNewWithModel model =
  makeNewObject mkIconView $
    liftM (castPtr :: Ptr Widget -> Ptr IconView) $
    {# call gtk_icon_view_new_with_model #}
    (toTreeModel model)

--------------------
-- Methods

-- %hash c:5ba8 d:c5c8
-- | Sets the model for a 'IconView'. If the @iconView@ already has a model
-- set, it will remove it before setting the new model. If @model@ is
-- @Nothing@, then it will unset the old model.
--
iconViewSetModel :: (IconViewClass self, TreeModelClass model) => self
 -> Maybe model -- ^ @model@ - The model.
 -> IO ()
iconViewSetModel self model =
  {# call gtk_icon_view_set_model #}
    (toIconView self)
    (maybe (TreeModel nullForeignPtr) toTreeModel model)

-- %hash c:6709 d:c0c5
-- | Returns the model the 'IconView' is based on. Returns @Nothing@ if the
-- model is unset.
--
iconViewGetModel :: IconViewClass self => self
 -> IO (Maybe TreeModel) -- ^ returns a 'TreeModel', or @Nothing@ if none is
                         -- currently being used.
iconViewGetModel self =
  maybeNull (makeNewGObject mkTreeModel) $
  {# call unsafe gtk_icon_view_get_model #}
    (toIconView self)

-- %hash c:c3fe d:fb7b
-- | Sets the column of the text for entries in the 'IconView'. If a markup
-- source is set using 'iconViewSetMarkupSource', then the text source is
-- ignored.
--
iconViewSetTextColumn :: IconViewClass self => self
 -> ColumnId row String -- ^ @column@ - A column in the currently used model.
 -> IO ()
iconViewSetTextColumn self column =
  {# call gtk_icon_view_set_text_column #}
    (toIconView self)
    ((fromIntegral . columnIdToNumber) column)

-- | Returns the column with text for @iconView@.
--
iconViewGetTextColumn :: IconViewClass self => self
 -> IO (ColumnId row String) -- ^ returns the text column, or 'invalidColumnId' if it's unset.
iconViewGetTextColumn self =
  liftM (makeColumnIdString . fromIntegral) $
  {# call gtk_icon_view_get_text_column #}
    (toIconView self)
    

-- %hash c:995f d:801c
-- | Sets the column of the text for entries in the 'IconView' as a markup
-- string (see 'Graphics.Rendering.Pango.Markup'). A text source that is set
-- using 'iconViewSetTextSource' is ignored once a markup source is set.
--
iconViewSetMarkupColumn :: IconViewClass self => self
 -> ColumnId row Markup -- ^ @column@ - A column in the currently used model.
 -> IO ()
iconViewSetMarkupColumn self column =
  {# call gtk_icon_view_set_markup_column #}
    (toIconView self)
    ((fromIntegral . columnIdToNumber) column)

-- | Returns the column with markup text for @iconView@.
--
iconViewGetMarkupColumn :: IconViewClass self => self
 -> IO (ColumnId row Markup) -- ^ returns the markup column, or 'invalidColumnId' if it's unset.
iconViewGetMarkupColumn self =
  liftM (makeColumnIdString . fromIntegral) $
  {# call gtk_icon_view_get_markup_column #}
    (toIconView self)


-- %hash c:4079 d:bf8
-- | Sets the column of the 'Graphics.UI.Gtk.Gdk.Pixbuf' for entries in the
-- 'IconView'.
--
iconViewSetPixbufColumn :: IconViewClass self => self
 -> ColumnId row Pixbuf -- ^ @column@ - A column in the currently used model.
 -> IO ()
iconViewSetPixbufColumn self column =
  {# call gtk_icon_view_set_pixbuf_column #}
    (toIconView self)
    ((fromIntegral . columnIdToNumber) column)

-- | Returns the column with pixbufs for @iconView@.
--
iconViewGetPixbufColumn :: IconViewClass self => self
 -> IO (ColumnId row Pixbuf) -- ^ returns the pixbuf column, or 'invalidColumnId' if it's unset.
iconViewGetPixbufColumn self =
  liftM (makeColumnIdPixbuf . fromIntegral) $
  {# call gtk_icon_view_get_pixbuf_column #}
    (toIconView self)

-- %hash c:2486 d:5e7
-- | Finds the path at the point (@x@, @y@), relative to widget coordinates.
-- See 'iconViewGetItemAtPos', if you are also interested in the cell at the
-- specified position.
--
iconViewGetPathAtPos :: IconViewClass self => self
 -> Int         -- ^ @x@ - The x position to be identified
 -> Int         -- ^ @y@ - The y position to be identified
 -> IO TreePath -- ^ returns The 'TreePath' corresponding to the icon or @[]@
                -- if no icon exists at that position.
iconViewGetPathAtPos self x y =
  {# call gtk_icon_view_get_path_at_pos #}
    (toIconView self)
    (fromIntegral x)
    (fromIntegral y)
  >>= fromTreePath

-- %hash c:dfc5
-- | Calls a function for each selected icon. Note that the model or selection
-- cannot be modified from within this function.
--
iconViewSelectedForeach :: IconViewClass self => self
 -> (TreePath -> IO ()) -- ^ @(\path -> ...)@ - The funcion to call for each
                        -- selected icon.
 -> IO ()
iconViewSelectedForeach self func = do
  funcPtr <- mkIconViewForeachFunc (\_ tpPtr _ -> do
    path <- peekTreePath tpPtr
    func path
    )
  {# call gtk_icon_view_selected_foreach #}
    (toIconView self)
    funcPtr
    nullPtr
  freeHaskellFunPtr funcPtr

{# pointer IconViewForeachFunc #}

foreign import ccall "wrapper" mkIconViewForeachFunc ::
  (Ptr IconView -> Ptr NativeTreePath -> Ptr () -> IO ()) -> IO IconViewForeachFunc

-- | Sets the selection mode of the @iconView@.
--
iconViewSetSelectionMode :: IconViewClass self => self
 -> SelectionMode -- ^ @mode@ - The selection mode
 -> IO ()
iconViewSetSelectionMode self mode =
  {# call gtk_icon_view_set_selection_mode #}
    (toIconView self)
    ((fromIntegral . fromEnum) mode)

-- | Gets the selection mode of the @iconView@.
--
iconViewGetSelectionMode :: IconViewClass self => self
 -> IO SelectionMode -- ^ returns the current selection mode
iconViewGetSelectionMode self =
  liftM (toEnum . fromIntegral) $
  {# call gtk_icon_view_get_selection_mode #}
    (toIconView self)

-- | Sets the ::orientation property which determines whether the labels are
-- drawn beside the icons instead of below.
--
iconViewSetOrientation :: IconViewClass self => self
 -> Orientation -- ^ @orientation@ - the relative position of texts and icons
 -> IO ()
iconViewSetOrientation self orientation =
  {# call gtk_icon_view_set_orientation #}
    (toIconView self)
    ((fromIntegral . fromEnum) orientation)

-- | Returns the value of the ::orientation property which determines whether
-- the labels are drawn beside the icons instead of below.
--
iconViewGetOrientation :: IconViewClass self => self
 -> IO Orientation -- ^ returns the relative position of texts and icons
iconViewGetOrientation self =
  liftM (toEnum . fromIntegral) $
  {# call gtk_icon_view_get_orientation #}
    (toIconView self)

-- %hash c:7d23 d:d4e7
-- | Sets the ::columns property which determines in how many columns the
-- icons are arranged. If @columns@ is -1, the number of columns will be chosen
-- automatically to fill the available area.
--
iconViewSetColumns :: IconViewClass self => self
 -> Int -- ^ @columns@ - the number of columns
 -> IO ()
iconViewSetColumns self columns =
  {# call gtk_icon_view_set_columns #}
    (toIconView self)
    (fromIntegral columns)

-- %hash c:f0f6 d:fc0e
-- | Returns the value of the ::columns property.
--
iconViewGetColumns :: IconViewClass self => self
 -> IO Int -- ^ returns the number of columns, or -1
iconViewGetColumns self =
  liftM fromIntegral $
  {# call gtk_icon_view_get_columns #}
    (toIconView self)

-- %hash c:643e d:b756
-- | Sets the ::item-width property which specifies the width to use for each
-- item. If it is set to -1, the icon view will automatically determine a
-- suitable item size.
--
iconViewSetItemWidth :: IconViewClass self => self
 -> Int -- ^ @itemWidth@ - the width for each item
 -> IO ()
iconViewSetItemWidth self itemWidth =
  {# call gtk_icon_view_set_item_width #}
    (toIconView self)
    (fromIntegral itemWidth)

-- %hash c:9f27 d:8569
-- | Returns the value of the ::item-width property.
--
iconViewGetItemWidth :: IconViewClass self => self
 -> IO Int -- ^ returns the width of a single item, or -1
iconViewGetItemWidth self =
  liftM fromIntegral $
  {# call gtk_icon_view_get_item_width #}
    (toIconView self)

-- %hash c:7e61 d:3186
-- | Sets the ::spacing property which specifies the space which is inserted
-- between the cells (i.e. the icon and the text) of an item.
--
iconViewSetSpacing :: IconViewClass self => self
 -> Int -- ^ @spacing@ - the spacing
 -> IO ()
iconViewSetSpacing self spacing =
  {# call gtk_icon_view_set_spacing #}
    (toIconView self)
    (fromIntegral spacing)

-- %hash c:5bc1 d:a1d2
-- | Returns the value of the ::spacing property.
--
iconViewGetSpacing :: IconViewClass self => self
 -> IO Int -- ^ returns the space between cells
iconViewGetSpacing self =
  liftM fromIntegral $
  {# call gtk_icon_view_get_spacing #}
    (toIconView self)

-- %hash c:dd08 d:730c
-- | Sets the ::row-spacing property which specifies the space which is
-- inserted between the rows of the icon view.
--
iconViewSetRowSpacing :: IconViewClass self => self
 -> Int -- ^ @rowSpacing@ - the row spacing
 -> IO ()
iconViewSetRowSpacing self rowSpacing =
  {# call gtk_icon_view_set_row_spacing #}
    (toIconView self)
    (fromIntegral rowSpacing)

-- %hash c:a040 d:bc37
-- | Returns the value of the ::row-spacing property.
--
iconViewGetRowSpacing :: IconViewClass self => self
 -> IO Int -- ^ returns the space between rows
iconViewGetRowSpacing self =
  liftM fromIntegral $
  {# call gtk_icon_view_get_row_spacing #}
    (toIconView self)

-- %hash c:3042 d:b4f8
-- | Sets the ::column-spacing property which specifies the space which is
-- inserted between the columns of the icon view.
--
iconViewSetColumnSpacing :: IconViewClass self => self
 -> Int -- ^ @columnSpacing@ - the column spacing
 -> IO ()
iconViewSetColumnSpacing self columnSpacing =
  {# call gtk_icon_view_set_column_spacing #}
    (toIconView self)
    (fromIntegral columnSpacing)

-- %hash c:3818 d:c1cd
-- | Returns the value of the ::column-spacing property.
--
iconViewGetColumnSpacing :: IconViewClass self => self
 -> IO Int -- ^ returns the space between columns
iconViewGetColumnSpacing self =
  liftM fromIntegral $
  {# call gtk_icon_view_get_column_spacing #}
    (toIconView self)

-- %hash c:990 d:d43c
-- | Sets the ::margin property which specifies the space which is inserted at
-- the top, bottom, left and right of the icon view.
--
iconViewSetMargin :: IconViewClass self => self
 -> Int -- ^ @margin@ - the margin
 -> IO ()
iconViewSetMargin self margin =
  {# call gtk_icon_view_set_margin #}
    (toIconView self)
    (fromIntegral margin)

-- %hash c:a116 d:6fab
-- | Returns the value of the ::margin property.
--
iconViewGetMargin :: IconViewClass self => self
 -> IO Int -- ^ returns the space at the borders
iconViewGetMargin self =
  liftM fromIntegral $
  {# call gtk_icon_view_get_margin #}
    (toIconView self)

-- %hash c:77b3
-- | Selects the row at @path@.
--
iconViewSelectPath :: IconViewClass self => self
 -> TreePath -- ^ @path@ - The 'TreePath' to be selected.
 -> IO ()
iconViewSelectPath self path =
  withTreePath path $ \path ->
  {# call gtk_icon_view_select_path #}
    (toIconView self)
    path

-- %hash c:7e5f
-- | Unselects the row at @path@.
--
iconViewUnselectPath :: IconViewClass self => self
 -> TreePath -- ^ @path@ - The 'TreePath' to be unselected.
 -> IO ()
iconViewUnselectPath self path =
  withTreePath path $ \path ->
  {# call gtk_icon_view_unselect_path #}
    (toIconView self)
    path

-- %hash c:8ea0
-- | Returns @True@ if the icon pointed to by @path@ is currently selected. If
-- @icon@ does not point to a valid location, @False@ is returned.
--
iconViewPathIsSelected :: IconViewClass self => self
 -> TreePath -- ^ @path@ - A 'TreePath' to check selection on.
 -> IO Bool  -- ^ returns @True@ if @path@ is selected.
iconViewPathIsSelected self path =
  liftM toBool $
  withTreePath path $ \path ->
  {# call gtk_icon_view_path_is_selected #}
    (toIconView self)
    path

-- %hash c:90f8 d:9c43
-- | Creates a list of paths of all selected items. Additionally, if you are
-- planning on modifying the model after calling this function, you may want
-- to convert the returned list into a list of 'TreeRowReference's. To do
-- this, you can use 'treeRowReferenceNew'.
--
iconViewGetSelectedItems :: IconViewClass self => self
 -> IO [TreePath] -- ^ returns a list of 'TreePath's, one for each selected row.
iconViewGetSelectedItems self =
  {# call gtk_icon_view_get_selected_items #}
    (toIconView self)
  >>= fromGList
  >>= mapM fromTreePath

-- | Selects all the icons. @iconView@ must has its selection mode set to
-- 'SelectionMultiple'.
--
iconViewSelectAll :: IconViewClass self => self -> IO ()
iconViewSelectAll self =
  {# call gtk_icon_view_select_all #}
    (toIconView self)

-- | Unselects all the icons.
--
iconViewUnselectAll :: IconViewClass self => self -> IO ()
iconViewUnselectAll self =
  {# call gtk_icon_view_unselect_all #}
    (toIconView self)

-- %hash c:6916
-- | Activates the item determined by @path@.
--
iconViewItemActivated :: IconViewClass self => self
 -> TreePath -- ^ @path@ - The 'TreePath' to be activated
 -> IO ()
iconViewItemActivated self path =
  withTreePath path $ \path ->
  {# call gtk_icon_view_item_activated #}
    (toIconView self)
    path


#if GTK_CHECK_VERSION(2,8,0)
-- %hash c:3122 d:346e
-- | Finds the path at the point (@x@, @y@), relative to widget coordinates.
-- In contrast to 'iconViewGetPathAtPos', this function also obtains the cell
-- at the specified position.
--
-- * Available since Gtk+ version 2.8
--
iconViewGetItemAtPos :: IconViewClass self => self
 -> Int                   -- ^ @x@ - The x position to be identified
 -> Int                   -- ^ @y@ - The y position to be identified
 -> IO (Maybe (TreePath, CellRenderer)) 
                          -- specified position
iconViewGetItemAtPos self x y =
  alloca $ \pathPtrPtr -> alloca $ \crPtrPtr -> do
  success <- liftM toBool $ {# call gtk_icon_view_get_item_at_pos #}
    (toIconView self)
    (fromIntegral x)
    (fromIntegral y)
    (castPtr pathPtrPtr)
    (castPtr crPtrPtr)
  if not success then return Nothing else do
  pathPtr <- peek pathPtrPtr
  crPtr <- peek crPtrPtr
  path <- fromTreePath pathPtr
  cr <- makeNewGObject mkCellRenderer (return crPtr)
  return (Just (path, cr))

-- %hash c:357b d:32d6
-- | Given @Left path@ as argument , sets the current keyboard focus to be at
-- @path@, and selects it. This is useful when you want to focus the user's
-- attention on a particular item. If @Right cell@ is given, then focus is
-- given to the cell specified by it. Additionally, if @startEditing@ is
-- @True@, then editing should be started in the specified cell.
--
-- This function is often followed by
-- 'Graphics.UI.Gtk.Abstract.Widget.widgetGrabFocus' in order to give keyboard
-- focus to the widget. Please note that editing can only happen when the
-- widget is realized.
--
-- * Available since Gtk+ version 2.8
--
iconViewSetCursor :: (IconViewClass self, CellRendererClass cell) => self
 -> (Either TreePath cell) -- ^ the path or the cell
 -> Bool     -- ^ @startEditing@ - @True@ if the specified cell should start
             -- being edited.
 -> IO ()
iconViewSetCursor self (Left path) startEditing =
  withTreePath path $ \path ->
  {# call gtk_icon_view_set_cursor #}
    (toIconView self)
    path
    (CellRenderer nullForeignPtr)
    (fromBool startEditing)
iconViewSetCursor self (Right cell) startEditing =
  {# call gtk_icon_view_set_cursor #}
    (toIconView self)
    (NativeTreePath nullPtr)
    (toCellRenderer cell)
    (fromBool startEditing)

-- %hash c:3307 d:9cf8
-- | Return a @path@ and a @cell@ with the current cursor path and cell. If the
-- cursor isn't currently set, then @[]@ will be returned for the @path@. If no cell currently has focus,
-- then @cell@ will be @Nothing@.
--
-- * Available since Gtk+ version 2.8
--
iconViewGetCursor :: IconViewClass self => self
 -> IO (TreePath, Maybe CellRenderer)               -- ^ returns a @path@ to the cursor and a @cell@ if the widget has the input focus
iconViewGetCursor self =
  alloca $ \pathPtrPtr -> alloca $ \crPtrPtr -> do
  {# call gtk_icon_view_get_cursor #}
    (toIconView self)
    (castPtr pathPtrPtr)
    (castPtr crPtrPtr)
  pathPtr <- peek pathPtrPtr
  crPtr <- peek crPtrPtr
  path <- fromTreePath pathPtr
  cr <- if crPtr==nullPtr then return Nothing else
        liftM Just $ makeNewGObject mkCellRenderer (return crPtr)
  return (path, cr)

-- %hash c:1c9e d:20c5
-- | Moves the alignments of @iconView@ to the position specified by @path@.
-- @rowAlign@ determines where the row is placed, and @colAlign@ determines
-- where @column@ is placed. Both are expected to be between 0.0 and 1.0. 0.0
-- means left\/top alignment, 1.0 means right\/bottom alignment, 0.5 means
-- center.
--
-- If @useAlign@ is @False@, then the alignment arguments are ignored, and the
-- tree does the minimum amount of work to scroll the item onto the screen.
-- This means that the item will be scrolled to the edge closest to its
-- current position. If the item is currently visible on the screen, nothing
-- is done.
--
-- This function only works if the model is set, and @path@ is a valid row on
-- the model. If the model changes before the @iconView@ is realized, the
-- centered path will be modified to reflect this change.
--
-- * Available since Gtk+ version 2.8
--
iconViewScrollToPath :: IconViewClass self => self
 -> TreePath -- ^ @path@ - The path of the item to move to.
 -> Bool     -- ^ @useAlign@ - whether to use alignment arguments, or @False@.
 -> Float    -- ^ @rowAlign@ - The vertical alignment of the item specified by
             -- @path@.
 -> Float    -- ^ @colAlign@ - The horizontal alignment of the item specified
             -- by @path@.
 -> IO ()
iconViewScrollToPath self path useAlign rowAlign colAlign =
  withTreePath path $ \path ->
  {# call gtk_icon_view_scroll_to_path #}
    (toIconView self)
    path
    (fromBool useAlign)
    (realToFrac rowAlign)
    (realToFrac colAlign)

-- %hash c:8354 d:f7f3
-- | Retrieve the first and last visible path.
-- Note that there may be invisible paths inbetween.
--
-- * Available since Gtk+ version 2.8
--
iconViewGetVisibleRange :: IconViewClass self => self
 -> IO (Maybe (TreePath, TreePath))
                -- ^ returns the first and last visible path, the return value
                -- @Nothing@ if every element is visible
iconViewGetVisibleRange self = alloca $ \fPtrPtr -> alloca $ \lPtrPtr -> do
  success <- liftM toBool $ {# call gtk_icon_view_get_visible_range #}
    (toIconView self)
    (castPtr fPtrPtr)
    (castPtr lPtrPtr)
  if not success then return Nothing else do
  fPtr <- peek fPtrPtr
  lPtr <- peek lPtrPtr
  f <- fromTreePath fPtr
  l <- fromTreePath lPtr
  return (Just (f,l))

#if GTK_CHECK_VERSION(2,10,0)
-- %hash c:bd16 d:3f4f
-- | Turns @iconView@ into a drag source for automatic DND.
--
-- * Available since Gtk+ version 2.10
--
iconViewEnableModelDragSource :: IconViewClass self => self
  -> [Modifier]         -- ^ @startButtonMask@ - Mask of allowed buttons
                        -- to start drag
  -> TargetList         -- ^ @targets@ - the list of targets that the
                        -- the view will support
  -> [DragAction]       -- ^ @actions@ - flags denoting the possible actions
                        -- for a drag from this widget
  -> IO ()
iconViewEnableModelDragSource self startButtonMask targets actions =
  alloca $ \nTargetsPtr -> do
  tlPtr <- {#call unsafe gtk_target_table_new_from_list#} targets nTargetsPtr
  nTargets <- peek nTargetsPtr
  {# call gtk_icon_view_enable_model_drag_source #}
    (toIconView self)
    ((fromIntegral . fromFlags) startButtonMask)
    tlPtr
    nTargets
    ((fromIntegral . fromFlags) actions)
  {#call unsafe gtk_target_table_free#} tlPtr nTargets

-- %hash c:b14d d:23d7
-- | Turns @iconView@ into a drop destination for automatic DND.
--
-- * Available since Gtk+ version 2.10
--
iconViewEnableModelDragDest :: IconViewClass self => self
  -> TargetList                -- ^ @targets@ - the list of targets that the
                               -- the view will support
  -> [DragAction]              -- ^ @actions@ - flags denoting the possible actions
                               -- for a drop into this widget
  -> IO ()
iconViewEnableModelDragDest self targets actions =
  alloca $ \nTargetsPtr -> do
  tlPtr <- {#call unsafe gtk_target_table_new_from_list#} targets nTargetsPtr
  nTargets <- peek nTargetsPtr
  {# call gtk_icon_view_enable_model_drag_dest #}
    (toIconView self)
    tlPtr
    nTargets
    ((fromIntegral . fromFlags) actions)

-- %hash c:25b0 d:5a6b
-- | Undoes the effect of 'iconViewEnableModelDragSource'.
--
-- * Available since Gtk+ version 2.10
--
iconViewUnsetModelDragSource :: IconViewClass self => self -> IO ()
iconViewUnsetModelDragSource self =
  {# call gtk_icon_view_unset_model_drag_source #}
    (toIconView self)

-- %hash c:d76d d:f18a
-- | Undoes the effect of 'iconViewEnableModelDragDest'.
--
-- * Available since Gtk+ version 2.10
--
iconViewUnsetModelDragDest :: IconViewClass self => self -> IO ()
iconViewUnsetModelDragDest self =
  {# call gtk_icon_view_unset_model_drag_dest #}
    (toIconView self)
#endif

-- %hash c:c270 d:b94d
-- | Check if icons can be moved around.
--
-- * Set whether the user can use drag and drop (DND) to reorder the rows in
--   the store. This works on both 'TreeStore' and 'ListStore' models. If @ro@
--   is @True@, then the user can reorder the model by dragging and dropping
--   rows.  The developer can listen to these changes by connecting to the
--   model's signals. If you need to control which rows may be dragged or
--   where rows may be dropped, you can override the
--   'Graphics.UI.Gtk.ModelView.CustomStore.treeDragSourceRowDraggable'
--   function in the default DND implementation of the model.
--
-- * Available since Gtk+ version 2.8
--
iconViewSetReorderable :: IconViewClass self => self
 -> Bool -- ^ @reorderable@ - @True@, if the list of items can be reordered.
 -> IO ()
iconViewSetReorderable self reorderable =
  {# call gtk_icon_view_set_reorderable #}
    (toIconView self)
    (fromBool reorderable)

-- %hash c:532 d:1d07
-- | Retrieves whether the user can reorder the list via drag-and-drop. See
-- 'iconViewSetReorderable'.
--
-- * Available since Gtk+ version 2.8
--
iconViewGetReorderable :: IconViewClass self => self
 -> IO Bool -- ^ returns @True@ if the list can be reordered.
iconViewGetReorderable self =
  liftM toBool $
  {# call gtk_icon_view_get_reorderable #}
    (toIconView self)

#endif

--------------------
-- Attributes

-- | The ::selection-mode property specifies the selection mode of icon view.
-- If the mode is 'SelectionMultiple', rubberband selection is enabled, for the
-- other modes, only keyboard selection is possible.
--
-- Default value: 'SelectionSingle'
--
iconViewSelectionMode :: IconViewClass self => Attr self SelectionMode
iconViewSelectionMode = newAttr
  iconViewGetSelectionMode
  iconViewSetSelectionMode

-- %hash c:4ce5 d:c77a
-- | The 'iconViewPixbufColumn' property contains the number of the model column
-- containing the pixbufs which are displayed. Setting this property to
-- 'invalidColumnId' turns off the display of pixbufs.
--
-- Default value: 'invalidColumnId'
--
iconViewPixbufColumn :: IconViewClass self => Attr self (ColumnId row Pixbuf)
iconViewPixbufColumn = newAttr
  iconViewGetPixbufColumn
  iconViewSetPixbufColumn

-- %hash c:702a d:f7ed
-- | The 'iconViewTextColumn' property contains the number of the model column
-- containing the texts which are displayed. If this property and the
-- 'iconViewMarkupColumn' property are both set to 'invalidColumnId', no texts
-- are displayed.
--
-- Default value: 'invalidColumnId'
--
iconViewTextColumn :: IconViewClass self => Attr self (ColumnId row String)
iconViewTextColumn = newAttr
  iconViewGetTextColumn
  iconViewSetTextColumn

-- %hash c:37cb d:ee83
-- | The 'iconViewMarkupColumn' property contains the number of the model column
-- containing markup information to be displayed. If this property and the
-- 'iconViewTextColumn' property are both set to column numbers, it overrides the text
-- column. If both are set to 'invalidColumnId', no texts are displayed.
--
-- Default value: 'invalidColumnId'
--
iconViewMarkupColumn :: IconViewClass self => Attr self (ColumnId row Markup)
iconViewMarkupColumn = newAttr
  iconViewGetMarkupColumn
  iconViewSetMarkupColumn

-- %hash c:723d
-- | The model for the icon view.
--
iconViewModel :: (IconViewClass self, TreeModelClass model)
 => ReadWriteAttr self (Maybe TreeModel) (Maybe model)
iconViewModel = newAttr
  iconViewGetModel
  iconViewSetModel

-- %hash c:6347
-- | The columns property contains the number of the columns in which the
-- items should be displayed. If it is -1, the number of columns will be chosen
-- automatically to fill the available area.
--
-- Allowed values: >= -1
--
-- Default value: -1
--
iconViewColumns :: IconViewClass self => Attr self Int
iconViewColumns = newAttrFromIntProperty "columns"

-- %hash c:d0fe d:42c5
-- | The item-width property specifies the width to use for each item. If it
-- is set to -1, the icon view will automatically determine a suitable item
-- size.
--
-- Allowed values: >= -1
--
-- Default value: -1
--
iconViewItemWidth :: IconViewClass self => Attr self Int
iconViewItemWidth = newAttrFromIntProperty "item-width"

-- %hash c:3813 d:23f9
-- | The spacing property specifies the space which is inserted between the
-- cells (i.e. the icon and the text) of an item.
--
-- Allowed values: >= 0
--
-- Default value: 0
--
iconViewSpacing :: IconViewClass self => Attr self Int
iconViewSpacing = newAttrFromIntProperty "spacing"

-- %hash c:6a28 d:8e65
-- | The row-spacing property specifies the space which is inserted between
-- the rows of the icon view.
--
-- Allowed values: >= 0
--
-- Default value: 6
--
iconViewRowSpacing :: IconViewClass self => Attr self Int
iconViewRowSpacing = newAttrFromIntProperty "row-spacing"

-- %hash c:56a d:2971
-- | The column-spacing property specifies the space which is inserted between
-- the columns of the icon view.
--
-- Allowed values: >= 0
--
-- Default value: 6
--
iconViewColumnSpacing :: IconViewClass self => Attr self Int
iconViewColumnSpacing = newAttrFromIntProperty "column-spacing"

-- %hash c:89de d:8e41
-- | The margin property specifies the space which is inserted at the edges of
-- the icon view.
--
-- Allowed values: >= 0
--
-- Default value: 6
--
iconViewMargin :: IconViewClass self => Attr self Int
iconViewMargin = newAttrFromIntProperty "margin"

-- %hash c:b606 d:31c3
-- | The orientation property specifies how the cells (i.e. the icon and the
-- text) of the item are positioned relative to each other.
--
-- Default value: 'OrientationVertical'
--
iconViewOrientation :: IconViewClass self => Attr self Orientation
iconViewOrientation = newAttrFromEnumProperty "orientation"
                        {# call pure unsafe gtk_orientation_get_type #}

#if GTK_CHECK_VERSION(2,8,0)
-- %hash c:f17b d:54d0
-- | The reorderable property specifies if the items can be reordered by DND.
--
-- Default value: @False@
--
-- * Available since Gtk+ version 2.8
--
iconViewReorderable :: IconViewClass self => Attr self Bool
iconViewReorderable = newAttrFromBoolProperty "reorderable"
#endif

--------------------
-- Signals

-- %hash c:4671 d:af3f
-- | New scroll adjustment have been set for this widget.
--
setIconViewScrollAdjustments :: IconViewClass self => Signal self (Adjustment -> Adjustment -> IO ())
setIconViewScrollAdjustments = Signal (connect_OBJECT_OBJECT__NONE "set_scroll_adjustments")

-- %hash c:4090 d:af3f
-- | A specific element has been activated (by pressing enter or double clicking).
--
itemActivated :: IconViewClass self => Signal self (TreePath -> IO ())
itemActivated = Signal (connect_BOXED__NONE "item_activated" (peekTreePath . castPtr))

-- %hash c:6098 d:af3f
-- | The selected item changed.
--
selectionChanged :: IconViewClass self => Signal self (IO ())
selectionChanged = Signal (connect_NONE__NONE "selection-changed")

#endif