[seahorse] Catalog: get rid of redundant `window` property.



commit c8b9ec0fa4735315e7aef680486a1b993d89b6a6
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sat May 5 10:54:47 2018 +0200

    Catalog: get rid of redundant `window` property.

 common/catalog.vala              |   11 +++--------
 pgp/seahorse-keyserver-results.c |   10 ++++------
 src/key-manager.vala             |   30 ++++++++++++++----------------
 3 files changed, 21 insertions(+), 30 deletions(-)
---
diff --git a/common/catalog.vala b/common/catalog.vala
index 5e066be..586961c 100644
--- a/common/catalog.vala
+++ b/common/catalog.vala
@@ -20,14 +20,9 @@
 
 namespace Seahorse {
 
-public abstract class Catalog : Gtk.Window {
+public abstract class Catalog : Gtk.ApplicationWindow {
        public const string MENU_OBJECT = "ObjectPopup";
 
-       /* For compatibility with old code */
-       public Gtk.Window window {
-               get { return this; }
-       }
-
        /* Set by the derived classes */
        public string ui_name { construct; get; }
 
@@ -300,7 +295,7 @@ public abstract class Catalog : Gtk.Window {
                        var objects = this.get_selected_objects();
                        Deletable.delete_with_prompt_wait(objects, this);
                } catch (GLib.Error err) {
-                       Util.show_error(window, _("Cannot delete"), err.message);
+                       Util.show_error(this, _("Cannot delete"), err.message);
                }
        }
 
@@ -323,7 +318,7 @@ public abstract class Catalog : Gtk.Window {
                try {
                        Exportable.export_to_prompt_wait(this.get_selected_objects(), this);
                } catch (GLib.Error err) {
-                       Util.show_error(window, _("Couldn’t export keys"), err.message);
+                       Util.show_error(this, _("Couldn’t export keys"), err.message);
                }
        }
 
diff --git a/pgp/seahorse-keyserver-results.c b/pgp/seahorse-keyserver-results.c
index 330f1fd..0bf404d 100644
--- a/pgp/seahorse-keyserver-results.c
+++ b/pgp/seahorse-keyserver-results.c
@@ -150,7 +150,7 @@ on_remote_find (GtkAction* action, SeahorseKeyserverResults* self)
 {
        g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
        g_return_if_fail (GTK_IS_ACTION (action));
-       seahorse_keyserver_search_show (seahorse_catalog_get_window (SEAHORSE_CATALOG (self)));
+       seahorse_keyserver_search_show (GTK_WINDOW (self));
 }
 
 static void
@@ -163,7 +163,7 @@ on_import_complete (GObject *source,
 
        if (!seahorse_pgp_backend_transfer_finish (SEAHORSE_PGP_BACKEND (source),
                                                   result, &error))
-               seahorse_util_handle_error (&error, seahorse_catalog_get_window (self),
+               seahorse_util_handle_error (&error, GTK_WINDOW (self),
                                            _("Couldn’t import keys"));
 
        g_object_unref (self);
@@ -281,7 +281,7 @@ seahorse_keyserver_results_constructed (GObject *obj)
                title = g_strdup_printf (_ ("Remote Keys Containing “%s”"), self->pv->search_string);
        }
 
-       window = seahorse_catalog_get_window (SEAHORSE_CATALOG (self));
+       window = GTK_WINDOW (self);
        gtk_window_set_default_geometry(window, 640, 476);
        gtk_widget_set_events (GTK_WIDGET (window), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
        gtk_window_set_title (window, title);
@@ -474,13 +474,11 @@ on_search_completed (GObject *source,
 {
        SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (user_data);
        GError *error = NULL;
-       GtkWindow *window;
 
        seahorse_pgp_backend_search_remote_finish (NULL, result, &error);
        if (error != NULL) {
-               window = seahorse_catalog_get_window (SEAHORSE_CATALOG (self));
                g_dbus_error_strip_remote_error (error);
-               seahorse_util_show_error (GTK_WIDGET (window),
+               seahorse_util_show_error (GTK_WIDGET (self),
                                          _("The search for keys failed."), error->message);
                g_error_free (error);
        }
diff --git a/src/key-manager.vala b/src/key-manager.vala
index a9864c3..81255f1 100644
--- a/src/key-manager.vala
+++ b/src/key-manager.vala
@@ -74,13 +74,12 @@ public class Seahorse.KeyManager : Catalog {
         );
         this.settings = new GLib.Settings("org.gnome.seahorse.manager");
 
-        Gtk.Window window = this.window;
-        window.set_default_geometry(640, 476);
-        window.set_events(Gdk.EventMask.POINTER_MOTION_MASK
-                          | Gdk.EventMask.POINTER_MOTION_HINT_MASK
-                          | Gdk.EventMask.BUTTON_PRESS_MASK
-                          | Gdk.EventMask.BUTTON_RELEASE_MASK);
-        window.set_title(_("Passwords and Keys"));
+        set_default_geometry(640, 476);
+        set_events(Gdk.EventMask.POINTER_MOTION_MASK
+                   | Gdk.EventMask.POINTER_MOTION_HINT_MASK
+                   | Gdk.EventMask.BUTTON_PRESS_MASK
+                   | Gdk.EventMask.BUTTON_RELEASE_MASK);
+        set_title(_("Passwords and Keys"));
 
         this.collection = setup_sidebar();
 
@@ -130,14 +129,13 @@ public class Seahorse.KeyManager : Catalog {
         show();
 
         // Setup drops
-        Gtk.drag_dest_set(window, Gtk.DestDefaults.ALL, {}, Gdk.DragAction.COPY);
+        Gtk.drag_dest_set(this, Gtk.DestDefaults.ALL, {}, Gdk.DragAction.COPY);
         Gtk.TargetList targets = new Gtk.TargetList(null);
         targets.add_uri_targets(DndTarget.URIS);
         targets.add_text_targets(DndTarget.PLAIN);
-        Gtk.drag_dest_set_target_list(window, targets);
-
-        window.drag_data_received.connect(on_target_drag_data_received);
+        Gtk.drag_dest_set_target_list(this, targets);
 
+        this.drag_data_received.connect(on_target_drag_data_received);
         this.view.button_press_event.connect(on_keymanager_key_list_button_pressed);
         this.view.row_activated.connect(on_keymanager_row_activated);
         this.view.popup_menu.connect(on_keymanager_key_list_popup_menu);
@@ -210,13 +208,13 @@ public class Seahorse.KeyManager : Catalog {
     }
 
     private void on_file_new(Gtk.Action action) {
-        GenerateSelect dialog = new GenerateSelect(this.window);
+        GenerateSelect dialog = new GenerateSelect(this);
         dialog.run();
         dialog.destroy();
     }
 
     private void on_keymanager_new_button(Gtk.Button button) {
-        GenerateSelect dialog = new GenerateSelect(this.window);
+        GenerateSelect dialog = new GenerateSelect(this);
         dialog.run();
         dialog.destroy();
     }
@@ -226,7 +224,7 @@ public class Seahorse.KeyManager : Catalog {
     }
 
     private void import_files(string[]? uris) {
-        ImportDialog dialog = new ImportDialog(this.window);
+        ImportDialog dialog = new ImportDialog(this);
         dialog.add_uris(uris);
         dialog.run();
         dialog.destroy();
@@ -234,7 +232,7 @@ public class Seahorse.KeyManager : Catalog {
 
     private void import_prompt() {
         Gtk.FileChooserDialog dialog =
-            new Gtk.FileChooserDialog(_("Import Key"), this.window,
+            new Gtk.FileChooserDialog(_("Import Key"), this,
                                       Gtk.FileChooserAction.OPEN,
                                       _("_Cancel"), Gtk.ResponseType.CANCEL,
                                       _("_Open"), Gtk.ResponseType.ACCEPT,
@@ -307,7 +305,7 @@ public class Seahorse.KeyManager : Catalog {
     }
 
     private void import_text(string? display_name, string? text) {
-        ImportDialog dialog = new ImportDialog(this.window);
+        ImportDialog dialog = new ImportDialog(this);
         dialog.add_text(display_name, text);
         dialog.run();
         dialog.destroy();


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