~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to libgnome-control-center/cc-panel.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
 
2
 *
 
3
 * Copyright (C) 2010 Red Hat, Inc.
 
4
 * Copyright (C) 2010 Intel, Inc
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
19
 *
 
20
 * Authors: William Jon McCann <jmccann@redhat.com>
 
21
 *          Thomas Wood <thomas.wood@intel.com>
 
22
 *
 
23
 */
 
24
 
 
25
/**
 
26
 * SECTION:cc-panel
 
27
 * @short_description: An abstract class for Control Center panels
 
28
 *
 
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
 
31
 * the shell window.
 
32
 */
 
33
 
 
34
#include "config.h"
 
35
 
 
36
#include "cc-panel.h"
 
37
 
 
38
#include <stdlib.h>
 
39
#include <stdio.h>
 
40
 
 
41
#include <gtk/gtk.h>
 
42
#include <gio/gio.h>
 
43
 
 
44
#define CC_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_PANEL, CcPanelPrivate))
 
45
 
 
46
struct CcPanelPrivate
 
47
{
 
48
  gchar    *id;
 
49
  gchar    *display_name;
 
50
  gchar    *category;
 
51
  gchar    *current_location;
 
52
 
 
53
  gboolean  is_active;
 
54
  CcShell  *shell;
 
55
};
 
56
 
 
57
enum
 
58
{
 
59
    PROP_0,
 
60
    PROP_SHELL,
 
61
};
 
62
 
 
63
G_DEFINE_ABSTRACT_TYPE (CcPanel, cc_panel, GTK_TYPE_BIN)
 
64
 
 
65
static void
 
66
cc_panel_set_property (GObject      *object,
 
67
                       guint         prop_id,
 
68
                       const GValue *value,
 
69
                       GParamSpec   *pspec)
 
70
{
 
71
  CcPanel *panel;
 
72
 
 
73
  panel = CC_PANEL (object);
 
74
 
 
75
  switch (prop_id)
 
76
    {
 
77
    case PROP_SHELL:
 
78
      /* construct only property */
 
79
      panel->priv->shell = g_value_get_object (value);
 
80
      break;
 
81
 
 
82
    default:
 
83
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
84
      break;
 
85
    }
 
86
}
 
87
 
 
88
static void
 
89
cc_panel_get_property (GObject    *object,
 
90
                       guint       prop_id,
 
91
                       GValue     *value,
 
92
                       GParamSpec *pspec)
 
93
{
 
94
  CcPanel *panel;
 
95
 
 
96
  panel = CC_PANEL (object);
 
97
 
 
98
  switch (prop_id)
 
99
    {
 
100
    case PROP_SHELL:
 
101
      g_value_set_object (value, panel->priv->shell);
 
102
      break;
 
103
 
 
104
    default:
 
105
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
106
      break;
 
107
    }
 
108
}
 
109
 
 
110
static void
 
111
cc_panel_finalize (GObject *object)
 
112
{
 
113
  CcPanel *panel;
 
114
 
 
115
  g_return_if_fail (object != NULL);
 
116
  g_return_if_fail (CC_IS_PANEL (object));
 
117
 
 
118
  panel = CC_PANEL (object);
 
119
 
 
120
  g_free (panel->priv->id);
 
121
  g_free (panel->priv->display_name);
 
122
 
 
123
  G_OBJECT_CLASS (cc_panel_parent_class)->finalize (object);
 
124
}
 
125
 
 
126
static void
 
127
cc_panel_get_preferred_width (GtkWidget *widget,
 
128
                              gint      *minimum,
 
129
                              gint      *natural)
 
130
{
 
131
  GtkBin *bin = GTK_BIN (widget);
 
132
  GtkWidget *child;
 
133
 
 
134
  if (minimum != NULL)
 
135
    *minimum = 0;
 
136
 
 
137
  if (natural != NULL)
 
138
    *natural = 0;
 
139
 
 
140
  if ((child = gtk_bin_get_child (bin)))
 
141
    gtk_widget_get_preferred_width (child, minimum, natural);
 
142
}
 
143
 
 
144
static void
 
145
cc_panel_get_preferred_height (GtkWidget *widget,
 
146
                               gint      *minimum,
 
147
                               gint      *natural)
 
148
{
 
149
  GtkBin *bin = GTK_BIN (widget);
 
150
  GtkWidget *child;
 
151
 
 
152
  if (minimum != NULL)
 
153
    *minimum = 0;
 
154
 
 
155
  if (natural != NULL)
 
156
    *natural = 0;
 
157
 
 
158
  if ((child = gtk_bin_get_child (bin)))
 
159
    gtk_widget_get_preferred_height (child, minimum, natural);
 
160
}
 
161
 
 
162
static void
 
163
cc_panel_size_allocate (GtkWidget     *widget,
 
164
                             GtkAllocation *allocation)
 
165
{
 
166
  GtkAllocation child_allocation;
 
167
 
 
168
  gtk_widget_set_allocation (widget, allocation);
 
169
 
 
170
  child_allocation = *allocation;
 
171
 
 
172
  gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)),
 
173
                            &child_allocation);
 
174
}
 
175
 
 
176
static void
 
177
cc_panel_class_init (CcPanelClass *klass)
 
178
{
 
179
  GParamSpec      *pspec;
 
180
  GObjectClass    *object_class = G_OBJECT_CLASS (klass);
 
181
  GtkWidgetClass  *widget_class = GTK_WIDGET_CLASS (klass);
 
182
 
 
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;
 
186
 
 
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;
 
190
 
 
191
  gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (klass));
 
192
 
 
193
  g_type_class_add_private (klass, sizeof (CcPanelPrivate));
 
194
 
 
195
  pspec = g_param_spec_object ("shell",
 
196
                               "Shell",
 
197
                               "Shell the Panel resides in",
 
198
                               CC_TYPE_SHELL,
 
199
                               G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
 
200
                               | G_PARAM_CONSTRUCT_ONLY);
 
201
  g_object_class_install_property (object_class, PROP_SHELL, pspec);
 
202
}
 
203
 
 
204
static void
 
205
cc_panel_init (CcPanel *panel)
 
206
{
 
207
  panel->priv = CC_PANEL_GET_PRIVATE (panel);
 
208
}
 
209
 
 
210
/**
 
211
 * cc_panel_get_shell:
 
212
 * @panel: A #CcPanel
 
213
 *
 
214
 * Get the shell that the panel resides in
 
215
 *
 
216
 * Returns: a #CcShell
 
217
 */
 
218
CcShell *
 
219
cc_panel_get_shell (CcPanel *panel)
 
220
{
 
221
  return panel->priv->shell;
 
222
}
 
223