[seahorse] Port SeahorsePrefs to Vala.



commit 086126dabb40e768e3379a47f6a8daaf1d5d1d22
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Thu Nov 23 23:26:09 2017 +0100

    Port SeahorsePrefs to Vala.

 common/add-keyserver-dialog.vala                  |  122 +++++
 common/catalog.vala                               |    7 +-
 common/config.vapi                                |    6 -
 common/meson.build                                |    7 +
 common/prefs.vala                                 |  299 +++++++++++
 {libseahorse => common}/seahorse-add-keyserver.ui |   81 +---
 {libseahorse => common}/seahorse-prefs.ui         |  137 ++----
 data/seahorse.gresource.xml                       |    6 +-
 libseahorse/meson.build                           |    1 -
 libseahorse/seahorse-key-manager-store.c          |    1 -
 libseahorse/seahorse-prefs.c                      |  573 ---------------------
 libseahorse/seahorse-prefs.h                      |   49 --
 pgp/seahorse-keyserver-sync.c                     |    5 +-
 po/POTFILES.in                                    |    7 +-
 po/POTFILES.skip                                  |    1 +
 15 files changed, 494 insertions(+), 808 deletions(-)
---
diff --git a/common/add-keyserver-dialog.vala b/common/add-keyserver-dialog.vala
new file mode 100644
index 0000000..f28abd3
--- /dev/null
+++ b/common/add-keyserver-dialog.vala
@@ -0,0 +1,122 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2004-2005 Stefan Walter
+ * Copyright (C) 2017 Niels De Graef
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+public class Seahorse.AddKeyserverDialog : Gtk.Dialog {
+
+    private string[]? keyserver_types;
+
+    private Gtk.Entry keyserver_host;
+    private Gtk.Entry keyserver_port;
+    private Gtk.ComboBoxText keyserver_type;
+    private Gtk.Box port_block;
+
+    public AddKeyserverDialog(Gtk.Window? parent) {
+        GLib.Object(
+            title: _("Add Key Server"),
+            transient_for: parent,
+            modal: true,
+            window_position: Gtk.WindowPosition.CENTER_ON_PARENT,
+            default_width: 400,
+            use_header_bar: 1
+        );
+        this.keyserver_types = Seahorse.Servers.get_types();
+
+        // Load ui
+        Gtk.Builder builder = new Gtk.Builder();
+        try {
+            string path = "/org/gnome/Seahorse/seahorse-add-keyserver.ui";
+            builder.add_from_resource(path);
+        } catch (GLib.Error err) {
+            GLib.critical("%s", err.message);
+        }
+        Gtk.Box content = (Gtk.Box) builder.get_object("add-keyserver");
+        get_content_area().add(content);
+        this.keyserver_host = (Gtk.Entry) builder.get_object("keyserver-host");
+        this.keyserver_port = (Gtk.Entry) builder.get_object("keyserver-port");
+        this.keyserver_type = (Gtk.ComboBoxText) builder.get_object("keyserver-type");
+        this.port_block = (Gtk.Box) builder.get_object("port-block");
+
+        this.keyserver_type.changed.connect(() => on_prefs_add_keyserver_uri_changed());
+        this.keyserver_host.changed.connect(() => on_prefs_add_keyserver_uri_changed());
+        this.keyserver_port.changed.connect(() => on_prefs_add_keyserver_uri_changed());
+
+        // The description for the key server types, plus custom
+        foreach (string type in this.keyserver_types)
+            this.keyserver_type.append_text(Seahorse.Servers.get_description(type));
+
+        this.keyserver_type.append_text(_("Custom"));
+        this.keyserver_type.set_active(0);
+
+        // Buttons
+        add_button(_("Cancel"), Gtk.ResponseType.CANCEL);
+        Gtk.Button save_button = (Gtk.Button) add_button(("Save"), Gtk.ResponseType.OK);
+        save_button.get_style_context().add_class("suggested-action");
+
+        show();
+    }
+
+    public string? calculate_keyserver_uri() {
+        // Figure out the scheme
+        string? scheme = null;
+        int active = this.keyserver_type.get_active();
+        int i;
+        if (active >= 0 && this.keyserver_types != null) {
+            for (i = 0; this.keyserver_types[i] != null && i < active; i++);
+            if (i == active
+                    && this.keyserver_types[active] != null
+                    && this.keyserver_types[active] != "")
+                scheme = this.keyserver_types[active];
+        }
+
+        string? host = this.keyserver_host.text;
+        if (host == null || host == "")
+            return null;
+
+        if (scheme == null) // Custom URI?
+            return Servers.is_valid_uri(host)? host : null;
+
+        string? port = this.keyserver_port.text;
+        if (port == "")
+            port = null;
+
+        // Mash 'em together into a uri
+        string? uri = "%s://%s".printf(scheme, host);
+        if (port != null)
+            uri += ":%s".printf(port);
+
+        // And check if it's valid
+        if (!Servers.is_valid_uri(uri))
+            uri = null;
+
+        return uri;
+    }
+
+    private void on_prefs_add_keyserver_uri_changed() {
+        set_response_sensitive(Gtk.ResponseType.OK, calculate_keyserver_uri() != null);
+
+        // Show or hide the port section based on whether 'custom' is selected
+        int active = this.keyserver_type.get_active();
+        if (active > -1) {
+            this.port_block.visible = this.keyserver_types != null
+                                      && this.keyserver_types[active] != null
+                                      && this.keyserver_types[active] != "";
+        }
+    }
+}
diff --git a/common/catalog.vala b/common/catalog.vala
index 0690795..394adc0 100644
--- a/common/catalog.vala
+++ b/common/catalog.vala
@@ -242,9 +242,10 @@ public abstract class Catalog : Gtk.Window {
        }
 
        [CCode (instance_pos = -1)]
-       private void on_app_preferences (Gtk.Action action)
-       {
-               Prefs.show(this, null);
+       private void on_app_preferences (Gtk.Action action) {
+        Prefs prefs_dialog = new Prefs(this);
+        prefs_dialog.run();
+        prefs_dialog.destroy();
        }
 
        private const string[] AUTHORS = {
diff --git a/common/config.vapi b/common/config.vapi
index 54bbddc..0e4ed5a 100644
--- a/common/config.vapi
+++ b/common/config.vapi
@@ -21,12 +21,6 @@ namespace Config
 
 namespace Seahorse {
 
-[CCode (cheader_filename = "libseahorse/seahorse-prefs.h")]
-namespace Prefs {
-       public void show(Gtk.Window window, string? tabid);
-       public bool available();
-}
-
 [CCode (cheader_filename = "libseahorse/seahorse-application.h")]
 namespace Application {
        public unowned Gtk.Application @get();
diff --git a/common/meson.build b/common/meson.build
index 94c92a8..e2eca83 100644
--- a/common/meson.build
+++ b/common/meson.build
@@ -1,5 +1,6 @@
 common_sources = [
   'actions.vala',
+  'add-keyserver-dialog.vala',
   'backend.vala',
   'catalog.vala',
   'collection.vala',
@@ -14,6 +15,7 @@ common_sources = [
   'passphrase-prompt.vala',
   'place.vala',
   'predicate.vala',
+  'prefs.vala',
   'registry.vala',
   'servers.vala',
   'types.vala',
@@ -30,13 +32,18 @@ common_deps = [
   config,
 ]
 
+common_vala_args = [
+]
+
 if with_keyservers
   common_sources += 'keyserver-control.vala'
+  common_vala_args += [ '-D', 'WITH_KEYSERVER' ]
 endif
 
 common_lib = static_library('common',
   common_sources,
   dependencies: common_deps,
+  vala_args: common_vala_args,
   vala_header: 'seahorse-common.h',
 )
 
diff --git a/common/prefs.vala b/common/prefs.vala
new file mode 100644
index 0000000..9edad26
--- /dev/null
+++ b/common/prefs.vala
@@ -0,0 +1,299 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2004-2005 Stefan Walter
+ * Copyright (C) 2017 Niels De Graef
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+public class Seahorse.Prefs : Gtk.Dialog {
+
+    private bool updating_model;
+
+    private Gtk.Notebook notebook;
+    private Gtk.Grid keyserver_tab;
+    private Gtk.TreeView keyservers;
+    private Gtk.Box keyserver_publish;
+    private Gtk.Label keyserver_publish_to_label;
+    private Gtk.Button keyserver_remove;
+    private Gtk.Button keyserver_add;
+    private Gtk.CheckButton auto_retrieve;
+    private Gtk.CheckButton auto_sync;
+
+    /**
+     * Create a new preferences window.
+     *
+     * @param parent The Gtk.Window to set as the preferences dialog's parent
+     */
+    public Prefs(Gtk.Window? parent, string? tabid = null) {
+        GLib.Object (
+            title: _("Preferences"),
+            transient_for: parent,
+            modal: true
+        );
+        this.updating_model = false;
+
+        Gtk.Builder builder = new Gtk.Builder();
+        try {
+            string path = "/org/gnome/Seahorse/seahorse-prefs.ui";
+            builder.add_from_resource(path);
+        } catch (GLib.Error err) {
+            GLib.critical("%s", err.message);
+        }
+        Gtk.Box content = (Gtk.Box) builder.get_object("prefs");
+        get_content_area().border_width = 0;
+        get_content_area().add(content);
+        this.notebook = (Gtk.Notebook) builder.get_object("notebook");
+        this.keyserver_tab = (Gtk.Grid) builder.get_object("keyserver-tab");
+        this.keyservers = (Gtk.TreeView) builder.get_object("keyservers");
+        this.keyserver_publish = (Gtk.Box) builder.get_object("keyserver-publish");
+        this.keyserver_publish_to_label = (Gtk.Label) builder.get_object("keyserver-publish-to-label");
+        this.keyserver_remove = (Gtk.Button) builder.get_object("keyserver_remove");
+        this.keyserver_add = (Gtk.Button) builder.get_object("keyserver_add");
+        this.auto_retrieve = (Gtk.CheckButton) builder.get_object("auto_retrieve");
+        this.auto_sync = (Gtk.CheckButton) builder.get_object("auto_sync");
+
+        this.keyserver_remove.clicked.connect(on_prefs_keyserver_remove_clicked);
+        this.keyserver_add.clicked.connect(on_prefs_keyserver_add_clicked);
+
+#if WITH_KEYSERVER
+        setup_keyservers();
+#else
+        remove_tab(this.keyserver_tab);
+#endif
+
+        if (tabid != null) {
+            Gtk.Widget? tab = builder.get_object(tabid) as Gtk.Widget;
+            if (tab != null)
+                select_tab(tab);
+        }
+    }
+
+    public static bool available() {
+#if WITH_KEYSERVER
+        return true;
+#else
+        return false;
+#endif
+    }
+
+    /**
+     * Add a tab to the preferences window
+     *
+     * @param label Label for the tab to be added
+     * @param tab Tab to be added
+     */
+    public void add_tab(Gtk.Widget? label, Gtk.Widget? tab) {
+        label.show();
+        this.notebook.prepend_page(tab, label);
+    }
+
+    /**
+     * Sets the input tab to be the active one
+     *
+     * @param tab The tab to be set active
+     */
+    public void select_tab(Gtk.Widget? tab) {
+        int pos = this.notebook.page_num(tab);
+        if (pos != -1)
+            this.notebook.set_current_page(pos);
+    }
+
+    /**
+     * Removes a tab from the preferences window
+     *
+     * @tab: The tab to be removed
+     */
+    public void remove_tab(Gtk.Widget? tab) {
+        int pos = this.notebook.page_num(tab);
+        if (pos != -1)
+            this.notebook.remove_page(pos);
+    }
+
+#if WITH_KEYSERVER
+
+    private enum Columns {
+        KEYSERVER,
+        N_COLUMNS
+    }
+
+    // Perform keyserver page initialization
+    private void setup_keyservers () {
+        string[] keyservers = Seahorse.Servers.get_uris();
+        populate_keyservers(keyservers);
+
+        Gtk.TreeModel model = this.keyservers.get_model();
+        model.row_changed.connect(keyserver_row_changed);
+        model.row_deleted.connect(keyserver_row_deleted);
+
+        Gtk.TreeSelection selection = this.keyservers.get_selection();
+        selection.set_mode(Gtk.SelectionMode.SINGLE);
+        selection.changed.connect(keyserver_sel_changed);
+
+        Application.pgp_settings().changed["keyserver"].connect((settings, key) => {
+            populate_keyservers(settings.get_strv(key));
+        });
+
+        KeyserverControl skc = new KeyserverControl("server-publish-to",
+                                                    _("None: Don’t publish keys"));
+        this.keyserver_publish.add(skc);
+        this.keyserver_publish.show_all();
+
+        this.keyserver_publish_to_label.set_mnemonic_widget(skc);
+
+        Application.settings().bind("server-auto-retrieve", this.auto_retrieve, "active",
+                                    SettingsBindFlags.DEFAULT);
+        Application.settings().bind("server-auto-publish", this.auto_sync, "active",
+                                    SettingsBindFlags.DEFAULT);
+    }
+
+    // Called when a cell has completed being edited
+    private void keyserver_cell_edited (Gtk.CellRendererText cell, string? path, string? text, Gtk.TreeStore 
store) {
+        if (!Servers.is_valid_uri(text)) {
+            Util.show_error (null,
+                             _("Not a valid Key Server address."),
+                             _("For help contact your system administrator or the administrator of the key 
server." ));
+            return;
+        }
+
+        Gtk.TreeIter iter;
+        warn_if_fail(store.get_iter_from_string(out iter, path));
+        store.set(iter, Columns.KEYSERVER, text, -1);
+    }
+
+    // The selection changed on the tree
+    private void keyserver_sel_changed (Gtk.TreeSelection selection) {
+        this.keyserver_remove.sensitive = (selection.count_selected_rows() > 0);
+    }
+
+    // User wants to remove selected rows
+    private void on_prefs_keyserver_remove_clicked (Gtk.Widget? button) {
+        this.keyservers.get_selection().selected_foreach((model, path, iter) => {
+            ((Gtk.TreeStore) model).remove(ref iter);
+        });
+    }
+
+    // Write key server list to settings
+    private void save_keyservers (Gtk.TreeModel model) {
+        string[] values = {};
+        Gtk.TreeIter iter;
+        if (model.get_iter_first(out iter)) {
+            do {
+                string? keyserver = null;
+                model.get(iter, Columns.KEYSERVER, out keyserver, -1);
+                if (keyserver == null)
+                    return;
+                values += keyserver;
+            } while (model.iter_next(ref iter));
+        }
+
+        Application.pgp_settings().set_strv("keyservers", values);
+    }
+
+    private void keyserver_row_changed (Gtk.TreeModel model, Gtk.TreePath arg1, Gtk.TreeIter arg2) {
+        // If currently updating (see populate_keyservers) ignore
+        if (this.updating_model)
+            return;
+
+        save_keyservers(model);
+    }
+
+    private void keyserver_row_deleted (Gtk.TreeModel model, Gtk.TreePath arg1) {
+        // If currently updating (see populate_keyservers) ignore
+        if (this.updating_model)
+            return;
+
+        save_keyservers(model);
+    }
+
+    private void populate_keyservers(string[] keyservers) {
+        Gtk.TreeStore store = (Gtk.TreeStore) this.keyservers.get_model();
+
+        // This is our first time so create a store
+        if (store == null) {
+            store = new Gtk.TreeStore(1, typeof(string));
+            this.keyservers.set_model(store);
+
+            // Make the column
+            Gtk.CellRendererText renderer = new Gtk.CellRendererText();
+            renderer.editable = true;
+            renderer.edited.connect((cell, path, text) => {
+                keyserver_cell_edited(cell, path, text, store);
+            });
+            Gtk.TreeViewColumn column = new Gtk.TreeViewColumn.with_attributes(
+                                                _("URL"), renderer,
+                                                "text", Columns.KEYSERVER,
+                                                null);
+            this.keyservers.append_column(column);
+        }
+
+        // Mark this so we can ignore events
+        this.updating_model = true;
+
+        // We try and be inteligent about updating so we don't throw
+        // away selections and stuff like that
+        uint i = 0;
+        Gtk.TreeIter iter;
+        if (store.get_iter_first(out iter)) {
+            bool cont = false;
+            do {
+                string? val;
+                store.get(iter, Columns.KEYSERVER, out val, -1);
+                if (keyservers[i] != null
+                        && val != null
+                        && keyservers[i].collate(val) == 0) {
+                    cont = store.iter_next(ref iter);
+                    i++;
+                } else {
+                    cont = store.remove(ref iter);
+                }
+            } while (cont);
+        }
+
+        // Any remaining extra rows
+        for ( ; keyservers[i] != null; i++) {
+            store.append(out iter, null);
+            store.set(iter, Columns.KEYSERVER, keyservers[i], -1);
+        }
+
+        // Done updating
+        this.updating_model = false;
+    }
+
+    private void on_prefs_keyserver_add_clicked (Gtk.Button button) {
+        AddKeyserverDialog dialog = new AddKeyserverDialog(this);
+
+        if (dialog.run() == Gtk.ResponseType.OK) {
+            string? result = dialog.calculate_keyserver_uri();
+
+            if (result != null) {
+                Gtk.TreeStore store = (Gtk.TreeStore) this.keyservers.get_model();
+                Gtk.TreeIter iter;
+                store.append(out iter, null);
+                store.set(iter, Columns.KEYSERVER, result, -1);
+            }
+        }
+
+        dialog.destroy();
+    }
+
+#else
+
+    private void on_prefs_keyserver_add_clicked (Gtk.Button? button) { }
+    void on_prefs_keyserver_remove_clicked (Gtk.Widget? button) { }
+
+#endif
+
+}
diff --git a/libseahorse/seahorse-add-keyserver.ui b/common/seahorse-add-keyserver.ui
similarity index 64%
rename from libseahorse/seahorse-add-keyserver.ui
rename to common/seahorse-add-keyserver.ui
index 1181ed0..ee165cf 100644
--- a/libseahorse/seahorse-add-keyserver.ui
+++ b/common/seahorse-add-keyserver.ui
@@ -13,21 +13,14 @@
       </row>
     </data>
   </object>
-  <object class="GtkDialog" id="add-keyserver">
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Add Key Server</property>
-    <property name="modal">True</property>
-    <property name="window_position">center-on-parent</property>
-    <property name="default_width">400</property>
-    <property name="type_hint">dialog</property>
-    <property name="skip_taskbar_hint">True</property>
-    <property name="skip_pager_hint">True</property>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox1">
+  <!-- <object class="GtkDialog" id=""> -->
+  <!--   <child internal-child="vbox"> -->
+      <object class="GtkBox" id="add-keyserver">
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <child>
-          <object class="GtkTable" id="table1">
+          <object class="GtkTable">
             <property name="visible">True</property>
             <property name="border_width">5</property>
             <property name="n_rows">2</property>
@@ -35,7 +28,7 @@
             <property name="column_spacing">12</property>
             <property name="row_spacing">6</property>
             <child>
-              <object class="GtkLabel" id="label2">
+              <object class="GtkLabel">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">Key Server Type:</property>
@@ -59,7 +52,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label3">
+              <object class="GtkLabel">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">Host:</property>
@@ -72,8 +65,9 @@
               </packing>
             </child>
             <child>
-              <object class="GtkHBox" id="hbox1">
+              <object class="GtkBox">
                 <property name="visible">True</property>
+                <property name="orientation">horizontal</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkEntry" id="keyserver-host">
@@ -89,11 +83,12 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkHBox" id="port-block">
+                  <object class="GtkBox" id="port-block">
                     <property name="visible">True</property>
+                    <property name="orientation">horizontal</property>
                     <property name="spacing">6</property>
                     <child>
-                      <object class="GtkLabel" id="label4">
+                      <object class="GtkLabel">
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">:</property>
                       </object>
@@ -140,55 +135,7 @@
             <property name="position">1</property>
           </packing>
         </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="cancel">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="ok">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="sensitive">False</property>
-                <property name="can_focus">True</property>
-                <property name="has_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
       </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">cancel</action-widget>
-      <action-widget response="-3">ok</action-widget>
-    </action-widgets>
-  </object>
+    <!-- </child> -->
+  <!-- </object> -->
 </interface>
diff --git a/libseahorse/seahorse-prefs.ui b/common/seahorse-prefs.ui
similarity index 63%
rename from libseahorse/seahorse-prefs.ui
rename to common/seahorse-prefs.ui
index fe577e2..8076ef0 100644
--- a/libseahorse/seahorse-prefs.ui
+++ b/common/seahorse-prefs.ui
@@ -1,50 +1,34 @@
 <?xml version="1.0"?>
 <interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy toplevel-contextual -->
-  <object class="GtkDialog" id="prefs">
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Preferences</property>
-    <property name="type_hint">dialog</property>
-    <signal name="delete_event" handler="on_widget_delete_event"/>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="mainbox">
+  <requires lib="gtk+" version="3.22"/>
+  <!-- <object class="SeahorsePrefs" parent="GtkDialog"> -->
+  <!--   <property name="border_width">5</property> -->
+  <!--   <property name="title" translatable="yes">Preferences</property> -->
+  <!--   <property name="type_hint">dialog</property> -->
+  <!--   <child internal-child="vbox"> -->
+      <object class="GtkBox" id="prefs">
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="vexpand">True</property>
         <property name="spacing">2</property>
         <child>
           <object class="GtkNotebook" id="notebook">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="border_width">5</property>
+            <property name="vexpand">True</property>
             <child>
-              <object class="GtkTable" id="keyserver-tab">
+              <object class="GtkGrid" id="keyserver-tab">
                 <property name="visible">True</property>
                 <property name="border_width">12</property>
-                <property name="n_rows">4</property>
-                <property name="n_columns">2</property>
                 <property name="column_spacing">12</property>
                 <property name="row_spacing">12</property>
                 <child>
-                  <object class="GtkVBox" id="keyserver-publish">
-                    <property name="visible">True</property>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkVBox" id="vbox2">
+                  <object class="GtkBox">
                     <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
                     <property name="spacing">11</property>
                     <child>
-                      <object class="GtkLabel" id="label8">
+                      <object class="GtkLabel">
                         <property name="visible">True</property>
                         <property name="xalign">0</property>
                         <property name="label" translatable="yes">_Find keys via:</property>
@@ -64,7 +48,6 @@
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
                         <property name="use_stock">True</property>
-                        <signal name="clicked" handler="on_prefs_keyserver_add_clicked"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -90,7 +73,8 @@
                     </child>
                   </object>
                   <packing>
-                    <property name="x_options"></property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
                   </packing>
                 </child>
                 <child>
@@ -110,8 +94,8 @@
                     </child>
                   </object>
                   <packing>
+                    <property name="top_attach">0</property>
                     <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
                   </packing>
                 </child>
                 <child>
@@ -123,9 +107,20 @@
                   </object>
                   <packing>
                     <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
+                    <property name="left_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkBox" id="keyserver-publish">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="left_attach">1</property>
                   </packing>
                 </child>
                 <child>
@@ -138,11 +133,8 @@
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
                     <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="y_options"></property>
+                    <property name="left_attach">1</property>
                   </packing>
                 </child>
                 <child>
@@ -155,23 +147,14 @@
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
                     <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options"></property>
+                    <property name="left_attach">1</property>
                   </packing>
                 </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
               </object>
             </child>
             <child type="tab">
-              <object class="GtkLabel" id="label7b">
+              <object class="GtkLabel">
                 <property name="visible">True</property>
                 <property name="label" translatable="yes">Key Servers</property>
               </object>
@@ -190,55 +173,7 @@
             <property name="position">1</property>
           </packing>
         </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="helpbutton1">
-                <property name="label">gtk-help</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" handler="on_widget_help"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="closebutton1">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" handler="on_widget_closed"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
       </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-11">helpbutton1</action-widget>
-      <action-widget response="-7">closebutton1</action-widget>
-    </action-widgets>
-  </object>
+    <!-- </child> -->
+  <!-- </object> -->
 </interface>
diff --git a/data/seahorse.gresource.xml b/data/seahorse.gresource.xml
index 3db0ee5..35e01fd 100644
--- a/data/seahorse.gresource.xml
+++ b/data/seahorse.gresource.xml
@@ -3,10 +3,12 @@
   <gresource prefix="/org/gnome/Seahorse">
     <file alias="seahorse.css">../libseahorse/seahorse.css</file>
 
-    <file alias="seahorse-add-keyserver.ui" 
preprocess="xml-stripblanks">../libseahorse/seahorse-add-keyserver.ui</file>
-    <file alias="seahorse-prefs.ui" preprocess="xml-stripblanks">../libseahorse/seahorse-prefs.ui</file>
     <file alias="seahorse-progress.ui" 
preprocess="xml-stripblanks">../libseahorse/seahorse-progress.ui</file>
 
+    <!-- Common -->
+    <file alias="seahorse-add-keyserver.ui" 
preprocess="xml-stripblanks">../common/seahorse-add-keyserver.ui</file>
+    <file alias="seahorse-prefs.ui" preprocess="xml-stripblanks">../common/seahorse-prefs.ui</file>
+
     <!-- Seahorse -->
     <file alias="seahorse-change-passphrase.ui" 
preprocess="xml-stripblanks">../src/seahorse-change-passphrase.ui</file>
     <file alias="seahorse-generate-select.ui" 
preprocess="xml-stripblanks">../src/seahorse-generate-select.ui</file>
diff --git a/libseahorse/meson.build b/libseahorse/meson.build
index 6a9db39..5c85791 100644
--- a/libseahorse/meson.build
+++ b/libseahorse/meson.build
@@ -18,7 +18,6 @@ libseahorse_sources = [
   'seahorse-object-list.c',
   'seahorse-object-model.c',
   'seahorse-object-widget.c',
-  'seahorse-prefs.c',
   'seahorse-progress.c',
   'seahorse-search-provider.c',
   'seahorse-util.c',
diff --git a/libseahorse/seahorse-key-manager-store.c b/libseahorse/seahorse-key-manager-store.c
index cb5403b..e75495a 100644
--- a/libseahorse/seahorse-key-manager-store.c
+++ b/libseahorse/seahorse-key-manager-store.c
@@ -25,7 +25,6 @@
 #define G_LOG_DOMAIN "seahorse-drag"
 
 #include "seahorse-key-manager-store.h"
-#include "seahorse-prefs.h"
 #include "seahorse-util.h"
 
 #include <string.h>
diff --git a/pgp/seahorse-keyserver-sync.c b/pgp/seahorse-keyserver-sync.c
index 64ee596..324eb09 100644
--- a/pgp/seahorse-keyserver-sync.c
+++ b/pgp/seahorse-keyserver-sync.c
@@ -27,7 +27,6 @@
 
 #include "seahorse-common.h"
 
-#include "libseahorse/seahorse-prefs.h"
 #include "libseahorse/seahorse-progress.h"
 #include "libseahorse/seahorse-util.h"
 #include "libseahorse/seahorse-widget.h"
@@ -96,7 +95,9 @@ on_sync_ok_clicked (GtkButton *button, SeahorseWidget *swidget)
 G_MODULE_EXPORT void
 on_sync_configure_clicked (GtkButton *button, SeahorseWidget *swidget)
 {
-    seahorse_prefs_show (GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name)), "keyserver-tab");
+    SeahorsePrefs *prefs_dialog = seahorse_prefs_new (GTK_WINDOW (seahorse_widget_get_widget (swidget, 
swidget->name)), "keyserver-tab");
+    gtk_dialog_run (GTK_DIALOG (prefs_dialog));
+    gtk_widget_destroy (GTK_DIALOG (prefs_dialog));
 }
 
 static void
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8e78b81..3eb150f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,10 +1,14 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
+common/add-keyserver-dialog.vala
 common/catalog.vala
 common/delete-dialog.vala
 common/exportable.vala
 common/object.vala
 common/passphrase-prompt.vala
+common/prefs.vala
+common/seahorse-add-keyserver.ui
+common/seahorse-prefs.ui
 common/util.vala
 common/validity.vala
 data/seahorse.appdata.xml.in
@@ -21,12 +25,9 @@ gkr/seahorse-gkr-add-item.ui
 gkr/seahorse-gkr-item-properties.ui
 gkr/seahorse-gkr-keyring.ui
 libegg/egg-datetime.c
-libseahorse/seahorse-add-keyserver.ui
 libseahorse/seahorse-application.c
 libseahorse/seahorse-interaction.c
 libseahorse/seahorse-key-manager-store.c
-libseahorse/seahorse-prefs.c
-libseahorse/seahorse-prefs.ui
 libseahorse/seahorse-progress.ui
 libseahorse/seahorse-search-provider.c
 libseahorse/seahorse-util.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index feaf44a..92d125a 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -5,6 +5,7 @@ common/delete-dialog.c
 common/exportable.c
 common/object.c
 common/passphrase-prompt.c
+common/prefs.c
 common/util.c
 common/validity.c
 data/seahorse.desktop.in



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]