~ubuntu-branches/ubuntu/precise/gnome-control-center/precise-updates

« back to all changes in this revision

Viewing changes to shell/cc-shell.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Jeremy Bicha, Ken VanDine
  • Date: 2012-02-15 23:16:31 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20120215231631-vk7me0mhofpsq0hp
Tags: 1:3.3.5-0ubuntu1
* Upload the new serie, that will bring in quite some fixes, we revert
  some problematic or risky changes as well
* The new version includes those fixes:
  - "Change Password in User Accounts panel focuses "New password" field, 
     skipping "Current password"" (lp: #821759)
  - The dialog to add online accounts should have a title 
    (lp: #822380)
  - "Remove Profile" button clickable in Color panel when 
     no profile selected (lp: #869603)
  - Move Removable Media into System Info (lp: #835880)
  - Sound preferences: mouse scrolling balance only works for right.
    (lp: #918017)
  - gnome-control-center SIGSEGV in actualize_printers_list() 
    (lp: #903009)
  - selecting preffered applications is not an info (lp: #890143)
  - Add a keyboard shortcut by default for take screenshot of a selection"
    (lp: #625518)
* debian/patches/revert_git_datetime_port.patch:
  - revert use of datetimed, we don't use systemd and ubuntu-system-service 
    doesn't support it yet
* debian/patches/revert_git_drop_library.patch:
  - consolidate "01_allow_external_panels.patch", don't drop the library
    we use it from other components on ubuntu, the patch will be improved
    later to not use a copy of files like it does in that version
* debian/patches/revert_git_stop_using_gconf.patch,
  debian/patches/revert_ua_gsettings.patch,
  debian/patches/revert_git_keyboard_gsettings.patch:
  - revert keyboard porting to gsettings, compiz still use gconf and we
    didn't update gnome-shell to the new serie (yet)

[ Jeremy Bicha ]
* New upstream release (Thanks Rico Tzchichholz!)
* debian/control.in:
  - Bump minimum dependency versions and add libwacom dependency
* debian/rules: Build without -Wl,-z,defs
* debian/watch: Watch for unstable releases
* Refreshed patches:
  - 01_allow_external_panels.patch
  - 04_add_theme_selection.patch
  - 50_ubuntu_systemwide_prefs.patch
  - 58_ubuntu_icon_views_redesign.patch
  - 59_install_gcm_components_on_demand.patch
  - 91_configure_cheese.patch
* Dropped upstream patches:
  - 00git_handle_media_dialog_close.patch
  - 03_show_wacom_under_unity.patch
  - 90_git_sound_tab_order.patch
  - 91_git_build_use_fontconfig.patch
  - 92_git_minimal_output_height.patch
  - 93_change_window_role_on_panel_change.patch
  - 94_git_adding_shortcuts.patch
  - 95_git_ctrlw_shortcut.patch
  - git_extra_keywords.patch

[ Ken VanDine ]
* debian/patches/96_sound_nua_panel.patch
  - refreshed with latest changes from ronoc

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
}