[PATCH] Re: xfce4-settings-4.10.0_layout_alpha

Alexsandr Sovenko owlx at mail.com
Mon Jun 25 00:35:19 CEST 2012


Hi,
Add  next code to "xfce4-settings-4.10.0/xfsettingsd/keyboard-layout.c" 
for correct shutdown xfsettingsd :)

...

+static void xfce_keyboard_layout_helper_finalize (GObject *object)

...

+static void
+xfce_keyboard_layout_helper_finalize (GObject *object)
+{
+    XfceKeyboardLayoutHelper *helper = XFCE_KEYBOARD_LAYOUT_HELPER 
(object);
+
+    gdk_window_remove_filter (NULL,
+        (GdkFilterFunc) xfce_keyboard_manage_layout_handle_xevent, NULL);
+    xkl_engine_stop_listen (helper->engine, XKLL_TRACK_KEYBOARD_STATE);

+#ifdef HAVE_DBUS
+    dbus_connection_remove_filter (helper->bus,
+        xfce_keyboard_manage_layout_signal_filter, helper);
+#endif /* HAVE_DBUS */
+
+  (*G_OBJECT_CLASS 
(xfce_keyboard_layout_helper_parent_class)->finalize) (object);
+}

Alexsandr
-------------- next part --------------
diff -rupN a/dialogs/keyboard-settings/keyboard-dialog.glade b/dialogs/keyboard-settings/keyboard-dialog.glade
--- a/dialogs/keyboard-settings/keyboard-dialog.glade	2012-04-28 20:48:30.000000000 +0000
+++ b/dialogs/keyboard-settings/keyboard-dialog.glade	2012-06-21 11:30:07.000000000 +0000
@@ -113,8 +113,8 @@
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="button2">
-                <property name="label">gtk-close</property>
+              <object class="GtkButton" id="button1">
+                <property name="label">gtk-help</property>
                 <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -125,11 +125,12 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="position">0</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="button1">
-                <property name="label">gtk-help</property>
+              <object class="GtkButton" id="button2">
+                <property name="label">gtk-close</property>
                 <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -140,7 +141,6 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="position">0</property>
-                <property name="secondary">True</property>
               </packing>
             </child>
           </object>
@@ -689,6 +689,92 @@
                       </packing>
                     </child>
                     <child>
+                      <object class="GtkHBox" id="hbox3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="homogeneous">True</property>
+                        <child>
+                          <object class="GtkFrame" id="xkb_layout_option_frame">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label_xalign">0</property>
+                            <property name="shadow_type">none</property>
+                            <child>
+                              <object class="GtkAlignment" id="alignment6">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="border_width">6</property>
+                                <property name="left_padding">12</property>
+                                <child>
+                                  <object class="GtkComboBox" id="xkb_layout_option_combo">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child type="label">
+                              <object class="GtkLabel" id="label1">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Change layout option</property>
+                                <attributes>
+                                  <attribute name="weight" value="bold"/>
+                                </attributes>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkFrame" id="xkb_manage_layout_frame">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label_xalign">0</property>
+                            <property name="shadow_type">none</property>
+                            <child>
+                              <object class="GtkAlignment" id="alignment7">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="border_width">6</property>
+                                <property name="left_padding">12</property>
+                                <child>
+                                  <object class="GtkComboBox" id="xkb_manage_layout_combo">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child type="label">
+                              <object class="GtkLabel" id="label14">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Manage layout</property>
+                                <attributes>
+                                  <attribute name="weight" value="bold"/>
+                                </attributes>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
                       <object class="GtkFrame" id="xkb_layout_frame">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
@@ -802,7 +888,7 @@
                       <packing>
                         <property name="expand">True</property>
                         <property name="fill">True</property>
-                        <property name="position">2</property>
+                        <property name="position">3</property>
                       </packing>
                     </child>
                   </object>
@@ -839,8 +925,8 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">button2</action-widget>
       <action-widget response="-11">button1</action-widget>
+      <action-widget response="0">button2</action-widget>
     </action-widgets>
   </object>
   <object class="GtkAdjustment" id="net_cursor_blink_time">
diff -rupN a/dialogs/keyboard-settings/keyboard-dialog_ui.h b/dialogs/keyboard-settings/keyboard-dialog_ui.h
--- a/dialogs/keyboard-settings/keyboard-dialog_ui.h	2012-04-28 20:48:40.000000000 +0000
+++ b/dialogs/keyboard-settings/keyboard-dialog_ui.h	2012-06-21 11:30:07.000000000 +0000
@@ -1,4 +1,4 @@
-/* automatically generated from keyboard-dialog.glade */
+/* automatically generated from keyboard-dialog1.glade */
 #ifdef __SUNPRO_C
 #pragma align 4 (keyboard_dialog_ui)
 #endif
@@ -70,70 +70,70 @@ static const char keyboard_dialog_ui[] =
   "ect class=\"GtkHButtonBox\" id=\"dialog-action_area1\"><property name=\""
   "visible\">True</property><property name=\"can_focus\">False</property><"
   "property name=\"layout_style\">end</property><child><object class=\"Gtk"
-  "Button\" id=\"button2\"><property name=\"label\">gtk-close</property><p"
-  "roperty name=\"use_action_appearance\">False</property><property name=\""
+  "Button\" id=\"button1\"><property name=\"label\">gtk-help</property><pr"
+  "operty name=\"use_action_appearance\">False</property><property name=\""
   "visible\">True</property><property name=\"can_focus\">True</property><p"
   "roperty name=\"receives_default\">True</property><property name=\"use_s"
   "tock\">True</property></object><packing><property name=\"expand\">False"
   "</property><property name=\"fill\">False</property><property name=\"pos"
-  "ition\">0</property></packing></child><child><object class=\"GtkButton\""
-  " id=\"button1\"><property name=\"label\">gtk-help</property><property n"
-  "ame=\"use_action_appearance\">False</property><property name=\"visible\""
-  ">True</property><property name=\"can_focus\">True</property><property n"
-  "ame=\"receives_default\">True</property><property name=\"use_stock\">Tr"
-  "ue</property></object><packing><property name=\"expand\">False</propert"
-  "y><property name=\"fill\">False</property><property name=\"position\">0"
-  "</property><property name=\"secondary\">True</property></packing></chil"
-  "d></object><packing><property name=\"expand\">False</property><property"
-  " name=\"fill\">True</property><property name=\"pack_type\">end</propert"
-  "y><property name=\"position\">0</property></packing></child><child><obj"
-  "ect class=\"GtkVBox\" id=\"plug-child\"><property name=\"visible\">True"
-  "</property><property name=\"can_focus\">False</property><property name="
-  "\"border_width\">6</property><property name=\"spacing\">6</property><ch"
-  "ild><object class=\"GtkNotebook\" id=\"notebook1\"><property name=\"vis"
-  "ible\">True</property><property name=\"can_focus\">True</property><chil"
-  "d><object class=\"GtkVBox\" id=\"vbox3\"><property name=\"visible\">Tru"
-  "e</property><property name=\"can_focus\">False</property><property name"
-  "=\"border_width\">12</property><property name=\"spacing\">6</property><"
-  "child><object class=\"GtkFrame\" id=\"frame1\"><property name=\"visible"
-  "\">True</property><property name=\"can_focus\">False</property><propert"
-  "y name=\"label_xalign\">0</property><property name=\"shadow_type\">none"
-  "</property><child><object class=\"GtkAlignment\" id=\"alignment5\"><pro"
-  "perty name=\"visible\">True</property><property name=\"can_focus\">Fals"
-  "e</property><property name=\"top_padding\">6</property><property name=\""
-  "bottom_padding\">6</property><property name=\"left_padding\">18</proper"
-  "ty><property name=\"right_padding\">6</property><child><object class=\""
-  "GtkCheckButton\" id=\"restore_numlock\"><property name=\"label\" transl"
-  "atable=\"yes\">Restore num l_ock state on startup</property><property n"
-  "ame=\"use_action_appearance\">False</property><property name=\"visible\""
-  ">True</property><property name=\"can_focus\">True</property><property n"
-  "ame=\"receives_default\">False</property><property name=\"use_underline"
-  "\">True</property><property name=\"draw_indicator\">True</property></ob"
-  "ject></child></object></child><child type=\"label\"><object class=\"Gtk"
-  "Label\" id=\"label9\"><property name=\"visible\">True</property><proper"
-  "ty name=\"can_focus\">False</property><property name=\"label\" translat"
-  "able=\"yes\">General</property><property name=\"use_markup\">True</prop"
-  "erty><attributes><attribute name=\"weight\" value=\"bold\"/></attribute"
-  "s></object></child></object><packing><property name=\"expand\">False</p"
-  "roperty><property name=\"fill\">True</property><property name=\"positio"
-  "n\">0</property></packing></child><child><object class=\"GtkFrame\" id="
-  "\"frame2\"><property name=\"visible\">True</property><property name=\"c"
-  "an_focus\">False</property><property name=\"label_xalign\">0</property>"
-  "<property name=\"shadow_type\">none</property><child><object class=\"Gt"
-  "kAlignment\" id=\"alignment2\"><property name=\"visible\">True</propert"
-  "y><property name=\"can_focus\">False</property><property name=\"left_pa"
-  "dding\">12</property><child><object class=\"GtkVBox\" id=\"vbox1\"><pro"
-  "perty name=\"visible\">True</property><property name=\"can_focus\">Fals"
-  "e</property><property name=\"border_width\">6</property><property name="
-  "\"spacing\">6</property><child><object class=\"GtkCheckButton\" id=\"xk"
-  "b_key_repeat_check\"><property name=\"label\" translatable=\"yes\">_Ena"
-  "ble key repeat</property><property name=\"use_action_appearance\">False"
-  "</property><property name=\"visible\">True</property><property name=\"c"
-  "an_focus\">True</property><property name=\"receives_default\">False</pr"
-  "operty><property name=\"tooltip_text\" translatable=\"yes\">When select"
-  "ed, pressing and holding down a key emits the same character over and o"
-  "ver again</property><property name=\"use_underline\">True</property><pr"
-  "operty name=\"active\">True</property><property name=\"draw_indicator\""
+  "ition\">0</property><property name=\"secondary\">True</property></packi"
+  "ng></child><child><object class=\"GtkButton\" id=\"button2\"><property "
+  "name=\"label\">gtk-close</property><property name=\"use_action_appearan"
+  "ce\">False</property><property name=\"visible\">True</property><propert"
+  "y name=\"can_focus\">True</property><property name=\"receives_default\""
+  ">True</property><property name=\"use_stock\">True</property></object><p"
+  "acking><property name=\"expand\">False</property><property name=\"fill\""
+  ">False</property><property name=\"position\">0</property></packing></ch"
+  "ild></object><packing><property name=\"expand\">False</property><proper"
+  "ty name=\"fill\">True</property><property name=\"pack_type\">end</prope"
+  "rty><property name=\"position\">0</property></packing></child><child><o"
+  "bject class=\"GtkVBox\" id=\"plug-child\"><property name=\"visible\">Tr"
+  "ue</property><property name=\"can_focus\">False</property><property nam"
+  "e=\"border_width\">6</property><property name=\"spacing\">6</property><"
+  "child><object class=\"GtkNotebook\" id=\"notebook1\"><property name=\"v"
+  "isible\">True</property><property name=\"can_focus\">True</property><ch"
+  "ild><object class=\"GtkVBox\" id=\"vbox3\"><property name=\"visible\">T"
+  "rue</property><property name=\"can_focus\">False</property><property na"
+  "me=\"border_width\">12</property><property name=\"spacing\">6</property"
+  "><child><object class=\"GtkFrame\" id=\"frame1\"><property name=\"visib"
+  "le\">True</property><property name=\"can_focus\">False</property><prope"
+  "rty name=\"label_xalign\">0</property><property name=\"shadow_type\">no"
+  "ne</property><child><object class=\"GtkAlignment\" id=\"alignment5\"><p"
+  "roperty name=\"visible\">True</property><property name=\"can_focus\">Fa"
+  "lse</property><property name=\"top_padding\">6</property><property name"
+  "=\"bottom_padding\">6</property><property name=\"left_padding\">18</pro"
+  "perty><property name=\"right_padding\">6</property><child><object class"
+  "=\"GtkCheckButton\" id=\"restore_numlock\"><property name=\"label\" tra"
+  "nslatable=\"yes\">Restore num l_ock state on startup</property><propert"
+  "y name=\"use_action_appearance\">False</property><property name=\"visib"
+  "le\">True</property><property name=\"can_focus\">True</property><proper"
+  "ty name=\"receives_default\">False</property><property name=\"use_under"
+  "line\">True</property><property name=\"draw_indicator\">True</property>"
+  "</object></child></object></child><child type=\"label\"><object class=\""
+  "GtkLabel\" id=\"label9\"><property name=\"visible\">True</property><pro"
+  "perty name=\"can_focus\">False</property><property name=\"label\" trans"
+  "latable=\"yes\">General</property><property name=\"use_markup\">True</p"
+  "roperty><attributes><attribute name=\"weight\" value=\"bold\"/></attrib"
+  "utes></object></child></object><packing><property name=\"expand\">False"
+  "</property><property name=\"fill\">True</property><property name=\"posi"
+  "tion\">0</property></packing></child><child><object class=\"GtkFrame\" "
+  "id=\"frame2\"><property name=\"visible\">True</property><property name="
+  "\"can_focus\">False</property><property name=\"label_xalign\">0</proper"
+  "ty><property name=\"shadow_type\">none</property><child><object class=\""
+  "GtkAlignment\" id=\"alignment2\"><property name=\"visible\">True</prope"
+  "rty><property name=\"can_focus\">False</property><property name=\"left_"
+  "padding\">12</property><child><object class=\"GtkVBox\" id=\"vbox1\"><p"
+  "roperty name=\"visible\">True</property><property name=\"can_focus\">Fa"
+  "lse</property><property name=\"border_width\">6</property><property nam"
+  "e=\"spacing\">6</property><child><object class=\"GtkCheckButton\" id=\""
+  "xkb_key_repeat_check\"><property name=\"label\" translatable=\"yes\">_E"
+  "nable key repeat</property><property name=\"use_action_appearance\">Fal"
+  "se</property><property name=\"visible\">True</property><property name=\""
+  "can_focus\">True</property><property name=\"receives_default\">False</p"
+  "roperty><property name=\"tooltip_text\" translatable=\"yes\">When selec"
+  "ted, pressing and holding down a key emits the same character over and "
+  "over again</property><property name=\"use_underline\">True</property><p"
+  "roperty name=\"active\">True</property><property name=\"draw_indicator\""
   ">True</property></object><packing><property name=\"expand\">False</prop"
   "erty><property name=\"fill\">False</property><property name=\"position\""
   ">0</property></packing></child><child><object class=\"GtkAlignment\" id"
@@ -343,87 +343,124 @@ static const char keyboard_dialog_ui[] =
   "\"bold\"/></attributes></object></child></object><packing><property nam"
   "e=\"expand\">False</property><property name=\"fill\">True</property><pr"
   "operty name=\"position\">1</property></packing></child><child><object c"
-  "lass=\"GtkFrame\" id=\"xkb_layout_frame\"><property name=\"visible\">Tr"
-  "ue</property><property name=\"can_focus\">False</property><property nam"
-  "e=\"label_xalign\">0</property><property name=\"shadow_type\">none</pro"
-  "perty><child><object class=\"GtkAlignment\" id=\"alignment4\"><property"
+  "lass=\"GtkHBox\" id=\"hbox3\"><property name=\"visible\">True</property"
+  "><property name=\"can_focus\">False</property><property name=\"homogene"
+  "ous\">True</property><child><object class=\"GtkFrame\" id=\"xkb_layout_"
+  "option_frame\"><property name=\"visible\">True</property><property name"
+  "=\"can_focus\">False</property><property name=\"label_xalign\">0</prope"
+  "rty><property name=\"shadow_type\">none</property><child><object class="
+  "\"GtkAlignment\" id=\"alignment6\"><property name=\"visible\">True</pro"
+  "perty><property name=\"can_focus\">False</property><property name=\"bor"
+  "der_width\">6</property><property name=\"left_padding\">12</property><c"
+  "hild><object class=\"GtkComboBox\" id=\"xkb_layout_option_combo\"><prop"
+  "erty name=\"visible\">True</property><property name=\"can_focus\">False"
+  "</property></object></child></object></child><child type=\"label\"><obj"
+  "ect class=\"GtkLabel\" id=\"label1\"><property name=\"visible\">True</p"
+  "roperty><property name=\"can_focus\">False</property><property name=\"l"
+  "abel\" translatable=\"yes\">Change layout option</property><attributes>"
+  "<attribute name=\"weight\" value=\"bold\"/></attributes></object></chil"
+  "d></object><packing><property name=\"expand\">False</property><property"
+  " name=\"fill\">True</property><property name=\"position\">0</property><"
+  "/packing></child><child><object class=\"GtkFrame\" id=\"xkb_manage_layo"
+  "ut_frame\"><property name=\"visible\">True</property><property name=\"c"
+  "an_focus\">False</property><property name=\"label_xalign\">0</property>"
+  "<property name=\"shadow_type\">none</property><child><object class=\"Gt"
+  "kAlignment\" id=\"alignment7\"><property name=\"visible\">True</propert"
+  "y><property name=\"can_focus\">False</property><property name=\"border_"
+  "width\">6</property><property name=\"left_padding\">12</property><child"
+  "><object class=\"GtkComboBox\" id=\"xkb_manage_layout_combo\"><property"
   " name=\"visible\">True</property><property name=\"can_focus\">False</pr"
-  "operty><property name=\"left_padding\">12</property><child><object clas"
-  "s=\"GtkVBox\" id=\"vbox8\"><property name=\"visible\">True</property><p"
-  "roperty name=\"can_focus\">False</property><property name=\"border_widt"
-  "h\">6</property><property name=\"spacing\">6</property><child><object c"
-  "lass=\"GtkScrolledWindow\" id=\"scrolledwindow1\"><property name=\"visi"
-  "ble\">True</property><property name=\"can_focus\">True</property><prope"
-  "rty name=\"hscrollbar_policy\">automatic</property><property name=\"vsc"
-  "rollbar_policy\">automatic</property><property name=\"shadow_type\">etc"
-  "hed-in</property><child><object class=\"GtkTreeView\" id=\"xkb_layout_v"
-  "iew\"><property name=\"visible\">True</property><property name=\"can_fo"
-  "cus\">True</property><property name=\"search_column\">0</property></obj"
-  "ect></child></object><packing><property name=\"expand\">True</property>"
-  "<property name=\"fill\">True</property><property name=\"position\">0</p"
-  "roperty></packing></child><child><object class=\"GtkHButtonBox\" id=\"h"
-  "buttonbox2\"><property name=\"visible\">True</property><property name=\""
-  "can_focus\">False</property><property name=\"spacing\">12</property><pr"
-  "operty name=\"layout_style\">start</property><child><object class=\"Gtk"
-  "Button\" id=\"xkb_layout_add_button\"><property name=\"label\">gtk-add<"
-  "/property><property name=\"use_action_appearance\">False</property><pro"
-  "perty 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=\"e"
-  "xpand\">False</property><property name=\"fill\">False</property><proper"
-  "ty name=\"position\">0</property></packing></child><child><object class"
-  "=\"GtkButton\" id=\"xkb_layout_edit_button\"><property name=\"label\">g"
-  "tk-edit</property><property name=\"use_action_appearance\">False</prope"
-  "rty><property name=\"visible\">True</property><property name=\"can_focu"
-  "s\">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\">1</property></packing></child><child><obje"
-  "ct class=\"GtkButton\" id=\"xkb_layout_delete_button\"><property name=\""
-  "label\">gtk-delete</property><property name=\"use_action_appearance\">F"
-  "alse</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\">Fals"
-  "e</property><property name=\"position\">2</property></packing></child><"
-  "/object><packing><property name=\"expand\">False</property><property na"
-  "me=\"fill\">True</property><property name=\"position\">1</property></pa"
-  "cking></child></object></child></object></child><child type=\"label\"><"
-  "object class=\"GtkLabel\" id=\"label8\"><property name=\"visible\">True"
-  "</property><property name=\"can_focus\">False</property><property name="
-  "\"label\" translatable=\"yes\">Keyboard layout</property><attributes><a"
-  "ttribute name=\"weight\" value=\"bold\"/></attributes></object></child>"
-  "</object><packing><property name=\"expand\">True</property><property na"
-  "me=\"fill\">True</property><property name=\"position\">2</property></pa"
-  "cking></child></object><packing><property name=\"position\">2</property"
-  "></packing></child><child type=\"tab\"><object class=\"GtkLabel\" id=\""
-  "label4\"><property name=\"visible\">True</property><property name=\"can"
-  "_focus\">False</property><property name=\"label\" translatable=\"yes\">"
-  "_Layout</property><property name=\"use_underline\">True</property></obj"
-  "ect><packing><property name=\"position\">2</property><property name=\"t"
-  "ab_fill\">False</property></packing></child></object><packing><property"
-  " name=\"expand\">True</property><property name=\"fill\">True</property>"
-  "<property name=\"position\">1</property></packing></child></object><pac"
-  "king><property name=\"expand\">True</property><property name=\"fill\">T"
-  "rue</property><property name=\"position\">1</property></packing></child"
-  "></object></child><action-widgets><action-widget response=\"0\">button2"
-  "</action-widget><action-widget response=\"-11\">button1</action-widget>"
-  "</action-widgets></object><object class=\"GtkAdjustment\" id=\"net_curs"
-  "or_blink_time\"><property name=\"lower\">100</property><property name=\""
-  "upper\">2000</property><property name=\"value\">1000</property><propert"
-  "y name=\"step_increment\">1</property><property name=\"page_increment\""
-  ">10</property></object><object class=\"GtkSizeGroup\" id=\"sizegroup1\""
-  "><widgets><widget name=\"add_shortcut_button\"/><widget name=\"delete_s"
-  "hortcut_button\"/></widgets></object><object class=\"GtkAdjustment\" id"
-  "=\"xkb_key_repeat_delay\"><property name=\"lower\">10</property><proper"
-  "ty name=\"upper\">1000</property><property name=\"value\">500</property"
-  "><property name=\"step_increment\">1</property><property name=\"page_in"
-  "crement\">10</property></object><object class=\"GtkAdjustment\" id=\"xk"
-  "b_key_repeat_rate\"><property name=\"lower\">1</property><property name"
-  "=\"upper\">250</property><property name=\"value\">20</property><propert"
-  "y name=\"step_increment\">1</property><property name=\"page_increment\""
-  ">10</property></object></interface>"
+  "operty></object></child></object></child><child type=\"label\"><object "
+  "class=\"GtkLabel\" id=\"label14\"><property name=\"visible\">True</prop"
+  "erty><property name=\"can_focus\">False</property><property name=\"labe"
+  "l\" translatable=\"yes\">Manage layout</property><attributes><attribute"
+  " name=\"weight\" value=\"bold\"/></attributes></object></child></object"
+  "><packing><property name=\"expand\">False</property><property name=\"fi"
+  "ll\">True</property><property name=\"position\">1</property></packing><"
+  "/child></object><packing><property name=\"expand\">False</property><pro"
+  "perty name=\"fill\">True</property><property name=\"position\">2</prope"
+  "rty></packing></child><child><object class=\"GtkFrame\" id=\"xkb_layout"
+  "_frame\"><property name=\"visible\">True</property><property name=\"can"
+  "_focus\">False</property><property name=\"label_xalign\">0</property><p"
+  "roperty name=\"shadow_type\">none</property><child><object class=\"GtkA"
+  "lignment\" id=\"alignment4\"><property name=\"visible\">True</property>"
+  "<property name=\"can_focus\">False</property><property name=\"left_padd"
+  "ing\">12</property><child><object class=\"GtkVBox\" id=\"vbox8\"><prope"
+  "rty name=\"visible\">True</property><property name=\"can_focus\">False<"
+  "/property><property name=\"border_width\">6</property><property name=\""
+  "spacing\">6</property><child><object class=\"GtkScrolledWindow\" id=\"s"
+  "crolledwindow1\"><property name=\"visible\">True</property><property na"
+  "me=\"can_focus\">True</property><property name=\"hscrollbar_policy\">au"
+  "tomatic</property><property name=\"vscrollbar_policy\">automatic</prope"
+  "rty><property name=\"shadow_type\">etched-in</property><child><object c"
+  "lass=\"GtkTreeView\" id=\"xkb_layout_view\"><property name=\"visible\">"
+  "True</property><property name=\"can_focus\">True</property><property na"
+  "me=\"search_column\">0</property></object></child></object><packing><pr"
+  "operty name=\"expand\">True</property><property name=\"fill\">True</pro"
+  "perty><property name=\"position\">0</property></packing></child><child>"
+  "<object class=\"GtkHButtonBox\" id=\"hbuttonbox2\"><property name=\"vis"
+  "ible\">True</property><property name=\"can_focus\">False</property><pro"
+  "perty name=\"spacing\">12</property><property name=\"layout_style\">sta"
+  "rt</property><child><object class=\"GtkButton\" id=\"xkb_layout_add_but"
+  "ton\"><property name=\"label\">gtk-add</property><property name=\"use_a"
+  "ction_appearance\">False</property><property name=\"visible\">True</pro"
+  "perty><property name=\"can_focus\">True</property><property name=\"rece"
+  "ives_default\">True</property><property name=\"use_stock\">True</proper"
+  "ty></object><packing><property name=\"expand\">False</property><propert"
+  "y name=\"fill\">False</property><property name=\"position\">0</property"
+  "></packing></child><child><object class=\"GtkButton\" id=\"xkb_layout_e"
+  "dit_button\"><property name=\"label\">gtk-edit</property><property name"
+  "=\"use_action_appearance\">False</property><property name=\"visible\">T"
+  "rue</property><property name=\"can_focus\">True</property><property nam"
+  "e=\"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\">1</"
+  "property></packing></child><child><object class=\"GtkButton\" id=\"xkb_"
+  "layout_delete_button\"><property name=\"label\">gtk-delete</property><p"
+  "roperty name=\"use_action_appearance\">False</property><property name=\""
+  "visible\">True</property><property name=\"can_focus\">True</property><p"
+  "roperty name=\"receives_default\">True</property><property name=\"use_s"
+  "tock\">True</property></object><packing><property name=\"expand\">False"
+  "</property><property name=\"fill\">False</property><property name=\"pos"
+  "ition\">2</property></packing></child></object><packing><property name="
+  "\"expand\">False</property><property name=\"fill\">True</property><prop"
+  "erty name=\"position\">1</property></packing></child></object></child><"
+  "/object></child><child type=\"label\"><object class=\"GtkLabel\" id=\"l"
+  "abel8\"><property name=\"visible\">True</property><property name=\"can_"
+  "focus\">False</property><property name=\"label\" translatable=\"yes\">K"
+  "eyboard layout</property><attributes><attribute name=\"weight\" value=\""
+  "bold\"/></attributes></object></child></object><packing><property name="
+  "\"expand\">True</property><property name=\"fill\">True</property><prope"
+  "rty name=\"position\">3</property></packing></child></object><packing><"
+  "property name=\"position\">2</property></packing></child><child type=\""
+  "tab\"><object class=\"GtkLabel\" id=\"label4\"><property name=\"visible"
+  "\">True</property><property name=\"can_focus\">False</property><propert"
+  "y name=\"label\" translatable=\"yes\">_Layout</property><property name="
+  "\"use_underline\">True</property></object><packing><property name=\"pos"
+  "ition\">2</property><property name=\"tab_fill\">False</property></packi"
+  "ng></child></object><packing><property name=\"expand\">True</property><"
+  "property name=\"fill\">True</property><property name=\"position\">1</pr"
+  "operty></packing></child></object><packing><property name=\"expand\">Tr"
+  "ue</property><property name=\"fill\">True</property><property name=\"po"
+  "sition\">1</property></packing></child></object></child><action-widgets"
+  "><action-widget response=\"-11\">button1</action-widget><action-widget "
+  "response=\"0\">button2</action-widget></action-widgets></object><object"
+  " class=\"GtkAdjustment\" id=\"net_cursor_blink_time\"><property name=\""
+  "lower\">100</property><property name=\"upper\">2000</property><property"
+  " name=\"value\">1000</property><property name=\"step_increment\">1</pro"
+  "perty><property name=\"page_increment\">10</property></object><object c"
+  "lass=\"GtkSizeGroup\" id=\"sizegroup1\"><widgets><widget name=\"add_sho"
+  "rtcut_button\"/><widget name=\"delete_shortcut_button\"/></widgets></ob"
+  "ject><object class=\"GtkAdjustment\" id=\"xkb_key_repeat_delay\"><prope"
+  "rty name=\"lower\">10</property><property name=\"upper\">1000</property"
+  "><property name=\"value\">500</property><property name=\"step_increment"
+  "\">1</property><property name=\"page_increment\">10</property></object>"
+  "<object class=\"GtkAdjustment\" id=\"xkb_key_repeat_rate\"><property na"
+  "me=\"lower\">1</property><property name=\"upper\">250</property><proper"
+  "ty name=\"value\">20</property><property name=\"step_increment\">1</pro"
+  "perty><property name=\"page_increment\">10</property></object></interfa"
+  "ce>"
 };
 
-static const unsigned keyboard_dialog_ui_length = 28087u;
+static const unsigned keyboard_dialog_ui_length = 30553u;
 
diff -rupN a/dialogs/keyboard-settings/xfce-keyboard-settings.c b/dialogs/keyboard-settings/xfce-keyboard-settings.c
--- a/dialogs/keyboard-settings/xfce-keyboard-settings.c	2012-04-28 20:48:30.000000000 +0000
+++ b/dialogs/keyboard-settings/xfce-keyboard-settings.c	2012-06-24 13:09:49.000000000 +0000
@@ -1,6 +1,7 @@
 /* vi:set sw=2 sts=2 ts=2 et ai: */
 /*-
- * Copyright (c) 2008 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2012 Alexsandr Sovenko <owlx at mail.com>
+ *               2008 Jannis Pohlmann <jannis at xfce.org>
  *               2008 Olivier Fourdan <olivier at xfce.org>
  * Portions based on xfkc
  * Copyright (c) 2007 Gauvain Pocentek <gauvainpocentek at gmail.com>
@@ -133,9 +134,19 @@ static void                      xfce_ke
 static void                      xfce_keyboard_settings_add_model_to_combo    (XklConfigRegistry         *config_registry,
                                                                                const XklConfigItem       *config_item,
                                                                                gpointer                   user_data);
+static void                      xfce_keyboard_settings_add_layout_option_to_combo    (XklConfigRegistry         *config_registry,
+                                                                               const XklConfigItem       *config_item,
+                                                                               gpointer                   user_data);
+static void                      xfce_keyboard_settings_add_manage_layout_to_combo    (gpointer user_data);
 static void                      xfce_keyboard_settings_init_model            (XfceKeyboardSettings      *settings);
+static void                      xfce_keyboard_settings_init_layout_option            (XfceKeyboardSettings      *settings);
+static void                      xfce_keyboard_settings_init_manage_layout            (XfceKeyboardSettings      *settings);
 static void                      xfce_keyboard_settings_model_changed_cb      (GtkComboBox               *combo,
                                                                                XfceKeyboardSettings      *settings);
+static void                      xfce_keyboard_settings_layout_option_changed_cb      (GtkComboBox               *combo,
+                                                                               XfceKeyboardSettings      *settings);
+static void                      xfce_keyboard_settings_manage_layout_changed_cb      (GtkComboBox               *combo,
+                                                                               XfceKeyboardSettings      *settings);
 static void                      xfce_keyboard_settings_active_layout_cb      (GtkTreeView               *view,
                                                                                XfceKeyboardSettings      *settings);
 static void                      xfce_keyboard_settings_update_layout_buttons (XfceKeyboardSettings      *settings);
@@ -254,6 +265,8 @@ xfce_keyboard_settings_constructed (GObj
   GObject              *xkb_use_system_default_checkbutton;
   GObject              *xkb_tab_layout_vbox;
   GObject              *xkb_model_combo;
+  GObject              *xkb_layout_option_combo;
+  GObject              *xkb_manage_layout_combo;
   GObject              *xkb_layout_view;
   GObject              *xkb_layout_add_button;
   GObject              *xkb_layout_edit_button;
@@ -371,6 +384,48 @@ xfce_keyboard_settings_constructed (GObj
                     G_CALLBACK (xfce_keyboard_settings_model_changed_cb),
                     settings);
 
+  /* Layout option combo */
+  list_store = gtk_list_store_new (XKB_COMBO_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), 0, GTK_SORT_ASCENDING);
+   xkl_config_registry_foreach_option (settings->priv->xkl_registry, "grp",
+                                     xfce_keyboard_settings_add_layout_option_to_combo,
+                                     list_store);
+
+  xkb_layout_option_combo = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_layout_option_combo");
+  gtk_combo_box_set_model (GTK_COMBO_BOX (xkb_layout_option_combo), GTK_TREE_MODEL (list_store));
+  g_object_unref (G_OBJECT (list_store));
+
+  gtk_cell_layout_clear (GTK_CELL_LAYOUT (xkb_layout_option_combo));
+  renderer = gtk_cell_renderer_text_new ();
+  g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (xkb_layout_option_combo), renderer, TRUE);
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (xkb_layout_option_combo), renderer, "text", 0);
+
+  xfce_keyboard_settings_init_layout_option (settings);
+  g_signal_connect (G_OBJECT (xkb_layout_option_combo), "changed",
+                    G_CALLBACK (xfce_keyboard_settings_layout_option_changed_cb),
+                    settings);
+
+  /* Manage layout combo */
+  list_store = gtk_list_store_new (XKB_COMBO_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
+  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), 0, GTK_SORT_ASCENDING);
+  xfce_keyboard_settings_add_manage_layout_to_combo(list_store);
+
+  xkb_manage_layout_combo = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_manage_layout_combo");
+  gtk_combo_box_set_model (GTK_COMBO_BOX (xkb_manage_layout_combo), GTK_TREE_MODEL (list_store));
+  g_object_unref (G_OBJECT (list_store));
+
+  gtk_cell_layout_clear (GTK_CELL_LAYOUT (xkb_manage_layout_combo));
+  renderer = gtk_cell_renderer_text_new ();
+  g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (xkb_manage_layout_combo), renderer, TRUE);
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (xkb_manage_layout_combo), renderer, "text", 0);
+
+  xfce_keyboard_settings_init_manage_layout (settings);
+  g_signal_connect (G_OBJECT (xkb_manage_layout_combo), "changed",
+                    G_CALLBACK (xfce_keyboard_settings_manage_layout_changed_cb),
+                    settings);
+
   /* Keyboard layout/variant treeview */
   settings->priv->layout_selection_treestore = NULL;
   xkb_layout_view = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_layout_view");
@@ -1011,6 +1066,8 @@ xfce_keyboard_settings_update_sensitive
 {
   GObject  *xkb_model_frame;
   GObject  *xkb_layout_frame;
+  GObject  *xkb_layout_option_frame;
+  GObject  *xkb_manage_layout_frame;
   gboolean  active;
 
   g_return_val_if_fail (XFCE_IS_KEYBOARD_SETTINGS (settings), FALSE);
@@ -1018,9 +1075,13 @@ xfce_keyboard_settings_update_sensitive
   active = gtk_toggle_button_get_active (toggle);
   xkb_model_frame = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_model_frame");
   xkb_layout_frame = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_layout_frame");
+  xkb_layout_option_frame = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_layout_option_frame");
+  xkb_manage_layout_frame = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_manage_layout_frame");
 
   gtk_widget_set_sensitive (GTK_WIDGET (xkb_model_frame), !active);
   gtk_widget_set_sensitive (GTK_WIDGET (xkb_layout_frame), !active);
+  gtk_widget_set_sensitive (GTK_WIDGET (xkb_layout_option_frame), !active);
+  gtk_widget_set_sensitive (GTK_WIDGET (xkb_manage_layout_frame), !active);
 
   return active;
 }
@@ -1062,6 +1123,8 @@ xfce_keyboard_settings_set_layout (XfceK
   gchar            *val_variant;
   gchar            *variants;
   gchar            *layouts;
+  gchar            *option;
+  gchar            *manage;
   gchar            *tmp;
 
   view = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_layout_view");
@@ -1152,13 +1215,23 @@ xfce_keyboard_settings_set_layout (XfceK
       g_free (active_variant);
     }
 
+  option = xfconf_channel_get_string (settings->priv->keyboard_layout_channel, 
+                             "/Default/XkbLayoutOption", "grp:alt_shift_toggle");
+  manage = xfconf_channel_get_string (settings->priv->keyboard_layout_channel, 
+                            "/Default/XkbManageLayout", "globally");
+
   xfconf_channel_set_string (settings->priv->keyboard_layout_channel,
                              "/Default/XkbLayout", layouts);
   xfconf_channel_set_string (settings->priv->keyboard_layout_channel,
                              "/Default/XkbVariant", variants);
-
+  xfconf_channel_set_string (settings->priv->keyboard_layout_channel,
+                             "/Default/XkbLayoutOption", option);
+  xfconf_channel_set_string (settings->priv->keyboard_layout_channel,
+                             "/Default/XkbManageLayout", manage);
   g_free (layouts);
   g_free (variants);
+  g_free (option);
+  g_free (manage);
 }
 
 
@@ -1246,7 +1319,6 @@ xfce_keyboard_settings_init_layout (Xfce
 }
 
 
-
 static void
 xfce_keyboard_settings_add_model_to_combo (XklConfigRegistry    *config_registry,
                                            const XklConfigItem  *config_item,
@@ -1265,6 +1337,45 @@ xfce_keyboard_settings_add_model_to_comb
   g_free (model_name);
 }
 
+static void
+xfce_keyboard_settings_add_layout_option_to_combo (XklConfigRegistry    *config_registry,
+                                           const XklConfigItem  *config_item,
+                                           gpointer              user_data)
+{
+  GtkListStore *store = GTK_LIST_STORE (user_data);
+  GtkTreeIter   iter;
+  gchar        *model_name;
+
+  model_name = xfce_keyboard_settings_xkb_description ((XklConfigItem *) config_item);
+
+  gtk_list_store_append (store, &iter);
+  gtk_list_store_set (store, &iter,
+                      XKB_COMBO_DESCRIPTION, model_name,
+                      XKB_COMBO_MODELS, config_item->name, -1);
+  g_free (model_name);
+}
+
+static void
+xfce_keyboard_settings_add_manage_layout_to_combo (gpointer user_data)
+{
+  GtkListStore *store = GTK_LIST_STORE (user_data);
+  GtkTreeIter   iter;
+
+  gtk_list_store_append (store, &iter);
+  gtk_list_store_set (store, &iter,
+                      XKB_COMBO_DESCRIPTION, _("Globally"),
+                      XKB_COMBO_MODELS, "globally", -1);
+
+  gtk_list_store_append (store, &iter);
+  gtk_list_store_set (store, &iter,
+                      XKB_COMBO_DESCRIPTION, _("Per window"),
+                      XKB_COMBO_MODELS, "window", -1);
+
+  gtk_list_store_append (store, &iter);
+  gtk_list_store_set (store, &iter,
+                      XKB_COMBO_DESCRIPTION, _("Per application"),
+                      XKB_COMBO_MODELS, "application", -1);
+}
 
 
 static void
@@ -1300,7 +1411,71 @@ xfce_keyboard_settings_init_model (XfceK
   g_free (xkbmodel);
 }
 
+static void
+xfce_keyboard_settings_init_layout_option (XfceKeyboardSettings *settings)
+{
+  GObject      *view;
+  GtkTreeModel *model;
+  GtkTreeIter   iter;
+  gchar        *id;
+  gchar        *xkbmodel;
+  gboolean      item;
+  gboolean      found = FALSE;
+
+  view = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_layout_option_combo");
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (view));
+
+  xkbmodel = xfconf_channel_get_string (settings->priv->keyboard_layout_channel, "/Default/XkbLayoutOption", "grp:alt_shift_toggle");
+  item = gtk_tree_model_get_iter_first (model, &iter);
+
+  while (item && !found)
+    {
+      gtk_tree_model_get (model, &iter, XKB_COMBO_MODELS, &id, -1);
+      found = !strcmp (id, xkbmodel);
+      g_free (id);
+
+      if (found)
+        {
+          gtk_combo_box_set_active_iter (GTK_COMBO_BOX (view), &iter);
+          break;
+        }
+      item = gtk_tree_model_iter_next (model, &iter);
+    }
+  g_free (xkbmodel);
+}
+
+static void
+xfce_keyboard_settings_init_manage_layout (XfceKeyboardSettings *settings)
+{
+  GObject      *view;
+  GtkTreeModel *model;
+  GtkTreeIter   iter;
+  gchar        *id;
+  gchar        *xkbmodel;
+  gboolean      item;
+  gboolean      found = FALSE;
+
+  view = gtk_builder_get_object (GTK_BUILDER (settings), "xkb_manage_layout_combo");
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (view));
 
+  xkbmodel = xfconf_channel_get_string (settings->priv->keyboard_layout_channel, "/Default/XkbManageLayout", "globally");
+  item = gtk_tree_model_get_iter_first (model, &iter);
+
+  while (item && !found)
+    {
+      gtk_tree_model_get (model, &iter, XKB_COMBO_MODELS, &id, -1);
+      found = !strcmp (id, xkbmodel);
+      g_free (id);
+
+      if (found)
+        {
+          gtk_combo_box_set_active_iter (GTK_COMBO_BOX (view), &iter);
+          break;
+        }
+      item = gtk_tree_model_iter_next (model, &iter);
+    }
+  g_free (xkbmodel);
+}
 
 static void
 xfce_keyboard_settings_active_layout_cb (GtkTreeView           *view,
@@ -1336,7 +1511,35 @@ xfce_keyboard_settings_model_changed_cb
   g_free (xkbmodel);
 }
 
+static void
+xfce_keyboard_settings_layout_option_changed_cb (GtkComboBox          *combo,
+                                         XfceKeyboardSettings *settings)
+{
+  GtkTreeModel *model;
+  GtkTreeIter   iter;
+  gchar        *xkbmodel;
 
+  gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
+  gtk_tree_model_get (model, &iter, XKB_COMBO_MODELS, &xkbmodel, -1);
+  xfconf_channel_set_string (settings->priv->keyboard_layout_channel, "/Default/XkbLayoutOption", xkbmodel);
+  g_free (xkbmodel);
+}
+
+static void
+xfce_keyboard_settings_manage_layout_changed_cb (GtkComboBox          *combo,
+                                         XfceKeyboardSettings *settings)
+{
+  GtkTreeModel *model;
+  GtkTreeIter   iter;
+  gchar        *xkbmodel;
+
+  gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
+  gtk_tree_model_get (model, &iter, XKB_COMBO_MODELS, &xkbmodel, -1);
+  xfconf_channel_set_string (settings->priv->keyboard_layout_channel, "/Default/XkbManageLayout", xkbmodel);
+  g_free (xkbmodel);
+}
 
 static void
 xfce_keyboard_settings_update_layout_buttons (XfceKeyboardSettings *settings)
diff -rupN a/xfsettingsd/keyboard-layout.c b/xfsettingsd/keyboard-layout.c
--- a/xfsettingsd/keyboard-layout.c	2012-04-28 20:48:30.000000000 +0000
+++ b/xfsettingsd/keyboard-layout.c	2012-06-24 22:34:53.000000000 +0000
@@ -1,5 +1,6 @@
 /*
- *  Copyright (c) 2008 Olivier Fourdan <olivier at xfce.org>
+ *  Copyright (c) 2012 Alexsandr Sovenko <owlx at mail.com>
+ *                2008 Olivier Fourdan <olivier at xfce.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -44,8 +45,18 @@
 #include "debug.h"
 #include "keyboard-layout.h"
 
+#ifdef HAVE_LIBWNCK
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <libwnck/libwnck.h>
+#endif /*HAVE_LIBWNCK*/
+
+static void xfce_keyboard_layout_helper_finalize                  (GObject *object);
 static void xfce_keyboard_layout_helper_process_xmodmap           (void);
 static void xfce_keyboard_layout_helper_set_model                 (XfceKeyboardLayoutHelper      *helper);
+static void xfce_keyboard_layout_helper_set_layout_option         (XfceKeyboardLayoutHelper      *helper);
+static void xfce_keyboard_layout_helper_set_manage_layout         (XfceKeyboardLayoutHelper      *helper);
 static void xfce_keyboard_layout_helper_set_layout                (XfceKeyboardLayoutHelper      *helper);
 static void xfce_keyboard_layout_helper_set_variant               (XfceKeyboardLayoutHelper      *helper);
 static void xfce_keyboard_layout_helper_channel_property_changed  (XfconfChannel                 *channel,
@@ -73,14 +84,234 @@ struct _XfceKeyboardLayoutHelper
     XklConfigRegistry *registry;
     XklConfigRec      *config;
 #endif /* HAVE_LIBXKLAVIER */
+
+#ifdef HAVE_LIBWNCK
+    GHashTable        *application_map;
+    GHashTable        *window_map;
+    gint               current_application_id;
+    gint               current_window_id;
+
+    /* Dbus */
+    DBusConnection    *bus;
+    DBusError          error;
+    gchar             *lang;
+    gchar             *xkbmanlay;
+    /* Dbus */
+#endif /*HAVE_LIBWNCK*/
 };
 
 G_DEFINE_TYPE (XfceKeyboardLayoutHelper, xfce_keyboard_layout_helper, G_TYPE_OBJECT);
 
+#ifdef HAVE_LIBWNCK
+
+DBusHandlerResult
+xfce_keyboard_manage_layout_signal_filter (DBusConnection *connection,
+                                           DBusMessage    *message,
+                                           void           *user_data)
+{
+    XfceKeyboardLayoutHelper *helper = (XfceKeyboardLayoutHelper *) user_data;
+
+    DBusError error;
+    gint      group;
+
+    if (dbus_message_is_signal
+        (message, DBUS_INTERFACE_LOCAL, "Disconnected"))
+    return DBUS_HANDLER_RESULT_HANDLED;
+    else if (dbus_message_is_signal (message, "org.xfce.SettingsDaemon.KeyboardLayoutHelper.Signal", "layoutset"))
+         {
+             dbus_error_init (&error);
+             if (dbus_message_get_args (message, &error,
+                     DBUS_TYPE_INT32, &group,
+                     DBUS_TYPE_INVALID))
+             {
+                  if(!strcmp(helper->xkbmanlay,"window"))
+                     g_hash_table_insert (helper->window_map,
+                         GINT_TO_POINTER (helper->current_window_id),
+                         GINT_TO_POINTER (group));
+                  if(!strcmp(helper->xkbmanlay,"application"))
+                     g_hash_table_insert (helper->application_map,
+                         GINT_TO_POINTER (helper->current_application_id),
+                         GINT_TO_POINTER (group));
+
+                     xkl_engine_lock_group (helper->engine, group);
+             } else 
+             {
+                 g_print("`layoutset` received, but error getting message: %s\n",
+                     error.message);
+                 dbus_error_free (&error);
+             }
+             return DBUS_HANDLER_RESULT_HANDLED;
+         }
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+GdkFilterReturn
+xfce_keyboard_manage_layout_handle_xevent (GdkXEvent    *xev,
+                                           GdkEvent     *event,
+XfceKeyboardLayoutHelper    *helper)
+{
+    XEvent *xevent = (XEvent *) xev;
+    xkl_engine_filter_events (helper->engine, xevent);
+    return GDK_FILTER_CONTINUE;
+}
+
 static void
-xfce_keyboard_layout_helper_class_init (XfceKeyboardLayoutHelperClass *klass)
+xfce_keyboard_manage_layout_init (XfceKeyboardLayoutHelper *helper)
 {
+    void
+    active_window_changed_cb (WnckScreen    *screen,
+                              WnckWindow    *previously_active_window,
+                XfceKeyboardLayoutHelper    *helper)
+    {
+        if (helper->xkb_disable_settings) return;
+        if (!strcmp (helper->xkbmanlay, "globally")) return;
+
+        WnckWindow *window = wnck_screen_get_active_window (screen);
+        if (!WNCK_IS_WINDOW (window)) return;
+        guint window_id = wnck_window_get_xid (window);
+        guint application_id = wnck_window_get_pid (window);
+        helper->current_application_id = application_id;
+        helper->current_window_id = window_id;
+
+        gint group = 0;
+        gpointer key, value;
+
+        if (!strcmp (helper->xkbmanlay, "window"))
+        {
+            if (g_hash_table_lookup_extended (helper->window_map,
+                GINT_TO_POINTER (window_id), &key, &value))
+                group = GPOINTER_TO_INT (value);
+
+                g_hash_table_insert (helper->window_map,
+                    GINT_TO_POINTER (window_id),
+                    GINT_TO_POINTER (group));
+
+                xkl_engine_lock_group (helper->engine, group);
+        }
+
+        if (!strcmp (helper->xkbmanlay, "application"))
+        {
+            if (g_hash_table_lookup_extended (helper->application_map,
+                    GINT_TO_POINTER (application_id), &key, &value))
+                group = GPOINTER_TO_INT (value);
+            g_hash_table_insert (helper->application_map,
+                GINT_TO_POINTER (application_id),
+                GINT_TO_POINTER (group));
+
+                xkl_engine_lock_group (helper->engine, group);
+        }
+    }
+
+    void
+    application_closed_cb (WnckScreen    *screen,
+                      WnckApplication    *app,
+             XfceKeyboardLayoutHelper    *helper)
+    {
+        if (helper->xkb_disable_settings) return;
+        guint application_id = wnck_application_get_pid (app);
+
+        if (!strcmp (helper->xkbmanlay, "window")) return;
+
+        if (!strcmp (helper->xkbmanlay, "application"))
+            g_hash_table_remove (helper->application_map,
+                GINT_TO_POINTER (application_id));
+    }
+
+    void
+    window_closed_cb (WnckScreen    *screen,
+                      WnckWindow    *window,
+        XfceKeyboardLayoutHelper    *helper)
+    {
+        if (helper->xkb_disable_settings) return;
+        guint window_id = wnck_window_get_xid (window);
+
+        if (!strcmp (helper->xkbmanlay, "application")) return;
+
+        if (!strcmp (helper->xkbmanlay,"window"))
+            g_hash_table_remove (helper->window_map,
+                GINT_TO_POINTER (window_id));
+    }
+
+    void
+    X_state_changed_cb (XklEngine    *engine,
+             XklEngineStateChange    *change,
+             gint                     group,
+                                      gboolean restore,
+         XfceKeyboardLayoutHelper     *helper)
+    {
+        if (change == GROUP_CHANGED)
+        {
+            if (!strcmp (helper->xkbmanlay, "window"))
+                g_hash_table_insert (helper->window_map,
+                    GINT_TO_POINTER (helper->current_window_id),
+                    GINT_TO_POINTER (group));
+
+            if (!strcmp (helper->xkbmanlay, "application"))
+                g_hash_table_insert (helper->application_map,
+                    GINT_TO_POINTER (helper->current_application_id),
+                    GINT_TO_POINTER (group));
+
+           if (helper->bus)
+           {
+               DBusMessage *message = 
+                   dbus_message_new_signal ("/org/xfce/SettingsDaemon/KeyboardLayoutHelper/layoutget",
+                                            "org.xfce.SettingsDaemon.KeyboardLayoutHelper.Signal",
+                                            "layoutget");
+               dbus_message_append_args (message,
+                                         DBUS_TYPE_INT32, &group,
+                                         DBUS_TYPE_INVALID);
+               dbus_connection_send (helper->bus, message, NULL);
+               dbus_message_unref (message);
+           }
+
+        }
+    }
+
+    dbus_error_init (&helper->error);
+    helper->bus = dbus_bus_get (DBUS_BUS_SESSION, &helper->error);
+    if (!helper->bus) 
+    {
+        g_warning ("Failed to connect to the D-BUS daemon: %s", helper->error.message);
+        dbus_error_free (&helper->error);
+    } else
+    {
+        dbus_connection_setup_with_g_main (helper->bus, NULL);
+        dbus_bus_add_match (helper->bus, "type='signal',interface='org.xfce.SettingsDaemon.KeyboardLayoutHelper.Signal'", NULL);
+        dbus_connection_add_filter (helper->bus,
+            xfce_keyboard_manage_layout_signal_filter, helper, NULL);
+    }
 
+    helper->window_map = g_hash_table_new (g_direct_hash, NULL);
+    helper->application_map = g_hash_table_new (g_direct_hash, NULL);
+
+    xkl_engine_set_group_per_toplevel_window (helper->engine, FALSE);
+    xkl_engine_start_listen (helper->engine, XKLL_TRACK_KEYBOARD_STATE);
+
+    g_signal_connect (helper->engine, "X-state-changed",
+        G_CALLBACK (X_state_changed_cb), helper);
+
+    gdk_window_add_filter (NULL,
+        (GdkFilterFunc) xfce_keyboard_manage_layout_handle_xevent, helper);
+
+    WnckScreen *wnck_screen = wnck_screen_get_default ();
+
+    g_signal_connect (G_OBJECT (wnck_screen), "active-window-changed",
+        G_CALLBACK (active_window_changed_cb), helper);
+
+    g_signal_connect (G_OBJECT (wnck_screen), "window-closed",
+        G_CALLBACK (window_closed_cb), helper);
+
+    g_signal_connect (G_OBJECT (wnck_screen), "application-closed",
+        G_CALLBACK (application_closed_cb), helper);
+}
+#endif /*HAVE_LIBWNCK*/
+
+static void
+xfce_keyboard_layout_helper_class_init (XfceKeyboardLayoutHelperClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    object_class->finalize = xfce_keyboard_layout_helper_finalize;
+    g_type_class_add_private (klass, sizeof (XfceKeyboardLayoutHelper));
 }
 
 static void
@@ -104,13 +335,35 @@ xfce_keyboard_layout_helper_init (XfceKe
     /* load settings */
     helper->xkb_disable_settings = xfconf_channel_get_bool (helper->channel, "/Default/XkbDisable", TRUE);
     xfce_keyboard_layout_helper_set_model (helper);
+    xfce_keyboard_layout_helper_set_layout_option (helper);
+    xfce_keyboard_layout_helper_set_manage_layout (helper);
     xfce_keyboard_layout_helper_set_layout (helper);
     xfce_keyboard_layout_helper_set_variant (helper);
 
     xfce_keyboard_layout_helper_process_xmodmap ();
+
+#ifdef HAVE_LIBWNCK
+    /* init manage layout */
+    xfce_keyboard_manage_layout_init (helper);
+#endif /*HAVE_LIBWNCK*/
 }
 
+static void
+xfce_keyboard_layout_helper_finalize (GObject *object)
+{
+    XfceKeyboardLayoutHelper *helper = XFCE_KEYBOARD_LAYOUT_HELPER (object);
+
+    gdk_window_remove_filter (NULL,
+        (GdkFilterFunc) xfce_keyboard_manage_layout_handle_xevent, NULL);
+    xkl_engine_stop_listen (helper->engine, XKLL_TRACK_KEYBOARD_STATE);
+
+#ifdef HAVE_DBUS
+    dbus_connection_remove_filter (helper->bus, 
+        xfce_keyboard_manage_layout_signal_filter, helper);
+#endif /* HAVE_DBUS */
 
+  (*G_OBJECT_CLASS (xfce_keyboard_layout_helper_parent_class)->finalize) (object);
+}
 
 static void
 xfce_keyboard_layout_helper_process_xmodmap (void)
@@ -157,6 +410,41 @@ xfce_keyboard_layout_helper_set_model (X
 }
 
 static void
+xfce_keyboard_layout_helper_set_layout_option (XfceKeyboardLayoutHelper *helper)
+{
+#ifdef HAVE_LIBXKLAVIER
+    gchar *default_layout_option, *val_layout;
+
+    if (!helper->xkb_disable_settings)
+    {
+        default_layout_option = g_strjoinv(",", helper->config->layouts);
+        val_layout  = xfconf_channel_get_string (helper->channel, "/Default/XkbLayoutOption",  default_layout_option);
+        //layouts = ;
+        g_strfreev(helper->config->options);
+        helper->config->options = g_strsplit_set (val_layout, ",", 0);
+        xkl_config_rec_activate (helper->config, helper->engine);
+        g_free (default_layout_option);
+
+        xfsettings_dbg (XFSD_DEBUG_KEYBOARD_LAYOUT, "set layout option to \"%s\"", val_layout);
+        g_free (val_layout);
+    }
+
+#endif /* HAVE_LIBXKLAVIER */
+}
+
+static void
+xfce_keyboard_layout_helper_set_manage_layout (XfceKeyboardLayoutHelper *helper)
+{
+#ifdef HAVE_LIBXKLAVIER
+    if (!helper->xkb_disable_settings)
+    {
+        helper->xkbmanlay = xfconf_channel_get_string (helper->channel, "/Default/XkbManageLayout", "globally");
+        xfsettings_dbg (XFSD_DEBUG_KEYBOARD_LAYOUT, "set manage layout to \"%s\"", helper->xkbmanlay);
+    }
+#endif /* HAVE_LIBXKLAVIER */
+}
+
+static void
 xfce_keyboard_layout_helper_set_layout (XfceKeyboardLayoutHelper *helper)
 {
 #ifdef HAVE_LIBXKLAVIER
@@ -215,6 +503,8 @@ xfce_keyboard_layout_helper_channel_prop
         helper->xkb_disable_settings = g_value_get_boolean (value);
         /* Apply all settings */
         xfce_keyboard_layout_helper_set_model (helper);
+        xfce_keyboard_layout_helper_set_layout_option (helper);
+        xfce_keyboard_layout_helper_set_manage_layout (helper);
         xfce_keyboard_layout_helper_set_layout (helper);
         xfce_keyboard_layout_helper_set_variant (helper);
     }
@@ -222,6 +512,14 @@ xfce_keyboard_layout_helper_channel_prop
     {
         xfce_keyboard_layout_helper_set_layout (helper);
     }
+    else if (strcmp (property_name, "/Default/XkbLayoutOption") == 0)
+    {
+        xfce_keyboard_layout_helper_set_layout_option (helper);
+    }
+    else if (strcmp (property_name, "/Default/XkbManageLayout") == 0)
+    {
+        xfce_keyboard_layout_helper_set_manage_layout (helper);
+    }
     else if (strcmp (property_name, "/Default/XkbLayout") == 0)
     {
         xfce_keyboard_layout_helper_set_layout (helper);


More information about the Xfce4-dev mailing list