From aa173d77f5bb9425dd12fa56916b6851cf4a1b67 Mon Sep 17 00:00:00 2001 From: smorlat Date: Mon, 12 Jan 2009 14:44:53 +0000 Subject: [PATCH] gui improvements, lang selection in config file. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@232 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/gtk-glade/linphone.h | 2 ++ linphone/gtk-glade/main.c | 34 +++++++++++-------------- linphone/gtk-glade/main.glade | 5 +++- linphone/gtk-glade/p2pwizard.glade | 4 +-- linphone/gtk-glade/support.c | 40 ++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 22 deletions(-) diff --git a/linphone/gtk-glade/linphone.h b/linphone/gtk-glade/linphone.h index a1afb5190..eeab6cac1 100644 --- a/linphone/gtk-glade/linphone.h +++ b/linphone/gtk-glade/linphone.h @@ -61,3 +61,5 @@ const gchar *linphone_gtk_get_ui_config(const char *key, const char *def); 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); + diff --git a/linphone/gtk-glade/main.c b/linphone/gtk-glade/main.c index 7c868895c..80289eb96 100644 --- a/linphone/gtk-glade/main.c +++ b/linphone/gtk-glade/main.c @@ -333,7 +333,6 @@ static gboolean linphone_gtk_iterate(LinphoneCore *lc){ static void load_uri_history(){ GtkEntry *uribar=GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")); - LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core()); char key[20]; int i; GtkEntryCompletion *gep=gtk_entry_completion_new(); @@ -341,7 +340,7 @@ static void load_uri_history(){ for (i=0;;i++){ const char *uri; snprintf(key,sizeof(key),"uri%i",i); - uri=lp_config_get_string(cfg,"GtkUi",key,NULL); + uri=linphone_gtk_get_ui_config(key,NULL); if (uri!=NULL) { GtkTreeIter iter; gtk_list_store_append(model,&iter); @@ -654,16 +653,6 @@ static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl) static void linphone_gtk_general_state(LinphoneCore *lc, LinphoneGeneralState *gstate){ } -const gchar *linphone_gtk_get_ui_config(const char *key, const char *def){ - LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core()); - return lp_config_get_string(cfg,"GtkUi",key,def); -} - -int linphone_gtk_get_ui_config_int(const char *key, int def){ - LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core()); - return lp_config_get_int(cfg,"GtkUi",key,def); -} - static void icon_popup_menu(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data){ GtkWidget *menu=(GtkWidget*)g_object_get_data(G_OBJECT(status_icon),"menu"); gtk_menu_popup(GTK_MENU(menu),NULL,NULL,gtk_status_icon_position_menu,status_icon,button,activate_time); @@ -892,8 +881,22 @@ void linphone_gtk_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){ int main(int argc, char *argv[]){ void *p; const char *config_file; + const char *lang; + g_thread_init(NULL); gdk_threads_init(); + + config_file=linphone_gtk_get_config_file(); + if (linphone_core_wake_up_possible_already_running_instance(config_file)==0){ + g_warning("Another running instance of linphone has been detected. It has been woken-up."); + g_warning("This instance is going to exit now."); + return 0; + } + + if ((lang=linphone_gtk_get_lang(config_file))!=NULL && lang[0]!='\0'){ + setenv("LANG",lang,1); + } + #ifdef ENABLE_NLS p=bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); if (p==NULL) perror("bindtextdomain failed"); @@ -902,13 +905,6 @@ int main(int argc, char *argv[]){ #else g_message("NLS disabled.\n"); #endif - config_file=linphone_gtk_get_config_file(); - if (linphone_core_wake_up_possible_already_running_instance(config_file)==0){ - g_warning("Another running instance of linphone has been detected. It has been woken-up."); - g_warning("This instance is going to exit now."); - return 0; - } - #ifdef WIN32 gtk_rc_add_default_file("./gtkrc"); #endif diff --git a/linphone/gtk-glade/main.glade b/linphone/gtk-glade/main.glade index 1518ae532..ef3323321 100644 --- a/linphone/gtk-glade/main.glade +++ b/linphone/gtk-glade/main.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -424,6 +424,7 @@ Online users True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 4 4 4 True @@ -722,6 +723,8 @@ Online users + False + False 1 diff --git a/linphone/gtk-glade/p2pwizard.glade b/linphone/gtk-glade/p2pwizard.glade index feca4d495..605d50161 100644 --- a/linphone/gtk-glade/p2pwizard.glade +++ b/linphone/gtk-glade/p2pwizard.glade @@ -1,6 +1,6 @@ - + Creating a FONICS account @@ -11,7 +11,7 @@ True WARNING: experimental feature ! -FONICS stands for Free Overlay Network for Interactive Communication Systems +FONIS stands for Free Overlay Network for Instant SIP. Based on SIP and Peer to Peer technologies, it allows people to find each other through the help of a virtual network. Once you and your friends registered, you'll be able to call each other simply by entering your friend's username in linphone's sip uri box. Read more information about FONICS at http://www.fonics.org diff --git a/linphone/gtk-glade/support.c b/linphone/gtk-glade/support.c index 618216c24..3f3877b4f 100644 --- a/linphone/gtk-glade/support.c +++ b/linphone/gtk-glade/support.c @@ -1,5 +1,6 @@ #include "linphone.h" +#include "lpconfig.h" static GList *pixmaps_directories = NULL; @@ -101,3 +102,42 @@ glade_set_atk_action_description (AtkAction *action, } } + +static char linphone_lang[256]={0}; + +/*lang has to be read before the config file is parsed...*/ +const char *linphone_gtk_get_lang(const char *config_file){ + FILE *f=fopen(config_file,"r"); + if (f){ + char tmp[256]; + while(fgets(tmp,sizeof(tmp),f)!=NULL){ + char *p; + if ((p=strstr(tmp,"lang="))!=NULL){ + p+=5; + sscanf(p,"%s",linphone_lang); + g_message("Found lang %s",linphone_lang); + break; + } + } + } + fclose(f); + return linphone_lang; +} + +const gchar *linphone_gtk_get_ui_config(const char *key, const char *def){ + LinphoneCore *lc=linphone_gtk_get_core(); + if (lc){ + LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core()); + return lp_config_get_string(cfg,"GtkUi",key,def); + }else{ + ms_warning ("Cannot read config, no core created yet."); + return NULL; + } +} + +int linphone_gtk_get_ui_config_int(const char *key, int def){ + LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core()); + return lp_config_get_int(cfg,"GtkUi",key,def); +} + +