summaryrefslogtreecommitdiffstats
path: root/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkhbbox.c.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkhbbox.c.diff')
-rw-r--r--meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkhbbox.c.diff344
1 files changed, 344 insertions, 0 deletions
diff --git a/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkhbbox.c.diff b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkhbbox.c.diff
new file mode 100644
index 0000000000..e43db37f5c
--- /dev/null
+++ b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkhbbox.c.diff
@@ -0,0 +1,344 @@
1--- gtk+-2.6.4/gtk/gtkhbbox.c 2004-08-09 19:59:52.000000000 +0300
2+++ gtk+-2.6.4/gtk/gtkhbbox.c 2005-04-06 16:19:36.644967480 +0300
3@@ -24,10 +24,20 @@
4 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
5 */
6
7+/* Modified for Nokia Oyj during 2002-2005. See CHANGES file for list
8+ * of changes.
9+ */
10+
11+/* Hildon : Button spacing according to the spec. */
12+#define HILDON_BUTTON_SPACING 5
13+/* Selecting hetefogenous mode for a childlayout */
14+#define GTK_BUTTONBOX_HETEROGENOUS 6
15+
16 #include <config.h>
17 #include "gtkalias.h"
18 #include "gtkhbbox.h"
19-
20+/* Hildon : We need this to mess with buttons graphics. */
21+#include "gtkbutton.h"
22
23 static void gtk_hbutton_box_class_init (GtkHButtonBoxClass *klass);
24 static void gtk_hbutton_box_init (GtkHButtonBox *box);
25@@ -36,6 +46,15 @@
26 static void gtk_hbutton_box_size_allocate (GtkWidget *widget,
27 GtkAllocation *allocation);
28
29+static void osso_gtk_hbutton_child_showhide_handler (GtkWidget *widget,
30+ gpointer user_data);
31+static void osso_gtk_hbutton_box_remove_child_signal_handlers (GtkHButtonBox *hbbox,
32+ GtkWidget *removed_widget,
33+ gpointer data);
34+static void osso_gtk_hbutton_box_find_button_detail (GtkHButtonBox *hbbox,
35+ GtkWidget *addremovewidget,
36+ gpointer data);
37+
38 static gint default_spacing = 30;
39 static gint default_layout_style = GTK_BUTTONBOX_EDGE;
40
41@@ -76,12 +95,23 @@
42
43 widget_class->size_request = gtk_hbutton_box_size_request;
44 widget_class->size_allocate = gtk_hbutton_box_size_allocate;
45+
46+ /* HILDON:
47+ * Name buttons only if hildon like style property is set
48+ */
49+ gtk_widget_class_install_style_property (widget_class,
50+ g_param_spec_boolean
51+ ( "hildonlike",
52+ "hildonlike looks",
53+ "Name buttons, 1/0",
54+ FALSE,
55+ G_PARAM_READABLE) );
56 }
57
58 static void
59 gtk_hbutton_box_init (GtkHButtonBox *hbutton_box)
60 {
61- /* button_box_init has done everything allready */
62+ /* button_box_init has done everything allready */
63 }
64
65 GtkWidget*
66@@ -91,6 +121,24 @@
67
68 hbutton_box = g_object_new (GTK_TYPE_HBUTTON_BOX, NULL);
69
70+ /* Attach signal handler for 'hildonizing' buttons.
71+ * gtk_hbutton_box_hildonize_buttons will check the name
72+ * and if it is something we're interested in i.e.
73+ *
74+ * hildon_dialogbuttons
75+ * hildon_viewbuttons
76+ *
77+ * it will do the hildonizing
78+ */
79+ g_signal_connect_after (G_OBJECT (hbutton_box), "remove",
80+ G_CALLBACK (osso_gtk_hbutton_box_remove_child_signal_handlers),
81+ NULL);
82+ g_signal_connect_after( G_OBJECT( hbutton_box ), "add",
83+ G_CALLBACK( osso_gtk_hbutton_box_find_button_detail ),
84+ NULL );
85+ g_signal_connect_after( G_OBJECT( hbutton_box ), "remove",
86+ G_CALLBACK( osso_gtk_hbutton_box_find_button_detail ),
87+ NULL );
88 return GTK_WIDGET (hbutton_box);
89 }
90
91@@ -145,6 +193,11 @@
92 gint child_height;
93 gint spacing;
94 GtkButtonBoxStyle layout;
95+ gint child_xpad=0;
96+ GtkBoxChild *child_req;
97+ GList *children_req;
98+ GtkRequisition treq;
99+
100
101 box = GTK_BOX (widget);
102 bbox = GTK_BUTTON_BOX (widget);
103@@ -159,6 +212,12 @@
104 &child_width,
105 &child_height);
106
107+ /* should GTK_BUTTONBOX_HETEROGENOUS add into the GtkButtonBoxStyle
108+ enum struct
109+ */
110+ if( !box->homogeneous )
111+ layout = GTK_BUTTONBOX_HETEROGENOUS;
112+
113 if (nvis_children == 0)
114 {
115 requisition->width = 0;
116@@ -177,11 +236,36 @@
117 case GTK_BUTTONBOX_END:
118 requisition->width = nvis_children*child_width + ((nvis_children-1)*spacing);
119 break;
120+ case GTK_BUTTONBOX_HETEROGENOUS:
121+ children_req = GTK_BOX (box)->children;
122+ child_req = children_req->data;
123+ requisition->width = 0;
124+
125+ while (children_req)
126+ {
127+ child_req = children_req->data;
128+ children_req = children_req->next;
129+
130+ if (GTK_WIDGET_VISIBLE (child_req->widget))
131+ {
132+ gtk_widget_get_child_requisition( child_req->widget,
133+ &(treq) );
134+ requisition->width += treq.width;
135+
136+ gtk_widget_style_get(widget,
137+ "child-internal-pad-x",
138+ &(child_xpad), NULL);
139+ requisition->width += (child_xpad*2);
140+ }
141+ }
142+ requisition->width += ((nvis_children-1)*spacing);
143+
144+ break;
145 default:
146 g_assert_not_reached();
147 break;
148 }
149-
150+
151 requisition->height = child_height;
152 }
153
154@@ -227,6 +311,10 @@
155 &child_height);
156 widget->allocation = *allocation;
157 width = allocation->width - GTK_CONTAINER (box)->border_width*2;
158+
159+ if( !base_box->homogeneous )
160+ layout = GTK_BUTTONBOX_HETEROGENOUS;
161+
162 switch (layout)
163 {
164 case GTK_BUTTONBOX_SPREAD:
165@@ -264,6 +352,39 @@
166 - GTK_CONTAINER (box)->border_width;
167 secondary_x = allocation->x + GTK_CONTAINER (box)->border_width;
168 break;
169+ case GTK_BUTTONBOX_HETEROGENOUS:
170+ {
171+ gint sumwidth = 0;
172+ GtkBoxChild *child_h;
173+ GList *children_h = GTK_BOX (box)->children;
174+ /* heterogenous sized childs onto center */
175+ childspacing = spacing;
176+ child_h = children_h->data;
177+
178+ while (children_h )
179+ {
180+ if ( g_list_length (children_h) == 0 ) break;
181+
182+ child_h = children_h->data;
183+ children_h = children_h->next;
184+
185+ if (GTK_WIDGET_VISIBLE (child_h->widget))
186+ {
187+ gint child_xpad = 0;
188+ GtkRequisition treq;
189+ gtk_widget_get_child_requisition( child_h->widget, &(treq) );
190+ sumwidth += treq.width;
191+
192+ gtk_widget_style_get(widget,
193+ "child-internal-pad-x",
194+ &(child_xpad), NULL);
195+ sumwidth += (child_xpad*2);
196+ }
197+ }
198+ x = secondary_x = allocation->x +
199+ ( (allocation->width - sumwidth - (spacing * (nvis_children - 1)))/2 );
200+ break;
201+ }
202 default:
203 g_assert_not_reached();
204 break;
205@@ -282,10 +403,33 @@
206
207 if (GTK_WIDGET_VISIBLE (child->widget))
208 {
209- child_allocation.width = child_width;
210 child_allocation.height = child_height;
211 child_allocation.y = y;
212
213+ if(layout != GTK_BUTTONBOX_HETEROGENOUS)
214+ {
215+ child_allocation.width = child_width;
216+ }
217+ else /* if layout will be hetergenous */
218+ {
219+ gint child_hwidth = 0;
220+ GtkRequisition treq;
221+ gint child_xpad = 0;
222+
223+ gtk_widget_get_child_requisition( child->widget, &(treq) );
224+ child_hwidth += treq.width;
225+
226+ gtk_widget_style_get(widget,
227+ "child-internal-pad-x",
228+ &child_xpad, NULL);
229+ child_hwidth += (child_xpad*2);
230+
231+ child_allocation.width = child_hwidth;
232+ childspace = child_hwidth + childspacing;
233+
234+ }
235+
236+ /* calculate the horizontal location */
237 if (child->is_secondary)
238 {
239 child_allocation.x = secondary_x;
240@@ -304,4 +448,104 @@
241 }
242 }
243 }
244+
245+/* Function to wrap "hide" and "show" signals to call
246+ * osso_gtk_hbutton_box_find_button_detail -function.*/
247+static void osso_gtk_hbutton_child_showhide_handler (GtkWidget *widget,
248+ gpointer user_data)
249+{
250+ osso_gtk_hbutton_box_find_button_detail (widget, GTK_WIDGET (user_data), NULL);
251+}
252
253+/* Function to remove "show"&"hide" signal handlers
254+ * from a child when it's removed. */
255+static void osso_gtk_hbutton_box_remove_child_signal_handlers (GtkHButtonBox *hbbox,
256+ GtkWidget *removed_widget,
257+ gpointer data)
258+{
259+ g_signal_handlers_disconnect_by_func (G_OBJECT (removed_widget), osso_gtk_hbutton_box_find_button_detail, hbbox);
260+}
261+
262+/* Signal handler called when we have to set
263+ * painting detail values for buttons in this
264+ * gtk_horizontal_button_box.
265+ */
266+static void osso_gtk_hbutton_box_find_button_detail (GtkHButtonBox *hbbox,
267+ GtkWidget *addremovewidget,
268+ gpointer data)
269+{
270+ GList *child;
271+ gint visible_buttons = 0;
272+ gint secondary_buttons = 0;
273+ GtkWidget *leftmost_button = NULL;
274+ GtkWidget *rightmost_button = NULL;
275+
276+ for( child = GTK_BOX (hbbox)->children ; child ; child = child->next )
277+ {
278+ GtkBoxChild *box_child = child->data;
279+ GtkWidget *child_widget = box_child->widget;
280+ gulong signal_handler = g_signal_handler_find ( G_OBJECT( child_widget ),
281+ G_SIGNAL_MATCH_FUNC,
282+ 0, 0, NULL,
283+ G_CALLBACK (osso_gtk_hbutton_child_showhide_handler),
284+ NULL);
285+
286+ if (signal_handler == 0)
287+ {
288+ g_signal_connect_object ( G_OBJECT( child_widget ),
289+ "hide",
290+ G_CALLBACK ( osso_gtk_hbutton_child_showhide_handler ),
291+ hbbox, G_CONNECT_SWAPPED);
292+ g_signal_connect_object ( G_OBJECT( child_widget ),
293+ "show",
294+ G_CALLBACK ( osso_gtk_hbutton_child_showhide_handler ),
295+ hbbox, G_CONNECT_SWAPPED);
296+ }
297+
298+ if ((GTK_WIDGET_VISIBLE (child_widget)) &&
299+ (GTK_IS_BUTTON (child_widget)))
300+ visible_buttons++;
301+ else
302+ continue;
303+
304+ if (leftmost_button == NULL)
305+ leftmost_button = child_widget;
306+
307+ if (secondary_buttons == 0)
308+ rightmost_button = child_widget;
309+ else
310+ if (box_child->is_secondary)
311+ {
312+ rightmost_button = child_widget;
313+ secondary_buttons++;
314+ }
315+
316+ if (box_child->is_secondary)
317+ rightmost_button = child_widget;
318+ }
319+
320+ if (visible_buttons == 0)
321+ return;
322+
323+ for( child = GTK_BOX (hbbox)->children ; child ; child = child->next )
324+ {
325+ GtkBoxChild *box_child = child->data;
326+ GtkWidget *child_widget = box_child->widget;
327+ OssoGtkButtonAttachFlags attachflags = OSSO_GTK_BUTTON_ATTACH_NORTH | OSSO_GTK_BUTTON_ATTACH_SOUTH;
328+ gboolean automatic_detail;
329+
330+ if (!((GTK_WIDGET_VISIBLE (child_widget)) &&
331+ (GTK_IS_BUTTON (child_widget))))
332+ continue;
333+
334+ if (child_widget == leftmost_button)
335+ attachflags |= OSSO_GTK_BUTTON_ATTACH_WEST;
336+
337+ if (child_widget == rightmost_button)
338+ attachflags |= OSSO_GTK_BUTTON_ATTACH_EAST;
339+
340+ g_object_get (G_OBJECT (child_widget), "automatic_detail", &automatic_detail, NULL);
341+ if (automatic_detail == TRUE)
342+ g_object_set (G_OBJECT (child_widget), "detail", osso_gtk_button_attach_details[attachflags], NULL);
343+ }
344+}