diff options
| author | Chong Yidong | 2008-06-10 20:56:15 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-06-10 20:56:15 +0000 |
| commit | 3402c0a6f1ced295fd038dd41d361024da087cfd (patch) | |
| tree | 33149900dd5c8ab2ebc528ffba7d42269459e49d | |
| parent | 85109001126d3adbec3e9b2b7585141f1299d0d6 (diff) | |
| download | emacs-3402c0a6f1ced295fd038dd41d361024da087cfd.tar.gz emacs-3402c0a6f1ced295fd038dd41d361024da087cfd.zip | |
(xg_dialog_response_cb): Rename from xg_file_response_callback.
(pop_down_dialog): Rename from pop_down_file_dialog.
(xg_get_file_name): Callers changed.
(xg_get_font_name): New function.
| -rw-r--r-- | src/gtkutil.c | 75 |
1 files changed, 70 insertions, 5 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index afafee11916..77f0815b95e 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1263,12 +1263,12 @@ xg_uses_old_file_dialog () | |||
| 1263 | } | 1263 | } |
| 1264 | 1264 | ||
| 1265 | 1265 | ||
| 1266 | /* Function that is called when the file dialog pops down. | 1266 | /* Function that is called when the file or font dialogs pop down. |
| 1267 | W is the dialog widget, RESPONSE is the response code. | 1267 | W is the dialog widget, RESPONSE is the response code. |
| 1268 | USER_DATA is what we passed in to g_signal_connect (pointer to int). */ | 1268 | USER_DATA is what we passed in to g_signal_connect (pointer to int). */ |
| 1269 | 1269 | ||
| 1270 | static void | 1270 | static void |
| 1271 | xg_file_response_cb (w, | 1271 | xg_dialog_response_cb (w, |
| 1272 | response, | 1272 | response, |
| 1273 | user_data) | 1273 | user_data) |
| 1274 | GtkDialog *w; | 1274 | GtkDialog *w; |
| @@ -1283,7 +1283,7 @@ xg_file_response_cb (w, | |||
| 1283 | /* Destroy the dialog. This makes it pop down. */ | 1283 | /* Destroy the dialog. This makes it pop down. */ |
| 1284 | 1284 | ||
| 1285 | static Lisp_Object | 1285 | static Lisp_Object |
| 1286 | pop_down_file_dialog (arg) | 1286 | pop_down_dialog (arg) |
| 1287 | Lisp_Object arg; | 1287 | Lisp_Object arg; |
| 1288 | { | 1288 | { |
| 1289 | struct Lisp_Save_Value *p = XSAVE_VALUE (arg); | 1289 | struct Lisp_Save_Value *p = XSAVE_VALUE (arg); |
| @@ -1593,7 +1593,7 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p) | |||
| 1593 | 1593 | ||
| 1594 | g_signal_connect (G_OBJECT (w), | 1594 | g_signal_connect (G_OBJECT (w), |
| 1595 | "response", | 1595 | "response", |
| 1596 | G_CALLBACK (xg_file_response_cb), | 1596 | G_CALLBACK (xg_dialog_response_cb), |
| 1597 | &filesel_done); | 1597 | &filesel_done); |
| 1598 | 1598 | ||
| 1599 | /* Don't destroy the widget if closed by the window manager close button. */ | 1599 | /* Don't destroy the widget if closed by the window manager close button. */ |
| @@ -1601,7 +1601,7 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p) | |||
| 1601 | 1601 | ||
| 1602 | gtk_widget_show (w); | 1602 | gtk_widget_show (w); |
| 1603 | 1603 | ||
| 1604 | record_unwind_protect (pop_down_file_dialog, make_save_value (w, 0)); | 1604 | record_unwind_protect (pop_down_dialog, make_save_value (w, 0)); |
| 1605 | while (! filesel_done) | 1605 | while (! filesel_done) |
| 1606 | { | 1606 | { |
| 1607 | x_menu_wait_for_event (0); | 1607 | x_menu_wait_for_event (0); |
| @@ -1620,6 +1620,71 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p) | |||
| 1620 | return fn; | 1620 | return fn; |
| 1621 | } | 1621 | } |
| 1622 | 1622 | ||
| 1623 | #ifdef HAVE_FREETYPE | ||
| 1624 | /* Pop up a GTK font selector and return the name of the font the user | ||
| 1625 | selects, as a C string. The returned font name follows GTK's own | ||
| 1626 | format: | ||
| 1627 | |||
| 1628 | `FAMILY [VALUE1 VALUE2] SIZE' | ||
| 1629 | |||
| 1630 | This can be parsed using font_parse_fcname in font.c. | ||
| 1631 | DEFAULT_NAME, if non-zero, is the default font name. */ | ||
| 1632 | |||
| 1633 | char * | ||
| 1634 | xg_get_font_name (f, default_name) | ||
| 1635 | FRAME_PTR f; | ||
| 1636 | char *default_name; | ||
| 1637 | { | ||
| 1638 | GtkWidget *w = 0; | ||
| 1639 | int count = SPECPDL_INDEX (); | ||
| 1640 | char *fontname = NULL; | ||
| 1641 | int done = 0; | ||
| 1642 | |||
| 1643 | #if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) | ||
| 1644 | sigblock (sigmask (__SIGRTMIN)); | ||
| 1645 | #endif /* HAVE_GTK_AND_PTHREAD */ | ||
| 1646 | |||
| 1647 | w = gtk_font_selection_dialog_new ("Pick a font"); | ||
| 1648 | if (default_name) | ||
| 1649 | gtk_font_selection_dialog_set_font_name (w, default_name); | ||
| 1650 | |||
| 1651 | xg_set_screen (w, f); | ||
| 1652 | gtk_widget_set_name (w, "emacs-fontdialog"); | ||
| 1653 | gtk_window_set_transient_for (GTK_WINDOW (w), | ||
| 1654 | GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); | ||
| 1655 | gtk_window_set_destroy_with_parent (GTK_WINDOW (w), TRUE); | ||
| 1656 | gtk_window_set_modal (GTK_WINDOW (w), TRUE); | ||
| 1657 | |||
| 1658 | g_signal_connect (G_OBJECT (w), "response", | ||
| 1659 | G_CALLBACK (xg_dialog_response_cb), &done); | ||
| 1660 | |||
| 1661 | /* Don't destroy the widget if closed by the window manager close button. */ | ||
| 1662 | g_signal_connect (G_OBJECT (w), "delete-event", G_CALLBACK (gtk_true), NULL); | ||
| 1663 | |||
| 1664 | gtk_widget_show (w); | ||
| 1665 | |||
| 1666 | record_unwind_protect (pop_down_dialog, make_save_value (w, 0)); | ||
| 1667 | while (!done) | ||
| 1668 | { | ||
| 1669 | x_menu_wait_for_event (0); | ||
| 1670 | gtk_main_iteration (); | ||
| 1671 | } | ||
| 1672 | |||
| 1673 | #if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) | ||
| 1674 | sigunblock (sigmask (__SIGRTMIN)); | ||
| 1675 | #endif | ||
| 1676 | |||
| 1677 | if (done == GTK_RESPONSE_OK) | ||
| 1678 | fontname = gtk_font_selection_dialog_get_font_name | ||
| 1679 | ((GtkFontSelectionDialog *) w); | ||
| 1680 | |||
| 1681 | unbind_to (count, Qnil); | ||
| 1682 | |||
| 1683 | return fontname; | ||
| 1684 | } | ||
| 1685 | #endif /* HAVE_FREETYPE */ | ||
| 1686 | |||
| 1687 | |||
| 1623 | 1688 | ||
| 1624 | /*********************************************************************** | 1689 | /*********************************************************************** |
| 1625 | Menu functions. | 1690 | Menu functions. |