[Xfce4-commits] <libxfce4ui:master> Add functions to handle xfwm4 feature names.
Jérôme Guelfucci
noreply at xfce.org
Sun Dec 30 15:42:50 CET 2012
Updating branch refs/heads/master
to 80dc447a8b9236a3c006b0e38009d35891c18891 (commit)
from b9f459f6c28796d5140b2a75b4ce05f108214716 (commit)
commit 80dc447a8b9236a3c006b0e38009d35891c18891
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date: Sun Dec 30 14:34:44 2012 +0100
Add functions to handle xfwm4 feature names.
This is used to provide translated versions of the strings to other
applications. Sharing the translations in the header was not working due
to textdomain issues.
libxfce4kbd-private/Makefile.am | 5 +-
libxfce4kbd-private/xfce-shortcuts-xfwm4.c | 146 +++++++++++++++++++++++++++
libxfce4kbd-private/xfce-shortcuts-xfwm4.h | 23 ++++
libxfce4kbd-private/xfce-shortcuts.c | 29 ++----
libxfce4kbd-private/xfwm4-shortcut-values.h | 106 -------------------
5 files changed, 180 insertions(+), 129 deletions(-)
diff --git a/libxfce4kbd-private/Makefile.am b/libxfce4kbd-private/Makefile.am
index b9b438f..e5cca7c 100644
--- a/libxfce4kbd-private/Makefile.am
+++ b/libxfce4kbd-private/Makefile.am
@@ -16,7 +16,7 @@ libxfce4kbd_headers = \
xfce-shortcuts-grabber.h \
xfce-shortcut-dialog.h \
xfce-shortcuts.h \
- xfwm4-shortcut-values.h
+ xfce-shortcuts-xfwm4.h
libxfce4kbd_built_sources = \
xfce-shortcuts-marshal.c \
@@ -28,7 +28,8 @@ libxfce4kbd_sources = \
xfce-shortcuts-provider.c \
xfce-shortcuts-grabber.c \
xfce-shortcut-dialog.c \
- xfce-shortcuts.c
+ xfce-shortcuts.c \
+ xfce-shortcuts-xfwm4.c
lib_LTLIBRARIES = libxfce4kbd-private-2.la
diff --git a/libxfce4kbd-private/xfce-shortcuts-xfwm4.c b/libxfce4kbd-private/xfce-shortcuts-xfwm4.c
new file mode 100644
index 0000000..2626d2b
--- /dev/null
+++ b/libxfce4kbd-private/xfce-shortcuts-xfwm4.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2012 Jérôme Guelfucci <jeromeg at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4kbd-private/xfce-shortcuts-xfwm4.h>
+
+typedef struct _ShortcutTemplate ShortcutTemplate;
+
+struct _ShortcutTemplate
+{
+ const gchar *name;
+ const gchar *feature;
+};
+
+const ShortcutTemplate xfwm4_shortcut_values[] = {
+ { N_("Window operations menu"), "popup_menu_key" },
+ { N_("Up"), "up_key" },
+ { N_("Down"), "down_key" },
+ { N_("Left"), "left_key" },
+ { N_("Right"), "right_key" },
+ { N_("Cancel"), "cancel_key" },
+ { N_("Cycle windows"), "cycle_windows_key" },
+ { N_("Cycle windows (Reverse)"), "cycle_reverse_windows_key" },
+ { N_("Switch window for same application"), "switch_window_key" },
+ { N_("Switch application"), "switch_application_key" },
+ { N_("Close window"), "close_window_key" },
+ { N_("Maximize window horizontally"), "maximize_horiz_key" },
+ { N_("Maximize window vertically"), "maximize_vert_key" },
+ { N_("Maximize window"), "maximize_window_key" },
+ { N_("Hide window"), "hide_window_key" },
+ { N_("Move window"), "move_window_key" },
+ { N_("Resize window"), "resize_window_key" },
+ { N_("Shade window"), "shade_window_key" },
+ { N_("Stick window"), "stick_window_key" },
+ { N_("Raise window"), "raise_window_key" },
+ { N_("Lower window"), "lower_window_key" },
+ { N_("Raise or lower window"), "raiselower_window_key" },
+ { N_("Fill window"), "fill_window_key" },
+ { N_("Fill window horizontally"), "fill_horiz_key" },
+ { N_("Fill window vertically"), "fill_vert_key" },
+ { N_("Toggle above"), "above_key" },
+ { N_("Toggle fullscreen"), "fullscreen_key" },
+ { N_("Move window to upper workspace"), "move_window_up_workspace_key" },
+ { N_("Move window to bottom workspace"), "move_window_down_workspace_key" },
+ { N_("Move window to left workspace"), "move_window_left_workspace_key" },
+ { N_("Move window to right workspace"), "move_window_right_workspace_key" },
+ { N_("Move window to previous workspace"), "move_window_prev_workspace_key" },
+ { N_("Move window to next workspace"), "move_window_next_workspace_key" },
+ { N_("Move window to workspace 1"), "move_window_workspace_1_key" },
+ { N_("Move window to workspace 2"), "move_window_workspace_2_key" },
+ { N_("Move window to workspace 3"), "move_window_workspace_3_key" },
+ { N_("Move window to workspace 4"), "move_window_workspace_4_key" },
+ { N_("Move window to workspace 5"), "move_window_workspace_5_key" },
+ { N_("Move window to workspace 6"), "move_window_workspace_6_key" },
+ { N_("Move window to workspace 7"), "move_window_workspace_7_key" },
+ { N_("Move window to workspace 8"), "move_window_workspace_8_key" },
+ { N_("Move window to workspace 9"), "move_window_workspace_9_key" },
+ { N_("Move window to workspace 10"), "move_window_workspace_10_key" },
+ { N_("Move window to workspace 11"), "move_window_workspace_11_key" },
+ { N_("Move window to workspace 12"), "move_window_workspace_12_key" },
+ { N_("Tile window to the top"), "tile_up_key" },
+ { N_("Tile window to the bottom"), "tile_down_key" },
+ { N_("Tile window to the left"), "tile_left_key" },
+ { N_("Tile window to the right"), "tile_right_key" },
+ { N_("Show desktop"), "show_desktop_key" },
+ { N_("Upper workspace"), "up_workspace_key" },
+ { N_("Bottom workspace"), "down_workspace_key" },
+ { N_("Left workspace"), "left_workspace_key" },
+ { N_("Right workspace"), "right_workspace_key" },
+ { N_("Previous workspace"), "prev_workspace_key" },
+ { N_("Next workspace"), "next_workspace_key" },
+ { N_("Workspace 1"), "workspace_1_key" },
+ { N_("Workspace 2"), "workspace_2_key" },
+ { N_("Workspace 3"), "workspace_3_key" },
+ { N_("Workspace 4"), "workspace_4_key" },
+ { N_("Workspace 5"), "workspace_5_key" },
+ { N_("Workspace 6"), "workspace_6_key" },
+ { N_("Workspace 7"), "workspace_7_key" },
+ { N_("Workspace 8"), "workspace_8_key" },
+ { N_("Workspace 9"), "workspace_9_key" },
+ { N_("Workspace 10"), "workspace_10_key" },
+ { N_("Workspace 11"), "workspace_11_key" },
+ { N_("Workspace 12"), "workspace_12_key" },
+ { N_("Add workspace"), "add_workspace_key" },
+ { N_("Add adjacent workspace"), "add_adjacent_workspace_key" },
+ { N_("Delete last workspace"), "del_workspace_key" },
+ { N_("Delete active workspace"), "del_active_workspace_key" },
+ { NULL, NULL }
+};
+
+
+
+const gchar *
+xfce_shortcuts_xfwm4_get_feature_name (const gchar *feature)
+{
+ guint i;
+
+ /* Make sure to use the translations from libxfce4ui */
+ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+ /* We need to get the human readable string of the action name */
+ for (i = 0; xfwm4_shortcut_values[i].name != NULL; ++i)
+ {
+ if (G_UNLIKELY (g_str_equal (xfwm4_shortcut_values[i].feature, feature)))
+ {
+ return _(xfwm4_shortcut_values[i].name);
+ }
+ }
+
+ /* Not a valid feature */
+ return NULL;
+}
+
+GList *
+xfce_shortcuts_xfwm4_get_feature_list (void)
+{
+ GList *list;
+ guint i;
+
+ list = NULL;
+
+ for (i = 0; xfwm4_shortcut_values[i].name != NULL; ++i)
+ list = g_list_prepend (list, (gpointer) xfwm4_shortcut_values[i].feature);
+
+ return g_list_reverse (list);
+}
diff --git a/libxfce4kbd-private/xfce-shortcuts-xfwm4.h b/libxfce4kbd-private/xfce-shortcuts-xfwm4.h
new file mode 100644
index 0000000..f79ea4c
--- /dev/null
+++ b/libxfce4kbd-private/xfce-shortcuts-xfwm4.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2012 Jérôme Guelfucci <jeromeg at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+
+const gchar *xfce_shortcuts_xfwm4_get_feature_name (const gchar *feature);
+GList *xfce_shortcuts_xfwm4_get_feature_list (void);
diff --git a/libxfce4kbd-private/xfce-shortcuts.c b/libxfce4kbd-private/xfce-shortcuts.c
index 85b5cce..ecdf185 100644
--- a/libxfce4kbd-private/xfce-shortcuts.c
+++ b/libxfce4kbd-private/xfce-shortcuts.c
@@ -33,7 +33,7 @@
#include <xfconf/xfconf.h>
#include <libxfce4kbd-private/xfce-shortcuts.h>
-#include <libxfce4kbd-private/xfwm4-shortcut-values.h>
+#include <libxfce4kbd-private/xfce-shortcuts-xfwm4.h>
@@ -123,19 +123,12 @@ xfce_shortcut_conflict_dialog (GtkWindow *parent,
owner_action_name = NULL;
else if (g_utf8_collate (owner, "xfwm4") == 0)
{
- gint j;
-
DBG ("Owner action %s is an xfwm4 action, get the string", owner_action);
/* We need to get the human readable string of the action name */
- for (j = 0; xfwm4_shortcut_values[j].name != NULL; ++j)
- if (G_UNLIKELY (g_str_equal (xfwm4_shortcut_values[j].feature,
- owner_action)))
- {
- owner_action_name =
- g_markup_escape_text (xfwm4_shortcut_values[j].name, -1);
- break;
- }
+ owner_action_name =
+ g_markup_escape_text (xfce_shortcuts_xfwm4_get_feature_name (owner_action), -1);
+
}
else
owner_action_name = g_markup_escape_text (owner_action, -1);
@@ -146,17 +139,11 @@ xfce_shortcut_conflict_dialog (GtkWindow *parent,
other_action_name = NULL;
else if (g_utf8_collate (other, "xfwm4") == 0)
{
- gint j;
-
/* We need to get the human readable string of the action name */
- for (j = 0; xfwm4_shortcut_values[j].name != NULL; ++j)
- if (G_UNLIKELY (g_str_equal (xfwm4_shortcut_values[j].feature,
- other_action)))
- {
- other_action_name =
- g_markup_escape_text (xfwm4_shortcut_values[j].name, -1);
- break;
- }
+
+ other_action_name =
+ g_markup_escape_text (xfce_shortcuts_xfwm4_get_feature_name (other_action), -1);
+
}
else
other_action_name = g_markup_escape_text (other_action, -1);
diff --git a/libxfce4kbd-private/xfwm4-shortcut-values.h b/libxfce4kbd-private/xfwm4-shortcut-values.h
deleted file mode 100644
index 4bd32ef..0000000
--- a/libxfce4kbd-private/xfwm4-shortcut-values.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
- * Copyright (c) 2008 Jannis Pohlmann <jannis at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-#include <glib.h>
-
-typedef struct _ShortcutTemplate ShortcutTemplate;
-
-struct _ShortcutTemplate
-{
- const gchar *name;
- const gchar *feature;
- const gchar *shortcut;
-};
-
-const ShortcutTemplate xfwm4_shortcut_values[] = {
- { N_("Window operations menu"), "popup_menu_key", NULL },
- { N_("Up"), "up_key", NULL },
- { N_("Down"), "down_key", NULL },
- { N_("Left"), "left_key", NULL },
- { N_("Right"), "right_key", NULL },
- { N_("Cancel"), "cancel_key", NULL },
- { N_("Cycle windows"), "cycle_windows_key", NULL },
- { N_("Cycle windows (Reverse)"), "cycle_reverse_windows_key", NULL },
- { N_("Switch window for same application"), "switch_window_key", NULL },
- { N_("Switch application"), "switch_application_key", NULL },
- { N_("Close window"), "close_window_key", NULL },
- { N_("Maximize window horizontally"), "maximize_horiz_key", NULL },
- { N_("Maximize window vertically"), "maximize_vert_key", NULL },
- { N_("Maximize window"), "maximize_window_key", NULL },
- { N_("Hide window"), "hide_window_key", NULL },
- { N_("Move window"), "move_window_key", NULL },
- { N_("Resize window"), "resize_window_key", NULL },
- { N_("Shade window"), "shade_window_key", NULL },
- { N_("Stick window"), "stick_window_key", NULL },
- { N_("Raise window"), "raise_window_key", NULL },
- { N_("Lower window"), "lower_window_key", NULL },
- { N_("Raise or lower window"), "raiselower_window_key", NULL },
- { N_("Fill window"), "fill_window_key", NULL },
- { N_("Fill window horizontally"), "fill_horiz_key", NULL },
- { N_("Fill window vertically"), "fill_vert_key", NULL },
- { N_("Toggle above"), "above_key", NULL },
- { N_("Toggle fullscreen"), "fullscreen_key", NULL },
- { N_("Move window to upper workspace"), "move_window_up_workspace_key", NULL },
- { N_("Move window to bottom workspace"), "move_window_down_workspace_key", NULL },
- { N_("Move window to left workspace"), "move_window_left_workspace_key", NULL },
- { N_("Move window to right workspace"), "move_window_right_workspace_key", NULL },
- { N_("Move window to previous workspace"), "move_window_prev_workspace_key", NULL },
- { N_("Move window to next workspace"), "move_window_next_workspace_key", NULL },
- { N_("Move window to workspace 1"), "move_window_workspace_1_key", NULL, },
- { N_("Move window to workspace 2"), "move_window_workspace_2_key", NULL, },
- { N_("Move window to workspace 3"), "move_window_workspace_3_key", NULL, },
- { N_("Move window to workspace 4"), "move_window_workspace_4_key", NULL, },
- { N_("Move window to workspace 5"), "move_window_workspace_5_key", NULL, },
- { N_("Move window to workspace 6"), "move_window_workspace_6_key", NULL, },
- { N_("Move window to workspace 7"), "move_window_workspace_7_key", NULL, },
- { N_("Move window to workspace 8"), "move_window_workspace_8_key", NULL, },
- { N_("Move window to workspace 9"), "move_window_workspace_9_key", NULL, },
- { N_("Move window to workspace 10"), "move_window_workspace_10_key", NULL, },
- { N_("Move window to workspace 11"), "move_window_workspace_11_key", NULL, },
- { N_("Move window to workspace 12"), "move_window_workspace_12_key", NULL, },
- { N_("Tile window to the top"), "tile_up_key", NULL, },
- { N_("Tile window to the bottom"), "tile_down_key", NULL, },
- { N_("Tile window to the left"), "tile_left_key", NULL, },
- { N_("Tile window to the right"), "tile_right_key", NULL, },
- { N_("Show desktop"), "show_desktop_key", NULL },
- { N_("Upper workspace"), "up_workspace_key", NULL },
- { N_("Bottom workspace"), "down_workspace_key", NULL },
- { N_("Left workspace"), "left_workspace_key", NULL },
- { N_("Right workspace"), "right_workspace_key", NULL },
- { N_("Previous workspace"), "prev_workspace_key", NULL },
- { N_("Next workspace"), "next_workspace_key", NULL },
- { N_("Workspace 1"), "workspace_1_key", NULL, },
- { N_("Workspace 2"), "workspace_2_key", NULL, },
- { N_("Workspace 3"), "workspace_3_key", NULL, },
- { N_("Workspace 4"), "workspace_4_key", NULL, },
- { N_("Workspace 5"), "workspace_5_key", NULL, },
- { N_("Workspace 6"), "workspace_6_key", NULL, },
- { N_("Workspace 7"), "workspace_7_key", NULL, },
- { N_("Workspace 8"), "workspace_8_key", NULL, },
- { N_("Workspace 9"), "workspace_9_key", NULL, },
- { N_("Workspace 10"), "workspace_10_key", NULL, },
- { N_("Workspace 11"), "workspace_11_key", NULL, },
- { N_("Workspace 12"), "workspace_12_key", NULL, },
- { N_("Add workspace"), "add_workspace_key", NULL },
- { N_("Add adjacent workspace"), "add_adjacent_workspace_key", NULL },
- { N_("Delete last workspace"), "del_workspace_key", NULL },
- { N_("Delete active workspace"), "del_active_workspace_key", NULL },
- { NULL, NULL, NULL }
-};
More information about the Xfce4-commits
mailing list