Mercurial > emacs
comparison src/gtkutil.c @ 83542:2d56e13fd23d
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-413
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-414
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-415
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-416
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-417
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-418
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-419
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-420
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-421
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-422
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-423
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-424
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-425
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-426
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-427
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-428
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-429
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-430
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-431
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-432
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-433
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-434
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-435
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-436
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-437
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-438
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-439
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-440
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-441
lisp/url/url-methods.el: Fix format error when http_proxy is empty string
* emacs@sv.gnu.org/emacs--devo--0--patch-442
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-443
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-444
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-445
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-446
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-447
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-448
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-449
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-450
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-451
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-452
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-453
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-454
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-455
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-456
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-457
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-458
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-459
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-460
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-461
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-462
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-463
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-464
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-465
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-466
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-467
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-468
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-469
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-470
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-471
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-472
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-473
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-128
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-129
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-130
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-131
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-132
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-133
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-134
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-135
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-136
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-137
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-138
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-139
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-140
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-141
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-142
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-143
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-144
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-145
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-146
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-147
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-148
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-149
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-582
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sat, 14 Oct 2006 17:36:28 +0000 |
parents | c19f348befac dcaff8f63a2b |
children | 58cf725f5330 |
comparison
equal
deleted
inserted
replaced
83541:694bbb62a75d | 83542:2d56e13fd23d |
---|---|
129 xg_display_close (Display *dpy) | 129 xg_display_close (Display *dpy) |
130 { | 130 { |
131 #ifdef HAVE_GTK_MULTIDISPLAY | 131 #ifdef HAVE_GTK_MULTIDISPLAY |
132 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpy); | 132 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpy); |
133 | 133 |
134 /* GTK 2.2 has a bug that makes gdk_display_close crash (bug | |
135 http://bugzilla.gnome.org/show_bug.cgi?id=85715). This way | |
136 we can continue running, but there will be memory leaks. */ | |
137 | |
138 #if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4 | |
139 | |
140 /* If this is the default display, we must change it before calling | 134 /* If this is the default display, we must change it before calling |
141 dispose, otherwise it will crash. */ | 135 dispose, otherwise it will crash on some Gtk+ versions. */ |
142 if (gdk_display_get_default () == gdpy) | 136 if (gdk_display_get_default () == gdpy) |
143 { | 137 { |
144 struct x_display_info *dpyinfo; | 138 struct x_display_info *dpyinfo; |
145 Display *new_dpy = 0; | 139 Display *new_dpy = 0; |
146 GdkDisplay *gdpy_new; | 140 GdkDisplay *gdpy_new; |
158 gdpy_new = gdk_x11_lookup_xdisplay (new_dpy); | 152 gdpy_new = gdk_x11_lookup_xdisplay (new_dpy); |
159 gdk_display_manager_set_default_display (gdk_display_manager_get (), | 153 gdk_display_manager_set_default_display (gdk_display_manager_get (), |
160 gdpy_new); | 154 gdpy_new); |
161 } | 155 } |
162 | 156 |
157 /* GTK 2.2-2.8 has a bug that makes gdk_display_close crash (bug | |
158 http://bugzilla.gnome.org/show_bug.cgi?id=85715). This way | |
159 we can continue running, but there will be memory leaks. */ | |
160 | |
161 #if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 10 | |
163 g_object_run_dispose (G_OBJECT (gdpy)); | 162 g_object_run_dispose (G_OBJECT (gdpy)); |
164 | |
165 #else | 163 #else |
166 /* I hope this will be fixed in GTK 2.4. It is what bug 85715 says. */ | 164 /* This seems to be fixed in GTK 2.10. */ |
167 gdk_display_close (gdpy); | 165 gdk_display_close (gdpy); |
168 #endif | 166 #endif |
169 #endif /* HAVE_GTK_MULTIDISPLAY */ | 167 #endif /* HAVE_GTK_MULTIDISPLAY */ |
170 } | 168 } |
171 | 169 |
507 get_utf8_string (str) | 505 get_utf8_string (str) |
508 char *str; | 506 char *str; |
509 { | 507 { |
510 char *utf8_str = str; | 508 char *utf8_str = str; |
511 | 509 |
510 if (!str) return NULL; | |
511 | |
512 /* If not UTF-8, try current locale. */ | 512 /* If not UTF-8, try current locale. */ |
513 if (str && !g_utf8_validate (str, -1, NULL)) | 513 if (!g_utf8_validate (str, -1, NULL)) |
514 utf8_str = g_locale_to_utf8 (str, -1, 0, 0, 0); | 514 utf8_str = g_locale_to_utf8 (str, -1, 0, 0, 0); |
515 | 515 |
516 if (!utf8_str) | |
517 { | |
518 /* Probably some control characters in str. Escape them. */ | |
519 size_t nr_bad = 0; | |
520 gsize bytes_read; | |
521 gsize bytes_written; | |
522 unsigned char *p = (unsigned char *)str; | |
523 char *cp, *up; | |
524 GError *error = NULL; | |
525 | |
526 while (! (cp = g_locale_to_utf8 (p, -1, &bytes_read, | |
527 &bytes_written, &error)) | |
528 && error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE) | |
529 { | |
530 ++nr_bad; | |
531 p += bytes_written+1; | |
532 g_error_free (error); | |
533 error = NULL; | |
534 } | |
535 | |
536 if (error) | |
537 { | |
538 g_error_free (error); | |
539 error = NULL; | |
540 } | |
541 if (cp) g_free (cp); | |
542 | |
543 up = utf8_str = xmalloc (strlen (str) + nr_bad * 4 + 1); | |
544 p = str; | |
545 | |
546 while (! (cp = g_locale_to_utf8 (p, -1, &bytes_read, | |
547 &bytes_written, &error)) | |
548 && error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE) | |
549 { | |
550 strncpy (up, p, bytes_written); | |
551 sprintf (up + bytes_written, "\\%03o", p[bytes_written]); | |
552 up[bytes_written+4] = '\0'; | |
553 up += bytes_written+4; | |
554 p += bytes_written+1; | |
555 g_error_free (error); | |
556 error = NULL; | |
557 } | |
558 | |
559 if (cp) | |
560 { | |
561 strcat (utf8_str, cp); | |
562 g_free (cp); | |
563 } | |
564 if (error) | |
565 { | |
566 g_error_free (error); | |
567 error = NULL; | |
568 } | |
569 } | |
516 return utf8_str; | 570 return utf8_str; |
517 } | 571 } |
518 | 572 |
519 | 573 |
520 | 574 |
1156 | 1210 |
1157 int | 1211 int |
1158 xg_uses_old_file_dialog () | 1212 xg_uses_old_file_dialog () |
1159 { | 1213 { |
1160 #ifdef HAVE_GTK_FILE_BOTH | 1214 #ifdef HAVE_GTK_FILE_BOTH |
1161 extern int x_use_old_gtk_file_dialog; | 1215 extern int x_gtk_use_old_file_dialog; |
1162 return x_use_old_gtk_file_dialog; | 1216 return x_gtk_use_old_file_dialog; |
1163 #else /* ! HAVE_GTK_FILE_BOTH */ | 1217 #else /* ! HAVE_GTK_FILE_BOTH */ |
1164 | 1218 |
1165 #ifdef HAVE_GTK_FILE_SELECTION_NEW | 1219 #ifdef HAVE_GTK_FILE_SELECTION_NEW |
1166 return 1; | 1220 return 1; |
1167 #else | 1221 #else |
1294 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); | 1348 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); |
1295 GtkFileChooserAction action = (mustmatch_p ? | 1349 GtkFileChooserAction action = (mustmatch_p ? |
1296 GTK_FILE_CHOOSER_ACTION_OPEN : | 1350 GTK_FILE_CHOOSER_ACTION_OPEN : |
1297 GTK_FILE_CHOOSER_ACTION_SAVE); | 1351 GTK_FILE_CHOOSER_ACTION_SAVE); |
1298 extern int x_gtk_show_hidden_files; | 1352 extern int x_gtk_show_hidden_files; |
1353 extern int x_gtk_file_dialog_help_text; | |
1354 | |
1299 | 1355 |
1300 if (only_dir_p) | 1356 if (only_dir_p) |
1301 action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; | 1357 action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; |
1302 | 1358 |
1303 filewin = gtk_file_chooser_dialog_new (prompt, gwin, action, | 1359 filewin = gtk_file_chooser_dialog_new (prompt, gwin, action, |
1321 g_signal_connect (G_OBJECT (wtoggle), "clicked", | 1377 g_signal_connect (G_OBJECT (wtoggle), "clicked", |
1322 G_CALLBACK (xg_toggle_visibility_cb), filewin); | 1378 G_CALLBACK (xg_toggle_visibility_cb), filewin); |
1323 g_signal_connect (G_OBJECT (filewin), "notify", | 1379 g_signal_connect (G_OBJECT (filewin), "notify", |
1324 G_CALLBACK (xg_toggle_notify_cb), wtoggle); | 1380 G_CALLBACK (xg_toggle_notify_cb), wtoggle); |
1325 | 1381 |
1326 message[0] = '\0'; | 1382 if (x_gtk_file_dialog_help_text) |
1327 if (action != GTK_FILE_CHOOSER_ACTION_SAVE) | 1383 { |
1328 strcat (message, "\nType C-l to display a file name text entry box.\n"); | 1384 message[0] = '\0'; |
1329 strcat (message, "\nIf you don't like this file selector, customize " | 1385 /* Gtk+ 2.10 has the file name text entry box integrated in the dialog. |
1330 "use-file-dialog\nto turn it off, or type C-x C-f to visit files."); | 1386 Show the C-l help text only for versions < 2.10. */ |
1331 | 1387 if (gtk_check_version (2, 10, 0) && action != GTK_FILE_CHOOSER_ACTION_SAVE) |
1332 wmessage = gtk_label_new (message); | 1388 strcat (message, "\nType C-l to display a file name text entry box.\n"); |
1333 gtk_widget_show (wmessage); | 1389 strcat (message, "\nIf you don't like this file selector, use the " |
1390 "corresponding\nkey binding or customize " | |
1391 "use-file-dialog to turn it off."); | |
1392 | |
1393 wmessage = gtk_label_new (message); | |
1394 gtk_widget_show (wmessage); | |
1395 } | |
1396 | |
1334 gtk_box_pack_start (GTK_BOX (wbox), wtoggle, FALSE, FALSE, 0); | 1397 gtk_box_pack_start (GTK_BOX (wbox), wtoggle, FALSE, FALSE, 0); |
1335 gtk_box_pack_start (GTK_BOX (wbox), wmessage, FALSE, FALSE, 0); | 1398 if (x_gtk_file_dialog_help_text) |
1399 gtk_box_pack_start (GTK_BOX (wbox), wmessage, FALSE, FALSE, 0); | |
1336 gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (filewin), wbox); | 1400 gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (filewin), wbox); |
1337 | 1401 |
1338 if (default_filename) | 1402 if (default_filename) |
1339 { | 1403 { |
1340 Lisp_Object file; | 1404 Lisp_Object file; |
1341 struct gcpro gcpro1; | 1405 struct gcpro gcpro1; |
1342 GCPRO1 (file); | 1406 GCPRO1 (file); |
1407 char *utf8_filename; | |
1343 | 1408 |
1344 file = build_string (default_filename); | 1409 file = build_string (default_filename); |
1345 | 1410 |
1346 /* File chooser does not understand ~/... in the file name. It must be | 1411 /* File chooser does not understand ~/... in the file name. It must be |
1347 an absolute name starting with /. */ | 1412 an absolute name starting with /. */ |
1348 if (default_filename[0] != '/') | 1413 if (default_filename[0] != '/') |
1349 file = Fexpand_file_name (file, Qnil); | 1414 file = Fexpand_file_name (file, Qnil); |
1350 | 1415 |
1351 default_filename = SSDATA (file); | 1416 utf8_filename = SSDATA (ENCODE_UTF_8 (file)); |
1352 if (Ffile_directory_p (file)) | 1417 if (! NILP (Ffile_directory_p (file))) |
1353 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filewin), | 1418 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filewin), |
1354 default_filename); | 1419 utf8_filename); |
1355 else | 1420 else |
1356 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filewin), | 1421 { |
1357 default_filename); | 1422 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filewin), |
1423 utf8_filename); | |
1424 if (action == GTK_FILE_CHOOSER_ACTION_SAVE) | |
1425 { | |
1426 char *cp = strrchr (utf8_filename, '/'); | |
1427 if (cp) ++cp; | |
1428 else cp = utf8_filename; | |
1429 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filewin), cp); | |
1430 } | |
1431 } | |
1358 | 1432 |
1359 UNGCPRO; | 1433 UNGCPRO; |
1360 } | 1434 } |
1361 | 1435 |
1362 *func = xg_get_file_name_from_chooser; | 1436 *func = xg_get_file_name_from_chooser; |