add new tab with language setting.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@560 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
smorlat 2009-07-30 15:19:23 +00:00
parent cfc1ce8c2d
commit 9deef2f0c5
6 changed files with 212 additions and 12 deletions

View file

@ -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.

View file

@ -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.");

View file

@ -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);

View file

@ -16,11 +16,11 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkVBox" id="vbox2">
<widget class="GtkVBox" id="network_tab">
<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>
<child>
<widget class="GtkFrame" id="frame1">
<widget class="GtkFrame" id="transport_frame">
<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="label_xalign">0</property>
@ -112,7 +112,7 @@
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame2">
<widget class="GtkFrame" id="ports_frame">
<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="label_xalign">0</property>
@ -223,7 +223,7 @@
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame6">
<widget class="GtkFrame" id="nat_frame">
<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="label_xalign">0</property>
@ -409,7 +409,7 @@
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox10">
<widget class="GtkVBox" id="multimedia_tab">
<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>
<child>
@ -429,7 +429,7 @@
<property name="n_rows">6</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkHBox" id="hbox19">
<widget class="GtkHBox" id="ring_sound_box">
<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>
<child>
@ -466,7 +466,7 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label37">
<widget class="GtkLabel" id="ring_sound_label">
<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="label" translatable="yes">Ring sound:</property>
@ -663,7 +663,7 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<widget class="GtkLabel" id="video_size_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Prefered video resolution:</property>
</widget>
@ -1508,6 +1508,80 @@ Video codecs</property>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkFrame" id="lang_frame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkComboBox" id="lang_combo">
<property name="visible">True</property>
<property name="items" translatable="yes">C</property>
<signal name="changed" handler="linphone_gtk_lang_changed"/>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="lang_label">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Language&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<child>
<widget class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="stock">gtk-properties</property>
<property name="icon-size">3</property>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="label" translatable="yes">User interface</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">4</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="position">0</property>
@ -1520,22 +1594,46 @@ Video codecs</property>
<property name="layout_style">end</property>
<child>
<widget class="GtkButton" id="button5">
<property name="label" translatable="yes">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">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="use_stock">True</property>
<signal name="clicked" handler="linphone_gtk_parameters_closed"/>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<child>
<widget class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="stock">gtk-apply</property>
<property name="icon-size">4</property>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">Done</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">10</property>
<property name="position">0</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>

View file

@ -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);
}

View file

@ -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){