[gnome-control-center/gnome-3-8] Keep using existing translations for input source switching shortcuts
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-8] Keep using existing translations for input source switching shortcuts
- Date: Fri, 24 May 2013 21:43:05 +0000 (UTC)
commit a34b94b38f518e32621e00022dee0808e0a1a9ca
Author: Rui Matos <tiagomatos gmail com>
Date: Thu May 16 16:27:02 2013 +0200
Keep using existing translations for input source switching shortcuts
https://bugzilla.gnome.org/show_bug.cgi?id=700346
panels/common/cc-util.c | 44 ++++++++++++++++++++++++++++++++++
panels/common/cc-util.h | 4 +++
panels/keyboard/Makefile.am | 2 +-
panels/keyboard/cc-keyboard-option.c | 5 ++-
panels/region/cc-input-options.c | 3 +-
5 files changed, 54 insertions(+), 4 deletions(-)
---
diff --git a/panels/common/cc-util.c b/panels/common/cc-util.c
index e51a9d2..eaf265b 100644
--- a/panels/common/cc-util.c
+++ b/panels/common/cc-util.c
@@ -20,7 +20,10 @@
#include "config.h"
#include <string.h>
+#include <glib/gi18n.h>
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <libgnome-desktop/gnome-xkb-info.h>
#include "cc-util.h"
@@ -103,3 +106,44 @@ cc_util_normalize_casefold_and_unaccent (const char *str)
return tmp;
}
+
+typedef struct {
+ const gchar *value;
+ const gchar *description;
+} CcInputSwitcherOptions;
+
+static CcInputSwitcherOptions cc_input_switcher_options[] = {
+ { "grp:lshift_toggle", N_("Left Shift") },
+ { "grp:lalt_toggle", N_("Left Alt") },
+ { "grp:lctrl_toggle", N_("Left Ctrl") },
+ { "grp:rshift_toggle", N_("Right Shift") },
+ { "grp:toggle", N_("Right Alt") },
+ { "grp:rctrl_toggle", N_("Right Ctrl") },
+ { "grp:lalt_lshift_toggle", N_("Left Alt+Shift") },
+ { "grp:lctrl_lshift_toggle", N_("Left Ctrl+Shift") },
+ { "grp:rctrl_rshift_toggle", N_("Right Ctrl+Shift") },
+ { "grp:alt_shift_toggle", N_("Alt+Shift") },
+ { "grp:ctrl_shift_toggle", N_("Ctrl+Shift") },
+ { "grp:ctrl_alt_toggle", N_("Alt+Ctrl") },
+ { "grp:caps_toggle", N_("Caps") },
+ { "grp:shift_caps_toggle", N_("Shift+Caps") },
+ { "grp:alt_caps_toggle", N_("Alt+Caps") },
+ { NULL, NULL }
+};
+
+const gchar *
+cc_util_xkb_info_description_for_option (void *info,
+ const gchar *group_id,
+ const gchar *id)
+{
+ CcInputSwitcherOptions *option;
+
+ if (!g_str_equal (group_id, "grp"))
+ return gnome_xkb_info_description_for_option (info, group_id, id);
+
+ for (option = &cc_input_switcher_options[0]; option->value != NULL; option++)
+ if (g_str_equal (id, option->value))
+ return _(option->description);
+
+ return gnome_xkb_info_description_for_option (info, group_id, id);
+}
diff --git a/panels/common/cc-util.h b/panels/common/cc-util.h
index 42b09ff..232bf49 100644
--- a/panels/common/cc-util.h
+++ b/panels/common/cc-util.h
@@ -25,4 +25,8 @@
char *cc_util_normalize_casefold_and_unaccent (const char *str);
+const gchar *cc_util_xkb_info_description_for_option (void *info,
+ const gchar *group_id,
+ const gchar *id);
+
#endif
diff --git a/panels/keyboard/Makefile.am b/panels/keyboard/Makefile.am
index bd9faea..81cc7bb 100644
--- a/panels/keyboard/Makefile.am
+++ b/panels/keyboard/Makefile.am
@@ -23,7 +23,7 @@ libkeyboard_la_SOURCES = \
keyboard-shortcuts.h
libkeyboard_la_CFLAGS = $(PANEL_CFLAGS) $(KEYBOARD_PANEL_CFLAGS) -I$(top_srcdir)/panels/common/
-libkeyboard_la_LIBADD = $(PANEL_LIBS) $(KEYBOARD_PANEL_LIBS)
+libkeyboard_la_LIBADD = $(PANEL_LIBS) $(KEYBOARD_PANEL_LIBS) $(top_builddir)/panels/common/liblanguage.la
resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies
$(srcdir)/keyboard.gresource.xml)
cc-keyboard-resources.c: keyboard.gresource.xml $(resource_files)
diff --git a/panels/keyboard/cc-keyboard-option.c b/panels/keyboard/cc-keyboard-option.c
index 19aa7d9..2b9ac0f 100644
--- a/panels/keyboard/cc-keyboard-option.c
+++ b/panels/keyboard/cc-keyboard-option.c
@@ -25,6 +25,7 @@
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-xkb-info.h>
+#include "cc-util.h"
#include "cc-keyboard-option.h"
#define CC_TYPE_KEYBOARD_OPTION (cc_keyboard_option_get_type ())
@@ -280,7 +281,7 @@ cc_keyboard_option_constructed (GObject *object)
gtk_list_store_append (self->store, &iter);
gtk_list_store_set (self->store, &iter,
XKB_OPTION_DESCRIPTION_COLUMN,
- gnome_xkb_info_description_for_option (xkb_info, self->group, option_id),
+ cc_util_xkb_info_description_for_option (xkb_info, self->group, option_id),
XKB_OPTION_ID_COLUMN,
option_id,
-1);
@@ -381,7 +382,7 @@ cc_keyboard_option_get_current_value_description (CcKeyboardOption *self)
if (!self->current_value)
return _("Disabled");
- return gnome_xkb_info_description_for_option (xkb_info, self->group, self->current_value);
+ return cc_util_xkb_info_description_for_option (xkb_info, self->group, self->current_value);
}
static void
diff --git a/panels/region/cc-input-options.c b/panels/region/cc-input-options.c
index aa16989..3980a53 100644
--- a/panels/region/cc-input-options.c
+++ b/panels/region/cc-input-options.c
@@ -26,6 +26,7 @@
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-xkb-info.h>
+#include "cc-util.h"
#include "cc-input-options.h"
typedef struct {
@@ -122,7 +123,7 @@ update_modifiers_shortcut (GtkWidget *dialog)
break;
if (p && *p) {
- text = gnome_xkb_info_description_for_option (xkb_info, "grp", *p);
+ text = cc_util_xkb_info_description_for_option (xkb_info, "grp", *p);
gtk_label_set_text (GTK_LABEL (priv->alt_next_source), text);
} else {
gtk_widget_hide (priv->alt_next_source);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]