~ubuntu-branches/ubuntu/lucid/webkit/lucid-security

« back to all changes in this revision

Viewing changes to WebCore/platform/gtk/gtk2drawing.c

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2010-01-20 20:09:57 UTC
  • mfrom: (1.2.7 upstream) (4.3.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100120200957-3ng8lah18c7pmm52
* New upstream release
- Fixes crashes related to clearing the clipboard, which many users were
  experiencing (Closes: #565166)

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
#define YTHICKNESS(style) (style->ythickness)
57
57
#define WINDOW_IS_MAPPED(window) ((window) && GDK_IS_WINDOW(window) && gdk_window_is_visible(window))
58
58
 
59
 
static GtkWidget* gProtoWindow;
60
 
static GtkWidget* gProtoLayout;
61
 
static GtkWidget* gButtonWidget;
62
 
static GtkWidget* gToggleButtonWidget;
63
 
static GtkWidget* gButtonArrowWidget;
64
 
static GtkWidget* gCheckboxWidget;
65
 
static GtkWidget* gRadiobuttonWidget;
66
 
static GtkWidget* gHorizScrollbarWidget;
67
 
static GtkWidget* gVertScrollbarWidget;
68
 
static GtkWidget* gSpinWidget;
69
 
static GtkWidget* gHScaleWidget;
70
 
static GtkWidget* gVScaleWidget;
71
 
static GtkWidget* gEntryWidget;
72
 
static GtkWidget* gComboBoxWidget;
73
 
static GtkWidget* gComboBoxButtonWidget;
74
 
static GtkWidget* gComboBoxArrowWidget;
75
 
static GtkWidget* gComboBoxSeparatorWidget;
76
 
static GtkWidget* gComboBoxEntryWidget;
77
 
static GtkWidget* gComboBoxEntryTextareaWidget;
78
 
static GtkWidget* gComboBoxEntryButtonWidget;
79
 
static GtkWidget* gComboBoxEntryArrowWidget;
80
 
static GtkWidget* gHandleBoxWidget;
81
 
static GtkWidget* gToolbarWidget;
82
 
static GtkWidget* gFrameWidget;
83
 
static GtkWidget* gStatusbarWidget;
84
 
static GtkWidget* gProgressWidget;
85
 
static GtkWidget* gTabWidget;
86
 
static GtkWidget* gTooltipWidget;
87
 
static GtkWidget* gMenuBarWidget;
88
 
static GtkWidget* gMenuBarItemWidget;
89
 
static GtkWidget* gMenuPopupWidget;
90
 
static GtkWidget* gMenuItemWidget;
91
 
static GtkWidget* gImageMenuItemWidget;
92
 
static GtkWidget* gCheckMenuItemWidget;
93
 
static GtkWidget* gTreeViewWidget;
94
 
static GtkTreeViewColumn* gMiddleTreeViewColumn;
95
 
static GtkWidget* gTreeHeaderCellWidget;
96
 
static GtkWidget* gTreeHeaderSortArrowWidget;
97
 
static GtkWidget* gExpanderWidget;
98
 
static GtkWidget* gToolbarSeparatorWidget;
99
 
static GtkWidget* gMenuSeparatorWidget;
100
 
static GtkWidget* gHPanedWidget;
101
 
static GtkWidget* gVPanedWidget;
102
 
static GtkWidget* gScrolledWindowWidget;
103
 
 
 
59
static GtkThemeParts *gParts = NULL;
104
60
static style_prop_t style_prop_func;
105
61
static gboolean have_arrow_scaling;
106
62
static gboolean is_initialized;
107
63
 
 
64
void
 
65
moz_gtk_use_theme_parts(GtkThemeParts* parts)
 
66
{
 
67
    gParts = parts;
 
68
}
 
69
 
108
70
/* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
109
71
   that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
110
72
   things they may want to do. */
124
86
static gint
125
87
ensure_window_widget()
126
88
{
127
 
    if (!gProtoWindow) {
128
 
        gProtoWindow = gtk_window_new(GTK_WINDOW_POPUP);
129
 
        gtk_widget_realize(gProtoWindow);
130
 
        moz_gtk_set_widget_name(gProtoWindow);
 
89
    if (!gParts->protoWindow) {
 
90
        gParts->protoWindow = gtk_window_new(GTK_WINDOW_POPUP);
 
91
 
 
92
        if (gParts->colormap)
 
93
            gtk_widget_set_colormap(gParts->protoWindow, gParts->colormap);
 
94
 
 
95
        gtk_widget_realize(gParts->protoWindow);
 
96
        moz_gtk_set_widget_name(gParts->protoWindow);
131
97
    }
132
98
    return MOZ_GTK_SUCCESS;
133
99
}
136
102
setup_widget_prototype(GtkWidget* widget)
137
103
{
138
104
    ensure_window_widget();
139
 
    if (!gProtoLayout) {
140
 
        gProtoLayout = gtk_fixed_new();
141
 
        gtk_container_add(GTK_CONTAINER(gProtoWindow), gProtoLayout);
 
105
    if (!gParts->protoLayout) {
 
106
        gParts->protoLayout = gtk_fixed_new();
 
107
        gtk_container_add(GTK_CONTAINER(gParts->protoWindow), gParts->protoLayout);
142
108
    }
143
109
 
144
 
    gtk_container_add(GTK_CONTAINER(gProtoLayout), widget);
 
110
    gtk_container_add(GTK_CONTAINER(gParts->protoLayout), widget);
145
111
    gtk_widget_realize(widget);
146
112
    g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
147
113
    return MOZ_GTK_SUCCESS;
150
116
static gint
151
117
ensure_button_widget()
152
118
{
153
 
    if (!gButtonWidget) {
154
 
        gButtonWidget = gtk_button_new_with_label("M");
155
 
        setup_widget_prototype(gButtonWidget);
 
119
    if (!gParts->buttonWidget) {
 
120
        gParts->buttonWidget = gtk_button_new_with_label("M");
 
121
        setup_widget_prototype(gParts->buttonWidget);
156
122
    }
157
123
    return MOZ_GTK_SUCCESS;
158
124
}
160
126
static gint
161
127
ensure_hpaned_widget()
162
128
{
163
 
    if (!gHPanedWidget) {
164
 
        gHPanedWidget = gtk_hpaned_new();
165
 
        setup_widget_prototype(gHPanedWidget);
 
129
    if (!gParts->hpanedWidget) {
 
130
        gParts->hpanedWidget = gtk_hpaned_new();
 
131
        setup_widget_prototype(gParts->hpanedWidget);
166
132
    }
167
133
    return MOZ_GTK_SUCCESS;
168
134
}
170
136
static gint
171
137
ensure_vpaned_widget()
172
138
{
173
 
    if (!gVPanedWidget) {
174
 
        gVPanedWidget = gtk_vpaned_new();
175
 
        setup_widget_prototype(gVPanedWidget);
 
139
    if (!gParts->vpanedWidget) {
 
140
        gParts->vpanedWidget = gtk_vpaned_new();
 
141
        setup_widget_prototype(gParts->vpanedWidget);
176
142
    }
177
143
    return MOZ_GTK_SUCCESS;
178
144
}
180
146
static gint
181
147
ensure_toggle_button_widget()
182
148
{
183
 
    if (!gToggleButtonWidget) {
184
 
        gToggleButtonWidget = gtk_toggle_button_new();
185
 
        setup_widget_prototype(gToggleButtonWidget);
 
149
    if (!gParts->toggleButtonWidget) {
 
150
        gParts->toggleButtonWidget = gtk_toggle_button_new();
 
151
        setup_widget_prototype(gParts->toggleButtonWidget);
186
152
        /* toggle button must be set active to get the right style on hover. */
187
 
        GTK_TOGGLE_BUTTON(gToggleButtonWidget)->active = TRUE;
 
153
        GTK_TOGGLE_BUTTON(gParts->toggleButtonWidget)->active = TRUE;
188
154
  }
189
155
  return MOZ_GTK_SUCCESS;
190
156
}
192
158
static gint
193
159
ensure_button_arrow_widget()
194
160
{
195
 
    if (!gButtonArrowWidget) {
 
161
    if (!gParts->buttonArrowWidget) {
196
162
        ensure_toggle_button_widget();
197
163
 
198
 
        gButtonArrowWidget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
199
 
        gtk_container_add(GTK_CONTAINER(gToggleButtonWidget), gButtonArrowWidget);
200
 
        gtk_widget_realize(gButtonArrowWidget);
 
164
        gParts->buttonArrowWidget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
 
165
        gtk_container_add(GTK_CONTAINER(gParts->toggleButtonWidget), gParts->buttonArrowWidget);
 
166
        gtk_widget_realize(gParts->buttonArrowWidget);
201
167
    }
202
168
    return MOZ_GTK_SUCCESS;
203
169
}
205
171
static gint
206
172
ensure_checkbox_widget()
207
173
{
208
 
    if (!gCheckboxWidget) {
209
 
        gCheckboxWidget = gtk_check_button_new_with_label("M");
210
 
        setup_widget_prototype(gCheckboxWidget);
 
174
    if (!gParts->checkboxWidget) {
 
175
        gParts->checkboxWidget = gtk_check_button_new_with_label("M");
 
176
        setup_widget_prototype(gParts->checkboxWidget);
211
177
    }
212
178
    return MOZ_GTK_SUCCESS;
213
179
}
215
181
static gint
216
182
ensure_radiobutton_widget()
217
183
{
218
 
    if (!gRadiobuttonWidget) {
219
 
        gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
220
 
        setup_widget_prototype(gRadiobuttonWidget);
 
184
    if (!gParts->radiobuttonWidget) {
 
185
        gParts->radiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
 
186
        setup_widget_prototype(gParts->radiobuttonWidget);
221
187
    }
222
188
    return MOZ_GTK_SUCCESS;
223
189
}
225
191
static gint
226
192
ensure_scrollbar_widget()
227
193
{
228
 
    if (!gVertScrollbarWidget) {
229
 
        gVertScrollbarWidget = gtk_vscrollbar_new(NULL);
230
 
        setup_widget_prototype(gVertScrollbarWidget);
 
194
    if (!gParts->vertScrollbarWidget) {
 
195
        gParts->vertScrollbarWidget = gtk_vscrollbar_new(NULL);
 
196
        setup_widget_prototype(gParts->vertScrollbarWidget);
231
197
    }
232
 
    if (!gHorizScrollbarWidget) {
233
 
        gHorizScrollbarWidget = gtk_hscrollbar_new(NULL);
234
 
        setup_widget_prototype(gHorizScrollbarWidget);
 
198
    if (!gParts->horizScrollbarWidget) {
 
199
        gParts->horizScrollbarWidget = gtk_hscrollbar_new(NULL);
 
200
        setup_widget_prototype(gParts->horizScrollbarWidget);
235
201
    }
236
202
    return MOZ_GTK_SUCCESS;
237
203
}
239
205
static gint
240
206
ensure_spin_widget()
241
207
{
242
 
  if (!gSpinWidget) {
243
 
    gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
244
 
    setup_widget_prototype(gSpinWidget);
 
208
  if (!gParts->spinWidget) {
 
209
    gParts->spinWidget = gtk_spin_button_new(NULL, 1, 0);
 
210
    setup_widget_prototype(gParts->spinWidget);
245
211
  }
246
212
  return MOZ_GTK_SUCCESS;
247
213
}
249
215
static gint
250
216
ensure_scale_widget()
251
217
{
252
 
  if (!gHScaleWidget) {
253
 
    gHScaleWidget = gtk_hscale_new(NULL);
254
 
    setup_widget_prototype(gHScaleWidget);
 
218
  if (!gParts->hScaleWidget) {
 
219
    gParts->hScaleWidget = gtk_hscale_new(NULL);
 
220
    setup_widget_prototype(gParts->hScaleWidget);
255
221
  }
256
 
  if (!gVScaleWidget) {
257
 
    gVScaleWidget = gtk_vscale_new(NULL);
258
 
    setup_widget_prototype(gVScaleWidget);
 
222
  if (!gParts->vScaleWidget) {
 
223
    gParts->vScaleWidget = gtk_vscale_new(NULL);
 
224
    setup_widget_prototype(gParts->vScaleWidget);
259
225
  }
260
226
  return MOZ_GTK_SUCCESS;
261
227
}
263
229
static gint
264
230
ensure_entry_widget()
265
231
{
266
 
    if (!gEntryWidget) {
267
 
        gEntryWidget = gtk_entry_new();
268
 
        setup_widget_prototype(gEntryWidget);
 
232
    if (!gParts->entryWidget) {
 
233
        gParts->entryWidget = gtk_entry_new();
 
234
        setup_widget_prototype(gParts->entryWidget);
269
235
    }
270
236
    return MOZ_GTK_SUCCESS;
271
237
}
278
244
 * g_object_add_weak_pointer().
279
245
 * Note that if we don't find the inner widgets (which shouldn't happen), we
280
246
 * fallback to use generic "non-inner" widgets, and they don't need that kind
281
 
 * of weak pointer since they are explicit children of gProtoWindow and as
 
247
 * of weak pointer since they are explicit children of gParts->protoWindow and as
282
248
 * such GTK holds a strong reference to them. */
283
249
static void
284
250
moz_gtk_get_combo_box_inner_button(GtkWidget *widget, gpointer client_data)
285
251
{
286
252
    if (GTK_IS_TOGGLE_BUTTON(widget)) {
287
 
        gComboBoxButtonWidget = widget;
 
253
        gParts->comboBoxButtonWidget = widget;
288
254
        g_object_add_weak_pointer(G_OBJECT(widget),
289
 
                                  (gpointer) &gComboBoxButtonWidget);
 
255
                                  (gpointer) &gParts->comboBoxButtonWidget);
290
256
        gtk_widget_realize(widget);
291
257
        g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
292
258
    }
297
263
                                           gpointer client_data)
298
264
{
299
265
    if (GTK_IS_SEPARATOR(widget)) {
300
 
        gComboBoxSeparatorWidget = widget;
 
266
        gParts->comboBoxSeparatorWidget = widget;
301
267
        g_object_add_weak_pointer(G_OBJECT(widget),
302
 
                                  (gpointer) &gComboBoxSeparatorWidget);
 
268
                                  (gpointer) &gParts->comboBoxSeparatorWidget);
303
269
    } else if (GTK_IS_ARROW(widget)) {
304
 
        gComboBoxArrowWidget = widget;
 
270
        gParts->comboBoxArrowWidget = widget;
305
271
        g_object_add_weak_pointer(G_OBJECT(widget),
306
 
                                  (gpointer) &gComboBoxArrowWidget);
 
272
                                  (gpointer) &gParts->comboBoxArrowWidget);
307
273
    } else
308
274
        return;
309
275
    gtk_widget_realize(widget);
315
281
{
316
282
    GtkWidget* buttonChild;
317
283
 
318
 
    if (gComboBoxButtonWidget && gComboBoxArrowWidget)
 
284
    if (gParts->comboBoxButtonWidget && gParts->comboBoxArrowWidget)
319
285
        return MOZ_GTK_SUCCESS;
320
286
 
321
287
    /* Create a ComboBox if needed */
322
 
    if (!gComboBoxWidget) {
323
 
        gComboBoxWidget = gtk_combo_box_new();
324
 
        setup_widget_prototype(gComboBoxWidget);
 
288
    if (!gParts->comboBoxWidget) {
 
289
        gParts->comboBoxWidget = gtk_combo_box_new();
 
290
        setup_widget_prototype(gParts->comboBoxWidget);
325
291
    }
326
292
 
327
293
    /* Get its inner Button */
328
 
    gtk_container_forall(GTK_CONTAINER(gComboBoxWidget),
 
294
    gtk_container_forall(GTK_CONTAINER(gParts->comboBoxWidget),
329
295
                         moz_gtk_get_combo_box_inner_button,
330
296
                         NULL);
331
297
 
332
 
    if (gComboBoxButtonWidget) {
 
298
    if (gParts->comboBoxButtonWidget) {
333
299
        /* Get the widgets inside the Button */
334
 
        buttonChild = GTK_BIN(gComboBoxButtonWidget)->child;
 
300
        buttonChild = GTK_BIN(gParts->comboBoxButtonWidget)->child;
335
301
        if (GTK_IS_HBOX(buttonChild)) {
336
302
            /* appears-as-list = FALSE, cell-view = TRUE; the button
337
303
             * contains an hbox. This hbox is there because the ComboBox
343
309
        } else if(GTK_IS_ARROW(buttonChild)) {
344
310
            /* appears-as-list = TRUE, or cell-view = FALSE;
345
311
             * the button only contains an arrow */
346
 
            gComboBoxArrowWidget = buttonChild;
 
312
            gParts->comboBoxArrowWidget = buttonChild;
347
313
            g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
348
 
                                      &gComboBoxArrowWidget);
349
 
            gtk_widget_realize(gComboBoxArrowWidget);
350
 
            g_object_set_data(G_OBJECT(gComboBoxArrowWidget),
 
314
                                      &gParts->comboBoxArrowWidget);
 
315
            gtk_widget_realize(gParts->comboBoxArrowWidget);
 
316
            g_object_set_data(G_OBJECT(gParts->comboBoxArrowWidget),
351
317
                              "transparent-bg-hint", GINT_TO_POINTER(TRUE));
352
318
        }
353
319
    } else {
355
321
         * use a generic toggle button as last resort fallback to avoid
356
322
         * crashing. */
357
323
        ensure_toggle_button_widget();
358
 
        gComboBoxButtonWidget = gToggleButtonWidget;
 
324
        gParts->comboBoxButtonWidget = gParts->toggleButtonWidget;
359
325
    }
360
326
 
361
 
    if (!gComboBoxArrowWidget) {
 
327
    if (!gParts->comboBoxArrowWidget) {
362
328
        /* Shouldn't be reached with current internal gtk implementation;
363
 
         * we gButtonArrowWidget as last resort fallback to avoid
 
329
         * we gParts->buttonArrowWidget as last resort fallback to avoid
364
330
         * crashing. */
365
331
        ensure_button_arrow_widget();
366
 
        gComboBoxArrowWidget = gButtonArrowWidget;
 
332
        gParts->comboBoxArrowWidget = gParts->buttonArrowWidget;
367
333
    }
368
334
 
369
 
    /* We don't test the validity of gComboBoxSeparatorWidget since there
 
335
    /* We don't test the validity of gParts->comboBoxSeparatorWidget since there
370
336
     * is none when "appears-as-list" = TRUE or "cell-view" = FALSE; if it
371
337
     * is invalid we just won't paint it. */
372
338
 
381
347
 * g_object_add_weak_pointer().
382
348
 * Note that if we don't find the inner widgets (which shouldn't happen), we
383
349
 * fallback to use generic "non-inner" widgets, and they don't need that kind
384
 
 * of weak pointer since they are explicit children of gProtoWindow and as
 
350
 * of weak pointer since they are explicit children of gParts->protoWindow and as
385
351
 * such GTK holds a strong reference to them. */
386
352
static void
387
353
moz_gtk_get_combo_box_entry_inner_widgets(GtkWidget *widget,
388
354
                                          gpointer client_data)
389
355
{
390
356
    if (GTK_IS_TOGGLE_BUTTON(widget)) {
391
 
        gComboBoxEntryButtonWidget = widget;
 
357
        gParts->comboBoxEntryButtonWidget = widget;
392
358
        g_object_add_weak_pointer(G_OBJECT(widget),
393
 
                                  (gpointer) &gComboBoxEntryButtonWidget);
 
359
                                  (gpointer) &gParts->comboBoxEntryButtonWidget);
394
360
    } else if (GTK_IS_ENTRY(widget)) {
395
 
        gComboBoxEntryTextareaWidget = widget;
 
361
        gParts->comboBoxEntryTextareaWidget = widget;
396
362
        g_object_add_weak_pointer(G_OBJECT(widget),
397
 
                                  (gpointer) &gComboBoxEntryTextareaWidget);
 
363
                                  (gpointer) &gParts->comboBoxEntryTextareaWidget);
398
364
    } else
399
365
        return;
400
366
    gtk_widget_realize(widget);
405
371
moz_gtk_get_combo_box_entry_arrow(GtkWidget *widget, gpointer client_data)
406
372
{
407
373
    if (GTK_IS_ARROW(widget)) {
408
 
        gComboBoxEntryArrowWidget = widget;
 
374
        gParts->comboBoxEntryArrowWidget = widget;
409
375
        g_object_add_weak_pointer(G_OBJECT(widget),
410
 
                                  (gpointer) &gComboBoxEntryArrowWidget);
 
376
                                  (gpointer) &gParts->comboBoxEntryArrowWidget);
411
377
        gtk_widget_realize(widget);
412
378
        g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
413
379
    }
418
384
{
419
385
    GtkWidget* buttonChild;
420
386
 
421
 
    if (gComboBoxEntryTextareaWidget &&
422
 
            gComboBoxEntryButtonWidget &&
423
 
            gComboBoxEntryArrowWidget)
 
387
    if (gParts->comboBoxEntryTextareaWidget &&
 
388
            gParts->comboBoxEntryButtonWidget &&
 
389
            gParts->comboBoxEntryArrowWidget)
424
390
        return MOZ_GTK_SUCCESS;
425
391
 
426
392
    /* Create a ComboBoxEntry if needed */
427
 
    if (!gComboBoxEntryWidget) {
428
 
        gComboBoxEntryWidget = gtk_combo_box_entry_new();
429
 
        setup_widget_prototype(gComboBoxEntryWidget);
 
393
    if (!gParts->comboBoxEntryWidget) {
 
394
        gParts->comboBoxEntryWidget = gtk_combo_box_entry_new();
 
395
        setup_widget_prototype(gParts->comboBoxEntryWidget);
430
396
    }
431
397
 
432
398
    /* Get its inner Entry and Button */
433
 
    gtk_container_forall(GTK_CONTAINER(gComboBoxEntryWidget),
 
399
    gtk_container_forall(GTK_CONTAINER(gParts->comboBoxEntryWidget),
434
400
                         moz_gtk_get_combo_box_entry_inner_widgets,
435
401
                         NULL);
436
402
 
437
 
    if (!gComboBoxEntryTextareaWidget) {
 
403
    if (!gParts->comboBoxEntryTextareaWidget) {
438
404
        ensure_entry_widget();
439
 
        gComboBoxEntryTextareaWidget = gEntryWidget;
 
405
        gParts->comboBoxEntryTextareaWidget = gParts->entryWidget;
440
406
    }
441
407
 
442
 
    if (gComboBoxEntryButtonWidget) {
 
408
    if (gParts->comboBoxEntryButtonWidget) {
443
409
        /* Get the Arrow inside the Button */
444
 
        buttonChild = GTK_BIN(gComboBoxEntryButtonWidget)->child;
 
410
        buttonChild = GTK_BIN(gParts->comboBoxEntryButtonWidget)->child;
445
411
        if (GTK_IS_HBOX(buttonChild)) {
446
412
            /* appears-as-list = FALSE, cell-view = TRUE; the button
447
413
             * contains an hbox. This hbox is there because ComboBoxEntry
456
422
        } else if(GTK_IS_ARROW(buttonChild)) {
457
423
            /* appears-as-list = TRUE, or cell-view = FALSE;
458
424
             * the button only contains an arrow */
459
 
            gComboBoxEntryArrowWidget = buttonChild;
 
425
            gParts->comboBoxEntryArrowWidget = buttonChild;
460
426
            g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
461
 
                                      &gComboBoxEntryArrowWidget);
462
 
            gtk_widget_realize(gComboBoxEntryArrowWidget);
463
 
            g_object_set_data(G_OBJECT(gComboBoxEntryArrowWidget),
 
427
                                      &gParts->comboBoxEntryArrowWidget);
 
428
            gtk_widget_realize(gParts->comboBoxEntryArrowWidget);
 
429
            g_object_set_data(G_OBJECT(gParts->comboBoxEntryArrowWidget),
464
430
                              "transparent-bg-hint", GINT_TO_POINTER(TRUE));
465
431
        }
466
432
    } else {
468
434
         * we use a generic toggle button as last resort fallback to avoid
469
435
         * crashing. */
470
436
        ensure_toggle_button_widget();
471
 
        gComboBoxEntryButtonWidget = gToggleButtonWidget;
 
437
        gParts->comboBoxEntryButtonWidget = gParts->toggleButtonWidget;
472
438
    }
473
439
 
474
 
    if (!gComboBoxEntryArrowWidget) {
 
440
    if (!gParts->comboBoxEntryArrowWidget) {
475
441
        /* Shouldn't be reached with current internal gtk implementation;
476
 
         * we gButtonArrowWidget as last resort fallback to avoid
 
442
         * we gParts->buttonArrowWidget as last resort fallback to avoid
477
443
         * crashing. */
478
444
        ensure_button_arrow_widget();
479
 
        gComboBoxEntryArrowWidget = gButtonArrowWidget;
 
445
        gParts->comboBoxEntryArrowWidget = gParts->buttonArrowWidget;
480
446
    }
481
447
 
482
448
    return MOZ_GTK_SUCCESS;
486
452
static gint
487
453
ensure_handlebox_widget()
488
454
{
489
 
    if (!gHandleBoxWidget) {
490
 
        gHandleBoxWidget = gtk_handle_box_new();
491
 
        setup_widget_prototype(gHandleBoxWidget);
 
455
    if (!gParts->handleBoxWidget) {
 
456
        gParts->handleBoxWidget = gtk_handle_box_new();
 
457
        setup_widget_prototype(gParts->handleBoxWidget);
492
458
    }
493
459
    return MOZ_GTK_SUCCESS;
494
460
}
496
462
static gint
497
463
ensure_toolbar_widget()
498
464
{
499
 
    if (!gToolbarWidget) {
 
465
    if (!gParts->toolbarWidget) {
500
466
        ensure_handlebox_widget();
501
 
        gToolbarWidget = gtk_toolbar_new();
502
 
        gtk_container_add(GTK_CONTAINER(gHandleBoxWidget), gToolbarWidget);
503
 
        gtk_widget_realize(gToolbarWidget);
504
 
        g_object_set_data(G_OBJECT(gToolbarWidget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
 
467
        gParts->toolbarWidget = gtk_toolbar_new();
 
468
        gtk_container_add(GTK_CONTAINER(gParts->handleBoxWidget), gParts->toolbarWidget);
 
469
        gtk_widget_realize(gParts->toolbarWidget);
 
470
        g_object_set_data(G_OBJECT(gParts->toolbarWidget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
505
471
    }
506
472
    return MOZ_GTK_SUCCESS;
507
473
}
509
475
static gint
510
476
ensure_toolbar_separator_widget()
511
477
{
512
 
    if (!gToolbarSeparatorWidget) {
 
478
    if (!gParts->toolbarSeparatorWidget) {
513
479
        ensure_toolbar_widget();
514
 
        gToolbarSeparatorWidget = GTK_WIDGET(gtk_separator_tool_item_new());
515
 
        setup_widget_prototype(gToolbarSeparatorWidget);
 
480
        gParts->toolbarSeparatorWidget = GTK_WIDGET(gtk_separator_tool_item_new());
 
481
        setup_widget_prototype(gParts->toolbarSeparatorWidget);
516
482
    }
517
483
    return MOZ_GTK_SUCCESS;
518
484
}
520
486
static gint
521
487
ensure_tooltip_widget()
522
488
{
523
 
    if (!gTooltipWidget) {
524
 
        gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
525
 
        gtk_widget_realize(gTooltipWidget);
526
 
        moz_gtk_set_widget_name(gTooltipWidget);
 
489
    if (!gParts->tooltipWidget) {
 
490
        gParts->tooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
 
491
        gtk_widget_realize(gParts->tooltipWidget);
 
492
        moz_gtk_set_widget_name(gParts->tooltipWidget);
527
493
    }
528
494
    return MOZ_GTK_SUCCESS;
529
495
}
531
497
static gint
532
498
ensure_tab_widget()
533
499
{
534
 
    if (!gTabWidget) {
535
 
        gTabWidget = gtk_notebook_new();
536
 
        setup_widget_prototype(gTabWidget);
 
500
    if (!gParts->tabWidget) {
 
501
        gParts->tabWidget = gtk_notebook_new();
 
502
        setup_widget_prototype(gParts->tabWidget);
537
503
    }
538
504
    return MOZ_GTK_SUCCESS;
539
505
}
541
507
static gint
542
508
ensure_progress_widget()
543
509
{
544
 
    if (!gProgressWidget) {
545
 
        gProgressWidget = gtk_progress_bar_new();
546
 
        setup_widget_prototype(gProgressWidget);
 
510
    if (!gParts->progresWidget) {
 
511
        gParts->progresWidget = gtk_progress_bar_new();
 
512
        setup_widget_prototype(gParts->progresWidget);
547
513
    }
548
514
    return MOZ_GTK_SUCCESS;
549
515
}
551
517
static gint
552
518
ensure_statusbar_widget()
553
519
{
554
 
    if (!gStatusbarWidget) {
555
 
      gStatusbarWidget = gtk_statusbar_new();
556
 
      setup_widget_prototype(gStatusbarWidget);
 
520
    if (!gParts->statusbarWidget) {
 
521
      gParts->statusbarWidget = gtk_statusbar_new();
 
522
      setup_widget_prototype(gParts->statusbarWidget);
557
523
    }
558
524
    return MOZ_GTK_SUCCESS;
559
525
}
561
527
static gint
562
528
ensure_frame_widget()
563
529
{
564
 
    if (!gFrameWidget) {
 
530
    if (!gParts->frameWidget) {
565
531
        ensure_statusbar_widget();
566
 
        gFrameWidget = gtk_frame_new(NULL);
567
 
        gtk_container_add(GTK_CONTAINER(gStatusbarWidget), gFrameWidget);
568
 
        gtk_widget_realize(gFrameWidget);
 
532
        gParts->frameWidget = gtk_frame_new(NULL);
 
533
        gtk_container_add(GTK_CONTAINER(gParts->statusbarWidget), gParts->frameWidget);
 
534
        gtk_widget_realize(gParts->frameWidget);
569
535
    }
570
536
    return MOZ_GTK_SUCCESS;
571
537
}
573
539
static gint
574
540
ensure_menu_bar_widget()
575
541
{
576
 
    if (!gMenuBarWidget) {
577
 
        gMenuBarWidget = gtk_menu_bar_new();
578
 
        setup_widget_prototype(gMenuBarWidget);
 
542
    if (!gParts->menuBarWidget) {
 
543
        gParts->menuBarWidget = gtk_menu_bar_new();
 
544
        setup_widget_prototype(gParts->menuBarWidget);
579
545
    }
580
546
    return MOZ_GTK_SUCCESS;
581
547
}
583
549
static gint
584
550
ensure_menu_bar_item_widget()
585
551
{
586
 
    if (!gMenuBarItemWidget) {
 
552
    if (!gParts->menuBarItemWidget) {
587
553
        ensure_menu_bar_widget();
588
 
        gMenuBarItemWidget = gtk_menu_item_new();
589
 
        gtk_menu_shell_append(GTK_MENU_SHELL(gMenuBarWidget),
590
 
                              gMenuBarItemWidget);
591
 
        gtk_widget_realize(gMenuBarItemWidget);
592
 
        g_object_set_data(G_OBJECT(gMenuBarItemWidget),
 
554
        gParts->menuBarItemWidget = gtk_menu_item_new();
 
555
        gtk_menu_shell_append(GTK_MENU_SHELL(gParts->menuBarWidget),
 
556
                              gParts->menuBarItemWidget);
 
557
        gtk_widget_realize(gParts->menuBarItemWidget);
 
558
        g_object_set_data(G_OBJECT(gParts->menuBarItemWidget),
593
559
                          "transparent-bg-hint", GINT_TO_POINTER(TRUE));
594
560
    }
595
561
    return MOZ_GTK_SUCCESS;
598
564
static gint
599
565
ensure_menu_popup_widget()
600
566
{
601
 
    if (!gMenuPopupWidget) {
 
567
    if (!gParts->menuPopupWidget) {
602
568
        ensure_menu_bar_item_widget();
603
 
        gMenuPopupWidget = gtk_menu_new();
604
 
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(gMenuBarItemWidget),
605
 
                                  gMenuPopupWidget);
606
 
        gtk_widget_realize(gMenuPopupWidget);
607
 
        g_object_set_data(G_OBJECT(gMenuPopupWidget),
 
569
        gParts->menuPopupWidget = gtk_menu_new();
 
570
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(gParts->menuBarItemWidget),
 
571
                                  gParts->menuPopupWidget);
 
572
        gtk_widget_realize(gParts->menuPopupWidget);
 
573
        g_object_set_data(G_OBJECT(gParts->menuPopupWidget),
608
574
                          "transparent-bg-hint", GINT_TO_POINTER(TRUE));
609
575
    }
610
576
    return MOZ_GTK_SUCCESS;
613
579
static gint
614
580
ensure_menu_item_widget()
615
581
{
616
 
    if (!gMenuItemWidget) {
 
582
    if (!gParts->menuItemWidget) {
617
583
        ensure_menu_popup_widget();
618
 
        gMenuItemWidget = gtk_menu_item_new_with_label("M");
619
 
        gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
620
 
                              gMenuItemWidget);
621
 
        gtk_widget_realize(gMenuItemWidget);
622
 
        g_object_set_data(G_OBJECT(gMenuItemWidget),
 
584
        gParts->menuItemWidget = gtk_menu_item_new_with_label("M");
 
585
        gtk_menu_shell_append(GTK_MENU_SHELL(gParts->menuPopupWidget),
 
586
                              gParts->menuItemWidget);
 
587
        gtk_widget_realize(gParts->menuItemWidget);
 
588
        g_object_set_data(G_OBJECT(gParts->menuItemWidget),
623
589
                          "transparent-bg-hint", GINT_TO_POINTER(TRUE));
624
590
    }
625
591
    return MOZ_GTK_SUCCESS;
628
594
static gint
629
595
ensure_image_menu_item_widget()
630
596
{
631
 
    if (!gImageMenuItemWidget) {
 
597
    if (!gParts->imageMenuItemWidget) {
632
598
        ensure_menu_popup_widget();
633
 
        gImageMenuItemWidget = gtk_image_menu_item_new();
634
 
        gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
635
 
                              gImageMenuItemWidget);
636
 
        gtk_widget_realize(gImageMenuItemWidget);
637
 
        g_object_set_data(G_OBJECT(gImageMenuItemWidget),
 
599
        gParts->imageMenuItemWidget = gtk_image_menu_item_new();
 
600
        gtk_menu_shell_append(GTK_MENU_SHELL(gParts->menuPopupWidget),
 
601
                              gParts->imageMenuItemWidget);
 
602
        gtk_widget_realize(gParts->imageMenuItemWidget);
 
603
        g_object_set_data(G_OBJECT(gParts->imageMenuItemWidget),
638
604
                          "transparent-bg-hint", GINT_TO_POINTER(TRUE));
639
605
    }
640
606
    return MOZ_GTK_SUCCESS;
643
609
static gint
644
610
ensure_menu_separator_widget()
645
611
{
646
 
    if (!gMenuSeparatorWidget) {
 
612
    if (!gParts->menuSeparatorWidget) {
647
613
        ensure_menu_popup_widget();
648
 
        gMenuSeparatorWidget = gtk_separator_menu_item_new();
649
 
        gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
650
 
                              gMenuSeparatorWidget);
651
 
        gtk_widget_realize(gMenuSeparatorWidget);
652
 
        g_object_set_data(G_OBJECT(gMenuSeparatorWidget),
 
614
        gParts->menuSeparatorWidget = gtk_separator_menu_item_new();
 
615
        gtk_menu_shell_append(GTK_MENU_SHELL(gParts->menuPopupWidget),
 
616
                              gParts->menuSeparatorWidget);
 
617
        gtk_widget_realize(gParts->menuSeparatorWidget);
 
618
        g_object_set_data(G_OBJECT(gParts->menuSeparatorWidget),
653
619
                          "transparent-bg-hint", GINT_TO_POINTER(TRUE));
654
620
    }
655
621
    return MOZ_GTK_SUCCESS;
658
624
static gint
659
625
ensure_check_menu_item_widget()
660
626
{
661
 
    if (!gCheckMenuItemWidget) {
 
627
    if (!gParts->checkMenuItemWidget) {
662
628
        ensure_menu_popup_widget();
663
 
        gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
664
 
        gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
665
 
                              gCheckMenuItemWidget);
666
 
        gtk_widget_realize(gCheckMenuItemWidget);
667
 
        g_object_set_data(G_OBJECT(gCheckMenuItemWidget),
 
629
        gParts->checkMenuItemWidget = gtk_check_menu_item_new_with_label("M");
 
630
        gtk_menu_shell_append(GTK_MENU_SHELL(gParts->menuPopupWidget),
 
631
                              gParts->checkMenuItemWidget);
 
632
        gtk_widget_realize(gParts->checkMenuItemWidget);
 
633
        g_object_set_data(G_OBJECT(gParts->checkMenuItemWidget),
668
634
                          "transparent-bg-hint", GINT_TO_POINTER(TRUE));
669
635
    }
670
636
    return MOZ_GTK_SUCCESS;
673
639
static gint
674
640
ensure_tree_view_widget()
675
641
{
676
 
    if (!gTreeViewWidget) {
677
 
        gTreeViewWidget = gtk_tree_view_new();
678
 
        setup_widget_prototype(gTreeViewWidget);
 
642
    if (!gParts->treeViewWidget) {
 
643
        gParts->treeViewWidget = gtk_tree_view_new();
 
644
        setup_widget_prototype(gParts->treeViewWidget);
679
645
    }
680
646
    return MOZ_GTK_SUCCESS;
681
647
}
683
649
static gint
684
650
ensure_tree_header_cell_widget()
685
651
{
686
 
    if(!gTreeHeaderCellWidget) {
 
652
    if(!gParts->treeHeaderCellWidget) {
687
653
        /*
688
654
         * Some GTK engines paint the first and last cell
689
655
         * of a TreeView header with a highlight.
705
671
        /* Create and append our three columns */
706
672
        firstTreeViewColumn = gtk_tree_view_column_new();
707
673
        gtk_tree_view_column_set_title(firstTreeViewColumn, "M");
708
 
        gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), firstTreeViewColumn);
 
674
        gtk_tree_view_append_column(GTK_TREE_VIEW(gParts->treeViewWidget), firstTreeViewColumn);
709
675
 
710
 
        gMiddleTreeViewColumn = gtk_tree_view_column_new();
711
 
        gtk_tree_view_column_set_title(gMiddleTreeViewColumn, "M");
712
 
        gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget),
713
 
                                    gMiddleTreeViewColumn);
 
676
        gParts->middleTreeViewColumn = gtk_tree_view_column_new();
 
677
        gtk_tree_view_column_set_title(gParts->middleTreeViewColumn, "M");
 
678
        gtk_tree_view_append_column(GTK_TREE_VIEW(gParts->treeViewWidget),
 
679
                                    gParts->middleTreeViewColumn);
714
680
 
715
681
        lastTreeViewColumn = gtk_tree_view_column_new();
716
682
        gtk_tree_view_column_set_title(lastTreeViewColumn, "M");
717
 
        gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), lastTreeViewColumn);
 
683
        gtk_tree_view_append_column(GTK_TREE_VIEW(gParts->treeViewWidget), lastTreeViewColumn);
718
684
 
719
685
        /* Use the middle column's header for our button */
720
 
        gTreeHeaderCellWidget = gMiddleTreeViewColumn->button;
721
 
        gTreeHeaderSortArrowWidget = gMiddleTreeViewColumn->arrow;
722
 
        g_object_set_data(G_OBJECT(gTreeHeaderCellWidget),
 
686
        gParts->treeHeaderCellWidget = gParts->middleTreeViewColumn->button;
 
687
        gParts->treeHeaderSortArrowWidget = gParts->middleTreeViewColumn->arrow;
 
688
        g_object_set_data(G_OBJECT(gParts->treeHeaderCellWidget),
723
689
                          "transparent-bg-hint", GINT_TO_POINTER(TRUE));
724
 
        g_object_set_data(G_OBJECT(gTreeHeaderSortArrowWidget),
 
690
        g_object_set_data(G_OBJECT(gParts->treeHeaderSortArrowWidget),
725
691
                          "transparent-bg-hint", GINT_TO_POINTER(TRUE));
726
692
    }
727
693
    return MOZ_GTK_SUCCESS;
730
696
static gint
731
697
ensure_expander_widget()
732
698
{
733
 
    if (!gExpanderWidget) {
734
 
        gExpanderWidget = gtk_expander_new("M");
735
 
        setup_widget_prototype(gExpanderWidget);
 
699
    if (!gParts->expanderWidget) {
 
700
        gParts->expanderWidget = gtk_expander_new("M");
 
701
        setup_widget_prototype(gParts->expanderWidget);
736
702
    }
737
703
    return MOZ_GTK_SUCCESS;
738
704
}
740
706
static gint
741
707
ensure_scrolled_window_widget()
742
708
{
743
 
    if (!gScrolledWindowWidget) {
744
 
        gScrolledWindowWidget = gtk_scrolled_window_new(NULL, NULL);
745
 
        setup_widget_prototype(gScrolledWindowWidget);
 
709
    if (!gParts->scrolledWindowWidget) {
 
710
        gParts->scrolledWindowWidget = gtk_scrolled_window_new(NULL, NULL);
 
711
        setup_widget_prototype(gParts->scrolledWindowWidget);
746
712
    }
747
713
    return MOZ_GTK_SUCCESS;
748
714
}
897
863
{
898
864
    ensure_checkbox_widget();
899
865
 
900
 
    gtk_widget_style_get (gCheckboxWidget,
 
866
    gtk_widget_style_get (gParts->checkboxWidget,
901
867
                          "indicator_size", indicator_size,
902
868
                          "indicator_spacing", indicator_spacing,
903
869
                          NULL);
910
876
{
911
877
    ensure_radiobutton_widget();
912
878
 
913
 
    gtk_widget_style_get (gRadiobuttonWidget,
 
879
    gtk_widget_style_get (gParts->radiobuttonWidget,
914
880
                          "indicator_size", indicator_size,
915
881
                          "indicator_spacing", indicator_spacing,
916
882
                          NULL);
936
902
{
937
903
    if (orientation == GTK_ORIENTATION_HORIZONTAL) {
938
904
        ensure_hpaned_widget();
939
 
        gtk_widget_style_get(gHPanedWidget, "handle_size", size, NULL);
 
905
        gtk_widget_style_get(gParts->hpanedWidget, "handle_size", size, NULL);
940
906
    } else {
941
907
        ensure_vpaned_widget();
942
 
        gtk_widget_style_get(gVPanedWidget, "handle_size", size, NULL);
 
908
        gtk_widget_style_get(gParts->vpanedWidget, "handle_size", size, NULL);
943
909
    }
944
910
    return MOZ_GTK_SUCCESS;
945
911
}
978
944
 
979
945
    if (isradio) {
980
946
        moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
981
 
        w = gRadiobuttonWidget;
 
947
        w = gParts->radiobuttonWidget;
982
948
    } else {
983
949
        moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
984
 
        w = gCheckboxWidget;
 
950
        w = gParts->checkboxWidget;
985
951
    }
986
952
 
987
953
    // "GetMinimumWidgetSize was ignored"
1013
979
      
1014
980
    if (isradio) {
1015
981
        gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
1016
 
                         gRadiobuttonWidget, "radiobutton", x, y,
 
982
                         gParts->radiobuttonWidget, "radiobutton", x, y,
1017
983
                         width, height);
1018
984
        if (state->focused) {
1019
985
            gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
1020
 
                            gRadiobuttonWidget, "radiobutton", focus_x, focus_y,
 
986
                            gParts->radiobuttonWidget, "radiobutton", focus_x, focus_y,
1021
987
                            focus_width, focus_height);
1022
988
        }
1023
989
    }
1027
993
        * must also be changed for the state to be drawn.
1028
994
        */
1029
995
        if (inconsistent) {
1030
 
            gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), TRUE);
 
996
            gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gParts->checkboxWidget), TRUE);
1031
997
            shadow_type = GTK_SHADOW_ETCHED_IN;
1032
998
        } else {
1033
 
            gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), FALSE);
 
999
            gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gParts->checkboxWidget), FALSE);
1034
1000
        }
1035
1001
 
1036
1002
        gtk_paint_check(style, drawable, state_type, shadow_type, cliprect, 
1037
 
                        gCheckboxWidget, "checkbutton", x, y, width, height);
 
1003
                        gParts->checkboxWidget, "checkbutton", x, y, width, height);
1038
1004
        if (state->focused) {
1039
1005
            gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
1040
 
                            gCheckboxWidget, "checkbutton", focus_x, focus_y,
 
1006
                            gParts->checkboxWidget, "checkbutton", focus_x, focus_y,
1041
1007
                            focus_width, focus_height);
1042
1008
        }
1043
1009
    }
1129
1095
    ensure_scrollbar_widget();
1130
1096
 
1131
1097
    if (flags & MOZ_GTK_STEPPER_VERTICAL)
1132
 
        scrollbar = gVertScrollbarWidget;
 
1098
        scrollbar = gParts->vertScrollbarWidget;
1133
1099
    else
1134
 
        scrollbar = gHorizScrollbarWidget;
 
1100
        scrollbar = gParts->horizScrollbarWidget;
1135
1101
 
1136
1102
    gtk_widget_set_direction(scrollbar, direction);
1137
1103
 
1215
1181
    ensure_scrollbar_widget();
1216
1182
 
1217
1183
    if (widget ==  MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL)
1218
 
        scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
 
1184
        scrollbar = GTK_SCROLLBAR(gParts->horizScrollbarWidget);
1219
1185
    else
1220
 
        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
 
1186
        scrollbar = GTK_SCROLLBAR(gParts->vertScrollbarWidget);
1221
1187
 
1222
1188
    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
1223
1189
 
1258
1224
    ensure_scrollbar_widget();
1259
1225
 
1260
1226
    if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL)
1261
 
        scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
 
1227
        scrollbar = GTK_SCROLLBAR(gParts->horizScrollbarWidget);
1262
1228
    else
1263
 
        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
 
1229
        scrollbar = GTK_SCROLLBAR(gParts->vertScrollbarWidget);
1264
1230
 
1265
1231
    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
1266
1232
 
1321
1287
    GtkStyle* style;
1322
1288
 
1323
1289
    ensure_spin_widget();
1324
 
    gtk_widget_set_direction(gSpinWidget, direction);
1325
 
    style = gSpinWidget->style;
 
1290
    gtk_widget_set_direction(gParts->spinWidget, direction);
 
1291
    style = gParts->spinWidget->style;
1326
1292
 
1327
1293
    TSOffsetStyleGCs(style, rect->x, rect->y);
1328
1294
    gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL,
1329
 
                  gSpinWidget, "spinbutton",
 
1295
                  gParts->spinWidget, "spinbutton",
1330
1296
                  rect->x, rect->y, rect->width, rect->height);
1331
1297
    return MOZ_GTK_SUCCESS;
1332
1298
}
1343
1309
    GtkStyle* style;
1344
1310
 
1345
1311
    ensure_spin_widget();
1346
 
    style = gSpinWidget->style;
1347
 
    gtk_widget_set_direction(gSpinWidget, direction);
 
1312
    style = gParts->spinWidget->style;
 
1313
    gtk_widget_set_direction(gParts->spinWidget, direction);
1348
1314
 
1349
1315
    TSOffsetStyleGCs(style, rect->x, rect->y);
1350
 
    gtk_paint_box(style, drawable, state_type, shadow_type, NULL, gSpinWidget,
 
1316
    gtk_paint_box(style, drawable, state_type, shadow_type, NULL, gParts->spinWidget,
1351
1317
                  isDown ? "spinbutton_down" : "spinbutton_up",
1352
1318
                  rect->x, rect->y, rect->width, rect->height);
1353
1319
 
1359
1325
    arrow_rect.y += isDown ? -1 : 1;
1360
1326
 
1361
1327
    gtk_paint_arrow(style, drawable, state_type, shadow_type, NULL,
1362
 
                    gSpinWidget, "spinbutton",
 
1328
                    gParts->spinWidget, "spinbutton",
1363
1329
                    isDown ? GTK_ARROW_DOWN : GTK_ARROW_UP, TRUE,
1364
1330
                    arrow_rect.x, arrow_rect.y,
1365
1331
                    arrow_rect.width, arrow_rect.height);
1378
1344
  GtkWidget* widget;
1379
1345
 
1380
1346
  ensure_scale_widget();
1381
 
  widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
 
1347
  widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
1382
1348
  gtk_widget_set_direction(widget, direction);
1383
1349
 
1384
1350
  style = widget->style;
1419
1385
  gint thumb_width, thumb_height, x, y;
1420
1386
 
1421
1387
  ensure_scale_widget();
1422
 
  widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
 
1388
  widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
1423
1389
  gtk_widget_set_direction(widget, direction);
1424
1390
 
1425
1391
  style = widget->style;
1454
1420
    GtkStyle* style;
1455
1421
 
1456
1422
    ensure_handlebox_widget();
1457
 
    gtk_widget_set_direction(gHandleBoxWidget, direction);
 
1423
    gtk_widget_set_direction(gParts->handleBoxWidget, direction);
1458
1424
 
1459
 
    style = gHandleBoxWidget->style;
1460
 
    shadow_type = GTK_HANDLE_BOX(gHandleBoxWidget)->shadow_type;
 
1425
    style = gParts->handleBoxWidget->style;
 
1426
    shadow_type = GTK_HANDLE_BOX(gParts->handleBoxWidget)->shadow_type;
1461
1427
 
1462
1428
    TSOffsetStyleGCs(style, rect->x, rect->y);
1463
1429
    gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
1464
 
                  gHandleBoxWidget, "handlebox_bin", rect->x, rect->y,
 
1430
                  gParts->handleBoxWidget, "handlebox_bin", rect->x, rect->y,
1465
1431
                  rect->width, rect->height);
1466
1432
 
1467
1433
    return MOZ_GTK_SUCCESS;
1474
1440
    GtkStateType hpaned_state = ConvertGtkState(state);
1475
1441
 
1476
1442
    ensure_hpaned_widget();
1477
 
    gtk_paint_handle(gHPanedWidget->style, drawable, hpaned_state,
1478
 
                     GTK_SHADOW_NONE, cliprect, gHPanedWidget, "paned",
 
1443
    gtk_paint_handle(gParts->hpanedWidget->style, drawable, hpaned_state,
 
1444
                     GTK_SHADOW_NONE, cliprect, gParts->hpanedWidget, "paned",
1479
1445
                     rect->x, rect->y, rect->width, rect->height,
1480
1446
                     GTK_ORIENTATION_VERTICAL);
1481
1447
 
1489
1455
    GtkStateType vpaned_state = ConvertGtkState(state);
1490
1456
 
1491
1457
    ensure_vpaned_widget();
1492
 
    gtk_paint_handle(gVPanedWidget->style, drawable, vpaned_state,
1493
 
                     GTK_SHADOW_NONE, cliprect, gVPanedWidget, "paned",
 
1458
    gtk_paint_handle(gParts->vpanedWidget->style, drawable, vpaned_state,
 
1459
                     GTK_SHADOW_NONE, cliprect, gParts->vpanedWidget, "paned",
1494
1460
                     rect->x, rect->y, rect->width, rect->height,
1495
1461
                     GTK_ORIENTATION_HORIZONTAL);
1496
1462
 
1508
1474
    }
1509
1475
 
1510
1476
    ensure_entry_widget();
1511
 
    gtk_draw_insertion_cursor(gEntryWidget, drawable, cliprect,
 
1477
    gtk_draw_insertion_cursor(gParts->entryWidget, drawable, cliprect,
1512
1478
                              &location, TRUE, direction, FALSE);
1513
1479
 
1514
1480
    return MOZ_GTK_SUCCESS;
1628
1594
    ensure_tree_view_widget();
1629
1595
    ensure_scrolled_window_widget();
1630
1596
 
1631
 
    gtk_widget_set_direction(gTreeViewWidget, direction);
1632
 
    gtk_widget_set_direction(gScrolledWindowWidget, direction);
 
1597
    gtk_widget_set_direction(gParts->treeViewWidget, direction);
 
1598
    gtk_widget_set_direction(gParts->scrolledWindowWidget, direction);
1633
1599
 
1634
1600
    /* only handle disabled and normal states, otherwise the whole background
1635
1601
     * area will be painted differently with other states */
1638
1604
    /* In GTK the treeview sets the background of the window
1639
1605
     * which contains the cells to the treeview base color.
1640
1606
     * If we don't set it here the background color will not be correct.*/
1641
 
    gtk_widget_modify_bg(gTreeViewWidget, state_type,
1642
 
                         &gTreeViewWidget->style->base[state_type]);
 
1607
    gtk_widget_modify_bg(gParts->treeViewWidget, state_type,
 
1608
                         &gParts->treeViewWidget->style->base[state_type]);
1643
1609
 
1644
 
    style = gScrolledWindowWidget->style;
 
1610
    style = gParts->scrolledWindowWidget->style;
1645
1611
    xthickness = XTHICKNESS(style);
1646
1612
    ythickness = YTHICKNESS(style);
1647
1613
 
1648
 
    TSOffsetStyleGCs(gTreeViewWidget->style, rect->x, rect->y);
 
1614
    TSOffsetStyleGCs(gParts->treeViewWidget->style, rect->x, rect->y);
1649
1615
    TSOffsetStyleGCs(style, rect->x, rect->y);
1650
1616
 
1651
 
    gtk_paint_flat_box(gTreeViewWidget->style, drawable, state_type,
1652
 
                       GTK_SHADOW_NONE, cliprect, gTreeViewWidget, "treeview",
 
1617
    gtk_paint_flat_box(gParts->treeViewWidget->style, drawable, state_type,
 
1618
                       GTK_SHADOW_NONE, cliprect, gParts->treeViewWidget, "treeview",
1653
1619
                       rect->x + xthickness, rect->y + ythickness,
1654
1620
                       rect->width - 2 * xthickness,
1655
1621
                       rect->height - 2 * ythickness);
1656
1622
 
1657
1623
    gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
1658
 
                     cliprect, gScrolledWindowWidget, "scrolled_window",
 
1624
                     cliprect, gParts->scrolledWindowWidget, "scrolled_window",
1659
1625
                     rect->x, rect->y, rect->width, rect->height); 
1660
1626
 
1661
1627
    return MOZ_GTK_SUCCESS;
1666
1632
                               GdkRectangle* cliprect, GtkWidgetState* state,
1667
1633
                               gboolean isSorted, GtkTextDirection direction)
1668
1634
{
1669
 
    gtk_tree_view_column_set_sort_indicator(gMiddleTreeViewColumn,
 
1635
    gtk_tree_view_column_set_sort_indicator(gParts->middleTreeViewColumn,
1670
1636
                                            isSorted);
1671
1637
 
1672
1638
    moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
1673
 
                         gTreeHeaderCellWidget, direction);
 
1639
                         gParts->treeHeaderCellWidget, direction);
1674
1640
    return MOZ_GTK_SUCCESS;
1675
1641
}
1676
1642
 
1687
1653
    GtkStyle* style;
1688
1654
 
1689
1655
    ensure_tree_header_cell_widget();
1690
 
    gtk_widget_set_direction(gTreeHeaderSortArrowWidget, direction);
 
1656
    gtk_widget_set_direction(gParts->treeHeaderSortArrowWidget, direction);
1691
1657
 
1692
1658
    /* hard code these values */
1693
1659
    arrow_rect.width = 11;
1695
1661
    arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
1696
1662
    arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
1697
1663
 
1698
 
    style = gTreeHeaderSortArrowWidget->style;
 
1664
    style = gParts->treeHeaderSortArrowWidget->style;
1699
1665
    TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
1700
1666
 
1701
1667
    gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
1702
 
                    gTreeHeaderSortArrowWidget, "arrow",  arrow_type, TRUE,
 
1668
                    gParts->treeHeaderSortArrowWidget, "arrow",  arrow_type, TRUE,
1703
1669
                    arrow_rect.x, arrow_rect.y,
1704
1670
                    arrow_rect.width, arrow_rect.height);
1705
1671
 
1716
1682
    GtkStateType state_type;
1717
1683
 
1718
1684
    ensure_tree_view_widget();
1719
 
    gtk_widget_set_direction(gTreeViewWidget, direction);
 
1685
    gtk_widget_set_direction(gParts->treeViewWidget, direction);
1720
1686
 
1721
 
    style = gTreeViewWidget->style;
 
1687
    style = gParts->treeViewWidget->style;
1722
1688
 
1723
1689
    /* Because the frame we get is of the entire treeview, we can't get the precise
1724
1690
     * event state of one expander, thus rendering hover and active feedback useless. */
1725
1691
    state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
1726
1692
 
1727
1693
    TSOffsetStyleGCs(style, rect->x, rect->y);
1728
 
    gtk_paint_expander(style, drawable, state_type, cliprect, gTreeViewWidget, "treeview",
 
1694
    gtk_paint_expander(style, drawable, state_type, cliprect, gParts->treeViewWidget, "treeview",
1729
1695
                       rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);
1730
1696
 
1731
1697
    return MOZ_GTK_SUCCESS;
1741
1707
    GtkStateType state_type = ConvertGtkState(state);
1742
1708
 
1743
1709
    ensure_expander_widget();
1744
 
    gtk_widget_set_direction(gExpanderWidget, direction);
 
1710
    gtk_widget_set_direction(gParts->expanderWidget, direction);
1745
1711
 
1746
 
    style = gExpanderWidget->style;
 
1712
    style = gParts->expanderWidget->style;
1747
1713
 
1748
1714
    TSOffsetStyleGCs(style, rect->x, rect->y);
1749
 
    gtk_paint_expander(style, drawable, state_type, cliprect, gExpanderWidget, "expander",
 
1715
    gtk_paint_expander(style, drawable, state_type, cliprect, gParts->expanderWidget, "expander",
1750
1716
                       rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);
1751
1717
 
1752
1718
    return MOZ_GTK_SUCCESS;
1758
1724
                        gboolean ishtml, GtkTextDirection direction)
1759
1725
{
1760
1726
    GdkRectangle arrow_rect, real_arrow_rect;
1761
 
    gint arrow_size, separator_width;
 
1727
    gint /* arrow_size, */ separator_width;
1762
1728
    gboolean wide_separators;
1763
1729
    GtkStateType state_type = ConvertGtkState(state);
1764
1730
    GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
1767
1733
 
1768
1734
    ensure_combo_box_widgets();
1769
1735
 
1770
 
    /* Also sets the direction on gComboBoxButtonWidget, which is then
 
1736
    /* Also sets the direction on gParts->comboBoxButtonWidget, which is then
1771
1737
     * inherited by the separator and arrow */
1772
1738
    moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
1773
 
                         gComboBoxButtonWidget, direction);
 
1739
                         gParts->comboBoxButtonWidget, direction);
1774
1740
 
1775
 
    calculate_button_inner_rect(gComboBoxButtonWidget,
 
1741
    calculate_button_inner_rect(gParts->comboBoxButtonWidget,
1776
1742
                                rect, &arrow_rect, direction, ishtml);
1777
1743
    /* Now arrow_rect contains the inner rect ; we want to correct the width
1778
1744
     * to what the arrow needs (see gtk_combo_box_size_allocate) */
1779
 
    gtk_widget_size_request(gComboBoxArrowWidget, &arrow_req);
 
1745
    gtk_widget_size_request(gParts->comboBoxArrowWidget, &arrow_req);
1780
1746
    if (direction == GTK_TEXT_DIR_LTR)
1781
1747
        arrow_rect.x += arrow_rect.width - arrow_req.width;
1782
1748
    arrow_rect.width = arrow_req.width;
1783
1749
 
1784
 
    calculate_arrow_rect(gComboBoxArrowWidget,
 
1750
    calculate_arrow_rect(gParts->comboBoxArrowWidget,
1785
1751
                         &arrow_rect, &real_arrow_rect, direction);
1786
1752
 
1787
 
    style = gComboBoxArrowWidget->style;
 
1753
    style = gParts->comboBoxArrowWidget->style;
1788
1754
    TSOffsetStyleGCs(style, rect->x, rect->y);
1789
1755
 
1790
 
    gtk_widget_size_allocate(gComboBoxWidget, rect);
 
1756
    gtk_widget_size_allocate(gParts->comboBoxWidget, rect);
1791
1757
 
1792
1758
    gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
1793
 
                    gComboBoxArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,
 
1759
                    gParts->comboBoxArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,
1794
1760
                    real_arrow_rect.x, real_arrow_rect.y,
1795
1761
                    real_arrow_rect.width, real_arrow_rect.height);
1796
1762
 
1797
1763
 
1798
1764
    /* If there is no separator in the theme, there's nothing left to do. */
1799
 
    if (!gComboBoxSeparatorWidget)
 
1765
    if (!gParts->comboBoxSeparatorWidget)
1800
1766
        return MOZ_GTK_SUCCESS;
1801
1767
 
1802
 
    style = gComboBoxSeparatorWidget->style;
 
1768
    style = gParts->comboBoxSeparatorWidget->style;
1803
1769
    TSOffsetStyleGCs(style, rect->x, rect->y);
1804
1770
 
1805
 
    gtk_widget_style_get(gComboBoxSeparatorWidget,
 
1771
    gtk_widget_style_get(gParts->comboBoxSeparatorWidget,
1806
1772
                         "wide-separators", &wide_separators,
1807
1773
                         "separator-width", &separator_width,
1808
1774
                         NULL);
1815
1781
 
1816
1782
        gtk_paint_box(style, drawable,
1817
1783
                      GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
1818
 
                      cliprect, gComboBoxSeparatorWidget, "vseparator",
 
1784
                      cliprect, gParts->comboBoxSeparatorWidget, "vseparator",
1819
1785
                      arrow_rect.x, arrow_rect.y,
1820
1786
                      separator_width, arrow_rect.height);
1821
1787
    } else {
1825
1791
            arrow_rect.x += arrow_rect.width;
1826
1792
 
1827
1793
        gtk_paint_vline(style, drawable, GTK_STATE_NORMAL, cliprect,
1828
 
                        gComboBoxSeparatorWidget, "vseparator",
 
1794
                        gParts->comboBoxSeparatorWidget, "vseparator",
1829
1795
                        arrow_rect.y, arrow_rect.y + arrow_rect.height,
1830
1796
                        arrow_rect.x);
1831
1797
    }
1843
1809
    GdkRectangle arrow_rect;
1844
1810
 
1845
1811
    ensure_button_arrow_widget();
1846
 
    style = gButtonArrowWidget->style;
 
1812
    style = gParts->buttonArrowWidget->style;
1847
1813
 
1848
 
    calculate_arrow_rect(gButtonArrowWidget, rect, &arrow_rect,
 
1814
    calculate_arrow_rect(gParts->buttonArrowWidget, rect, &arrow_rect,
1849
1815
                         GTK_TEXT_DIR_LTR);
1850
1816
 
1851
1817
    TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
1852
1818
    gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
1853
 
                    gButtonArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,
 
1819
                    gParts->buttonArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,
1854
1820
                    arrow_rect.x, arrow_rect.y, arrow_rect.width, arrow_rect.height);
1855
1821
 
1856
1822
    return MOZ_GTK_SUCCESS;
1874
1840
    if (input_focus) {
1875
1841
        /* Some themes draw a complementary focus ring for the dropdown button
1876
1842
         * when the dropdown entry has focus */
1877
 
        GTK_WIDGET_SET_FLAGS(gComboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
 
1843
        GTK_WIDGET_SET_FLAGS(gParts->comboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
1878
1844
    }
1879
1845
 
1880
1846
    moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
1881
 
                         gComboBoxEntryButtonWidget, direction);
 
1847
                         gParts->comboBoxEntryButtonWidget, direction);
1882
1848
 
1883
1849
    if (input_focus)
1884
 
        GTK_WIDGET_UNSET_FLAGS(gComboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
 
1850
        GTK_WIDGET_UNSET_FLAGS(gParts->comboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
1885
1851
 
1886
 
    calculate_button_inner_rect(gComboBoxEntryButtonWidget,
 
1852
    calculate_button_inner_rect(gParts->comboBoxEntryButtonWidget,
1887
1853
                                rect, &arrow_rect, direction, FALSE);
1888
1854
    if (state_type == GTK_STATE_ACTIVE) {
1889
 
        gtk_widget_style_get(gComboBoxEntryButtonWidget,
 
1855
        gtk_widget_style_get(gParts->comboBoxEntryButtonWidget,
1890
1856
                             "child-displacement-x", &x_displacement,
1891
1857
                             "child-displacement-y", &y_displacement,
1892
1858
                             NULL);
1894
1860
        arrow_rect.y += y_displacement;
1895
1861
    }
1896
1862
 
1897
 
    calculate_arrow_rect(gComboBoxEntryArrowWidget,
 
1863
    calculate_arrow_rect(gParts->comboBoxEntryArrowWidget,
1898
1864
                         &arrow_rect, &real_arrow_rect, direction);
1899
1865
 
1900
 
    style = gComboBoxEntryArrowWidget->style;
 
1866
    style = gParts->comboBoxEntryArrowWidget->style;
1901
1867
    TSOffsetStyleGCs(style, real_arrow_rect.x, real_arrow_rect.y);
1902
1868
 
1903
1869
    gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
1904
 
                    gComboBoxEntryArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,
 
1870
                    gParts->comboBoxEntryArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,
1905
1871
                    real_arrow_rect.x, real_arrow_rect.y,
1906
1872
                    real_arrow_rect.width, real_arrow_rect.height);
1907
1873
 
1921
1887
 
1922
1888
    if (isradio) {
1923
1889
        ensure_radiobutton_widget();
1924
 
        widget = gRadiobuttonWidget;
 
1890
        widget = gParts->radiobuttonWidget;
1925
1891
    } else {
1926
1892
        ensure_checkbox_widget();
1927
 
        widget = gCheckboxWidget;
 
1893
        widget = gParts->checkboxWidget;
1928
1894
    }
1929
1895
    gtk_widget_set_direction(widget, direction);
1930
1896
 
1972
1938
 
1973
1939
    if (isradio) {
1974
1940
        ensure_radiobutton_widget();
1975
 
        widget = gRadiobuttonWidget;
 
1941
        widget = gParts->radiobuttonWidget;
1976
1942
    } else {
1977
1943
        ensure_checkbox_widget();
1978
 
        widget = gCheckboxWidget;
 
1944
        widget = gParts->checkboxWidget;
1979
1945
    }
1980
1946
    gtk_widget_set_direction(widget, direction);
1981
1947
 
2004
1970
    GtkShadowType shadow_type;
2005
1971
 
2006
1972
    ensure_toolbar_widget();
2007
 
    gtk_widget_set_direction(gToolbarWidget, direction);
 
1973
    gtk_widget_set_direction(gParts->toolbarWidget, direction);
2008
1974
 
2009
 
    style = gToolbarWidget->style;
 
1975
    style = gParts->toolbarWidget->style;
2010
1976
 
2011
1977
    TSOffsetStyleGCs(style, rect->x, rect->y);
2012
1978
 
2015
1981
                                       cliprect, rect->x, rect->y,
2016
1982
                                       rect->width, rect->height);
2017
1983
 
2018
 
    gtk_widget_style_get(gToolbarWidget, "shadow-type", &shadow_type, NULL);
 
1984
    gtk_widget_style_get(gParts->toolbarWidget, "shadow-type", &shadow_type, NULL);
2019
1985
 
2020
1986
    gtk_paint_box (style, drawable, GTK_STATE_NORMAL, shadow_type,
2021
 
                   cliprect, gToolbarWidget, "toolbar",
 
1987
                   cliprect, gParts->toolbarWidget, "toolbar",
2022
1988
                   rect->x, rect->y, rect->width, rect->height);
2023
1989
 
2024
1990
    return MOZ_GTK_SUCCESS;
2039
2005
    const double end_fraction = 0.8;
2040
2006
 
2041
2007
    ensure_toolbar_separator_widget();
2042
 
    gtk_widget_set_direction(gToolbarSeparatorWidget, direction);
2043
 
 
2044
 
    style = gToolbarSeparatorWidget->style;
2045
 
 
2046
 
    gtk_widget_style_get(gToolbarWidget,
 
2008
    gtk_widget_set_direction(gParts->toolbarSeparatorWidget, direction);
 
2009
 
 
2010
    style = gParts->toolbarSeparatorWidget->style;
 
2011
 
 
2012
    gtk_widget_style_get(gParts->toolbarWidget,
2047
2013
                         "wide-separators", &wide_separators,
2048
2014
                         "separator-width", &separator_width,
2049
2015
                         NULL);
2056
2022
 
2057
2023
        gtk_paint_box(style, drawable,
2058
2024
                      GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
2059
 
                      cliprect, gToolbarWidget, "vseparator",
 
2025
                      cliprect, gParts->toolbarWidget, "vseparator",
2060
2026
                      rect->x + (rect->width - separator_width) / 2,
2061
2027
                      rect->y + rect->height * start_fraction,
2062
2028
                      separator_width,
2069
2035
            paint_width = rect->width;
2070
2036
    
2071
2037
        gtk_paint_vline(style, drawable,
2072
 
                        GTK_STATE_NORMAL, cliprect, gToolbarSeparatorWidget,
 
2038
                        GTK_STATE_NORMAL, cliprect, gParts->toolbarSeparatorWidget,
2073
2039
                        "toolbar",
2074
2040
                        rect->y + rect->height * start_fraction,
2075
2041
                        rect->y + rect->height * end_fraction,
2086
2052
    GtkStyle* style;
2087
2053
 
2088
2054
    ensure_tooltip_widget();
2089
 
    gtk_widget_set_direction(gTooltipWidget, direction);
 
2055
    gtk_widget_set_direction(gParts->tooltipWidget, direction);
2090
2056
 
2091
2057
    style = gtk_rc_get_style_by_paths(gtk_settings_get_default(),
2092
2058
                                      "gtk-tooltips", "GtkWindow",
2093
2059
                                      GTK_TYPE_WINDOW);
2094
2060
 
2095
 
    style = gtk_style_attach(style, gTooltipWidget->window);
 
2061
    style = gtk_style_attach(style, gParts->tooltipWidget->window);
2096
2062
    TSOffsetStyleGCs(style, rect->x, rect->y);
2097
2063
    gtk_paint_flat_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
2098
 
                       cliprect, gTooltipWidget, "tooltip",
 
2064
                       cliprect, gParts->tooltipWidget, "tooltip",
2099
2065
                       rect->x, rect->y, rect->width, rect->height);
2100
2066
 
2101
2067
    return MOZ_GTK_SUCCESS;
2110
2076
    GtkStateType state_type = ConvertGtkState(state);
2111
2077
 
2112
2078
    ensure_window_widget();
2113
 
    gtk_widget_set_direction(gProtoWindow, direction);
 
2079
    gtk_widget_set_direction(gParts->protoWindow, direction);
2114
2080
 
2115
 
    style = gProtoWindow->style;
 
2081
    style = gParts->protoWindow->style;
2116
2082
 
2117
2083
    TSOffsetStyleGCs(style, rect->x, rect->y);
2118
2084
 
2119
 
    gtk_paint_resize_grip(style, drawable, state_type, cliprect, gProtoWindow,
 
2085
    gtk_paint_resize_grip(style, drawable, state_type, cliprect, gParts->protoWindow,
2120
2086
                          NULL, (direction == GTK_TEXT_DIR_LTR) ?
2121
2087
                          GDK_WINDOW_EDGE_SOUTH_EAST :
2122
2088
                          GDK_WINDOW_EDGE_SOUTH_WEST,
2132
2098
    GtkShadowType shadow_type;
2133
2099
 
2134
2100
    ensure_frame_widget();
2135
 
    gtk_widget_set_direction(gFrameWidget, direction);
2136
 
 
2137
 
    style = gFrameWidget->style;
2138
 
 
2139
 
    gtk_widget_style_get(gStatusbarWidget, "shadow-type", &shadow_type, NULL);
 
2101
    gtk_widget_set_direction(gParts->frameWidget, direction);
 
2102
 
 
2103
    style = gParts->frameWidget->style;
 
2104
 
 
2105
    gtk_widget_style_get(gParts->statusbarWidget, "shadow-type", &shadow_type, NULL);
2140
2106
 
2141
2107
    TSOffsetStyleGCs(style, rect->x, rect->y);
2142
2108
    gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, shadow_type,
2143
 
                     cliprect, gFrameWidget, "frame", rect->x, rect->y,
 
2109
                     cliprect, gParts->frameWidget, "frame", rect->x, rect->y,
2144
2110
                     rect->width, rect->height);
2145
2111
 
2146
2112
    return MOZ_GTK_SUCCESS;
2153
2119
    GtkStyle* style;
2154
2120
 
2155
2121
    ensure_progress_widget();
2156
 
    gtk_widget_set_direction(gProgressWidget, direction);
 
2122
    gtk_widget_set_direction(gParts->progresWidget, direction);
2157
2123
 
2158
 
    style = gProgressWidget->style;
 
2124
    style = gParts->progresWidget->style;
2159
2125
 
2160
2126
    TSOffsetStyleGCs(style, rect->x, rect->y);
2161
2127
    gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
2162
 
                  cliprect, gProgressWidget, "trough", rect->x, rect->y,
 
2128
                  cliprect, gParts->progresWidget, "trough", rect->x, rect->y,
2163
2129
                  rect->width, rect->height);
2164
2130
 
2165
2131
    return MOZ_GTK_SUCCESS;
2172
2138
    GtkStyle* style;
2173
2139
 
2174
2140
    ensure_progress_widget();
2175
 
    gtk_widget_set_direction(gProgressWidget, direction);
 
2141
    gtk_widget_set_direction(gParts->progresWidget, direction);
2176
2142
 
2177
 
    style = gProgressWidget->style;
 
2143
    style = gParts->progresWidget->style;
2178
2144
 
2179
2145
    TSOffsetStyleGCs(style, rect->x, rect->y);
2180
2146
    gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
2181
 
                  cliprect, gProgressWidget, "bar", rect->x, rect->y,
 
2147
                  cliprect, gParts->progresWidget, "bar", rect->x, rect->y,
2182
2148
                  rect->width, rect->height);
2183
2149
 
2184
2150
    return MOZ_GTK_SUCCESS;
2188
2154
moz_gtk_get_tab_thickness(void)
2189
2155
{
2190
2156
    ensure_tab_widget();
2191
 
    if (YTHICKNESS(gTabWidget->style) < 2)
 
2157
    if (YTHICKNESS(gParts->tabWidget->style) < 2)
2192
2158
        return 2; /* some themes don't set ythickness correctly */
2193
2159
 
2194
 
    return YTHICKNESS(gTabWidget->style);
 
2160
    return YTHICKNESS(gParts->tabWidget->style);
2195
2161
}
2196
2162
 
2197
2163
static gint
2207
2173
    GtkStyle* style;
2208
2174
 
2209
2175
    ensure_tab_widget();
2210
 
    gtk_widget_set_direction(gTabWidget, direction);
 
2176
    gtk_widget_set_direction(gParts->tabWidget, direction);
2211
2177
 
2212
 
    style = gTabWidget->style;
 
2178
    style = gParts->tabWidget->style;
2213
2179
    TSOffsetStyleGCs(style, rect->x, rect->y);
2214
2180
 
2215
2181
    if ((flags & MOZ_GTK_TAB_SELECTED) == 0) {
2216
2182
        /* Only draw the tab */
2217
2183
        gtk_paint_extension(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
2218
 
                            cliprect, gTabWidget, "tab",
 
2184
                            cliprect, gParts->tabWidget, "tab",
2219
2185
                            rect->x, rect->y, rect->width, rect->height,
2220
2186
                            (flags & MOZ_GTK_TAB_BOTTOM) ?
2221
2187
                                GTK_POS_TOP : GTK_POS_BOTTOM );
2282
2248
 
2283
2249
            /* Draw the tab */
2284
2250
            gtk_paint_extension(style, drawable, GTK_STATE_NORMAL,
2285
 
                                GTK_SHADOW_OUT, cliprect, gTabWidget, "tab",
 
2251
                                GTK_SHADOW_OUT, cliprect, gParts->tabWidget, "tab",
2286
2252
                                rect->x, rect->y + gap_voffset, rect->width,
2287
2253
                                rect->height - gap_voffset, GTK_POS_TOP);
2288
2254
 
2295
2261
                                                       - gap_height,
2296
2262
                                               rect->width, gap_height);
2297
2263
            gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
2298
 
                              cliprect, gTabWidget, "notebook",
 
2264
                              cliprect, gParts->tabWidget, "notebook",
2299
2265
                              rect->x - gap_loffset,
2300
2266
                              rect->y + gap_voffset - 3 * gap_height,
2301
2267
                              rect->width + gap_loffset + gap_roffset,
2307
2273
 
2308
2274
            /* Draw the tab */
2309
2275
            gtk_paint_extension(style, drawable, GTK_STATE_NORMAL,
2310
 
                                GTK_SHADOW_OUT, cliprect, gTabWidget, "tab",
 
2276
                                GTK_SHADOW_OUT, cliprect, gParts->tabWidget, "tab",
2311
2277
                                rect->x, rect->y, rect->width,
2312
2278
                                rect->height - gap_voffset, GTK_POS_BOTTOM);
2313
2279
 
2320
2286
                                                       - gap_voffset,
2321
2287
                                               rect->width, gap_height);
2322
2288
            gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
2323
 
                              cliprect, gTabWidget, "notebook",
 
2289
                              cliprect, gParts->tabWidget, "notebook",
2324
2290
                              rect->x - gap_loffset,
2325
2291
                              rect->y + rect->height - gap_voffset,
2326
2292
                              rect->width + gap_loffset + gap_roffset,
2344
2310
    GtkStyle* style;
2345
2311
 
2346
2312
    ensure_tab_widget();
2347
 
    gtk_widget_set_direction(gTabWidget, direction);
 
2313
    gtk_widget_set_direction(gParts->tabWidget, direction);
2348
2314
 
2349
 
    style = gTabWidget->style;
 
2315
    style = gParts->tabWidget->style;
2350
2316
 
2351
2317
    TSOffsetStyleGCs(style, rect->x, rect->y);
2352
2318
    gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
2353
 
                      cliprect, gTabWidget, "notebook", rect->x, rect->y,
 
2319
                      cliprect, gParts->tabWidget, "notebook", rect->x, rect->y,
2354
2320
                      rect->width, rect->height,
2355
2321
                      GTK_POS_TOP, -10, 0);
2356
2322
 
2372
2338
 
2373
2339
    ensure_tab_widget();
2374
2340
 
2375
 
    style = gTabWidget->style;
 
2341
    style = gParts->tabWidget->style;
2376
2342
    TSOffsetStyleGCs(style, rect->x, rect->y);
2377
2343
 
2378
2344
    if (direction == GTK_TEXT_DIR_RTL) {
2381
2347
    }
2382
2348
 
2383
2349
    gtk_paint_arrow(style, drawable, state_type, shadow_type, NULL,
2384
 
                    gTabWidget, "notebook", arrow_type, TRUE,
 
2350
                    gParts->tabWidget, "notebook", arrow_type, TRUE,
2385
2351
                    x, y, arrow_size, arrow_size);
2386
2352
 
2387
2353
    return MOZ_GTK_SUCCESS;
2394
2360
    GtkStyle* style;
2395
2361
    GtkShadowType shadow_type;
2396
2362
    ensure_menu_bar_widget();
2397
 
    gtk_widget_set_direction(gMenuBarWidget, direction);
2398
 
 
2399
 
    gtk_widget_style_get(gMenuBarWidget, "shadow-type", &shadow_type, NULL);
2400
 
 
2401
 
    style = gMenuBarWidget->style;
 
2363
    gtk_widget_set_direction(gParts->menuBarWidget, direction);
 
2364
 
 
2365
    gtk_widget_style_get(gParts->menuBarWidget, "shadow-type", &shadow_type, NULL);
 
2366
 
 
2367
    style = gParts->menuBarWidget->style;
2402
2368
 
2403
2369
    TSOffsetStyleGCs(style, rect->x, rect->y);
2404
2370
    gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
2406
2372
                                       rect->width, rect->height);
2407
2373
 
2408
2374
    gtk_paint_box(style, drawable, GTK_STATE_NORMAL, shadow_type,
2409
 
                  cliprect, gMenuBarWidget, "menubar", rect->x, rect->y,
 
2375
                  cliprect, gParts->menuBarWidget, "menubar", rect->x, rect->y,
2410
2376
                  rect->width, rect->height);
2411
2377
    return MOZ_GTK_SUCCESS;
2412
2378
}
2417
2383
{
2418
2384
    GtkStyle* style;
2419
2385
    ensure_menu_popup_widget();
2420
 
    gtk_widget_set_direction(gMenuPopupWidget, direction);
 
2386
    gtk_widget_set_direction(gParts->menuPopupWidget, direction);
2421
2387
 
2422
 
    style = gMenuPopupWidget->style;
 
2388
    style = gParts->menuPopupWidget->style;
2423
2389
 
2424
2390
    TSOffsetStyleGCs(style, rect->x, rect->y);
2425
2391
    gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
2426
2392
                                       cliprect, rect->x, rect->y,
2427
2393
                                       rect->width, rect->height);
2428
2394
    gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT, 
2429
 
                  cliprect, gMenuPopupWidget, "menu",
 
2395
                  cliprect, gParts->menuPopupWidget, "menu",
2430
2396
                  rect->x, rect->y, rect->width, rect->height);
2431
2397
 
2432
2398
    return MOZ_GTK_SUCCESS;
2443
2409
    gint paint_height;
2444
2410
 
2445
2411
    ensure_menu_separator_widget();
2446
 
    gtk_widget_set_direction(gMenuSeparatorWidget, direction);
2447
 
 
2448
 
    style = gMenuSeparatorWidget->style;
2449
 
 
2450
 
    gtk_widget_style_get(gMenuSeparatorWidget,
 
2412
    gtk_widget_set_direction(gParts->menuSeparatorWidget, direction);
 
2413
 
 
2414
    style = gParts->menuSeparatorWidget->style;
 
2415
 
 
2416
    gtk_widget_style_get(gParts->menuSeparatorWidget,
2451
2417
                         "wide-separators",    &wide_separators,
2452
2418
                         "separator-height",   &separator_height,
2453
2419
                         "horizontal-padding", &horizontal_padding,
2461
2427
 
2462
2428
        gtk_paint_box(style, drawable,
2463
2429
                      GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
2464
 
                      cliprect, gMenuSeparatorWidget, "hseparator",
 
2430
                      cliprect, gParts->menuSeparatorWidget, "hseparator",
2465
2431
                      rect->x + horizontal_padding + style->xthickness,
2466
2432
                      rect->y + (rect->height - separator_height - style->ythickness) / 2,
2467
2433
                      rect->width - 2 * (horizontal_padding + style->xthickness),
2472
2438
            paint_height = rect->height;
2473
2439
 
2474
2440
        gtk_paint_hline(style, drawable,
2475
 
                        GTK_STATE_NORMAL, cliprect, gMenuSeparatorWidget,
 
2441
                        GTK_STATE_NORMAL, cliprect, gParts->menuSeparatorWidget,
2476
2442
                        "menuitem",
2477
2443
                        rect->x + horizontal_padding + style->xthickness,
2478
2444
                        rect->x + rect->width - horizontal_padding - style->xthickness - 1,
2494
2460
    if (state->inHover && !state->disabled) {
2495
2461
        if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
2496
2462
            ensure_menu_bar_item_widget();
2497
 
            item_widget = gMenuBarItemWidget;
 
2463
            item_widget = gParts->menuBarItemWidget;
2498
2464
        } else {
2499
2465
            ensure_menu_item_widget();
2500
 
            item_widget = gMenuItemWidget;
 
2466
            item_widget = gParts->menuItemWidget;
2501
2467
        }
2502
2468
        gtk_widget_set_direction(item_widget, direction);
2503
2469
        
2524
2490
    GtkStateType state_type = ConvertGtkState(state);
2525
2491
 
2526
2492
    ensure_menu_item_widget();
2527
 
    gtk_widget_set_direction(gMenuItemWidget, direction);
 
2493
    gtk_widget_set_direction(gParts->menuItemWidget, direction);
2528
2494
 
2529
 
    style = gMenuItemWidget->style;
 
2495
    style = gParts->menuItemWidget->style;
2530
2496
 
2531
2497
    TSOffsetStyleGCs(style, rect->x, rect->y);
2532
2498
    gtk_paint_arrow(style, drawable, state_type,
2533
2499
                    (state_type == GTK_STATE_PRELIGHT) ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
2534
 
                    cliprect, gMenuItemWidget, "menuitem",
 
2500
                    cliprect, gParts->menuItemWidget, "menuitem",
2535
2501
                    (direction == GTK_TEXT_DIR_LTR) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT,
2536
2502
                    TRUE, rect->x, rect->y, rect->width, rect->height);
2537
2503
 
2554
2520
    moz_gtk_menu_item_paint(drawable, rect, cliprect, state, FALSE, direction);
2555
2521
 
2556
2522
    ensure_check_menu_item_widget();
2557
 
    gtk_widget_set_direction(gCheckMenuItemWidget, direction);
 
2523
    gtk_widget_set_direction(gParts->checkMenuItemWidget, direction);
2558
2524
 
2559
 
    gtk_widget_style_get (gCheckMenuItemWidget,
 
2525
    gtk_widget_style_get (gParts->checkMenuItemWidget,
2560
2526
                          "indicator-size", &indicator_size,
2561
2527
                          NULL);
2562
2528
 
2563
 
    if (checked || GTK_CHECK_MENU_ITEM(gCheckMenuItemWidget)->always_show_toggle) {
2564
 
      style = gCheckMenuItemWidget->style;
 
2529
    if (checked || GTK_CHECK_MENU_ITEM(gParts->checkMenuItemWidget)->always_show_toggle) {
 
2530
      style = gParts->checkMenuItemWidget->style;
2565
2531
 
2566
 
      offset = GTK_CONTAINER(gCheckMenuItemWidget)->border_width +
2567
 
             gCheckMenuItemWidget->style->xthickness + 2;
 
2532
      offset = GTK_CONTAINER(gParts->checkMenuItemWidget)->border_width +
 
2533
             gParts->checkMenuItemWidget->style->xthickness + 2;
2568
2534
 
2569
2535
      /* while normally this "3" would be the horizontal-padding style value, passing it to Gecko
2570
2536
         as the value of menuitem padding causes problems with dropdowns (bug 406129), so in the menu.css
2574
2540
      y = rect->y + (rect->height - indicator_size) / 2;
2575
2541
 
2576
2542
      TSOffsetStyleGCs(style, x, y);
2577
 
      gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gCheckMenuItemWidget),
 
2543
      gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gParts->checkMenuItemWidget),
2578
2544
                                     checked);
2579
2545
 
2580
2546
      if (isradio) {
2581
2547
        gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
2582
 
                         gCheckMenuItemWidget, "option",
 
2548
                         gParts->checkMenuItemWidget, "option",
2583
2549
                         x, y, indicator_size, indicator_size);
2584
2550
      } else {
2585
2551
        gtk_paint_check(style, drawable, state_type, shadow_type, cliprect,
2586
 
                        gCheckMenuItemWidget, "check",
 
2552
                        gParts->checkMenuItemWidget, "check",
2587
2553
                        x, y, indicator_size, indicator_size);
2588
2554
      }
2589
2555
    }
2598
2564
    GtkStyle* style;
2599
2565
 
2600
2566
    ensure_window_widget();
2601
 
    gtk_widget_set_direction(gProtoWindow, direction);
 
2567
    gtk_widget_set_direction(gParts->protoWindow, direction);
2602
2568
 
2603
 
    style = gProtoWindow->style;
 
2569
    style = gParts->protoWindow->style;
2604
2570
 
2605
2571
    TSOffsetStyleGCs(style, rect->x, rect->y);
2606
2572
    gtk_style_apply_default_background(style, drawable, TRUE,
2625
2591
            gint focus_width, focus_pad;
2626
2592
 
2627
2593
            ensure_button_widget();
2628
 
            *left = *top = *right = *bottom = GTK_CONTAINER(gButtonWidget)->border_width;
 
2594
            *left = *top = *right = *bottom = GTK_CONTAINER(gParts->buttonWidget)->border_width;
2629
2595
 
2630
2596
            /* Don't add this padding in HTML, otherwise the buttons will
2631
2597
               become too big and stuff the layout. */
2632
2598
            if (!inhtml) {
2633
 
                moz_gtk_widget_get_focus(gButtonWidget, &interior_focus, &focus_width, &focus_pad);
2634
 
                moz_gtk_button_get_inner_border(gButtonWidget, &inner_border);
 
2599
                moz_gtk_widget_get_focus(gParts->buttonWidget, &interior_focus, &focus_width, &focus_pad);
 
2600
                moz_gtk_button_get_inner_border(gParts->buttonWidget, &inner_border);
2635
2601
                *left += focus_width + focus_pad + inner_border.left;
2636
2602
                *right += focus_width + focus_pad + inner_border.right;
2637
2603
                *top += focus_width + focus_pad + inner_border.top;
2638
2604
                *bottom += focus_width + focus_pad + inner_border.bottom;
2639
2605
            }
2640
2606
 
2641
 
            *left += gButtonWidget->style->xthickness;
2642
 
            *right += gButtonWidget->style->xthickness;
2643
 
            *top += gButtonWidget->style->ythickness;
2644
 
            *bottom += gButtonWidget->style->ythickness;
 
2607
            *left += gParts->buttonWidget->style->xthickness;
 
2608
            *right += gParts->buttonWidget->style->xthickness;
 
2609
            *top += gParts->buttonWidget->style->ythickness;
 
2610
            *bottom += gParts->buttonWidget->style->ythickness;
2645
2611
            return MOZ_GTK_SUCCESS;
2646
2612
        }
2647
2613
    case MOZ_GTK_ENTRY:
2648
2614
        ensure_entry_widget();
2649
 
        w = gEntryWidget;
 
2615
        w = gParts->entryWidget;
2650
2616
        break;
2651
2617
    case MOZ_GTK_TREEVIEW:
2652
2618
        ensure_tree_view_widget();
2653
 
        w = gTreeViewWidget;
 
2619
        w = gParts->treeViewWidget;
2654
2620
        break;
2655
2621
    case MOZ_GTK_TREE_HEADER_CELL:
2656
2622
        {
2665
2631
            gint focus_width, focus_pad;
2666
2632
 
2667
2633
            ensure_tree_header_cell_widget();
2668
 
            *left = *top = *right = *bottom = GTK_CONTAINER(gTreeHeaderCellWidget)->border_width;
 
2634
            *left = *top = *right = *bottom = GTK_CONTAINER(gParts->treeHeaderCellWidget)->border_width;
2669
2635
 
2670
 
            moz_gtk_widget_get_focus(gTreeHeaderCellWidget, &interior_focus, &focus_width, &focus_pad);
2671
 
            moz_gtk_button_get_inner_border(gTreeHeaderCellWidget, &inner_border);
 
2636
            moz_gtk_widget_get_focus(gParts->treeHeaderCellWidget, &interior_focus, &focus_width, &focus_pad);
 
2637
            moz_gtk_button_get_inner_border(gParts->treeHeaderCellWidget, &inner_border);
2672
2638
            *left += focus_width + focus_pad + inner_border.left;
2673
2639
            *right += focus_width + focus_pad + inner_border.right;
2674
2640
            *top += focus_width + focus_pad + inner_border.top;
2675
2641
            *bottom += focus_width + focus_pad + inner_border.bottom;
2676
2642
            
2677
 
            *left += gTreeHeaderCellWidget->style->xthickness;
2678
 
            *right += gTreeHeaderCellWidget->style->xthickness;
2679
 
            *top += gTreeHeaderCellWidget->style->ythickness;
2680
 
            *bottom += gTreeHeaderCellWidget->style->ythickness;
 
2643
            *left += gParts->treeHeaderCellWidget->style->xthickness;
 
2644
            *right += gParts->treeHeaderCellWidget->style->xthickness;
 
2645
            *top += gParts->treeHeaderCellWidget->style->ythickness;
 
2646
            *bottom += gParts->treeHeaderCellWidget->style->ythickness;
2681
2647
            return MOZ_GTK_SUCCESS;
2682
2648
        }
2683
2649
    case MOZ_GTK_TREE_HEADER_SORTARROW:
2684
2650
        ensure_tree_header_cell_widget();
2685
 
        w = gTreeHeaderSortArrowWidget;
 
2651
        w = gParts->treeHeaderSortArrowWidget;
2686
2652
        break;
2687
2653
    case MOZ_GTK_DROPDOWN_ENTRY:
2688
2654
        ensure_combo_box_entry_widgets();
2689
 
        w = gComboBoxEntryTextareaWidget;
 
2655
        w = gParts->comboBoxEntryTextareaWidget;
2690
2656
        break;
2691
2657
    case MOZ_GTK_DROPDOWN_ARROW:
2692
2658
        ensure_combo_box_entry_widgets();
2693
 
        w = gComboBoxEntryButtonWidget;
 
2659
        w = gParts->comboBoxEntryButtonWidget;
2694
2660
        break;
2695
2661
    case MOZ_GTK_DROPDOWN:
2696
2662
        {
2703
2669
 
2704
2670
            ensure_combo_box_widgets();
2705
2671
 
2706
 
            *left = GTK_CONTAINER(gComboBoxButtonWidget)->border_width;
 
2672
            *left = GTK_CONTAINER(gParts->comboBoxButtonWidget)->border_width;
2707
2673
 
2708
2674
            if (!inhtml) {
2709
 
                moz_gtk_widget_get_focus(gComboBoxButtonWidget,
 
2675
                moz_gtk_widget_get_focus(gParts->comboBoxButtonWidget,
2710
2676
                                         &ignored_interior_focus,
2711
2677
                                         &focus_width, &focus_pad);
2712
2678
                *left += focus_width + focus_pad;
2713
2679
            }
2714
2680
 
2715
 
            *top = *left + gComboBoxButtonWidget->style->ythickness;
2716
 
            *left += gComboBoxButtonWidget->style->xthickness;
 
2681
            *top = *left + gParts->comboBoxButtonWidget->style->ythickness;
 
2682
            *left += gParts->comboBoxButtonWidget->style->xthickness;
2717
2683
 
2718
2684
            *right = *left; *bottom = *top;
2719
2685
 
2720
2686
            /* If there is no separator, don't try to count its width. */
2721
2687
            separator_width = 0;
2722
 
            if (gComboBoxSeparatorWidget) {
2723
 
                gtk_widget_style_get(gComboBoxSeparatorWidget,
 
2688
            if (gParts->comboBoxSeparatorWidget) {
 
2689
                gtk_widget_style_get(gParts->comboBoxSeparatorWidget,
2724
2690
                                     "wide-separators", &wide_separators,
2725
2691
                                     "separator-width", &separator_width,
2726
2692
                                     NULL);
2727
2693
 
2728
2694
                if (!wide_separators)
2729
2695
                    separator_width =
2730
 
                        XTHICKNESS(gComboBoxSeparatorWidget->style);
 
2696
                        XTHICKNESS(gParts->comboBoxSeparatorWidget->style);
2731
2697
            }
2732
2698
 
2733
 
            gtk_widget_size_request(gComboBoxArrowWidget, &arrow_req);
 
2699
            gtk_widget_size_request(gParts->comboBoxArrowWidget, &arrow_req);
2734
2700
 
2735
2701
            if (direction == GTK_TEXT_DIR_RTL)
2736
2702
                *left += separator_width + arrow_req.width;
2741
2707
        }
2742
2708
    case MOZ_GTK_TABPANELS:
2743
2709
        ensure_tab_widget();
2744
 
        w = gTabWidget;
 
2710
        w = gParts->tabWidget;
2745
2711
        break;
2746
2712
    case MOZ_GTK_PROGRESSBAR:
2747
2713
        ensure_progress_widget();
2748
 
        w = gProgressWidget;
 
2714
        w = gParts->progresWidget;
2749
2715
        break;
2750
2716
    case MOZ_GTK_SPINBUTTON_ENTRY:
2751
2717
    case MOZ_GTK_SPINBUTTON_UP:
2752
2718
    case MOZ_GTK_SPINBUTTON_DOWN:
2753
2719
        ensure_spin_widget();
2754
 
        w = gSpinWidget;
 
2720
        w = gParts->spinWidget;
2755
2721
        break;
2756
2722
    case MOZ_GTK_SCALE_HORIZONTAL:
2757
2723
        ensure_scale_widget();
2758
 
        w = gHScaleWidget;
 
2724
        w = gParts->hScaleWidget;
2759
2725
        break;
2760
2726
    case MOZ_GTK_SCALE_VERTICAL:
2761
2727
        ensure_scale_widget();
2762
 
        w = gVScaleWidget;
 
2728
        w = gParts->vScaleWidget;
2763
2729
        break;
2764
2730
    case MOZ_GTK_FRAME:
2765
2731
        ensure_frame_widget();
2766
 
        w = gFrameWidget;
 
2732
        w = gParts->frameWidget;
2767
2733
        break;
2768
2734
    case MOZ_GTK_CHECKBUTTON_LABEL:
2769
2735
    case MOZ_GTK_RADIOBUTTON_LABEL:
2775
2741
               (focus_width + focus_pad). */
2776
2742
            if (widget == MOZ_GTK_CHECKBUTTON_LABEL) {
2777
2743
                ensure_checkbox_widget();
2778
 
                moz_gtk_widget_get_focus(gCheckboxWidget, &interior_focus,
 
2744
                moz_gtk_widget_get_focus(gParts->checkboxWidget, &interior_focus,
2779
2745
                                           &focus_width, &focus_pad);
2780
2746
            }
2781
2747
            else {
2782
2748
                ensure_radiobutton_widget();
2783
 
                moz_gtk_widget_get_focus(gRadiobuttonWidget, &interior_focus,
 
2749
                moz_gtk_widget_get_focus(gParts->radiobuttonWidget, &interior_focus,
2784
2750
                                        &focus_width, &focus_pad);
2785
2751
            }
2786
2752
 
2802
2768
               of (focus_width + focus_pad). */
2803
2769
            if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
2804
2770
                ensure_checkbox_widget();
2805
 
                moz_gtk_widget_get_focus(gCheckboxWidget, &interior_focus,
 
2771
                moz_gtk_widget_get_focus(gParts->checkboxWidget, &interior_focus,
2806
2772
                                           &focus_width, &focus_pad);
2807
 
                w = gCheckboxWidget;
 
2773
                w = gParts->checkboxWidget;
2808
2774
            } else {
2809
2775
                ensure_radiobutton_widget();
2810
 
                moz_gtk_widget_get_focus(gRadiobuttonWidget, &interior_focus,
 
2776
                moz_gtk_widget_get_focus(gParts->radiobuttonWidget, &interior_focus,
2811
2777
                                        &focus_width, &focus_pad);
2812
 
                w = gRadiobuttonWidget;
 
2778
                w = gParts->radiobuttonWidget;
2813
2779
            }
2814
2780
 
2815
2781
            *left = *top = *right = *bottom = GTK_CONTAINER(w)->border_width;
2825
2791
        }
2826
2792
    case MOZ_GTK_MENUPOPUP:
2827
2793
        ensure_menu_popup_widget();
2828
 
        w = gMenuPopupWidget;
 
2794
        w = gParts->menuPopupWidget;
2829
2795
        break;
2830
2796
    case MOZ_GTK_MENUITEM:
2831
2797
        ensure_menu_item_widget();
2832
2798
        ensure_menu_bar_item_widget();
2833
 
        w = gMenuItemWidget;
 
2799
        w = gParts->menuItemWidget;
2834
2800
        break;
2835
2801
    case MOZ_GTK_CHECKMENUITEM:
2836
2802
    case MOZ_GTK_RADIOMENUITEM:
2837
2803
        ensure_check_menu_item_widget();
2838
 
        w = gCheckMenuItemWidget;
 
2804
        w = gParts->checkMenuItemWidget;
2839
2805
        break;
2840
2806
    case MOZ_GTK_TAB:
2841
2807
        ensure_tab_widget();
2842
 
        w = gTabWidget;
 
2808
        w = gParts->tabWidget;
2843
2809
        break;
2844
2810
    /* These widgets have no borders, since they are not containers. */
2845
2811
    case MOZ_GTK_SPLITTER_HORIZONTAL:
2894
2860
    GtkRequisition requisition;
2895
2861
    ensure_combo_box_entry_widgets();
2896
2862
 
2897
 
    gtk_widget_size_request(gComboBoxEntryButtonWidget, &requisition);
 
2863
    gtk_widget_size_request(gParts->comboBoxEntryButtonWidget, &requisition);
2898
2864
    *width = requisition.width;
2899
2865
    *height = requisition.height;
2900
2866
 
2907
2873
    gint arrow_size;
2908
2874
 
2909
2875
    ensure_tab_widget();
2910
 
    gtk_widget_style_get(gTabWidget,
 
2876
    gtk_widget_style_get(gParts->tabWidget,
2911
2877
                         "scroll-arrow-hlength", &arrow_size,
2912
2878
                         NULL);
2913
2879
 
2922
2888
    GtkRequisition requisition;
2923
2889
    ensure_button_arrow_widget();
2924
2890
 
2925
 
    gtk_widget_size_request(gButtonArrowWidget, &requisition);
 
2891
    gtk_widget_size_request(gParts->buttonArrowWidget, &requisition);
2926
2892
    *width = requisition.width;
2927
2893
    *height = requisition.height;
2928
2894
 
2938
2904
 
2939
2905
    ensure_toolbar_widget();
2940
2906
 
2941
 
    style = gToolbarWidget->style;
 
2907
    style = gParts->toolbarWidget->style;
2942
2908
 
2943
 
    gtk_widget_style_get(gToolbarWidget,
 
2909
    gtk_widget_style_get(gParts->toolbarWidget,
2944
2910
                         "space-size", size,
2945
2911
                         "wide-separators",  &wide_separators,
2946
2912
                         "separator-width", &separator_width,
2956
2922
moz_gtk_get_expander_size(gint* size)
2957
2923
{
2958
2924
    ensure_expander_widget();
2959
 
    gtk_widget_style_get(gExpanderWidget,
 
2925
    gtk_widget_style_get(gParts->expanderWidget,
2960
2926
                         "expander-size", size,
2961
2927
                         NULL);
2962
2928
 
2967
2933
moz_gtk_get_treeview_expander_size(gint* size)
2968
2934
{
2969
2935
    ensure_tree_view_widget();
2970
 
    gtk_widget_style_get(gTreeViewWidget,
 
2936
    gtk_widget_style_get(gParts->treeViewWidget,
2971
2937
                         "expander-size", size,
2972
2938
                         NULL);
2973
2939
 
2982
2948
 
2983
2949
    ensure_menu_separator_widget();
2984
2950
 
2985
 
    gtk_widget_style_get(gMenuSeparatorWidget,
 
2951
    gtk_widget_style_get(gParts->menuSeparatorWidget,
2986
2952
                          "wide-separators",  &wide_separators,
2987
2953
                          "separator-height", &separator_height,
2988
2954
                          NULL);
2989
2955
 
2990
2956
    if (wide_separators)
2991
 
        *size = separator_height + gMenuSeparatorWidget->style->ythickness;
 
2957
        *size = separator_height + gParts->menuSeparatorWidget->style->ythickness;
2992
2958
    else
2993
 
        *size = gMenuSeparatorWidget->style->ythickness * 2;
 
2959
        *size = gParts->menuSeparatorWidget->style->ythickness * 2;
2994
2960
 
2995
2961
    return MOZ_GTK_SUCCESS;
2996
2962
}
3001
2967
  GtkWidget* widget;
3002
2968
 
3003
2969
  ensure_scale_widget();
3004
 
  widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
 
2970
  widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
3005
2971
 
3006
2972
  gtk_widget_style_get (widget,
3007
2973
                        "slider_length", thumb_length,
3016
2982
{
3017
2983
    ensure_scrollbar_widget();
3018
2984
 
3019
 
    gtk_widget_style_get (gHorizScrollbarWidget,
 
2985
    gtk_widget_style_get (gParts->horizScrollbarWidget,
3020
2986
                          "slider_width", &metrics->slider_width,
3021
2987
                          "trough_border", &metrics->trough_border,
3022
2988
                          "stepper_size", &metrics->stepper_size,
3024
2990
                          NULL);
3025
2991
 
3026
2992
    metrics->min_slider_size =
3027
 
        GTK_RANGE(gHorizScrollbarWidget)->min_slider_size;
 
2993
        GTK_RANGE(gParts->horizScrollbarWidget)->min_slider_size;
3028
2994
 
3029
2995
    return MOZ_GTK_SUCCESS;
3030
2996
}
3036
3002
    GtkSettings* settings;
3037
3003
 
3038
3004
    ensure_image_menu_item_widget();
3039
 
    settings = gtk_widget_get_settings(gImageMenuItemWidget);
 
3005
    settings = gtk_widget_get_settings(gParts->imageMenuItemWidget);
3040
3006
 
3041
3007
    g_object_get(settings, "gtk-menu-images", &result, NULL);
3042
3008
    return result;
3054
3020
            ensure_toggle_button_widget();
3055
3021
            return moz_gtk_button_paint(drawable, rect, cliprect, state,
3056
3022
                                        (GtkReliefStyle) flags,
3057
 
                                        gToggleButtonWidget, direction);
 
3023
                                        gParts->toggleButtonWidget, direction);
3058
3024
        }
3059
3025
        ensure_button_widget();
3060
3026
        return moz_gtk_button_paint(drawable, rect, cliprect, state,
3061
 
                                    (GtkReliefStyle) flags, gButtonWidget,
 
3027
                                    (GtkReliefStyle) flags, gParts->buttonWidget,
3062
3028
                                    direction);
3063
3029
        break;
3064
3030
    case MOZ_GTK_CHECKBUTTON:
3106
3072
    case MOZ_GTK_SPINBUTTON_ENTRY:
3107
3073
        ensure_spin_widget();
3108
3074
        return moz_gtk_entry_paint(drawable, rect, cliprect, state,
3109
 
                                   gSpinWidget, direction);
 
3075
                                   gParts->spinWidget, direction);
3110
3076
        break;
3111
3077
    case MOZ_GTK_GRIPPER:
3112
3078
        return moz_gtk_gripper_paint(drawable, rect, cliprect, state,
3137
3103
    case MOZ_GTK_ENTRY:
3138
3104
        ensure_entry_widget();
3139
3105
        return moz_gtk_entry_paint(drawable, rect, cliprect, state,
3140
 
                                   gEntryWidget, direction);
 
3106
                                   gParts->entryWidget, direction);
3141
3107
        break;
3142
3108
    case MOZ_GTK_ENTRY_CARET:
3143
3109
        return moz_gtk_caret_paint(drawable, rect, cliprect, direction);
3153
3119
    case MOZ_GTK_DROPDOWN_ENTRY:
3154
3120
        ensure_combo_box_entry_widgets();
3155
3121
        return moz_gtk_entry_paint(drawable, rect, cliprect, state,
3156
 
                                   gComboBoxEntryTextareaWidget, direction);
 
3122
                                   gParts->comboBoxEntryTextareaWidget, direction);
3157
3123
        break;
3158
3124
    case MOZ_GTK_CHECKBUTTON_CONTAINER:
3159
3125
    case MOZ_GTK_RADIOBUTTON_CONTAINER:
3251
3217
    if (!is_initialized)
3252
3218
        return NULL;
3253
3219
    ensure_scrollbar_widget();
3254
 
    return gHorizScrollbarWidget;
 
3220
    return gParts->horizScrollbarWidget;
3255
3221
}
3256
3222
 
3257
3223
gint
3258
3224
moz_gtk_shutdown()
3259
3225
{
3260
3226
    GtkWidgetClass *entry_class;
3261
 
 
3262
 
    if (gTooltipWidget)
3263
 
        gtk_widget_destroy(gTooltipWidget);
3264
 
    /* This will destroy all of our widgets */
3265
 
    if (gProtoWindow)
3266
 
        gtk_widget_destroy(gProtoWindow);
3267
 
 
3268
 
    gProtoWindow = NULL;
3269
 
    gProtoLayout = NULL;
3270
 
    gButtonWidget = NULL;
3271
 
    gToggleButtonWidget = NULL;
3272
 
    gButtonArrowWidget = NULL;
3273
 
    gCheckboxWidget = NULL;
3274
 
    gRadiobuttonWidget = NULL;
3275
 
    gHorizScrollbarWidget = NULL;
3276
 
    gVertScrollbarWidget = NULL;
3277
 
    gSpinWidget = NULL;
3278
 
    gHScaleWidget = NULL;
3279
 
    gVScaleWidget = NULL;
3280
 
    gEntryWidget = NULL;
3281
 
    gComboBoxWidget = NULL;
3282
 
    gComboBoxButtonWidget = NULL;
3283
 
    gComboBoxSeparatorWidget = NULL;
3284
 
    gComboBoxArrowWidget = NULL;
3285
 
    gComboBoxEntryWidget = NULL;
3286
 
    gComboBoxEntryButtonWidget = NULL;
3287
 
    gComboBoxEntryArrowWidget = NULL;
3288
 
    gComboBoxEntryTextareaWidget = NULL;
3289
 
    gHandleBoxWidget = NULL;
3290
 
    gToolbarWidget = NULL;
3291
 
    gStatusbarWidget = NULL;
3292
 
    gFrameWidget = NULL;
3293
 
    gProgressWidget = NULL;
3294
 
    gTabWidget = NULL;
3295
 
    gTooltipWidget = NULL;
3296
 
    gMenuBarWidget = NULL;
3297
 
    gMenuBarItemWidget = NULL;
3298
 
    gMenuPopupWidget = NULL;
3299
 
    gMenuItemWidget = NULL;
3300
 
    gImageMenuItemWidget = NULL;
3301
 
    gCheckMenuItemWidget = NULL;
3302
 
    gTreeViewWidget = NULL;
3303
 
    gMiddleTreeViewColumn = NULL;
3304
 
    gTreeHeaderCellWidget = NULL;
3305
 
    gTreeHeaderSortArrowWidget = NULL;
3306
 
    gExpanderWidget = NULL;
3307
 
    gToolbarSeparatorWidget = NULL;
3308
 
    gMenuSeparatorWidget = NULL;
3309
 
    gHPanedWidget = NULL;
3310
 
    gVPanedWidget = NULL;
3311
 
    gScrolledWindowWidget = NULL;
3312
 
 
3313
3227
    entry_class = g_type_class_peek(GTK_TYPE_ENTRY);
3314
3228
    g_type_class_unref(entry_class);
3315
3229
 
3317
3231
 
3318
3232
    return MOZ_GTK_SUCCESS;
3319
3233
}
 
3234
 
 
3235
void moz_gtk_destroy_theme_parts_widgets(GtkThemeParts* parts)
 
3236
{
 
3237
    if (!parts)
 
3238
        return;
 
3239
 
 
3240
    if (parts->tooltipWidget) {
 
3241
        gtk_widget_destroy(parts->tooltipWidget);
 
3242
        parts->tooltipWidget = NULL;
 
3243
    }
 
3244
 
 
3245
    if (parts->protoWindow) {
 
3246
        gtk_widget_destroy(parts->protoWindow);
 
3247
        parts->protoWindow = NULL;
 
3248
    }
 
3249
}