~midori/midori/gtk3WebKit2only

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
/*
 Copyright (C) 2007-2009 Christian Dywan <christian@twotoasts.de>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 See the file COPYING for the full license text.
*/

#include "midori-preferences.h"

#include "midori-app.h"
#include "midori-core.h"
#include "midori-extension.h"
#include "panels/midori-extensions.h"
#include "midori-platform.h"

#include <string.h>
#include <glib/gi18n.h>
#include <libsoup/soup.h>

    #define LIBSOUP_USE_UNSTABLE_REQUEST_API
    #include <libsoup/soup-cache.h>

#include <config.h>

struct _MidoriPreferences
{
    KatzePreferences parent_instance;

    gpointer settings;
};

G_DEFINE_TYPE (MidoriPreferences, midori_preferences, KATZE_TYPE_PREFERENCES);

enum
{
    PROP_0,

    PROP_SETTINGS
};

static void
midori_preferences_finalize (GObject* object);

static void
midori_preferences_set_property (GObject*      object,
                                 guint         prop_id,
                                 const GValue* value,
                                 GParamSpec*   pspec);

static void
midori_preferences_get_property (GObject*    object,
                                 guint       prop_id,
                                 GValue*     value,
                                 GParamSpec* pspec);

static void
midori_preferences_class_init (MidoriPreferencesClass* class)
{
    GObjectClass* gobject_class = G_OBJECT_CLASS (class);
    gobject_class->finalize = midori_preferences_finalize;
    gobject_class->set_property = midori_preferences_set_property;
    gobject_class->get_property = midori_preferences_get_property;

    /**
     * MidoriPreferences:settings:
     *
     * The settings to proxy properties from.
     */
    g_object_class_install_property (gobject_class,
                                     PROP_SETTINGS,
                                     g_param_spec_object (
                                     "settings",
                                     "Settings",
                                     "Settings instance to provide properties",
                                     MIDORI_TYPE_WEB_SETTINGS,
                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}

static void
midori_preferences_init (MidoriPreferences* preferences)
{
    preferences->settings = NULL;
}

static void
midori_preferences_finalize (GObject* object)
{
    G_OBJECT_CLASS (midori_preferences_parent_class)->finalize (object);
}

static void
midori_preferences_set_property (GObject*      object,
                                 guint         prop_id,
                                 const GValue* value,
                                 GParamSpec*   pspec)
{
    MidoriPreferences* preferences = MIDORI_PREFERENCES (object);

    switch (prop_id)
    {
    case PROP_SETTINGS:
        midori_preferences_set_settings (preferences,
                                         g_value_get_object (value));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}

static void
midori_preferences_get_property (GObject*    object,
                                 guint       prop_id,
                                 GValue*     value,
                                 GParamSpec* pspec)
{
    MidoriPreferences* preferences = MIDORI_PREFERENCES (object);

    switch (prop_id)
    {
    case PROP_SETTINGS:
        g_value_set_object (value, preferences->settings);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}

/**
 * midori_preferences_new:
 * @parent: the parent window
 * @settings: the settings
 *
 * Creates a new preferences dialog.
 *
 * Since 0.1.2 @parent may be %NULL.
 *
 * Return value: a new #MidoriPreferences
 **/
GtkWidget*
midori_preferences_new (GtkWindow*         parent,
                        MidoriWebSettings* settings)
{
    MidoriPreferences* preferences;

    g_return_val_if_fail (!parent || GTK_IS_WINDOW (parent), NULL);
    g_return_val_if_fail (MIDORI_IS_WEB_SETTINGS (settings), NULL);

    preferences = g_object_new (MIDORI_TYPE_PREFERENCES,
                                "transient-for", parent,
                                "settings", settings,
                                NULL);

    return GTK_WIDGET (preferences);
}

static void
midori_preferences_homepage_current_clicked_cb (GtkWidget*         button,
                                                MidoriWebSettings* settings)
{
    GtkWidget* preferences = gtk_widget_get_toplevel (button);
    GtkWidget* browser = katze_object_get_object (preferences, "transient-for");

    if (GTK_IS_WINDOW (browser))
    {
        gchar* uri = katze_object_get_string (browser, "uri");
        if (uri && *uri)
            g_object_set (settings, "homepage", uri, NULL);
        else
            g_object_set (settings, "homepage", "about:blank", NULL);
        g_free (uri);
    }
}

static void
midori_preferences_notify_proxy_type_cb (MidoriWebSettings* settings,
                                         GParamSpec*        pspec,
                                         GtkWidget*         entry)
{
    MidoriProxy proxy_type = katze_object_get_enum (settings, "proxy-type");

    gtk_widget_set_sensitive (entry, proxy_type == MIDORI_PROXY_HTTP);
}

#if HAVE_OSX
static void
midori_preferences_toolbutton_clicked_cb (GtkWidget* toolbutton,
                                          GtkWidget* page)
{
    gpointer notebook = g_object_get_data (G_OBJECT (toolbutton), "notebook");
    guint n = gtk_notebook_page_num (notebook, page);
    gtk_notebook_set_current_page (notebook, n);
}
#endif

#if 0
static void
midori_preferences_list_dicts_cb (const gchar* lang_tag,
                                  const gchar* provider_name,
                                  const gchar* provider_desc,
                                  const gchar* provider_file,
                                  GList**      dicts)
{
    *dicts = g_list_prepend (*dicts, (gchar*)lang_tag);
}

static GList*
midori_preferences_get_spell_languages (void)
{
    GList* dicts = NULL;
    gpointer broker = enchant_broker_init ();
    enchant_broker_list_dicts (broker, (GCallback)midori_preferences_list_dicts_cb, &dicts);
    enchant_broker_free (broker);
    return dicts;
}
#endif

#ifdef G_OS_WIN32
static void
midori_preferences_theme_changed_cb (GtkWidget* button,
                                     gpointer   user_data)
{
    MidoriSettings* settings = user_data;
    midori_settings_set_theme_name (settings,
        gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (button)));
}
#endif

/**
 * midori_preferences_set_settings:
 * @settings: the settings
 *
 * Assigns a settings instance to a preferences dialog.
 *
 * Note: This must not be called more than once.
 *
 * Since 0.1.2 this is equal to setting #MidoriPreferences:settings:.
 **/
void
midori_preferences_set_settings (MidoriPreferences* preferences,
                                 MidoriWebSettings* settings)
{
    GtkWidget* header;
    GtkWindow* parent;
    const gchar* icon_name;
    KatzePreferences* _preferences;
    GtkWidget* label;
    GtkWidget* button;
    GtkWidget* entry;

    g_return_if_fail (MIDORI_IS_PREFERENCES (preferences));
    g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));

    g_return_if_fail (!preferences->settings);

    preferences->settings = settings;

    g_object_get (preferences, "transient-for", &parent, NULL);
    icon_name = parent ? gtk_window_get_icon_name (parent) : NULL;
    if ((header = sokoke_xfce_header_new (icon_name,
        gtk_window_get_title (GTK_WINDOW (preferences)))))
    {
        GtkWidget* vbox = gtk_dialog_get_content_area (GTK_DIALOG (preferences));
        gtk_box_pack_start (GTK_BOX (vbox), header, FALSE, FALSE, 0);
        gtk_widget_show_all (header);
    }
    _preferences = KATZE_PREFERENCES (preferences);

    #define PAGE_NEW(__icon, __label) \
     katze_preferences_add_category (_preferences, __label, __icon)
    #define FRAME_NEW(__label) \
     katze_preferences_add_group (_preferences, __label)
    #define FILLED_ADD(__widget) \
     katze_preferences_add_widget (_preferences, __widget, "filled")
    #define INDENTED_ADD(__widget) \
     katze_preferences_add_widget (_preferences, __widget, "indented")
    #define SPANNED_ADD(__widget) \
     katze_preferences_add_widget (_preferences, __widget, "spanned")
    /* Page "General" */
    if (!midori_paths_is_readonly ())
    {
    PAGE_NEW (GTK_STOCK_HOME, _("Startup"));
    FRAME_NEW (NULL);
    label = gtk_label_new (_("When Midori starts:"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "load-on-startup", NULL);
    SPANNED_ADD (button);
    label = gtk_label_new (_("Homepage:"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    entry = katze_property_proxy (settings, "homepage", "address");
    SPANNED_ADD (entry);
    if (parent && MIDORI_IS_BROWSER (parent))
    {
        #if 0
        button = gtk_button_new_with_mnemonic (_("Use _current page"));
        #else
        label = gtk_label_new (NULL);
        INDENTED_ADD (label);
        button = gtk_button_new_with_label (_("Use current page as homepage"));
        #endif
        g_signal_connect (button, "clicked",
            G_CALLBACK (midori_preferences_homepage_current_clicked_cb), settings);
        SPANNED_ADD (button);
    }
    }

    /* Page "Appearance" */
    PAGE_NEW (GTK_STOCK_SELECT_FONT, _("Fonts"));
    FRAME_NEW (NULL);
    label = gtk_label_new (_("Proportional Font Family"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "default-font-family", "font");
    gtk_widget_set_tooltip_text (button, _("The default font family used to display text"));
    SPANNED_ADD (button);
    entry = katze_property_proxy (settings, "default-font-size", NULL);
    gtk_widget_set_tooltip_text (entry, _("The default font size used to display text"));
    SPANNED_ADD (entry);
    label = gtk_label_new (_("Fixed-width Font Family"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "monospace-font-family", "font-monospace");
    gtk_widget_set_tooltip_text (button, _("The font family used to display fixed-width text"));
    SPANNED_ADD (button);
    entry = katze_property_proxy (settings, "default-monospace-font-size", NULL);
    gtk_widget_set_tooltip_text (entry, _("The font size used to display fixed-width text"));
    SPANNED_ADD (entry);
    label = gtk_label_new (_("Minimum Font Size"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    entry = katze_property_proxy (settings, "minimum-font-size", NULL);
    gtk_widget_set_tooltip_text (entry, _("The minimum font size used to display text"));
    SPANNED_ADD (entry);
    button = katze_property_proxy (settings, "enforce-font-family", NULL);
    INDENTED_ADD (button);
    label = gtk_label_new (_("Preferred Encoding"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "preferred-encoding", "custom-default-charset");
    SPANNED_ADD (button);

    /* Page "Behavior" */
    PAGE_NEW (GTK_STOCK_SELECT_COLOR, _("Behavior"));
    FRAME_NEW (NULL);
    button = katze_property_proxy (settings, "auto-load-images", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Load images automatically"));
    INDENTED_ADD (button);
    button = katze_property_proxy (settings, "enable-spell-checking", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Enable Spell Checking"));
    SPANNED_ADD (button);
    /* Disable spell check option if there are no enchant modules */
    {
        gchar* enchant_path = midori_paths_get_lib_path ("enchant");
        if (enchant_path == NULL)
        {
            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
            gtk_widget_set_sensitive (button, FALSE);
        }
        else
            g_free (enchant_path);
    }
    button = katze_property_proxy (settings, "enable-javascript", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Enable scripts"));
    INDENTED_ADD (button);
    button = katze_property_proxy (settings, "enable-webgl", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Enable WebGL support"));
    #ifndef HAVE_WEBKIT2
    if (parent && MIDORI_IS_BROWSER (parent))
    {
        GtkWidget* tab = midori_browser_get_current_tab (MIDORI_BROWSER (parent));
        WebKitWebView* web_view = midori_tab_get_web_view (MIDORI_TAB (tab));
        WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
        JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
        gchar* supports_web_gl = sokoke_js_script_eval (js_context,
            "!!window.WebGLRenderingContext", NULL);
        if (g_strcmp0 (supports_web_gl, "true"))
            gtk_widget_hide (button);
        g_free (supports_web_gl);
    }
    #endif
    SPANNED_ADD (button);
    button = katze_property_proxy (settings, "zoom-text-and-images", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Zoom Text and Images"));
    INDENTED_ADD (button);
    button = katze_property_proxy (settings, "javascript-can-open-windows-automatically", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Allow scripts to open popups"));
    gtk_widget_set_tooltip_text (button, _("Whether scripts are allowed to open popup windows automatically"));
    SPANNED_ADD (button);
    label = gtk_label_new (_("Default Zoom Level"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "zoom-level", NULL);
    gtk_widget_set_tooltip_text (button, _("Initial factor to enlarge newly opened tabs by"));
    SPANNED_ADD (button);

    FRAME_NEW (NULL);
    button = gtk_label_new (_("Preferred languages"));
    gtk_misc_set_alignment (GTK_MISC (button), 0.0, 0.5);
    INDENTED_ADD (button);
    entry = katze_property_proxy (settings, "preferred-languages", "languages");
    gtk_widget_set_tooltip_text (entry, _("A comma separated list of languages preferred for rendering multilingual webpages, for example \"de\", \"ru,nl\" or \"en-us;q=1.0, fr-fr;q=0.667\""));
    SPANNED_ADD (entry);
    label = gtk_label_new (_("Save downloaded files to:"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "download-folder", "folder");
    SPANNED_ADD (button);

    /* Page "Interface" */
    PAGE_NEW (GTK_STOCK_CONVERT, _("Browsing"));
        FRAME_NEW (NULL);
    #ifdef G_OS_WIN32
    INDENTED_ADD (gtk_label_new (_("Theme:")));
    button = gtk_combo_box_text_new ();
    SPANNED_ADD (button);
    guint i = 0;
    /* On Windows the default theme may be a built-in specific to the
       running system. So we always add the default and skip it later.
     */
    const gchar* default_theme = midori_settings_get_default_theme_name (MIDORI_SETTINGS (settings));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (button), default_theme);
    gtk_combo_box_set_active (GTK_COMBO_BOX (button), i++);

    const gchar* current_theme = midori_settings_get_theme_name (MIDORI_SETTINGS (settings));
    gchar* theme_path = midori_paths_get_data_filename ("themes", FALSE);
    GDir* dir;
    if ((dir = g_dir_open (theme_path, 0, NULL)))
    {
        const gchar* name;
        while ((name = g_dir_read_name (dir)))
        {
            if (!g_strcmp0 (name, default_theme))
                continue;
            gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (button), name);
            if (!g_strcmp0 (name, current_theme))
                gtk_combo_box_set_active (GTK_COMBO_BOX (button), i);
            i++;
        }
        g_dir_close (dir);
        g_signal_connect (button, "changed",
                          G_CALLBACK (midori_preferences_theme_changed_cb), settings);
    }
    g_free (theme_path);
    #endif
        INDENTED_ADD (gtk_label_new (_("Toolbar Style:")));
        button = katze_property_proxy (settings, "toolbar-style", NULL);
        SPANNED_ADD (button);
    FRAME_NEW (NULL);
    label = gtk_label_new (_("Open new pages in:"));
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "open-new-pages-in", NULL);
    SPANNED_ADD (button);
    label = gtk_label_new (_("New tab behavior:"));
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "new-tab-type", "custom-tabhome");
    SPANNED_ADD (button);
    button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Close Buttons on Tabs"));
    INDENTED_ADD (button);
    button = katze_property_proxy (settings, "open-tabs-next-to-current", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Open Tabs next to Current"));
    gtk_widget_set_tooltip_text (button, _("Whether to open new tabs next to the current tab or after the last one"));
    INDENTED_ADD (button);
    button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Open tabs in the background"));
    SPANNED_ADD (button);

    /* Page "Network" */
    PAGE_NEW (GTK_STOCK_NETWORK, _("Network"));
    FRAME_NEW (NULL);
    label = gtk_label_new (_("Proxy server"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "proxy-type", NULL);
    SPANNED_ADD (button);
    label = gtk_label_new (_("URI"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    entry = katze_property_proxy (settings, "http-proxy", "address");
    SPANNED_ADD (entry);
    g_signal_connect_object (settings, "notify::proxy-type",
        G_CALLBACK (midori_preferences_notify_proxy_type_cb), entry, 0);
    midori_preferences_notify_proxy_type_cb (settings, NULL, entry);
    label = gtk_label_new (_("Port"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    entry = katze_property_proxy (settings, "http-proxy-port", NULL);
    SPANNED_ADD (entry);
    g_signal_connect_object (settings, "notify::proxy-type",
        G_CALLBACK (midori_preferences_notify_proxy_type_cb), entry, 0);
    midori_preferences_notify_proxy_type_cb (settings, NULL, entry);
    INDENTED_ADD (gtk_event_box_new ());
    label = gtk_label_new (NULL);
    GString* proxy_types = g_string_new (NULL);
    g_string_append (proxy_types, "<span size=\"smaller\">");
    g_string_append (proxy_types, _("Supported proxy types:"));
    g_string_append_c (proxy_types, ' ');
    /* http is not implemented as a GIO extension */
    g_string_append (proxy_types, "http:// https://");
    GIOExtensionPoint* proxy_extension = g_io_extension_point_lookup ("gio-proxy");
    GList* proxies = g_io_extension_point_get_extensions (proxy_extension);
    for (; proxies; proxies = g_list_next (proxies))
        g_string_append_printf (proxy_types, " %s://", g_io_extension_get_name (proxies->data));
    g_string_append (proxy_types, "</span>");
    gtk_label_set_markup (GTK_LABEL (label), proxy_types->str);
    g_string_free (proxy_types, TRUE);
    SPANNED_ADD (label);
    g_signal_connect_object (settings, "notify::proxy-type",
        G_CALLBACK (midori_preferences_notify_proxy_type_cb), label, 0);
    midori_preferences_notify_proxy_type_cb (settings, NULL, label);
    /* i18n: This refers to an application, not the 'user agent' string */
    label = gtk_label_new (_("Identify as"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    INDENTED_ADD (label);
    button = katze_property_proxy (settings, "identify-as", "custom-user-agent");
    SPANNED_ADD (button);
}

void
midori_preferences_add_privacy_category (KatzePreferences*  preferences,
                                         MidoriWebSettings* settings)
{
    GtkWidget* button;
    GtkWidget* label;
    gchar* markup;

    g_return_if_fail (KATZE_IS_PREFERENCES (preferences));
    g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));

    katze_preferences_add_category (preferences, _("Privacy"), GTK_STOCK_INDEX);
    katze_preferences_add_group (preferences, NULL);
    button = gtk_label_new (_("Delete old Cookies after:"));
    gtk_misc_set_alignment (GTK_MISC (button), 0.0, 0.5);
    gtk_widget_set_tooltip_text (button, _("The maximum number of days to save cookies for"));
    katze_preferences_add_widget (preferences, button, "indented");
    button = katze_property_proxy (settings, "maximum-cookie-age", "days");
    gtk_widget_set_tooltip_text (button, _("The maximum number of days to save cookies for"));
    katze_preferences_add_widget (preferences, button, "spanned");
    #ifdef HAVE_LIBSOUP_2_29_91
    button = katze_property_proxy (settings, "first-party-cookies-only", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Only accept Cookies from sites you visit"));
    gtk_widget_set_tooltip_text (button, _("Block cookies sent by third-party websites"));
    katze_preferences_add_widget (preferences, button, "filled");
    #endif

    markup = g_strdup_printf ("<span size=\"smaller\">%s</span>",
        _("Cookies store login data, saved games, "
          "or user profiles for advertisement purposes."));
    label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label), markup);
    g_free (markup);
    katze_preferences_add_widget (preferences, label, "filled");
    button = katze_property_proxy (settings, "enable-offline-web-application-cache", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Enable offline web application cache"));
    katze_preferences_add_widget (preferences, button, "indented");
    button = katze_property_proxy (settings, "enable-html5-local-storage", NULL);
    gtk_button_set_label (GTK_BUTTON (button), _("Enable HTML5 local storage support"));
    katze_preferences_add_widget (preferences, button, "spanned");
    button = katze_property_proxy (settings, "strip-referer", NULL);
    /* i18n: Reworded: Shorten details propagated when going to another page */
    gtk_button_set_label (GTK_BUTTON (button), _("Strip referrer details sent to websites"));
    /* i18n: Referer here is not a typo but a technical term */
    gtk_widget_set_tooltip_text (button, _("Whether the \"Referer\" header should be shortened to the hostname"));
    katze_preferences_add_widget (preferences, button, "indented");
    katze_preferences_add_widget (preferences, gtk_label_new (NULL), "indented");
    button = gtk_label_new (_("Delete pages from history after:"));
    gtk_misc_set_alignment (GTK_MISC (button), 0.0, 0.5);
    gtk_widget_set_tooltip_text (button, _("The maximum number of days to save the history for"));
    katze_preferences_add_widget (preferences, button, "indented");
    button = katze_property_proxy (settings, "maximum-history-age", "days");
    gtk_widget_set_tooltip_text (button, _("The maximum number of days to save the history for"));
    katze_preferences_add_widget (preferences, button, "spanned");
}

void
midori_preferences_add_extension_category (KatzePreferences*  preferences,
                                           MidoriApp*         app)
{
    KatzeArray* array;
    GtkWidget* scrolled;
    GtkWidget* addon;
    GList* children;
    GtkWidget* page;

    array = katze_object_get_object (app, "extensions");

    midori_extension_load_from_folder (app, NULL, FALSE);
    /* Reset frozen list: allow active extensions to be saved */
    g_object_set_data (G_OBJECT (app), "extensions", NULL);

    /* Hide if there are no extensions at all */
    if (!katze_array_get_nth_item (array, 0))
    {
        g_object_unref (array);
        return;
    }
    g_object_unref (array);

    scrolled = gtk_scrolled_window_new (NULL, NULL);
    /* For lack of a better way of keeping descriptions visible */
    g_object_set (scrolled, "visible", TRUE, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
    addon = g_object_new (MIDORI_TYPE_EXTENSIONS, "app", app, NULL);
    children = gtk_container_get_children (GTK_CONTAINER (addon));
    gtk_widget_reparent (g_list_nth_data (children, 0), scrolled);
    g_list_free (children);
    page = katze_preferences_add_category (preferences,
                                           _("Extensions"), STOCK_EXTENSION);
    gtk_box_pack_start (GTK_BOX (page), scrolled, TRUE, TRUE, 4);
}