region: Removal of the Layouts tab

https://bugzilla.gnome.org/show_bug.cgi?id=662489
This commit is contained in:
Rui Matos 2012-05-16 23:22:02 +02:00 committed by Bastien Nocera
parent bfaeb6a41d
commit 0fb0d6139b
13 changed files with 7 additions and 2300 deletions

View file

@ -114,9 +114,8 @@ PKG_CHECK_MODULES(POWER_PANEL, $COMMON_MODULES upower-glib >= 0.9.1
PKG_CHECK_MODULES(COLOR_PANEL, $COMMON_MODULES colord >= 0.1.8)
PKG_CHECK_MODULES(PRINTERS_PANEL, $COMMON_MODULES
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
PKG_CHECK_MODULES(REGION_PANEL, $COMMON_MODULES libgnomekbd >= 2.91.91
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
libxklavier >= 5.1 libgnomekbdui >= 2.91.91)
PKG_CHECK_MODULES(REGION_PANEL, $COMMON_MODULES
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
PKG_CHECK_MODULES(SCREEN_PANEL, $COMMON_MODULES)
PKG_CHECK_MODULES(SOUND_PANEL, $COMMON_MODULES libxml-2.0
libcanberra-gtk3 >= $CANBERRA_REQUIRED_VERSION

View file

@ -25,12 +25,7 @@ libregion_la_SOURCES = \
gnome-region-panel-system.h \
gnome-region-panel-input.c \
gnome-region-panel-input.h \
gnome-region-panel-xkb.c \
gnome-region-panel-xkblt.c \
gnome-region-panel-xkbltadd.c \
gnome-region-panel-xkbot.c \
gnome-region-panel-xkbpv.c \
gnome-region-panel-xkb.h
$(NULL)
libregion_la_LIBADD = $(PANEL_LIBS) $(REGION_PANEL_LIBS) $(builddir)/../common/liblanguage.la
@ -41,9 +36,8 @@ libregion_la_LDFLAGS = $(PANEL_LDFLAGS)
uidir = $(pkgdatadir)/ui
ui_DATA = \
gnome-region-panel.ui \
gnome-region-panel-layout-chooser.ui \
gnome-region-panel-input-chooser.ui \
gnome-region-panel-options-dialog.ui
$(NULL)
desktopdir = $(datadir)/applications
Desktop_in_files = gnome-region-panel.desktop.in

View file

@ -22,7 +22,6 @@
#include "cc-region-panel.h"
#include <gtk/gtk.h>
#include "gnome-region-panel-xkb.h"
#include "gnome-region-panel-input.h"
#include "gnome-region-panel-lang.h"
#include "gnome-region-panel-formats.h"
@ -161,7 +160,6 @@ cc_region_panel_init (CcRegionPanel * self)
gtk_widget_reparent (prefs_widget, GTK_WIDGET (self));
setup_xkb_tabs (priv->builder);
setup_input_tabs (priv->builder, self);
setup_language (priv->builder);
setup_formats (priv->builder);

View file

@ -1,180 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<object class="GtkListStore" id="layout_list_model">
<columns>
<!-- column-name sort_order -->
<column type="gchararray"/>
<!-- column-name visible -->
<column type="gchararray"/>
<!-- column-name xkb_id -->
<column type="gchararray"/>
<!-- column-name country_desc -->
<column type="gchararray"/>
<!-- column-name language_desc -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkTreeModelFilter" id="filtered_layout_list_model">
<property name="child_model">layout_list_model</property>
</object>
<object class="GtkDialog" id="xkb_layout_chooser">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Choose a Layout</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="hbtnBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="btnPreview">
<property name="label" translatable="yes">Preview</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="secondary">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnCancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnOk">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkVBox" id="vbox40">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="spacing">6</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Select an input source to add</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">etched-in</property>
<property name="min_content_width">450</property>
<property name="min_content_height">250</property>
<child>
<object class="GtkTreeView" id="xkb_filtered_layouts_list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">filtered_layout_list_model</property>
<property name="headers_visible">False</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="xkb_layout_filter">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="secondary-icon-name">edit-find-symbolic</property>
<property name="secondary-icon-activatable">False</property>
<property name="secondary-icon-sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="1">btnPreview</action-widget>
<action-widget response="-5">btnOk</action-widget>
<action-widget response="-6">btnCancel</action-widget>
</action-widgets>
</object>
</interface>

View file

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<object class="GtkDialog" id="xkb_options_dialog">
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Keyboard Layout Options</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">550</property>
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog_vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkScrolledWindow" id="options_scroll">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">5</property>
<property name="shadow_type">out</property>
<child>
<object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkVBox" id="options_vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-7">button2</action-widget>
</action-widgets>
</object>
</interface>

View file

@ -29,13 +29,13 @@
#include <glib/gi18n.h>
#include <libgnomekbd/gkbd-keyboard-config.h>
#include "cc-common-language.h"
#include "gdm-languages.h"
#include "gnome-region-panel-system.h"
#include "gnome-region-panel-xkb.h"
static GSettings *locale_settings, *xkb_settings;
#define WID(s) GTK_WIDGET(gtk_builder_get_object (dialog, s))
static GSettings *locale_settings;
static GDBusProxy *localed_proxy;
static GPermission *localed_permission;
@ -130,64 +130,6 @@ system_update_language (GtkBuilder *dialog, const gchar *language)
update_copy_button (dialog);
}
static void
xkb_settings_changed (GSettings *settings,
const gchar *key,
GtkBuilder *dialog)
{
guint i;
GString *disp, *list, *variants;
GtkWidget *label;
gchar **layouts;
layouts = g_settings_get_strv (settings, "layouts");
if (layouts == NULL)
return;
label = WID ("user_input_source");
disp = g_string_new ("");
list = g_string_new ("");
variants = g_string_new ("");
for (i = 0; layouts[i]; i++) {
gchar *utf_visible;
char **split;
gchar *layout, *variant;
utf_visible = xkb_layout_description_utf8 (layouts[i]);
if (disp->str[0] != '\0')
g_string_append (disp, ", ");
g_string_append (disp, utf_visible ? utf_visible : layouts[i]);
g_free (utf_visible);
split = g_strsplit_set (layouts[i], " \t", 2);
if (split == NULL || split[0] == NULL)
continue;
layout = split[0];
variant = split[1];
if (list->str[0] != '\0')
g_string_append (list, ",");
g_string_append (list, layout);
if (variants->str[0] != '\0')
g_string_append (variants, ",");
g_string_append (variants, variant ? variant : "");
g_strfreev (split);
}
g_strfreev (layouts);
g_object_set_data_full (G_OBJECT (label), "input_source", g_string_free (list, FALSE), g_free);
g_object_set_data_full (G_OBJECT (label), "input_variants", g_string_free (variants, FALSE), g_free);
gtk_label_set_text (GTK_LABEL (label), disp->str);
g_string_free (disp, TRUE);
update_copy_button (dialog);
}
static void
update_property (GDBusProxy *proxy,
const char *property)
@ -223,11 +165,6 @@ on_localed_properties_changed (GDBusProxy *proxy,
GtkBuilder *dialog)
{
GVariant *v;
GtkWidget *label;
const char *layout;
char **layouts;
GString *disp;
guint i;
if (invalidated_properties != NULL) {
guint i;
@ -287,33 +224,6 @@ on_localed_properties_changed (GDBusProxy *proxy,
g_variant_unref (v);
}
label = WID ("system_input_source");
v = g_dbus_proxy_get_cached_property (proxy, "X11Layout");
if (v) {
layout = g_variant_get_string (v, NULL);
g_object_set_data_full (G_OBJECT (label), "input_source", g_strdup (layout), g_free);
} else {
g_object_set_data_full (G_OBJECT (label), "input_source", NULL, g_free);
update_copy_button (dialog);
return;
}
disp = g_string_new ("");
layouts = g_strsplit (layout, ",", -1);
for (i = 0; layouts[i]; i++) {
gchar *utf_visible;
utf_visible = xkb_layout_description_utf8 (layouts[i]);
if (disp->str[0] != '\0')
disp = g_string_append (disp, ", ");
disp = g_string_append (disp, utf_visible ? utf_visible : layouts[i]);
g_free (utf_visible);
}
gtk_label_set_text (GTK_LABEL (label), disp->str);
g_string_free (disp, TRUE);
g_variant_unref (v);
update_copy_button (dialog);
}
@ -468,11 +378,6 @@ setup_system (GtkBuilder *dialog)
G_CALLBACK (locale_settings_changed), dialog);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, locale_settings);
xkb_settings = g_settings_new (GKBD_KEYBOARD_SCHEMA);
g_signal_connect (xkb_settings, "changed::layouts",
G_CALLBACK (xkb_settings_changed), dialog);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, xkb_settings);
/* Display user settings */
language = cc_common_language_get_current_language ();
system_update_language (dialog, language);
@ -480,8 +385,6 @@ setup_system (GtkBuilder *dialog)
locale_settings_changed (locale_settings, "region", dialog);
xkb_settings_changed (xkb_settings, "layouts", dialog);
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
g_dbus_proxy_new (bus,
G_DBUS_PROXY_FLAGS_NONE,

View file

@ -1,190 +0,0 @@
/* gnome-region-panel-xkb.c
* Copyright (C) 2003-2007 Sergey V. Udaltsov
*
* Written by: Sergey V. Udaltsov <svu@gnome.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, 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <gdk/gdkx.h>
#include <glib/gi18n.h>
#include "gnome-region-panel-xkb.h"
#include <libgnomekbd/gkbd-desktop-config.h>
XklEngine *engine;
XklConfigRegistry *config_registry;
GkbdKeyboardConfig initial_config;
GkbdDesktopConfig desktop_config;
GSettings *xkb_keyboard_settings;
GSettings *xkb_desktop_settings;
char *
xci_desc_to_utf8 (const XklConfigItem * ci)
{
gchar *dd = g_strdup (ci->description);
gchar *sd = g_strstrip (dd);
gchar *rv = g_strdup (sd[0] == 0 ? ci->name : sd);
g_free (dd);
return rv;
}
static void
cleanup_xkb_tabs (GtkBuilder * dialog,
GObject *where_the_object_wa)
{
gkbd_desktop_config_term (&desktop_config);
gkbd_keyboard_config_term (&initial_config);
g_object_unref (G_OBJECT (config_registry));
config_registry = NULL;
/* Don't unref it here, or we'll crash if open the panel again */
engine = NULL;
g_object_unref (G_OBJECT (xkb_keyboard_settings));
g_object_unref (G_OBJECT (xkb_desktop_settings));
xkb_keyboard_settings = NULL;
xkb_desktop_settings = NULL;
}
static void
reset_to_defaults (GtkWidget * button, GtkBuilder * dialog)
{
GkbdKeyboardConfig empty_kbd_config;
gkbd_keyboard_config_init (&empty_kbd_config, engine);
gkbd_keyboard_config_save (&empty_kbd_config);
gkbd_keyboard_config_term (&empty_kbd_config);
g_settings_reset (xkb_desktop_settings,
GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP);
/* all the rest is g-s-d's business */
}
static void
chk_new_windows_inherit_layout_toggled (GtkWidget *
chk_new_windows_inherit_layout,
GtkBuilder * dialog)
{
xkb_save_default_group (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON
(chk_new_windows_inherit_layout)) ? -1 :
0);
}
void
setup_xkb_tabs (GtkBuilder * dialog)
{
GtkWidget *widget;
GtkStyleContext *context;
GtkWidget *chk_new_windows_inherit_layout;
chk_new_windows_inherit_layout = WID ("chk_new_windows_inherit_layout");
xkb_desktop_settings = g_settings_new (GKBD_DESKTOP_SCHEMA);
xkb_keyboard_settings = g_settings_new (GKBD_KEYBOARD_SCHEMA);
engine =
xkl_engine_get_instance (GDK_DISPLAY_XDISPLAY
(gdk_display_get_default ()));
config_registry = xkl_config_registry_get_instance (engine);
gkbd_desktop_config_init (&desktop_config, engine);
gkbd_desktop_config_load (&desktop_config);
xkl_config_registry_load (config_registry,
desktop_config.load_extra_items);
gkbd_keyboard_config_init (&initial_config, engine);
gkbd_keyboard_config_load_from_x_initial (&initial_config, NULL);
/* Set initial state */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("chk_separate_group_per_window")),
g_settings_get_boolean (xkb_desktop_settings,
GKBD_DESKTOP_CONFIG_KEY_GROUP_PER_WINDOW));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chk_new_windows_inherit_layout),
xkb_get_default_group () < 0);
g_settings_bind (xkb_desktop_settings,
GKBD_DESKTOP_CONFIG_KEY_GROUP_PER_WINDOW,
WID ("chk_separate_group_per_window"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (xkb_desktop_settings,
GKBD_DESKTOP_CONFIG_KEY_GROUP_PER_WINDOW,
WID ("chk_new_windows_inherit_layout"), "sensitive",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (xkb_desktop_settings,
GKBD_DESKTOP_CONFIG_KEY_GROUP_PER_WINDOW,
WID ("chk_new_windows_default_layout"), "sensitive",
G_SETTINGS_BIND_DEFAULT);
xkb_layouts_prepare_selected_tree (dialog);
xkb_layouts_fill_selected_tree (dialog);
xkb_layouts_register_buttons_handlers (dialog);
g_signal_connect (G_OBJECT (WID ("xkb_reset_to_defaults")),
"clicked", G_CALLBACK (reset_to_defaults),
dialog);
g_signal_connect (G_OBJECT (chk_new_windows_inherit_layout),
"toggled",
G_CALLBACK
(chk_new_windows_inherit_layout_toggled),
dialog);
g_signal_connect_swapped (G_OBJECT (WID ("xkb_layout_options")),
"clicked",
G_CALLBACK (xkb_options_popup_dialog),
dialog);
xkb_layouts_register_conf_listener (dialog);
xkb_options_register_conf_listener (dialog);
g_object_weak_ref (G_OBJECT (WID ("region_notebook")),
(GWeakNotify) cleanup_xkb_tabs, dialog);
enable_disable_restoring (dialog);
/* Setup junction between toolbar and treeview */
widget = WID ("xkb_layouts_swindow");
context = gtk_widget_get_style_context (widget);
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
widget = WID ("layouts-toolbar");
context = gtk_widget_get_style_context (widget);
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
}
void
enable_disable_restoring (GtkBuilder * dialog)
{
GkbdKeyboardConfig gswic;
gboolean enable;
gkbd_keyboard_config_init (&gswic, engine);
gkbd_keyboard_config_load (&gswic, NULL);
enable = !gkbd_keyboard_config_equals (&gswic, &initial_config);
gkbd_keyboard_config_term (&gswic);
gtk_widget_set_sensitive (WID ("xkb_reset_to_defaults"), enable);
}

View file

@ -1,96 +0,0 @@
/* gnome-region-panel-xkb.h
* Copyright (C) 2003-2007 Sergey V Udaltsov
*
* Written by Sergey V. Udaltsov <svu@gnome.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, 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef __GNOME_KEYBOARD_PROPERTY_XKB_H
#define __GNOME_KEYBOARD_PROPERTY_XKB_H
#include <gtk/gtk.h>
#include "libgnomekbd/gkbd-keyboard-config.h"
#include "libgnomekbd/gkbd-util.h"
G_BEGIN_DECLS
#define CWID(s) GTK_WIDGET (gtk_builder_get_object (chooser_dialog, s))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (dialog, s))
extern XklEngine *engine;
extern XklConfigRegistry *config_registry;
extern GSettings *xkb_keyboard_settings;
extern GSettings *xkb_desktop_settings;
extern GkbdKeyboardConfig initial_config;
extern void setup_xkb_tabs (GtkBuilder * dialog);
extern void xkb_layouts_fill_selected_tree (GtkBuilder * dialog);
extern void xkb_layouts_register_buttons_handlers (GtkBuilder * dialog);
extern void xkb_layouts_register_conf_listener (GtkBuilder * dialog);
extern void xkb_options_register_conf_listener (GtkBuilder * dialog);
extern void xkb_layouts_prepare_selected_tree (GtkBuilder * dialog);
extern void xkb_options_load_options (GtkBuilder * dialog);
extern void xkb_options_popup_dialog (GtkBuilder * dialog);
extern char *xci_desc_to_utf8 (const XklConfigItem * ci);
extern gchar *xkb_layout_description_utf8 (const gchar * visible);
extern void enable_disable_restoring (GtkBuilder * dialog);
extern void preview_toggled (GtkBuilder * dialog, GtkWidget * button);
extern GtkWidget *xkb_layout_choose (GtkBuilder * dialog);
extern void xkb_layout_chooser_response (GtkDialog *dialog, gint response_id);
extern gchar **xkb_layouts_get_selected_list (void);
extern gchar **xkb_options_get_selected_list (void);
#define xkb_layouts_set_selected_list(list) \
g_settings_set_strv (xkb_keyboard_settings, \
GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, \
(const gchar *const*)(list))
#define xkb_options_set_selected_list(list) \
g_settings_set_strv (xkb_keyboard_settings, \
GKBD_KEYBOARD_CONFIG_KEY_OPTIONS, \
(const gchar *const*)(list))
extern GtkWidget *xkb_layout_preview_create_widget (GtkBuilder *
chooser_dialog);
extern void xkb_layout_preview_update (GtkBuilder * chooser_dialog);
extern void xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw,
const gchar * id);
extern gchar *xkb_layout_chooser_get_selected_id (GtkDialog *dialog);
extern void xkb_save_default_group (gint group_no);
extern gint xkb_get_default_group (void);
G_END_DECLS
#endif /* __GNOME_KEYBOARD_PROPERTY_XKB_H */

View file

@ -1,470 +0,0 @@
/* gnome-region-panel-xkblt.c
* Copyright (C) 2003-2007 Sergey V. Udaltsov
*
* Written by: Sergey V. Udaltsov <svu@gnome.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, 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gdk/gdkx.h>
#include <glib/gi18n.h>
#include <libgnomekbd/gkbd-desktop-config.h>
#include <libgnomekbd/gkbd-keyboard-drawing.h>
#include "gnome-region-panel-xkb.h"
enum {
SEL_LAYOUT_TREE_COL_DESCRIPTION,
SEL_LAYOUT_TREE_COL_ID,
SEL_LAYOUT_TREE_COL_ENABLED,
SEL_LAYOUT_N_COLS
};
static int idx2select = -1;
static int max_selected_layouts = -1;
static GtkCellRenderer *text_renderer;
static gboolean disable_buttons_sensibility_update = FALSE;
static gboolean
get_selected_iter (GtkBuilder *dialog,
GtkTreeModel **model,
GtkTreeIter *iter)
{
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (WID ("xkb_layouts_selected")));
return gtk_tree_selection_get_selected (selection, model, iter);
}
static void
set_selected_path (GtkBuilder *dialog,
GtkTreePath *path)
{
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (WID ("xkb_layouts_selected")));
gtk_tree_selection_select_path (selection, path);
}
static gint
find_selected_layout_idx (GtkBuilder *dialog)
{
GtkTreeIter selected_iter;
GtkTreeModel *model;
GtkTreePath *path;
gint *indices;
gint rv;
if (!get_selected_iter (dialog, &model, &selected_iter))
return -1;
path = gtk_tree_model_get_path (model, &selected_iter);
if (path == NULL)
return -1;
indices = gtk_tree_path_get_indices (path);
rv = indices[0];
gtk_tree_path_free (path);
return rv;
}
gchar **
xkb_layouts_get_selected_list (void)
{
gchar **retval;
retval = g_settings_get_strv (xkb_keyboard_settings,
GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS);
if (retval == NULL || retval[0] == NULL) {
g_strfreev (retval);
retval = g_strdupv (initial_config.layouts_variants);
}
return retval;
}
gint
xkb_get_default_group ()
{
return g_settings_get_int (xkb_desktop_settings,
GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP);
}
void
xkb_save_default_group (gint default_group)
{
g_settings_set_int (xkb_desktop_settings,
GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
default_group);
}
static void
xkb_layouts_enable_disable_buttons (GtkBuilder * dialog)
{
GtkWidget *add_layout_btn = WID ("xkb_layouts_add");
GtkWidget *show_layout_btn = WID ("xkb_layouts_show");
GtkWidget *del_layout_btn = WID ("xkb_layouts_remove");
GtkWidget *selected_layouts_tree = WID ("xkb_layouts_selected");
GtkWidget *move_up_layout_btn = WID ("xkb_layouts_move_up");
GtkWidget *move_down_layout_btn = WID ("xkb_layouts_move_down");
GtkTreeSelection *s_selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW
(selected_layouts_tree));
const int n_selected_selected_layouts =
gtk_tree_selection_count_selected_rows (s_selection);
GtkTreeModel *selected_layouts_model = gtk_tree_view_get_model
(GTK_TREE_VIEW (selected_layouts_tree));
const int n_selected_layouts =
gtk_tree_model_iter_n_children (selected_layouts_model,
NULL);
gint sidx = find_selected_layout_idx (dialog);
if (disable_buttons_sensibility_update)
return;
gtk_widget_set_sensitive (add_layout_btn,
(n_selected_layouts <
max_selected_layouts
|| max_selected_layouts == 0));
gtk_widget_set_sensitive (del_layout_btn, (n_selected_layouts > 1)
&& (n_selected_selected_layouts > 0));
gtk_widget_set_sensitive (show_layout_btn,
(n_selected_selected_layouts > 0));
gtk_widget_set_sensitive (move_up_layout_btn, sidx > 0);
gtk_widget_set_sensitive (move_down_layout_btn, sidx >= 0
&& sidx < (n_selected_layouts - 1));
}
static void
update_layouts_list (GtkTreeModel *model,
GtkBuilder *dialog)
{
gboolean cont;
GtkTreeIter iter;
GPtrArray *array;
array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
cont = gtk_tree_model_get_iter_first (model, &iter);
while (cont) {
char *id;
gtk_tree_model_get (model, &iter,
SEL_LAYOUT_TREE_COL_ID, &id,
-1);
g_ptr_array_add (array, id);
cont = gtk_tree_model_iter_next (model, &iter);
}
g_ptr_array_add (array, NULL);
xkb_layouts_set_selected_list (array->pdata);
g_ptr_array_free (array, TRUE);
xkb_layouts_enable_disable_buttons (dialog);
}
static void
xkb_layouts_drag_end (GtkWidget *widget,
GdkDragContext *drag_context,
gpointer user_data)
{
update_layouts_list (gtk_tree_view_get_model (GTK_TREE_VIEW (widget)),
GTK_BUILDER (user_data));
}
void
xkb_layouts_prepare_selected_tree (GtkBuilder * dialog)
{
GtkListStore *list_store;
GtkWidget *tree_view = WID ("xkb_layouts_selected");
GtkTreeSelection *selection;
GtkTreeViewColumn *desc_column;
list_store = gtk_list_store_new (SEL_LAYOUT_N_COLS,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
text_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ());
desc_column =
gtk_tree_view_column_new_with_attributes (_("Layout"),
text_renderer,
"text",
SEL_LAYOUT_TREE_COL_DESCRIPTION,
"sensitive",
SEL_LAYOUT_TREE_COL_ENABLED,
NULL);
selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view),
GTK_TREE_MODEL (list_store));
gtk_tree_view_column_set_sizing (desc_column,
GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_tree_view_column_set_resizable (desc_column, TRUE);
gtk_tree_view_column_set_expand (desc_column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
desc_column);
g_signal_connect_swapped (G_OBJECT (selection), "changed",
G_CALLBACK
(xkb_layouts_enable_disable_buttons),
dialog);
max_selected_layouts = xkl_engine_get_max_num_groups (engine);
/* Setting up DnD */
gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tree_view), TRUE);
g_signal_connect (G_OBJECT (tree_view), "drag-end",
G_CALLBACK (xkb_layouts_drag_end), dialog);
}
gchar *
xkb_layout_description_utf8 (const gchar * visible)
{
char *l, *sl, *v, *sv;
if (gkbd_keyboard_config_get_descriptions
(config_registry, visible, &sl, &l, &sv, &v))
visible =
gkbd_keyboard_config_format_full_description (l, v);
return g_strstrip (g_strdup (visible));
}
void
xkb_layouts_fill_selected_tree (GtkBuilder * dialog)
{
gchar **layouts = xkb_layouts_get_selected_list ();
guint i;
GtkListStore *list_store =
GTK_LIST_STORE (gtk_tree_view_get_model
(GTK_TREE_VIEW
(WID ("xkb_layouts_selected"))));
/* temporarily disable the buttons' status update */
disable_buttons_sensibility_update = TRUE;
gtk_list_store_clear (list_store);
for (i = 0; layouts != NULL && layouts[i] != NULL; i++) {
char *cur_layout = layouts[i];
gchar *utf_visible =
xkb_layout_description_utf8 (cur_layout);
gtk_list_store_insert_with_values (list_store, NULL, G_MAXINT,
SEL_LAYOUT_TREE_COL_DESCRIPTION,
utf_visible,
SEL_LAYOUT_TREE_COL_ID,
cur_layout,
SEL_LAYOUT_TREE_COL_ENABLED,
i < max_selected_layouts, -1);
g_free (utf_visible);
}
g_strfreev (layouts);
/* enable the buttons' status update */
disable_buttons_sensibility_update = FALSE;
if (idx2select != -1) {
GtkTreeSelection *selection =
gtk_tree_view_get_selection ((GTK_TREE_VIEW
(WID
("xkb_layouts_selected"))));
GtkTreePath *path =
gtk_tree_path_new_from_indices (idx2select, -1);
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
idx2select = -1;
} else {
/* if there is nothing to select - just enable/disable the buttons,
otherwise it would be done by the selection change */
xkb_layouts_enable_disable_buttons (dialog);
}
}
static void
add_default_switcher_if_necessary ()
{
gchar **layouts_list = xkb_layouts_get_selected_list();
gchar **options_list = xkb_options_get_selected_list ();
gboolean was_appended;
options_list =
gkbd_keyboard_config_add_default_switch_option_if_necessary
(layouts_list, options_list, &was_appended);
if (was_appended)
xkb_options_set_selected_list (options_list);
g_strfreev (options_list);
}
static void
chooser_response (GtkDialog *chooser,
int response_id,
GtkBuilder *dialog)
{
if (response_id == GTK_RESPONSE_OK) {
char *id, *name;
GtkListStore *list_store;
list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (WID ("xkb_layouts_selected"))));
id = xkb_layout_chooser_get_selected_id (chooser);
name = xkb_layout_description_utf8 (id);
gtk_list_store_insert_with_values (list_store, NULL, G_MAXINT,
SEL_LAYOUT_TREE_COL_DESCRIPTION, name,
SEL_LAYOUT_TREE_COL_ID, id,
SEL_LAYOUT_TREE_COL_ENABLED, TRUE,
-1);
g_free (name);
add_default_switcher_if_necessary ();
update_layouts_list (GTK_TREE_MODEL (list_store), dialog);
}
xkb_layout_chooser_response (chooser, response_id);
}
static void
add_selected_layout (GtkWidget * button, GtkBuilder * dialog)
{
GtkWidget *chooser;
chooser = xkb_layout_choose (dialog);
g_signal_connect (G_OBJECT (chooser), "response",
G_CALLBACK (chooser_response), dialog);
}
static void
show_selected_layout (GtkWidget * button, GtkBuilder * dialog)
{
gint idx = find_selected_layout_idx (dialog);
if (idx != -1) {
GtkWidget *parent = WID ("region_notebook");
GtkWidget *popup = gkbd_keyboard_drawing_dialog_new ();
gkbd_keyboard_drawing_dialog_set_group (popup,
config_registry,
idx);
gtk_window_set_transient_for (GTK_WINDOW (popup),
GTK_WINDOW
(gtk_widget_get_toplevel
(parent)));
gtk_widget_show_all (popup);
}
}
static void
remove_selected_layout (GtkWidget * button, GtkBuilder * dialog)
{
GtkTreeModel *model;
GtkTreeIter iter;
if (get_selected_iter (dialog, &model, &iter) == FALSE)
return;
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
update_layouts_list (model, dialog);
}
static void
move_up_selected_layout (GtkWidget * button, GtkBuilder * dialog)
{
GtkTreeModel *model;
GtkTreeIter iter, prev;
GtkTreePath *path;
if (get_selected_iter (dialog, &model, &iter) == FALSE)
return;
prev = iter;
if (!gtk_tree_model_iter_previous (model, &prev))
return;
path = gtk_tree_model_get_path (model, &prev);
gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &prev);
update_layouts_list (model, dialog);
set_selected_path (dialog, path);
gtk_tree_path_free (path);
}
static void
move_down_selected_layout (GtkWidget * button, GtkBuilder * dialog)
{
GtkTreeModel *model;
GtkTreeIter iter, next;
GtkTreePath *path;
if (get_selected_iter (dialog, &model, &iter) == FALSE)
return;
next = iter;
if (!gtk_tree_model_iter_next (model, &next))
return;
path = gtk_tree_model_get_path (model, &next);
gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &next);
update_layouts_list (model, dialog);
set_selected_path (dialog, path);
gtk_tree_path_free (path);
}
void
xkb_layouts_register_buttons_handlers (GtkBuilder * dialog)
{
g_signal_connect (G_OBJECT (WID ("xkb_layouts_add")), "clicked",
G_CALLBACK (add_selected_layout), dialog);
g_signal_connect (G_OBJECT (WID ("xkb_layouts_show")), "clicked",
G_CALLBACK (show_selected_layout), dialog);
g_signal_connect (G_OBJECT (WID ("xkb_layouts_remove")), "clicked",
G_CALLBACK (remove_selected_layout), dialog);
g_signal_connect (G_OBJECT (WID ("xkb_layouts_move_up")),
"clicked", G_CALLBACK (move_up_selected_layout),
dialog);
g_signal_connect (G_OBJECT (WID ("xkb_layouts_move_down")),
"clicked",
G_CALLBACK (move_down_selected_layout), dialog);
}
static void
xkb_layouts_update_list (GSettings * settings,
gchar * key, GtkBuilder * dialog)
{
if (strcmp (key, GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS) == 0) {
xkb_layouts_fill_selected_tree (dialog);
enable_disable_restoring (dialog);
}
}
void
xkb_layouts_register_conf_listener (GtkBuilder * dialog)
{
g_signal_connect (xkb_keyboard_settings, "changed",
G_CALLBACK (xkb_layouts_update_list), dialog);
}

View file

@ -1,495 +0,0 @@
/* gnome-region-panel-xkbltadd.c
* Copyright (C) 2007 Sergey V. Udaltsov
*
* Written by: Sergey V. Udaltsov <svu@gnome.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, 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <libgnomekbd/gkbd-keyboard-drawing.h>
#include <libgnomekbd/gkbd-util.h>
#include "gnome-region-panel-xkb.h"
enum {
COMBO_BOX_MODEL_COL_SORT,
COMBO_BOX_MODEL_COL_VISIBLE,
COMBO_BOX_MODEL_COL_XKB_ID,
COMBO_BOX_MODEL_COL_COUNTRY_DESC,
COMBO_BOX_MODEL_COL_LANGUAGE_DESC
};
static gchar **search_pattern_list = NULL;
static GtkWidget *preview_dialog = NULL;
static GRegex *left_bracket_regex = NULL;
#define RESPONSE_PREVIEW 1
static void
xkb_preview_destroy_callback (GtkWidget * widget)
{
preview_dialog = NULL;
}
static gboolean
xkb_layout_chooser_selection_dupe (GtkDialog * dialog)
{
gchar *selected_id =
(gchar *) xkb_layout_chooser_get_selected_id (dialog);
gchar **layouts_list, **pl;
gboolean rv = FALSE;
if (selected_id == NULL)
return rv;
layouts_list = pl = xkb_layouts_get_selected_list ();
while (pl && *pl) {
if (!g_ascii_strcasecmp (*pl++, selected_id)) {
rv = TRUE;
break;
}
}
g_strfreev (layouts_list);
return rv;
}
void
xkb_layout_chooser_response (GtkDialog * dialog, gint response)
{
switch (response)
case GTK_RESPONSE_OK:{
/* Handled by the main code */
break;
case RESPONSE_PREVIEW:{
gchar *selected_id = (gchar *)
xkb_layout_chooser_get_selected_id
(dialog);
if (selected_id != NULL) {
if (preview_dialog == NULL) {
preview_dialog =
gkbd_keyboard_drawing_dialog_new
();
g_signal_connect (G_OBJECT
(preview_dialog),
"destroy",
G_CALLBACK
(xkb_preview_destroy_callback),
NULL);
/* Put into the separate group to avoid conflict
with modal parent */
gtk_window_group_add_window
(gtk_window_group_new
(),
GTK_WINDOW
(preview_dialog));
};
gkbd_keyboard_drawing_dialog_set_layout
(preview_dialog,
config_registry, selected_id);
gtk_widget_show_all
(preview_dialog);
}
}
return;
}
if (preview_dialog != NULL) {
gtk_widget_destroy (preview_dialog);
}
if (search_pattern_list != NULL) {
g_strfreev (search_pattern_list);
search_pattern_list = NULL;
}
gtk_widget_destroy (GTK_WIDGET (dialog));
}
static gchar *
xkl_create_description_from_list (const XklConfigItem * item,
const XklConfigItem * subitem,
const gchar * prop_name,
const gchar *
(*desc_getter) (const gchar * code))
{
gchar *rv = NULL, *code = NULL;
gchar **list = NULL;
const gchar *desc;
if (subitem != NULL)
list =
(gchar
**) (g_object_get_data (G_OBJECT (subitem),
prop_name));
if (list == NULL || *list == 0)
list =
(gchar
**) (g_object_get_data (G_OBJECT (item), prop_name));
/* First try the parent id as such */
desc = desc_getter (item->name);
if (desc != NULL) {
rv = g_utf8_strup (desc, -1);
} else {
code = g_utf8_strup (item->name, -1);
desc = desc_getter (code);
if (desc != NULL) {
rv = g_utf8_strup (desc, -1);
}
g_free (code);
}
if (list == NULL || *list == 0)
return rv;
while (*list != 0) {
code = *list++;
desc = desc_getter (code);
if (desc != NULL) {
gchar *udesc = g_utf8_strup (desc, -1);
if (rv == NULL) {
rv = udesc;
} else {
gchar *orv = rv;
rv = g_strdup_printf ("%s %s", rv, udesc);
g_free (orv);
g_free (udesc);
}
}
}
return rv;
}
static void
xkl_layout_add_to_list (XklConfigRegistry * config,
const XklConfigItem * item,
const XklConfigItem * subitem,
GtkBuilder * chooser_dialog)
{
GtkListStore *list_store =
GTK_LIST_STORE (gtk_builder_get_object (chooser_dialog,
"layout_list_model"));
GtkTreeIter iter;
gchar *utf_variant_name =
subitem ?
xkb_layout_description_utf8 (gkbd_keyboard_config_merge_items
(item->name,
subitem->name)) :
xci_desc_to_utf8 (item);
const gchar *xkb_id =
subitem ? gkbd_keyboard_config_merge_items (item->name,
subitem->name) :
item->name;
gchar *country_desc =
xkl_create_description_from_list (item, subitem,
XCI_PROP_COUNTRY_LIST,
xkl_get_country_name);
gchar *language_desc =
xkl_create_description_from_list (item, subitem,
XCI_PROP_LANGUAGE_LIST,
xkl_get_language_name);
gchar *tmp = utf_variant_name;
utf_variant_name =
g_regex_replace_literal (left_bracket_regex, tmp, -1, 0,
"&lt;", 0, NULL);
g_free (tmp);
if (subitem
&& g_object_get_data (G_OBJECT (subitem),
XCI_PROP_EXTRA_ITEM)) {
gchar *buf =
g_strdup_printf ("<i>%s</i>", utf_variant_name);
gtk_list_store_insert_with_values (list_store, &iter, -1,
COMBO_BOX_MODEL_COL_SORT,
utf_variant_name,
COMBO_BOX_MODEL_COL_VISIBLE,
buf,
COMBO_BOX_MODEL_COL_XKB_ID,
xkb_id,
COMBO_BOX_MODEL_COL_COUNTRY_DESC,
country_desc,
COMBO_BOX_MODEL_COL_LANGUAGE_DESC,
language_desc, -1);
g_free (buf);
} else
gtk_list_store_insert_with_values (list_store, &iter,
-1,
COMBO_BOX_MODEL_COL_SORT,
utf_variant_name,
COMBO_BOX_MODEL_COL_VISIBLE,
utf_variant_name,
COMBO_BOX_MODEL_COL_XKB_ID,
xkb_id,
COMBO_BOX_MODEL_COL_COUNTRY_DESC,
country_desc,
COMBO_BOX_MODEL_COL_LANGUAGE_DESC,
language_desc, -1);
g_free (utf_variant_name);
g_free (country_desc);
g_free (language_desc);
}
static void
xkb_layout_filter_clear (GtkEntry * entry,
GtkEntryIconPosition icon_pos,
GdkEvent * event, gpointer user_data)
{
gtk_entry_set_text (entry, "");
}
static void
xkb_layout_filter_changed (GtkBuilder * chooser_dialog)
{
GtkTreeModelFilter *filtered_model =
GTK_TREE_MODEL_FILTER (gtk_builder_get_object (chooser_dialog,
"filtered_layout_list_model"));
GtkWidget *xkb_layout_filter = CWID ("xkb_layout_filter");
const gchar *pattern =
gtk_entry_get_text (GTK_ENTRY (xkb_layout_filter));
gchar *upattern = g_utf8_strup (pattern, -1);
if (!g_strcmp0 (pattern, "")) {
g_object_set (G_OBJECT (xkb_layout_filter),
"secondary-icon-name", "edit-find-symbolic",
"secondary-icon-activatable", FALSE,
"secondary-icon-sensitive", FALSE, NULL);
} else {
g_object_set (G_OBJECT (xkb_layout_filter),
"secondary-icon-name", "edit-clear-symbolic",
"secondary-icon-activatable", TRUE,
"secondary-icon-sensitive", TRUE, NULL);
}
if (search_pattern_list != NULL)
g_strfreev (search_pattern_list);
search_pattern_list = g_strsplit (upattern, " ", -1);
g_free (upattern);
gtk_tree_model_filter_refilter (filtered_model);
}
static void
xkb_layout_chooser_selection_changed (GtkTreeSelection * selection,
GtkBuilder * chooser_dialog)
{
GList *selected_layouts =
gtk_tree_selection_get_selected_rows (selection, NULL);
GtkWidget *add_button = CWID ("btnOk");
GtkWidget *preview_button = CWID ("btnPreview");
gboolean anything_selected = g_list_length (selected_layouts) == 1;
gboolean dupe =
xkb_layout_chooser_selection_dupe (GTK_DIALOG
(CWID
("xkb_layout_chooser")));
gtk_widget_set_sensitive (add_button, anything_selected && !dupe);
gtk_widget_set_sensitive (preview_button, anything_selected);
}
static void
xkb_layout_chooser_row_activated (GtkTreeView * tree_view,
GtkTreePath * path,
GtkTreeViewColumn * column,
GtkBuilder * chooser_dialog)
{
GtkWidget *add_button = CWID ("btnOk");
GtkWidget *dialog = CWID ("xkb_layout_chooser");
if (gtk_widget_is_sensitive (add_button))
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
}
static gboolean
xkb_filter_layouts (GtkTreeModel * model,
GtkTreeIter * iter, gpointer data)
{
gchar *desc = NULL, *country_desc = NULL, *language_desc =
NULL, **pattern;
gboolean rv = TRUE;
if (search_pattern_list == NULL || search_pattern_list[0] == NULL)
return TRUE;
gtk_tree_model_get (model, iter,
COMBO_BOX_MODEL_COL_SORT, &desc,
COMBO_BOX_MODEL_COL_COUNTRY_DESC,
&country_desc,
COMBO_BOX_MODEL_COL_LANGUAGE_DESC,
&language_desc, -1);
pattern = search_pattern_list;
do {
gboolean is_pattern_found = FALSE;
gchar *udesc = g_utf8_strup (desc, -1);
if (udesc != NULL && g_strstr_len (udesc, -1, *pattern)) {
is_pattern_found = TRUE;
} else if (country_desc != NULL
&& g_strstr_len (country_desc, -1, *pattern)) {
is_pattern_found = TRUE;
} else if (language_desc != NULL
&& g_strstr_len (language_desc, -1, *pattern)) {
is_pattern_found = TRUE;
}
g_free (udesc);
if (!is_pattern_found) {
rv = FALSE;
break;
}
} while (*++pattern != NULL);
g_free (desc);
g_free (country_desc);
g_free (language_desc);
return rv;
}
GtkWidget *
xkb_layout_choose (GtkBuilder * dialog)
{
GtkBuilder *chooser_dialog = gtk_builder_new ();
GtkWidget *chooser, *xkb_filtered_layouts_list, *xkb_layout_filter;
GtkTreeViewColumn *visible_column;
GtkTreeSelection *selection;
GtkListStore *model;
GtkTreeModelFilter *filtered_model;
gtk_builder_add_from_file (chooser_dialog, GNOMECC_UI_DIR
"/gnome-region-panel-layout-chooser.ui",
NULL);
chooser = CWID ("xkb_layout_chooser");
xkb_filtered_layouts_list = CWID ("xkb_filtered_layouts_list");
xkb_layout_filter = CWID ("xkb_layout_filter");
g_object_set_data (G_OBJECT (chooser), "xkb_filtered_layouts_list",
xkb_filtered_layouts_list);
visible_column =
gtk_tree_view_column_new_with_attributes ("Layout",
gtk_cell_renderer_text_new
(), "markup",
COMBO_BOX_MODEL_COL_VISIBLE,
NULL);
gtk_window_set_transient_for (GTK_WINDOW (chooser),
GTK_WINDOW
(gtk_widget_get_toplevel
(WID ("region_notebook"))));
gtk_tree_view_append_column (GTK_TREE_VIEW
(xkb_filtered_layouts_list),
visible_column);
g_signal_connect_swapped (G_OBJECT (xkb_layout_filter),
"notify::text",
G_CALLBACK
(xkb_layout_filter_changed),
chooser_dialog);
g_signal_connect (G_OBJECT (xkb_layout_filter), "icon-release",
G_CALLBACK (xkb_layout_filter_clear), NULL);
selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW
(xkb_filtered_layouts_list));
g_signal_connect (G_OBJECT (selection),
"changed",
G_CALLBACK
(xkb_layout_chooser_selection_changed),
chooser_dialog);
xkb_layout_chooser_selection_changed (selection, chooser_dialog);
g_signal_connect (G_OBJECT (xkb_filtered_layouts_list),
"row-activated",
G_CALLBACK (xkb_layout_chooser_row_activated),
chooser_dialog);
filtered_model =
GTK_TREE_MODEL_FILTER (gtk_builder_get_object
(chooser_dialog,
"filtered_layout_list_model"));
model =
GTK_LIST_STORE (gtk_builder_get_object
(chooser_dialog, "layout_list_model"));
left_bracket_regex = g_regex_new ("<", 0, 0, NULL);
xkl_config_registry_search_by_pattern (config_registry,
NULL,
(TwoConfigItemsProcessFunc)
(xkl_layout_add_to_list),
chooser_dialog);
g_regex_unref (left_bracket_regex);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
COMBO_BOX_MODEL_COL_SORT,
GTK_SORT_ASCENDING);
gtk_tree_model_filter_set_visible_func (filtered_model,
xkb_filter_layouts,
NULL, NULL);
gtk_widget_grab_focus (xkb_layout_filter);
gtk_widget_show (chooser);
return chooser;
}
gchar *
xkb_layout_chooser_get_selected_id (GtkDialog * dialog)
{
GtkTreeModel *filtered_list_model;
GtkWidget *xkb_filtered_layouts_list =
g_object_get_data (G_OBJECT (dialog),
"xkb_filtered_layouts_list");
GtkTreeIter viter;
gchar *v_id;
GtkTreeSelection *selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW
(xkb_filtered_layouts_list));
GList *selected_layouts =
gtk_tree_selection_get_selected_rows (selection,
&filtered_list_model);
if (g_list_length (selected_layouts) != 1)
return NULL;
gtk_tree_model_get_iter (filtered_list_model,
&viter,
(GtkTreePath *) (selected_layouts->data));
g_list_foreach (selected_layouts,
(GFunc) gtk_tree_path_free, NULL);
g_list_free (selected_layouts);
gtk_tree_model_get (filtered_list_model, &viter,
COMBO_BOX_MODEL_COL_XKB_ID, &v_id, -1);
return v_id;
}

View file

@ -1,515 +0,0 @@
/* gnome-region-panel-xkbot.c
* Copyright (C) 2003-2007 Sergey V. Udaltsov
*
* Written by: Sergey V. Udaltsov <svu@gnome.org>
* John Spray <spray_john@users.sourceforge.net>
*
* 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, 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <glib/gi18n.h>
#include <string.h>
#include "gnome-region-panel-xkb.h"
static GtkBuilder *chooser_dialog = NULL;
static const char *current1st_level_id = NULL;
static GSList *option_checks_list = NULL;
static GtkWidget *current_none_radio = NULL;
static GtkWidget *current_expander = NULL;
static gboolean current_multi_select = FALSE;
static GSList *current_radio_group = NULL;
#define OPTION_ID_PROP "optionID"
#define SELCOUNTER_PROP "selectionCounter"
#define GCONFSTATE_PROP "gconfState"
#define EXPANDERS_PROP "expandersList"
gchar **
xkb_options_get_selected_list (void)
{
gchar **retval;
retval =
g_settings_get_strv (xkb_keyboard_settings,
GKBD_KEYBOARD_CONFIG_KEY_OPTIONS);
if (retval == NULL) {
retval = g_strdupv (initial_config.options);
}
return retval;
}
/* Returns the selection counter of the expander (static current_expander) */
static int
xkb_options_expander_selcounter_get (void)
{
return
GPOINTER_TO_INT (g_object_get_data
(G_OBJECT (current_expander),
SELCOUNTER_PROP));
}
/* Increments the selection counter in the expander (static current_expander)
using the value (can be 0)*/
static void
xkb_options_expander_selcounter_add (int value)
{
g_object_set_data (G_OBJECT (current_expander), SELCOUNTER_PROP,
GINT_TO_POINTER
(xkb_options_expander_selcounter_get ()
+ value));
}
/* Resets the seletion counter in the expander (static current_expander) */
static void
xkb_options_expander_selcounter_reset (void)
{
g_object_set_data (G_OBJECT (current_expander), SELCOUNTER_PROP,
GINT_TO_POINTER (0));
}
/* Formats the expander (static current_expander), based on the selection counter */
static void
xkb_options_expander_highlight (void)
{
char *utf_group_name =
g_object_get_data (G_OBJECT (current_expander),
"utfGroupName");
int counter = xkb_options_expander_selcounter_get ();
if (utf_group_name != NULL) {
gchar *titlemarkup =
g_strconcat (counter >
0 ? "<span weight=\"bold\">" : "<span>",
utf_group_name, "</span>", NULL);
gtk_expander_set_label (GTK_EXPANDER (current_expander),
titlemarkup);
g_free (titlemarkup);
}
}
/* Add optionname from the backend's selection list if it's not
already in there. */
static void
xkb_options_select (gchar * optionname)
{
gboolean already_selected = FALSE;
gchar **options_list;
guint i;
options_list = xkb_options_get_selected_list ();
for (i = 0; options_list != NULL && options_list[i] != NULL; i++) {
gchar *option = options_list[i];
if (!strcmp (option, optionname)) {
already_selected = TRUE;
break;
}
}
if (!already_selected) {
options_list =
gkbd_strv_append (options_list, g_strdup (optionname));
xkb_options_set_selected_list (options_list);
}
g_strfreev (options_list);
}
/* Remove all occurences of optionname from the backend's selection list */
static void
xkb_options_deselect (gchar * optionname)
{
gchar **options_list = xkb_options_get_selected_list ();
if (options_list != NULL) {
gchar **option = options_list;
while (*option != NULL) {
gchar *id = *option;
if (!strcmp (id, optionname)) {
gkbd_strv_behead (option);
} else
option++;
}
xkb_options_set_selected_list (options_list);
}
g_strfreev (options_list);
}
/* Return true if optionname describes a string already in the backend's
list of selected options */
static gboolean
xkb_options_is_selected (gchar * optionname)
{
gboolean retval = FALSE;
gchar **options_list = xkb_options_get_selected_list ();
if (options_list != NULL) {
gchar **option = options_list;
while (*option != NULL) {
if (!strcmp (*option, optionname)) {
retval = TRUE;
break;
}
option++;
}
}
g_strfreev (options_list);
return retval;
}
/* Make sure selected options stay visible when navigating with the keyboard */
static gboolean
option_focused_cb (GtkWidget * widget, GdkEventFocus * event,
gpointer data)
{
GtkScrolledWindow *win = GTK_SCROLLED_WINDOW (data);
GtkAllocation alloc;
GtkAdjustment *adj;
gtk_widget_get_allocation (widget, &alloc);
adj = gtk_scrolled_window_get_vadjustment (win);
gtk_adjustment_clamp_page (adj, alloc.y, alloc.y + alloc.height);
return FALSE;
}
/* Update xkb backend to reflect the new UI state */
static void
option_toggled_cb (GtkWidget * checkbutton, gpointer data)
{
gpointer optionID =
g_object_get_data (G_OBJECT (checkbutton), OPTION_ID_PROP);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)))
xkb_options_select (optionID);
else
xkb_options_deselect (optionID);
}
/* Add a check_button or radio_button to control a particular option
This function makes particular use of the current... variables at
the top of this file. */
static void
xkb_options_add_option (XklConfigRegistry * config_registry,
XklConfigItem * config_item, GtkBuilder * dialog)
{
GtkWidget *option_check;
gchar *utf_option_name = xci_desc_to_utf8 (config_item);
/* Copy this out because we'll load it into the widget with set_data */
gchar *full_option_name =
g_strdup (gkbd_keyboard_config_merge_items
(current1st_level_id, config_item->name));
gboolean initial_state;
if (current_multi_select)
option_check =
gtk_check_button_new_with_label (utf_option_name);
else {
if (current_radio_group == NULL) {
/* The first radio in a group is to be "Default", meaning none of
the below options are to be included in the selected list.
This is a HIG-compliant alternative to allowing no
selection in the group. */
option_check =
gtk_radio_button_new_with_label
(current_radio_group, _("Default"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(option_check),
TRUE);
/* Make option name underscore -
to enforce its first position in the list */
g_object_set_data_full (G_OBJECT (option_check),
"utfOptionName",
g_strdup (" "), g_free);
option_checks_list =
g_slist_append (option_checks_list,
option_check);
current_radio_group =
gtk_radio_button_get_group (GTK_RADIO_BUTTON
(option_check));
current_none_radio = option_check;
g_signal_connect (option_check, "focus-in-event",
G_CALLBACK (option_focused_cb),
WID ("options_scroll"));
}
option_check =
gtk_radio_button_new_with_label (current_radio_group,
utf_option_name);
current_radio_group =
gtk_radio_button_get_group (GTK_RADIO_BUTTON
(option_check));
g_object_set_data (G_OBJECT (option_check), "NoneRadio",
current_none_radio);
}
initial_state = xkb_options_is_selected (full_option_name);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (option_check),
initial_state);
g_object_set_data_full (G_OBJECT (option_check), OPTION_ID_PROP,
full_option_name, g_free);
g_object_set_data_full (G_OBJECT (option_check), "utfOptionName",
utf_option_name, g_free);
g_signal_connect (option_check, "toggled",
G_CALLBACK (option_toggled_cb), NULL);
option_checks_list =
g_slist_append (option_checks_list, option_check);
g_signal_connect (option_check, "focus-in-event",
G_CALLBACK (option_focused_cb),
WID ("options_scroll"));
xkb_options_expander_selcounter_add (initial_state);
g_object_set_data (G_OBJECT (option_check), GCONFSTATE_PROP,
GINT_TO_POINTER (initial_state));
}
static gint
xkb_option_checks_compare (GtkWidget * chk1, GtkWidget * chk2)
{
const gchar *t1 =
g_object_get_data (G_OBJECT (chk1), "utfOptionName");
const gchar *t2 =
g_object_get_data (G_OBJECT (chk2), "utfOptionName");
return g_utf8_collate (t1, t2);
}
/* Add a group of options: create title and layout widgets and then
add widgets for all the options in the group. */
static void
xkb_options_add_group (XklConfigRegistry * config_registry,
XklConfigItem * config_item, GtkBuilder * dialog)
{
GtkWidget *align, *vbox, *option_check;
gboolean allow_multiple_selection =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (config_item),
XCI_PROP_ALLOW_MULTIPLE_SELECTION));
GSList *expanders_list =
g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP);
gchar *utf_group_name = xci_desc_to_utf8 (config_item);
gchar *titlemarkup =
g_strconcat ("<span>", utf_group_name, "</span>", NULL);
current_expander = gtk_expander_new (titlemarkup);
gtk_expander_set_use_markup (GTK_EXPANDER (current_expander),
TRUE);
g_object_set_data_full (G_OBJECT (current_expander),
"utfGroupName", utf_group_name, g_free);
g_object_set_data_full (G_OBJECT (current_expander), "groupId",
g_strdup (config_item->name), g_free);
g_free (titlemarkup);
align = gtk_alignment_new (0, 0, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 12, 12, 0);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
gtk_container_add (GTK_CONTAINER (align), vbox);
gtk_container_add (GTK_CONTAINER (current_expander), align);
current_multi_select = (gboolean) allow_multiple_selection;
current_radio_group = NULL;
current1st_level_id = config_item->name;
option_checks_list = NULL;
xkl_config_registry_foreach_option (config_registry,
config_item->name,
(ConfigItemProcessFunc)
xkb_options_add_option,
dialog);
/* sort it */
option_checks_list =
g_slist_sort (option_checks_list,
(GCompareFunc) xkb_option_checks_compare);
while (option_checks_list) {
option_check = GTK_WIDGET (option_checks_list->data);
gtk_box_pack_start (GTK_BOX (vbox), option_check, TRUE,
TRUE, 0);
option_checks_list = option_checks_list->next;
}
/* free it */
g_slist_free (option_checks_list);
option_checks_list = NULL;
xkb_options_expander_highlight ();
expanders_list = g_slist_append (expanders_list, current_expander);
g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP,
expanders_list);
g_signal_connect (current_expander, "focus-in-event",
G_CALLBACK (option_focused_cb),
WID ("options_scroll"));
}
static gint
xkb_options_expanders_compare (GtkWidget * expander1,
GtkWidget * expander2)
{
const gchar *t1 =
g_object_get_data (G_OBJECT (expander1), "utfGroupName");
const gchar *t2 =
g_object_get_data (G_OBJECT (expander2), "utfGroupName");
return g_utf8_collate (t1, t2);
}
/* Create widgets to represent the options made available by the backend */
void
xkb_options_load_options (GtkBuilder * dialog)
{
GtkWidget *opts_vbox = WID ("options_vbox");
GtkWidget *dialog_vbox = WID ("dialog_vbox");
GtkWidget *options_scroll = WID ("options_scroll");
GtkWidget *expander;
GSList *expanders_list;
current1st_level_id = NULL;
current_none_radio = NULL;
current_multi_select = FALSE;
current_radio_group = NULL;
/* fill the list */
xkl_config_registry_foreach_option_group (config_registry,
(ConfigItemProcessFunc)
xkb_options_add_group,
dialog);
/* sort it */
expanders_list =
g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP);
expanders_list =
g_slist_sort (expanders_list,
(GCompareFunc) xkb_options_expanders_compare);
g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP,
expanders_list);
while (expanders_list) {
expander = GTK_WIDGET (expanders_list->data);
gtk_box_pack_start (GTK_BOX (opts_vbox), expander, FALSE,
FALSE, 0);
expanders_list = expanders_list->next;
}
/* Somewhere in gtk3 the top vbox in dialog is made non-expandable */
gtk_box_set_child_packing (GTK_BOX (dialog_vbox), options_scroll,
TRUE, TRUE, 0, GTK_PACK_START);
gtk_widget_show_all (dialog_vbox);
}
static void
chooser_response_cb (GtkDialog * dialog, gint response, gpointer data)
{
switch (response) {
case GTK_RESPONSE_DELETE_EVENT:
case GTK_RESPONSE_CLOSE: {
/* just cleanup */
GSList *expanders_list =
g_object_get_data (G_OBJECT (dialog),
EXPANDERS_PROP);
g_object_set_data (G_OBJECT (dialog),
EXPANDERS_PROP, NULL);
g_slist_free (expanders_list);
gtk_widget_destroy (GTK_WIDGET (dialog));
chooser_dialog = NULL;
}
break;
}
}
/* Create popup dialog */
void
xkb_options_popup_dialog (GtkBuilder * dialog)
{
GtkWidget *chooser;
chooser_dialog = gtk_builder_new ();
gtk_builder_add_from_file (chooser_dialog, GNOMECC_UI_DIR
"/gnome-region-panel-options-dialog.ui",
NULL);
chooser = CWID ("xkb_options_dialog");
gtk_window_set_transient_for (GTK_WINDOW (chooser),
GTK_WINDOW (gtk_widget_get_toplevel (WID ("region_notebook"))));
gtk_window_set_modal (GTK_WINDOW (chooser), TRUE);
xkb_options_load_options (chooser_dialog);
g_signal_connect (chooser, "response",
G_CALLBACK (chooser_response_cb), dialog);
gtk_widget_show (chooser);
}
/* Update selected option counters for a group-bound expander */
static void
xkb_options_update_option_counters (XklConfigRegistry * config_registry,
XklConfigItem * config_item)
{
gchar *full_option_name =
g_strdup (gkbd_keyboard_config_merge_items
(current1st_level_id, config_item->name));
gboolean current_state =
xkb_options_is_selected (full_option_name);
g_free (full_option_name);
xkb_options_expander_selcounter_add (current_state);
}
/* Respond to a change in the xkb gconf settings */
static void
xkb_options_update (GSettings * settings, gchar * key, GtkBuilder * dialog)
{
if (!strcmp (key, GKBD_KEYBOARD_CONFIG_KEY_OPTIONS)) {
/* Updating options is handled by gconf notifies for each widget
This is here to avoid calling it N_OPTIONS times for each gconf
change. */
enable_disable_restoring (dialog);
if (chooser_dialog != NULL) {
GSList *expanders_list =
g_object_get_data (G_OBJECT (chooser_dialog),
EXPANDERS_PROP);
while (expanders_list) {
current_expander =
GTK_WIDGET (expanders_list->data);
gchar *group_id =
g_object_get_data (G_OBJECT
(current_expander),
"groupId");
current1st_level_id = group_id;
xkb_options_expander_selcounter_reset ();
xkl_config_registry_foreach_option
(config_registry, group_id,
(ConfigItemProcessFunc)
xkb_options_update_option_counters,
current_expander);
xkb_options_expander_highlight ();
expanders_list = expanders_list->next;
}
}
}
}
void
xkb_options_register_conf_listener (GtkBuilder * dialog)
{
g_signal_connect (xkb_keyboard_settings, "changed",
G_CALLBACK (xkb_options_update), dialog);
}

View file

@ -1,120 +0,0 @@
/* gnome-region-panel-xkbpv.c
* Copyright (C) 2003-2007 Sergey V. Udaltsov
*
* Written by: Sergey V. Udaltsov <svu@gnome.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, 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libgnomekbd/gkbd-keyboard-drawing.h>
#include "gnome-region-panel-xkb.h"
#ifdef HAVE_X11_EXTENSIONS_XKB_H
#include "X11/XKBlib.h"
/**
* BAD STYLE: Taken from xklavier_private_xkb.h
* Any ideas on architectural improvements are WELCOME
*/
extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine,
const XklConfigRec * data,
XkbComponentNamesPtr
component_names);
extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
XkbComponentNamesPtr
component_names);
/* */
#endif
static GkbdKeyboardDrawingGroupLevel groupsLevels[] =
{ {0, 1}, {0, 3}, {0, 0}, {0, 2} };
static GkbdKeyboardDrawingGroupLevel *pGroupsLevels[] = {
groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3
};
GtkWidget *
xkb_layout_preview_create_widget (GtkBuilder * chooserDialog)
{
GtkWidget *kbdraw = gkbd_keyboard_drawing_new ();
gkbd_keyboard_drawing_set_groups_levels (GKBD_KEYBOARD_DRAWING
(kbdraw), pGroupsLevels);
return kbdraw;
}
void
xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw,
const gchar * id)
{
#ifdef HAVE_X11_EXTENSIONS_XKB_H
if (kbdraw != NULL) {
if (id != NULL) {
XklConfigRec *data;
char **p, *layout, *variant;
XkbComponentNamesRec component_names;
data = xkl_config_rec_new ();
if (xkl_config_rec_get_from_server (data, engine)) {
if ((p = data->layouts) != NULL)
g_strfreev (data->layouts);
if ((p = data->variants) != NULL)
g_strfreev (data->variants);
data->layouts = g_new0 (char *, 2);
data->variants = g_new0 (char *, 2);
if (gkbd_keyboard_config_split_items
(id, &layout, &variant)
&& variant != NULL) {
data->layouts[0] =
(layout ==
NULL) ? NULL :
g_strdup (layout);
data->variants[0] =
(variant ==
NULL) ? NULL :
g_strdup (variant);
} else {
data->layouts[0] =
(id ==
NULL) ? NULL : g_strdup (id);
data->variants[0] = NULL;
}
if (xkl_xkb_config_native_prepare
(engine, data, &component_names)) {
gkbd_keyboard_drawing_set_keyboard
(GKBD_KEYBOARD_DRAWING
(kbdraw), &component_names);
xkl_xkb_config_native_cleanup
(engine, &component_names);
}
}
g_object_unref (G_OBJECT (data));
} else
gkbd_keyboard_drawing_set_keyboard
(GKBD_KEYBOARD_DRAWING (kbdraw), NULL);
}
#endif
}

View file

@ -1,42 +0,0 @@
Preface
This document describes the scenarios which have to be checked every time someone makes changes in the gnome keyboard handling modules, namely:
- libxklavier (project in freedesktop.org CVS)
- libgswitchit (virtual module in gnome.org CVS)
- gnome-settings-daemon (module in gnome-control-center, gnome.org CVS)
- gnome-keyboard-properties (module in gnome-control-center, gnome.org CVS)
- gnome-keyboard-indicator (module in gnome-applets, gnome.org CVS)
Changes in configuration
The tests should be performed under different configurations, controlled by several variables:
- "group per window" mode (GPW: on/off): visible in UI
- "default group" (DG: switchited off - or some group selected): only in GConf
- "keep indicators with the group" (IPW: on/off): only in GConf
- "hidden groups" (HG: some list of groups, can be empty): only in GConf
Taking that parameters DG and IPW only make sense when GPW is on, there are 5 combinations possible for the first 3 parameters. Taking that DG and IPW do not interfere, it is reasonable to test 3 combinations:
- GPW: off
- GPW: on, DG: off, IPW: off
- GPW: on, DG: {some value}, IPW: on
It is necessary to perform each test with the empty and non-empty HG. If HG is not empty, every test should be performed with both "enabled" and "hidden" groups.
Test cases
1. Open a terminal window. Type in some characters. Change the group using some chosen keyboard combination (default LAlt-RAlt or any other from the list of available ones). Type in some characters - ensure the group was changed.
2. Same as #1 - but change the group by clicking on the indicator applet
3. Same as #1 - but choose the group from the applet's menu
4. Set the US group in one terminal window. Create new terminal window. Ensure the group matches the DG setting.
5. Switch between two terminal windows using Alt-Tab. Ensure the behaviour matches the GPW setting and IPW setting.
6. Same as #5, but switch using the panel WindowList applet.
7. Change the settings in g-k-p, ensure the applet picks the changes.