Updated Slovenian translation
[nautilus.git] / libnautilus-extension / nautilus-property-page.c
bloba774915acb7d8c2da880afbf6035b5c1723bb74f
1 /*
2 * nautilus-property-page.h - Property pages exported by
3 * NautilusPropertyProvider objects.
5 * Copyright (C) 2003 Novell, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library 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 GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Author: Dave Camp <dave@ximian.com>
25 #include <config.h>
26 #include "nautilus-property-page.h"
28 #include "nautilus-extension-i18n.h"
30 enum {
31 PROP_0,
32 PROP_NAME,
33 PROP_LABEL,
34 PROP_PAGE,
35 LAST_PROP
38 struct _NautilusPropertyPageDetails {
39 char *name;
40 GtkWidget *label;
41 GtkWidget *page;
44 static GObjectClass *parent_class = NULL;
46 NautilusPropertyPage *
47 nautilus_property_page_new (const char *name,
48 GtkWidget *label,
49 GtkWidget *page_widget)
51 NautilusPropertyPage *page;
53 g_return_val_if_fail (name != NULL, NULL);
54 g_return_val_if_fail (label != NULL && GTK_IS_WIDGET (label), NULL);
55 g_return_val_if_fail (page_widget != NULL && GTK_IS_WIDGET (page_widget),
56 NULL);
58 page = g_object_new (NAUTILUS_TYPE_PROPERTY_PAGE,
59 "name", name,
60 "label", label,
61 "page", page_widget,
62 NULL);
64 return page;
67 static void
68 nautilus_property_page_get_property (GObject *object,
69 guint param_id,
70 GValue *value,
71 GParamSpec *pspec)
73 NautilusPropertyPage *page;
75 page = NAUTILUS_PROPERTY_PAGE (object);
77 switch (param_id) {
78 case PROP_NAME :
79 g_value_set_string (value, page->details->name);
80 break;
81 case PROP_LABEL :
82 g_value_set_object (value, page->details->label);
83 break;
84 case PROP_PAGE :
85 g_value_set_object (value, page->details->page);
86 break;
87 default :
88 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
89 break;
93 static void
94 nautilus_property_page_set_property (GObject *object,
95 guint param_id,
96 const GValue *value,
97 GParamSpec *pspec)
99 NautilusPropertyPage *page;
101 page = NAUTILUS_PROPERTY_PAGE (object);
103 switch (param_id) {
104 case PROP_NAME :
105 g_free (page->details->name);
106 page->details->name = g_strdup (g_value_get_string (value));
107 g_object_notify (object, "name");
108 break;
109 case PROP_LABEL :
110 if (page->details->label) {
111 g_object_unref (page->details->label);
114 page->details->label = g_object_ref (g_value_get_object (value));
115 g_object_notify (object, "label");
116 break;
117 case PROP_PAGE :
118 if (page->details->page) {
119 g_object_unref (page->details->page);
122 page->details->page = g_object_ref (g_value_get_object (value));
123 g_object_notify (object, "page");
124 break;
125 default :
126 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
127 break;
131 static void
132 nautilus_property_page_dispose (GObject *object)
134 NautilusPropertyPage *page;
136 page = NAUTILUS_PROPERTY_PAGE (object);
138 if (page->details->label) {
139 g_object_unref (page->details->label);
140 page->details->label = NULL;
142 if (page->details->page) {
143 g_object_unref (page->details->page);
144 page->details->page = NULL;
148 static void
149 nautilus_property_page_finalize (GObject *object)
151 NautilusPropertyPage *page;
153 page = NAUTILUS_PROPERTY_PAGE (object);
155 g_free (page->details->name);
157 g_free (page->details);
159 G_OBJECT_CLASS (parent_class)->finalize (object);
162 static void
163 nautilus_property_page_instance_init (NautilusPropertyPage *page)
165 page->details = g_new0 (NautilusPropertyPageDetails, 1);
168 static void
169 nautilus_property_page_class_init (NautilusPropertyPageClass *class)
171 parent_class = g_type_class_peek_parent (class);
173 G_OBJECT_CLASS (class)->finalize = nautilus_property_page_finalize;
174 G_OBJECT_CLASS (class)->dispose = nautilus_property_page_dispose;
175 G_OBJECT_CLASS (class)->get_property = nautilus_property_page_get_property;
176 G_OBJECT_CLASS (class)->set_property = nautilus_property_page_set_property;
178 g_object_class_install_property (G_OBJECT_CLASS (class),
179 PROP_NAME,
180 g_param_spec_string ("name",
181 "Name",
182 "Name of the page",
183 NULL,
184 G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE));
185 g_object_class_install_property (G_OBJECT_CLASS (class),
186 PROP_LABEL,
187 g_param_spec_object ("label",
188 "Label",
189 "Label widget to display in the notebook tab",
190 GTK_TYPE_WIDGET,
191 G_PARAM_READWRITE));
192 g_object_class_install_property (G_OBJECT_CLASS (class),
193 PROP_PAGE,
194 g_param_spec_object ("page",
195 "Page",
196 "Widget for the property page",
197 GTK_TYPE_WIDGET,
198 G_PARAM_READWRITE));
201 GType
202 nautilus_property_page_get_type (void)
204 static GType type = 0;
206 if (!type) {
207 const GTypeInfo info = {
208 sizeof (NautilusPropertyPageClass),
209 NULL,
210 NULL,
211 (GClassInitFunc)nautilus_property_page_class_init,
212 NULL,
213 NULL,
214 sizeof (NautilusPropertyPage),
216 (GInstanceInitFunc)nautilus_property_page_instance_init
219 type = g_type_register_static
220 (G_TYPE_OBJECT,
221 "NautilusPropertPage",
222 &info, 0);
225 return type;