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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Martin Pitt, Aurélien Gâteau
  • Date: 2012-03-08 18:30:18 UTC
  • Revision ID: package-import@ubuntu.com-20120308183018-ewmdzzyuoll4twgk
Tags: 1:3.3.91-0ubuntu2
* debian/patches/96_sound_nua_panel.patch:
  - change X-GNOME-Keywords to Keywords
  - updated to r273, fixes profile selection issues with bluetooth devices
    (lp: #948236)
* debian/patches/revert_git_drop_library.patch:
  - simplified, don't copy files or create a new dir
* debian/patches/git_zoom_shell_only.patch:
  - hide zoom option when not under gnome-shell since they do nothing 
    on other environments (lp: #945813)

[ Martin Pitt ]
* debian/control.in: Only recommend gnome-session-bin, to avoid pulling in
  all of gnome-session and Unity for derivatives. (LP: #936761)

[ Aurélien Gâteau ]
* debian/patches/60_ubuntu_nav_bar.patch: Use a GtkBox instead of a GtkGrid
  so that GTK_STYLE_CLASS_LINKED works.

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 Intel, Inc.
4
 
 *
5
 
 * The Control Center is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by the
7
 
 * Free Software Foundation; either version 2 of the License, or (at your
8
 
 * option) any later version.
9
 
 *
10
 
 * The Control Center is distributed in the hope that it will be useful, but
11
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13
 
 * for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License along
16
 
 * with the Control Center; if not, write to the Free Software Foundation,
17
 
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 *
19
 
 * Author: Thomas Wood <thos@gnome.org>
20
 
 */
21
 
 
22
 
/**
23
 
 * SECTION:cc-shell
24
 
 * @short_description: Abstract class representing the Control Center shell
25
 
 *
26
 
 * CcShell is an abstract class that represents an instance of a control
27
 
 * center shell. It provides access to some of the properties of the shell
28
 
 * that panels will need to read or change. When a panel is created it has an
29
 
 * instance of CcShell available that represents the current shell.
30
 
 */
31
 
 
32
 
 
33
 
#include "cc-shell.h"
34
 
#include "cc-panel.h"
35
 
 
36
 
G_DEFINE_ABSTRACT_TYPE (CcShell, cc_shell, G_TYPE_OBJECT)
37
 
 
38
 
#define SHELL_PRIVATE(o) \
39
 
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_SHELL, CcShellPrivate))
40
 
 
41
 
struct _CcShellPrivate
42
 
{
43
 
  CcPanel *active_panel;
44
 
};
45
 
 
46
 
enum
47
 
{
48
 
  PROP_ACTIVE_PANEL = 1
49
 
};
50
 
 
51
 
 
52
 
static void
53
 
cc_shell_get_property (GObject    *object,
54
 
                       guint       property_id,
55
 
                       GValue     *value,
56
 
                       GParamSpec *pspec)
57
 
{
58
 
  CcShell *shell = CC_SHELL (object);
59
 
 
60
 
  switch (property_id)
61
 
    {
62
 
    case PROP_ACTIVE_PANEL:
63
 
      g_value_set_object (value, shell->priv->active_panel);
64
 
      break;
65
 
 
66
 
    default:
67
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
68
 
    }
69
 
}
70
 
 
71
 
static void
72
 
cc_shell_set_property (GObject      *object,
73
 
                       guint         property_id,
74
 
                       const GValue *value,
75
 
                       GParamSpec   *pspec)
76
 
{
77
 
  CcShell *shell = CC_SHELL (object);
78
 
 
79
 
  switch (property_id)
80
 
    {
81
 
    case PROP_ACTIVE_PANEL:
82
 
      cc_shell_set_active_panel (shell, g_value_get_object (value));
83
 
      break;
84
 
 
85
 
    default:
86
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
87
 
    }
88
 
}
89
 
 
90
 
static void
91
 
cc_shell_dispose (GObject *object)
92
 
{
93
 
  /* remove and unref the active shell */
94
 
  cc_shell_set_active_panel (CC_SHELL (object), NULL);
95
 
 
96
 
  G_OBJECT_CLASS (cc_shell_parent_class)->dispose (object);
97
 
}
98
 
 
99
 
static void
100
 
cc_shell_class_init (CcShellClass *klass)
101
 
{
102
 
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
103
 
  GParamSpec *pspec;
104
 
 
105
 
  g_type_class_add_private (klass, sizeof (CcShellPrivate));
106
 
 
107
 
  object_class->get_property = cc_shell_get_property;
108
 
  object_class->set_property = cc_shell_set_property;
109
 
  object_class->dispose = cc_shell_dispose;
110
 
 
111
 
  pspec = g_param_spec_object ("active-panel",
112
 
                               "active panel",
113
 
                               "The currently active Panel",
114
 
                               CC_TYPE_PANEL,
115
 
                               G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
116
 
  g_object_class_install_property (object_class, PROP_ACTIVE_PANEL, pspec);
117
 
}
118
 
 
119
 
static void
120
 
cc_shell_init (CcShell *self)
121
 
{
122
 
  self->priv = SHELL_PRIVATE (self);
123
 
}
124
 
 
125
 
/**
126
 
 * cc_shell_get_active_panel:
127
 
 * @shell: A #CcShell
128
 
 *
129
 
 * Get the current active panel
130
 
 *
131
 
 * Returns: a #CcPanel or NULL if no panel is active
132
 
 */
133
 
CcPanel*
134
 
cc_shell_get_active_panel (CcShell *shell)
135
 
{
136
 
  g_return_val_if_fail (CC_IS_SHELL (shell), NULL);
137
 
 
138
 
  return shell->priv->active_panel;
139
 
}
140
 
 
141
 
/**
142
 
 * cc_shell_set_active_panel:
143
 
 * @shell: A #CcShell
144
 
 * @panel: A #CcPanel
145
 
 *
146
 
 * Set the current active panel. If @panel is NULL, then the shell is returned
147
 
 * to a state where no panel is being displayed (for example, the list of panels
148
 
 * may be shown instead).
149
 
 *
150
 
 */
151
 
void
152
 
cc_shell_set_active_panel (CcShell *shell,
153
 
                           CcPanel *panel)
154
 
{
155
 
  g_return_if_fail (CC_IS_SHELL (shell));
156
 
  g_return_if_fail (panel == NULL || CC_IS_PANEL (panel));
157
 
 
158
 
  if (panel != shell->priv->active_panel)
159
 
    {
160
 
      /* remove the old panel */
161
 
      g_object_unref (shell->priv->active_panel);
162
 
      shell->priv->active_panel = NULL;
163
 
 
164
 
      /* set the new panel */
165
 
      if (panel)
166
 
        {
167
 
          shell->priv->active_panel = g_object_ref (panel);
168
 
          g_object_set (G_OBJECT (panel), "shell", shell, NULL);
169
 
        }
170
 
      g_object_notify (G_OBJECT (shell), "active-panel");
171
 
    }
172
 
}
173
 
 
174
 
/**
175
 
 * cc_shell_set_active_panel_from_id:
176
 
 * @shell: A #CcShell
177
 
 * @id: the ID of the panel to set as active
178
 
 * @error: A #GError
179
 
 *
180
 
 * Find a panel corresponding to the specified id and set it as active.
181
 
 *
182
 
 * Returns: #TRUE if the panel was found and set as the active panel
183
 
 */
184
 
gboolean
185
 
cc_shell_set_active_panel_from_id (CcShell      *shell,
186
 
                                   const gchar  *id,
187
 
                                   const gchar **argv,
188
 
                                   GError      **error)
189
 
{
190
 
  CcShellClass *class;
191
 
 
192
 
  g_return_val_if_fail (CC_IS_SHELL (shell), FALSE);
193
 
 
194
 
 
195
 
  class = (CcShellClass *) G_OBJECT_GET_CLASS (shell);
196
 
 
197
 
  if (!class->set_active_panel_from_id)
198
 
    {
199
 
      g_warning ("Object of type \"%s\" does not implement required virtual"
200
 
                 " function \"set_active_panel_from_id\",",
201
 
                 G_OBJECT_TYPE_NAME (shell));
202
 
      return FALSE;
203
 
    }
204
 
  else
205
 
    {
206
 
      return class->set_active_panel_from_id (shell, id, argv, error);
207
 
    }
208
 
}
209
 
 
210
 
/**
211
 
 * cc_shell_get_toplevel:
212
 
 * @shell: A #CcShell
213
 
 *
214
 
 * Gets the toplevel window of the shell.
215
 
 *
216
 
 * Returns: The #GtkWidget of the shell window, or #NULL on error.
217
 
 */
218
 
GtkWidget *
219
 
cc_shell_get_toplevel (CcShell *shell)
220
 
{
221
 
  CcShellClass *klass;
222
 
 
223
 
  g_return_val_if_fail (CC_IS_SHELL (shell), NULL);
224
 
 
225
 
  klass = CC_SHELL_GET_CLASS (shell);
226
 
 
227
 
  if (klass->get_toplevel)
228
 
    {
229
 
        return klass->get_toplevel (shell);
230
 
    }
231
 
 
232
 
  g_warning ("Object of type \"%s\" does not implement required virtual"
233
 
             " function \"get_toplevel\",",
234
 
             G_OBJECT_TYPE_NAME (shell));
235
 
 
236
 
  return NULL;
237
 
}
238
 
 
239
 
void
240
 
cc_shell_embed_widget_in_header (CcShell *shell, GtkWidget *widget)
241
 
{
242
 
  CcShellClass *class;
243
 
 
244
 
  g_return_if_fail (CC_IS_SHELL (shell));
245
 
 
246
 
  class = (CcShellClass *) G_OBJECT_GET_CLASS (shell);
247
 
 
248
 
  if (!class->embed_widget_in_header)
249
 
    {
250
 
      g_warning ("Object of type \"%s\" does not implement required virtual"
251
 
                 " function \"embed_widget_in_header\",",
252
 
                 G_OBJECT_TYPE_NAME (shell));
253
 
      return FALSE;
254
 
    }
255
 
  else
256
 
    {
257
 
      return class->embed_widget_in_header (shell, widget);
258
 
    }
259
 
}