5 static GList *pixmaps_directories = NULL;
7 /* Use this function to set the directory containing installed pixmaps. */
9 add_pixmap_directory (const gchar *directory)
11 pixmaps_directories = g_list_prepend (pixmaps_directories,
12 g_strdup (directory));
15 /* This is an internally used function to find pixmap files. */
17 find_pixmap_file (const gchar *filename)
21 /* We step through each of the pixmaps directory to find it. */
22 elem = pixmaps_directories;
25 gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
26 G_DIR_SEPARATOR_S, filename);
27 if (g_file_test (pathname, G_FILE_TEST_EXISTS))
35 /* This is an internally used function to create pixmaps. */
37 create_pixmap (const gchar *filename)
39 gchar *pathname = NULL;
42 if (!filename || !filename[0])
43 return gtk_image_new ();
45 pathname = find_pixmap_file (filename);
49 g_warning (_("Couldn't find pixmap file: %s"), filename);
50 return gtk_image_new ();
53 pixmap = gtk_image_new_from_file (pathname);
58 /* This is an internally used function to create pixmaps. */
60 create_pixbuf (const gchar *filename)
62 gchar *pathname = NULL;
66 if (!filename || !filename[0])
69 pathname = find_pixmap_file (filename);
73 g_warning (_("Couldn't find pixmap file: %s"), filename);
77 pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
80 fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
81 pathname, error->message);
88 /* This is an internally used function to create animations */
90 create_pixbuf_animation(const gchar *filename)
92 gchar *pathname = NULL;
93 GdkPixbufAnimation *pixbuf;
96 if (!filename || !filename[0])
99 pathname = find_pixmap_file (filename);
102 g_warning (_("Couldn't find pixmap file: %s"), filename);
106 pixbuf = gdk_pixbuf_animation_new_from_file (pathname, &error);
108 fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
109 pathname, error->message);
110 g_error_free (error);
118 /* This is used to set ATK action descriptions. */
120 glade_set_atk_action_description (AtkAction *action,
121 const gchar *action_name,
122 const gchar *description)
126 n_actions = atk_action_get_n_actions (action);
127 for (i = 0; i < n_actions; i++)
129 if (!strcmp (atk_action_get_name (action, i), action_name))
130 atk_action_set_description (action, i, description);
135 static char linphone_lang[256]={0};
137 /*lang has to be read before the config file is parsed...*/
138 const char *linphone_gtk_get_lang(const char *config_file){
139 FILE *f=fopen(config_file,"r");
142 while(fgets(tmp,sizeof(tmp),f)!=NULL){
144 if ((p=strstr(tmp,"lang="))!=NULL){
146 sscanf(p,"%s",linphone_lang);
147 g_message("Found lang %s",linphone_lang);
153 return linphone_lang;
156 void linphone_gtk_set_lang(const char *code){
157 LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core());
159 #if defined(WIN32) || defined(__APPLE__)
160 curlang=getenv("LANG");
162 curlang=getenv("LANGUAGE");
164 if (curlang!=NULL && strncmp(curlang,code,2)==0) {
165 /* do not loose the _territory@encoding part*/
168 lp_config_set_string(cfg,"GtkUi","lang",code);
171 snprintf(tmp,sizeof(tmp),"LANG=%s",code);
174 setenv("LANG",code,1);
176 setenv("LANGUAGE",code,1);
180 const gchar *linphone_gtk_get_ui_config(const char *key, const char *def){
181 LinphoneCore *lc=linphone_gtk_get_core();
183 LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core());
184 return lp_config_get_string(cfg,"GtkUi",key,def);
186 g_error ("Cannot read config, no core created yet.");
191 int linphone_gtk_get_ui_config_int(const char *key, int def){
192 LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core());
193 return lp_config_get_int(cfg,"GtkUi",key,def);
196 void linphone_gtk_set_ui_config_int(const char *key , int val){
197 LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core());
198 lp_config_set_int(cfg,"GtkUi",key,val);
201 void linphone_gtk_set_ui_config(const char *key , const char * val){
202 LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core());
203 lp_config_set_string(cfg,"GtkUi",key,val);
206 static void parse_item(const char *item, const char *window_name, GtkWidget *w, gboolean show){
214 if (strcmp(window_name,tmp)==0){
215 GtkWidget *wd=linphone_gtk_get_widget(w,dot);
217 if (!show) gtk_widget_hide(wd);
218 else gtk_widget_show(wd);
224 void linphone_gtk_visibility_set(const char *hiddens, const char *window_name, GtkWidget *w, gboolean show){
229 for(b=i=hiddens;*i!='\0';++i){
231 len=MIN(i-b,sizeof(item)-1);
235 parse_item(item,window_name,w,show);
238 len=MIN(i-b,sizeof(item)-1);
242 parse_item(item,window_name,w,show);