]> spindle.queued.net Git - midori/commitdiff
Turn prefs into MidoriPreferences
authorChristian Dywan <christian@twotoasts.de>
Sun, 20 Apr 2008 01:30:24 +0000 (03:30 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 20 Apr 2008 01:30:24 +0000 (03:30 +0200)
po/POTFILES.in
src/Makefile.am
src/midori-browser.c
src/midori-panel.h
src/midori-preferences.c [new file with mode: 0644]
src/midori-preferences.h [new file with mode: 0644]
src/prefs.c [deleted file]
src/prefs.h [deleted file]

index f5f1651b4c52319796497b08024e18794e3e66d1..d597db364eeed71906e91a02fbe35ebf0c4e0876 100644 (file)
@@ -9,7 +9,7 @@ src/midori-panel.c
 src/midori-trash.c
 src/midori-websettings.c
 src/midori-webview.c
-src/prefs.c
+src/midori-preferences.c
 src/search.c
 src/sokoke.c
 src/webSearch.c
index 1b927068e2ba6e9c3372da578284e80ebf616ba9..b712c2067a20cba2259c56e3339a3e649fe80534 100644 (file)
@@ -24,7 +24,7 @@ midori_SOURCES = \
     midori-trash.c       midori-trash.h       \
     midori-webview.c     midori-webview.h     \
     midori-websettings.c midori-websettings.h \
-    prefs.c     prefs.h     \
+    midori-preferences.c midori-preferences.h \
     webSearch.c webSearch.h \
     helpers.c   helpers.h   \
     sokoke.c    sokoke.h    \
index b84285086cfd293a84860e1faddc6300e7bd6108..576e230cbf624edefb986fc4b67563086ca39d18 100644 (file)
 #include "global.h"
 #include "helpers.h"
 #include "webSearch.h"
-#include "prefs.h"
 
 #include "sokoke.h"
 #include "midori-webview.h"
+#include "midori-preferences.h"
 #include "midori-panel.h"
 #include "midori-console.h"
 #include "midori-trash.h"
@@ -876,8 +876,8 @@ _action_preferences_activate (GtkAction*     action,
     {
         MidoriBrowserPrivate* priv = browser->priv;
 
-        dialog = prefs_preferences_dialog_new (GTK_WINDOW (browser),
-                                               priv->settings);
+        dialog = midori_preferences_new (GTK_WINDOW (browser),
+                                         priv->settings);
         gtk_widget_show (dialog);
     }
 }
index c4772039e8958e09e3a5edb3c1e6d9fc2eb9874f..d10a4aa64e079a35a396e4c80574677908d7080f 100644 (file)
@@ -37,14 +37,14 @@ typedef struct _MidoriPanelClass           MidoriPanelClass;
 
 struct _MidoriPanel
 {
-    GtkFrame parent_instance;
+    GtkHBox parent_instance;
 
     MidoriPanelPrivate* priv;
 };
 
 struct _MidoriPanelClass
 {
-    GtkFrameClass parent_class;
+    GtkHBoxClass parent_class;
 
     /* Signals */
     gboolean
diff --git a/src/midori-preferences.c b/src/midori-preferences.c
new file mode 100644 (file)
index 0000000..e623453
--- /dev/null
@@ -0,0 +1,398 @@
+/*
+ Copyright (C) 2007-2008 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 "sokoke.h"
+
+#include <glib/gi18n.h>
+
+G_DEFINE_TYPE (MidoriPreferences, midori_preferences, GTK_TYPE_DIALOG)
+
+struct _MidoriPreferencesPrivate
+{
+    GtkWidget* notebook;
+};
+
+#define MIDORI_PREFERENCES_GET_PRIVATE(obj) \
+    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+     MIDORI_TYPE_PREFERENCES, MidoriPreferencesPrivate))
+
+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;
+
+    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_WRITABLE));
+
+    g_type_class_add_private (class, sizeof (MidoriPreferencesPrivate));
+}
+
+static void
+clear_button_clicked_cb (GtkWidget* button, GtkWidget* file_chooser)
+{
+    gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_chooser), "");
+    // Emit "file-set" manually for Gtk doesn't emit it otherwise
+    g_signal_emit_by_name (file_chooser, "file-set");
+}
+
+static void
+midori_preferences_init (MidoriPreferences* preferences)
+{
+    preferences->priv = MIDORI_PREFERENCES_GET_PRIVATE (preferences);
+    MidoriPreferencesPrivate* priv = preferences->priv;
+
+    priv->notebook = NULL;
+
+    gchar* dialog_title = g_strdup_printf (_("%s Preferences"),
+                                           g_get_application_name ());
+    g_object_set (preferences,
+                  "icon-name", GTK_STOCK_PREFERENCES,
+                  "title", dialog_title,
+                  "has-separator", FALSE,
+                  NULL);
+    gtk_dialog_add_buttons (GTK_DIALOG (preferences),
+        GTK_STOCK_HELP, GTK_RESPONSE_HELP,
+        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+        NULL);
+    // TODO: Implement some kind of help function
+    gtk_dialog_set_response_sensitive (GTK_DIALOG (preferences),
+                                       GTK_RESPONSE_HELP, FALSE); //...
+    g_signal_connect (preferences, "response",
+                      G_CALLBACK (gtk_widget_destroy), preferences);
+
+    // TODO: Do we want tooltips for explainations or can we omit that?
+    g_free (dialog_title);
+}
+
+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:
+    {
+        GtkWidget* xfce_heading;
+        GtkWindow* parent;
+        g_object_get (object, "transient-for", &parent, NULL);
+        if ((xfce_heading = sokoke_xfce_header_new (
+            gtk_window_get_icon_name (parent),
+            gtk_window_get_title (GTK_WINDOW (object)))))
+                gtk_box_pack_start (GTK_BOX (GTK_DIALOG (preferences)->vbox),
+                                    xfce_heading, FALSE, FALSE, 0);
+        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);
+    MidoriPreferencesPrivate* priv = preferences->priv;
+
+    switch (prop_id)
+    {
+    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.
+ *
+ * Return value: a new #MidoriPreferences
+ **/
+GtkWidget*
+midori_preferences_new (GtkWindow*         parent,
+                        MidoriWebSettings* settings)
+{
+    g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
+    g_return_val_if_fail (MIDORI_IS_WEB_SETTINGS (settings), NULL);
+
+    MidoriPreferences* preferences = g_object_new (MIDORI_TYPE_PREFERENCES,
+                                                   "transient-for", parent,
+                                                   "settings", settings,
+                                                   NULL);
+
+    return GTK_WIDGET (preferences);
+}
+
+/**
+ * midori_preferences_set_settings:
+ * @settings: the settings
+ *
+ * Assigns a settings instance to a preferences dialog.
+ *
+ * Note: This must not be called more than once.
+ **/
+void
+midori_preferences_set_settings (MidoriPreferences* preferences,
+                                 MidoriWebSettings* settings)
+{
+    g_return_if_fail (MIDORI_IS_PREFERENCES (preferences));
+    g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
+
+    MidoriPreferencesPrivate* priv = preferences->priv;
+
+    g_return_if_fail (!priv->notebook);
+
+    priv->notebook = gtk_notebook_new ();
+    gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 6);
+    GtkSizeGroup* sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+    GtkWidget* page; GtkWidget* frame; GtkWidget* table; GtkWidget* align;
+    GtkWidget* label; GtkWidget* button;
+    GtkWidget* entry; GtkWidget* hbox;
+    #define PAGE_NEW(__label) page = gtk_vbox_new (FALSE, 0); \
+     gtk_container_set_border_width (GTK_CONTAINER (page), 5); \
+     gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page, \
+                               gtk_label_new (__label))
+    #define FRAME_NEW(__label) frame = sokoke_hig_frame_new (__label); \
+     gtk_container_set_border_width (GTK_CONTAINER (frame), 5); \
+     gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0);
+    #define TABLE_NEW(__rows, __cols) table = gtk_table_new ( \
+                                       __rows, __cols, FALSE); \
+     gtk_container_set_border_width (GTK_CONTAINER (table), 5); \
+     gtk_container_add (GTK_CONTAINER (frame), table);
+    #define WIDGET_ADD(__widget, __left, __right, __top, __bottom) \
+     gtk_table_attach (GTK_TABLE (table), __widget \
+      , __left, __right, __top, __bottom \
+      , GTK_FILL, GTK_FILL, 8, 2)
+    #define FILLED_ADD(__widget, __left, __right, __top, __bottom) \
+     gtk_table_attach (GTK_TABLE (table), __widget \
+      , __left, __right, __top, __bottom\
+      , GTK_EXPAND | GTK_FILL, GTK_FILL, 8, 2)
+    #define INDENTED_ADD(__widget, __left, __right, __top, __bottom) \
+     align = gtk_alignment_new (0, 0.5, 0, 0); \
+     gtk_container_add (GTK_CONTAINER (align), __widget); \
+     gtk_size_group_add_widget (sizegroup, align); \
+     WIDGET_ADD (align, __left, __right, __top, __bottom)
+    #define SPANNED_ADD(__widget, __left, __right, __top, __bottom) \
+     align = gtk_alignment_new (0, 0.5, 0, 0); \
+     gtk_container_add (GTK_CONTAINER (align), __widget); \
+     FILLED_ADD (align, __left, __right, __top, __bottom)
+    // Page "General"
+    PAGE_NEW (_("General"));
+    FRAME_NEW (_("Startup"));
+    TABLE_NEW (2, 2);
+    label = katze_property_label (settings, "load-on-startup");
+    INDENTED_ADD (label, 0, 1, 0, 1);
+    button = katze_property_proxy (settings, "load-on-startup", NULL);
+    FILLED_ADD (button, 1, 2, 0, 1);
+    label = katze_property_label (settings, "homepage");
+    INDENTED_ADD (label, 0, 1, 1, 2);
+    entry = katze_property_proxy (settings, "homepage", NULL);
+    FILLED_ADD (entry, 1, 2, 1, 2);
+    // TODO: We need something like "use current website"
+    FRAME_NEW (_("Transfers"));
+    TABLE_NEW (1, 2);
+    label = katze_property_label (settings, "download-folder");
+    INDENTED_ADD (label, 0, 1, 0, 1);
+    button = katze_property_proxy (settings, "download-folder", "folder");
+    FILLED_ADD (button, 1, 2, 0, 1);
+    button = katze_property_proxy (settings, "show-download-notification", "blurb");
+    SPANNED_ADD (button, 0, 2, 1, 2);
+
+    // Page "Appearance"
+    PAGE_NEW (_("Appearance"));
+    FRAME_NEW (_("Font settings"));
+    TABLE_NEW (5, 2);
+    label = katze_property_label (settings, "default-font-family");
+    INDENTED_ADD (label, 0, 1, 0, 1);
+    hbox = gtk_hbox_new (FALSE, 4);
+    button = katze_property_proxy (settings, "default-font-family", NULL);
+    gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+    entry = katze_property_proxy (settings, "default-font-size", NULL);
+    gtk_box_pack_end (GTK_BOX (hbox), entry, FALSE, FALSE, 4);
+    FILLED_ADD (hbox, 1, 2, 0, 1);
+    label = katze_property_label (settings, "minimum-font-size");
+    INDENTED_ADD (label, 0, 1, 1, 2);
+    hbox = gtk_hbox_new (FALSE, 4);
+    entry = katze_property_proxy (settings, "minimum-font-size", NULL);
+    INDENTED_ADD (entry, 1, 2, 1, 2);
+    label = katze_property_label (settings, "preferred-encoding");
+    INDENTED_ADD (label, 0, 1, 2, 3);
+    button = katze_property_proxy (settings, "preferred-encoding", NULL);
+    FILLED_ADD (button, 1, 2, 2, 3);
+
+    // Page "Behavior"
+    PAGE_NEW (_("Behavior"));
+    FRAME_NEW (_("Features"));
+    TABLE_NEW (5, 2);
+    button = katze_property_proxy (settings, "auto-load-images", NULL);
+    INDENTED_ADD (button, 0, 1, 0, 1);
+    button = katze_property_proxy (settings, "auto-shrink-images", NULL);
+    SPANNED_ADD (button, 1, 2, 0, 1);
+    button = katze_property_proxy (settings, "print-backgrounds", NULL);
+    INDENTED_ADD (button, 0, 1, 1, 2);
+    button = katze_property_proxy (settings, "resizable-text-areas", NULL);
+    SPANNED_ADD (button, 1, 2, 1, 2);
+    button = katze_property_proxy (settings, "enable-scripts", NULL);
+    INDENTED_ADD (button, 0, 1, 2, 3);
+    button = katze_property_proxy (settings, "enable-plugins", NULL);
+    SPANNED_ADD(button, 1, 2, 2, 3);
+    label = katze_property_label (settings, "user-stylesheet-uri");
+    INDENTED_ADD (label, 0, 1, 3, 4);
+    hbox = gtk_hbox_new (FALSE, 4);
+    entry = katze_property_proxy (settings, "user-stylesheet-uri", "uri");
+    gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+    button = gtk_button_new ();
+    gtk_container_add (GTK_CONTAINER (button),
+        gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU));
+    g_signal_connect (button, "clicked",
+                      G_CALLBACK (clear_button_clicked_cb), entry);
+    gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 4);
+    FILLED_ADD (hbox, 1, 2, 3, 4);
+    label = katze_property_label (settings, "location-entry-search");
+    INDENTED_ADD (label, 0, 1, 4, 5);
+    entry = katze_property_proxy (settings, "location-entry-search", NULL);
+    FILLED_ADD (entry, 1, 2, 4, 5);
+
+    // Page "Interface"
+    PAGE_NEW (_("Interface"));
+    FRAME_NEW (_("Navigationbar"));
+    TABLE_NEW (3, 2);
+    INDENTED_ADD (katze_property_label (settings, "toolbar-style"), 0, 1, 0, 1);
+    button = katze_property_proxy (settings, "toolbar-style", NULL);
+    FILLED_ADD(button, 1, 2, 0, 1);
+    button = katze_property_proxy (settings, "small-toolbar", NULL);
+    INDENTED_ADD (button, 0, 1, 1, 2);
+    button = katze_property_proxy (settings, "show-web-search", NULL);
+    SPANNED_ADD (button, 1, 2, 1, 2);
+    button = katze_property_proxy (settings, "show-new-tab", NULL);
+    INDENTED_ADD (button, 0, 1, 2, 3);
+    button = katze_property_proxy (settings, "show-trash", NULL);
+    SPANNED_ADD (button, 1, 2, 2, 3);
+    FRAME_NEW(_("Browsing"));
+    TABLE_NEW (3, 2);
+    label = katze_property_label (settings, "open-new-pages-in");
+    INDENTED_ADD (label, 0, 1, 0, 1);
+    button = katze_property_proxy (settings, "open-new-pages-in", NULL);
+    FILLED_ADD (button, 1, 2, 0, 1);
+    button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
+    INDENTED_ADD (button, 0, 1, 1, 2);
+    button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
+    SPANNED_ADD (button, 1, 2, 1, 2);
+    button = katze_property_proxy (settings, "open-popups-in-tabs", NULL);
+    SPANNED_ADD (button, 0, 1, 2, 3);
+    button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
+    SPANNED_ADD (button, 1, 2, 2, 3);
+
+    // Page "Network"
+    PAGE_NEW (_("Network"));
+    FRAME_NEW (_("Network"));
+    TABLE_NEW (2, 2);
+    label = katze_property_label (settings, "http-proxy");
+    INDENTED_ADD (label, 0, 1, 0, 1);
+    button = katze_property_proxy (settings, "http-proxy", NULL);
+    FILLED_ADD (button, 1, 2, 0, 1);
+    label = katze_property_label (settings, "cache-size");
+    INDENTED_ADD (label, 0, 1, 1, 2);
+    hbox = gtk_hbox_new (FALSE, 4);
+    entry = katze_property_proxy (settings, "cache-size", NULL);
+    gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("MB")),
+                        FALSE, FALSE, 0);
+    FILLED_ADD (hbox, 1, 2, 1, 2);
+
+    // Page "Privacy"
+    PAGE_NEW (_("Privacy"));
+    FRAME_NEW (_("Cookies"));
+    TABLE_NEW (3, 2);
+    label = katze_property_label (settings, "accept-cookies");
+    INDENTED_ADD (label, 0, 1, 0, 1);
+    button = katze_property_proxy (settings, "accept-cookies", NULL);
+    FILLED_ADD (button, 1, 2, 0, 1);
+    button = katze_property_proxy (settings, "original-cookies-only", "blurb");
+    SPANNED_ADD (button, 0, 2, 1, 2);
+    label = katze_property_label (settings, "maximum-cookie-age");
+    INDENTED_ADD (label, 0, 1, 2, 3);
+    hbox = gtk_hbox_new (FALSE, 4);
+    entry = katze_property_proxy (settings, "maximum-cookie-age", NULL);
+    gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
+                        FALSE, FALSE, 0);
+    FILLED_ADD (hbox, 1, 2, 2, 3);
+    FRAME_NEW (_("History"));
+    TABLE_NEW (3, 2);
+    button = katze_property_proxy (settings, "remember-last-visited-pages", NULL);
+    SPANNED_ADD (button, 0, 1, 0, 1);
+    hbox = gtk_hbox_new (FALSE, 4);
+    button = katze_property_proxy (settings, "maximum-history-age", NULL);
+    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
+                        FALSE, FALSE, 0);
+    SPANNED_ADD (hbox, 1, 2, 0, 1);
+    button = katze_property_proxy (settings, "remember-last-form-inputs", NULL);
+    SPANNED_ADD (button, 0, 2, 1, 2);
+    button = katze_property_proxy (settings, "remember-last-downloaded-files", NULL);
+    SPANNED_ADD (button, 0, 2, 2, 3);
+
+    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (preferences)->vbox),
+                        priv->notebook, FALSE, FALSE, 4);
+    gtk_widget_show_all (GTK_DIALOG (preferences)->vbox);
+}
diff --git a/src/midori-preferences.h b/src/midori-preferences.h
new file mode 100644 (file)
index 0000000..e47d843
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2008 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.
+*/
+
+#ifndef __MIDORI_PREFERENCES_H__
+#define __MIDORI_PREFERENCES_H__
+
+#include "midori-websettings.h"
+
+#include <gtk/gtk.h>
+
+#include <katze/katze.h>
+
+G_BEGIN_DECLS
+
+#define MIDORI_TYPE_PREFERENCES \
+    (midori_preferences_get_type ())
+#define MIDORI_PREFERENCES(obj) \
+    (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_PREFERENCES, MidoriPreferences))
+#define MIDORI_PREFERENCES_CLASS(klass) \
+    (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_PREFERENCES, MidoriPreferencesClass))
+#define MIDORI_IS_PREFERENCES(obj) \
+    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_PREFERENCES))
+#define MIDORI_IS_PREFERENCES_CLASS(klass) \
+    (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_PREFERENCES))
+#define MIDORI_PREFERENCES_GET_CLASS(obj) \
+    (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_PREFERENCES, MidoriPreferencesClass))
+
+typedef struct _MidoriPreferences                MidoriPreferences;
+typedef struct _MidoriPreferencesPrivate         MidoriPreferencesPrivate;
+typedef struct _MidoriPreferencesClass           MidoriPreferencesClass;
+
+struct _MidoriPreferences
+{
+    GtkDialog parent_instance;
+
+    MidoriPreferencesPrivate* priv;
+};
+
+struct _MidoriPreferencesClass
+{
+    GtkDialogClass parent_class;
+};
+
+GType
+midori_preferences_get_type               (void);
+
+GtkWidget*
+midori_preferences_new              (GtkWindow*         parent,
+                                     MidoriWebSettings* settings);
+
+void
+midori_preferences_set_settings     (MidoriPreferences* preferences,
+                                     MidoriWebSettings* settings);
+
+G_END_DECLS
+
+#endif /* __MIDORI_PREFERENCES_H__ */
diff --git a/src/prefs.c b/src/prefs.c
deleted file mode 100644 (file)
index ffdee1f..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- Copyright (C) 2007-2008 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 "prefs.h"
-
-#include "helpers.h"
-#include "sokoke.h"
-
-#include <glib/gi18n.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void
-clear_button_clicked_cb (GtkWidget* button, GtkWidget* file_chooser)
-{
-    gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_chooser), "");
-    // Emit "file-set" manually for Gtk doesn't emit it otherwise
-    g_signal_emit_by_name (file_chooser, "file-set");
-}
-
-GtkWidget* prefs_preferences_dialog_new (GtkWindow* window,
-                                         MidoriWebSettings* settings)
-{
-    gchar* dialogTitle = g_strdup_printf(_("%s Preferences"), g_get_application_name());
-    GtkWidget* dialog = gtk_dialog_new_with_buttons(dialogTitle
-        , window
-        , GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR
-        , GTK_STOCK_HELP, GTK_RESPONSE_HELP
-        , GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE
-        , NULL);
-    gtk_window_set_icon_name(GTK_WINDOW(dialog), GTK_STOCK_PREFERENCES);
-    // TODO: Implement some kind of help function
-    gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_HELP, FALSE); //...
-    g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
-
-    CPrefs* prefs = g_new0(CPrefs, 1);
-    g_signal_connect(dialog, "response", G_CALLBACK(g_free), prefs);
-
-    // TODO: Do we want tooltips for explainations or can we omit that?
-    // TODO: We need mnemonics
-    // TODO: Take multiple windows into account when applying changes
-    GtkWidget* xfce_heading;
-    if((xfce_heading = sokoke_xfce_header_new(
-     gtk_window_get_icon_name(window), dialogTitle)))
-        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox)
-         , xfce_heading, FALSE, FALSE, 0);
-    g_free(dialogTitle);
-    GtkWidget* notebook = gtk_notebook_new();
-    gtk_container_set_border_width(GTK_CONTAINER(notebook), 6);
-    GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-    GtkWidget* page; GtkWidget* frame; GtkWidget* table; GtkWidget* align;
-    GtkWidget* label; GtkWidget* button;
-    GtkWidget* entry; GtkWidget* hbox;
-    #define PAGE_NEW(__label) page = gtk_vbox_new(FALSE, 0);\
-     gtk_container_set_border_width(GTK_CONTAINER(page), 5);\
-     gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, gtk_label_new(__label))
-    #define FRAME_NEW(__label) frame = sokoke_hig_frame_new(__label);\
-     gtk_container_set_border_width(GTK_CONTAINER(frame), 5);\
-     gtk_box_pack_start(GTK_BOX(page), frame, FALSE, FALSE, 0);
-    #define TABLE_NEW(__rows, __cols) table = gtk_table_new(__rows, __cols, FALSE);\
-     gtk_container_set_border_width(GTK_CONTAINER(table), 5);\
-     gtk_container_add(GTK_CONTAINER(frame), table);
-    #define WIDGET_ADD(__widget, __left, __right, __top, __bottom)\
-     gtk_table_attach(GTK_TABLE(table), __widget\
-      , __left, __right, __top, __bottom\
-      , GTK_FILL, GTK_FILL, 8, 2)
-    #define FILLED_ADD(__widget, __left, __right, __top, __bottom)\
-     gtk_table_attach(GTK_TABLE(table), __widget\
-      , __left, __right, __top, __bottom\
-      , GTK_EXPAND | GTK_FILL, GTK_FILL, 8, 2)
-    #define INDENTED_ADD(__widget, __left, __right, __top, __bottom)\
-     align = gtk_alignment_new(0, 0.5, 0, 0);\
-     gtk_container_add(GTK_CONTAINER(align), __widget);\
-     gtk_size_group_add_widget(sizegroup, align);\
-     WIDGET_ADD(align, __left, __right, __top, __bottom)
-    #define SPANNED_ADD(__widget, __left, __right, __top, __bottom)\
-     align = gtk_alignment_new(0, 0.5, 0, 0);\
-     gtk_container_add(GTK_CONTAINER(align), __widget);\
-     FILLED_ADD(align, __left, __right, __top, __bottom)
-    // Page "General"
-    PAGE_NEW (_("General"));
-    FRAME_NEW (_("Startup"));
-    TABLE_NEW (2, 2);
-    label = katze_property_label (settings, "load-on-startup");
-    INDENTED_ADD (label, 0, 1, 0, 1);
-    button = katze_property_proxy (settings, "load-on-startup", NULL);
-    FILLED_ADD (button, 1, 2, 0, 1);
-    label = katze_property_label (settings, "homepage");
-    INDENTED_ADD (label, 0, 1, 1, 2);
-    entry = katze_property_proxy (settings, "homepage", NULL);
-    FILLED_ADD (entry, 1, 2, 1, 2);
-    // TODO: We need something like "use current website"
-    FRAME_NEW (_("Transfers"));
-    TABLE_NEW (1, 2);
-    label = katze_property_label (settings, "download-folder");
-    INDENTED_ADD (label, 0, 1, 0, 1);
-    button = katze_property_proxy (settings, "download-folder", "folder");
-    FILLED_ADD (button, 1, 2, 0, 1);
-    button = katze_property_proxy (settings, "show-download-notification", "blurb");
-    SPANNED_ADD (button, 0, 2, 1, 2);
-
-    // Page "Appearance"
-    PAGE_NEW (_("Appearance"));
-    FRAME_NEW (_("Font settings"));
-    TABLE_NEW (5, 2);
-    label = katze_property_label (settings, "default-font-family");
-    INDENTED_ADD (label, 0, 1, 0, 1);
-    hbox = gtk_hbox_new (FALSE, 4);
-    button = katze_property_proxy (settings, "default-font-family", NULL);
-    gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
-    entry = katze_property_proxy (settings, "default-font-size", NULL);
-    gtk_box_pack_end (GTK_BOX (hbox), entry, FALSE, FALSE, 4);
-    FILLED_ADD (hbox, 1, 2, 0, 1);
-    label = katze_property_label (settings, "minimum-font-size");
-    INDENTED_ADD (label, 0, 1, 1, 2);
-    hbox = gtk_hbox_new (FALSE, 4);
-    entry = katze_property_proxy (settings, "minimum-font-size", NULL);
-    INDENTED_ADD (entry, 1, 2, 1, 2);
-    label = katze_property_label (settings, "preferred-encoding");
-    INDENTED_ADD (label, 0, 1, 2, 3);
-    button = katze_property_proxy (settings, "preferred-encoding", NULL);
-    FILLED_ADD (button, 1, 2, 2, 3);
-
-    // Page "Behavior"
-    PAGE_NEW (_("Behavior"));
-    FRAME_NEW (_("Features"));
-    TABLE_NEW (5, 2);
-    button = katze_property_proxy (settings, "auto-load-images", NULL);
-    INDENTED_ADD (button, 0, 1, 0, 1);
-    button = katze_property_proxy (settings, "auto-shrink-images", NULL);
-    SPANNED_ADD (button, 1, 2, 0, 1);
-    button = katze_property_proxy (settings, "print-backgrounds", NULL);
-    INDENTED_ADD (button, 0, 1, 1, 2);
-    button = katze_property_proxy (settings, "resizable-text-areas", NULL);
-    SPANNED_ADD (button, 1, 2, 1, 2);
-    button = katze_property_proxy (settings, "enable-scripts", NULL);
-    INDENTED_ADD (button, 0, 1, 2, 3);
-    button = katze_property_proxy (settings, "enable-plugins", NULL);
-    SPANNED_ADD(button, 1, 2, 2, 3);
-    label = katze_property_label (settings, "user-stylesheet-uri");
-    INDENTED_ADD (label, 0, 1, 3, 4);
-    hbox = gtk_hbox_new (FALSE, 4);
-    entry = katze_property_proxy (settings, "user-stylesheet-uri", "uri");
-    gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
-    button = gtk_button_new ();
-    gtk_container_add (GTK_CONTAINER (button),
-        gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU));
-    g_signal_connect (button, "clicked",
-                      G_CALLBACK (clear_button_clicked_cb), entry);
-    gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 4);
-    FILLED_ADD (hbox, 1, 2, 3, 4);
-    label = katze_property_label (settings, "location-entry-search");
-    INDENTED_ADD (label, 0, 1, 4, 5);
-    entry = katze_property_proxy (settings, "location-entry-search", NULL);
-    FILLED_ADD (entry, 1, 2, 4, 5);
-
-    // Page "Interface"
-    PAGE_NEW (_("Interface"));
-    FRAME_NEW (_("Navigationbar"));
-    TABLE_NEW (3, 2);
-    INDENTED_ADD (katze_property_label (settings, "toolbar-style"), 0, 1, 0, 1);
-    button = katze_property_proxy (settings, "toolbar-style", NULL);
-    FILLED_ADD(button, 1, 2, 0, 1);
-    button = katze_property_proxy (settings, "small-toolbar", NULL);
-    INDENTED_ADD (button, 0, 1, 1, 2);
-    button = katze_property_proxy (settings, "show-web-search", NULL);
-    SPANNED_ADD (button, 1, 2, 1, 2);
-    button = katze_property_proxy (settings, "show-new-tab", NULL);
-    INDENTED_ADD (button, 0, 1, 2, 3);
-    button = katze_property_proxy (settings, "show-trash", NULL);
-    SPANNED_ADD (button, 1, 2, 2, 3);
-    FRAME_NEW(_("Browsing"));
-    TABLE_NEW (3, 2);
-    label = katze_property_label (settings, "open-new-pages-in");
-    INDENTED_ADD (label, 0, 1, 0, 1);
-    button = katze_property_proxy (settings, "open-new-pages-in", NULL);
-    FILLED_ADD (button, 1, 2, 0, 1);
-    button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
-    INDENTED_ADD (button, 0, 1, 1, 2);
-    button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
-    SPANNED_ADD (button, 1, 2, 1, 2);
-    button = katze_property_proxy (settings, "open-popups-in-tabs", NULL);
-    SPANNED_ADD (button, 0, 1, 2, 3);
-    button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
-    SPANNED_ADD (button, 1, 2, 2, 3);
-
-    // Page "Network"
-    PAGE_NEW (_("Network"));
-    FRAME_NEW (_("Network"));
-    TABLE_NEW (2, 2);
-    label = katze_property_label (settings, "http-proxy");
-    INDENTED_ADD (label, 0, 1, 0, 1);
-    button = katze_property_proxy (settings, "http-proxy", NULL);
-    FILLED_ADD (button, 1, 2, 0, 1);
-    label = katze_property_label (settings, "cache-size");
-    INDENTED_ADD (label, 0, 1, 1, 2);
-    hbox = gtk_hbox_new (FALSE, 4);
-    entry = katze_property_proxy (settings, "cache-size", NULL);
-    gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("MB")),
-                        FALSE, FALSE, 0);
-    FILLED_ADD (hbox, 1, 2, 1, 2);
-
-    // Page "Privacy"
-    PAGE_NEW (_("Privacy"));
-    FRAME_NEW (_("Cookies"));
-    TABLE_NEW (3, 2);
-    label = katze_property_label (settings, "accept-cookies");
-    INDENTED_ADD (label, 0, 1, 0, 1);
-    button = katze_property_proxy (settings, "accept-cookies", NULL);
-    FILLED_ADD (button, 1, 2, 0, 1);
-    button = katze_property_proxy (settings, "original-cookies-only", "blurb");
-    SPANNED_ADD (button, 0, 2, 1, 2);
-    label = katze_property_label (settings, "maximum-cookie-age");
-    INDENTED_ADD (label, 0, 1, 2, 3);
-    hbox = gtk_hbox_new (FALSE, 4);
-    entry = katze_property_proxy (settings, "maximum-cookie-age", NULL);
-    gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
-                        FALSE, FALSE, 0);
-    FILLED_ADD (hbox, 1, 2, 2, 3);
-    FRAME_NEW (_("History"));
-    TABLE_NEW (3, 2);
-    button = katze_property_proxy (settings, "remember-last-visited-pages", NULL);
-    SPANNED_ADD (button, 0, 1, 0, 1);
-    hbox = gtk_hbox_new (FALSE, 4);
-    button = katze_property_proxy (settings, "maximum-history-age", NULL);
-    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
-                        FALSE, FALSE, 0);
-    SPANNED_ADD (hbox, 1, 2, 0, 1);
-    button = katze_property_proxy (settings, "remember-last-form-inputs", NULL);
-    SPANNED_ADD (button, 0, 2, 1, 2);
-    button = katze_property_proxy (settings, "remember-last-downloaded-files", NULL);
-    SPANNED_ADD (button, 0, 2, 2, 3);
-
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox)
-     , notebook, FALSE, FALSE, 4);
-    gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
-    return dialog;
-}
diff --git a/src/prefs.h b/src/prefs.h
deleted file mode 100644 (file)
index 990def9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Copyright (C) 2007 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.
-*/
-
-#ifndef __PREFS_H__
-#define __PREFS_H__ 1
-
-#include <gtk/gtk.h>
-
-#include "midori-websettings.h"
-
-// -- Types
-
-typedef struct
-{
-    GtkWidget* userStylesheetUri;
-    GtkWidget* treeview;
-    GtkWidget* combobox;
-    GtkWidget* add;
-} CPrefs;
-
-enum
-{
-    PROTOCOLS_COL_NAME,
-    PROTOCOLS_COL_COMMAND,
-    PROTOCOLS_COL_N
-};
-
-// -- Declarations
-
-GtkWidget*
-prefs_preferences_dialog_new(GtkWindow*, MidoriWebSettings*);
-
-#endif /* !__PREFS_H__ */