[gnome-control-center/wip/feborges/new-addprinter-dialog: 1/7] printers: Make PpSamba a derivated class of PpHost
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/feborges/new-addprinter-dialog: 1/7] printers: Make PpSamba a derivated class of PpHost
- Date: Sat, 12 Nov 2016 17:53:42 +0000 (UTC)
commit 93c4fc9588516a1da81f6972a9236036e42092a3
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Nov 1 14:25:21 2016 +0100
printers: Make PpSamba a derivated class of PpHost
panels/printers/pp-host.c | 4 +---
panels/printers/pp-samba.c | 40 ++++++++++------------------------------
panels/printers/pp-samba.h | 5 +++--
3 files changed, 14 insertions(+), 35 deletions(-)
---
diff --git a/panels/printers/pp-host.c b/panels/printers/pp-host.c
index fbfb434..eab1c0a 100644
--- a/panels/printers/pp-host.c
+++ b/panels/printers/pp-host.c
@@ -30,7 +30,7 @@ struct _PpHostPrivate
gint port;
};
-G_DEFINE_TYPE (PpHost, pp_host, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_PRIVATE (PpHost, pp_host, G_TYPE_OBJECT);
enum {
PROP_0 = 0,
@@ -106,8 +106,6 @@ pp_host_class_init (PpHostClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (PpHostPrivate));
-
gobject_class->set_property = pp_host_set_property;
gobject_class->get_property = pp_host_get_property;
gobject_class->finalize = pp_host_finalize;
diff --git a/panels/printers/pp-samba.c b/panels/printers/pp-samba.c
index 0aa0363..9c5ee4b 100644
--- a/panels/printers/pp-samba.c
+++ b/panels/printers/pp-samba.c
@@ -33,16 +33,13 @@
struct _PpSambaPrivate
{
GtkWindow *parent;
-
- gchar *hostname;
};
-G_DEFINE_TYPE (PpSamba, pp_samba, G_TYPE_OBJECT);
+G_DEFINE_TYPE (PpSamba, pp_samba, PP_TYPE_HOST);
enum
{
PROP_0 = 0,
- PROP_HOSTNAME,
PROP_PARENT,
};
@@ -53,7 +50,6 @@ pp_samba_finalize (GObject *object)
priv = PP_SAMBA (object)->priv;
- g_free (priv->hostname);
g_object_unref (priv->parent);
G_OBJECT_CLASS (pp_samba_parent_class)->finalize (object);
@@ -69,9 +65,6 @@ pp_samba_get_property (GObject *object,
switch (prop_id)
{
- case PROP_HOSTNAME:
- g_value_set_string (value, self->priv->hostname);
- break;
case PROP_PARENT:
g_value_set_pointer (value, self->priv->parent);
break;
@@ -93,10 +86,6 @@ pp_samba_set_property (GObject *object,
switch (prop_id)
{
- case PROP_HOSTNAME:
- g_free (self->priv->hostname);
- self->priv->hostname = g_value_dup_string (value);
- break;
case PROP_PARENT:
if (self->priv->parent)
g_object_unref (self->priv->parent);
@@ -122,16 +111,6 @@ pp_samba_class_init (PpSambaClass *klass)
gobject_class->finalize = pp_samba_finalize;
/*
- * Used for searching on specific host.
- */
- g_object_class_install_property (gobject_class, PROP_HOSTNAME,
- g_param_spec_string ("hostname",
- "Hostname",
- "The hostname to search",
- NULL,
- G_PARAM_READWRITE));
-
- /*
* Used for authentication dialog.
*/
g_object_class_install_property (gobject_class, PROP_PARENT,
@@ -459,15 +438,12 @@ _pp_samba_get_devices_thread (GSimpleAsyncResult *res,
GObject *object,
GCancellable *cancellable)
{
- PpSambaPrivate *priv;
static GMutex mutex;
- PpSamba *samba = PP_SAMBA (object);
SMBData *data;
SMBCCTX *smb_context;
gchar *dirname;
gchar *path;
-
- priv = samba->priv;
+ gchar *hostname = NULL;
data = g_simple_async_result_get_op_res_gpointer (res);
data->devices = g_new0 (PpDevicesList, 1);
@@ -482,10 +458,11 @@ _pp_samba_get_devices_thread (GSimpleAsyncResult *res,
{
smbc_setOptionUserData (smb_context, data);
- if (priv->hostname)
+ hostname = g_object_get_data (object, "hostname");
+ if (hostname != NULL)
{
- dirname = g_strdup_printf ("smb://%s", priv->hostname);
- path = g_strdup_printf ("//%s", priv->hostname);
+ dirname = g_strdup_printf ("smb://%s", hostname);
+ path = g_strdup_printf ("//%s", hostname);
}
else
{
@@ -516,12 +493,15 @@ pp_samba_get_devices_async (PpSamba *samba,
GSimpleAsyncResult *res;
PpSambaPrivate *priv = samba->priv;
SMBData *data;
+ gchar *hostname;
+
+ hostname = g_object_get_data (G_OBJECT (samba), "hostname");
res = g_simple_async_result_new (G_OBJECT (samba), callback, user_data, pp_samba_get_devices_async);
data = g_new0 (SMBData, 1);
data->devices = NULL;
data->context = g_main_context_default ();
- data->hostname_set = priv->hostname != NULL;
+ data->hostname_set = hostname != NULL;
data->parent = g_object_ref (priv->parent);
data->auth_if_needed = auth_if_needed;
diff --git a/panels/printers/pp-samba.h b/panels/printers/pp-samba.h
index 0385231..7df0056 100644
--- a/panels/printers/pp-samba.h
+++ b/panels/printers/pp-samba.h
@@ -21,6 +21,7 @@
#ifndef __PP_SAMBA_H__
#define __PP_SAMBA_H__
+#include "pp-host.h"
#include "pp-utils.h"
G_BEGIN_DECLS
@@ -38,13 +39,13 @@ typedef struct _PpSambaPrivate PpSambaPrivate;
struct _PpSamba
{
- GObject parent_instance;
+ PpHost parent_instance;
PpSambaPrivate *priv;
};
struct _PpSambaClass
{
- GObjectClass parent_class;
+ PpHostClass parent_class;
};
GType pp_samba_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]