File: browser-variable.c

package info (click to toggle)
libgda5 5.2.10-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,168 kB
  • sloc: ansic: 495,319; xml: 10,486; yacc: 5,165; sh: 4,451; makefile: 4,095; php: 1,416; java: 1,300; javascript: 1,298; python: 896; sql: 879; perl: 116
file content (122 lines) | stat: -rw-r--r-- 3,062 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * Copyright (C) 2009 - 2011 Vivien Malerba <malerba@gnome-db.org>
 * Copyright (C) 2010 David King <davidk@openismus.com>
 *
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include <string.h>
#include <glib/gi18n-lib.h>
#include "browser-variable.h"

/* 
 * Main static functions 
 */
static void browser_variable_class_init (BrowserVariableClass *klass);
static void browser_variable_init (BrowserVariable *bvar);
static void browser_variable_dispose (GObject *object);

/* get a pointer to the parents to be able to call their destructor */
static GObjectClass  *parent_class = NULL;

struct _BrowserVariablePrivate {
	GdaHolder *holder;
};

GType
browser_variable_get_type (void)
{
	static GType type = 0;

	if (G_UNLIKELY (type == 0)) {
		static GMutex registering;
		static const GTypeInfo info = {
			sizeof (BrowserVariableClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) browser_variable_class_init,
			NULL,
			NULL,
			sizeof (BrowserVariable),
			0,
			(GInstanceInitFunc) browser_variable_init,
			0
		};

		
		g_mutex_lock (&registering);
		if (type == 0)
			type = g_type_register_static (G_TYPE_OBJECT, "BrowserVariable", &info, 0);
		g_mutex_unlock (&registering);
	}
	return type;
}

static void
browser_variable_class_init (BrowserVariableClass *klass)
{
	GObjectClass   *object_class = G_OBJECT_CLASS (klass);
	parent_class = g_type_class_peek_parent (klass);

	object_class->dispose = browser_variable_dispose;
}

static void
browser_variable_init (BrowserVariable *bvar)
{
	bvar->priv = g_new0 (BrowserVariablePrivate, 1);
	bvar->priv->holder = NULL;
}

/**
 * browser_variable_new
 *
 * Creates a new #BrowserVariable object
 *
 * Returns: the new object
 */
BrowserVariable*
browser_variable_new (GdaHolder *holder)
{
	BrowserVariable *bvar;

	g_return_val_if_fail (GDA_IS_HOLDER (holder), NULL);

	bvar = BROWSER_VARIABLE (g_object_new (BROWSER_TYPE_VARIABLE, NULL));
	bvar->priv->holder = g_object_ref (holder);

	return bvar;
}

static void
browser_variable_dispose (GObject *object)
{
	BrowserVariable *bvar;

	g_return_if_fail (object != NULL);
	g_return_if_fail (BROWSER_IS_VARIABLE (object));

	bvar = BROWSER_VARIABLE (object);
	if (bvar->priv) {
		if (bvar->priv->holder)
			g_object_unref (bvar->priv->holder);

		g_free (bvar->priv);
		bvar->priv = NULL;
	}

	/* parent class */
	parent_class->dispose (object);
}