This commit is contained in:
Sergey V. Udaltsov
2005-07-26 20:38:25 +00:00
parent 30347dd0e1
commit 25ac663f39
11 changed files with 207 additions and 106 deletions

View File

@@ -1,3 +1,29 @@
2005-07-15 Mark McLoughlin <mark@skynet.ie>
Re-work the way some of the XKB GConf keys are handled.
See bug #310513
* gnome-keyboard-properties-xkb.c:
(set_model_text), (model_key_changed), (setup_model_entry),
(setup_xkb_tabs): make the "model" entry not be a peditor
to we can correctly display the XKB default if the GConf
key is unset.
(enable_disable_restoring): update for API change.
(reset_to_defaults): reset to defaults by unsetting the
GConf keys rather than setting overrideSettings to true.
* gnome-keyboard-properties-xkblt.c:
(xkb_layouts_get_selected_list): if the "layouts" key is unset,
use the layouts list from the XKB defaults.
* gnome-keyboard-properties-xkbot.c:
(xkb_options_get_selected_list): ditto for the "options" key.
* gnome-keyboard-properties-xkb.h: include gswitchit_config.h,
declare xkb_options_load_options to avoid warnings, make
xkb_(layouts|options)_get_selected_list() functions instead
of macros.
2005-05-22 Sebastien Bacher <seb128@debian.org>
* gnome-keyboard-properties-xkbot.c: (xkb_options_add_group):

View File

@@ -40,7 +40,7 @@
#include "gnome-keyboard-properties-xkb.h"
static GSwitchItKbdConfig initialConfig;
GSwitchItKbdConfig initialConfig;
GConfClient *xkbGConfClient;
@@ -52,50 +52,67 @@ xci_desc_to_utf8 (XklConfigItem * ci)
g_locale_to_utf8 (sd, -1, NULL, NULL, NULL);
}
static GConfValue *
model_from_widget (GConfPropertyEditor * peditor, GConfValue * value)
static void
set_model_text (GtkWidget * entry,
GConfValue * value)
{
GConfValue *new_value;
XklConfigItem ci;
const char * model = NULL;
new_value = gconf_value_new (GCONF_VALUE_STRING);
if (value->type == GCONF_VALUE_STRING)
if (value != NULL && value->type == GCONF_VALUE_STRING)
{
GObject* widget = gconf_property_editor_get_ui_control(peditor);
gchar* n = g_object_get_data (widget, "xkbModelName");
gconf_value_set_string (new_value, n);
model = gconf_value_get_string (value);
if (model != NULL && model[0] == '\0')
model = NULL;
}
if (model == NULL)
model = initialConfig.model;
g_snprintf (ci.name, sizeof (ci.name), "%s", model);
if (XklConfigFindModel (&ci))
{
char * d;
d = xci_desc_to_utf8 (&ci);
gtk_entry_set_text (GTK_ENTRY (entry), d);
g_free (d);
}
else
gconf_value_set_string (new_value, _("Unknown"));
return new_value;
{
gtk_entry_set_text (GTK_ENTRY (entry), _("Unknown"));
}
}
static GConfValue *
model_to_widget (GConfPropertyEditor * peditor, GConfValue * value)
static void
model_key_changed (GConfClient * client,
guint cnxn_id,
GConfEntry * entry,
GladeXML * dialog)
{
GConfValue *new_value;
set_model_text (WID ("xkb_model"),
gconf_entry_get_value (entry));
new_value = gconf_value_new (GCONF_VALUE_STRING);
enable_disable_restoring (dialog);
}
if (value->type == GCONF_VALUE_STRING)
{
XklConfigItem ci;
g_snprintf( ci.name, sizeof (ci.name), "%s", gconf_value_get_string( value ) );
if ( XklConfigFindModel( &ci ) )
{
GObject* widget = gconf_property_editor_get_ui_control(peditor);
gchar* d = xci_desc_to_utf8 (&ci);
static void
setup_model_entry (GladeXML * dialog)
{
GConfValue * value;
g_object_set_data_full (widget, "xkbModelName", g_strdup (ci.name), g_free);
gconf_value_set_string (new_value, d);
g_free (d);
}
else
gconf_value_set_string (new_value, _("Unknown"));
}
value = gconf_client_get (xkbGConfClient,
GSWITCHIT_KBD_CONFIG_KEY_MODEL,
NULL);
set_model_text (WID ("xkb_model"), value);
if (value != NULL)
gconf_value_free (value);
return new_value;
gconf_client_notify_add (xkbGConfClient,
GSWITCHIT_KBD_CONFIG_KEY_MODEL,
(GConfClientNotifyFunc) model_key_changed,
dialog, NULL, NULL);
}
static void
@@ -112,17 +129,14 @@ cleanup_xkb_tabs (GladeXML * dialog)
static void
reset_to_defaults (GtkWidget * button, GladeXML * dialog)
{
gconf_client_set_bool (xkbGConfClient,
GSWITCHIT_KBD_CONFIG_KEY_OVERRIDE_SETTINGS,
TRUE, NULL);
/* all the rest is g-s-d's business */
}
GSwitchItKbdConfig emptyKbdConfig;
static void
update_model (GConfClient * client,
guint cnxn_id, GConfEntry * entry, GladeXML * dialog)
{
enable_disable_restoring (dialog);
GSwitchItKbdConfigInit (&emptyKbdConfig, xkbGConfClient);
GSwitchItKbdConfigSaveToGConfBackup (&emptyKbdConfig);
GSwitchItKbdConfigSaveToGConf (&emptyKbdConfig);
GSwitchItKbdConfigTerm (&emptyKbdConfig);
/* all the rest is g-s-d's business */
}
static void
@@ -144,11 +158,10 @@ setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset)
XklConfigInit ();
XklConfigLoadRegistry ();
gconf_peditor_new_string
(changeset, (gchar *) GSWITCHIT_KBD_CONFIG_KEY_MODEL,
WID ("xkb_model"),
"conv-to-widget-cb", model_to_widget,
"conv-from-widget-cb", model_from_widget, NULL);
GSwitchItKbdConfigInit (&initialConfig, xkbGConfClient);
GSwitchItKbdConfigLoadFromXInitial (&initialConfig);
setup_model_entry (dialog);
peditor = gconf_peditor_new_boolean
(changeset, (gchar *) GSWITCHIT_CONFIG_KEY_GROUP_PER_WINDOW,
@@ -177,14 +190,6 @@ setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset)
g_signal_connect (G_OBJECT (WID ("keyboard_dialog")),
"destroy", G_CALLBACK (cleanup_xkb_tabs), dialog);
gconf_client_notify_add (xkbGConfClient,
GSWITCHIT_KBD_CONFIG_KEY_MODEL,
(GConfClientNotifyFunc)
update_model, dialog, NULL, NULL);
GSwitchItKbdConfigInit (&initialConfig, xkbGConfClient);
GSwitchItKbdConfigLoadFromXInitial (&initialConfig);
enable_disable_restoring (dialog);
xkb_layouts_enable_disable_default (dialog,
gconf_client_get_bool (xkbGConfClient,
@@ -199,7 +204,7 @@ enable_disable_restoring (GladeXML * dialog)
gboolean enable;
GSwitchItKbdConfigInit (&gswic, xkbGConfClient);
GSwitchItKbdConfigLoadFromGConf (&gswic);
GSwitchItKbdConfigLoadFromGConf (&gswic, NULL);
enable = !GSwitchItKbdConfigEquals (&gswic, &initialConfig);

View File

@@ -27,6 +27,8 @@
#include <libxklavier/xklavier_config.h>
#include <gconf/gconf-client.h>
#include "libgswitchit/gswitchit_config.h"
G_BEGIN_DECLS
#define SEL_LAYOUT_TREE_COL_DESCRIPTION 0
@@ -39,6 +41,7 @@ G_BEGIN_DECLS
#define CWID(s) glade_xml_get_widget (chooserDialog, s)
extern GConfClient *xkbGConfClient;
extern GSwitchItKbdConfig initialConfig;
extern void setup_xkb_tabs (GladeXML * dialog,
GConfChangeSet * changeset);
@@ -64,6 +67,8 @@ extern void xkb_layouts_prepare_selected_tree (GladeXML * dialog,
extern void xkb_options_prepare_selected_tree (GladeXML * dialog);
extern void xkb_options_load_options (GladeXML * dialog);
extern void clear_xkb_elements_list (GSList * list);
extern char *xci_desc_to_utf8 (XklConfigItem * ci);
@@ -81,21 +86,14 @@ extern void xkb_layout_choose (GladeXML * dialog);
extern void xkb_layouts_enable_disable_default (GladeXML * dialog,
gboolean enable);
#define xkb_layouts_get_selected_list() \
gconf_client_get_list (gconf_client_get_default (), \
GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS, \
GCONF_VALUE_STRING, NULL)
extern GSList *xkb_layouts_get_selected_list (void);
extern GSList *xkb_options_get_selected_list (void);
#define xkb_layouts_set_selected_list(list) \
gconf_client_set_list (gconf_client_get_default (), \
GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS, \
GCONF_VALUE_STRING, (list), NULL)
#define xkb_options_get_selected_list() \
gconf_client_get_list (gconf_client_get_default (), \
GSWITCHIT_KBD_CONFIG_KEY_OPTIONS, \
GCONF_VALUE_STRING, NULL)
#define xkb_options_set_selected_list(list) \
gconf_client_set_list (gconf_client_get_default (), \
GSWITCHIT_KBD_CONFIG_KEY_OPTIONS, \

View File

@@ -65,6 +65,28 @@ clear_xkb_elements_list (GSList * list)
}
}
GSList *
xkb_layouts_get_selected_list (void)
{
GSList *retval;
retval = gconf_client_get_list (xkbGConfClient,
GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS,
GCONF_VALUE_STRING,
NULL);
if (retval == NULL)
{
GSList *curLayout;
for (curLayout = initialConfig.layouts; curLayout != NULL; curLayout = curLayout->next)
retval = g_slist_prepend (retval, g_strdup (curLayout->data));
retval = g_slist_reverse (retval);
}
return retval;
}
static void
save_default_group (int aDefaultGroup)
{

View File

@@ -51,6 +51,28 @@ static GSList *currentRadioGroup = NULL;
#define GCONFSTATE_PROP "gconfState"
#define EXPANDERS_PROP "expandersList"
GSList *
xkb_options_get_selected_list (void)
{
GSList *retval;
retval = gconf_client_get_list (xkbGConfClient,
GSWITCHIT_KBD_CONFIG_KEY_OPTIONS,
GCONF_VALUE_STRING,
NULL);
if (retval == NULL)
{
GSList *curOption;
for (curOption = initialConfig.options; curOption != NULL; curOption = curOption->next)
retval = g_slist_prepend (retval, g_strdup (curOption->data));
retval = g_slist_reverse (retval);
}
return retval;
}
static GtkWidget *
xkb_options_get_expander (GtkWidget * option_button)
{