~ubuntu-branches/ubuntu/saucy/gnome-control-center/saucy-proposed

« back to all changes in this revision

Viewing changes to .pc/revert_new_ibus_keyboard_use.patch/panels/keyboard/cc-keyboard-option.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Sebastien Bacher, Robert Ancell, Iain Lane, Edward Donovan, Rico Tzschichholz, Jeremy Bicha, David Henningsson
  • Date: 2012-11-21 19:32:45 UTC
  • mfrom: (1.1.63)
  • Revision ID: package-import@ubuntu.com-20121121193245-mj61nzz1z4fk3z25
Tags: 1:3.6.3-0ubuntu1
[ Sebastien Bacher ]
* New upstream version
* debian/control.in: recommends libcanberra-pulse (lp: #1004973)
* debian/patches/58_ubuntu_icon_views_redesign.patch:
  - drop most of the changes, keep the different grid size though
    to fit on screen with our extra icons
* debian/patches/91_dont_show_in_unity.patch:
  - dropped, show the upstream printer panel and the layout tab
* debian/patches/revert_git_keyboard_gsettings.patch,
  debian/patches/revert_git_stop_using_gconf.patch:
  - dropped the gconf->gsettings reverts

[ Robert Ancell ]
* New upstream release (LP: #1010317)
* debian/control:
  - Bump build-depends on libgnome-desktop-3-dev, libwacom-dev
  - Add build-depends on libclutter-1.0-dev, libclutter-gtk-1.0-dev,
    libpwquality-dev
  - Drop build-depends on libgnomekbd-dev
* debian/patches/60_ubuntu_nav_bar.patch:
  - Disabled for now, doesn't apply
* debian/patches/revert_ua_gsettings.patch:
  - We can use GSettings for universal access now
* debian/patches/00git_online_accounts_gtkgrid.patch:
* debian/patches/00git_online_accounts_layout.part:
* debian/patches/git_wacom_translations.patch:
  - Applied upstream

[ Iain Lane ]
* Add Build-Depends on libxkbfile-dev
* New upstream release.
* Refresh all patches to apply cleanly.

[ Edward Donovan ]
* debian/source_gnome-control-center.py: Fix for Python 3. (LP: #1013171)

[ Rico Tzschichholz ]
* debian/control.in:
  - Build-depend on gtk-doc-tools instead of docbook directly
  - Bump minimum glib-2.0, gnome-desktop3, gnome-settings-daemon
     and gsettings-desktop-schemas

[ Jeremy Bicha ]
* Dropped more patches applied in new version:
  - git_unmute_sound_event.patch
  - git_fix_big_editable_labels.patch
  - 96_sound_nua_panel.patch
* debian/patches/04_new_appearance_settings.patch:
  - Dropped, this is now packaged separately as gnome-control-center-unity
* debian/patches/10_keyboard_layout_on_unity.patch:
  - Don't change the keyboard panel name when not running Unity
* debian/patches/52_ubuntu_language_list_mods.patch:
  - Don't disable adding current language to the list. While this
    fix shows the current language twice, at least it avoids the
    "Ubuntu suddenly in Chinese" bug (LP: #1035219)
* debian/patches/53_use_ubuntu_help.patch:
  - Only show Ubuntu help when running Unity
* debian/patches/58_hide_gdm_notifications.patch:
  - Hide "Show notifications when locked" settings when running Unity
    since it's a GNOME Shell-specific feature
* debian/patches/63_normal_scrollbar_in_a11y.patch:
  - Drop, overlay-scrollbars should handle this instead
* debian/patches/91_dont_show_in_unity.patch:
  - Hide Printers & Region panels in Unity until we're ready to switch
    to them.
* debian/patches/fix-crash-on-user-panel.patch:
  - Dropped, GNOME says it's obsolete
* debian/rules:
  - Build with -z,defs again
  - Explicitly disable ibus support since ibus 1.4 isn't supported in
    this version
* debian/control.in:
  - Drop ubuntu-docs and gnome-user-guide from recommends to suggests
  - Don't recommend indicators; let's leave that to Unity

[ David Henningsson ]
* sound_nua_panel.patch: Rebase to gnome 3.6 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Red Hat, Inc.
 
3
 *
 
4
 * Written by: Rui Matos <rmatos@redhat.com>
 
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, or (at your option)
 
9
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA
 
19
 * 02110-1301, USA.
 
20
 */
 
21
 
 
22
#include <glib/gi18n.h>
 
23
 
 
24
#define GNOME_DESKTOP_USE_UNSTABLE_API
 
25
#include <libgnome-desktop/gnome-xkb-info.h>
 
26
 
 
27
#include "cc-keyboard-option.h"
 
28
 
 
29
#define CC_TYPE_KEYBOARD_OPTION            (cc_keyboard_option_get_type ())
 
30
#define CC_KEYBOARD_OPTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_KEYBOARD_OPTION, CcKeyboardOption))
 
31
#define CC_KEYBOARD_OPTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  CC_TYPE_KEYBOARD_OPTION, CcKeyboardOptionClass))
 
32
#define CC_IS_KEYBOARD_OPTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_KEYBOARD_OPTION))
 
33
#define CC_IS_KEYBOARD_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  CC_TYPE_KEYBOARD_OPTION))
 
34
#define CC_KEYBOARD_OPTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  CC_TYPE_KEYBOARD_OPTION, CcKeyboardOptionClass))
 
35
 
 
36
#define INPUT_SOURCES_SCHEMA "org.gnome.desktop.input-sources"
 
37
#define XKB_OPTIONS_KEY "xkb-options"
 
38
 
 
39
#define XKB_OPTION_GROUP_LVL3 "lv3"
 
40
#define XKB_OPTION_GROUP_COMP "Compose key"
 
41
 
 
42
enum
 
43
{
 
44
  PROP_0,
 
45
  PROP_GROUP,
 
46
  PROP_DESCRIPTION
 
47
};
 
48
 
 
49
enum
 
50
{
 
51
  CHANGED_SIGNAL,
 
52
  LAST_SIGNAL
 
53
};
 
54
 
 
55
struct _CcKeyboardOption
 
56
{
 
57
  GObject parent_object;
 
58
 
 
59
  gchar *group;
 
60
  gchar *description;
 
61
  gchar *current_value;
 
62
  GtkListStore *store;
 
63
 
 
64
  const gchar * const *whitelist;
 
65
};
 
66
 
 
67
typedef struct _CcKeyboardOptionClass CcKeyboardOptionClass;
 
68
struct _CcKeyboardOptionClass
 
69
{
 
70
  GObjectClass parent_class;
 
71
};
 
72
 
 
73
static guint keyboard_option_signals[LAST_SIGNAL] = { 0 };
 
74
 
 
75
static GnomeXkbInfo *xkb_info = NULL;
 
76
static GSettings *input_sources_settings = NULL;
 
77
static gchar **current_xkb_options = NULL;
 
78
 
 
79
static const gchar *xkb_option_lvl3_whitelist[] = {
 
80
  "lv3:switch",
 
81
  "lv3:menu_switch",
 
82
  "lv3:rwin_switch",
 
83
  "lv3:lalt_switch",
 
84
  "lv3:ralt_switch",
 
85
  "lv3:caps_switch",
 
86
  NULL
 
87
};
 
88
 
 
89
static const gchar *xkb_option_comp_whitelist[] = {
 
90
  "compose:ralt",
 
91
  "compose:rwin",
 
92
  "compose:menu",
 
93
  "compose:lctrl",
 
94
  "compose:rctrl",
 
95
  "compose:caps",
 
96
  NULL
 
97
};
 
98
 
 
99
static GList *objects_list = NULL;
 
100
 
 
101
GType cc_keyboard_option_get_type (void);
 
102
 
 
103
G_DEFINE_TYPE (CcKeyboardOption, cc_keyboard_option, G_TYPE_OBJECT);
 
104
 
 
105
static gboolean
 
106
strv_contains (const gchar * const *strv,
 
107
               const gchar         *str)
 
108
{
 
109
  const gchar * const *p = strv;
 
110
  for (p = strv; *p; p++)
 
111
    if (g_strcmp0 (*p, str) == 0)
 
112
      return TRUE;
 
113
 
 
114
  return FALSE;
 
115
}
 
116
 
 
117
static void
 
118
reload_setting (CcKeyboardOption *self)
 
119
{
 
120
  gchar **iter;
 
121
 
 
122
  for (iter = current_xkb_options; *iter; ++iter)
 
123
    if (strv_contains (self->whitelist, *iter))
 
124
      {
 
125
        if (g_strcmp0 (self->current_value, *iter) != 0)
 
126
          {
 
127
            g_free (self->current_value);
 
128
            self->current_value = g_strdup (*iter);
 
129
            g_signal_emit (self, keyboard_option_signals[CHANGED_SIGNAL], 0);
 
130
          }
 
131
        break;
 
132
      }
 
133
 
 
134
  if (*iter == NULL && self->current_value != NULL)
 
135
    {
 
136
      g_clear_pointer (&self->current_value, g_free);
 
137
      g_signal_emit (self, keyboard_option_signals[CHANGED_SIGNAL], 0);
 
138
    }
 
139
}
 
140
 
 
141
static void
 
142
xkb_options_changed (GSettings *settings,
 
143
                     gchar     *key,
 
144
                     gpointer   data)
 
145
{
 
146
  GList *l;
 
147
 
 
148
  g_strfreev (current_xkb_options);
 
149
  current_xkb_options = g_settings_get_strv (settings, key);
 
150
 
 
151
  for (l = objects_list; l; l = l->next)
 
152
    reload_setting (CC_KEYBOARD_OPTION (l->data));
 
153
}
 
154
 
 
155
static void
 
156
cc_keyboard_option_get_property (GObject    *object,
 
157
                                 guint       prop_id,
 
158
                                 GValue     *value,
 
159
                                 GParamSpec *pspec)
 
160
{
 
161
  CcKeyboardOption *self;
 
162
 
 
163
  self = CC_KEYBOARD_OPTION (object);
 
164
 
 
165
  switch (prop_id)
 
166
    {
 
167
    case PROP_GROUP:
 
168
      g_value_set_string (value, self->group);
 
169
      break;
 
170
    case PROP_DESCRIPTION:
 
171
      g_value_set_string (value, self->description);
 
172
      break;
 
173
    default:
 
174
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
175
      break;
 
176
    }
 
177
}
 
178
 
 
179
static void
 
180
cc_keyboard_option_set_property (GObject      *object,
 
181
                                 guint         prop_id,
 
182
                                 const GValue *value,
 
183
                                 GParamSpec   *pspec)
 
184
{
 
185
  CcKeyboardOption *self;
 
186
 
 
187
  self = CC_KEYBOARD_OPTION (object);
 
188
 
 
189
  switch (prop_id)
 
190
    {
 
191
    case PROP_GROUP:
 
192
      self->group = g_value_dup_string (value);
 
193
      break;
 
194
    case PROP_DESCRIPTION:
 
195
      self->description = g_value_dup_string (value);
 
196
      break;
 
197
    default:
 
198
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
199
      break;
 
200
    }
 
201
}
 
202
 
 
203
static void
 
204
cc_keyboard_option_init (CcKeyboardOption *self)
 
205
{
 
206
}
 
207
 
 
208
static void
 
209
cc_keyboard_option_finalize (GObject *object)
 
210
{
 
211
  CcKeyboardOption *self = CC_KEYBOARD_OPTION (object);
 
212
 
 
213
  g_clear_pointer (&self->group, g_free);
 
214
  g_clear_pointer (&self->description, g_free);
 
215
  g_clear_pointer (&self->current_value, g_free);
 
216
  g_clear_object (&self->store);
 
217
 
 
218
  G_OBJECT_CLASS (cc_keyboard_option_parent_class)->finalize (object);
 
219
}
 
220
 
 
221
static void
 
222
cc_keyboard_option_constructed (GObject *object)
 
223
{
 
224
  GtkTreeIter iter;
 
225
  GList *options, *l;
 
226
  gchar *option_id;
 
227
  CcKeyboardOption *self = CC_KEYBOARD_OPTION (object);
 
228
 
 
229
  G_OBJECT_CLASS (cc_keyboard_option_parent_class)->constructed (object);
 
230
 
 
231
  if (g_str_equal (self->group, XKB_OPTION_GROUP_LVL3))
 
232
    self->whitelist = xkb_option_lvl3_whitelist;
 
233
  else if (g_str_equal (self->group, XKB_OPTION_GROUP_COMP))
 
234
    self->whitelist = xkb_option_comp_whitelist;
 
235
  else
 
236
    g_assert_not_reached ();
 
237
 
 
238
  self->store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
 
239
  gtk_list_store_append (self->store, &iter);
 
240
  gtk_list_store_set (self->store, &iter,
 
241
                      XKB_OPTION_DESCRIPTION_COLUMN, _("Disabled"),
 
242
                      XKB_OPTION_ID_COLUMN, NULL,
 
243
                      -1);
 
244
  options = gnome_xkb_info_get_options_for_group (xkb_info, self->group);
 
245
  for (l = options; l; l = l->next)
 
246
    {
 
247
      option_id = l->data;
 
248
      if (strv_contains (self->whitelist, option_id))
 
249
        {
 
250
          gtk_list_store_append (self->store, &iter);
 
251
          gtk_list_store_set (self->store, &iter,
 
252
                              XKB_OPTION_DESCRIPTION_COLUMN,
 
253
                              gnome_xkb_info_description_for_option (xkb_info, self->group, option_id),
 
254
                              XKB_OPTION_ID_COLUMN,
 
255
                              option_id,
 
256
                              -1);
 
257
        }
 
258
    }
 
259
  g_list_free (options);
 
260
 
 
261
  reload_setting (self);
 
262
}
 
263
 
 
264
static void
 
265
cc_keyboard_option_class_init (CcKeyboardOptionClass *klass)
 
266
{
 
267
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
268
 
 
269
  gobject_class->get_property = cc_keyboard_option_get_property;
 
270
  gobject_class->set_property = cc_keyboard_option_set_property;
 
271
  gobject_class->finalize = cc_keyboard_option_finalize;
 
272
  gobject_class->constructed = cc_keyboard_option_constructed;
 
273
 
 
274
  g_object_class_install_property (gobject_class,
 
275
                                   PROP_GROUP,
 
276
                                   g_param_spec_string ("group",
 
277
                                                        "group",
 
278
                                                        "xkb option group identifier",
 
279
                                                        NULL,
 
280
                                                        G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
 
281
  g_object_class_install_property (gobject_class,
 
282
                                   PROP_DESCRIPTION,
 
283
                                   g_param_spec_string ("description",
 
284
                                                        "description",
 
285
                                                        "translated option description",
 
286
                                                        NULL,
 
287
                                                        G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 
288
 
 
289
  keyboard_option_signals[CHANGED_SIGNAL] = g_signal_new ("changed",
 
290
                                                          CC_TYPE_KEYBOARD_OPTION,
 
291
                                                          G_SIGNAL_RUN_LAST,
 
292
                                                          0, NULL, NULL, NULL,
 
293
                                                          G_TYPE_NONE,
 
294
                                                          0);
 
295
}
 
296
 
 
297
GList *
 
298
cc_keyboard_option_get_all (void)
 
299
{
 
300
  if (objects_list)
 
301
    return objects_list;
 
302
 
 
303
  xkb_info = gnome_xkb_info_new ();
 
304
 
 
305
  input_sources_settings = g_settings_new (INPUT_SOURCES_SCHEMA);
 
306
 
 
307
  g_signal_connect (input_sources_settings, "changed::" XKB_OPTIONS_KEY,
 
308
                    G_CALLBACK (xkb_options_changed), NULL);
 
309
 
 
310
  xkb_options_changed (input_sources_settings, XKB_OPTIONS_KEY, NULL);
 
311
 
 
312
  objects_list = g_list_prepend (objects_list,
 
313
                                 g_object_new (CC_TYPE_KEYBOARD_OPTION,
 
314
                                               "group", XKB_OPTION_GROUP_LVL3,
 
315
                                               "description", _("Alternative Characters Key"),
 
316
                                               NULL));
 
317
  objects_list = g_list_prepend (objects_list,
 
318
                                 g_object_new (CC_TYPE_KEYBOARD_OPTION,
 
319
                                               "group", XKB_OPTION_GROUP_COMP,
 
320
                                               "description", _("Compose Key"),
 
321
                                               NULL));
 
322
  return objects_list;
 
323
}
 
324
 
 
325
const gchar *
 
326
cc_keyboard_option_get_description (CcKeyboardOption *self)
 
327
{
 
328
  g_return_val_if_fail (CC_IS_KEYBOARD_OPTION (self), NULL);
 
329
 
 
330
  return self->description;
 
331
}
 
332
 
 
333
GtkListStore *
 
334
cc_keyboard_option_get_store (CcKeyboardOption *self)
 
335
{
 
336
  g_return_val_if_fail (CC_IS_KEYBOARD_OPTION (self), NULL);
 
337
 
 
338
  return self->store;
 
339
}
 
340
 
 
341
const gchar *
 
342
cc_keyboard_option_get_current_value_description (CcKeyboardOption *self)
 
343
{
 
344
  g_return_val_if_fail (CC_IS_KEYBOARD_OPTION (self), NULL);
 
345
 
 
346
  if (!self->current_value)
 
347
    return _("Disabled");
 
348
 
 
349
  return gnome_xkb_info_description_for_option (xkb_info, self->group, self->current_value);
 
350
}
 
351
 
 
352
static void
 
353
remove_value (const gchar *value)
 
354
{
 
355
  gchar **p;
 
356
 
 
357
  for (p = current_xkb_options; *p; ++p)
 
358
    if (g_str_equal (*p, value))
 
359
      {
 
360
        g_free (*p);
 
361
        break;
 
362
      }
 
363
 
 
364
  for (++p; *p; ++p)
 
365
    *(p - 1) = *p;
 
366
 
 
367
  *(p - 1) = NULL;
 
368
}
 
369
 
 
370
static void
 
371
add_value (const gchar *value)
 
372
{
 
373
  gchar **new_xkb_options;
 
374
  gchar **a, **b;
 
375
 
 
376
  new_xkb_options = g_new0 (gchar *, g_strv_length (current_xkb_options) + 2);
 
377
 
 
378
  a = new_xkb_options;
 
379
  for (b = current_xkb_options; *b; ++a, ++b)
 
380
    *a = g_strdup (*b);
 
381
 
 
382
  *a = g_strdup (value);
 
383
 
 
384
  g_strfreev (current_xkb_options);
 
385
  current_xkb_options = new_xkb_options;
 
386
}
 
387
 
 
388
static void
 
389
replace_value (const gchar *old,
 
390
               const gchar *new)
 
391
{
 
392
  gchar **iter;
 
393
 
 
394
  if (g_str_equal (old, new))
 
395
    return;
 
396
 
 
397
  for (iter = current_xkb_options; *iter; ++iter)
 
398
    if (g_str_equal (*iter, old))
 
399
      {
 
400
        g_free (*iter);
 
401
        *iter = g_strdup (new);
 
402
        break;
 
403
      }
 
404
}
 
405
 
 
406
void
 
407
cc_keyboard_option_set_selection (CcKeyboardOption *self,
 
408
                                  GtkTreeIter      *iter)
 
409
{
 
410
  gchar *new_value = NULL;
 
411
 
 
412
  g_return_if_fail (CC_IS_KEYBOARD_OPTION (self));
 
413
 
 
414
  gtk_tree_model_get (GTK_TREE_MODEL (self->store), iter,
 
415
                      XKB_OPTION_ID_COLUMN, &new_value,
 
416
                      -1);
 
417
 
 
418
  if (!new_value)
 
419
    {
 
420
      if (self->current_value)
 
421
        remove_value (self->current_value);
 
422
    }
 
423
  else
 
424
    {
 
425
      if (self->current_value)
 
426
        replace_value (self->current_value, new_value);
 
427
      else
 
428
        add_value (new_value);
 
429
    }
 
430
 
 
431
  g_settings_set_strv (input_sources_settings, XKB_OPTIONS_KEY,
 
432
                       (const gchar * const *) current_xkb_options);
 
433
 
 
434
  g_free (new_value);
 
435
}
 
436
 
 
437
void
 
438
cc_keyboard_option_clear_all (void)
 
439
{
 
440
  GList *l;
 
441
 
 
442
  for (l = objects_list; l; l = l->next)
 
443
    g_object_unref (l->data);
 
444
 
 
445
  g_clear_pointer (&objects_list, g_list_free);
 
446
  g_clear_pointer (&current_xkb_options, g_strfreev);
 
447
  g_clear_object (&input_sources_settings);
 
448
  g_clear_object (&xkb_info);
 
449
}