diff --git a/linphone/configure.in b/linphone/configure.in index cdab69b90..ff21474f8 100644 --- a/linphone/configure.in +++ b/linphone/configure.in @@ -67,6 +67,7 @@ dnl Add the languages which your application supports here. PKG_PROG_PKG_CONFIG ALL_LINGUAS="fr it de ja es pl cs nl sv pt_BR hu ru" AC_SUBST(ALL_LINGUAS) +AC_DEFINE_UNQUOTED(LINPHONE_ALL_LANGS, "$ALL_LINGUAS", [All supported languages]) if test "$mingw_found" != "yes" ; then dnl gettext macro does not work properly under mingw. diff --git a/linphone/coreapi/misc.c b/linphone/coreapi/misc.c index 9f3b1b70e..22ed27852 100644 --- a/linphone/coreapi/misc.c +++ b/linphone/coreapi/misc.c @@ -715,9 +715,9 @@ int linphone_core_wake_up_possible_already_running_instance(const char *config_f break; } #ifdef WIN32 - Sleep(10); + Sleep(100); #else - usleep(10000); + usleep(100000); #endif } }else ms_message("sendto() of WAKEUP request failed, nobody to wakeup."); diff --git a/linphone/gtk-glade/linphone.h b/linphone/gtk-glade/linphone.h index 755de2f22..11d2eb6f4 100644 --- a/linphone/gtk-glade/linphone.h +++ b/linphone/gtk-glade/linphone.h @@ -59,6 +59,7 @@ int linphone_gtk_get_ui_config_int(const char *key, int def); void linphone_gtk_open_browser(const char *url); void linphone_gtk_check_for_new_version(void); const char *linphone_gtk_get_lang(const char *config_file); +void linphone_gtk_set_lang(const char *code); SipSetupContext* linphone_gtk_get_default_sip_setup_context(void); void linphone_gtk_show_buddy_lookup_window(SipSetupContext *ctx); void * linphone_gtk_wait(LinphoneCore *lc, void *ctx, LinphoneWaitingState ws, const char *purpose, float progress); diff --git a/linphone/gtk-glade/parameters.glade b/linphone/gtk-glade/parameters.glade index 4e56f8537..56d02a486 100644 --- a/linphone/gtk-glade/parameters.glade +++ b/linphone/gtk-glade/parameters.glade @@ -16,11 +16,11 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -112,7 +112,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -223,7 +223,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -409,7 +409,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -429,7 +429,7 @@ 6 2 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -466,7 +466,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Ring sound: @@ -663,7 +663,7 @@ - + True Prefered video resolution: @@ -1508,6 +1508,80 @@ Video codecs tab + + + True + vertical + + + True + 0 + + + True + 12 + + + True + C + + + + + + + + True + <b>Language</b> + True + + + label_item + + + + + False + 0 + + + + + + + + 4 + + + + + True + + + True + gtk-properties + 3 + + + 0 + + + + + True + User interface + + + 1 + + + + + 4 + False + tab + + 0 @@ -1520,22 +1594,46 @@ Video codecs end - gtk-close True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True + + + True + + + True + gtk-apply + 4 + + + 0 + + + + + True + Done + + + 1 + + + + False False + 10 0 + 5 1 diff --git a/linphone/gtk-glade/propertybox.c b/linphone/gtk-glade/propertybox.c index 5c4774872..90ba7511d 100644 --- a/linphone/gtk-glade/propertybox.c +++ b/linphone/gtk-glade/propertybox.c @@ -611,6 +611,92 @@ void linphone_gtk_edit_proxy(GtkButton *button){ } } +typedef struct _LangCodes{ + const char *code; + const char *name; +}LangCodes; + +static LangCodes supported_langs[]={ + { "C" , N_("English") }, + { "fr" , N_("French") }, + { "sv" , N_("Swedish") }, + { "it" , N_("Italian") }, + { "es" , N_("Spanish") }, + { "pt_BR" , N_("Bresilian") }, + { "pl" , N_("Polish") }, + { "de" , N_("German") }, + { "ru" , N_("Russian") }, + { "ja" , N_("Japanese") }, + { "nl" , N_("Dutch") }, + { "hu" , N_("Hungarian") }, + { "cs" , N_("Czech") }, + { NULL , NULL } +}; + +static const char *lang_get_name(const char *code){ + LangCodes *p=supported_langs; + while(p->code!=NULL){ + if (strcmp(p->code,code)==0) return p->name; + p++; + } + return NULL; +} + +static gboolean lang_equals(const char *l1, const char *l2){ + return ((strncmp(l1,l2,5)==0 || strncmp(l1,l2,2)==0)); +} + +static void linphone_gtk_fill_langs(GtkWidget *pb){ + GtkWidget *combo=linphone_gtk_get_widget(pb,"lang_combo"); + char code[10]; + const char *all_langs="C " LINPHONE_ALL_LANGS; + const char *name; + int i=0,index=0; + int adv; + const char *cur_lang=getenv("LANG"); + int cur_lang_index=-1; + char text[256]={0}; + if (cur_lang==NULL) cur_lang="C"; + /* glade creates a combo box without list model and text renderer, + unless we fill it with a dummy text. + This dummy text needs to be removed first*/ + gtk_combo_box_remove_text(GTK_COMBO_BOX(combo),0); + while(sscanf(all_langs+i,"%s %n",code,&adv)>=1){ + i+=adv; + name=lang_get_name(code); + snprintf(text,sizeof(text)-1,"%s : %s",code,name!=NULL ? _(name) : code); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo),text); + if (cur_lang_index==-1 && lang_equals(cur_lang,code)) + cur_lang_index=index; + index++; + } + gtk_combo_box_set_active(GTK_COMBO_BOX(combo),cur_lang_index); +} + +void linphone_gtk_lang_changed(GtkComboBox *combo){ + const char *selected=gtk_combo_box_get_active_text(combo); + char code[10]; + const char *cur_lang=getenv("LANG"); + if (selected!=NULL){ + sscanf(selected,"%s",code); + if (cur_lang==NULL) cur_lang="C"; + if (!lang_equals(cur_lang,code)){ + GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(combo))), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + "%s", + (const gchar*)_("You need to restart linphone for the new language selection to take effect.")); + /* Destroy the dialog when the user responds to it (e.g. clicks a button) */ + g_signal_connect_swapped (G_OBJECT (dialog), "response", + G_CALLBACK (gtk_widget_destroy), + G_OBJECT (dialog)); + gtk_widget_show(dialog); + linphone_gtk_set_lang(code); + } + } +} + void linphone_gtk_show_parameters(void){ GtkWidget *pb=linphone_gtk_create_window("parameters"); LinphoneCore *lc=linphone_gtk_get_core(); @@ -688,5 +774,7 @@ void linphone_gtk_show_parameters(void){ linphone_core_get_download_bandwidth(lc)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"upload_bw")), linphone_core_get_upload_bandwidth(lc)); + + linphone_gtk_fill_langs(pb); gtk_widget_show(pb); } diff --git a/linphone/gtk-glade/support.c b/linphone/gtk-glade/support.c index 8463ae829..6ed94c822 100644 --- a/linphone/gtk-glade/support.c +++ b/linphone/gtk-glade/support.c @@ -124,6 +124,18 @@ const char *linphone_gtk_get_lang(const char *config_file){ return linphone_lang; } +void linphone_gtk_set_lang(const char *code){ + LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core()); + lp_config_set_string(cfg,"GtkUi","lang",code); +#ifdef WIN32 + char tmp[128]; + snprintf(tmp,sizeof(tmp),"LANG=%s",code); + _putenv(tmp); +#else + setenv("LANG",code,1); +#endif +} + const gchar *linphone_gtk_get_ui_config(const char *key, const char *def){ LinphoneCore *lc=linphone_gtk_get_core(); if (lc){