1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
3
* Copyright (C) 2010 Red Hat, Inc.
4
* Copyright (C) 2010 Intel, Inc
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* Authors: William Jon McCann <jmccann@redhat.com>
21
* Thomas Wood <thomas.wood@intel.com>
27
* @short_description: An abstract class for Control Center panels
29
* CcPanel is an abstract class used to implement panels for the shell. A
30
* panel contains a collection of related settings that are displayed within
44
#define CC_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_PANEL, CcPanelPrivate))
51
gchar *current_location;
63
G_DEFINE_ABSTRACT_TYPE (CcPanel, cc_panel, GTK_TYPE_BIN)
66
cc_panel_set_property (GObject *object,
73
panel = CC_PANEL (object);
78
/* construct only property */
79
panel->priv->shell = g_value_get_object (value);
83
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
89
cc_panel_get_property (GObject *object,
96
panel = CC_PANEL (object);
101
g_value_set_object (value, panel->priv->shell);
105
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
111
cc_panel_finalize (GObject *object)
115
g_return_if_fail (object != NULL);
116
g_return_if_fail (CC_IS_PANEL (object));
118
panel = CC_PANEL (object);
120
g_free (panel->priv->id);
121
g_free (panel->priv->display_name);
123
G_OBJECT_CLASS (cc_panel_parent_class)->finalize (object);
127
cc_panel_get_preferred_width (GtkWidget *widget,
131
GtkBin *bin = GTK_BIN (widget);
140
if ((child = gtk_bin_get_child (bin)))
141
gtk_widget_get_preferred_width (child, minimum, natural);
145
cc_panel_get_preferred_height (GtkWidget *widget,
149
GtkBin *bin = GTK_BIN (widget);
158
if ((child = gtk_bin_get_child (bin)))
159
gtk_widget_get_preferred_height (child, minimum, natural);
163
cc_panel_size_allocate (GtkWidget *widget,
164
GtkAllocation *allocation)
166
GtkAllocation child_allocation;
168
gtk_widget_set_allocation (widget, allocation);
170
child_allocation = *allocation;
172
gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)),
177
cc_panel_class_init (CcPanelClass *klass)
180
GObjectClass *object_class = G_OBJECT_CLASS (klass);
181
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
183
object_class->get_property = cc_panel_get_property;
184
object_class->set_property = cc_panel_set_property;
185
object_class->finalize = cc_panel_finalize;
187
widget_class->get_preferred_width = cc_panel_get_preferred_width;
188
widget_class->get_preferred_height = cc_panel_get_preferred_height;
189
widget_class->size_allocate = cc_panel_size_allocate;
191
gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (klass));
193
g_type_class_add_private (klass, sizeof (CcPanelPrivate));
195
pspec = g_param_spec_object ("shell",
197
"Shell the Panel resides in",
199
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
200
| G_PARAM_CONSTRUCT_ONLY);
201
g_object_class_install_property (object_class, PROP_SHELL, pspec);
205
cc_panel_init (CcPanel *panel)
207
panel->priv = CC_PANEL_GET_PRIVATE (panel);
211
* cc_panel_get_shell:
214
* Get the shell that the panel resides in
216
* Returns: a #CcShell
219
cc_panel_get_shell (CcPanel *panel)
221
return panel->priv->shell;