~canonical-dx-team/ubuntu/maverick/gtk+2.0/menuproxy

« back to all changes in this revision

Viewing changes to docs/reference/gtk/migrating-GtkIconView.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-05-04 12:24:25 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20070504122425-0m8midgzrp40y8w2
Tags: 2.10.12-1ubuntu1
* Sync with Debian
* New upstream version:
  Fixed bugs:
  - 379414 file chooser warnings when changing path in the entry
  - 418585 GtkFileChooserDefault sizing code is not DPI independent
  - 419568 Crash in search if start with special letter
  - 435062 build dies with icon cache validation
  - 379399 Segfault to call gtk_print_operation_run twice.
  - 387889 cups backend has problems when there are too many printers
  - 418531 invalid read to gtkicontheme.c gtk_icon_theme_lookup_icon...
  - 423916 crash in color scheme code
  - 424042 Segmentation fault while quickly pressing Alt+arrows
  - 415260 Protect against negative indices when setting values in G...
  - 419171 XGetVisualInfo() may not set nxvisuals
  - 128852 Gdk cursors don't look good on win32
  - 344657 Ctrl-H doesn't toggle "Show Hidden Files" setting
  - 345345 PrintOperation::paginate is not emitted for class handler
  - 347567 GtkPrintOperation::end-print is not emitted if it's cance...
  - 369112 gtk_ui_manager_add_ui should accept unnamed separator
  - 392015 Selected menu item invisible on Windows Vista
  - 399253 MS-Windows Theme Bottom Tab placement rendering glitches
  - 399425 gtk_input_dialog_fill_axes() adds child to gtkscrolledwin...
  - 403251 [patch] little memory leak in GtkPrintJob
  - 403267 [patch] memory leak in GtkPageSetupUnixDialog
  - 403470 MS-Windows Theme tab placement other than on top leaks a ...
  - 404506 Windows system fonts that have multi-byte font names cann...
  - 405089 Incorrect window placement for GtkEventBox private window
  - 405515 Minor leak in gtkfilesystemmodel.c
  - 405539 gdk_pixbuf_save() for PNG saver can return FALSE without ...
  - 415681 gdk_window_clear_area includes an extra line and column o...
  - 418219 GtkRecentChooser should apply filter before sorting and c...
  - 418403 Scroll to printer after selecting it from settings
  - 421985 _gtk_print_operation_platform_backend_launch_preview
  - 421990 gtk_print_job_get_surface
  - 421993 gtk_print_operation_init
  - 423064 Conditional jump or move depends on uninitialised value(s...
  - 423722 Fix printing header in gtk-demo
  - 424168 gtk_print_operation_run on async preview
  - 425655 Don't install gtk+-unix-print-2.0.pc on non-UNIX platforms
  - 425786 GDK segfaults if XineramaQueryScreens fails
  - 428665 Lpr Backend gets stuck in infinite loop during gtk_enumer...
  - 429902 GtkPrintOperation leaks cairo contextes
  - 431997 First delay of GdkPixbufAnimationIter is wrong
  - 433242 Inconsistent scroll arrow position calculations
  - 433972 Placing gtk.Expander inside a gtk.TextView() changes gtk....
  - 434261 _gtk_toolbar_elide_underscores incorrectly handles some s...
  - 383354 ctrl-L should make 'Location' entry disappear
  - 418673 gtk_recent_manager_add_item
  - 429732 gtk_accel_group_finalize accesses invalid memory
  - 435028 WM_CLIENT_LEADER is wrong on the leader_window
  - 431067 Background of the header window is not updated
  - 338843 add recent files support inside the ui manager
  - 148535 add drop shadow to menus, tooltips, etc. under Windows XP
* debian/control.in:
  - Conflicts on ubuntulooks (<= 0.9.11-1)
* debian/patches/15_default-fallback-icon-theme.patch:
  - patch from Debian, fallback on gnome icon theme

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<chapter id="gtk-migrating-GtkIconView">
 
2
 
 
3
  <title>Migrating from GnomeIconList to GtkIconView</title>
 
4
 
 
5
  <para>
 
6
    Since version 2.6, GTK+ provides the #GtkIconView widget. It is similar in 
 
7
    functionality to the <structname>GnomeIconList</structname> widget in the 
 
8
    libgnomeui library, both widgets provide a way to lay out named icons in 
 
9
    a grid. The distinctive feature of the GTK+ widget is that it follows the 
 
10
    model-view pattern, allowing it to share the actual data (i.e. the names 
 
11
    and images of the icons) with other views.
 
12
  </para>
 
13
 
 
14
  <para>
 
15
    #GtkIconView currently doesn't support some features found in 
 
16
    <structname>GnomeIconList</structname>. Icons can not be positioned freely, 
 
17
    the spacing is not customizable, and it is not possible to edit the names of 
 
18
    icons. 
 
19
  </para>
 
20
 
 
21
  <para>
 
22
    To convert an application that uses <structname>GnomeIconList</structname> 
 
23
    to #GtkIconView, the first step is to organize your data in a #GtkTreeModel. 
 
24
    <structname>GnomeIconList</structname> lets you directly insert data with 
 
25
    gnome_icon_list_insert() and gnome_icon_list_insert_pixbuf() and their
 
26
    append variants. So, if you previously had a function to fill your icon 
 
27
    list similar to this one:
 
28
    <informalexample><programlisting>
 
29
      void 
 
30
      fill_icon_list (GnomeIconList *icon_list)
 
31
      {
 
32
        gnome_icon_list_append (icon_list, "file1.png", "Icon 1");
 
33
        gnome_icon_list_append (icon_list, "file2.png", "Icon 2");
 
34
 
 
35
        /* more icons ... */ 
 
36
      }
 
37
    </programlisting></informalexample>
 
38
    you will have to create a tree model, attach your icon view to it, and 
 
39
    fill the model:
 
40
    <informalexample><programlisting>
 
41
      enum { 
 
42
        PIXBUF_COLUMN,
 
43
        TEXT_COLUMN,
 
44
 
 
45
        /* you can have more columns here, e.g */ 
 
46
 
 
47
        DATA_COLUMN
 
48
      };
 
49
 
 
50
      void 
 
51
      fill_model (GtkListStore *store)
 
52
      {
 
53
        GtkTreeIter iter;
 
54
        GdkPixbuf *pixbuf;
 
55
 
 
56
        gtk_list_store_append (store, &amp;iter);
 
57
        pixbuf = gdk_pixbuf_new_from_file ("file1.png", NULL);
 
58
        gtk_list_store_set (store, &amp;iter, PIXBUF_COLUMN, pixbuf, TEXT_COLUMN, "Icon 1", -1);
 
59
        g_object_unref (pixbuf);
 
60
 
 
61
        gtk_list_store_append (store, &amp;iter);
 
62
        pixbuf = gdk_pixbuf_new_from_file ("file2.png", NULL);
 
63
        gtk_list_store_set (store, &amp;iter, PIXBUF_COLUMN, pixbuf, TEXT_COLUMN, "Icon 2", -1);
 
64
        g_object_unref (pixbuf);
 
65
 
 
66
        /* more icons ... */ 
 
67
      }
 
68
 
 
69
      int 
 
70
      main (int argc, char *argv[])
 
71
      {
 
72
        GtkWidget *icon_view;
 
73
        GtkListStore *store;
 
74
 
 
75
        gtk_init (&amp;argc, &amp;argv);
 
76
 
 
77
        /* do other initialization... */
 
78
 
 
79
        /* construct the GtkIconView */
 
80
        icon_view = gtk_icon_view_new (<!-- -->);
 
81
        store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER);
 
82
 
 
83
        gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icon_view), PIXBUF_COLUMN);
 
84
        gtk_icon_view_set_text_column (GTK_ICON_VIEW (icon_view), TEXT_COLUMN);
 
85
        gtk_icon_view_set_model (GTK_ICON_VIEW (icon_view), GTK_TREE_MODEL (store));
 
86
 
 
87
        fill_model (store);
 
88
 
 
89
        /* ... */
 
90
      }
 
91
    </programlisting></informalexample>
 
92
    This example uses a #GtkListStore as model, but part of the elegance of the 
 
93
    model-view pattern is that you can easily use another tree model implementation, 
 
94
    or even write your own custom tree model.
 
95
  </para>
 
96
 
 
97
  <para>
 
98
    Your application may make use of extra data attached to the icons in the 
 
99
    <structname>GnomeIconList</structname> via gnome_icon_list_set_icon_data() and 
 
100
    gnome_icon_list_get_icon_data(). With #GtkIconView such data is most 
 
101
    conveniently stored in an extra column in the tree model, so you would 
 
102
    call a function like
 
103
    <informalexample><programlisting>
 
104
    void 
 
105
    set_icon_data (GtkIconView *icon_view,
 
106
                   gint         idx,
 
107
                   gpointer     data)
 
108
    {
 
109
       GtkTreeModel *model;
 
110
       GtkTreeIter iter;
 
111
 
 
112
       model = gtk_icon_view_get_model (icon_view);
 
113
    
 
114
       if (gtk_tree_model_iter_nth_child (model, &amp;iter, NULL, idx))
 
115
         gtk_list_store_set (GTK_LIST_STORE (model), &amp;iter, 
 
116
                             DATA_COLUMN, data, -1);
 
117
    }
 
118
    </programlisting></informalexample>
 
119
    assuming that your tree model has a <literal>DATA_COLUMN</literal> of type 
 
120
    %G_TYPE_POINTER.
 
121
  </para>
 
122
 
 
123
  <para>
 
124
    There is a number of minor API differences between 
 
125
    <structname>GnomeIconList</structname> and 
 
126
    <structname>GtkIconView</structname>:
 
127
    <itemizedlist> 
 
128
     <listitem><para>
 
129
       <typename>GnomeIconListMode</typename> is replaced by the 
 
130
       <link linkend="GtkIconView--orientation">orientation</link> 
 
131
       property of <structname>GtkIconView</structname>
 
132
     </para></listitem>
 
133
     <listitem><para>
 
134
       <structname>GtkIconView</structname> can not be frozen in the same 
 
135
       way as <structname>GnomeIconList</structname> can with 
 
136
       gnome_icon_list_freeze() and gnome_icon_list_thaw(). Instead you can 
 
137
       replace the whole model of a <structname>GtkIconView</structname>, 
 
138
       instead of doing many small changes to the existing model.
 
139
     </para></listitem>
 
140
    </itemizedlist>
 
141
  </para> 
 
142
</chapter>
 
143
 
 
144
<!--
 
145
Local variables:
 
146
mode: sgml
 
147
sgml-parent-document: ("gtk-docs.sgml" "book" "part" "chapter")
 
148
End:
 
149
-->