[gnome-control-center] universal-access: Show the actual keyboard shortcuts
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] universal-access: Show the actual keyboard shortcuts
- Date: Wed, 23 Feb 2011 16:48:33 +0000 (UTC)
commit 1b39b18b7cd19939cb2d25aee0c1ac97e91be641
Author: Bastien Nocera <hadess hadess net>
Date: Wed Feb 23 16:46:53 2011 +0000
universal-access: Show the actual keyboard shortcuts
Rather than hard-coded versions
https://bugzilla.gnome.org/show_bug.cgi?id=642582
panels/universal-access/Makefile.am | 3 +-
panels/universal-access/cc-ua-panel.c | 49 +++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletions(-)
---
diff --git a/panels/universal-access/Makefile.am b/panels/universal-access/Makefile.am
index 5b19b4d..1593768 100644
--- a/panels/universal-access/Makefile.am
+++ b/panels/universal-access/Makefile.am
@@ -6,6 +6,7 @@ INCLUDES = \
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
+ -I$(top_srcdir)/panels/common/ \
$(NULL)
ccpanelsdir = $(PANELS_DIR)
@@ -16,7 +17,7 @@ libuniversal_access_la_SOURCES = \
cc-ua-panel.c \
cc-ua-panel.h
-libuniversal_access_la_LIBADD = $(PANEL_LIBS) $(UNIVERSAL_ACCESS_PANEL_LIBS)
+libuniversal_access_la_LIBADD = $(PANEL_LIBS) $(UNIVERSAL_ACCESS_PANEL_LIBS) $(top_builddir)/panels/common/libshortcuts.la
libuniversal_access_la_LDFLAGS = $(PANEL_LDFLAGS)
uidir = $(pkgdatadir)/ui
diff --git a/panels/universal-access/cc-ua-panel.c b/panels/universal-access/cc-ua-panel.c
index 4fd3783..2ee4a89 100644
--- a/panels/universal-access/cc-ua-panel.c
+++ b/panels/universal-access/cc-ua-panel.c
@@ -27,6 +27,7 @@
#include <gconf/gconf-client.h>
+#include "eggaccelerators.h"
#include "gconf-property-editor.h"
#define WID(b, w) (GtkWidget *) gtk_builder_get_object (b, w)
@@ -46,6 +47,7 @@ struct _CcUaPanelPrivate
GSettings *mouse_settings;
GSettings *font_settings;
GSettings *application_settings;
+ GSettings *mediakeys_settings;
GSList *notify_list;
};
@@ -139,6 +141,12 @@ cc_ua_panel_dispose (GObject *object)
priv->application_settings = NULL;
}
+ if (priv->mediakeys_settings)
+ {
+ g_object_unref (priv->mediakeys_settings);
+ priv->mediakeys_settings = NULL;
+ }
+
G_OBJECT_CLASS (cc_ua_panel_parent_class)->dispose (object);
}
@@ -516,6 +524,38 @@ contrast_combobox_changed_cb (GtkComboBox *box,
}
static void
+cc_ua_panel_set_shortcut_label (CcUaPanel *self,
+ const char *label,
+ const char *key)
+{
+ GtkWidget *widget;
+ char *value;
+ char *text;
+ guint accel_key, keycode;
+ EggVirtualModifierType mods;
+
+ widget = WID (self->priv->builder, label);
+ value = g_settings_get_string (self->priv->mediakeys_settings, key);
+
+ if (value == NULL || *value == '\0') {
+ gtk_label_set_text (GTK_LABEL (widget), _("No shortcut set"));
+ g_free (value);
+ return;
+ }
+ if (egg_accelerator_parse_virtual (value, &accel_key, &keycode, &mods) == FALSE) {
+ gtk_label_set_text (GTK_LABEL (widget), _("No shortcut set"));
+ g_free (value);
+ g_warning ("Failed to parse keyboard shortcut: '%s'", value);
+ return;
+ }
+ g_free (value);
+
+ text = egg_virtual_accelerator_label (accel_key, keycode, mods);
+ gtk_label_set_text (GTK_LABEL (widget), text);
+ g_free (text);
+}
+
+static void
cc_ua_panel_init_seeing (CcUaPanel *self)
{
CcUaPanelPrivate *priv = self->priv;
@@ -536,6 +576,14 @@ cc_ua_panel_init_seeing (CcUaPanel *self)
"screen-magnifier-enabled",
WID (priv->builder, "seeing_zoom_switch"),
NULL);
+
+ cc_ua_panel_set_shortcut_label (self, "seeing_contrast_toggle_keybinding_label", "toggle-contrast");
+ cc_ua_panel_set_shortcut_label (self, "seeing_increase_size_keybinding_label", "increase-text-size");
+ cc_ua_panel_set_shortcut_label (self, "seeing_decrease_size_keybinding_label", "decrease-text-size");
+ cc_ua_panel_set_shortcut_label (self, "seeing_zoom_enable_keybinding_label", "magnifier");
+ cc_ua_panel_set_shortcut_label (self, "seeing_zoom_in_keybinding_label", "magnifier-zoom-in");
+ cc_ua_panel_set_shortcut_label (self, "seeing_zoom_out_keybinding_label", "magnifier-zoom-out");
+ cc_ua_panel_set_shortcut_label (self, "seeing_reader_enable_keybinding_label", "screenreader");
}
@@ -785,6 +833,7 @@ cc_ua_panel_init (CcUaPanel *self)
priv->mouse_settings = g_settings_new ("org.gnome.desktop.a11y.mouse");
priv->font_settings = g_settings_new ("org.gnome.settings-daemon.plugins.xsettings");
priv->application_settings = g_settings_new ("org.gnome.desktop.a11y.applications");
+ priv->mediakeys_settings = g_settings_new ("org.gnome.settings-daemon.plugins.media-keys");
cc_ua_panel_init_keyboard (self);
cc_ua_panel_init_mouse (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]