add new language config dialog for setting a desklock language (NOT keyboard layout)
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 2 Oct 2012 13:00:25 +0000 (13:00 +0000)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 2 Oct 2012 13:00:25 +0000 (13:00 +0000)
part of ticket #1538

SVN revision: 77321

src/bin/e_config.c
src/bin/e_config.h
src/bin/e_desklock.c
src/modules/conf_intl/e_int_config_intl.c
src/modules/conf_intl/e_int_config_intl.h
src/modules/conf_intl/e_mod_main.c

index e43675c..c98e8b9 100644 (file)
@@ -657,6 +657,7 @@ e_config_init(void)
    E_CONFIG_VAL(D, T, edge_flip_dragging, INT); /**/
    E_CONFIG_VAL(D, T, use_composite, INT); /**/
    E_CONFIG_VAL(D, T, language, STR); /**/
+   E_CONFIG_VAL(D, T, desklock_language, STR); /**/
    E_CONFIG_LIST(D, T, modules, _e_config_module_edd); /**/
    E_CONFIG_LIST(D, T, font_fallbacks, _e_config_font_fallback_edd); /**/
    E_CONFIG_LIST(D, T, font_defaults, _e_config_font_default_edd); /**/
@@ -2119,6 +2120,7 @@ _e_config_free(E_Config *ecf)
    if (ecf->desktop_default_background) eina_stringshare_del(ecf->desktop_default_background);
    if (ecf->desktop_default_name) eina_stringshare_del(ecf->desktop_default_name);
    if (ecf->language) eina_stringshare_del(ecf->language);
+   eina_stringshare_del(ecf->desklock_language);
    if (ecf->transition_start) eina_stringshare_del(ecf->transition_start);
    if (ecf->transition_desk) eina_stringshare_del(ecf->transition_desk);
    if (ecf->transition_change) eina_stringshare_del(ecf->transition_change);
index 7518800..5a563a2 100644 (file)
@@ -37,7 +37,7 @@ typedef struct _E_Event_Config_Icon_Theme   E_Event_Config_Icon_Theme;
 /* increment this whenever a new set of config values are added but the users
  * config doesn't need to be wiped - simply new values need to be put in
  */
-#define E_CONFIG_FILE_GENERATION 0x0154
+#define E_CONFIG_FILE_GENERATION 0x0155
 #define E_CONFIG_FILE_VERSION    ((E_CONFIG_FILE_EPOCH << 16) | E_CONFIG_FILE_GENERATION)
 
 struct _E_Config
@@ -67,6 +67,7 @@ struct _E_Config
    int         edge_flip_dragging; // GUI
    int         use_composite; // GUI
    const char *language; // GUI
+   const char *desklock_language; // GUI
    Eina_List  *modules; // GUI
    Eina_List  *font_fallbacks; // GUI
    Eina_List  *font_defaults; // GUI
index aeadc1d..2d5591c 100644 (file)
@@ -223,6 +223,8 @@ e_desklock_show(Eina_Bool suspend)
           ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
                                   _e_desklock_cb_custom_desklock_exit, NULL);
         e_util_library_path_strip();
+        if (e_config->desklock_language)
+          e_intl_language_set(e_config->desklock_language);
         _e_custom_desklock_exe =
           ecore_exe_run(e_config->desklock_custom_desklock_cmd, NULL);
         e_util_library_path_restore();
@@ -305,7 +307,8 @@ e_desklock_show(Eina_Bool suspend)
         return 0;
      }
 works:
-
+   if (e_config->desklock_language)
+     e_intl_language_set(e_config->desklock_language);
    total_zone_num = _e_desklock_zone_num_get();
    EINA_LIST_FOREACH(managers, l, man)
      {
@@ -372,6 +375,9 @@ e_desklock_hide(void)
 
    if ((!edd) && (!_e_custom_desklock_exe)) return;
 
+   if (e_config->desklock_language)
+     e_intl_language_set(e_config->language);
+
    _e_desklock_state = EINA_FALSE;
    ev = E_NEW(E_Event_Desklock, 1);
    ev->on = 0;
index 6f6d4a8..033f62a 100644 (file)
@@ -5,6 +5,7 @@ typedef struct _E_Intl_Langauge_Node E_Intl_Language_Node;
 typedef struct _E_Intl_Region_Node   E_Intl_Region_Node;
 
 static void        *_create_data(E_Config_Dialog *cfd);
+static void        *_create_desklock_data(E_Config_Dialog *cfd);
 static void         _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
 static int          _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
 static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
@@ -96,8 +97,8 @@ struct _E_Config_Dialog_Data
       Evas_Object *mod_list;
 
       Evas_Object *locale_entry;
-   }
-   gui;
+   } gui;
+   Eina_Bool desklock : 1;
 };
 
 const E_Intl_Pair basic_language_predefined_pairs[] = {
@@ -599,6 +600,29 @@ e_int_config_intl(E_Container *con, const char *params __UNUSED__)
    return cfd;
 }
 
+E_Config_Dialog *
+e_int_config_desklock_intl(E_Container *con, const char *params __UNUSED__)
+{
+   E_Config_Dialog *cfd;
+   E_Config_Dialog_View *v;
+
+   if (e_config_dialog_find("E", "language/desklock_language_settings")) return NULL;
+   v = E_NEW(E_Config_Dialog_View, 1);
+
+   v->create_cfdata = _create_desklock_data;
+   v->free_cfdata = _free_data;
+   v->advanced.create_widgets = _advanced_create_widgets;
+   v->advanced.apply_cfdata = _advanced_apply_data;
+   v->basic.create_widgets = _basic_create_widgets;
+   v->basic.apply_cfdata = _basic_apply_data;
+
+   cfd = e_config_dialog_new(con,
+                             _("Desklock Language Settings"),
+                             "E", "language/desklock_language_settings",
+                             "preferences-desktop-locale", 0, v, NULL);
+   return cfd;
+}
+
 /* Build hash tables used for locale navigation. The locale information is
  * gathered using the locale -a command.
  *
@@ -813,6 +837,19 @@ _create_data(E_Config_Dialog *cfd)
    return cfdata;
 }
 
+static void *
+_create_desklock_data(E_Config_Dialog *cfd)
+{
+   E_Config_Dialog_Data *cfdata;
+
+   cfdata = _create_data(cfd);
+   E_FREE(cfdata->cur_language);
+   if (e_config->desklock_language)
+     cfdata->cur_language = strdup(e_config->desklock_language);
+   cfdata->desklock = 1;
+   return cfdata;
+}
+
 static void
 _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
 {
@@ -923,12 +960,22 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
 {
    if (cfdata->cur_language)
      {
-        if (e_config->language) eina_stringshare_del(e_config->language);
-        e_config->language = NULL;
-        if ((cfdata->cur_language) && (cfdata->cur_language[0]))
-          e_config->language = eina_stringshare_add(cfdata->cur_language);
-        e_intl_language_set(e_config->language);
-        _lc_check();
+        if (cfdata->desklock)
+          {
+             if (e_config->desklock_language) eina_stringshare_del(e_config->desklock_language);
+             e_config->desklock_language = NULL;
+             if ((cfdata->cur_language) && (cfdata->cur_language[0]))
+               e_config->desklock_language = eina_stringshare_add(cfdata->cur_language);
+          }
+        else
+          {
+             if (e_config->language) eina_stringshare_del(e_config->language);
+             e_config->language = NULL;
+             if ((cfdata->cur_language) && (cfdata->cur_language[0]))
+               e_config->language = eina_stringshare_add(cfdata->cur_language);
+             e_intl_language_set(e_config->language);
+             _lc_check();
+          }
      }
 
    e_config_save_queue();
@@ -940,12 +987,22 @@ _advanced_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfda
 {
    if (cfdata->cur_language)
      {
-        if (e_config->language) eina_stringshare_del(e_config->language);
-        e_config->language = NULL;
-        if ((cfdata->cur_language) && (cfdata->cur_language[0]))
-          e_config->language = eina_stringshare_add(cfdata->cur_language);
-        e_intl_language_set(e_config->language);
-        _lc_check();
+        if (cfdata->desklock)
+          {
+             if (e_config->desklock_language) eina_stringshare_del(e_config->desklock_language);
+             e_config->desklock_language = NULL;
+             if ((cfdata->cur_language) && (cfdata->cur_language[0]))
+               e_config->desklock_language = eina_stringshare_add(cfdata->cur_language);
+          }
+        else
+          {
+             if (e_config->language) eina_stringshare_del(e_config->language);
+             e_config->language = NULL;
+             if ((cfdata->cur_language) && (cfdata->cur_language[0]))
+               e_config->language = eina_stringshare_add(cfdata->cur_language);
+             e_intl_language_set(e_config->language);
+             _lc_check();
+          }
      }
 
    e_config_save_queue();
index 72b4e1b..f8b48fb 100644 (file)
@@ -4,6 +4,7 @@
 #define E_INT_CONFIG_INTL_H
 
 E_Config_Dialog *e_int_config_intl(E_Container *con, const char *params __UNUSED__);
+E_Config_Dialog *e_int_config_desklock_intl(E_Container *con, const char *params __UNUSED__);
 
 #endif
 #endif
index f748ab2..5216758 100644 (file)
@@ -20,6 +20,10 @@ e_modapi_init(E_Module *m)
                                  _("Language Settings"), NULL,
                                  "preferences-desktop-locale",
                                  e_int_config_intl);
+   e_configure_registry_item_add("language/desklock_language_settings", 10,
+                                 _("Desklock Language Settings"), NULL,
+                                 "preferences-desktop-locale",
+                                 e_int_config_desklock_intl);
    e_configure_registry_item_add("language/input_method_settings", 20,
                                  _("Input Method Settings"), NULL,
                                  "preferences-imc", e_int_config_imc);
@@ -37,7 +41,10 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
      e_object_del(E_OBJECT(cfd));
    while ((cfd = e_config_dialog_get("E", "language/language_settings")))
      e_object_del(E_OBJECT(cfd));
+   while ((cfd = e_config_dialog_get("E", "language/desklock_language_settings")))
+     e_object_del(E_OBJECT(cfd));
    e_configure_registry_item_del("language/input_method_settings");
+   e_configure_registry_item_del("language/desklock_language_settings");
    e_configure_registry_item_del("language/language_settings");
    e_configure_registry_category_del("language");
    conf_module = NULL;