summaryrefslogtreecommitdiff
path: root/src/nautilus-bookmark.c
blob: 69e34593734257f632675a6c9a94293525e194d7 (plain)
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
123
124
125
126
127
128
129
130
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */

/* nautilus-bookmark.c - implementation of individual bookmarks.

   Copyright (C) 1999 Eazel, Inc.

   The Gnome Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The Gnome Library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the Gnome Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.

   Authors: John Sullivan <sullivan@eazel.com>
*/

#include "nautilus.h"
#include "nautilus-bookmark.h"


static GtkObjectClass *parent_class = NULL;

/* GtkObject methods.  */

static void
nautilus_bookmark_destroy (GtkObject *object)
{
	NautilusBookmark *bookmark;

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

	bookmark = NAUTILUS_BOOKMARK(object);
	g_string_free(bookmark->name, TRUE);
	g_string_free(bookmark->uri, TRUE);

	/* Chain up */
	if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
		(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}

static void
nautilus_bookmark_finalize (GtkObject *object)
{
	/* Chain up */
	if (GTK_OBJECT_CLASS (parent_class)->finalize != NULL)
		(* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
}


/* Initialization.  */

static void
class_init (NautilusBookmarkClass *class)
{
	GtkObjectClass *object_class;

	object_class = GTK_OBJECT_CLASS (class);
	parent_class = gtk_type_class (GTK_TYPE_OBJECT);

	object_class->destroy = nautilus_bookmark_destroy;
	object_class->finalize = nautilus_bookmark_finalize;
}

static void
init (NautilusBookmark *bookmark)
{
	g_assert(bookmark->name == NULL);
	g_assert(bookmark->uri == NULL);

	bookmark->name = g_string_new(NULL);
	bookmark->uri = g_string_new(NULL);
}


GtkType
nautilus_bookmark_get_type (void)
{
	static GtkType type = 0;

	if (type == 0) {
		static GtkTypeInfo info = {
			"NautilusBookmark",
			sizeof (NautilusBookmark),
			sizeof (NautilusBookmarkClass),
			(GtkClassInitFunc) class_init,
			(GtkObjectInitFunc) init,
			NULL,
			NULL,
			NULL
		};

		type = gtk_type_unique (GTK_TYPE_OBJECT, &info);
	}

	return type;
}


NautilusBookmark *
nautilus_bookmark_new (const gchar *name, const gchar *uri)
{
	NautilusBookmark *new_bookmark;

	new_bookmark = gtk_type_new (NAUTILUS_TYPE_BOOKMARK);
	g_string_assign(new_bookmark->name, name);
	g_string_assign(new_bookmark->uri, uri);

	return new_bookmark;
}

const gchar *
nautilus_bookmark_get_name (const NautilusBookmark *bookmark)
{
	return bookmark->name->str;
}

const gchar *
nautilus_bookmark_get_uri (const NautilusBookmark *bookmark)
{
	return bookmark->uri->str;
}