[PATCH v6 2/3] remote-viewer: Remove unused properties

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

 



The reason for using properties to access those members was to ensure
that they would only be set during the creation of the object. Now that
we removed that restriction, we set private members directly.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx>
---
 src/remote-viewer.c | 101 +++-------------------------------------------------
 1 file changed, 4 insertions(+), 97 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 1cef19e..6b12056 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -66,15 +66,6 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
 #define GET_PRIVATE(o)                                                        \
     (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate))
 
-enum {
-    PROP_0,
-#ifdef HAVE_SPICE_GTK
-    PROP_CONTROLLER,
-    PROP_CTRL_FOREIGN_MENU,
-#endif
-    PROP_OPEN_RECENT_DIALOG
-};
-
 #ifdef HAVE_OVIRT
 static OvirtVm * choose_vm(GtkWindow *main_window,
                            char **vm_name,
@@ -121,56 +112,6 @@ remote_viewer_dispose (GObject *object)
 }
 
 static void
-remote_viewer_get_property (GObject *object, guint property_id,
-                            GValue *value, GParamSpec *pspec)
-{
-    RemoteViewer *self = REMOTE_VIEWER(object);
-    RemoteViewerPrivate *priv = self->priv;
-
-    switch (property_id) {
-#ifdef HAVE_SPICE_GTK
-    case PROP_CONTROLLER:
-        g_value_set_object(value, priv->controller);
-        break;
-    case PROP_CTRL_FOREIGN_MENU:
-        g_value_set_object(value, priv->ctrl_foreign_menu);
-        break;
-#endif
-    case PROP_OPEN_RECENT_DIALOG:
-        g_value_set_boolean(value, priv->open_recent_dialog);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-    }
-}
-
-static void
-remote_viewer_set_property (GObject *object, guint property_id,
-                            const GValue *value, GParamSpec *pspec)
-{
-    RemoteViewer *self = REMOTE_VIEWER(object);
-    RemoteViewerPrivate *priv = self->priv;
-
-    switch (property_id) {
-#ifdef HAVE_SPICE_GTK
-    case PROP_CONTROLLER:
-        g_return_if_fail(priv->controller == NULL);
-        priv->controller = g_value_dup_object(value);
-        break;
-    case PROP_CTRL_FOREIGN_MENU:
-        g_return_if_fail(priv->ctrl_foreign_menu == NULL);
-        priv->ctrl_foreign_menu = g_value_dup_object(value);
-        break;
-#endif
-    case PROP_OPEN_RECENT_DIALOG:
-        priv->open_recent_dialog = g_value_get_boolean(value);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-    }
-}
-
-static void
 remote_viewer_deactivated(VirtViewerApp *app, gboolean connect_error)
 {
     RemoteViewer *self = REMOTE_VIEWER(app);
@@ -248,20 +189,14 @@ remote_viewer_local_command_line (GApplication   *gapp,
         if (opt_args)
             ERROR_GOTO_END(_("\nError: extra arguments given while using Spice controller\n\n"));
 
-        SpiceCtrlController *ctrl = spice_ctrl_controller_new();
-        SpiceCtrlForeignMenu *menu = spice_ctrl_foreign_menu_new();
+        self->priv->controller = spice_ctrl_controller_new();
+        self->priv->ctrl_foreign_menu = spice_ctrl_foreign_menu_new();
 
-        g_object_set(self, "guest-name", "defined by Spice controller",
-                           "controller", ctrl,
-                           "foreign-menu", menu,
-                           NULL);
+        g_object_set(self, "guest-name", "defined by Spice controller", NULL);
 
-        g_signal_connect(menu, "notify::title",
+        g_signal_connect(self->priv->ctrl_foreign_menu, "notify::title",
                          G_CALLBACK(foreign_menu_title_changed),
                          self);
-
-        g_object_unref(ctrl);
-        g_object_unref(menu);
     }
 #endif
 
@@ -288,8 +223,6 @@ remote_viewer_class_init (RemoteViewerClass *klass)
 
     g_type_class_add_private (klass, sizeof (RemoteViewerPrivate));
 
-    object_class->get_property = remote_viewer_get_property;
-    object_class->set_property = remote_viewer_set_property;
     object_class->dispose = remote_viewer_dispose;
 
     g_app_class->local_command_line = remote_viewer_local_command_line;
@@ -299,36 +232,10 @@ remote_viewer_class_init (RemoteViewerClass *klass)
     app_class->add_option_entries = remote_viewer_add_option_entries;
 #ifdef HAVE_SPICE_GTK
     app_class->activate = remote_viewer_activate;
-
     gtk_app_class->window_added = remote_viewer_window_added;
-
-    g_object_class_install_property(object_class,
-                                    PROP_CONTROLLER,
-                                    g_param_spec_object("controller",
-                                                        "Controller",
-                                                        "Spice controller",
-                                                        SPICE_CTRL_TYPE_CONTROLLER,
-                                                        G_PARAM_READWRITE |
-                                                        G_PARAM_STATIC_STRINGS));
-    g_object_class_install_property(object_class,
-                                    PROP_CTRL_FOREIGN_MENU,
-                                    g_param_spec_object("foreign-menu",
-                                                        "Foreign Menu",
-                                                        "Spice foreign menu",
-                                                        SPICE_CTRL_TYPE_FOREIGN_MENU,
-                                                        G_PARAM_READWRITE |
-                                                        G_PARAM_STATIC_STRINGS));
 #else
     (void) gtk_app_class;
 #endif
-    g_object_class_install_property(object_class,
-                                    PROP_OPEN_RECENT_DIALOG,
-                                    g_param_spec_boolean("open-recent-dialog",
-                                                         "Open recent dialog",
-                                                         "Open recent dialog",
-                                                         FALSE,
-                                                         G_PARAM_READWRITE |
-                                                         G_PARAM_STATIC_STRINGS));
 }
 
 static void
-- 
2.5.0

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux