[gnome-control-center] Serious changes in the keyboard capplet UI
- From: Sergey V. Udaltsov <svu src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-control-center] Serious changes in the keyboard capplet UI
- Date: Thu, 15 Oct 2009 22:20:10 +0000 (UTC)
commit 37fc3c54a4311e01789672e7cffaf09612e4057a
Author: Sergey V. Udaltsov <svu gnome org>
Date: Thu Oct 15 23:18:59 2009 +0100
Serious changes in the keyboard capplet UI
Following the discussion at
http://live.gnome.org/UsabilityProject/Whiteboard/KeyboardPreferences
.../keyboard/gnome-keyboard-properties-dialog.ui | 187 +++++++++++------
capplets/keyboard/gnome-keyboard-properties-xkb.c | 44 +++-
capplets/keyboard/gnome-keyboard-properties-xkb.h | 10 +-
.../keyboard/gnome-keyboard-properties-xkblt.c | 218 ++++++++------------
4 files changed, 248 insertions(+), 211 deletions(-)
---
diff --git a/capplets/keyboard/gnome-keyboard-properties-dialog.ui b/capplets/keyboard/gnome-keyboard-properties-dialog.ui
index b09d11c..46b941f 100644
--- a/capplets/keyboard/gnome-keyboard-properties-dialog.ui
+++ b/capplets/keyboard/gnome-keyboard-properties-dialog.ui
@@ -207,7 +207,7 @@
<property name="label" translatable="yes">Short</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -222,7 +222,7 @@
<property name="label" translatable="yes">Slow</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -285,7 +285,7 @@
<property name="label" translatable="yes">Long</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -299,7 +299,7 @@
<property name="label" translatable="yes">Fast</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -420,7 +420,7 @@
<property name="label" translatable="yes">Slow</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -453,7 +453,7 @@
<property name="label" translatable="yes">Fast</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -548,21 +548,6 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkCheckButton" id="chk_separate_group_per_window">
- <property name="label" translatable="yes">Separate _layout for each window</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
<object class="GtkVBox" id="vbox41">
<property name="visible">True</property>
<property name="orientation">vertical</property>
@@ -571,7 +556,7 @@
<object class="GtkLabel" id="label52">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">_Selected layouts:</property>
+ <property name="label" translatable="yes">Selected _layouts:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">xkb_layouts_selected</property>
</object>
@@ -610,25 +595,37 @@
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox2">
+ <object class="GtkHBox" id="hbox1">
<property name="visible">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="spacing">6</property>
<child>
- <object class="GtkHButtonBox" id="hbuttonbox2">
+ <object class="GtkVButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
- <property name="spacing">6</property>
- <property name="layout_style">start</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">3</property>
+ <child>
+ <object class="GtkButton" id="xkb_layouts_add">
+ <property name="label" translatable="yes">_Add...</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<object class="GtkButton" id="xkb_layouts_remove">
<property name="label">gtk-remove</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -637,61 +634,111 @@
<property name="position">1</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVButtonBox" id="vbuttonbox2">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkButton" id="xkb_layouts_print">
- <property name="label">gtk-print</property>
+ <object class="GtkButton" id="xkb_layouts_move_up">
+ <property name="label" translatable="yes">Move _Up</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="xkb_layouts_add">
- <property name="label" translatable="yes">_Add...</property>
+ <object class="GtkButton" id="xkb_layouts_move_down">
+ <property name="label" translatable="yes">Move _Down</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="receives_default">True</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="xkb_reset_to_defaults">
- <property name="label" translatable="yes">Reset to De_faults</property>
+ <object class="GtkVButtonBox" id="vbuttonbox3">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
+ <property name="orientation">vertical</property>
+ <property name="layout_style">start</property>
+ <child>
+ <object class="GtkButton" id="xkb_layouts_print">
+ <property name="label">gtk-print</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">4</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="chk_separate_group_per_window">
+ <property name="label" translatable="yes">_Separate layout for each window</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="chk_new_windows_get_first_layout">
+ <property name="label" translatable="yes">New windows get layout "foobar"</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">1</property>
@@ -701,6 +748,7 @@
<object class="GtkHButtonBox" id="hbuttonbox3">
<property name="visible">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="spacing">6</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="xkb_layout_options">
@@ -717,6 +765,21 @@
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="xkb_reset_to_defaults">
+ <property name="label" translatable="yes">Reset to De_faults</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">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>
</object>
<packing>
<property name="expand">False</property>
@@ -964,7 +1027,7 @@
<property name="label" translatable="yes">Short</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -997,7 +1060,7 @@
<property name="label" translatable="yes">Long</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1118,7 +1181,7 @@
<property name="label" translatable="yes">Short</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1151,7 +1214,7 @@
<property name="label" translatable="yes">Long</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1290,7 +1353,7 @@
<property name="justify">center</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1310,7 +1373,7 @@
<property name="justify">center</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1360,7 +1423,7 @@
<property name="justify">center</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1380,7 +1443,7 @@
<property name="justify">center</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1444,7 +1507,7 @@
<property name="justify">center</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1481,7 +1544,7 @@
<property name="justify">center</property>
<attributes>
<attribute name="style" value="italic"/>
- <attribute name="scale" value="0.83"/>
+ <attribute name="scale" value="0.830000"/>
</attributes>
</object>
<packing>
@@ -1843,8 +1906,8 @@
</object>
</child>
<action-widgets>
- <action-widget response="-11">helpbutton1</action-widget>
- <action-widget response="-7">button4</action-widget>
+ <action-widget response="-1">helpbutton1</action-widget>
+ <action-widget response="-1">button4</action-widget>
</action-widgets>
</object>
</interface>
diff --git a/capplets/keyboard/gnome-keyboard-properties-xkb.c b/capplets/keyboard/gnome-keyboard-properties-xkb.c
index ba31659..160524f 100644
--- a/capplets/keyboard/gnome-keyboard-properties-xkb.c
+++ b/capplets/keyboard/gnome-keyboard-properties-xkb.c
@@ -135,8 +135,7 @@ reset_to_defaults (GtkWidget * button, GtkBuilder * dialog)
gkbd_keyboard_config_term (&empty_kbd_config);
gconf_client_unset (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
- NULL);
+ GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP, NULL);
/* all the rest is g-s-d's business */
}
@@ -147,21 +146,35 @@ chk_separate_group_per_window_toggled (GConfPropertyEditor * peditor,
const GConfValue * value,
GtkBuilder * dialog)
{
- xkb_layouts_enable_disable_default (dialog, value
- &&
- gconf_value_get_bool (value));
+ gtk_widget_set_sensitive (WID ("chk_new_windows_get_first_layout"),
+ gconf_value_get_bool (value));
+}
+
+static void
+chk_new_windows_get_first_layout_toggled (GtkWidget *
+ chk_new_windows_get_first_layout,
+ GtkBuilder * dialog)
+{
+ xkb_save_default_group (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON
+ (chk_new_windows_get_first_layout)) ? 0 :
+ -1);
}
void
setup_xkb_tabs (GtkBuilder * dialog, GConfChangeSet * changeset)
{
GObject *peditor;
+ GtkWidget *chk_new_windows_get_first_layout =
+ WID ("chk_new_windows_get_first_layout");
+
xkb_gconf_client = gconf_client_get_default ();
engine = xkl_engine_get_instance (GDK_DISPLAY ());
config_registry = xkl_config_registry_get_instance (engine);
- gkbd_desktop_config_init (&desktop_config, xkb_gconf_client, engine);
+ gkbd_desktop_config_init (&desktop_config, xkb_gconf_client,
+ engine);
gkbd_desktop_config_load_from_gconf (&desktop_config);
xkl_config_registry_load (config_registry,
@@ -188,11 +201,25 @@ setup_xkb_tabs (GtkBuilder * dialog, GConfChangeSet * changeset)
xkb_layouts_prepare_selected_tree (dialog, changeset);
xkb_layouts_fill_selected_tree (dialog);
+ gtk_widget_set_sensitive (chk_new_windows_get_first_layout,
+ gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON
+ (WID
+ ("chk_separate_group_per_window"))));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (chk_new_windows_get_first_layout),
+ xkb_get_default_group () == 0);
+
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_get_first_layout),
+ "toggled", (GCallback)
+ chk_new_windows_get_first_layout_toggled,
+ dialog);
+
g_signal_connect_swapped (G_OBJECT (WID ("xkb_layout_options")),
"clicked",
G_CALLBACK (xkb_options_popup_dialog),
@@ -210,11 +237,6 @@ setup_xkb_tabs (GtkBuilder * dialog, GConfChangeSet * changeset)
dialog);
enable_disable_restoring (dialog);
- xkb_layouts_enable_disable_default (dialog,
- gconf_client_get_bool
- (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_GROUP_PER_WINDOW,
- NULL));
}
void
diff --git a/capplets/keyboard/gnome-keyboard-properties-xkb.h b/capplets/keyboard/gnome-keyboard-properties-xkb.h
index cf22447..d9c3878 100644
--- a/capplets/keyboard/gnome-keyboard-properties-xkb.h
+++ b/capplets/keyboard/gnome-keyboard-properties-xkb.h
@@ -35,7 +35,8 @@ extern XklConfigRegistry *config_registry;
extern GConfClient *xkb_gconf_client;
extern GkbdKeyboardConfig initial_config;
-extern void setup_xkb_tabs (GtkBuilder * dialog, GConfChangeSet * changeset);
+extern void setup_xkb_tabs (GtkBuilder * dialog,
+ GConfChangeSet * changeset);
extern void xkb_layouts_fill_selected_tree (GtkBuilder * dialog);
@@ -66,9 +67,6 @@ extern void choose_model (GtkBuilder * dialog);
extern void xkb_layout_choose (GtkBuilder * dialog);
-extern void xkb_layouts_enable_disable_default (GtkBuilder * dialog,
- gboolean enable);
-
extern GSList *xkb_layouts_get_selected_list (void);
extern GSList *xkb_options_get_selected_list (void);
@@ -94,5 +92,9 @@ extern void xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw,
extern gchar *xkb_layout_chooser_get_selected_id (GtkBuilder *
chooser_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 */
diff --git a/capplets/keyboard/gnome-keyboard-properties-xkblt.c b/capplets/keyboard/gnome-keyboard-properties-xkblt.c
index 21b72f8..c7d2fc1 100644
--- a/capplets/keyboard/gnome-keyboard-properties-xkblt.c
+++ b/capplets/keyboard/gnome-keyboard-properties-xkblt.c
@@ -36,15 +36,13 @@
#define SEL_LAYOUT_TREE_COL_DESCRIPTION 0
-#define SEL_LAYOUT_TREE_COL_DEFAULT 1
-#define SEL_LAYOUT_TREE_COL_ID 2
+#define SEL_LAYOUT_TREE_COL_ID 1
static int idx2select = -1;
static int max_selected_layouts = -1;
static int default_group = -1;
static GtkCellRenderer *text_renderer;
-static GtkCellRenderer *toggle_renderer;
static gboolean disable_buttons_sensibility_update = FALSE;
@@ -108,71 +106,21 @@ xkb_layouts_get_selected_list (void)
return retval;
}
-static void
-save_default_group (int default_group)
+gint
+xkb_get_default_group ()
{
- if (default_group != gconf_client_get_int (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
- NULL))
- gconf_client_set_int (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
- default_group, NULL);
+ return gconf_client_get_int (xkb_gconf_client,
+ GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
+ NULL);
}
-static void
-def_group_in_ui_changed (GtkCellRendererToggle * cell_renderer,
- gchar * path, GtkBuilder * dialog)
-{
- GtkTreePath *chpath = gtk_tree_path_new_from_string (path);
- int new_default_group = -1;
- gboolean previously_selected =
- gtk_cell_renderer_toggle_get_active (cell_renderer);
-
- if (!previously_selected) { /* prev state - non-selected! */
- int *indices = gtk_tree_path_get_indices (chpath);
- new_default_group = indices[0];
- }
-
- save_default_group (new_default_group);
- gtk_tree_path_free (chpath);
-}
-
-static void
-def_group_in_gconf_changed (GConfClient * client,
- guint cnxn_id,
- GConfEntry * entry, GtkBuilder * dialog)
+void
+xkb_save_default_group (gint default_group)
{
- GConfValue *value = gconf_entry_get_value (entry);
-
- if (!value)
- return;
-
- if (value->type == GCONF_VALUE_INT) {
- GtkWidget *tree_view = WID ("xkb_layouts_selected");
- GtkTreeModel *model =
- GTK_TREE_MODEL (gtk_tree_view_get_model
- (GTK_TREE_VIEW (tree_view)));
- GtkTreeIter iter;
- int counter = 0;
- default_group = MAX(0, gconf_value_get_int (value));
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gboolean cur_val;
- gtk_tree_model_get (model, &iter,
- SEL_LAYOUT_TREE_COL_DEFAULT,
- &cur_val, -1);
- if (cur_val != (counter == default_group))
- gtk_list_store_set (GTK_LIST_STORE
- (model), &iter,
- SEL_LAYOUT_TREE_COL_DEFAULT,
- counter ==
- default_group,
- -1);
- counter++;
- }
- while (gtk_tree_model_iter_next (model, &iter));
- }
- }
+ if (default_group != xkb_get_default_group ())
+ gconf_client_set_int (xkb_gconf_client,
+ GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
+ default_group, NULL);
}
static void
@@ -182,6 +130,8 @@ xkb_layouts_enable_disable_buttons (GtkBuilder * dialog)
GtkWidget *print_layout_btn = WID ("xkb_layouts_print");
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
@@ -193,6 +143,7 @@ xkb_layouts_enable_disable_buttons (GtkBuilder * dialog)
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;
@@ -205,47 +156,9 @@ xkb_layouts_enable_disable_buttons (GtkBuilder * dialog)
&& (n_selected_selected_layouts > 0));
gtk_widget_set_sensitive (print_layout_btn,
(n_selected_selected_layouts > 0));
-}
-
-static GtkTreeViewColumn *
-xkb_layouts_create_default_layout_column ()
-{
- GtkTreeViewColumn *def_column =
- gtk_tree_view_column_new_with_attributes (_("Default"),
- toggle_renderer,
- "active",
- SEL_LAYOUT_TREE_COL_DEFAULT,
- NULL);
- gtk_tree_view_column_set_sizing (def_column,
- GTK_TREE_VIEW_COLUMN_AUTOSIZE);
- gtk_tree_view_column_set_resizable (def_column, TRUE);
- gtk_tree_view_column_set_expand (def_column, FALSE);
- return def_column;
-}
-
-void
-xkb_layouts_enable_disable_default (GtkBuilder * dialog, gboolean enable)
-{
- GtkWidget *tree_view = WID ("xkb_layouts_selected");
-
- if (enable) {
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
- xkb_layouts_create_default_layout_column
- ());
- g_object_unref (toggle_renderer);
- } else {
- GtkTreeViewColumn *col =
- gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view),
- 1);
- if (col != NULL) {
- g_object_ref (toggle_renderer);
- gtk_tree_view_column_clear (col);
- gtk_tree_view_remove_column (GTK_TREE_VIEW
- (tree_view), col);
- }
- }
-
- gtk_widget_queue_draw (tree_view);
+ 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
@@ -322,11 +235,6 @@ xkb_layouts_prepare_selected_tree (GtkBuilder * dialog,
GtkTreeViewColumn *desc_column;
text_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ());
- toggle_renderer =
- GTK_CELL_RENDERER (gtk_cell_renderer_toggle_new ());
- gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE
- (toggle_renderer), TRUE);
- g_object_ref (toggle_renderer);
desc_column =
gtk_tree_view_column_new_with_attributes (_("Layout"),
@@ -354,14 +262,6 @@ xkb_layouts_prepare_selected_tree (GtkBuilder * dialog,
dialog);
max_selected_layouts = xkl_engine_get_max_num_groups (engine);
- gconf_client_notify_add (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
- (GConfClientNotifyFunc)
- def_group_in_gconf_changed, dialog, NULL,
- NULL);
- g_signal_connect (G_OBJECT (toggle_renderer), "toggled",
- G_CALLBACK (def_group_in_ui_changed), dialog);
-
/* Setting up DnD */
gtk_drag_source_set (tree_view, GDK_BUTTON1_MASK,
&self_drag_target, 1, GDK_ACTION_MOVE);
@@ -389,14 +289,15 @@ xkb_layout_description_utf8 (const gchar * visible)
void
xkb_layouts_fill_selected_tree (GtkBuilder * dialog)
{
- GConfEntry *gce;
- GError *err = NULL;
GSList *layouts = xkb_layouts_get_selected_list ();
GSList *cur_layout;
GtkListStore *list_store =
GTK_LIST_STORE (gtk_tree_view_get_model
(GTK_TREE_VIEW
(WID ("xkb_layouts_selected"))));
+ GtkWidget *chk_new_windows_get_first_layout =
+ WID ("chk_new_windows_get_first_layout");
+ int counter = 0;
/* temporarily disable the buttons' status update */
disable_buttons_sensibility_update = TRUE;
@@ -404,7 +305,7 @@ xkb_layouts_fill_selected_tree (GtkBuilder * dialog)
gtk_list_store_clear (list_store);
for (cur_layout = layouts; cur_layout != NULL;
- cur_layout = cur_layout->next) {
+ cur_layout = cur_layout->next, counter++) {
GtkTreeIter iter;
const char *visible = (char *) cur_layout->data;
gchar *utf_visible = xkb_layout_description_utf8 (visible);
@@ -412,9 +313,18 @@ xkb_layouts_fill_selected_tree (GtkBuilder * dialog)
gtk_list_store_set (list_store, &iter,
SEL_LAYOUT_TREE_COL_DESCRIPTION,
utf_visible,
- SEL_LAYOUT_TREE_COL_DEFAULT, FALSE,
SEL_LAYOUT_TREE_COL_ID,
cur_layout->data, -1);
+ if (!counter) {
+ gchar *chklbl =
+ g_strdup_printf (_
+ ("New windows get layout \"%s\""),
+utf_visible);
+ gtk_button_set_label (GTK_BUTTON
+ (chk_new_windows_get_first_layout),
+ chklbl);
+ g_free (chklbl);
+ }
g_free (utf_visible);
}
@@ -438,16 +348,6 @@ xkb_layouts_fill_selected_tree (GtkBuilder * dialog)
otherwise it would be done by the selection change */
xkb_layouts_enable_disable_buttons (dialog);
}
-
- gce = gconf_client_get_entry (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
- NULL, TRUE, &err);
- if (err == NULL) {
- def_group_in_gconf_changed (xkb_gconf_client, -1, gce,
- dialog);
- } else {
- g_error_free (err);
- }
}
static void
@@ -500,15 +400,59 @@ remove_selected_layout (GtkWidget * button, GtkBuilder * dialog)
g_free (id);
if (default_group > idx)
- save_default_group (default_group - 1);
+ xkb_save_default_group (default_group - 1);
else if (default_group == idx)
- save_default_group (-1);
+ xkb_save_default_group (-1);
xkb_layouts_set_selected_list (layouts_list);
clear_xkb_elements_list (layouts_list);
}
}
+static void
+move_up_selected_layout (GtkWidget * button, GtkBuilder * dialog)
+{
+ gint idx = find_selected_layout_idx (dialog);
+
+ if (idx != -1) {
+ GSList *layouts_list = xkb_layouts_get_selected_list ();
+ GSList *node2Remove = g_slist_nth (layouts_list, idx);
+
+ layouts_list =
+ g_slist_remove_link (layouts_list, node2Remove);
+ layouts_list =
+ g_slist_insert (layouts_list, node2Remove->data,
+ idx - 1);
+ g_slist_free_1 (node2Remove);
+
+ idx2select = idx - 1;
+ xkb_layouts_set_selected_list (layouts_list);
+ clear_xkb_elements_list (layouts_list);
+ }
+}
+
+static void
+move_down_selected_layout (GtkWidget * button, GtkBuilder * dialog)
+{
+ gint idx = find_selected_layout_idx (dialog);
+
+ if (idx != -1) {
+ GSList *layouts_list = xkb_layouts_get_selected_list ();
+ GSList *node2Remove = g_slist_nth (layouts_list, idx);
+
+ layouts_list =
+ g_slist_remove_link (layouts_list, node2Remove);
+ layouts_list =
+ g_slist_insert (layouts_list, node2Remove->data,
+ idx + 1);
+ g_slist_free_1 (node2Remove);
+
+ idx2select = idx + 1;
+ xkb_layouts_set_selected_list (layouts_list);
+ clear_xkb_elements_list (layouts_list);
+ }
+}
+
void
xkb_layouts_register_buttons_handlers (GtkBuilder * dialog)
{
@@ -518,6 +462,12 @@ xkb_layouts_register_buttons_handlers (GtkBuilder * dialog)
G_CALLBACK (print_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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]