From 3ace68ee6f143abbcd1cc2f38f6595557dc2eaa5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 11 May 2011 23:55:54 -0400 Subject: [PATCH] Add an initial migration chapter for GtkGrid --- docs/reference/gtk/Makefile.am | 6 + docs/reference/gtk/gtk-docs.sgml | 1 + docs/reference/gtk/images/box-expand.png | Bin 0 -> 2372 bytes docs/reference/gtk/images/box-packing.png | Bin 0 -> 3561 bytes docs/reference/gtk/images/widget-hvalign.png | Bin 0 -> 7323 bytes docs/reference/gtk/migrating-GtkGrid.xml | 185 +++++++++++++++++++ 6 files changed, 192 insertions(+) create mode 100644 docs/reference/gtk/images/box-expand.png create mode 100644 docs/reference/gtk/images/box-packing.png create mode 100644 docs/reference/gtk/images/widget-hvalign.png create mode 100644 docs/reference/gtk/migrating-GtkGrid.xml diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am index a9bdd747c..7c643b55a 100644 --- a/docs/reference/gtk/Makefile.am +++ b/docs/reference/gtk/Makefile.am @@ -124,6 +124,7 @@ content_files = \ migrating-2to3.xml \ migrating-checklist.sgml \ migrating-GtkApplication.xml \ + migrating-GtkGrid.xml \ migrating-GtkStyleContext.xml \ objects_grouped.sgml \ osx.sgml \ @@ -146,6 +147,7 @@ expand_content_files = \ migrating-2to3.xml \ migrating-checklist.sgml \ migrating-GtkApplication.xml \ + migrating-GtkGrid.xml \ migrating-GtkStyleContext.xml \ question_index.sgml \ text_widget.sgml \ @@ -277,6 +279,8 @@ HTML_IMAGES = \ $(srcdir)/images/appchooserbutton.png \ $(srcdir)/images/appchooserdialog.png \ $(srcdir)/images/assistant.png \ + $(srcdir)/images/box-packing.png \ + $(srcdir)/images/box-expand.png \ $(srcdir)/images/button.png \ $(srcdir)/images/check-button.png \ $(srcdir)/images/color-button.png \ @@ -296,6 +300,7 @@ HTML_IMAGES = \ $(srcdir)/images/label.png \ $(srcdir)/images/link-button.png \ $(srcdir)/images/list-and-tree.png \ + $(srcdir)/images/lockbutton.png \ $(srcdir)/images/lockbutton-locked.png \ $(srcdir)/images/lockbutton-unlocked.png \ $(srcdir)/images/lockbutton-sorry.png \ @@ -329,6 +334,7 @@ HTML_IMAGES = \ $(srcdir)/images/layout-rltb.png \ $(srcdir)/images/layout-tblr.png \ $(srcdir)/images/layout-tbrl.png \ + $(srcdir)/images/widget-hvalign.png \ $(srcdir)/images/window-default.png \ $(srcdir)/images/hello-world.png \ $(srcdir)/images/grid-packing.png \ diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml index a2bd08298..11d14ab2d 100644 --- a/docs/reference/gtk/gtk-docs.sgml +++ b/docs/reference/gtk/gtk-docs.sgml @@ -355,6 +355,7 @@ + diff --git a/docs/reference/gtk/images/box-expand.png b/docs/reference/gtk/images/box-expand.png new file mode 100644 index 0000000000000000000000000000000000000000..e5af4f285a6f38344a52b25ae1c5a8715b2a2940 GIT binary patch literal 2372 zcma);YdjN<9>$l@O#U^IP;N~wxyv&oCf8y@NLVUnuDON~lG`6eOj3)~ zP$P5OjB+<-+lCC z0010Bz^~YcJzu0pS)ag299fRij?w-?yd29X7$b`24lI)~Qz+nSlWM~c5()+z+So3s zAjN?Kc_~o2a@R%Bibqrq)eJptaN2Nz_Qy@p4g8%bA){yp5D@&5kbSv6d@1=%@I^kH zY%4mQF;lBG+{9e%Sz1-fD|}U6enc7$Xa`T;VgUeW52x~+{(m50G}E1x%H(}oLwO$d z_F6)tvn}cql#Fb|lDw4e@jaw?2qSZCD^9PAzc_mwctI?QFA*CO!VWW7kLZA;ni{v* zB1-NEL)Z4cf17t$#iJ zM>LQ%CsUNtlRSQem)FcH1NDAA->fuOTvyJYC1GOnWtymbcT~_EMCkboco{f#dY6L^ zWEJ7D63H81Yg`HIgiBgF{H#f_E?odHB3Q7NDFi^l)3JP3~Bu}*|@12bNL6YuXv-TBrdKTUcBLf7-q*yiYKnDmfa6yZbgmM z75~~TTwKf3JL|QOxtoK;_`F`CZEYMA(6M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64Y#N^5#M!eB=CgSYod>v0OBTRU3878W%KI?`&C)tOm9 z!7*#p8^gY+l#2~EIyYuU zt$CA)(hC*@*8o3t#8jMX>EVU z5|t>lLR%=-ricHKKCs$yeM6H!NjE24}}0##}KLU#kK0@4~Zzx;@wQoX@p_WShz(4Jj1 z)?0jC{u>L`@95%BE+ahokaXC<%xaS1O4}?52Wpx;<7%(SN)y*HROXx@!-iGd^U22} zPQ$>~)wRjcELU@!$y}@8?aPVSNH0uP{?yS5NtV6`{9Bf}7K4Vq@A6sFq+4runpF!n zSA!EG>J!7W#$turf^9JoiQyj`19Y8Wr@WN4b*;z`<#<>pU4>t_f?FB@dYQNa&sp zo|x5ej^tqxbob6|?&`NsR}KNmtIPS2y)|YPC|a+}2dsVUKD3@}3hen*NX4RT zjL9mqzalTck5=X0nZr15>Ob^%6P;$rQV}+1`z_Cl>Kiiu@IGs*)7{y>qWk+m# + + + + Migrating from other containers to GtkGrid + + + #GtkGrid is an attempt to write a comprehensive, legacy-free, + box-layout container that is flexible enough to replace #GtkBox, + #GtkTable, #GtkAlignment and the like. + + + + The layout model of GtkGrid is to arrange its children in rows and + columns (children can span multiple rows or columns, too). This is + done by assigning positions (and sizes) on a two-dimentions grid that + stretches arbitrarily far in all directions. + + +
+ + GtkBox versus GtkGrid: packing + + + GtkBox works by arranging child widgets in a single line, either + horizontally or vertically. It allows packing children from the + beginning or end, using gtk_box_pack_start() and gtk_box_pack_end(). + + + + + + A simple box + + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + + gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("One"), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("Two"), FALSE, FALSE, 0); + + This can be done with #GtkGrid as follows: + + grid = gtk_grid_new (); + + child1 = gtk_label_new ("One"); + gtk_grid_attach (GTK_GRID (grid), child1, 0, 0, 1, 1); + child2 = gtk_label_new ("Two"); + gtk_grid_attach_next_to (GTK_GRID (grid), child2, child1, GTK_POS_RIGHT, 1, 1); + + + And similarly for gtk_box_pack_end(). In that case, you + would use #GTK_POS_LEFT to place the grid children from + left to right. + + + + + One difference to keep in mind is that the gtk_box_pack_start/pack_end + functions allow you to place an arbitrary number of children from + either end without ever 'colliding in the middle'. With GtkGrid, you + have to leave enough space between the two ends, if you want to combine + packing from both ends towards the middle. In practice, this should be + easy to avoid; and GtkGrid simply ignores entirely empty rows or + columns for layout and spacing. + + + On the other hand, GtkGrid is more flexible in that its grid extends + indefinitively in both directions — there is no problem with + using negative numbers for the grid positions. So, if you discover + that you need to place a widget before your existing arrangement, + you always can. + +
+ +
+ GtkBox versus GtkGrid: sizing + + + When adding a child to a GtkBox, there are two hard-to-remember + parameters (child properties, more exactly) named expand and fill + that determine how the child size behaves in the main direction + of the box. If expand is set, the box allows the position occupied + by the child to grow when extra space is available. If fill is + also set, the extra space is allocated to the child widget itself. + Otherwise it is left 'free'. + There is no control about the 'minor' direction; children + are always given the full size in the minor direction. + + + + + + GtkGrid does not have any custom child properties for controlling + size allocation to children. Instead, it fully supports the newly + introduced #GtkWidget:hexpand, #GtkWidget:vexpand, #GtkWidget:halign + and #GtkWidget:valign properties. + + + The #GtkWidget:hexpand and #GtkWidget:vexpand properties operate + in a similar way to the expand child properties of #GtkBox. As soon + as a column contains a hexpanding child, GtkGrid allows the column + to grow when extra space is available (similar for rows and vexpand). + In contrast to GtkBox, all the extra space is always allocated + to the child widget, there are no 'free' areas. + + + To replace the functionality of the fill child properties, you can + set the #GtkWidget:halign and #GtkWidget:valign properties. An + align value of #GTK_ALIGN_FILL has the same effect as setting fill + to %TRUE, a value of #GTK_ALIGN_CENTER has the same effect as setting + fill to %FALSE. The image below shows the effect of various combinations + of halign and valign. + + + + + + Expansion and alignment + + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + + gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("One"), TRUE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("Two"), TRUE, TRUE, 0); + + This can be done with #GtkGrid as follows: + + grid = gtk_grid_new (); + + child1 = gtk_label_new ("One"); + gtk_widget_set_hexpand (child1, TRUE); + gtk_widget_set_halign (child1, GTK_ALIGN_CENTER); + gtk_grid_attach (GTK_GRID (grid), child1, 0, 0, 1, 1); + child2 = gtk_label_new ("Two"); + gtk_widget_set_hexpand (child2, TRUE); + gtk_widget_set_halign (child1, GTK_ALIGN_FILL); + gtk_grid_attach_next_to (GTK_GRID (grid), child2, child1, GTK_POS_RIGHT, 1, 1); + + + + One difference between the new GtkWidget expand properties and + the GtkBox child property of the same name is that widget expandability + is 'inherited' from children. What this means is that a container + will become itself expanding as soon as it has + an expanding child. This is typically what you want, it lets + you e.g. mark the content pane of your application window as + expanding, and all the intermediate containers between the + content pane and the toplevel window will automatically do + the right thing. This automatism can be overridden at any + point by setting the expand flags on a container explicitly. + + + Another difference between GtkBox and GtkGrid with respect to + expandability is when there are no expanding children at all. + In this case, GtkBox will forcibly expand all children whereas + GtkGrid will not. In practice, the effect of this is typically + that a grid will 'stick to the corner' when the toplevel + containing it is grown, instead of spreading out its children + over the entire area. The problem can be fixed by setting some + or all of the children to expand. + + + + When you set the #GtkBox:homogeneous property on a GtkBox, + it reserves the same space for all its children. GtkGrid does + this in a very similar way, with #GtkGrid:row-homogeneous and + #GtkGrid:column-homogeneous properties which control whether + all rows have the same height and whether all columns have + the same width. + +
+ + +
-- 2.43.2