diff options
| author | Po Lu | 2021-12-02 18:03:51 +0800 |
|---|---|---|
| committer | Po Lu | 2021-12-02 18:03:51 +0800 |
| commit | 7fa11be2fae2b9fa5981e01da05cb618859d77ca (patch) | |
| tree | 2b7f6ff9da8917628887067ef5cf5d1f6fdae8a0 /src | |
| parent | 2f6b519eaeb3be4ee6a912b40a21686be12d4d88 (diff) | |
| download | emacs-7fa11be2fae2b9fa5981e01da05cb618859d77ca.tar.gz emacs-7fa11be2fae2b9fa5981e01da05cb618859d77ca.zip | |
Fix `menu-set-font' on pgtk
* src/pgtkfns.c (Fx_select_font): New function.
(syms_of_pgtkfns): Define new subr.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pgtkfns.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/pgtkfns.c b/src/pgtkfns.c index afcb44f1223..caf1cc65fb7 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c | |||
| @@ -3908,6 +3908,52 @@ If omitted or nil, that stands for the selected frame's display. */) | |||
| 3908 | return build_string (type_name); | 3908 | return build_string (type_name); |
| 3909 | } | 3909 | } |
| 3910 | 3910 | ||
| 3911 | DEFUN ("x-select-font", Fx_select_font, Sx_select_font, 0, 2, 0, | ||
| 3912 | doc: /* Read a font using a GTK dialog and return a font spec. | ||
| 3913 | |||
| 3914 | FRAME is the frame on which to pop up the font chooser. If omitted or | ||
| 3915 | nil, it defaults to the selected frame. */) | ||
| 3916 | (Lisp_Object frame, Lisp_Object ignored) | ||
| 3917 | { | ||
| 3918 | struct frame *f = decode_window_system_frame (frame); | ||
| 3919 | Lisp_Object font; | ||
| 3920 | Lisp_Object font_param; | ||
| 3921 | char *default_name = NULL; | ||
| 3922 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 3923 | |||
| 3924 | if (popup_activated ()) | ||
| 3925 | error ("Trying to use a menu from within a menu-entry"); | ||
| 3926 | else | ||
| 3927 | pgtk_menu_set_in_use (true); | ||
| 3928 | |||
| 3929 | /* Prevent redisplay. */ | ||
| 3930 | specbind (Qinhibit_redisplay, Qt); | ||
| 3931 | record_unwind_protect_void (clean_up_dialog); | ||
| 3932 | |||
| 3933 | block_input (); | ||
| 3934 | |||
| 3935 | XSETFONT (font, FRAME_FONT (f)); | ||
| 3936 | font_param = Ffont_get (font, QCname); | ||
| 3937 | if (STRINGP (font_param)) | ||
| 3938 | default_name = xlispstrdup (font_param); | ||
| 3939 | else | ||
| 3940 | { | ||
| 3941 | font_param = Fframe_parameter (frame, Qfont_parameter); | ||
| 3942 | if (STRINGP (font_param)) | ||
| 3943 | default_name = xlispstrdup (font_param); | ||
| 3944 | } | ||
| 3945 | |||
| 3946 | font = xg_get_font (f, default_name); | ||
| 3947 | xfree (default_name); | ||
| 3948 | |||
| 3949 | unblock_input (); | ||
| 3950 | |||
| 3951 | if (NILP (font)) | ||
| 3952 | quit (); | ||
| 3953 | |||
| 3954 | return unbind_to (count, font); | ||
| 3955 | } | ||
| 3956 | |||
| 3911 | /* ========================================================================== | 3957 | /* ========================================================================== |
| 3912 | 3958 | ||
| 3913 | Lisp interface declaration | 3959 | Lisp interface declaration |
| @@ -4032,6 +4078,7 @@ be used as the image of the icon representing the frame. */); | |||
| 4032 | defsubr (&Spgtk_set_monitor_scale_factor); | 4078 | defsubr (&Spgtk_set_monitor_scale_factor); |
| 4033 | 4079 | ||
| 4034 | defsubr (&Sx_file_dialog); | 4080 | defsubr (&Sx_file_dialog); |
| 4081 | defsubr (&Sx_select_font); | ||
| 4035 | 4082 | ||
| 4036 | as_status = 0; | 4083 | as_status = 0; |
| 4037 | as_script = Qnil; | 4084 | as_script = Qnil; |