now gnome-settings-daemon resets the configuration is asked by gconf flag overrideSettings
This commit is contained in:
parent
12fdfa6484
commit
2bc51a2486
6 changed files with 214 additions and 158 deletions
|
@ -7,3 +7,4 @@ Makefile.in
|
|||
*.o
|
||||
gnome-keyboard-properties
|
||||
keyboard.desktop
|
||||
gnome-keyboard-properties.gladep
|
||||
|
|
|
@ -42,176 +42,169 @@
|
|||
char *
|
||||
xci_desc_to_utf8 (XklConfigItem * ci)
|
||||
{
|
||||
char *sd = g_strstrip (ci->description);
|
||||
return sd[0] == 0 ? g_strdup (ci->name) :
|
||||
g_locale_to_utf8 (sd, -1, NULL, NULL, NULL);
|
||||
char *sd = g_strstrip (ci->description);
|
||||
return sd[0] == 0 ? g_strdup (ci->name) :
|
||||
g_locale_to_utf8 (sd, -1, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static GConfValue *
|
||||
model_from_widget (GConfPropertyEditor * peditor, GConfValue * value)
|
||||
{
|
||||
GConfValue *new_value = gconf_value_new (GCONF_VALUE_STRING);
|
||||
const char *rvs = "";
|
||||
if (value->type == GCONF_VALUE_INT) {
|
||||
GtkWidget *omenu =
|
||||
GTK_WIDGET (gconf_property_editor_get_ui_control
|
||||
(peditor));
|
||||
const int ivalue = gconf_value_get_int (value);
|
||||
GtkWidget *menu =
|
||||
gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
|
||||
GList *items = GTK_MENU_SHELL (menu)->children;
|
||||
while (items != NULL) {
|
||||
GtkWidget *item = GTK_WIDGET (items->data);
|
||||
const int itemNo =
|
||||
GPOINTER_TO_INT (g_object_get_data
|
||||
(G_OBJECT (item), "itemNo"));
|
||||
if (itemNo == ivalue) {
|
||||
rvs = (const char *)
|
||||
g_object_get_data (G_OBJECT (item),
|
||||
"itemId");
|
||||
break;
|
||||
}
|
||||
items = items->next;
|
||||
}
|
||||
GConfValue *new_value = gconf_value_new (GCONF_VALUE_STRING);
|
||||
const char *rvs = "";
|
||||
if (value->type == GCONF_VALUE_INT)
|
||||
{
|
||||
GtkWidget *omenu =
|
||||
GTK_WIDGET (gconf_property_editor_get_ui_control (peditor));
|
||||
const int ivalue = gconf_value_get_int (value);
|
||||
GtkWidget *menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
|
||||
GList *items = GTK_MENU_SHELL (menu)->children;
|
||||
while (items != NULL)
|
||||
{
|
||||
GtkWidget *item = GTK_WIDGET (items->data);
|
||||
const int itemNo =
|
||||
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "itemNo"));
|
||||
if (itemNo == ivalue)
|
||||
{
|
||||
rvs = (const char *)
|
||||
g_object_get_data (G_OBJECT (item), "itemId");
|
||||
break;
|
||||
}
|
||||
items = items->next;
|
||||
}
|
||||
gconf_value_set_string (new_value, rvs);
|
||||
return new_value;
|
||||
}
|
||||
gconf_value_set_string (new_value, rvs);
|
||||
return new_value;
|
||||
}
|
||||
|
||||
static GConfValue *
|
||||
model_to_widget (GConfPropertyEditor * peditor, GConfValue * value)
|
||||
{
|
||||
GConfValue *new_value;
|
||||
int rvi = -1;
|
||||
GConfValue *new_value;
|
||||
int rvi = -1;
|
||||
|
||||
new_value = gconf_value_new (GCONF_VALUE_INT);
|
||||
new_value = gconf_value_new (GCONF_VALUE_INT);
|
||||
|
||||
if (value->type == GCONF_VALUE_STRING) {
|
||||
GtkWidget *omenu =
|
||||
GTK_WIDGET (gconf_property_editor_get_ui_control
|
||||
(peditor));
|
||||
const char *svalue = gconf_value_get_string (value);
|
||||
GtkWidget *menu =
|
||||
gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
|
||||
GList *items = GTK_MENU_SHELL (menu)->children;
|
||||
while (items != NULL) {
|
||||
GtkWidget *item = GTK_WIDGET (items->data);
|
||||
const char *itemId = (const char *)
|
||||
g_object_get_data (G_OBJECT (item), "itemId");
|
||||
if (!g_strcasecmp (itemId, svalue)) {
|
||||
rvi =
|
||||
GPOINTER_TO_INT (g_object_get_data
|
||||
(G_OBJECT (item),
|
||||
"itemNo"));
|
||||
break;
|
||||
}
|
||||
items = items->next;
|
||||
}
|
||||
if (value->type == GCONF_VALUE_STRING)
|
||||
{
|
||||
GtkWidget *omenu =
|
||||
GTK_WIDGET (gconf_property_editor_get_ui_control (peditor));
|
||||
const char *svalue = gconf_value_get_string (value);
|
||||
GtkWidget *menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
|
||||
GList *items = GTK_MENU_SHELL (menu)->children;
|
||||
while (items != NULL)
|
||||
{
|
||||
GtkWidget *item = GTK_WIDGET (items->data);
|
||||
const char *itemId = (const char *)
|
||||
g_object_get_data (G_OBJECT (item), "itemId");
|
||||
if (!g_strcasecmp (itemId, svalue))
|
||||
{
|
||||
rvi =
|
||||
GPOINTER_TO_INT (g_object_get_data
|
||||
(G_OBJECT (item), "itemNo"));
|
||||
break;
|
||||
}
|
||||
items = items->next;
|
||||
}
|
||||
gconf_value_set_int (new_value, rvi);
|
||||
}
|
||||
gconf_value_set_int (new_value, rvi);
|
||||
|
||||
return new_value;
|
||||
return new_value;
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_xkb_tabs (GladeXML * dialog)
|
||||
{
|
||||
XklConfigFreeRegistry ();
|
||||
XklConfigTerm ();
|
||||
XklConfigFreeRegistry ();
|
||||
XklConfigTerm ();
|
||||
}
|
||||
|
||||
static void
|
||||
add_model_to_option_menu (const XklConfigItemPtr configItem,
|
||||
GtkWidget * menu)
|
||||
add_model_to_option_menu (const XklConfigItemPtr configItem, GtkWidget * menu)
|
||||
{
|
||||
GList *existingItemNode = GTK_MENU_SHELL (menu)->children;
|
||||
char *utfModelName = xci_desc_to_utf8 (configItem);
|
||||
GtkWidget *menuItem = gtk_menu_item_new_with_label (utfModelName);
|
||||
int position = 0;
|
||||
g_object_set_data_full (G_OBJECT (menuItem), "itemId",
|
||||
g_strdup (configItem->name),
|
||||
(GDestroyNotify) g_free);
|
||||
for (; existingItemNode != NULL;
|
||||
position++, existingItemNode = existingItemNode->next) {
|
||||
GtkWidget *menuItem = GTK_WIDGET (existingItemNode->data);
|
||||
GtkWidget *lbl = GTK_BIN (menuItem)->child;
|
||||
const char *txt = gtk_label_get_text (GTK_LABEL (lbl));
|
||||
if (g_strcasecmp (txt, utfModelName) > 0)
|
||||
break;
|
||||
}
|
||||
g_free (utfModelName);
|
||||
gtk_menu_shell_insert (GTK_MENU_SHELL (menu),
|
||||
GTK_WIDGET (menuItem), position);
|
||||
GList *existingItemNode = GTK_MENU_SHELL (menu)->children;
|
||||
char *utfModelName = xci_desc_to_utf8 (configItem);
|
||||
GtkWidget *menuItem = gtk_menu_item_new_with_label (utfModelName);
|
||||
int position = 0;
|
||||
g_object_set_data_full (G_OBJECT (menuItem), "itemId",
|
||||
g_strdup (configItem->name),
|
||||
(GDestroyNotify) g_free);
|
||||
for (; existingItemNode != NULL;
|
||||
position++, existingItemNode = existingItemNode->next)
|
||||
{
|
||||
GtkWidget *menuItem = GTK_WIDGET (existingItemNode->data);
|
||||
GtkWidget *lbl = GTK_BIN (menuItem)->child;
|
||||
const char *txt = gtk_label_get_text (GTK_LABEL (lbl));
|
||||
if (g_strcasecmp (txt, utfModelName) > 0)
|
||||
break;
|
||||
}
|
||||
g_free (utfModelName);
|
||||
gtk_menu_shell_insert (GTK_MENU_SHELL (menu),
|
||||
GTK_WIDGET (menuItem), position);
|
||||
}
|
||||
|
||||
static void
|
||||
fill_models_option_menu (GladeXML * dialog)
|
||||
{
|
||||
GtkWidget *menu = gtk_menu_new ();
|
||||
int itemCounter = 0;
|
||||
GList *items;
|
||||
XklConfigEnumModels ((ConfigItemProcessFunc)
|
||||
add_model_to_option_menu, menu);
|
||||
GtkWidget *menu = gtk_menu_new ();
|
||||
int itemCounter = 0;
|
||||
GList *items;
|
||||
XklConfigEnumModels ((ConfigItemProcessFunc)
|
||||
add_model_to_option_menu, menu);
|
||||
|
||||
items = GTK_MENU_SHELL (menu)->children;
|
||||
while (items != NULL) {
|
||||
GtkWidget *menuItem = GTK_WIDGET (items->data);
|
||||
g_object_set_data (G_OBJECT (menuItem), "itemNo",
|
||||
GINT_TO_POINTER (itemCounter++));
|
||||
items = items->next;
|
||||
}
|
||||
items = GTK_MENU_SHELL (menu)->children;
|
||||
while (items != NULL)
|
||||
{
|
||||
GtkWidget *menuItem = GTK_WIDGET (items->data);
|
||||
g_object_set_data (G_OBJECT (menuItem), "itemNo",
|
||||
GINT_TO_POINTER (itemCounter++));
|
||||
items = items->next;
|
||||
}
|
||||
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (WID ("xkb_models")),
|
||||
GTK_WIDGET (menu));
|
||||
gtk_widget_show_all (menu);
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (WID ("xkb_models")),
|
||||
GTK_WIDGET (menu));
|
||||
gtk_widget_show_all (menu);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_to_defaults (GtkWidget * button, GladeXML * dialog)
|
||||
{
|
||||
gconf_client_set_bool (gconf_client_get_default (),
|
||||
GSWITCHIT_CONFIG_XKB_KEY_OVERRIDE_SETTINGS,
|
||||
TRUE, NULL);
|
||||
/* all the rest is g-s-d's business */
|
||||
}
|
||||
|
||||
void
|
||||
setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset)
|
||||
{
|
||||
GObject *peditor;
|
||||
XklConfigInit ();
|
||||
XklConfigLoadRegistry ();
|
||||
|
||||
XklConfigInit ();
|
||||
XklConfigLoadRegistry ();
|
||||
fill_models_option_menu (dialog);
|
||||
|
||||
fill_models_option_menu (dialog);
|
||||
gconf_peditor_new_select_menu
|
||||
(changeset, (gchar *) GSWITCHIT_CONFIG_XKB_KEY_MODEL,
|
||||
WID ("xkb_models"),
|
||||
"conv-to-widget-cb", model_to_widget,
|
||||
"conv-from-widget-cb", model_from_widget, NULL);
|
||||
|
||||
peditor = gconf_peditor_new_boolean
|
||||
(changeset,
|
||||
(gchar *) GSWITCHIT_CONFIG_XKB_KEY_OVERRIDE_SETTINGS,
|
||||
WID ("xkb_use_custom_config"), NULL);
|
||||
fill_available_layouts_tree (dialog);
|
||||
fill_available_options_tree (dialog);
|
||||
prepare_selected_layouts_tree (dialog);
|
||||
prepare_selected_options_tree (dialog);
|
||||
fill_selected_layouts_tree (dialog);
|
||||
fill_selected_options_tree (dialog);
|
||||
|
||||
gtk_widget_set_sensitive (WID ("xkb_models_box"), FALSE);
|
||||
gtk_widget_set_sensitive (WID ("xkb_layouts_box"), FALSE);
|
||||
gtk_widget_set_sensitive (WID ("xkb_options_box"), FALSE);
|
||||
register_layouts_buttons_handlers (dialog);
|
||||
register_options_buttons_handlers (dialog);
|
||||
g_signal_connect (G_OBJECT (WID ("xkb_reset_to_defaults")), "clicked",
|
||||
G_CALLBACK (reset_to_defaults), dialog);
|
||||
|
||||
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
|
||||
WID ("xkb_models_box"));
|
||||
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
|
||||
WID ("xkb_layouts_box"));
|
||||
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
|
||||
WID ("xkb_options_box"));
|
||||
register_layouts_gconf_listener (dialog);
|
||||
register_options_gconf_listener (dialog);
|
||||
|
||||
gconf_peditor_new_select_menu
|
||||
(changeset, (gchar *) GSWITCHIT_CONFIG_XKB_KEY_MODEL,
|
||||
WID ("xkb_models"),
|
||||
"conv-to-widget-cb", model_to_widget,
|
||||
"conv-from-widget-cb", model_from_widget, NULL);
|
||||
|
||||
fill_available_layouts_tree (dialog);
|
||||
fill_available_options_tree (dialog);
|
||||
prepare_selected_layouts_tree (dialog);
|
||||
prepare_selected_options_tree (dialog);
|
||||
fill_selected_layouts_tree (dialog);
|
||||
fill_selected_options_tree (dialog);
|
||||
|
||||
register_layouts_buttons_handlers (dialog);
|
||||
register_options_buttons_handlers (dialog);
|
||||
|
||||
register_layouts_gconf_listener (dialog);
|
||||
register_options_gconf_listener (dialog);
|
||||
|
||||
g_signal_connect (G_OBJECT (WID ("keyboard_dialog")),
|
||||
"destroy", G_CALLBACK (cleanup_xkb_tabs),
|
||||
dialog);
|
||||
g_signal_connect (G_OBJECT (WID ("keyboard_dialog")),
|
||||
"destroy", G_CALLBACK (cleanup_xkb_tabs), dialog);
|
||||
}
|
||||
|
|
|
@ -1121,24 +1121,6 @@
|
|||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="xkb_use_custom_config">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Ignore system configuration</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="xkb_models_box">
|
||||
<property name="visible">True</property>
|
||||
|
@ -1179,6 +1161,76 @@
|
|||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="xkb_reset_to_defaults">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xscale">0</property>
|
||||
<property name="yscale">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox29">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">2</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image3">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-refresh</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label51">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Reset to defaults</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
|
2
gnome-settings-daemon/.indent.pro
vendored
Normal file
2
gnome-settings-daemon/.indent.pro
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
-kr -i8 -pcs -lps -psl
|
||||
|
|
@ -35,6 +35,7 @@
|
|||
#include <libgnome/gnome-i18n.h>
|
||||
|
||||
#include <libxklavier/xklavier.h>
|
||||
#include <libxklavier/xklavier_config.h>
|
||||
#include <libgswitchit/gswitchit_xkb_config.h>
|
||||
|
||||
#include "gnome-settings-keyboard-xkb.h"
|
||||
|
@ -77,6 +78,9 @@ apply_settings (void)
|
|||
{
|
||||
GConfClient *confClient;
|
||||
|
||||
if (!initedOk)
|
||||
return;
|
||||
|
||||
memset (&gswic, 0, sizeof (gswic));
|
||||
|
||||
confClient = gconf_client_get_default ();
|
||||
|
@ -84,12 +88,17 @@ apply_settings (void)
|
|||
g_object_unref (confClient);
|
||||
GSwitchItXkbConfigLoad (&gswic);
|
||||
|
||||
if (!gswic.overrideSettings)
|
||||
if (gswic.overrideSettings) {
|
||||
/* initialization - from the system settings */
|
||||
GSwitchItXkbConfigLoadInitial (&gswic);
|
||||
|
||||
if (!GSwitchItXkbConfigActivate (&gswic)) {
|
||||
g_warning ("Could not activate the XKB configuration");
|
||||
activation_error ();
|
||||
gswic.overrideSettings = FALSE;
|
||||
GSwitchItXkbConfigSave (&gswic);
|
||||
} else {
|
||||
if (!GSwitchItXkbConfigActivate (&gswic)) {
|
||||
g_warning
|
||||
("Could not activate the XKB configuration");
|
||||
activation_error ();
|
||||
}
|
||||
}
|
||||
|
||||
GSwitchItXkbConfigTerm (&gswic);
|
||||
|
@ -110,6 +119,5 @@ gnome_settings_keyboard_xkb_init (GConfClient * client)
|
|||
void
|
||||
gnome_settings_keyboard_xkb_load (GConfClient * client)
|
||||
{
|
||||
if (initedOk)
|
||||
apply_settings ();
|
||||
apply_settings ();
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
<type>bool</type>
|
||||
|
||||
<default>false</default>
|
||||
<default>true</default>
|
||||
|
||||
<locale name="C">
|
||||
<short>XKB settings should be overridden</short>
|
||||
<long>XKB settings should be overridden</long>
|
||||
<short>XKB settings in gconf will be overridden from the system ASAP</short>
|
||||
<long>Very soon, XKB settings in gconf will be overridden (from the system configuration)</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue