fixing #164090, big UI change
This commit is contained in:
parent
1abaf69ac1
commit
c8aede029c
4 changed files with 255 additions and 474 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2005-01-19 Sergey V. Udaltsov <svu@gnome.org>
|
||||||
|
|
||||||
|
* gnome-keyboard-properties-xkb.c,
|
||||||
|
gnome-keyboard-properties-xkbot.c
|
||||||
|
gnome-keyboard-properties.glade: big change in the layout options UI.
|
||||||
|
Fixing #164090
|
||||||
|
|
||||||
2005-01-16 Sergey V. Udaltsov <svu@gnome.org>
|
2005-01-16 Sergey V. Udaltsov <svu@gnome.org>
|
||||||
|
|
||||||
* gnome-keyboard-properties.glade: fixed #159685
|
* gnome-keyboard-properties.glade: fixed #159685
|
||||||
|
|
|
@ -162,12 +162,9 @@ setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset)
|
||||||
xkb_layouts_fill_selected_tree (dialog);
|
xkb_layouts_fill_selected_tree (dialog);
|
||||||
|
|
||||||
/* tab 3 */
|
/* tab 3 */
|
||||||
xkb_options_fill_available_tree (dialog);
|
xkb_options_load_options (dialog);
|
||||||
xkb_options_prepare_selected_tree (dialog);
|
|
||||||
xkb_options_fill_selected_tree (dialog);
|
|
||||||
|
|
||||||
xkb_layouts_register_buttons_handlers (dialog);
|
xkb_layouts_register_buttons_handlers (dialog);
|
||||||
xkb_options_register_buttons_handlers (dialog);
|
|
||||||
g_signal_connect (G_OBJECT (WID ("xkb_reset_to_defaults")), "clicked",
|
g_signal_connect (G_OBJECT (WID ("xkb_reset_to_defaults")), "clicked",
|
||||||
G_CALLBACK (reset_to_defaults), dialog);
|
G_CALLBACK (reset_to_defaults), dialog);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* Copyright (C) 2003 Sergey V. Oudaltsov
|
* Copyright (C) 2003 Sergey V. Oudaltsov
|
||||||
*
|
*
|
||||||
* Written by: Sergey V. Oudaltsov <svu@users.sourceforge.net>
|
* Written by: Sergey V. Oudaltsov <svu@users.sourceforge.net>
|
||||||
|
* John Spray <spray_john@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -39,332 +40,284 @@
|
||||||
|
|
||||||
#include "gnome-keyboard-properties-xkb.h"
|
#include "gnome-keyboard-properties-xkb.h"
|
||||||
|
|
||||||
static GtkTreeIter current1stLevelIter;
|
static const char *current1stLevelId = NULL;
|
||||||
static const char *current1stLevelId;
|
static GtkWidget *currentVbox = NULL;
|
||||||
|
static GtkWidget *currentNoneRadio = NULL;
|
||||||
|
static gboolean currentMultiSelect = FALSE;
|
||||||
|
static GSList *currentRadioGroup = NULL;
|
||||||
|
|
||||||
static gboolean
|
#define OPTION_ID_PROP "optionID"
|
||||||
can_add_option (GladeXML * dialog)
|
#define SELCOUNTER_PROP "selectionCounter"
|
||||||
|
#define GCONFSTATE_PROP "gconfState"
|
||||||
|
#define EXPANDERS_PROP "expandersList"
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
xkb_options_get_expander (GtkWidget * option_button)
|
||||||
{
|
{
|
||||||
GtkWidget *availableOptionsTree = WID ("xkb_options_available");
|
return gtk_widget_get_parent (
|
||||||
GtkWidget *selectedOptionsTree = WID ("xkb_options_selected");
|
gtk_widget_get_parent (
|
||||||
GtkTreeSelection *aSelection =
|
gtk_widget_get_parent (option_button)));
|
||||||
gtk_tree_view_get_selection (GTK_TREE_VIEW (availableOptionsTree));
|
}
|
||||||
GtkTreeIter aiter, siter, groupIter;
|
|
||||||
GtkTreeModel *availableOptionsModel, *selectedOptionsModel;
|
|
||||||
GtkTreePath *path, *groupPath;
|
|
||||||
char *selectedOptionId = NULL, *selectedGroupId =
|
|
||||||
NULL, *selectedFullOptionId = NULL;
|
|
||||||
gboolean retval = FALSE, multipleAllowed = TRUE;
|
|
||||||
int depth;
|
|
||||||
|
|
||||||
if (!gtk_tree_selection_get_selected
|
static int
|
||||||
(aSelection, &availableOptionsModel, &aiter))
|
xkb_options_expander_selcounter_get (GtkWidget * expander)
|
||||||
return FALSE;
|
{
|
||||||
|
return GPOINTER_TO_INT(g_object_get_data (G_OBJECT (expander), SELCOUNTER_PROP));
|
||||||
|
}
|
||||||
|
|
||||||
path = gtk_tree_model_get_path (availableOptionsModel, &aiter);
|
static void
|
||||||
if (path == NULL)
|
xkb_options_expander_selcounter_add (GtkWidget * expander, int value)
|
||||||
return FALSE;
|
{
|
||||||
|
g_object_set_data (G_OBJECT (expander), SELCOUNTER_PROP,
|
||||||
|
GINT_TO_POINTER (xkb_options_expander_selcounter_get (expander) + value));
|
||||||
|
}
|
||||||
|
|
||||||
depth = gtk_tree_path_get_depth (path);
|
static void
|
||||||
|
xkb_options_expander_highlight (GtkWidget * expander)
|
||||||
|
{
|
||||||
|
char * utfGroupName = g_object_get_data (G_OBJECT (expander), "utfGroupName");
|
||||||
|
int counter = xkb_options_expander_selcounter_get (expander);
|
||||||
|
gchar *titlemarkup = g_strconcat (counter > 0 ? "<span weight=\"bold\">" : "<span>",
|
||||||
|
utfGroupName, "</span>", NULL);
|
||||||
|
gtk_expander_set_label (GTK_EXPANDER (expander), titlemarkup);
|
||||||
|
g_free (titlemarkup);
|
||||||
|
}
|
||||||
|
|
||||||
if (depth != 2)
|
/* 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;
|
||||||
|
GSList *optionsList = xkb_options_get_selected_list ();
|
||||||
|
GSList *option;
|
||||||
|
for (option = optionsList ; option != NULL ; option = option->next)
|
||||||
|
if (!strcmp ((gchar*)option->data, optionname))
|
||||||
|
already_selected = TRUE;
|
||||||
|
|
||||||
|
if (!already_selected)
|
||||||
|
optionsList = g_slist_append (optionsList, g_strdup (optionname));
|
||||||
|
xkb_options_set_selected_list (optionsList);
|
||||||
|
|
||||||
|
clear_xkb_elements_list (optionsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove all occurences of optionname from the backend's selection list */
|
||||||
|
static void
|
||||||
|
xkb_options_deselect (gchar *optionname)
|
||||||
|
{
|
||||||
|
GSList *optionsList = xkb_options_get_selected_list ();
|
||||||
|
GSList *nodetmp;
|
||||||
|
GSList *option = optionsList;
|
||||||
|
while (option != NULL)
|
||||||
{
|
{
|
||||||
gtk_tree_path_free (path);
|
gchar *id = (char *) option->data;
|
||||||
return FALSE;
|
if (!strcmp(id, optionname))
|
||||||
|
{
|
||||||
|
nodetmp = option->next;
|
||||||
|
g_free (id);
|
||||||
|
optionsList = g_slist_remove_link (optionsList, option);
|
||||||
|
g_slist_free_1 (option);
|
||||||
|
option=nodetmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
option = option->next;
|
||||||
}
|
}
|
||||||
|
xkb_options_set_selected_list (optionsList);
|
||||||
|
clear_xkb_elements_list (optionsList);
|
||||||
|
}
|
||||||
|
|
||||||
if (!gtk_tree_model_iter_parent (availableOptionsModel, &groupIter, &aiter))
|
/* 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;
|
||||||
|
GSList *optionsList = xkb_options_get_selected_list ();
|
||||||
|
GSList *option;
|
||||||
|
for (option = optionsList ; option != NULL ; option = option->next)
|
||||||
{
|
{
|
||||||
gtk_tree_path_free (path);
|
if (!strcmp ((gchar*)option->data, optionname))
|
||||||
return FALSE;
|
retval = TRUE;
|
||||||
}
|
}
|
||||||
groupPath = gtk_tree_model_get_path (availableOptionsModel, &groupIter);
|
clear_xkb_elements_list (optionsList);
|
||||||
if (groupPath == NULL)
|
|
||||||
{
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_model_get (availableOptionsModel, &groupIter, 2,
|
|
||||||
&multipleAllowed, -1);
|
|
||||||
|
|
||||||
gtk_tree_model_get (availableOptionsModel, &aiter, 1,
|
|
||||||
&selectedFullOptionId, -1);
|
|
||||||
|
|
||||||
if (!GSwitchItKbdConfigSplitItems
|
|
||||||
(selectedFullOptionId, &selectedGroupId, &selectedOptionId))
|
|
||||||
{
|
|
||||||
gtk_tree_path_free (groupPath);
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
selectedGroupId = g_strdup (selectedGroupId);
|
|
||||||
selectedOptionId = g_strdup (selectedOptionId);
|
|
||||||
|
|
||||||
selectedOptionsModel =
|
|
||||||
gtk_tree_view_get_model (GTK_TREE_VIEW (selectedOptionsTree));
|
|
||||||
|
|
||||||
retval = TRUE;
|
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first (selectedOptionsModel, &siter))
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
char *sid = NULL;
|
|
||||||
gtk_tree_model_get (selectedOptionsModel, &siter, 1, &sid, -1);
|
|
||||||
if (multipleAllowed)
|
|
||||||
{
|
|
||||||
// look for the _same_ option - and do not allow it twice
|
|
||||||
if (!g_strcasecmp (sid, selectedFullOptionId))
|
|
||||||
{
|
|
||||||
retval = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// look for options within same group
|
|
||||||
char *sgid = NULL, *soid = NULL;
|
|
||||||
gtk_tree_model_get (selectedOptionsModel, &siter, 1, &sid, -1);
|
|
||||||
if (GSwitchItKbdConfigSplitItems
|
|
||||||
(sid, &sgid, &soid)
|
|
||||||
&& !g_strcasecmp (sgid, selectedGroupId))
|
|
||||||
{
|
|
||||||
retval = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_free (sid);
|
|
||||||
}
|
|
||||||
while (retval && gtk_tree_model_iter_next
|
|
||||||
(selectedOptionsModel, &siter));
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (selectedFullOptionId);
|
|
||||||
g_free (selectedGroupId);
|
|
||||||
g_free (selectedOptionId);
|
|
||||||
|
|
||||||
gtk_tree_path_free (groupPath);
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update xkb backend to reflect the new UI state */
|
||||||
static void
|
static void
|
||||||
xkb_options_enable_disable_buttons (GladeXML * dialog)
|
option_toggled_cb (GtkWidget *checkbutton, gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *addOptionBtn = WID ("xkb_options_add");
|
gpointer optionID = g_object_get_data (G_OBJECT (checkbutton), OPTION_ID_PROP);
|
||||||
GtkWidget *delOptionBtn = WID ("xkb_options_remove");
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)))
|
||||||
GtkWidget *selectedOptionsTree = WID ("xkb_options_selected");
|
xkb_options_select (optionID);
|
||||||
|
else
|
||||||
GtkTreeSelection *sSelection =
|
xkb_options_deselect (optionID);
|
||||||
gtk_tree_view_get_selection (GTK_TREE_VIEW (selectedOptionsTree));
|
|
||||||
const int nSelectedSelectedOptions =
|
|
||||||
gtk_tree_selection_count_selected_rows (sSelection);
|
|
||||||
|
|
||||||
gtk_widget_set_sensitive (addOptionBtn, can_add_option (dialog));
|
|
||||||
gtk_widget_set_sensitive (delOptionBtn, nSelectedSelectedOptions > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Update UI state from xkb backend */
|
||||||
xkb_options_prepare_selected_tree (GladeXML * dialog)
|
static void
|
||||||
|
option_update_cb (GConfClient * client,
|
||||||
|
guint cnxn_id, GConfEntry * entry, gpointer data)
|
||||||
{
|
{
|
||||||
GtkListStore *listStore =
|
GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (data);
|
||||||
gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING,
|
GtkWidget *expander = xkb_options_get_expander (GTK_WIDGET (toggle));
|
||||||
G_TYPE_STRING);
|
gboolean old_state = gtk_toggle_button_get_active (toggle);
|
||||||
GtkWidget *treeView = WID ("xkb_options_selected");
|
gboolean new_state = xkb_options_is_selected (
|
||||||
GtkCellRenderer *renderer =
|
g_object_get_data (G_OBJECT (toggle), OPTION_ID_PROP));
|
||||||
GTK_CELL_RENDERER (gtk_cell_renderer_text_new ());
|
int old_gstate = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toggle), GCONFSTATE_PROP));
|
||||||
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes (NULL,
|
int state_diff = new_state - old_gstate;
|
||||||
renderer,
|
|
||||||
"text",
|
if (GTK_WIDGET_TYPE (toggle) == GTK_TYPE_RADIO_BUTTON &&
|
||||||
0,
|
old_state == TRUE && new_state == FALSE)
|
||||||
NULL);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data (G_OBJECT (toggle), "NoneRadio")), TRUE);
|
||||||
GtkTreeSelection *selection =
|
else
|
||||||
gtk_tree_view_get_selection (GTK_TREE_VIEW (treeView));
|
gtk_toggle_button_set_active (toggle, new_state);
|
||||||
gtk_tree_view_set_model (GTK_TREE_VIEW (treeView),
|
|
||||||
GTK_TREE_MODEL (listStore));
|
g_object_set_data (G_OBJECT (toggle), GCONFSTATE_PROP, GINT_TO_POINTER (new_state));
|
||||||
gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column);
|
xkb_options_expander_selcounter_add (expander, state_diff);
|
||||||
g_signal_connect_swapped (G_OBJECT (selection), "changed",
|
xkb_options_expander_highlight (expander);
|
||||||
G_CALLBACK
|
|
||||||
(xkb_options_enable_disable_buttons), dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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
|
static void
|
||||||
xkb_options_add_selected (GtkWidget * button, GladeXML * dialog)
|
xkb_options_add_option (const XklConfigItemPtr
|
||||||
{
|
|
||||||
GtkTreeSelection *selection =
|
|
||||||
gtk_tree_view_get_selection (GTK_TREE_VIEW
|
|
||||||
(WID ("xkb_options_available")));
|
|
||||||
GtkTreeIter selectedIter;
|
|
||||||
GtkTreeModel *model;
|
|
||||||
if (gtk_tree_selection_get_selected (selection, &model, &selectedIter))
|
|
||||||
{
|
|
||||||
gchar *id;
|
|
||||||
GSList *optionsList = xkb_options_get_selected_list ();
|
|
||||||
gtk_tree_model_get (model, &selectedIter, 1, &id, -1);
|
|
||||||
optionsList = g_slist_append (optionsList, id);
|
|
||||||
xkb_options_set_selected_list (optionsList);
|
|
||||||
clear_xkb_elements_list (optionsList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xkb_options_remove_selected (GtkWidget * button, GladeXML * dialog)
|
|
||||||
{
|
|
||||||
GtkTreeSelection *selection =
|
|
||||||
gtk_tree_view_get_selection (GTK_TREE_VIEW
|
|
||||||
(WID ("xkb_options_selected")));
|
|
||||||
GtkTreeIter selectedIter;
|
|
||||||
GtkTreeModel *model;
|
|
||||||
if (gtk_tree_selection_get_selected (selection, &model, &selectedIter))
|
|
||||||
{
|
|
||||||
GSList *optionsList = xkb_options_get_selected_list ();
|
|
||||||
GtkTreePath *path = gtk_tree_model_get_path (model,
|
|
||||||
&selectedIter);
|
|
||||||
if (path != NULL)
|
|
||||||
{
|
|
||||||
int *indices = gtk_tree_path_get_indices (path);
|
|
||||||
char *id = NULL;
|
|
||||||
GSList *node2Remove = g_slist_nth (optionsList, indices[0]);
|
|
||||||
|
|
||||||
optionsList = g_slist_remove_link (optionsList, node2Remove);
|
|
||||||
|
|
||||||
id = (char *) node2Remove->data;
|
|
||||||
g_slist_free_1 (node2Remove);
|
|
||||||
|
|
||||||
g_free (id);
|
|
||||||
|
|
||||||
xkb_options_set_selected_list (optionsList);
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
}
|
|
||||||
clear_xkb_elements_list (optionsList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xkb_options_add_option_to_available_tree (const XklConfigItemPtr
|
|
||||||
configItem, GladeXML * dialog)
|
configItem, GladeXML * dialog)
|
||||||
{
|
{
|
||||||
GtkWidget *optionsTree = WID ("xkb_options_available");
|
GtkWidget *option_check;
|
||||||
GtkTreeIter iter;
|
gchar *utfOptionName = xci_desc_to_utf8 (configItem);
|
||||||
GtkTreeStore *treeStore =
|
/* Copy this out because we'll load it into the widget with set_data */
|
||||||
GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (optionsTree)));
|
gchar *fullOptionName = g_strdup(
|
||||||
const gchar *fullOptionName = GSwitchItKbdConfigMergeItems (current1stLevelId,
|
GSwitchItKbdConfigMergeItems (current1stLevelId, configItem->name));
|
||||||
configItem->name);
|
gboolean initial_state;
|
||||||
char *utfOptionName = xci_desc_to_utf8 (configItem);
|
|
||||||
|
|
||||||
gtk_tree_store_append (treeStore, &iter, ¤t1stLevelIter);
|
if (currentMultiSelect)
|
||||||
gtk_tree_store_set (treeStore, &iter, 0, utfOptionName, 1,
|
option_check = gtk_check_button_new_with_label (utfOptionName);
|
||||||
fullOptionName, -1);
|
else
|
||||||
|
{
|
||||||
|
if (currentRadioGroup == 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 (currentRadioGroup, _("Default"));
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (option_check), TRUE);
|
||||||
|
gtk_box_pack_start_defaults (GTK_BOX (currentVbox), option_check);
|
||||||
|
currentRadioGroup = gtk_radio_button_get_group (GTK_RADIO_BUTTON (option_check));
|
||||||
|
currentNoneRadio = option_check;
|
||||||
|
}
|
||||||
|
option_check = gtk_radio_button_new_with_label (currentRadioGroup, utfOptionName);
|
||||||
|
currentRadioGroup = gtk_radio_button_get_group (GTK_RADIO_BUTTON (option_check));
|
||||||
|
g_object_set_data (G_OBJECT (option_check), "NoneRadio", currentNoneRadio);
|
||||||
|
}
|
||||||
g_free (utfOptionName);
|
g_free (utfOptionName);
|
||||||
|
|
||||||
|
initial_state = xkb_options_is_selected (fullOptionName);
|
||||||
|
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (option_check), initial_state);
|
||||||
|
|
||||||
|
g_object_set_data_full (G_OBJECT (option_check), OPTION_ID_PROP, fullOptionName, g_free);
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (option_check), "toggled", G_CALLBACK (option_toggled_cb), NULL);
|
||||||
|
|
||||||
|
gconf_client_notify_add (xkbGConfClient,
|
||||||
|
GSWITCHIT_KBD_CONFIG_KEY_OPTIONS,
|
||||||
|
(GConfClientNotifyFunc)
|
||||||
|
option_update_cb, option_check, NULL, NULL);
|
||||||
|
|
||||||
|
gtk_box_pack_start_defaults (GTK_BOX (currentVbox), option_check);
|
||||||
|
|
||||||
|
xkb_options_expander_selcounter_add (xkb_options_get_expander (option_check), initial_state);
|
||||||
|
g_object_set_data (G_OBJECT (option_check), GCONFSTATE_PROP, GINT_TO_POINTER (initial_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add a group of options: create title and layout widgets and then
|
||||||
|
add widgets for all the options in the group. */
|
||||||
static void
|
static void
|
||||||
xkb_options_add_group_to_available_tree (const XklConfigItemPtr
|
xkb_options_add_group (const XklConfigItemPtr
|
||||||
configItem,
|
configItem,
|
||||||
Bool allowMultipleSelection,
|
Bool allowMultipleSelection,
|
||||||
GladeXML * dialog)
|
GladeXML * dialog)
|
||||||
{
|
{
|
||||||
GtkWidget *optionsTree = WID ("xkb_options_available");
|
GSList * expanders_list = g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP);
|
||||||
GtkTreeStore *treeStore =
|
|
||||||
GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (optionsTree)));
|
|
||||||
char *utfGroupName = xci_desc_to_utf8 (configItem);
|
|
||||||
|
|
||||||
gtk_tree_store_append (treeStore, ¤t1stLevelIter, NULL);
|
|
||||||
gtk_tree_store_set (treeStore, ¤t1stLevelIter, 0,
|
|
||||||
utfGroupName, 1, configItem->name, 2,
|
|
||||||
(gboolean) allowMultipleSelection, -1);
|
|
||||||
g_free (utfGroupName);
|
|
||||||
|
|
||||||
current1stLevelId = configItem->name;
|
current1stLevelId = configItem->name;
|
||||||
|
|
||||||
|
gchar *utfGroupName = xci_desc_to_utf8 (configItem);
|
||||||
|
gchar *titlemarkup = g_strconcat ("<span>", utfGroupName, "</span>", NULL);
|
||||||
|
|
||||||
|
GtkWidget *expander = gtk_expander_new (titlemarkup);
|
||||||
|
g_object_set_data_full (G_OBJECT (expander), "utfGroupName", utfGroupName, g_free);
|
||||||
|
|
||||||
|
g_free (titlemarkup);
|
||||||
|
gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE);
|
||||||
|
GtkWidget *align = gtk_alignment_new (0, 0, 1, 1);
|
||||||
|
gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 12, 12, 0);
|
||||||
|
GtkWidget *vbox = gtk_vbox_new (TRUE, 6);
|
||||||
|
gtk_container_add (GTK_CONTAINER (align), vbox);
|
||||||
|
gtk_container_add (GTK_CONTAINER (expander), align);
|
||||||
|
currentVbox = vbox;
|
||||||
|
|
||||||
|
currentMultiSelect = (gboolean) allowMultipleSelection;
|
||||||
|
currentRadioGroup = NULL;
|
||||||
|
|
||||||
XklConfigEnumOptions (configItem->name, (ConfigItemProcessFunc)
|
XklConfigEnumOptions (configItem->name, (ConfigItemProcessFunc)
|
||||||
xkb_options_add_option_to_available_tree, dialog);
|
xkb_options_add_option, dialog);
|
||||||
|
|
||||||
|
xkb_options_expander_highlight (expander);
|
||||||
|
|
||||||
|
expanders_list = g_slist_append (expanders_list, expander);
|
||||||
|
g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP, expanders_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static gint
|
||||||
xkb_options_fill_available_tree (GladeXML * dialog)
|
xkb_options_expanders_compare (GtkWidget * expander1, GtkWidget * expander2)
|
||||||
{
|
{
|
||||||
GtkTreeStore *treeStore =
|
const gchar *t1 = gtk_expander_get_label (GTK_EXPANDER (expander1));
|
||||||
gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_STRING,
|
const gchar *t2 = gtk_expander_get_label (GTK_EXPANDER (expander2));
|
||||||
G_TYPE_BOOLEAN);
|
return g_utf8_collate (t1, t2);
|
||||||
GtkWidget *treeView = WID ("xkb_options_available");
|
}
|
||||||
GtkCellRenderer *renderer =
|
|
||||||
GTK_CELL_RENDERER (gtk_cell_renderer_text_new ());
|
|
||||||
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes (NULL,
|
|
||||||
renderer,
|
|
||||||
"text",
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
GtkTreeSelection *selection =
|
|
||||||
gtk_tree_view_get_selection (GTK_TREE_VIEW (treeView));
|
|
||||||
|
|
||||||
gtk_tree_view_set_model (GTK_TREE_VIEW (treeView),
|
/* Create widgets to represent the options made available by the backend */
|
||||||
GTK_TREE_MODEL (treeStore));
|
void
|
||||||
gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column);
|
xkb_options_load_options (GladeXML * dialog)
|
||||||
|
{
|
||||||
|
GtkWidget *opts_vbox = WID ("options_vbox");
|
||||||
|
GSList * expanders_list;
|
||||||
|
GtkWidget * expander;
|
||||||
|
|
||||||
|
/* fill the list */
|
||||||
XklConfigEnumOptionGroups ((GroupProcessFunc)
|
XklConfigEnumOptionGroups ((GroupProcessFunc)
|
||||||
xkb_options_add_group_to_available_tree, dialog);
|
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);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
sort_tree_content (treeView);
|
/* just cleanup */
|
||||||
|
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);
|
||||||
|
|
||||||
g_signal_connect_swapped (G_OBJECT (selection), "changed",
|
gtk_widget_show_all (opts_vbox);
|
||||||
G_CALLBACK
|
|
||||||
(xkb_options_enable_disable_buttons), dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Respond to a change in the xkb gconf settings */
|
||||||
xkb_options_fill_selected_tree (GladeXML * dialog)
|
|
||||||
{
|
|
||||||
GSList *options = xkb_options_get_selected_list ();
|
|
||||||
GSList *curOption;
|
|
||||||
GtkListStore *listStore =
|
|
||||||
GTK_LIST_STORE (gtk_tree_view_get_model
|
|
||||||
(GTK_TREE_VIEW (WID ("xkb_options_selected"))));
|
|
||||||
gtk_list_store_clear (listStore);
|
|
||||||
|
|
||||||
for (curOption = options; curOption != NULL; curOption = curOption->next)
|
|
||||||
{
|
|
||||||
GtkTreeIter iter;
|
|
||||||
char *groupName, *optionName;
|
|
||||||
const char *visible = (char *) curOption->data;
|
|
||||||
|
|
||||||
if (GSwitchItKbdConfigSplitItems (visible, &groupName, &optionName))
|
|
||||||
{
|
|
||||||
XklConfigItem citem;
|
|
||||||
char *v1, *utfVisible;
|
|
||||||
g_snprintf (citem.name, sizeof (citem.name), "%s", optionName);
|
|
||||||
if (XklConfigFindOption (groupName, &citem))
|
|
||||||
{
|
|
||||||
visible = citem.description;
|
|
||||||
}
|
|
||||||
v1 = g_strdup (visible);
|
|
||||||
utfVisible =
|
|
||||||
g_locale_to_utf8 (g_strstrip (v1), -1, NULL, NULL, NULL);
|
|
||||||
gtk_list_store_append (listStore, &iter);
|
|
||||||
gtk_list_store_set (listStore, &iter,
|
|
||||||
0, utfVisible, 1, curOption->data, -1);
|
|
||||||
g_free (utfVisible);
|
|
||||||
g_free (v1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_xkb_elements_list (options);
|
|
||||||
xkb_options_enable_disable_buttons (dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xkb_options_register_buttons_handlers (GladeXML * dialog)
|
|
||||||
{
|
|
||||||
g_signal_connect (G_OBJECT (WID ("xkb_options_add")), "clicked",
|
|
||||||
G_CALLBACK (xkb_options_add_selected), dialog);
|
|
||||||
g_signal_connect (G_OBJECT (WID ("xkb_options_remove")), "clicked",
|
|
||||||
G_CALLBACK (xkb_options_remove_selected), dialog);
|
|
||||||
}
|
|
||||||
static void
|
static void
|
||||||
xkb_options_update_list (GConfClient * client,
|
xkb_options_update (GConfClient * client,
|
||||||
guint cnxn_id, GConfEntry * entry, GladeXML * dialog)
|
guint cnxn_id, GConfEntry * entry, GladeXML * dialog)
|
||||||
{
|
{
|
||||||
xkb_options_fill_selected_tree (dialog);
|
/* 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);
|
enable_disable_restoring (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,5 +327,5 @@ xkb_options_register_gconf_listener (GladeXML * dialog)
|
||||||
gconf_client_notify_add (xkbGConfClient,
|
gconf_client_notify_add (xkbGConfClient,
|
||||||
GSWITCHIT_KBD_CONFIG_KEY_OPTIONS,
|
GSWITCHIT_KBD_CONFIG_KEY_OPTIONS,
|
||||||
(GConfClientNotifyFunc)
|
(GConfClientNotifyFunc)
|
||||||
xkb_options_update_list, dialog, NULL, NULL);
|
xkb_options_update, dialog, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||||
|
|
||||||
<glade-interface>
|
<glade-interface>
|
||||||
<requires lib="gnome"/>
|
|
||||||
|
|
||||||
<widget class="GtkDialog" id="keyboard_dialog">
|
<widget class="GtkDialog" id="keyboard_dialog">
|
||||||
<property name="border_width">6</property>
|
<property name="border_width">6</property>
|
||||||
|
@ -119,7 +118,9 @@
|
||||||
<widget class="GtkButton" id="button4">
|
<widget class="GtkButton" id="button4">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_default">True</property>
|
<property name="can_default">True</property>
|
||||||
|
<property name="has_default">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="has_focus">True</property>
|
||||||
<property name="label">gtk-close</property>
|
<property name="label">gtk-close</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
@ -728,7 +729,7 @@
|
||||||
<property name="max_length">256</property>
|
<property name="max_length">256</property>
|
||||||
<property name="text" translatable="yes"></property>
|
<property name="text" translatable="yes"></property>
|
||||||
<property name="has_frame">True</property>
|
<property name="has_frame">True</property>
|
||||||
<property name="invisible_char">*</property>
|
<property name="invisible_char" translatable="yes">*</property>
|
||||||
<property name="activates_default">False</property>
|
<property name="activates_default">False</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -819,7 +820,7 @@
|
||||||
<property name="max_length">0</property>
|
<property name="max_length">0</property>
|
||||||
<property name="text" translatable="yes">Microsoft Natural Keyboard</property>
|
<property name="text" translatable="yes">Microsoft Natural Keyboard</property>
|
||||||
<property name="has_frame">True</property>
|
<property name="has_frame">True</property>
|
||||||
<property name="invisible_char">*</property>
|
<property name="invisible_char" translatable="yes">*</property>
|
||||||
<property name="activates_default">False</property>
|
<property name="activates_default">False</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -1237,205 +1238,28 @@
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkHBox" id="xkb_options_panels">
|
<widget class="GtkScrolledWindow" id="scrolledwindow7">
|
||||||
<property name="border_width">12</property>
|
<property name="border_width">12</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="spacing">6</property>
|
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
|
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
|
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||||
|
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="vbox41">
|
<widget class="GtkViewport" id="viewport1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||||
<property name="spacing">6</property>
|
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label55">
|
<widget class="GtkVBox" id="options_vbox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">_Selected options:</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="spacing">0</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</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
<property name="mnemonic_widget">xkb_options_selected</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkScrolledWindow" id="scrolledwindow3">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
|
||||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
|
||||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
|
||||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkTreeView" id="xkb_options_selected">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="headers_visible">False</property>
|
|
||||||
<property name="rules_hint">False</property>
|
|
||||||
<property name="reorderable">False</property>
|
|
||||||
<property name="enable_search">True</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkVBox" id="vbox38">
|
|
||||||
<property name="border_width">6</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">12</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="label57">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes"></property>
|
|
||||||
<property name="use_underline">False</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>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="xkb_options_add">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-add</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="xkb_options_remove">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-remove</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkVBox" id="vbox42">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="label56">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes">A_vailable options:</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</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
<property name="mnemonic_widget">xkb_options_available</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkScrolledWindow" id="scrolledwindow4">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
|
||||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
|
||||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
|
||||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkTreeView" id="xkb_options_available">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="headers_visible">False</property>
|
|
||||||
<property name="rules_hint">False</property>
|
|
||||||
<property name="reorderable">False</property>
|
|
||||||
<property name="enable_search">True</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -1445,7 +1269,7 @@
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label47">
|
<widget class="GtkLabel" id="label64">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Layout Options</property>
|
<property name="label" translatable="yes">Layout Options</property>
|
||||||
<property name="use_underline">False</property>
|
<property name="use_underline">False</property>
|
||||||
|
|
Loading…
Add table
Reference in a new issue