Commit f5ed8d1e8f0a75e49cfe25800eeff3317bc7cf2c
1 parent
47ebd366
Exists in
master
and in
5 other branches
Implementando dialogo de charset para todas as plataformas
Showing
1 changed file
with
48 additions
and
18 deletions
Show diff stats
src/gtk/dialog.c
... | ... | @@ -309,39 +309,70 @@ |
309 | 309 | |
310 | 310 | } |
311 | 311 | |
312 | - static void add_encoding(GtkWidget *widget, const gchar **attr) | |
312 | + static void add_option_menus(GtkWidget *widget, GtkAction *action, const gchar **encoding) | |
313 | 313 | { |
314 | -// GtkWidget *box; | |
315 | -// GtkWidget *combo; | |
316 | - const gchar **charset = NULL; | |
317 | -// int f; | |
314 | + GtkWidget *box = gtk_hbox_new(FALSE,6); | |
315 | + int f; | |
318 | 316 | |
319 | - g_get_charset(attr); | |
317 | +// http://people.gnome.org/~icq/scan-build/report-KvV84s.html | |
318 | + | |
319 | + *encoding = g_object_get_data(G_OBJECT(action),"encoding"); | |
320 | + if(!*encoding) | |
321 | + { | |
322 | + // Add charset options | |
323 | + static const struct _list | |
324 | + { | |
325 | + const gchar *charset; | |
326 | + const gchar *text; | |
327 | + } list[] = | |
328 | + { | |
329 | + // http://en.wikipedia.org/wiki/Character_encoding | |
330 | + { "ISO-8859-1", N_( "Western Europe (ISO 8859-1)" ) }, | |
331 | + | |
332 | + { NULL, NULL } | |
333 | + }; | |
334 | + | |
335 | + GtkWidget * label = gtk_label_new_with_mnemonic (_("C_haracter Coding:")); | |
336 | + const gchar * charset = NULL; | |
337 | + GtkWidget * menu = gtk_combo_box_text_new(); | |
338 | + gchar * text; | |
339 | + int f; | |
340 | + int p = 0; | |
341 | + | |
342 | + g_get_charset(&charset); | |
343 | + *encoding = charset; | |
344 | + | |
345 | + text = g_strdup_printf(_("Current (%s)"),charset); | |
346 | + gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(menu),p,charset,text); | |
347 | + g_free(text); | |
348 | + | |
349 | + gtk_combo_box_set_active(GTK_COMBO_BOX(menu),p++); | |
350 | + | |
351 | + for(f=0;list[f].charset;f++) | |
352 | + { | |
353 | + if(strcasecmp(charset,list[f].charset)) | |
354 | + gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(menu),p++,list[f].charset,gettext(list[f].text)); | |
355 | + } | |
320 | 356 | |
321 | - if(g_get_filename_charsets(&charset)) | |
322 | - return; | |
323 | 357 | |
324 | -#ifdef WIN32 | |
358 | + gtk_label_set_mnemonic_widget(GTK_LABEL(label), menu); | |
325 | 359 | |
326 | - #warning Confirmar necessidade em windows | |
360 | + gtk_box_pack_start(GTK_BOX(box),label,FALSE,FALSE,0); | |
327 | 361 | |
328 | - box = gtk_hbox_new(FALSE,2); | |
329 | - combo = gtk_combo_box_text_new(); | |
362 | + gtk_box_pack_start(GTK_BOX(box),menu,TRUE,TRUE,0); | |
330 | 363 | |
331 | - gtk_box_pack_start(GTK_BOX(box),gtk_label_new(_("Encoding:")),FALSE,FALSE,0); | |
332 | - gtk_box_pack_start(GTK_BOX(box),combo,FALSE,FALSE,0); | |
364 | + } | |
333 | 365 | |
334 | 366 | gtk_widget_show_all(box); |
335 | 367 | gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(widget),box); |
336 | 368 | |
337 | -#endif | |
338 | 369 | } |
339 | 370 | |
340 | 371 | void paste_file_action(GtkAction *action, GtkWidget *widget) |
341 | 372 | { |
342 | 373 | const gchar * user_title = g_object_get_data(G_OBJECT(action),"title"); |
343 | 374 | const gchar * filename = g_object_get_data(G_OBJECT(action),"filename"); |
344 | - const gchar * encattr = g_object_get_data(G_OBJECT(action),"encoding"); | |
375 | + const gchar * encattr; | |
345 | 376 | GtkWidget * dialog; |
346 | 377 | gchar * ptr; |
347 | 378 | |
... | ... | @@ -360,8 +391,7 @@ |
360 | 391 | GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
361 | 392 | NULL ); |
362 | 393 | |
363 | - if(!encattr) | |
364 | - add_encoding(dialog, &encattr); | |
394 | + add_option_menus(dialog, action, &encattr); | |
365 | 395 | |
366 | 396 | ptr = get_string_from_config("load",gtk_action_get_name(action),""); |
367 | 397 | if(*ptr) | ... | ... |