Handle language selection.
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Thu, 28 Oct 2010 23:47:58 +0000 (07:47 +0800)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Thu, 28 Oct 2010 23:47:58 +0000 (07:47 +0800)
src/ldm-gtk-builder-greeter.c

index 3c09d0e..0c5a576 100644 (file)
@@ -45,7 +45,6 @@ static GtkWidget* lang_combo;
 static GtkWidget* exit_btn;
 
 static GtkWidget* exit_menu;
-static GtkWidget *lang_menu;
 
 static GOptionEntry option_entries[] =
 {
@@ -63,6 +62,21 @@ static void on_show_prompt(LdmGreeter *greeter, gchar* text, gpointer user_data)
     gtk_widget_grab_focus(login_entry);
 }
 
+static const char* get_lang()
+{
+    GtkTreeIter it;
+    if(gtk_combo_box_get_active_iter(lang_combo, &it))
+    {
+        LdmLanguage* lang;
+        GtkTreeModel* model = gtk_combo_box_get_model(lang_combo);
+        gtk_tree_model_get(model, &it, 1, &lang, -1);
+        if(lang)
+            g_object_unref(lang);
+        return ldm_language_get_code(lang);
+    }
+    return NULL;
+}
+
 static void on_authentication_complete(LdmGreeter *greeter, gpointer user_data)
 {
     if(ldm_greeter_get_is_authenticated(greeter))
@@ -70,6 +84,7 @@ static void on_authentication_complete(LdmGreeter *greeter, gpointer user_data)
         GtkTreeIter it;
         const char* user = ldm_greeter_get_authentication_user(greeter);
         const char* session_name = NULL;
+        const char* language = NULL;
 
         /* get selected session */
         if(gtk_combo_box_get_active_iter(sessions_combo, &it))
@@ -88,7 +103,7 @@ static void on_authentication_complete(LdmGreeter *greeter, gpointer user_data)
             session_name = ldm_greeter_get_default_session(greeter);
 
         /* do login */
-        ldm_greeter_login(greeter, user, session_name);
+        ldm_greeter_login(greeter, user, session_name, get_lang());
     }
     else /* login failed, ask for username again */
     {
@@ -102,7 +117,7 @@ static void on_authentication_complete(LdmGreeter *greeter, gpointer user_data)
 
 static void on_timed_login(LdmGreeter *greeter, const gchar *username, gpointer user_data)
 {
-    ldm_greeter_login (greeter, ldm_greeter_get_timed_login_user(greeter), ldm_greeter_get_default_session(greeter));
+    ldm_greeter_login (greeter, ldm_greeter_get_timed_login_user(greeter), ldm_greeter_get_default_session(greeter), get_lang());
 }
 
 static void on_quit()
@@ -231,6 +246,7 @@ static void load_exit_btn()
         gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
         g_signal_connect_swapped(item, "activate", G_CALLBACK(ldm_greeter_restart), greeter);
     }
+    g_debug("ldm_greeter_get_can_shutdown(greeter) = %d", ldm_greeter_get_can_shutdown(greeter));
     if(ldm_greeter_get_can_shutdown(greeter))
     {
         item = gtk_menu_item_new_with_label(_("Shutdown"));