annotate src/ui-gtk.c @ 5127:a9c41067dd88 ben-lisp-object

more cleanups, terminology clarification, lots of doc work -------------------- ChangeLog entries follow: -------------------- man/ChangeLog addition: 2010-03-05 Ben Wing <ben@xemacs.org> * internals/internals.texi (Introduction to Allocation): * internals/internals.texi (Integers and Characters): * internals/internals.texi (Allocation from Frob Blocks): * internals/internals.texi (lrecords): * internals/internals.texi (Low-level allocation): Rewrite section on allocation of Lisp objects to reflect the new reality. Remove references to nonexistent XSETINT and XSETCHAR. modules/ChangeLog addition: 2010-03-05 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c (allocate_pgconn): * postgresql/postgresql.c (allocate_pgresult): * postgresql/postgresql.h (struct Lisp_PGconn): * postgresql/postgresql.h (struct Lisp_PGresult): * ldap/eldap.c (allocate_ldap): * ldap/eldap.h (struct Lisp_LDAP): Same changes as in src/ dir. See large log there in ChangeLog, but basically: ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER ../hlo/src/ChangeLog addition: 2010-03-05 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (old_alloc_sized_lcrecord): * alloc.c (very_old_free_lcrecord): * alloc.c (copy_lisp_object): * alloc.c (zero_sized_lisp_object): * alloc.c (zero_nonsized_lisp_object): * alloc.c (lisp_object_storage_size): * alloc.c (free_normal_lisp_object): * alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC): * alloc.c (ALLOC_FROB_BLOCK_LISP_OBJECT): * alloc.c (Fcons): * alloc.c (noseeum_cons): * alloc.c (make_float): * alloc.c (make_bignum): * alloc.c (make_bignum_bg): * alloc.c (make_ratio): * alloc.c (make_ratio_bg): * alloc.c (make_ratio_rt): * alloc.c (make_bigfloat): * alloc.c (make_bigfloat_bf): * alloc.c (size_vector): * alloc.c (make_compiled_function): * alloc.c (Fmake_symbol): * alloc.c (allocate_extent): * alloc.c (allocate_event): * alloc.c (make_key_data): * alloc.c (make_button_data): * alloc.c (make_motion_data): * alloc.c (make_process_data): * alloc.c (make_timeout_data): * alloc.c (make_magic_data): * alloc.c (make_magic_eval_data): * alloc.c (make_eval_data): * alloc.c (make_misc_user_data): * alloc.c (Fmake_marker): * alloc.c (noseeum_make_marker): * alloc.c (size_string_direct_data): * alloc.c (make_uninit_string): * alloc.c (make_string_nocopy): * alloc.c (mark_lcrecord_list): * alloc.c (alloc_managed_lcrecord): * alloc.c (free_managed_lcrecord): * alloc.c (sweep_lcrecords_1): * alloc.c (malloced_storage_size): * buffer.c (allocate_buffer): * buffer.c (compute_buffer_usage): * buffer.c (DEFVAR_BUFFER_LOCAL_1): * buffer.c (nuke_all_buffer_slots): * buffer.c (common_init_complex_vars_of_buffer): * buffer.h (struct buffer_text): * buffer.h (struct buffer): * bytecode.c: * bytecode.c (make_compiled_function_args): * bytecode.c (size_compiled_function_args): * bytecode.h (struct compiled_function_args): * casetab.c (allocate_case_table): * casetab.h (struct Lisp_Case_Table): * charset.h (struct Lisp_Charset): * chartab.c (fill_char_table): * chartab.c (Fmake_char_table): * chartab.c (make_char_table_entry): * chartab.c (copy_char_table_entry): * chartab.c (Fcopy_char_table): * chartab.c (put_char_table): * chartab.h (struct Lisp_Char_Table_Entry): * chartab.h (struct Lisp_Char_Table): * console-gtk-impl.h (struct gtk_device): * console-gtk-impl.h (struct gtk_frame): * console-impl.h (struct console): * console-msw-impl.h (struct Lisp_Devmode): * console-msw-impl.h (struct mswindows_device): * console-msw-impl.h (struct msprinter_device): * console-msw-impl.h (struct mswindows_frame): * console-msw-impl.h (struct mswindows_dialog_id): * console-stream-impl.h (struct stream_console): * console-stream.c (stream_init_console): * console-tty-impl.h (struct tty_console): * console-tty-impl.h (struct tty_device): * console-tty.c (allocate_tty_console_struct): * console-x-impl.h (struct x_device): * console-x-impl.h (struct x_frame): * console.c (allocate_console): * console.c (nuke_all_console_slots): * console.c (DEFVAR_CONSOLE_LOCAL_1): * console.c (common_init_complex_vars_of_console): * data.c (make_weak_list): * data.c (make_weak_box): * data.c (make_ephemeron): * database.c: * database.c (struct Lisp_Database): * database.c (allocate_database): * database.c (finalize_database): * device-gtk.c (allocate_gtk_device_struct): * device-impl.h (struct device): * device-msw.c: * device-msw.c (mswindows_init_device): * device-msw.c (msprinter_init_device): * device-msw.c (finalize_devmode): * device-msw.c (allocate_devmode): * device-tty.c (allocate_tty_device_struct): * device-x.c (allocate_x_device_struct): * device.c: * device.c (nuke_all_device_slots): * device.c (allocate_device): * dialog-msw.c (handle_question_dialog_box): * elhash.c: * elhash.c (struct Lisp_Hash_Table): * elhash.c (finalize_hash_table): * elhash.c (make_general_lisp_hash_table): * elhash.c (Fcopy_hash_table): * elhash.h (htentry): * emacs.c (main_1): * eval.c: * eval.c (size_multiple_value): * event-stream.c (finalize_command_builder): * event-stream.c (allocate_command_builder): * event-stream.c (free_command_builder): * event-stream.c (event_stream_generate_wakeup): * event-stream.c (event_stream_resignal_wakeup): * event-stream.c (event_stream_disable_wakeup): * event-stream.c (event_stream_wakeup_pending_p): * events.h (struct Lisp_Timeout): * events.h (struct command_builder): * extents-impl.h: * extents-impl.h (struct extent_auxiliary): * extents-impl.h (struct extent_info): * extents-impl.h (set_extent_no_chase_aux_field): * extents-impl.h (set_extent_no_chase_normal_field): * extents.c: * extents.c (gap_array_marker): * extents.c (gap_array): * extents.c (extent_list_marker): * extents.c (extent_list): * extents.c (stack_of_extents): * extents.c (gap_array_make_marker): * extents.c (extent_list_make_marker): * extents.c (allocate_extent_list): * extents.c (SLOT): * extents.c (mark_extent_auxiliary): * extents.c (allocate_extent_auxiliary): * extents.c (attach_extent_auxiliary): * extents.c (size_gap_array): * extents.c (finalize_extent_info): * extents.c (allocate_extent_info): * extents.c (uninit_buffer_extents): * extents.c (allocate_soe): * extents.c (copy_extent): * extents.c (vars_of_extents): * extents.h: * faces.c (allocate_face): * faces.h (struct Lisp_Face): * faces.h (struct face_cachel): * file-coding.c: * file-coding.c (finalize_coding_system): * file-coding.c (sizeof_coding_system): * file-coding.c (Fcopy_coding_system): * file-coding.h (struct Lisp_Coding_System): * file-coding.h (MARKED_SLOT): * fns.c (size_bit_vector): * font-mgr.c: * font-mgr.c (finalize_fc_pattern): * font-mgr.c (print_fc_pattern): * font-mgr.c (Ffc_pattern_p): * font-mgr.c (Ffc_pattern_create): * font-mgr.c (Ffc_name_parse): * font-mgr.c (Ffc_name_unparse): * font-mgr.c (Ffc_pattern_duplicate): * font-mgr.c (Ffc_pattern_add): * font-mgr.c (Ffc_pattern_del): * font-mgr.c (Ffc_pattern_get): * font-mgr.c (fc_config_create_using): * font-mgr.c (fc_strlist_to_lisp_using): * font-mgr.c (fontset_to_list): * font-mgr.c (Ffc_config_p): * font-mgr.c (Ffc_config_up_to_date): * font-mgr.c (Ffc_config_build_fonts): * font-mgr.c (Ffc_config_get_cache): * font-mgr.c (Ffc_config_get_fonts): * font-mgr.c (Ffc_config_set_current): * font-mgr.c (Ffc_config_get_blanks): * font-mgr.c (Ffc_config_get_rescan_interval): * font-mgr.c (Ffc_config_set_rescan_interval): * font-mgr.c (Ffc_config_app_font_add_file): * font-mgr.c (Ffc_config_app_font_add_dir): * font-mgr.c (Ffc_config_app_font_clear): * font-mgr.c (size): * font-mgr.c (Ffc_config_substitute): * font-mgr.c (Ffc_font_render_prepare): * font-mgr.c (Ffc_font_match): * font-mgr.c (Ffc_font_sort): * font-mgr.c (finalize_fc_config): * font-mgr.c (print_fc_config): * font-mgr.h: * font-mgr.h (struct fc_pattern): * font-mgr.h (XFC_PATTERN): * font-mgr.h (struct fc_config): * font-mgr.h (XFC_CONFIG): * frame-gtk.c (allocate_gtk_frame_struct): * frame-impl.h (struct frame): * frame-msw.c (mswindows_init_frame_1): * frame-x.c (allocate_x_frame_struct): * frame.c (nuke_all_frame_slots): * frame.c (allocate_frame_core): * gc.c: * gc.c (GC_CHECK_NOT_FREE): * glyphs.c (finalize_image_instance): * glyphs.c (allocate_image_instance): * glyphs.c (Fcolorize_image_instance): * glyphs.c (allocate_glyph): * glyphs.c (unmap_subwindow_instance_cache_mapper): * glyphs.c (register_ignored_expose): * glyphs.h (struct Lisp_Image_Instance): * glyphs.h (struct Lisp_Glyph): * glyphs.h (struct glyph_cachel): * glyphs.h (struct expose_ignore): * gui.c (allocate_gui_item): * gui.h (struct Lisp_Gui_Item): * keymap.c (struct Lisp_Keymap): * keymap.c (make_keymap): * lisp.h: * lisp.h (struct Lisp_String_Direct_Data): * lisp.h (struct Lisp_String_Indirect_Data): * lisp.h (struct Lisp_Vector): * lisp.h (struct Lisp_Bit_Vector): * lisp.h (DECLARE_INLINE_LISP_BIT_VECTOR): * lisp.h (struct weak_box): * lisp.h (struct ephemeron): * lisp.h (struct weak_list): * lrecord.h: * lrecord.h (struct lrecord_implementation): * lrecord.h (MC_ALLOC_CALL_FINALIZER): * lrecord.h (struct lcrecord_list): * lstream.c (finalize_lstream): * lstream.c (sizeof_lstream): * lstream.c (Lstream_new): * lstream.c (Lstream_delete): * lstream.h (struct lstream): * marker.c: * marker.c (finalize_marker): * marker.c (compute_buffer_marker_usage): * mule-charset.c: * mule-charset.c (make_charset): * mule-charset.c (compute_charset_usage): * objects-impl.h (struct Lisp_Color_Instance): * objects-impl.h (struct Lisp_Font_Instance): * objects-tty-impl.h (struct tty_color_instance_data): * objects-tty-impl.h (struct tty_font_instance_data): * objects-tty.c (tty_initialize_color_instance): * objects-tty.c (tty_initialize_font_instance): * objects.c (finalize_color_instance): * objects.c (Fmake_color_instance): * objects.c (finalize_font_instance): * objects.c (Fmake_font_instance): * objects.c (reinit_vars_of_objects): * opaque.c: * opaque.c (sizeof_opaque): * opaque.c (make_opaque_ptr): * opaque.c (free_opaque_ptr): * opaque.h: * opaque.h (Lisp_Opaque): * opaque.h (Lisp_Opaque_Ptr): * print.c (printing_unreadable_lcrecord): * print.c (external_object_printer): * print.c (debug_p4): * process.c (finalize_process): * process.c (make_process_internal): * procimpl.h (struct Lisp_Process): * rangetab.c (Fmake_range_table): * rangetab.c (Fcopy_range_table): * rangetab.h (struct Lisp_Range_Table): * scrollbar.c: * scrollbar.c (create_scrollbar_instance): * scrollbar.c (compute_scrollbar_instance_usage): * scrollbar.h (struct scrollbar_instance): * specifier.c (finalize_specifier): * specifier.c (sizeof_specifier): * specifier.c (set_specifier_caching): * specifier.h (struct Lisp_Specifier): * specifier.h (struct specifier_caching): * symeval.h: * symeval.h (SYMBOL_VALUE_MAGIC_P): * symeval.h (DEFVAR_SYMVAL_FWD): * symsinit.h: * syntax.c (init_buffer_syntax_cache): * syntax.h (struct syntax_cache): * toolbar.c: * toolbar.c (allocate_toolbar_button): * toolbar.c (update_toolbar_button): * toolbar.h (struct toolbar_button): * tooltalk.c (struct Lisp_Tooltalk_Message): * tooltalk.c (make_tooltalk_message): * tooltalk.c (struct Lisp_Tooltalk_Pattern): * tooltalk.c (make_tooltalk_pattern): * ui-gtk.c: * ui-gtk.c (allocate_ffi_data): * ui-gtk.c (emacs_gtk_object_finalizer): * ui-gtk.c (allocate_emacs_gtk_object_data): * ui-gtk.c (allocate_emacs_gtk_boxed_data): * ui-gtk.h: * window-impl.h (struct window): * window-impl.h (struct window_mirror): * window.c (finalize_window): * window.c (allocate_window): * window.c (new_window_mirror): * window.c (mark_window_as_deleted): * window.c (make_dummy_parent): * window.c (compute_window_mirror_usage): * window.c (compute_window_usage): Overall point of this change and previous ones in this repository: (1) Introduce new, clearer terminology: everything other than int or char is a "record" object, which comes in two types: "normal objects" and "frob-block objects". Fix up all places that referred to frob-block objects as "simple", "basic", etc. (2) Provide an advertised interface for doing operations on Lisp objects, including creating new types, that is clean and consistent in its naming, uses the above-referenced terms and avoids referencing "lrecords", "old lcrecords", etc., which should hide under the surface. (3) Make the size_in_bytes and finalizer methods take a Lisp_Object rather than a void * for consistency with other methods. (4) Separate finalizer method into finalizer and disksaver, so that normal finalize methods don't have to worry about disksaving. Other specifics: (1) Renaming: LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT implementation->basic_p -> implementation->frob_block_p ALLOCATE_FIXED_TYPE_AND_SET_IMPL -> ALLOC_FROB_BLOCK_LISP_OBJECT *FCCONFIG*, wrap_fcconfig -> *FC_CONFIG*, wrap_fc_config *FCPATTERN*, wrap_fcpattern -> *FC_PATTERN*, wrap_fc_pattern (the last two changes make the naming of these macros consistent with the naming of all other macros, since the objects are named fc-config and fc-pattern with a hyphen) (2) Lots of documentation fixes in lrecord.h. (3) Eliminate macros for copying, freeing, zeroing objects, getting their storage size. Instead, new functions: zero_sized_lisp_object() zero_nonsized_lisp_object() lisp_object_storage_size() free_normal_lisp_object() (copy_lisp_object() already exists) LISP_OBJECT_FROB_BLOCK_P() (actually a macro) Eliminated: free_lrecord() zero_lrecord() copy_lrecord() copy_sized_lrecord() old_copy_lcrecord() old_copy_sized_lcrecord() old_zero_lcrecord() old_zero_sized_lcrecord() LISP_OBJECT_STORAGE_SIZE() COPY_SIZED_LISP_OBJECT() COPY_SIZED_LCRECORD() COPY_LISP_OBJECT() ZERO_LISP_OBJECT() FREE_LISP_OBJECT() (4) Catch the remaining places where lrecord stuff was used directly and use the advertised interface, e.g. alloc_sized_lrecord() -> ALLOC_SIZED_LISP_OBJECT(). (5) Make certain statically-declared pseudo-objects (buffer_local_flags, console_local_flags) have their lheader initialized correctly, so things like copy_lisp_object() can work on them. Make extent_auxiliary_defaults a proper heap object Vextent_auxiliary_defaults, and make extent auxiliaries dumpable so that this object can be dumped. allocate_extent_auxiliary() now just creates the object, and attach_extent_auxiliary() creates an extent auxiliary and attaches to an extent, like the old allocate_extent_auxiliary(). (6) Create EXTENT_AUXILIARY_SLOTS macro, similar to the foo-slots.h files but in a macro instead of a file. The purpose is to avoid duplication when iterating over all the slots in an extent auxiliary. Use it. (7) In lstream.c, don't zero out object after allocation because allocation routines take care of this. (8) In marker.c, fix a mistake in computing marker overhead. (9) In print.c, clean up printing_unreadable_lcrecord(), external_object_printer() to avoid lots of ifdef NEW_GC's. (10) Separate toolbar-button allocation into a separate allocate_toolbar_button() function for use in the example code in lrecord.h.
author Ben Wing <ben@xemacs.org>
date Fri, 05 Mar 2010 04:08:17 -0600
parents b5df3737028a
children f965e31a35f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 /* ui-gtk.c
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 ** Description: Creating 'real' UIs from lisp.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5 ** Created by: William M. Perry <wmperry@gnu.org>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 ** Copyright (c) 2000 William M. Perry <wmperry@gnu.org>
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
7 ** Copyright (C) 2010 Ben Wing.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 **
4709
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
9 ** This file is part of XEmacs.
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
10 **
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
11 ** XEmacs is free software; you can redistribute it and/or modify it
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
12 ** under the terms of the GNU General Public License as published by the
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
13 ** Free Software Foundation; either version 2, or (at your option) any
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
14 ** later version.
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
15 **
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
16 ** XEmacs is distributed in the hope that it will be useful, but WITHOUT
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
17 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
18 ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
19 ** for more details.
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
20 **
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
21 ** You should have received a copy of the GNU General Public License
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
22 ** along with XEmacs; see the file COPYING. If not, write to
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
23 ** the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
db7068430402 Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents: 3017
diff changeset
24 ** Boston, MA 02111-1301, USA. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 #include "lisp.h"
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
28
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 #include "buffer.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 #include "device.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 #include "elhash.h"
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
32 #include "events.h"
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
33 #include "faces.h"
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
34 #include "hash.h"
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
35 #include "sysdll.h"
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
36 #include "window.h"
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
37
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
38 #include "console-gtk-impl.h"
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
39 #include "glyphs-gtk.h"
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
40 #include "objects-gtk.h"
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
41 #include "ui-gtk.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43 /* XEmacs specific GTK types */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 #include "gtk-glue.c"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
46 /* Is the fundamental type of 't' the xemacs defined fundamental type 'type'? */
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
47 #define IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t,type) (((GtkType) GTK_FUNDAMENTAL_TYPE(t)) == (type))
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
48
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49 Lisp_Object Qemacs_ffip;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 Lisp_Object Qemacs_gtk_objectp;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 Lisp_Object Qemacs_gtk_boxedp;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 Lisp_Object Qvoid;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 Lisp_Object Venumeration_info;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 static GHashTable *dll_cache;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 Lisp_Object gtk_type_to_lisp (GtkArg *arg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 int lisp_to_gtk_type (Lisp_Object obj, GtkArg *arg);
1883
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
59 int lisp_to_gtk_ret_type (Lisp_Object obj, GtkArg *arg);
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 563
diff changeset
60 #if 0
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 void describe_gtk_arg (GtkArg *arg);
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 563
diff changeset
62 #endif
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 guint symbol_to_enum (Lisp_Object obj, GtkType t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64 static guint lisp_to_flag (Lisp_Object obj, GtkType t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 static Lisp_Object flags_to_list (guint value, GtkType t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 static Lisp_Object enum_to_symbol (guint value, GtkType t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 #define NIL_OR_VOID_P(x) (NILP (x) || EQ (x, Qvoid))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 initialize_dll_cache (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73 if (!dll_cache)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
75 static char text[] = "---XEmacs Internal Handle---";
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
76
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 dll_cache = g_hash_table_new (g_str_hash, g_str_equal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
79 g_hash_table_insert (dll_cache, text, dll_open (Qnil));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 DEFUN ("dll-load", Fdll_load, 1, 1, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84 Load a shared library DLL into XEmacs. No initialization routines are required.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85 This is for loading dependency DLLs into XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 (dll))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 dll_handle h;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 CHECK_STRING (dll);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 initialize_dll_cache ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 /* If the dll name has a directory component in it, then we should
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 expand it. */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
97 if (!NILP (Fstring_match (build_ascstring ("/"), dll, Qnil, Qnil)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 dll = Fexpand_file_name (dll, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100 /* Check if we have already opened it first */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 h = g_hash_table_lookup (dll_cache, XSTRING_DATA (dll));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 if (!h)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 {
1811
3fe1a35b705d [xemacs-hg @ 2003-11-29 22:11:47 by james]
james
parents: 1726
diff changeset
105 h = dll_open (dll);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 if (h)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
109 g_hash_table_insert (dll_cache, qxestrdup (XSTRING_DATA (dll)), h);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
113 signal_error (Qfile_error, "dll_open error", dll_error());
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 return (h ? Qt : Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 /* Gtk object importing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 EXFUN (Fgtk_import_type, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 static struct hash_table *internal_type_hash;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 type_already_imported_p (GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 void *retval = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 /* These are cases that we don't need to import */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 switch (GTK_FUNDAMENTAL_TYPE (t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 case GTK_TYPE_CHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 case GTK_TYPE_UCHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 case GTK_TYPE_BOOL:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 case GTK_TYPE_INT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 case GTK_TYPE_UINT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 case GTK_TYPE_LONG:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 case GTK_TYPE_ULONG:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 case GTK_TYPE_FLOAT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 case GTK_TYPE_DOUBLE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 case GTK_TYPE_STRING:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 case GTK_TYPE_BOXED:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 case GTK_TYPE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 case GTK_TYPE_SIGNAL:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 case GTK_TYPE_ARGS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 case GTK_TYPE_CALLBACK:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 case GTK_TYPE_C_CALLBACK:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 case GTK_TYPE_FOREIGN:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 return (1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 if (!internal_type_hash)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 {
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2500
diff changeset
155 internal_type_hash = make_hash_table (163);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159 if (gethash ((void *)t, internal_type_hash, (const void **)&retval))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161 return (1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 mark_type_as_imported (GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 if (type_already_imported_p (t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 puthash ((void *) t, (void *) 1, internal_type_hash);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 static void import_gtk_type (GtkType t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 import_gtk_object_internal (GtkType the_type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 GtkType original_type = the_type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 int first_time = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 GtkArg *args;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 guint32 *flags;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 guint n_args;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 guint i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 GtkObjectClass *klass;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 GtkSignalQuery *query;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 guint32 *signals;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 guint n_signals;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 /* Register the type before we do anything else with it... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 if (!first_time)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 if (!type_already_imported_p (the_type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 import_gtk_type (the_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 /* We need to mark the object type as imported here or we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 run the risk of SERIOUS recursion when we do automatic
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208 argument type importing. mark_type_as_imported() is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 smart enough to be a noop if we attempt to register
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210 things twice. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 first_time = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212 mark_type_as_imported (the_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 args = gtk_object_query_args(the_type,&flags,&n_args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 /* First get the arguments the object can accept */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 for (i = 0; i < n_args; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220 if ((args[i].type != original_type) && !type_already_imported_p (args[i].type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 import_gtk_type (args[i].type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 g_free(args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 g_free(flags);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
229 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 /* Now lets publish the signals */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 klass = (GtkObjectClass *) gtk_type_class (the_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232 signals = klass->signals;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 n_signals = klass->nsignals;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
234
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 for (i = 0; i < n_signals; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 query = gtk_signal_query (signals[i]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 /* What do we want to do here? */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 g_free (query);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243 the_type = gtk_type_parent(the_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 } while (the_type != GTK_TYPE_INVALID);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 import_gtk_enumeration_internal (GtkType the_type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250 GtkEnumValue *vals = gtk_type_enum_get_values (the_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 Lisp_Object assoc = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253 if (NILP (Venumeration_info))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 Venumeration_info = call2 (intern ("make-hashtable"), make_int (100), Qequal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 while (vals && vals->value_name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 assoc = Fcons (Fcons (intern (vals->value_nick), make_int (vals->value)), assoc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 assoc = Fcons (Fcons (intern (vals->value_name), make_int (vals->value)), assoc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 vals++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 assoc = Fnreverse (assoc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 Fputhash (make_int (the_type), assoc, Venumeration_info);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 import_gtk_type (GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273 if (type_already_imported_p (t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 switch (GTK_FUNDAMENTAL_TYPE (t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 case GTK_TYPE_ENUM:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 case GTK_TYPE_FLAGS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 import_gtk_enumeration_internal (t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 case GTK_TYPE_OBJECT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 import_gtk_object_internal (t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 mark_type_as_imported (t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 /* Foreign function calls */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 static emacs_ffi_data *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 allocate_ffi_data (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 {
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
299 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (emacs_ffi);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
300 emacs_ffi_data *data = XFFI (obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 data->return_type = GTK_TYPE_NONE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 data->n_args = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 data->function_name = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 data->function_ptr = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 data->marshal = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 return (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 960
diff changeset
311 static const struct memory_description ffi_data_description [] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 960
diff changeset
312 { XD_LISP_OBJECT, offsetof (emacs_ffi_data, function_name) },
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 867
diff changeset
313 { XD_END }
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 867
diff changeset
314 };
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 867
diff changeset
315
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 mark_ffi_data (Lisp_Object obj)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 emacs_ffi_data *data = (emacs_ffi_data *) XFFI (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 mark_object (data->function_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 return (Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
326 ffi_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
327 int UNUSED (escapeflag))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 if (print_readably)
4846
a98ca4640147 clean up object print methods
Ben Wing <ben@xemacs.org>
parents: 4709
diff changeset
330 printing_unreadable_lcrecord (obj, 0);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 797
diff changeset
332 write_fmt_string_lisp (printcharfun, "#<ffi %S", 1, XFFI (obj)->function_name);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333 if (XFFI (obj)->n_args)
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 797
diff changeset
334 write_fmt_string (printcharfun, " %d arguments", XFFI (obj)->n_args);
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 797
diff changeset
335 write_fmt_string (printcharfun, " %p>", (void *)XFFI (obj)->function_ptr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4709
diff changeset
338 DEFINE_NODUMP_LISP_OBJECT ("ffi", emacs_ffi,
5124
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
339 mark_ffi_data, ffi_object_printer,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
340 0, 0, 0,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
341 ffi_data_description, emacs_ffi_data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
343 #if defined (__cplusplus)
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
344 #define MANY_ARGS ...
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
345 #else
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
346 #define MANY_ARGS
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
347 #endif
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
348
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
349 typedef void (*pfv)();
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
350 typedef GtkObject * (*__OBJECT_fn) (MANY_ARGS);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
351 typedef gint (*__INT_fn) (MANY_ARGS);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
352 typedef void (*__NONE_fn) (MANY_ARGS);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
353 typedef gchar * (*__STRING_fn) (MANY_ARGS);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
354 typedef gboolean (*__BOOL_fn) (MANY_ARGS);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
355 typedef gfloat (*__FLOAT_fn) (MANY_ARGS);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
356 typedef void * (*__POINTER_fn) (MANY_ARGS);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
357 typedef GList * (*__LIST_fn) (MANY_ARGS);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 /* An auto-generated file of marshalling functions. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
360 #include "emacs-marshals.c"
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
361 #undef MANY_ARGS
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 #define CONVERT_SINGLE_TYPE(var,nam,tp) case GTK_TYPE_##nam: GTK_VALUE_##nam (var) = * (tp *) v; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 #define CONVERT_RETVAL(a,freep) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365 do { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 void *v = GTK_VALUE_POINTER(a); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
367 switch (GTK_FUNDAMENTAL_TYPE (a.type)) \
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
368 { \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 CONVERT_SINGLE_TYPE(a,CHAR,gchar); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 CONVERT_SINGLE_TYPE(a,UCHAR,guchar); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 CONVERT_SINGLE_TYPE(a,BOOL,gboolean); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 CONVERT_SINGLE_TYPE(a,INT,gint); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373 CONVERT_SINGLE_TYPE(a,UINT,guint); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 CONVERT_SINGLE_TYPE(a,LONG,glong); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375 CONVERT_SINGLE_TYPE(a,ULONG,gulong); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 CONVERT_SINGLE_TYPE(a,FLOAT,gfloat); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377 CONVERT_SINGLE_TYPE(a,DOUBLE,gdouble); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 CONVERT_SINGLE_TYPE(a,STRING,gchar *); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
379 CONVERT_SINGLE_TYPE(a,ENUM,gint); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
380 CONVERT_SINGLE_TYPE(a,FLAGS,guint); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
381 CONVERT_SINGLE_TYPE(a,BOXED,void *); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 CONVERT_SINGLE_TYPE(a,POINTER,void *); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 CONVERT_SINGLE_TYPE(a,OBJECT,GtkObject *); \
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
384 default: \
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
385 GTK_VALUE_POINTER (a) = * (void **) v; \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 break; \
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
387 } \
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
388 if (freep) xfree (v); \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389 } while (0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 563
diff changeset
391 static gpointer __allocate_object_storage (GtkType t)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393 size_t s = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394 void *rval = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396 switch (GTK_FUNDAMENTAL_TYPE (t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
398 /* flag types */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 case GTK_TYPE_CHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 s = (sizeof (gchar));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 case GTK_TYPE_UCHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
403 s = (sizeof (guchar));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 case GTK_TYPE_BOOL:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 s = (sizeof (gboolean));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 case GTK_TYPE_INT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 s = (sizeof (gint));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 case GTK_TYPE_UINT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 s = (sizeof (guint));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 case GTK_TYPE_LONG:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 s = (sizeof (glong));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 case GTK_TYPE_ULONG:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 s = (sizeof (gulong));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 case GTK_TYPE_FLOAT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 s = (sizeof (gfloat));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 case GTK_TYPE_DOUBLE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 s = (sizeof (gdouble));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 case GTK_TYPE_STRING:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 s = (sizeof (gchar *));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 case GTK_TYPE_ENUM:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430 case GTK_TYPE_FLAGS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431 s = (sizeof (guint));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 case GTK_TYPE_BOXED:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434 case GTK_TYPE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435 s = (sizeof (void *));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 /* base type of the object system */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439 case GTK_TYPE_OBJECT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440 s = (sizeof (GtkObject *));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 default:
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
444 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_LISTOF))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 s = (sizeof (void *));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 rval = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 if (s)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 rval = xmalloc (s);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 memset (rval, '\0', s);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 563
diff changeset
461 static Lisp_Object type_to_marshaller_type (GtkType t)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 switch (GTK_FUNDAMENTAL_TYPE (t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 case GTK_TYPE_NONE:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
466 return (build_ascstring ("NONE"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 /* flag types */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 case GTK_TYPE_CHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 case GTK_TYPE_UCHAR:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
470 return (build_ascstring ("CHAR"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
471 case GTK_TYPE_BOOL:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
472 return (build_ascstring ("BOOL"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 case GTK_TYPE_ENUM:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 case GTK_TYPE_FLAGS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475 case GTK_TYPE_INT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 case GTK_TYPE_UINT:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
477 return (build_ascstring ("INT"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 case GTK_TYPE_LONG:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 case GTK_TYPE_ULONG:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
480 return (build_ascstring ("LONG"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 case GTK_TYPE_FLOAT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482 case GTK_TYPE_DOUBLE:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
483 return (build_ascstring ("FLOAT"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484 case GTK_TYPE_STRING:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
485 return (build_ascstring ("STRING"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 case GTK_TYPE_BOXED:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 case GTK_TYPE_POINTER:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
488 return (build_ascstring ("POINTER"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489 case GTK_TYPE_OBJECT:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
490 return (build_ascstring ("OBJECT"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491 case GTK_TYPE_CALLBACK:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
492 return (build_ascstring ("CALLBACK"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
494 /* I can't put this in the main switch statement because it is a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
495 new fundamental type that is not fixed at compile time.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
496 *sigh*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
497 */
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
498 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_ARRAY))
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
499 return (build_ascstring ("ARRAY"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
501 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_LISTOF))
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
502 return (build_ascstring ("LIST"));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503 return (Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 struct __dll_mapper_closure {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
508 void * (*func) (dll_handle, const CIbyte *);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
509 Ibyte *obj_name;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
510 void **storage;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 };
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
512
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
513 static void __dll_mapper (gpointer UNUSED (key), gpointer value,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
514 gpointer user_data)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 struct __dll_mapper_closure *closure = (struct __dll_mapper_closure *) user_data;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518 if (*(closure->storage) == NULL)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
519 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
520 /* Need to see if it is in this one */
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
521 *(closure->storage) = closure->func ((dll_handle) value, (CIbyte*) closure->obj_name);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
522 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
523 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
524
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
525 DEFUN ("gtk-import-variable-internal", Fgtk_import_variable_internal, 2, 2, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
526 Import a variable into the XEmacs namespace.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528 (type, name))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
529 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
530 void *var = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 GtkArg arg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533 if (SYMBOLP (type)) type = Fsymbol_name (type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535 CHECK_STRING (type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
536 CHECK_STRING (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538 initialize_dll_cache ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539 xemacs_init_gtk_classes ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541 arg.type = gtk_type_from_name ((char *) XSTRING_DATA (type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543 if (arg.type == GTK_TYPE_INVALID)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
545 sferror ("Unknown type", type);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
546 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
547
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548 /* Need to look thru the already-loaded dlls */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
549 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
550 struct __dll_mapper_closure closure;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
552 closure.func = dll_variable;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
553 closure.obj_name = XSTRING_DATA (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
554 closure.storage = &var;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
555
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
556 g_hash_table_foreach (dll_cache, __dll_mapper, &closure);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
559 if (!var)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
561 gui_error ("Could not locate variable", name);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
562 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
563
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
564 GTK_VALUE_POINTER(arg) = var;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565 CONVERT_RETVAL (arg, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566 return (gtk_type_to_lisp (&arg));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
567 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
568
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
569 DEFUN ("gtk-import-function-internal", Fgtk_import_function_internal, 2, 3, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570 Import a function into the XEmacs namespace.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
571 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
572 (rettype, name, args))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
573 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574 Lisp_Object rval = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575 Lisp_Object marshaller = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576 emacs_ffi_data *data = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577 gint n_args = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579 dll_handle h = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581 ffi_marshalling_function marshaller_func = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582 ffi_actual_function name_func = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584 CHECK_SYMBOL (rettype);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585 CHECK_STRING (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586 CHECK_LIST (args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
587
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
588 initialize_dll_cache ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 xemacs_init_gtk_classes ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591 /* Need to look thru the already-loaded dlls */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 struct __dll_mapper_closure closure;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595 closure.func = dll_function;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596 closure.obj_name = XSTRING_DATA (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 closure.storage = (void **) &name_func;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
598
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
599 g_hash_table_foreach (dll_cache, __dll_mapper, &closure);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
600 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
601
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
602 if (!name_func)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
603 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
604 gui_error ("Could not locate function", name);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
605 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
606
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
607 data = allocate_ffi_data ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
608
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
609 if (NILP (rettype))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
610 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
611 rettype = Qvoid;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
612 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
613
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
614 if (!NILP (args))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
615 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
616 Lisp_Object value = args;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
617 Lisp_Object type = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
618
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
619 EXTERNAL_LIST_LOOP_2 (elt, value)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
620 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
621 GtkType the_type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
622 Lisp_Object marshaller_type = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
623
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
624 CHECK_SYMBOL (elt);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
625
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
626 type = Fsymbol_name (elt);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
627
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
628 the_type = gtk_type_from_name ((char *) XSTRING_DATA (type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
629
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
630 if (the_type == GTK_TYPE_INVALID)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
631 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
632 invalid_argument ("Unknown argument type", type);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
633 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
634
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
635 /* All things must be reduced to their basest form... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
636 import_gtk_type (the_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
637 data->args[n_args] = the_type; /* GTK_FUNDAMENTAL_TYPE (the_type); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
638
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
639 /* Now lets build up another chunk of our marshaller function name */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
640 marshaller_type = type_to_marshaller_type (data->args[n_args]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
641
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
642 if (NILP (marshaller_type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
643 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
644 invalid_argument ("Do not know how to marshal", type);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
645 }
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
646 marshaller = concat3 (marshaller, build_ascstring ("_"), marshaller_type);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
647 n_args++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
648 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
649 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
650 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
651 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
652 marshaller = concat3 (marshaller, build_ascstring ("_"), type_to_marshaller_type (GTK_TYPE_NONE));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
653 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
654
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
655 rettype = Fsymbol_name (rettype);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
656 data->return_type = gtk_type_from_name ((char *) XSTRING_DATA (rettype));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
657
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
658 if (data->return_type == GTK_TYPE_INVALID)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
659 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
660 invalid_argument ("Unknown return type", rettype);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
661 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
662
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
663 import_gtk_type (data->return_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
664
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
665 marshaller = concat3 (type_to_marshaller_type (data->return_type), build_ascstring ("_"), marshaller);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
666 marshaller = concat2 (build_ascstring ("emacs_gtk_marshal_"), marshaller);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
667
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
668 marshaller_func = (ffi_marshalling_function) find_marshaller ((char *) XSTRING_DATA (marshaller));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
669
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
670 if (!marshaller_func)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
671 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
672 gui_error ("Could not locate marshaller function", marshaller);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
673 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
674
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
675 data->n_args = n_args;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
676 data->function_name = name;
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
677 data->function_ptr = (dll_func) name_func;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
678 data->marshal = marshaller_func;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
679
797
776fcda0ee36 [xemacs-hg @ 2002-03-29 13:51:37 by wmperry]
wmperry
parents: 793
diff changeset
680 rval = wrap_emacs_ffi (data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
681 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
682 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
683
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
684 DEFUN ("gtk-call-function", Fgtk_call_function, 1, 2, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
685 Call an external function.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
686 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
687 (func, args))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
688 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
689 GtkArg the_args[MAX_GTK_ARGS];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
690 gint n_args = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
691 Lisp_Object retval = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
692
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
693 CHECK_FFI (func);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
694 CHECK_LIST (args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
695
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
696 n_args = XINT (Flength (args));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
697
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
698 #ifdef XEMACS_IS_SMARTER_THAN_THE_PROGRAMMER
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
699 /* #### I think this is too dangerous to enable by default.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
700 ** #### Genuine program bugs would probably be allowed to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
701 ** #### slip by, and not be very easy to find.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
702 ** #### Bill Perry July 9, 2000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
703 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
704 if (n_args != XFFI(func)->n_args)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
705 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
706 Lisp_Object for_append[3];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
707
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
708 /* Signal an error if they pass in too many arguments */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
709 if (n_args > XFFI(func)->n_args)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
710 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
711 return Fsignal (Qwrong_number_of_arguments,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
712 list2 (func, make_int (n_args)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
713 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
714
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
715 /* If they did not provide enough arguments, be nice and assume
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
716 ** they wanted `nil' in there.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
717 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
718 for_append[0] = args;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
719 for_append[1] = Fmake_list (make_int (XFFI(func)->n_args - n_args), Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
720
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
721 args = Fappend (2, for_append);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
722 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
723 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
724 if (n_args != XFFI(func)->n_args)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
725 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
726 /* Signal an error if they do not pass in the correct # of arguments */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
727 return Fsignal (Qwrong_number_of_arguments,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
728 list2 (func, make_int (n_args)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
729 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
730 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
731
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
732 if (!NILP (args))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
733 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
734 Lisp_Object value = args;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
735
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
736 CHECK_LIST (args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
737 n_args = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
738
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
739 /* First we convert all of the arguments from Lisp to GtkArgs */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
740 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
741 EXTERNAL_LIST_LOOP_2 (elt, value)
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
742 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
743 the_args[n_args].type = XFFI (func)->args[n_args];
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
744
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
745 if (lisp_to_gtk_type (elt, &the_args[n_args]))
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
746 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
747 /* There was some sort of an error */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
748 gui_error ("Error converting arguments", args);
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
749 }
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
750 n_args++;
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
751 }
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
752 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
753 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
754
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
755 /* Now we need to tack on space for a return value, if they have
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
756 asked for one */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
757 if (XFFI (func)->return_type != GTK_TYPE_NONE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
758 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
759 the_args[n_args].type = XFFI (func)->return_type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
760 GTK_VALUE_POINTER (the_args[n_args]) = __allocate_object_storage (the_args[n_args].type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
761 n_args++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
762 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
763
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
764 XFFI (func)->marshal ((ffi_actual_function) (XFFI (func)->function_ptr), the_args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
765
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
766 if (XFFI (func)->return_type != GTK_TYPE_NONE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
767 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
768 CONVERT_RETVAL (the_args[n_args - 1], 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
769 retval = gtk_type_to_lisp (&the_args[n_args - 1]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
770 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
771
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
772 /* Need to free any array or list pointers */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
773 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
774 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
775 for (i = 0; i < n_args; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
776 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
777 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(the_args[i].type, GTK_TYPE_ARRAY))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
778 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
779 g_free (GTK_VALUE_POINTER (the_args[i]));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
780 }
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
781 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(the_args[i].type, GTK_TYPE_LISTOF))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
782 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
783 /* g_list_free (GTK_VALUE_POINTER (the_args[i])); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
784 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
785 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
786 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
787
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
788 return (retval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
789 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
790
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
791
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
792
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
793 /* GtkObject wrapping for Lisp */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
794 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
795 emacs_gtk_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
796 int UNUSED (escapeflag))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
797 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
798 if (print_readably)
4846
a98ca4640147 clean up object print methods
Ben Wing <ben@xemacs.org>
parents: 4709
diff changeset
799 printing_unreadable_lcrecord (obj, 0);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
800
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
801 write_ascstring (printcharfun, "#<GtkObject (");
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
802 if (XGTK_OBJECT (obj)->alive_p)
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
803 write_cistring (printcharfun, gtk_type_name (GTK_OBJECT_TYPE (XGTK_OBJECT (obj)->object)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
804 else
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
805 write_ascstring (printcharfun, "dead");
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 797
diff changeset
806 write_fmt_string (printcharfun, ") %p>", (void *) XGTK_OBJECT (obj)->object);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
807 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
808
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
809 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
810 object_getprop (Lisp_Object obj, Lisp_Object prop)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
811 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
812 Lisp_Object rval = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
813 Lisp_Object prop_name = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
814 GtkArgInfo *info = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
815 char *err;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
816 GtkArg args[2];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
817
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
818 CHECK_SYMBOL (prop); /* Shouldn't need to ever do this, but I'm paranoid */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
819
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
820 prop_name = Fsymbol_name (prop);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
821
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
822 args[0].name = (char *) XSTRING_DATA (prop_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
823
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
824 err = gtk_object_arg_get_info (GTK_OBJECT_TYPE (XGTK_OBJECT (obj)->object),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
825 args[0].name,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
826 &info);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
827
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
828 if (err)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
829 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
830 /* Not a magic symbol, fall back to just looking in our real plist */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
831 g_free (err);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
832
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
833 return (Fplist_get (XGTK_OBJECT (obj)->plist, prop, Qunbound));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
834 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
835
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
836 if (!(info->arg_flags & GTK_ARG_READABLE))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
837 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
838 invalid_operation ("Attempt to get write-only property", prop);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
839 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
840
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
841 gtk_object_getv (XGTK_OBJECT (obj)->object, 1, args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
842
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
843 if (args[0].type == GTK_TYPE_INVALID)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
844 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
845 /* If we can't get the attribute, then let the code in Fget know
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
846 so it can use the default value supplied by the caller */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
847 return (Qunbound);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
848 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
849
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
850 rval = gtk_type_to_lisp (&args[0]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
851
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
852 /* Free up any memory. According to the documentation and Havoc's
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
853 book, if the fundamental type of the returned value is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
854 GTK_TYPE_STRING, GTK_TYPE_BOXED, or GTK_TYPE_ARGS, you are
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
855 responsible for freeing it. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
856 switch (GTK_FUNDAMENTAL_TYPE (args[0].type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
857 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
858 case GTK_TYPE_STRING:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
859 g_free (GTK_VALUE_STRING (args[0]));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
860 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
861 case GTK_TYPE_BOXED:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
862 g_free (GTK_VALUE_BOXED (args[0]));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
863 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
864 case GTK_TYPE_ARGS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
865 g_free (GTK_VALUE_ARGS (args[0]).args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
866 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
867 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
868 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
869
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
870 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
871 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
872
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
873 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
874 object_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
875 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
876 GtkArgInfo *info = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
877 Lisp_Object prop_name = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
878 GtkArg args[2];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
879 char *err = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
880
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
881 prop_name = Fsymbol_name (prop);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
882
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
883 args[0].name = (char *) XSTRING_DATA (prop_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
884
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
885 err = gtk_object_arg_get_info (GTK_OBJECT_TYPE (XGTK_OBJECT (obj)->object),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
886 args[0].name,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
887 &info);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
888
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
889 if (err)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
890 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
891 /* Not a magic symbol, fall back to just storing in our real plist */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
892 g_free (err);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
893
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
894 XGTK_OBJECT (obj)->plist = Fplist_put (XGTK_OBJECT (obj)->plist, prop, value);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
895 return (1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
896 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
897
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
898 args[0].type = info->type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
899
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
900 if (lisp_to_gtk_type (value, &args[0]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
901 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
902 gui_error ("Error converting to GtkType", value);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
903 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
904
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
905 if (!(info->arg_flags & GTK_ARG_WRITABLE))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
906 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
907 invalid_operation ("Attempt to set read-only argument", prop);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
908 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
909
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
910 gtk_object_setv (XGTK_OBJECT (obj)->object, 1, args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
911
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
912 return (1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
913 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
914
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 960
diff changeset
915 static const struct memory_description gtk_object_data_description [] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 960
diff changeset
916 { XD_LISP_OBJECT, offsetof (emacs_gtk_object_data, plist) },
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 867
diff changeset
917 { XD_END }
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 867
diff changeset
918 };
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 867
diff changeset
919
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
920 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
921 mark_gtk_object_data (Lisp_Object obj)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
922 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
923 return (XGTK_OBJECT (obj)->plist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
924 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
925
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
926 static void
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
927 emacs_gtk_object_finalizer (Lisp_Object obj)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
928 {
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
929 emacs_gtk_object_data *data = XEMACS_GTK_OBJECT_DATA (obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
930
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
931 if (data->alive_p)
5124
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
932 gtk_object_unref (data->object);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
933 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
934
5124
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
935 DEFINE_NODUMP_GENERAL_LISP_OBJECT ("GtkObject", emacs_gtk_object,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
936 mark_gtk_object_data,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
937 emacs_gtk_object_printer,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
938 emacs_gtk_object_finalizer,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
939 0, /* equality */
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
940 0, /* hash */
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
941 gtk_object_data_description,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
942 object_getprop,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
943 object_putprop,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
944 0, /* rem prop */
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
945 0, /* plist */
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
946 0, /* disksaver */
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
947 emacs_gtk_object_data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
948
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
949 static emacs_gtk_object_data *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
950 allocate_emacs_gtk_object_data (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
951 {
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
952 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (emacs_gtk_object);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
953 emacs_gtk_object_data *data = XGTK_OBJECT (obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
954
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
955 data->object = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
956 data->alive_p = FALSE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
957 data->plist = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
958
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
959 return (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
960 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
961
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
962 /* We need to keep track of when the object is destroyed so that we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
963 can mark it as dead, otherwise even our print routine (which calls
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
964 GTK_OBJECT_TYPE) will crap out and die. This is also used in the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
965 lisp_to_gtk_type() routine to defend against passing dead objects
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
966 to GTK routines. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
967 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
968 __notice_object_destruction (GtkObject *UNUSED (obj), gpointer user_data)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
969 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
970 ungcpro_popup_callbacks ((GUI_ID) user_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
971 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
972
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
973 Lisp_Object build_gtk_object (GtkObject *obj)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
974 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
975 Lisp_Object retval = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
976 emacs_gtk_object_data *data = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
977 GUI_ID id = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
978
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2054
diff changeset
979 id = (GUI_ID) gtk_object_get_data (obj, GTK_DATA_GUI_IDENTIFIER);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
980
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
981 if (id)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
982 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
983 retval = get_gcpro_popup_callbacks (id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
984 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
985
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
986 if (NILP (retval))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
987 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
988 data = allocate_emacs_gtk_object_data ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
989
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
990 data->object = obj;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
991 data->alive_p = TRUE;
797
776fcda0ee36 [xemacs-hg @ 2002-03-29 13:51:37 by wmperry]
wmperry
parents: 793
diff changeset
992 retval = wrap_emacs_gtk_object (data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
993
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
994 id = new_gui_id ();
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2054
diff changeset
995 gtk_object_set_data (obj, GTK_DATA_GUI_IDENTIFIER, (gpointer) id);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
996 gcpro_popup_callbacks (id, retval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
997 gtk_object_ref (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
998 gtk_signal_connect (obj, "destroy", GTK_SIGNAL_FUNC (__notice_object_destruction), (gpointer)id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
999 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1001 return (retval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1002 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1003
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1004 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1005 __internal_callback_destroy (gpointer data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1006 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1007 Lisp_Object lisp_data;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1008
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
1009 lisp_data = GET_LISP_FROM_VOID (data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1010
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1011 ungcpro_popup_callbacks (XINT (XCAR (lisp_data)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1012 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1013
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1014 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1015 __internal_callback_marshal (GtkObject *obj, gpointer data, guint n_args, GtkArg *args)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1016 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1017 Lisp_Object arg_list = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1018 Lisp_Object callback_fn = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1019 Lisp_Object callback_data = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1020 Lisp_Object newargs[3];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1021 Lisp_Object rval = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1022 struct gcpro gcpro1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1023 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1024
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
1025 callback_fn = GET_LISP_FROM_VOID (data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1026
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1027 /* Nuke the GUI_ID off the front */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1028 callback_fn = XCDR (callback_fn);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1029
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1030 callback_data = XCAR (callback_fn);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1031 callback_fn = XCDR (callback_fn);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1032
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1033 /* The callback data goes at the very end of the argument list */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1034 arg_list = Fcons (callback_data, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1035
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1036 /* Build up the argument list, lisp style */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1037 for (i = n_args - 1; i >= 0; i--)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1038 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1039 arg_list = Fcons (gtk_type_to_lisp (&args[i]), arg_list);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1040 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1041
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1042 /* We always pass the widget as the first parameter at the very least */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1043 arg_list = Fcons (build_gtk_object (obj), arg_list);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1044
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1045 GCPRO1 ((arg_list));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1046
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1047 newargs[0] = callback_fn;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1048 newargs[1] = arg_list;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1049
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1050 rval = Fapply (2, newargs);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1051 signal_fake_event ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1052
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1053 if (args[n_args].type != GTK_TYPE_NONE)
1883
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1054 lisp_to_gtk_ret_type (rval, &args[n_args]);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1055
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1056 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1057 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1058
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1059 DEFUN ("gtk-signal-connect", Fgtk_signal_connect, 3, 6, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1060 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1061 (obj, name, func, cb_data, object_signal, after_p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1062 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1063 int c_after;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1064 int c_object_signal;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1065 GUI_ID id = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1066
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1067 CHECK_GTK_OBJECT (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1068
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1069 if (SYMBOLP (name))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1070 name = Fsymbol_name (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1071
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1072 CHECK_STRING (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1073
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1074 if (NILP (object_signal))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1075 c_object_signal = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1076 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1077 c_object_signal = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1078
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1079 if (NILP (after_p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1080 c_after = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1081 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1082 c_after = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1083
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1084 id = new_gui_id ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1085 func = Fcons (cb_data, func);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1086 func = Fcons (make_int (id), func);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1087
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1088 gcpro_popup_callbacks (id, func);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1089
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1090 gtk_signal_connect_full (XGTK_OBJECT (obj)->object, (char *) XSTRING_DATA (name),
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
1091 NULL, __internal_callback_marshal, STORE_LISP_IN_VOID (func),
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1092 __internal_callback_destroy, c_object_signal, c_after);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1093 return (Qt);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1094 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1095
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1096
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1097 /* GTK_TYPE_BOXED wrapper for Emacs lisp */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 960
diff changeset
1098 static const struct memory_description emacs_gtk_boxed_description [] = {
960
5b372a329b97 [xemacs-hg @ 2002-08-12 08:00:01 by michaels]
michaels
parents: 934
diff changeset
1099 { XD_END }
5b372a329b97 [xemacs-hg @ 2002-08-12 08:00:01 by michaels]
michaels
parents: 934
diff changeset
1100 };
5b372a329b97 [xemacs-hg @ 2002-08-12 08:00:01 by michaels]
michaels
parents: 934
diff changeset
1101
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1102 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
1103 emacs_gtk_boxed_printer (Lisp_Object obj, Lisp_Object printcharfun,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
1104 int UNUSED (escapeflag))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1105 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1106 if (print_readably)
4846
a98ca4640147 clean up object print methods
Ben Wing <ben@xemacs.org>
parents: 4709
diff changeset
1107 printing_unreadable_lcrecord (obj, 0);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1108
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
1109 write_ascstring (printcharfun, "#<GtkBoxed (");
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1110 write_cistring (printcharfun, gtk_type_name (XGTK_BOXED (obj)->object_type));
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 797
diff changeset
1111 write_fmt_string (printcharfun, ") %p>", (void *) XGTK_BOXED (obj)->object);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1112 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1113
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1114 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
1115 emacs_gtk_boxed_equality (Lisp_Object o1, Lisp_Object o2, int UNUSED (depth))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1116 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1117 emacs_gtk_boxed_data *data1 = XGTK_BOXED(o1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1118 emacs_gtk_boxed_data *data2 = XGTK_BOXED(o2);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1119
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1120 return ((data1->object == data2->object) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1121 (data1->object_type == data2->object_type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1122 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1123
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2500
diff changeset
1124 static Hashcode
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2168
diff changeset
1125 emacs_gtk_boxed_hash (Lisp_Object obj, int UNUSED (depth))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1126 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1127 emacs_gtk_boxed_data *data = XGTK_BOXED(obj);
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2500
diff changeset
1128 return (HASH2 ((Hashcode) data->object, data->object_type));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1129 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1130
5124
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1131 DEFINE_NODUMP_LISP_OBJECT ("GtkBoxed", emacs_gtk_boxed,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1132 0, /* marker function */
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1133 emacs_gtk_boxed_printer,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1134 0, /* nuker */
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1135 emacs_gtk_boxed_equality,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1136 emacs_gtk_boxed_hash,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1137 emacs_gtk_boxed_description,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1138 emacs_gtk_boxed_data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1139 /* Currently defined GTK_TYPE_BOXED structures are:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1140
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1141 GtkAccelGroup -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1142 GtkSelectionData -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1143 GtkStyle -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1144 GtkCTreeNode -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1145 GdkColormap -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1146 GdkVisual -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1147 GdkFont -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1148 GdkWindow -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1149 GdkDragContext -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1150 GdkEvent -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1151 GdkColor -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1152 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1153 static emacs_gtk_boxed_data *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1154 allocate_emacs_gtk_boxed_data (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1155 {
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
1156 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (emacs_gtk_boxed);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
1157 emacs_gtk_boxed_data *data = XGTK_BOXED (obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1158
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1159 data->object = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1160 data->object_type = GTK_TYPE_INVALID;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1161
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1162 return (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1163 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1164
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1165 Lisp_Object build_gtk_boxed (void *obj, GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1166 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1167 Lisp_Object retval = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1168 emacs_gtk_boxed_data *data = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1169
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1170 if (GTK_FUNDAMENTAL_TYPE (t) != GTK_TYPE_BOXED)
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1171 ABORT();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1172
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1173 data = allocate_emacs_gtk_boxed_data ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1174 data->object = obj;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1175 data->object_type = t;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1176
797
776fcda0ee36 [xemacs-hg @ 2002-03-29 13:51:37 by wmperry]
wmperry
parents: 793
diff changeset
1177 retval = wrap_emacs_gtk_boxed (data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1178
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1179 return (retval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1180 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1181
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1182
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1183 /* The automatically generated structure access routines */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1184 #include "emacs-widget-accessors.c"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1185
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1186 /* The hand generated funky functions that we can't just import using the FFI */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1187 #include "ui-byhand.c"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1188
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1189 /* The glade support */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1190 #include "glade.c"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1191
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1192
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1193 /* Type manipulation */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1194 DEFUN ("gtk-fundamental-type", Fgtk_fundamental_type, 1, 1, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1195 Load a shared library DLL into XEmacs. No initialization routines are required.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1196 This is for loading dependency DLLs into XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1197 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1198 (type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1199 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1200 GtkType t;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1201
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1202 if (SYMBOLP (type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1203 type = Fsymbol_name (type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1204
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1205 CHECK_STRING (type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1206
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1207 t = gtk_type_from_name ((char *) XSTRING_DATA (type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1208
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1209 if (t == GTK_TYPE_INVALID)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1210 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1211 invalid_argument ("Not a GTK type", type);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1212 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1213 return (make_int (GTK_FUNDAMENTAL_TYPE (t)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1214 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1215
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1216 DEFUN ("gtk-object-type", Fgtk_object_type, 1, 1, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1217 Return the GtkType of OBJECT.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1218 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1219 (object))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1220 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1221 CHECK_GTK_OBJECT (object);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1222 return (make_int (GTK_OBJECT_TYPE (XGTK_OBJECT (object)->object)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1223 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1224
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1225 DEFUN ("gtk-describe-type", Fgtk_describe_type, 1, 1, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1226 Returns a cons of two lists describing the Gtk object TYPE.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1227 The car is a list of all the signals that it will emit.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1228 The cdr is a list of all the magic properties it has.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1229 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1230 (type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1231 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1232 Lisp_Object rval, signals, props;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1233 GtkType t;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1234
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1235 props = signals = rval = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1236
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1237 if (SYMBOLP (type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1238 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1239 type = Fsymbol_name (type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1240 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1241
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1242 if (STRINGP (type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1243 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
1244 t = gtk_type_from_name ((gchar*) XSTRING_DATA (type));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1245 if (t == GTK_TYPE_INVALID)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1246 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1247 invalid_argument ("Not a GTK type", type);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1248 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1249 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1250 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1251 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1252 CHECK_INT (type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1253 t = XINT (type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1254 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1255
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1256 if (GTK_FUNDAMENTAL_TYPE (t) != GTK_TYPE_OBJECT)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1257 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1258 invalid_argument ("Not a GtkObject", type);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1259 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1260
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1261 /* Need to do stupid shit like this to get the args
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1262 ** registered... damn GTK and its lazy loading
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1263 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1264 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1265 GtkArg args[3];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1266 GtkObject *obj = gtk_object_newv (t, 0, args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1267
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1268 gtk_object_destroy(obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1269 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1270
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1271 do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1272 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1273 guint i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1274
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1275 /* Do the magic arguments first */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1276 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1277 GtkArg *args;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1278 guint32 *flags;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1279 guint n_args;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1280
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1281 args = gtk_object_query_args(t,&flags,&n_args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1282
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1283 for (i = 0; i < n_args; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1284 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1285 props = Fcons (Fcons (intern (gtk_type_name(args[i].type)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1286 intern (args[i].name)), props);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1287 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1288
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1289 g_free (args);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1290 g_free (flags);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1291 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1292
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1293 /* Now the signals */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1294 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1295 GtkObjectClass *klass;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1296 GtkSignalQuery *query;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1297 guint32 *gtk_signals;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1298 guint n_signals;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1299
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1300 klass = (GtkObjectClass *) gtk_type_class (t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1301 gtk_signals = klass->signals;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1302 n_signals = klass->nsignals;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1303
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1304 for (i = 0; i < n_signals; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1305 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1306 Lisp_Object params = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1307
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1308 query = gtk_signal_query (gtk_signals[i]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1309
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1310 if (query)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1311 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1312 if (query->nparams)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1313 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1314 int j;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1315
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1316 for (j = query->nparams - 1; j >= 0; j--)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1317 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1318 params = Fcons (intern (gtk_type_name (query->params[j])), params);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1319 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1320 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1321
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1322 signals = Fcons (Fcons (intern (gtk_type_name (query->return_val)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1323 Fcons (intern (query->signal_name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1324 params)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1325 signals);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1326
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1327 g_free (query);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1328 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1329 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1330 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1331 t = gtk_type_parent(t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1332 } while (t != GTK_TYPE_INVALID);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1333
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1334 rval = Fcons (signals, props);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1335
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1336 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1337 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1338
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1339
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1340 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1341 syms_of_ui_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1342 {
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
1343 INIT_LISP_OBJECT (emacs_ffi);
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
1344 INIT_LISP_OBJECT (emacs_gtk_object);
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
1345 INIT_LISP_OBJECT (emacs_gtk_boxed);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1346 DEFSYMBOL_MULTIWORD_PREDICATE (Qemacs_ffip);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1347 DEFSYMBOL_MULTIWORD_PREDICATE (Qemacs_gtk_objectp);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1348 DEFSYMBOL_MULTIWORD_PREDICATE (Qemacs_gtk_boxedp);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1349 DEFSYMBOL (Qvoid);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1350 DEFSUBR (Fdll_load);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1351 DEFSUBR (Fgtk_import_function_internal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1352 DEFSUBR (Fgtk_import_variable_internal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1353 DEFSUBR (Fgtk_signal_connect);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1354 DEFSUBR (Fgtk_call_function);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1355 DEFSUBR (Fgtk_fundamental_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1356 DEFSUBR (Fgtk_object_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1357 DEFSUBR (Fgtk_describe_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1358 syms_of_widget_accessors ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1359 syms_of_ui_byhand ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1360 syms_of_glade ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1361 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1362
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1363 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1364 vars_of_ui_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1365 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1366 Fprovide (intern ("gtk-ui"));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1367 DEFVAR_LISP ("gtk-enumeration-info", &Venumeration_info /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1368 A hashtable holding type information about GTK enumerations and flags.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1369 Do NOT modify unless you really understand ui-gtk.c.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1370 */);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1371
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1372 Venumeration_info = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1373 vars_of_glade ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1374 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1375
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1376
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1377 /* Various utility functions */
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 563
diff changeset
1378 #if 0
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1379 void describe_gtk_arg (GtkArg *arg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1380 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1381 GtkArg a = *arg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1382
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1383 switch (GTK_FUNDAMENTAL_TYPE (a.type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1384 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1385 /* flag types */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1386 case GTK_TYPE_CHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1387 stderr_out ("char: %c\n", GTK_VALUE_CHAR (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1388 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1389 case GTK_TYPE_UCHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1390 stderr_out ("uchar: %c\n", GTK_VALUE_CHAR (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1391 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1392 case GTK_TYPE_BOOL:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1393 stderr_out ("uchar: %s\n", GTK_VALUE_BOOL (a) ? "true" : "false");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1394 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1395 case GTK_TYPE_INT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1396 stderr_out ("int: %d\n", GTK_VALUE_INT (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1397 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1398 case GTK_TYPE_UINT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1399 stderr_out ("uint: %du\n", GTK_VALUE_UINT (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1400 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1401 case GTK_TYPE_LONG:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1402 stderr_out ("long: %ld\n", GTK_VALUE_LONG (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1403 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1404 case GTK_TYPE_ULONG:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1405 stderr_out ("ulong: %lu\n", GTK_VALUE_ULONG (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1406 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1407 case GTK_TYPE_FLOAT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1408 stderr_out ("float: %g\n", GTK_VALUE_FLOAT (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1409 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1410 case GTK_TYPE_DOUBLE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1411 stderr_out ("double: %f\n", GTK_VALUE_DOUBLE (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1412 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1413 case GTK_TYPE_STRING:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1414 stderr_out ("string: %s\n", GTK_VALUE_STRING (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1415 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1416 case GTK_TYPE_ENUM:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1417 case GTK_TYPE_FLAGS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1418 stderr_out ("%s: ", (a.type == GTK_TYPE_ENUM) ? "enum" : "flag");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1419 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1420 GtkEnumValue *vals = gtk_type_enum_get_values (a.type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1421
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1422 while (vals && vals->value_name && (vals->value != GTK_VALUE_ENUM(a))) vals++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1423
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1424 stderr_out ("%s\n", vals ? vals->value_name : "!!! UNKNOWN ENUM VALUE !!!");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1425 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1426 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1427 case GTK_TYPE_BOXED:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1428 stderr_out ("boxed: %p\n", GTK_VALUE_BOXED (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1429 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1430 case GTK_TYPE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1431 stderr_out ("pointer: %p\n", GTK_VALUE_BOXED (a));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1432 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1433
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1434 /* structured types */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1435 case GTK_TYPE_SIGNAL:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1436 case GTK_TYPE_ARGS: /* This we can do as a list of values */
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1437 ABORT();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1438 case GTK_TYPE_CALLBACK:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1439 stderr_out ("callback fn: ...\n");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1440 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1441 case GTK_TYPE_C_CALLBACK:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1442 case GTK_TYPE_FOREIGN:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1443 ABORT();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1444
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1445 /* base type of the object system */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1446 case GTK_TYPE_OBJECT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1447 if (GTK_VALUE_OBJECT (a))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1448 stderr_out ("object: %s\n", gtk_type_name (GTK_OBJECT_TYPE (GTK_VALUE_OBJECT (a))));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1449 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1450 stderr_out ("object: NULL\n");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1451 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1452
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1453 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1454 ABORT();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1455 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1456 }
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 563
diff changeset
1457 #endif
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1458
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1459 Lisp_Object gtk_type_to_lisp (GtkArg *arg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1460 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1461 switch (GTK_FUNDAMENTAL_TYPE (arg->type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1462 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1463 case GTK_TYPE_NONE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1464 return (Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1465 case GTK_TYPE_CHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1466 return (make_char (GTK_VALUE_CHAR (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1467 case GTK_TYPE_UCHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1468 return (make_char (GTK_VALUE_UCHAR (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1469 case GTK_TYPE_BOOL:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1470 return (GTK_VALUE_BOOL (*arg) ? Qt : Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1471 case GTK_TYPE_INT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1472 return (make_int (GTK_VALUE_INT (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1473 case GTK_TYPE_UINT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1474 return (make_int (GTK_VALUE_INT (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1475 case GTK_TYPE_LONG: /* I think these are wrong! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1476 return (make_int (GTK_VALUE_INT (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1477 case GTK_TYPE_ULONG: /* I think these are wrong! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1478 return (make_int (GTK_VALUE_INT (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1479 case GTK_TYPE_FLOAT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1480 return (make_float (GTK_VALUE_FLOAT (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1481 case GTK_TYPE_DOUBLE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1482 return (make_float (GTK_VALUE_DOUBLE (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1483 case GTK_TYPE_STRING:
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1484 return (build_cistring (GTK_VALUE_STRING (*arg)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1485 case GTK_TYPE_FLAGS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1486 return (flags_to_list (GTK_VALUE_FLAGS (*arg), arg->type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1487 case GTK_TYPE_ENUM:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1488 return (enum_to_symbol (GTK_VALUE_ENUM (*arg), arg->type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1489 case GTK_TYPE_BOXED:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1490 if (arg->type == GTK_TYPE_GDK_EVENT)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1491 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1492 return (gdk_event_to_emacs_event((GdkEvent *) GTK_VALUE_BOXED (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1493 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1494
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1495 if (GTK_VALUE_BOXED (*arg))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1496 return (build_gtk_boxed (GTK_VALUE_BOXED (*arg), arg->type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1497 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1498 return (Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1499 case GTK_TYPE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1500 if (GTK_VALUE_POINTER (*arg))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1501 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1502 Lisp_Object rval;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1503
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
1504 rval = GET_LISP_FROM_VOID (GTK_VALUE_POINTER (*arg));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1505 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1506 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1507 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1508 return (Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1509 case GTK_TYPE_OBJECT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1510 if (GTK_VALUE_OBJECT (*arg))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1511 return (build_gtk_object (GTK_VALUE_OBJECT (*arg)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1512 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1513 return (Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1514
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1515 case GTK_TYPE_CALLBACK:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1516 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1517 Lisp_Object rval;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1518
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
1519 rval = GET_LISP_FROM_VOID (GTK_VALUE_CALLBACK (*arg).data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1520
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1521 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1522 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1523
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1524 default:
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
1525 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1526 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1527 if (!GTK_VALUE_POINTER (*arg))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1528 return (Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1529 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1530 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1531 return (xemacs_gtklist_to_list (arg));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1532 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1533 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1534 stderr_out ("Do not know how to convert `%s' to lisp!\n", gtk_type_name (arg->type));
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1535 ABORT ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1536 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1537 /* This is chuck reminding GCC to... SHUT UP! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1538 return (Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1539 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1540
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1541 int lisp_to_gtk_type (Lisp_Object obj, GtkArg *arg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1542 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1543 switch (GTK_FUNDAMENTAL_TYPE (arg->type))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1544 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1545 /* flag types */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1546 case GTK_TYPE_NONE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1547 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1548 case GTK_TYPE_CHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1549 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1550 Ichar c;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1551
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1552 CHECK_CHAR_COERCE_INT (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1553 c = XCHAR (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1554 GTK_VALUE_CHAR (*arg) = c;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1555 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1556 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1557 case GTK_TYPE_UCHAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1558 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1559 Ichar c;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1560
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1561 CHECK_CHAR_COERCE_INT (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1562 c = XCHAR (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1563 GTK_VALUE_CHAR (*arg) = c;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1564 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1565 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1566 case GTK_TYPE_BOOL:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1567 GTK_VALUE_BOOL (*arg) = NILP (obj) ? FALSE : TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1568 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1569 case GTK_TYPE_INT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1570 case GTK_TYPE_UINT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1571 if (NILP (obj) || EQ (Qt, obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1572 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1573 /* For we are a kind mistress and allow sending t/nil for
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1574 1/0 to stupid GTK functions that say they take guint or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1575 gint in the header files, but actually treat it like a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1576 bool. *sigh*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1577 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1578 GTK_VALUE_INT(*arg) = NILP (obj) ? 0 : 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1579 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1580 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1581 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1582 CHECK_INT (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1583 GTK_VALUE_INT(*arg) = XINT (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1584 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1585 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1586 case GTK_TYPE_LONG:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1587 case GTK_TYPE_ULONG:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1588 ABORT();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1589 case GTK_TYPE_FLOAT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1590 CHECK_INT_OR_FLOAT (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1591 GTK_VALUE_FLOAT(*arg) = extract_float (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1592 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1593 case GTK_TYPE_DOUBLE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1594 CHECK_INT_OR_FLOAT (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1595 GTK_VALUE_DOUBLE(*arg) = extract_float (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1596 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1597 case GTK_TYPE_STRING:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1598 if (NILP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1599 GTK_VALUE_STRING (*arg) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1600 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1601 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1602 CHECK_STRING (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1603 GTK_VALUE_STRING (*arg) = (char *) XSTRING_DATA (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1604 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1605 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1606 case GTK_TYPE_ENUM:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1607 case GTK_TYPE_FLAGS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1608 /* Convert a lisp symbol to a GTK enum */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1609 GTK_VALUE_ENUM(*arg) = lisp_to_flag (obj, arg->type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1610 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1611 case GTK_TYPE_BOXED:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1612 if (NILP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1613 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1614 GTK_VALUE_BOXED(*arg) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1615 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1616 else if (GTK_BOXEDP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1617 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1618 GTK_VALUE_BOXED(*arg) = XGTK_BOXED (obj)->object;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1619 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1620 else if (arg->type == GTK_TYPE_STYLE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1621 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1622 obj = Ffind_face (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1623 CHECK_FACE (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1624 GTK_VALUE_BOXED(*arg) = face_to_style (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1625 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1626 else if (arg->type == GTK_TYPE_GDK_GC)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1627 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1628 obj = Ffind_face (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1629 CHECK_FACE (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1630 GTK_VALUE_BOXED(*arg) = face_to_gc (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1631 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1632 else if (arg->type == GTK_TYPE_GDK_WINDOW)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1633 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1634 if (GLYPHP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1635 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1636 Lisp_Object window = Fselected_window (Qnil);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 778
diff changeset
1637 Lisp_Object instance =
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 778
diff changeset
1638 glyph_image_instance (obj, window, ERROR_ME_DEBUG_WARN, 1);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1639 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1640
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1641 switch (XIMAGE_INSTANCE_TYPE (instance))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1642 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1643 case IMAGE_TEXT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1644 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1645 case IMAGE_SUBWINDOW:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1646 case IMAGE_NOTHING:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1647 GTK_VALUE_BOXED(*arg) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1648 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1649
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1650 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1651 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1652 GTK_VALUE_BOXED(*arg) = IMAGE_INSTANCE_GTK_PIXMAP (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1653 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1654 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1655 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1656 else if (GTK_OBJECTP (obj) && GTK_IS_WIDGET (XGTK_OBJECT (obj)->object))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1657 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1658 GTK_VALUE_BOXED(*arg) = GTK_WIDGET (XGTK_OBJECT (obj))->window;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1659 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1660 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1661 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1662 invalid_argument ("Don't know how to convert object to GDK_WINDOW", obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1663 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1664 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1665 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1666 else if (arg->type == GTK_TYPE_GDK_COLOR)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1667 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1668 if (COLOR_SPECIFIERP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1669 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1670 /* If it is a specifier, we just convert it to an
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1671 instance, and let the ifs below handle it.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1672 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1673 obj = Fspecifier_instance (obj, Qnil, Qnil, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1674 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1675
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1676 if (COLOR_INSTANCEP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1677 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1678 /* Easiest one */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1679 GTK_VALUE_BOXED(*arg) = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (obj));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1680 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1681 else if (STRINGP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1682 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1683 invalid_argument ("Please use a color specifier or instance, not a string", obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1684 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1685 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1686 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1687 invalid_argument ("Don't know how to convert to GdkColor", obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1688 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1689 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1690 else if (arg->type == GTK_TYPE_GDK_FONT)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1691 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1692 if (SYMBOLP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1693 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1694 /* If it is a symbol, we treat that as a face name */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1695 obj = Ffind_face (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1696 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1697
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1698 if (FACEP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1699 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1700 /* If it is a face, we just grab the font specifier, and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1701 cascade down until we finally reach a FONT_INSTANCE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1702 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1703 obj = Fget (obj, Qfont, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1704 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1705
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1706 if (FONT_SPECIFIERP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1707 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1708 /* If it is a specifier, we just convert it to an
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1709 instance, and let the ifs below handle it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1710 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1711 obj = Fspecifier_instance (obj, Qnil, Qnil, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1712 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1713
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1714 if (FONT_INSTANCEP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1715 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1716 /* Easiest one */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1717 GTK_VALUE_BOXED(*arg) = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (obj));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1718 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1719 else if (STRINGP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1720 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1721 invalid_argument ("Please use a font specifier or instance, not a string", obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1722 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1723 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1724 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1725 invalid_argument ("Don't know how to convert to GdkColor", obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1726 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1727 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1728 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1729 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1730 /* Unknown type to convert to boxed */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1731 stderr_out ("Don't know how to convert to boxed!\n");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1732 GTK_VALUE_BOXED(*arg) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1733 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1734 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1735
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1736 case GTK_TYPE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1737 if (NILP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1738 GTK_VALUE_POINTER(*arg) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1739 else
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
1740 GTK_VALUE_POINTER(*arg) = STORE_LISP_IN_VOID (obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1741 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1742
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1743 /* structured types */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1744 case GTK_TYPE_SIGNAL:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1745 case GTK_TYPE_ARGS: /* This we can do as a list of values */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1746 case GTK_TYPE_C_CALLBACK:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1747 case GTK_TYPE_FOREIGN:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1748 stderr_out ("Do not know how to convert `%s' from lisp!\n", gtk_type_name (arg->type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1749 return (-1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1750
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1751 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1752 /* #### BILL! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1753 /* This is not used, and does not work with union type */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1754 case GTK_TYPE_CALLBACK:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1755 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1756 GUI_ID id;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1757
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1758 id = new_gui_id ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1759 obj = Fcons (Qnil, obj); /* Empty data */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1760 obj = Fcons (make_int (id), obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1761
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1762 gcpro_popup_callbacks (id, obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1763
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1764 GTK_VALUE_CALLBACK(*arg).marshal = __internal_callback_marshal;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1765 GTK_VALUE_CALLBACK(*arg).data = (gpointer) obj;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1766 GTK_VALUE_CALLBACK(*arg).notify = __internal_callback_destroy;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1767 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1768 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1769 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1770
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1771 /* base type of the object system */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1772 case GTK_TYPE_OBJECT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1773 if (NILP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1774 GTK_VALUE_OBJECT (*arg) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1775 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1776 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1777 CHECK_GTK_OBJECT (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1778 if (XGTK_OBJECT (obj)->alive_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1779 GTK_VALUE_OBJECT (*arg) = XGTK_OBJECT (obj)->object;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1780 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1781 invalid_argument ("Attempting to pass dead object to GTK function", obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1782 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1783 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1784
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1785 default:
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
1786 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_ARRAY))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1787 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1788 if (NILP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1789 GTK_VALUE_POINTER(*arg) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1790 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1791 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1792 xemacs_list_to_array (obj, arg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1793 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1794 }
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
1795 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1796 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1797 if (NILP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1798 GTK_VALUE_POINTER(*arg) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1799 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1800 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1801 xemacs_list_to_gtklist (obj, arg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1802 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1803 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1804 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1805 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1806 stderr_out ("Do not know how to convert `%s' from lisp!\n", gtk_type_name (arg->type));
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1807 ABORT();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1808 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1809 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1810 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1811
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1812 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1813 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1814
1883
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1815 /* Convert lisp types to GTK return types. This is identical to
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1816 lisp_to_gtk_type() except that the macro used to set the value is
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1817 different.
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1818
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1819 ### There should be some way of combining these two functions.
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1820 */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1821 int lisp_to_gtk_ret_type (Lisp_Object obj, GtkArg *arg)
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1822 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1823 switch (GTK_FUNDAMENTAL_TYPE (arg->type))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1824 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1825 /* flag types */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1826 case GTK_TYPE_NONE:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1827 return (0);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1828 case GTK_TYPE_CHAR:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1829 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1830 Ichar c;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1831
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1832 CHECK_CHAR_COERCE_INT (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1833 c = XCHAR (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1834 *(GTK_RETLOC_CHAR (*arg)) = c;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1835 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1836 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1837 case GTK_TYPE_UCHAR:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1838 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1839 Ichar c;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1840
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1841 CHECK_CHAR_COERCE_INT (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1842 c = XCHAR (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1843 *(GTK_RETLOC_CHAR (*arg)) = c;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1844 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1845 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1846 case GTK_TYPE_BOOL:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1847 *(GTK_RETLOC_BOOL (*arg)) = NILP (obj) ? FALSE : TRUE;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1848 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1849 case GTK_TYPE_INT:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1850 case GTK_TYPE_UINT:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1851 if (NILP (obj) || EQ (Qt, obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1852 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1853 /* For we are a kind mistress and allow sending t/nil for
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1854 1/0 to stupid GTK functions that say they take guint or
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1855 gint in the header files, but actually treat it like a
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1856 bool. *sigh*
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1857 */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1858 *(GTK_RETLOC_INT(*arg)) = NILP (obj) ? 0 : 1;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1859 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1860 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1861 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1862 CHECK_INT (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1863 *(GTK_RETLOC_INT(*arg)) = XINT (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1864 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1865 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1866 case GTK_TYPE_LONG:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1867 case GTK_TYPE_ULONG:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1868 ABORT();
1883
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1869 case GTK_TYPE_FLOAT:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1870 CHECK_INT_OR_FLOAT (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1871 *(GTK_RETLOC_FLOAT(*arg)) = extract_float (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1872 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1873 case GTK_TYPE_DOUBLE:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1874 CHECK_INT_OR_FLOAT (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1875 *(GTK_RETLOC_DOUBLE(*arg)) = extract_float (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1876 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1877 case GTK_TYPE_STRING:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1878 if (NILP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1879 *(GTK_RETLOC_STRING (*arg)) = NULL;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1880 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1881 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1882 CHECK_STRING (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1883 *(GTK_RETLOC_STRING (*arg)) = (char *) XSTRING_DATA (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1884 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1885 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1886 case GTK_TYPE_ENUM:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1887 case GTK_TYPE_FLAGS:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1888 /* Convert a lisp symbol to a GTK enum */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1889 *(GTK_RETLOC_ENUM(*arg)) = lisp_to_flag (obj, arg->type);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1890 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1891 case GTK_TYPE_BOXED:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1892 if (NILP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1893 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1894 *(GTK_RETLOC_BOXED(*arg)) = NULL;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1895 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1896 else if (GTK_BOXEDP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1897 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1898 *(GTK_RETLOC_BOXED(*arg)) = XGTK_BOXED (obj)->object;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1899 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1900 else if (arg->type == GTK_TYPE_STYLE)
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1901 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1902 obj = Ffind_face (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1903 CHECK_FACE (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1904 *(GTK_RETLOC_BOXED(*arg)) = face_to_style (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1905 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1906 else if (arg->type == GTK_TYPE_GDK_GC)
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1907 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1908 obj = Ffind_face (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1909 CHECK_FACE (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1910 *(GTK_RETLOC_BOXED(*arg)) = face_to_gc (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1911 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1912 else if (arg->type == GTK_TYPE_GDK_WINDOW)
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1913 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1914 if (GLYPHP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1915 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1916 Lisp_Object window = Fselected_window (Qnil);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1917 Lisp_Object instance =
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1918 glyph_image_instance (obj, window, ERROR_ME_DEBUG_WARN, 1);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1919 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (instance);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1920
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1921 switch (XIMAGE_INSTANCE_TYPE (instance))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1922 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1923 case IMAGE_TEXT:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1924 case IMAGE_POINTER:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1925 case IMAGE_SUBWINDOW:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1926 case IMAGE_NOTHING:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1927 *(GTK_RETLOC_BOXED(*arg)) = NULL;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1928 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1929
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1930 case IMAGE_MONO_PIXMAP:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1931 case IMAGE_COLOR_PIXMAP:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1932 *(GTK_RETLOC_BOXED(*arg)) = IMAGE_INSTANCE_GTK_PIXMAP (p);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1933 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1934 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1935 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1936 else if (GTK_OBJECTP (obj) && GTK_IS_WIDGET (XGTK_OBJECT (obj)->object))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1937 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1938 *(GTK_RETLOC_BOXED(*arg)) = GTK_WIDGET (XGTK_OBJECT (obj))->window;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1939 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1940 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1941 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1942 invalid_argument ("Don't know how to convert object to GDK_WINDOW", obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1943 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1944 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1945 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1946 else if (arg->type == GTK_TYPE_GDK_COLOR)
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1947 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1948 if (COLOR_SPECIFIERP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1949 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1950 /* If it is a specifier, we just convert it to an
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1951 instance, and let the ifs below handle it.
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1952 */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1953 obj = Fspecifier_instance (obj, Qnil, Qnil, Qnil);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1954 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1955
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1956 if (COLOR_INSTANCEP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1957 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1958 /* Easiest one */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1959 *(GTK_RETLOC_BOXED(*arg)) = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (obj));
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1960 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1961 else if (STRINGP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1962 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1963 invalid_argument ("Please use a color specifier or instance, not a string", obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1964 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1965 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1966 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1967 invalid_argument ("Don't know how to convert to GdkColor", obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1968 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1969 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1970 else if (arg->type == GTK_TYPE_GDK_FONT)
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1971 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1972 if (SYMBOLP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1973 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1974 /* If it is a symbol, we treat that as a face name */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1975 obj = Ffind_face (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1976 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1977
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1978 if (FACEP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1979 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1980 /* If it is a face, we just grab the font specifier, and
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1981 cascade down until we finally reach a FONT_INSTANCE
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1982 */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1983 obj = Fget (obj, Qfont, Qnil);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1984 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1985
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1986 if (FONT_SPECIFIERP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1987 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1988 /* If it is a specifier, we just convert it to an
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1989 instance, and let the ifs below handle it
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1990 */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1991 obj = Fspecifier_instance (obj, Qnil, Qnil, Qnil);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1992 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1993
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1994 if (FONT_INSTANCEP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1995 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1996 /* Easiest one */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1997 *(GTK_RETLOC_BOXED(*arg)) = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (obj));
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1998 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
1999 else if (STRINGP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2000 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2001 invalid_argument ("Please use a font specifier or instance, not a string", obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2002 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2003 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2004 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2005 invalid_argument ("Don't know how to convert to GdkColor", obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2006 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2007 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2008 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2009 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2010 /* Unknown type to convert to boxed */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2011 stderr_out ("Don't know how to convert to boxed!\n");
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2012 *(GTK_RETLOC_BOXED(*arg)) = NULL;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2013 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2014 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2015
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2016 case GTK_TYPE_POINTER:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2017 if (NILP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2018 *(GTK_RETLOC_POINTER(*arg)) = NULL;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2019 else
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
2020 *(GTK_RETLOC_POINTER(*arg)) = STORE_LISP_IN_VOID (obj);
1883
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2021 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2022
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2023 /* structured types */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2024 case GTK_TYPE_SIGNAL:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2025 case GTK_TYPE_ARGS: /* This we can do as a list of values */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2026 case GTK_TYPE_C_CALLBACK:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2027 case GTK_TYPE_FOREIGN:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2028 stderr_out ("Do not know how to convert `%s' from lisp!\n", gtk_type_name (arg->type));
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2029 return (-1);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2030
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2031 #if 0
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2032 /* #### BILL! */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2033 /* This is not used, and does not work with union type */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2034 case GTK_TYPE_CALLBACK:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2035 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2036 GUI_ID id;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2037
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2038 id = new_gui_id ();
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2039 obj = Fcons (Qnil, obj); /* Empty data */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2040 obj = Fcons (make_int (id), obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2041
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2042 gcpro_popup_callbacks (id, obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2043
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2044 *(GTK_RETLOC_CALLBACK(*arg)).marshal = __internal_callback_marshal;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2045 *(GTK_RETLOC_CALLBACK(*arg)).data = (gpointer) obj;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2046 *(GTK_RETLOC_CALLBACK(*arg)).notify = __internal_callback_destroy;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2047 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2048 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2049 #endif
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2050
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2051 /* base type of the object system */
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2052 case GTK_TYPE_OBJECT:
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2053 if (NILP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2054 *(GTK_RETLOC_OBJECT (*arg)) = NULL;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2055 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2056 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2057 CHECK_GTK_OBJECT (obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2058 if (XGTK_OBJECT (obj)->alive_p)
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2059 *(GTK_RETLOC_OBJECT (*arg)) = XGTK_OBJECT (obj)->object;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2060 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2061 invalid_argument ("Attempting to pass dead object to GTK function", obj);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2062 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2063 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2064
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2065 default:
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
2066 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_ARRAY))
1883
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2067 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2068 if (NILP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2069 *(GTK_RETLOC_POINTER(*arg)) = NULL;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2070 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2071 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2072 xemacs_list_to_array (obj, arg);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2073 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2074 }
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1883
diff changeset
2075 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
1883
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2076 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2077 if (NILP (obj))
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2078 *(GTK_RETLOC_POINTER(*arg)) = NULL;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2079 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2080 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2081 xemacs_list_to_gtklist (obj, arg);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2082 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2083 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2084 else
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2085 {
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2086 stderr_out ("Do not know how to convert `%s' from lisp!\n", gtk_type_name (arg->type));
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
2087 ABORT();
1883
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2088 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2089 break;
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2090 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2091
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2092 return (0);
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2093 }
c347bc6e2cb3 [xemacs-hg @ 2004-01-27 13:13:42 by stephent]
stephent
parents: 1811
diff changeset
2094
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2095 /* This is used in glyphs-gtk.c as well */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2096 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2097 get_enumeration (GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2098 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2099 Lisp_Object alist;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2100
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2101 if (NILP (Venumeration_info))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2102 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2103 Venumeration_info = call2 (intern ("make-hashtable"), make_int (100), Qequal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2104 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2105
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2106 alist = Fgethash (make_int (t), Venumeration_info, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2107
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2108 if (NILP (alist))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2109 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2110 import_gtk_enumeration_internal (t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2111 alist = Fgethash (make_int (t), Venumeration_info, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2112 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2113 return (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2114 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2115
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2116 guint
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2117 symbol_to_enum (Lisp_Object obj, GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2118 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2119 Lisp_Object alist = get_enumeration (t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2120 Lisp_Object value = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2121
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2122 if (NILP (alist))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2123 {
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
2124 invalid_argument ("Unknown enumeration", build_cistring (gtk_type_name (t)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2125 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2126
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2127 value = Fassq (obj, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2128
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2129 if (NILP (value))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2130 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2131 invalid_argument ("Unknown value", obj);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2132 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2133
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2134 CHECK_INT (XCDR (value));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2135
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2136 return (XINT (XCDR (value)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2137 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2138
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2139 static guint
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2140 lisp_to_flag (Lisp_Object obj, GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2141 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2142 guint val = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2143
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2144 if (NILP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2145 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2146 /* Do nothing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2147 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2148 else if (SYMBOLP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2149 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2150 val = symbol_to_enum (obj, t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2151 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2152 else if (LISTP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2153 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2154 while (!NILP (obj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2155 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2156 val |= symbol_to_enum (XCAR (obj), t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2157 obj = XCDR (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2158 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2159 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2160 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2161 {
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
2162 /* ABORT ()? */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2163 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2164 return (val);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2165 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2166
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2167 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2168 flags_to_list (guint value, GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2169 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2170 Lisp_Object rval = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2171 Lisp_Object alist = get_enumeration (t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2172
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2173 while (!NILP (alist))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2174 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2175 if (value & XINT (XCDR (XCAR (alist))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2176 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2177 rval = Fcons (XCAR (XCAR (alist)), rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2178 value &= ~(XINT (XCDR (XCAR (alist))));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2179 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2180 alist = XCDR (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2181 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2182 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2183 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2184
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2185 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2186 enum_to_symbol (guint value, GtkType t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2187 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2188 Lisp_Object alist = get_enumeration (t);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2189 Lisp_Object cell = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2190
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2191 if (NILP (alist))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2192 {
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
2193 invalid_argument ("Unknown enumeration", build_cistring (gtk_type_name (t)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2194 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2195
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2196 cell = Frassq (make_int (value), alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2197
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2198 return (NILP (cell) ? Qnil : XCAR (cell));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2199 }