1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2011 Richard Hughes <richard@hughsie.com>
5
* Licensed under the GNU General Public License Version 2
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
#include <glib-object.h>
25
#include <glib/gi18n.h>
27
#include "net-object.h"
29
#define NET_OBJECT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_OBJECT, NetObjectPrivate))
31
struct _NetObjectPrivate
43
static guint signals[SIGNAL_LAST] = { 0 };
44
G_DEFINE_TYPE (NetObject, net_object, G_TYPE_OBJECT)
47
net_object_emit_changed (NetObject *object)
49
g_return_if_fail (NET_IS_OBJECT (object));
50
g_debug ("NetObject: %s emit 'changed'", object->priv->id);
51
g_signal_emit (object, signals[SIGNAL_CHANGED], 0);
55
net_object_emit_removed (NetObject *object)
57
g_return_if_fail (NET_IS_OBJECT (object));
58
g_debug ("NetObject: %s emit 'removed'", object->priv->id);
59
g_signal_emit (object, signals[SIGNAL_REMOVED], 0);
63
net_object_get_id (NetObject *object)
65
g_return_val_if_fail (NET_IS_OBJECT (object), NULL);
66
return object->priv->id;
70
net_object_set_id (NetObject *object, const gchar *id)
72
g_return_if_fail (NET_IS_OBJECT (object));
73
object->priv->id = g_strdup (id);
77
net_object_get_title (NetObject *object)
79
g_return_val_if_fail (NET_IS_OBJECT (object), NULL);
80
return object->priv->title;
84
net_object_set_title (NetObject *object, const gchar *title)
86
g_return_if_fail (NET_IS_OBJECT (object));
87
object->priv->title = g_strdup (title);
91
net_object_finalize (GObject *object)
93
NetObject *nm_object = NET_OBJECT (object);
94
NetObjectPrivate *priv = nm_object->priv;
99
G_OBJECT_CLASS (net_object_parent_class)->finalize (object);
103
net_object_class_init (NetObjectClass *klass)
105
GObjectClass *object_class = G_OBJECT_CLASS (klass);
106
object_class->finalize = net_object_finalize;
108
signals[SIGNAL_CHANGED] =
109
g_signal_new ("changed",
110
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
111
G_STRUCT_OFFSET (NetObjectClass, changed),
112
NULL, NULL, g_cclosure_marshal_VOID__VOID,
114
signals[SIGNAL_REMOVED] =
115
g_signal_new ("removed",
116
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
117
G_STRUCT_OFFSET (NetObjectClass, changed),
118
NULL, NULL, g_cclosure_marshal_VOID__VOID,
121
g_type_class_add_private (klass, sizeof (NetObjectPrivate));
125
net_object_init (NetObject *object)
127
object->priv = NET_OBJECT_GET_PRIVATE (object);
131
net_object_new (void)
134
object = g_object_new (NET_TYPE_OBJECT, NULL);
135
return NET_OBJECT (object);