~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimpframe.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
gimp_frame_size_request (GtkWidget      *widget,
99
99
                         GtkRequisition *requisition)
100
100
{
101
 
  GtkFrame       *frame = GTK_FRAME (widget);
102
 
  GtkBin         *bin   = GTK_BIN (widget);
 
101
  GtkFrame       *frame        = GTK_FRAME (widget);
 
102
  GtkWidget      *label_widget = gtk_frame_get_label_widget (frame);
 
103
  GtkWidget      *child        = gtk_bin_get_child (GTK_BIN (widget));
103
104
  GtkRequisition  child_requisition;
 
105
  gint            border_width;
104
106
 
105
 
  if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
 
107
  if (label_widget && GTK_WIDGET_VISIBLE (label_widget))
106
108
    {
107
 
      gtk_widget_size_request (frame->label_widget, requisition);
 
109
      gtk_widget_size_request (label_widget, requisition);
108
110
    }
109
111
  else
110
112
    {
114
116
 
115
117
  requisition->height += gimp_frame_get_label_spacing (frame);
116
118
 
117
 
  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
 
119
  if (child && GTK_WIDGET_VISIBLE (child))
118
120
    {
119
121
      gint indent = gimp_frame_get_indent (widget);
120
122
 
121
 
      gtk_widget_size_request (bin->child, &child_requisition);
 
123
      gtk_widget_size_request (child, &child_requisition);
122
124
 
123
125
      requisition->width = MAX (requisition->width,
124
126
                                child_requisition.width + indent);
125
127
      requisition->height += child_requisition.height;
126
128
    }
127
129
 
128
 
  requisition->width  += 2 * GTK_CONTAINER (widget)->border_width;
129
 
  requisition->height += 2 * GTK_CONTAINER (widget)->border_width;
 
130
  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
131
 
 
132
  requisition->width  += 2 * border_width;
 
133
  requisition->height += 2 * border_width;
130
134
}
131
135
 
132
136
static void
133
137
gimp_frame_size_allocate (GtkWidget     *widget,
134
138
                          GtkAllocation *allocation)
135
139
{
136
 
  GtkFrame *frame = GTK_FRAME (widget);
137
 
  GtkBin   *bin   = GTK_BIN (widget);
 
140
  GtkFrame  *frame        = GTK_FRAME (widget);
 
141
  GtkWidget *label_widget = gtk_frame_get_label_widget (frame);
 
142
  GtkWidget *child        = gtk_bin_get_child (GTK_BIN (widget));
138
143
 
139
144
  widget->allocation = *allocation;
140
145
 
141
146
  gimp_frame_child_allocate (frame, &frame->child_allocation);
142
147
 
143
 
  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
144
 
    gtk_widget_size_allocate (bin->child, &frame->child_allocation);
 
148
  if (child && GTK_WIDGET_VISIBLE (child))
 
149
    gtk_widget_size_allocate (child, &frame->child_allocation);
145
150
 
146
 
  if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
 
151
  if (label_widget && GTK_WIDGET_VISIBLE (label_widget))
147
152
    {
148
153
      GtkAllocation   label_allocation;
149
154
      GtkRequisition  label_requisition;
150
 
      gint            border = GTK_CONTAINER (widget)->border_width;
151
 
 
152
 
      gtk_widget_get_child_requisition (frame->label_widget,
153
 
                                        &label_requisition);
154
 
 
155
 
      label_allocation.x      = allocation->x + border;
156
 
      label_allocation.y      = allocation->y + border;
 
155
      gint            border_width;
 
156
 
 
157
      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
158
 
 
159
      gtk_widget_get_child_requisition (label_widget, &label_requisition);
 
160
 
 
161
      label_allocation.x      = allocation->x + border_width;
 
162
      label_allocation.y      = allocation->y + border_width;
157
163
      label_allocation.width  = MAX (label_requisition.width,
158
 
                                     allocation->width - 2 * border);
 
164
                                     allocation->width - 2 * border_width);
159
165
      label_allocation.height = label_requisition.height;
160
166
 
161
 
      gtk_widget_size_allocate (frame->label_widget, &label_allocation);
 
167
      gtk_widget_size_allocate (label_widget, &label_allocation);
162
168
    }
163
169
}
164
170
 
166
172
gimp_frame_child_allocate (GtkFrame      *frame,
167
173
                           GtkAllocation *child_allocation)
168
174
{
169
 
  GtkWidget     *widget     = GTK_WIDGET (frame);
170
 
  GtkAllocation *allocation = &widget->allocation;
171
 
  gint           border     = GTK_CONTAINER (frame)->border_width;
172
 
  gint           spacing    = 0;
173
 
  gint           indent     = gimp_frame_get_indent (widget);
174
 
 
175
 
  if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
 
175
  GtkWidget     *widget       = GTK_WIDGET (frame);
 
176
  GtkWidget     *label_widget = gtk_frame_get_label_widget (frame);
 
177
  GtkAllocation *allocation   = &widget->allocation;
 
178
  gint           border_width;
 
179
  gint           spacing      = 0;
 
180
  gint           indent       = gimp_frame_get_indent (widget);
 
181
 
 
182
  border_width = gtk_container_get_border_width (GTK_CONTAINER (frame));
 
183
 
 
184
  if (label_widget && GTK_WIDGET_VISIBLE (label_widget))
176
185
    {
177
186
      GtkRequisition  child_requisition;
178
187
 
179
 
      gtk_widget_get_child_requisition (frame->label_widget,
180
 
                                        &child_requisition);
 
188
      gtk_widget_get_child_requisition (label_widget, &child_requisition);
181
189
      spacing += child_requisition.height;
182
190
    }
183
191
 
184
192
  spacing += gimp_frame_get_label_spacing (frame);
185
193
 
186
194
  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
187
 
    child_allocation->x    = border + indent;
 
195
    child_allocation->x    = border_width + indent;
188
196
  else
189
 
    child_allocation->x    = border;
 
197
    child_allocation->x    = border_width;
190
198
 
191
 
  child_allocation->y      = border + spacing;
 
199
  child_allocation->y      = border_width + spacing;
192
200
  child_allocation->width  = MAX (1,
193
 
                                  allocation->width - 2 * border - indent);
 
201
                                  allocation->width - 2 * border_width - indent);
194
202
  child_allocation->height = MAX (1,
195
203
                                  allocation->height -
196
 
                                  child_allocation->y - border);
 
204
                                  child_allocation->y - border_width);
197
205
 
198
206
  child_allocation->x += allocation->x;
199
207
  child_allocation->y += allocation->y;
227
235
static void
228
236
gimp_frame_label_widget_notify (GtkFrame *frame)
229
237
{
230
 
  if (frame->label_widget)
 
238
  GtkWidget *label_widget = gtk_frame_get_label_widget (frame);
 
239
 
 
240
  if (label_widget)
231
241
    {
232
242
      GtkLabel *label = NULL;
233
243
 
234
 
      if (GTK_IS_LABEL (frame->label_widget))
 
244
      if (GTK_IS_LABEL (label_widget))
235
245
        {
236
 
          label = GTK_LABEL (frame->label_widget);
237
 
 
238
 
          gtk_misc_set_alignment (GTK_MISC (label),
239
 
                                  frame->label_xalign, frame->label_yalign);
 
246
          gfloat xalign, yalign;
 
247
 
 
248
          label = GTK_LABEL (label_widget);
 
249
 
 
250
          gtk_frame_get_label_align (frame, &xalign, &yalign);
 
251
          gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign);
240
252
        }
241
 
      else if (GTK_IS_BIN (frame->label_widget))
 
253
      else if (GTK_IS_BIN (label_widget))
242
254
        {
243
 
          GtkWidget *child = gtk_bin_get_child (GTK_BIN (frame->label_widget));
 
255
          GtkWidget *child = gtk_bin_get_child (GTK_BIN (label_widget));
244
256
 
245
257
          if (GTK_IS_LABEL (child))
246
258
            label = GTK_LABEL (child);
293
305
static gint
294
306
gimp_frame_get_label_spacing (GtkFrame *frame)
295
307
{
296
 
  gint spacing = 0;
 
308
  GtkWidget *label_widget = gtk_frame_get_label_widget (frame);
 
309
  gint       spacing      = 0;
297
310
 
298
 
  if ((frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget)) ||
 
311
  if ((label_widget && GTK_WIDGET_VISIBLE (label_widget)) ||
299
312
      (g_object_get_data (G_OBJECT (frame), GIMP_FRAME_IN_EXPANDER_KEY)))
300
313
    {
301
314
      gtk_widget_style_get (GTK_WIDGET (frame),