annotate src/menubar-gtk.c @ 1204:e22b0213b713

[xemacs-hg @ 2003-01-12 11:07:58 by michaels] modules/ChangeLog: 2002-12-16 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c: remove ifdef USE_KKCC. src/ChangeLog: 2003-01-08 Mike Sperber <mike@xemacs.org> * console.h (CDFW_CONSOLE): Don't lead to a crash if we're dealing with a dead window/frame/device/console. 2002-12-20 Mike Sperber <mike@xemacs.org> * ui-gtk.c: Fix typo from Ben's patch: emacs_ffi_data is a typedef, not a struct. emacs_gtk_object_data is a typedef, not a struct. * gtk-glue.c (gdk_event_to_emacs_event): Fix typos from Ben's patch: le -> emacs_event + rearrange the code. * event-gtk.c (gtk_event_to_emacs_event): Fix typos from Ben's patch: ..._UNDERLYING_GDK_EVENT -> ..._GDK_EVENT, ev -> key_event. * device-gtk.c: Fix typo from Ben's patch: x_keysym_map_hash_table -> x_keysym_map_hashtable. 2002-12-19 Mike Sperber <mike@xemacs.org> * menubar-x.c (set_frame_menubar): Initialize protect_me field of popup_data. 2002-12-16 Ben Wing <ben@xemacs.org> Major cleanup of KKCC, etc. KKCC, pdump-related: -- descriptions are written for all objects. this required some changes in the format of some objects, e.g. extents, popup-data, coding system, lstream, lcrecord-list. -- KKCC now handles weakness in markers, hash tables, elsewhere correctly (formerly, you'd eventually get a stack overflow due to endlessly expanding markers). -- textual changes: lrecord_description -> memory_description, struct_description -> sized_memory_description. -- extensive comment describing descriptions and pdump. -- redo XD_UNION so it works inline and change its format to provide sufficient info for pdump. implement XD_UNION in pdump. also add XD_UNION_DYNAMIC_SIZE, which works like XD_UNION except for when auto-computing structure sizes. -- add support for XD_INDIRECT in description offsets (used by extents). -- add support for "description maps", allowing for indirect descriptions that are retrieved from an object at run-time. this generalizes XD_CODING_SYSTEM_END, XD_SPECIFIER_END, etc., which have now been eliminated. -- add a fifth field "flags" to memory_description, to support flags that can be specified for this particular line. Currently defined flags are XD_FLAG_NO_KKCC (KKCC should ignore this entry; useful for the weakness above in markers, etc.), XD_FLAG_NO_PDUMP (pdump should ignore this entry), XD_FLAG_UNION_DEFAULT_ENTRY (in union maps, this specifies a "default" entry for all remaining values), and XD_FLAG_FREE_LISP_OBJECT (for use with lcrecord-lists). -- clean up the kkcc-itis in events, so that the differences between event data as separate objects and as a union are now minimized to a small number of places. with the new XD_UNION, we no longer need event data as separate objects, so this code is no longer ifdef USE_KKCC, but instead ifdef EVENT_DATA_AS_OBJECTS, not used by default. make sure that we explicitly free the separate event data objects when no longer in use, to maintain the invariant the event processing causes no consing. -- also remove other USE_KKCC ifdefs when not necessary. -- allow for KKCC compilation under MS Windows. -- fix README.kkcc. -- dump_add_root_object -> dump_add_root_lisp_object. -- implement dump_add_root_block and use this to handle dump_add_opaque. -- factor out some code duplicated in kkcc and pdump. Other allocation/object-related: -- change various *slots.h so MARKED_SLOT() call no longer includes semicolon. -- free_marker() takes a Lisp_Object not a direct pointer. -- make bit vectors lcrecords, like vectors, and eliminate code that essentially duplicated the lcrecord handling. -- additional asserts in FREE_FIXED_TYPE, formerly duplicated in the various callers of this. -- all lcrecord allocation functions now zero out the returned lcrecords. unnecessary calls to zero_lcrecord removed. add long comment describing these functions. -- extract out process and coding system slots, like for buffers, frames, etc. -- lcrecords now set the type of items sitting on the free list to lcrecord_type_free. -- changes to the way that gap arrays are allocated, for kkcc's benefit -- now, one single memory block with a stretchy array on the end, instead of a separate block holding the array. Error-checking-related: -- now can compile with C++ under MS Windows. clean up compile errors discovered that way. (a few were real problems) -- add C++ error-checking code to verify problems with mismatched GCPRO/UNGCPRO. (there were a few in the kkcc code.) add long comment about how to catch insufficient GCPRO (yes, it's possible using C++). -- add debug_p4(), a simple object printer, when debug_print() doesn't work. -- add dp() and db() as short synonyms of debug_print(), debug_backtrace(). -- `print' tries EXTREMELY hard to avoid core dumping when printing when crashing or from debug_print(), and tries as hard as it reasonably can in other situations. -- Correct the message output upon crashing to be more up-to-date. Event-related: -- document event-matches-key-specifier-p better. -- generalize the dispatch queues formerly duplicated in the various event implementations. add event methods to drain pending events. generalize and clean up QUIT handling, removing event-specific quit processing. allow arbitrary keystrokes, not just ASCII, to be the QUIT char. among other things, this should fix some longstanding bugs in X quit handling. long comment describing the various event queues. -- implement delaying of XFlush() if there are pending expose events. SOMEONE PLEASE TRY THIS OUT. -- Fix `xemacs -batch -l dunnet' under Cygwin. Try to fix under MS Windows but not quite there yet. Other: -- class -> class_ and no more C++ games with this item. new -> new_ in the lwlib code, so far not elsewhere. -- use `struct htentry' not `struct hentry' in elhash.c to avoid debugger confusion with hash.c. -- new macros ALIST_LOOP_3, ALIST_LOOP_4. * README.kkcc: * alloc.c: * alloc.c (deadbeef_memory): * alloc.c (allocate_lisp_storage): * alloc.c (copy_lisp_object): * alloc.c (ALLOCATE_FIXED_TYPE_1): * alloc.c (FREE_FIXED_TYPE): * alloc.c (make_vector_internal): * alloc.c (make_bit_vector_internal): * 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 (struct string_chars_block): * alloc.c (mark_lcrecord_list): * alloc.c (make_lcrecord_list): * alloc.c (alloc_managed_lcrecord): * alloc.c (free_managed_lcrecord): * alloc.c (alloc_automanaged_lcrecord): * alloc.c (staticpro_1): * alloc.c (staticpro): * alloc.c (lispdesc_indirect_count_1): * alloc.c (lispdesc_indirect_description_1): * alloc.c (lispdesc_one_description_line_size): * alloc.c (lispdesc_structure_size): * alloc.c (mark_object_maybe_checking_free): * alloc.c (mark_with_description): * alloc.c (mark_struct_contents): * alloc.c (mark_object): * alloc.c (tick_lcrecord_stats): * alloc.c (free_cons): * alloc.c (free_key_data): * alloc.c (free_button_data): * alloc.c (free_motion_data): * alloc.c (free_process_data): * alloc.c (free_timeout_data): * alloc.c (free_magic_data): * alloc.c (free_magic_eval_data): * alloc.c (free_eval_data): * alloc.c (free_misc_user_data): * alloc.c (free_marker): * alloc.c (compact_string_chars): * alloc.c (gc_sweep): * alloc.c (garbage_collect_1): * alloc.c (Fgarbage_collect): * alloc.c (common_init_alloc_early): * alloc.c (init_alloc_early): * alloc.c (init_alloc_once_early): * buffer.c: * buffer.c (mark_buffer): * buffer.c (MARKED_SLOT): * buffer.c (cleanup_buffer_undo_lists): * buffer.c (Fget_file_buffer): * buffer.h (MARKED_SLOT): * bufslots.h: * bytecode.c: * callint.c: * casetab.c: * chartab.c: * chartab.c (symbol_to_char_table_type): * cmdloop.c: * cmdloop.c (Fcommand_loop_1): * config.h.in (new): * conslots.h: * console-gtk-impl.h (struct gtk_frame): * console-impl.h: * console-impl.h (struct console): * console-impl.h (MARKED_SLOT): * console-impl.h (CONSOLE_QUIT_EVENT): * console-msw-impl.h (XM_BUMPQUEUE): * console-msw.c (write_string_to_mswindows_debugging_output): * console-msw.h: * console-stream-impl.h: * console-stream-impl.h (struct stream_console): * console-stream.c: * console-stream.c (stream_init_console): * console-stream.h: * console-tty.c: * console-tty.h: * console-x.h: * console.c: * console.c (mark_console): * console.c (MARKED_SLOT): * console.c (allocate_console): * console.c (get_console_variant): * console.c (create_console): * console.c (delete_console_internal): * console.c (Fset_input_mode): * console.c (Fcurrent_input_mode): * console.c (common_init_complex_vars_of_console): * console.h: * console.h (console_variant): * console.h (device_metrics): * data.c: * data.c (Faref): * data.c (Faset): * data.c (decode_weak_list_type): * database.c: * debug.c (xemacs_debug_loop): * debug.c (FROB): * debug.c (Fadd_debug_class_to_check): * debug.c (Fdelete_debug_class_to_check): * debug.c (Fset_debug_classes_to_check): * debug.c (Fset_debug_class_types_to_check): * debug.c (Fdebug_types_being_checked): * debug.h (DASSERT): * device-gtk.c: * device-impl.h (struct device): * device-impl.h (MARKED_SLOT): * device-msw.c: * device-x.c: * device-x.c (x_init_device_class): * device-x.c (x_comp_visual_info): * device-x.c (x_try_best_visual_class): * device-x.c (x_init_device): * device-x.c (construct_name_list): * device-x.c (x_get_resource_prefix): * device-x.c (Fx_get_resource): * device-x.c (Fx_display_visual_class): * device.c: * device.c (MARKED_SLOT): * device.c (allocate_device): * device.c (Fmake_device): * device.c (delete_device_internal): * device.c (Fset_device_class): * device.h: * devslots.h: * devslots.h (MARKED_SLOT): * dialog-msw.c: * dired-msw.c (mswindows_ls_sort_fcn): * dired-msw.c (mswindows_get_files): * dired-msw.c (mswindows_format_file): * doprnt.c (parse_doprnt_spec): * dumper.c: * dumper.c (struct): * dumper.c (dump_add_root_block): * dumper.c (dump_add_root_struct_ptr): * dumper.c (dump_add_root_lisp_object): * dumper.c (pdump_struct_list_elt): * dumper.c (pdump_get_entry_list): * dumper.c (pdump_backtrace): * dumper.c (pdump_bump_depth): * dumper.c (pdump_register_sub): * dumper.c (pdump_register_object): * dumper.c (pdump_register_struct_contents): * dumper.c (pdump_register_struct): * dumper.c (pdump_store_new_pointer_offsets): * dumper.c (pdump_dump_data): * dumper.c (pdump_reloc_one): * dumper.c (pdump_allocate_offset): * dumper.c (pdump_scan_by_alignment): * dumper.c (pdump_dump_root_blocks): * dumper.c (pdump_dump_rtables): * dumper.c (pdump_dump_root_lisp_objects): * dumper.c (pdump): * dumper.c (pdump_load_finish): * dumper.c (pdump_file_get): * dumper.c (pdump_resource_get): * dumper.c (pdump_load): * editfns.c (save_excursion_restore): * editfns.c (user_login_name): * editfns.c (save_restriction_restore): * elhash.c: * elhash.c (htentry): * elhash.c (struct Lisp_Hash_Table): * elhash.c (HTENTRY_CLEAR_P): * elhash.c (LINEAR_PROBING_LOOP): * elhash.c (check_hash_table_invariants): * elhash.c (mark_hash_table): * elhash.c (hash_table_equal): * elhash.c (print_hash_table_data): * elhash.c (free_hentries): * elhash.c (make_general_lisp_hash_table): * elhash.c (decode_hash_table_weakness): * elhash.c (decode_hash_table_test): * elhash.c (Fcopy_hash_table): * elhash.c (resize_hash_table): * elhash.c (pdump_reorganize_hash_table): * elhash.c (find_htentry): * elhash.c (Fgethash): * elhash.c (Fputhash): * elhash.c (remhash_1): * elhash.c (Fremhash): * elhash.c (Fclrhash): * elhash.c (copy_compress_hentries): * elhash.c (elisp_maphash_unsafe): * elhash.c (finish_marking_weak_hash_tables): * elhash.c (prune_weak_hash_tables): * elhash.h: * emacs.c: * emacs.c (main_1): * emacs.c (main): * emacs.c (shut_down_emacs): * emodules.h (dump_add_root_lisp_object): * eval.c: * eval.c (unwind_to_catch): * eval.c (maybe_signal_error_1): * eval.c (maybe_signal_continuable_error_1): * eval.c (maybe_signal_error): * eval.c (maybe_signal_continuable_error): * eval.c (maybe_signal_error_2): * eval.c (maybe_signal_continuable_error_2): * eval.c (maybe_signal_ferror): * eval.c (maybe_signal_continuable_ferror): * eval.c (maybe_signal_ferror_with_frob): * eval.c (maybe_signal_continuable_ferror_with_frob): * eval.c (maybe_syntax_error): * eval.c (maybe_sferror): * eval.c (maybe_invalid_argument): * eval.c (maybe_invalid_constant): * eval.c (maybe_invalid_operation): * eval.c (maybe_invalid_change): * eval.c (maybe_invalid_state): * eval.c (Feval): * eval.c (call_trapping_problems): * eval.c (call_with_suspended_errors): * eval.c (warn_when_safe_lispobj): * eval.c (warn_when_safe): * eval.c (vars_of_eval): * event-Xt.c: * event-Xt.c (maybe_define_x_key_as_self_inserting_character): * event-Xt.c (x_to_emacs_keysym): * event-Xt.c (x_event_to_emacs_event): * event-Xt.c (emacs_Xt_enqueue_focus_event): * event-Xt.c (emacs_Xt_format_magic_event): * event-Xt.c (emacs_Xt_compare_magic_event): * event-Xt.c (emacs_Xt_hash_magic_event): * event-Xt.c (emacs_Xt_handle_magic_event): * event-Xt.c (Xt_timeout_to_emacs_event): * event-Xt.c (Xt_process_to_emacs_event): * event-Xt.c (signal_special_Xt_user_event): * event-Xt.c (emacs_Xt_next_event): * event-Xt.c (emacs_Xt_event_handler): * event-Xt.c (emacs_Xt_drain_queue): * event-Xt.c (emacs_Xt_event_pending_p): * event-Xt.c (check_if_pending_expose_event): * event-Xt.c (reinit_vars_of_event_Xt): * event-Xt.c (vars_of_event_Xt): * event-gtk.c: * event-gtk.c (IS_MODIFIER_KEY): * event-gtk.c (emacs_gtk_format_magic_event): * event-gtk.c (emacs_gtk_compare_magic_event): * event-gtk.c (emacs_gtk_hash_magic_event): * event-gtk.c (emacs_gtk_handle_magic_event): * event-gtk.c (gtk_to_emacs_keysym): * event-gtk.c (gtk_timeout_to_emacs_event): * event-gtk.c (gtk_process_to_emacs_event): * event-gtk.c (dragndrop_data_received): * event-gtk.c (signal_special_gtk_user_event): * event-gtk.c (emacs_gtk_next_event): * event-gtk.c (gtk_event_to_emacs_event): * event-gtk.c (generic_event_handler): * event-gtk.c (emacs_shell_event_handler): * event-gtk.c (emacs_gtk_drain_queue): * event-gtk.c (emacs_gtk_event_pending_p): * event-gtk.c (reinit_vars_of_event_gtk): * event-gtk.c (vars_of_event_gtk): * event-msw.c: * event-msw.c (struct winsock_stream): * event-msw.c (winsock_reader): * event-msw.c (winsock_writer): * event-msw.c (mswindows_enqueue_dispatch_event): * event-msw.c (mswindows_enqueue_misc_user_event): * event-msw.c (mswindows_enqueue_magic_event): * event-msw.c (mswindows_enqueue_process_event): * event-msw.c (mswindows_enqueue_mouse_button_event): * event-msw.c (mswindows_enqueue_keypress_event): * event-msw.c (mswindows_dequeue_dispatch_event): * event-msw.c (emacs_mswindows_drain_queue): * event-msw.c (mswindows_need_event_in_modal_loop): * event-msw.c (mswindows_need_event): * event-msw.c (mswindows_wm_timer_callback): * event-msw.c (dde_eval_string): * event-msw.c (Fdde_alloc_advise_item): * event-msw.c (mswindows_dde_callback): * event-msw.c (mswindows_wnd_proc): * event-msw.c (remove_timeout_mapper): * event-msw.c (emacs_mswindows_remove_timeout): * event-msw.c (emacs_mswindows_event_pending_p): * event-msw.c (emacs_mswindows_format_magic_event): * event-msw.c (emacs_mswindows_compare_magic_event): * event-msw.c (emacs_mswindows_hash_magic_event): * event-msw.c (emacs_mswindows_handle_magic_event): * event-msw.c (emacs_mswindows_select_console): * event-msw.c (emacs_mswindows_unselect_console): * event-msw.c (reinit_vars_of_event_mswindows): * event-msw.c (vars_of_event_mswindows): * event-stream.c: * event-stream.c (mark_command_builder): * event-stream.c (reset_command_builder_event_chain): * event-stream.c (allocate_command_builder): * event-stream.c (copy_command_builder): * event-stream.c (command_builder_append_event): * event-stream.c (event_stream_event_pending_p): * event-stream.c (event_stream_force_event_pending): * event-stream.c (maybe_read_quit_event): * event-stream.c (event_stream_drain_queue): * event-stream.c (remove_quit_p_event): * event-stream.c (event_stream_quit_p): * event-stream.c (echo_key_event): * event-stream.c (maybe_kbd_translate): * event-stream.c (execute_help_form): * event-stream.c (event_stream_generate_wakeup): * event-stream.c (enqueue_dispatch_event): * event-stream.c (enqueue_magic_eval_event): * event-stream.c (Fenqueue_eval_event): * event-stream.c (enqueue_misc_user_event): * event-stream.c (enqueue_misc_user_event_pos): * event-stream.c (next_event_internal): * event-stream.c (Fnext_event): * event-stream.c (Faccept_process_output): * event-stream.c (execute_internal_event): * event-stream.c (munge_keymap_translate): * event-stream.c (command_builder_find_leaf_no_mule_processing): * event-stream.c (command_builder_find_leaf): * event-stream.c (lookup_command_event): * event-stream.c (is_scrollbar_event): * event-stream.c (execute_command_event): * event-stream.c (Fdispatch_event): * event-stream.c (Fread_key_sequence): * event-stream.c (dribble_out_event): * event-stream.c (vars_of_event_stream): * event-tty.c (tty_timeout_to_emacs_event): * event-tty.c (emacs_tty_next_event): * event-tty.c (emacs_tty_drain_queue): * event-tty.c (reinit_vars_of_event_tty): * event-unixoid.c: * event-unixoid.c (find_tty_or_stream_console_from_fd): * event-unixoid.c (read_event_from_tty_or_stream_desc): * event-unixoid.c (drain_tty_devices): * event-unixoid.c (poll_fds_for_input): * events.c: * events.c (deinitialize_event): * events.c (zero_event): * events.c (mark_event): * events.c (print_event_1): * events.c (print_event): * events.c (event_equal): * events.c (event_hash): * events.c (Fmake_event): * events.c (Fdeallocate_event): * events.c (Fcopy_event): * events.c (map_event_chain_remove): * events.c (character_to_event): * events.c (event_to_character): * events.c (Fevent_to_character): * events.c (format_event_object): * events.c (upshift_event): * events.c (downshift_event): * events.c (event_upshifted_p): * events.c (Fevent_live_p): * events.c (Fevent_type): * events.c (Fevent_timestamp): * events.c (CHECK_EVENT_TYPE): * events.c (CHECK_EVENT_TYPE2): * events.c (CHECK_EVENT_TYPE3): * events.c (Fevent_key): * events.c (Fevent_button): * events.c (Fevent_modifier_bits): * events.c (event_x_y_pixel_internal): * events.c (event_pixel_translation): * events.c (Fevent_process): * events.c (Fevent_function): * events.c (Fevent_object): * events.c (Fevent_properties): * events.c (syms_of_events): * events.c (vars_of_events): * events.h: * events.h (struct event_stream): * events.h (struct Lisp_Key_Data): * events.h (KEY_DATA_KEYSYM): * events.h (EVENT_KEY_KEYSYM): * events.h (struct Lisp_Button_Data): * events.h (EVENT_BUTTON_BUTTON): * events.h (struct Lisp_Motion_Data): * events.h (EVENT_MOTION_X): * events.h (struct Lisp_Process_Data): * events.h (EVENT_PROCESS_PROCESS): * events.h (struct Lisp_Timeout_Data): * events.h (EVENT_TIMEOUT_INTERVAL_ID): * events.h (struct Lisp_Eval_Data): * events.h (EVENT_EVAL_FUNCTION): * events.h (struct Lisp_Misc_User_Data): * events.h (EVENT_MISC_USER_FUNCTION): * events.h (struct Lisp_Magic_Eval_Data): * events.h (EVENT_MAGIC_EVAL_INTERNAL_FUNCTION): * events.h (struct Lisp_Magic_Data): * events.h (EVENT_MAGIC_UNDERLYING): * events.h (EVENT_MAGIC_GDK_EVENT): * events.h (struct Lisp_Event): * events.h (XEVENT_CHANNEL): * events.h (SET_EVENT_TIMESTAMP_ZERO): * events.h (SET_EVENT_CHANNEL): * events.h (SET_EVENT_NEXT): * events.h (XSET_EVENT_TYPE): * events.h (struct command_builder): * extents.c: * extents.c (gap_array_adjust_markers): * extents.c (gap_array_recompute_derived_values): * extents.c (gap_array_move_gap): * extents.c (gap_array_make_gap): * extents.c (gap_array_insert_els): * extents.c (gap_array_delete_els): * extents.c (gap_array_make_marker): * extents.c (gap_array_delete_marker): * extents.c (gap_array_move_marker): * extents.c (make_gap_array): * extents.c (free_gap_array): * extents.c (extent_list_num_els): * extents.c (extent_list_insert): * extents.c (mark_extent_auxiliary): * extents.c (allocate_extent_auxiliary): * extents.c (decode_extent_at_flag): * extents.c (verify_extent_mapper): * extents.c (symbol_to_glyph_layout): * extents.c (syms_of_extents): * faces.c: * file-coding.c: * file-coding.c (struct_detector_category_description =): * file-coding.c (detector_category_dynarr_description_1): * file-coding.c (struct_detector_description =): * file-coding.c (detector_dynarr_description_1): * file-coding.c (MARKED_SLOT): * file-coding.c (mark_coding_system): * file-coding.c (coding_system_extra_description_map): * file-coding.c (coding_system_description): * file-coding.c (allocate_coding_system): * file-coding.c (symbol_to_eol_type): * file-coding.c (Fcoding_system_aliasee): * file-coding.c (set_coding_stream_coding_system): * file-coding.c (struct convert_eol_coding_system): * file-coding.c (struct undecided_coding_system): * file-coding.c (undecided_mark_coding_stream): * file-coding.c (coding_category_symbol_to_id): * file-coding.c (struct gzip_coding_system): * file-coding.c (coding_system_type_create): * file-coding.h: * file-coding.h (struct Lisp_Coding_System): * file-coding.h (CODING_SYSTEM_SLOT_DECLARATION): * file-coding.h (coding_system_variant): * file-coding.h (struct coding_system_methods): * file-coding.h (DEFINE_CODING_SYSTEM_TYPE_WITH_DATA): * file-coding.h (INITIALIZE_CODING_SYSTEM_TYPE_WITH_DATA): * file-coding.h (struct coding_stream): * fileio.c (Fsubstitute_in_file_name): * floatfns.c: * fns.c: * fns.c (base64_encode_1): * frame-gtk.c: * frame-gtk.c (Fgtk_start_drag_internal): * frame-impl.h (struct frame): * frame-impl.h (MARKED_SLOT): * frame-msw.c: * frame-x.c: * frame-x.c (Fcde_start_drag_internal): * frame-x.c (Foffix_start_drag_internal): * frame.c: * frame.c (MARKED_SLOT): * frame.c (allocate_frame_core): * frame.c (delete_frame_internal): * frame.c (Fmouse_position_as_motion_event): * frameslots.h: * frameslots.h (MARKED_SLOT_ARRAY): * free-hook.c: * glyphs-msw.c (mswindows_widget_instantiate): * glyphs-x.c: * glyphs-x.c (convert_EImage_to_XImage): * glyphs.c: * glyphs.c (process_image_string_instantiator): * glyphs.c (mark_image_instance): * glyphs.c (allocate_image_instance): * glyphs.c (unmap_subwindow): * glyphs.c (map_subwindow): * glyphs.c (syms_of_glyphs): * glyphs.c (specifier_type_create_image): * glyphs.h: * glyphs.h (struct text_image_instance): * glyphs.h (struct Lisp_Image_Instance): * gmalloc.c: * gmalloc.c ("C"): * gpmevent.c (Freceive_gpm_event): * gpmevent.c (gpm_next_event_cb): * gpmevent.c (vars_of_gpmevent): * gtk-glue.c (gdk_event_to_emacs_event): * gtk-xemacs.c (gtk_xemacs_class_init): * gui-msw.c: * gui-msw.c (mswindows_handle_gui_wm_command): * gui-msw.c (mswindows_translate_menu_or_dialog_item): * gui-x.c: * gui-x.c (mark_popup_data): * gui-x.c (snarf_widget_value_mapper): * gui-x.c (gcpro_popup_callbacks): * gui-x.c (ungcpro_popup_callbacks): * gui-x.c (free_popup_widget_value_tree): * gui-x.c (popup_selection_callback): * gui-x.h: * gui-x.h (struct popup_data): * gui.c: * gui.c (allocate_gui_item): * gutter.c (decode_gutter_position): * hash.c (NULL_ENTRY): * indent.c (vmotion_1): * indent.c (vmotion_pixels): * input-method-motif.c (res): * input-method-xlib.c (IMInstantiateCallback): * input-method-xlib.c (XIM_init_device): * input-method-xlib.c (res): * intl-encap-win32.c: * intl-encap-win32.c (qxeSHGetDataFromIDList): * intl-win32.c: * intl-win32.c (mswindows_multibyte_cp_type): * intl-win32.c (struct mswindows_multibyte_coding_system): * keymap.c: * keymap.c (make_key_description): * keymap.c (keymap_store): * keymap.c (get_keyelt): * keymap.c (keymap_lookup_1): * keymap.c (define_key_parser): * keymap.c (key_desc_list_to_event): * keymap.c (event_matches_key_specifier_p): * keymap.c (meta_prefix_char_p): * keymap.c (ensure_meta_prefix_char_keymapp): * keymap.c (Fdefine_key): * keymap.c (struct raw_lookup_key_mapper_closure): * keymap.c (raw_lookup_key): * keymap.c (raw_lookup_key_mapper): * keymap.c (lookup_keys): * keymap.c (lookup_events): * keymap.c (Flookup_key): * keymap.c (struct map_keymap_unsorted_closure): * keymap.c (map_keymap_unsorted_mapper): * keymap.c (map_keymap_sorted): * keymap.c (map_keymap_mapper): * keymap.c (map_keymap): * keymap.c (accessible_keymaps_mapper_1): * keymap.c (Faccessible_keymaps): * keymap.c (Fsingle_key_description): * keymap.c (raw_keys_to_keys): * keymap.c (format_raw_keys): * keymap.c (where_is_recursive_mapper): * keymap.c (where_is_internal): * keymap.c (describe_map_mapper_shadow_search): * keymap.c (keymap_lookup_inherited_mapper): * keymap.c (describe_map_mapper): * keymap.h (event_matches_key_specifier_p): * lisp.h: * lisp.h (this): * lisp.h (RETURN_NOT_REACHED): * lisp.h (struct Lisp_Vector): * lisp.h (struct Lisp_Bit_Vector): * lisp.h (UNGCPRO_1): * lisp.h (NUNGCPRO): * lisp.h (NNUNGCPRO): * lisp.h (DECLARE_INLINE_HEADER): * lrecord.h: * lrecord.h (struct lrecord_header): * lrecord.h (struct lcrecord_header): * lrecord.h (lrecord_type): * lrecord.h (struct lrecord_implementation): * lrecord.h (RECORD_DUMPABLE): * lrecord.h (memory_description_type): * lrecord.h (data_description_entry_flags): * lrecord.h (struct memory_description): * lrecord.h (struct sized_memory_description): * lrecord.h (XD_INDIRECT): * lrecord.h (XD_IS_INDIRECT): * lrecord.h (XD_DYNARR_DESC): * lrecord.h (DEFINE_BASIC_LRECORD_IMPLEMENTATION): * lrecord.h (MAKE_LRECORD_IMPLEMENTATION): * lrecord.h (MAKE_EXTERNAL_LRECORD_IMPLEMENTATION): * lrecord.h (alloc_lcrecord_type): * lstream.c: * lstream.c (Lstream_new): * lstream.c (lisp_buffer_marker): * lstream.h: * lstream.h (lstream_implementation): * lstream.h (DEFINE_LSTREAM_IMPLEMENTATION): * lstream.h (DEFINE_LSTREAM_IMPLEMENTATION_WITH_DATA): * marker.c: * marker.c (copy_marker_1): * mem-limits.h: * menubar-gtk.c: * menubar-gtk.c (gtk_popup_menu): * menubar-msw.c: * menubar-msw.c (mswindows_popup_menu): * menubar-x.c (make_dummy_xbutton_event): * menubar-x.c (command_builder_operate_menu_accelerator): * menubar-x.c (menu_accelerator_safe_compare): * menubar-x.c (menu_accelerator_safe_mod_compare): * mule-charset.c: * mule-charset.c (make_charset): * mule-charset.c (Fcharset_property): * mule-coding.c: * mule-coding.c (ccs_description_1): * mule-coding.c (ccs_description =): * mule-coding.c (ccsd_description_1): * mule-coding.c (ccsd_description =): * nt.c (getpwnam): * nt.c (init_mswindows_environment): * nt.c (get_cached_volume_information): * nt.c (mswindows_is_executable): * nt.c (read_unc_volume): * nt.c (mswindows_access): * nt.c (mswindows_link): * nt.c (mswindows_fstat): * nt.c (mswindows_stat): * nt.c (mswindows_executable_type): * nt.c (Fmswindows_short_file_name): * nt.c (Fmswindows_long_file_name): * objects-impl.h (struct Lisp_Color_Instance): * objects-impl.h (struct Lisp_Font_Instance): * objects-tty.c: * objects-x.c (allocate_nearest_color): * objects.c: * objects.c (Fmake_color_instance): * objects.c (Fmake_font_instance): * objects.c (font_instantiate): * opaque.c: * opaque.c (make_opaque): * opaque.c (make_opaque_ptr): * opaque.c (reinit_opaque_early): * opaque.c (init_opaque_once_early): * print.c: * print.c (printing_badness): * print.c (printing_major_badness): * print.c (print_internal): * print.c (debug_p4): * print.c (dp): * print.c (debug_backtrace): * process-nt.c (nt_create_process): * process-nt.c (get_internet_address): * process-unix.c: * process-unix.c (struct unix_process_data): * process-unix.c (get_internet_address): * process-unix.c (unix_alloc_process_data): * process-unix.c (unix_create_process): * process-unix.c (try_to_initialize_subtty): * process-unix.c (unix_kill_child_process): * process-unix.c (process_type_create_unix): * process.c: * process.c (mark_process): * process.c (MARKED_SLOT): * process.c (make_process_internal): * process.c (Fprocess_tty_name): * process.c (decode_signal): * process.h: * procimpl.h: * procimpl.h (struct process_methods): * procimpl.h (struct Lisp_Process): * rangetab.c: * realpath.c (readlink_and_correct_case): * redisplay-x.c (x_window_output_end): * redisplay-x.c (x_redraw_exposed_area): * redisplay-x.c (x_clear_frame): * redisplay.c: * redisplay.h: * redisplay.h (struct rune_dglyph): * redisplay.h (struct rune): * scrollbar.c: * scrollbar.c (create_scrollbar_instance): * specifier.c: * specifier.c (specifier_empty_extra_description_1): * specifier.c (make_specifier_internal): * specifier.c (decode_locale_type): * specifier.c (decode_how_to_add_specification): * specifier.h: * specifier.h (struct specifier_methods): * specifier.h (DEFINE_SPECIFIER_TYPE_WITH_DATA): * specifier.h (INITIALIZE_SPECIFIER_TYPE_WITH_DATA): * symbols.c: * symbols.c (Fsetplist): * symbols.c (default_value): * symbols.c (decode_magic_handler_type): * symbols.c (handler_type_from_function_symbol): * symbols.c (Fdefvaralias): * symbols.c (init_symbols_once_early): * symbols.c (reinit_symbols_early): * symsinit.h: * sysdep.c (sys_subshell): * sysdep.c (tty_init_sys_modes_on_device): * syswindows.h: * text.c (dfc_convert_to_external_format): * text.c (dfc_convert_to_internal_format): * text.c (reinit_eistring_early): * text.c (init_eistring_once_early): * text.c (reinit_vars_of_text): * text.h: * text.h (INC_IBYTEPTR_FMT): * text.h (DEC_IBYTEPTR_FMT): * toolbar.c: * toolbar.c (decode_toolbar_position): * tooltalk.c: * ui-gtk.c: * unexnt.c: * unexnt.c (_start): * unexnt.c (unexec): * unexnt.c (get_section_info): * unicode.c: * unicode.c (vars_of_unicode): * window.c: * window.c (allocate_window): * window.c (new_window_mirror): * window.c (update_mirror_internal): * winslots.h:
author michaels
date Sun, 12 Jan 2003 11:08:22 +0000
parents 890f3cafe600
children f0af455e89d9
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 /* Implements an elisp-programmable menubar -- X interface.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
4 Copyright (C) 2002 Ben Wing.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
11 later version.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16 for more details.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25 /* created 16-dec-91 by jwz */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 #include "buffer.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 #include "commands.h" /* zmacs_regions */
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
32 #include "device.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33 #include "events.h"
876
890f3cafe600 [xemacs-hg @ 2002-06-23 09:25:11 by stephent]
stephent
parents: 872
diff changeset
34 #include "device-impl.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
35 #include "frame-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
36 #include "gui.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 #include "opaque.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38 #include "window.h"
876
890f3cafe600 [xemacs-hg @ 2002-06-23 09:25:11 by stephent]
stephent
parents: 872
diff changeset
39 #include "window-impl.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
41 #include "console-gtk-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
42 #include "gui-gtk.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
43 #include "ui-gtk.h"
876
890f3cafe600 [xemacs-hg @ 2002-06-23 09:25:11 by stephent]
stephent
parents: 872
diff changeset
44 #include "menubar.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
45
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 #ifdef HAVE_GNOME
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 #include <libgnomeui/libgnomeui.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 #define MENUBAR_TYPE 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 #define SUBMENU_TYPE 1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 #define POPUP_TYPE 2
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 static GtkWidget *menu_descriptor_to_widget_1 (Lisp_Object descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 #define FRAME_MENUBAR_DATA(frame) ((frame)->menubar_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 #define XFRAME_MENUBAR_DATA_LASTBUFF(frame) (XCAR ((frame)->menubar_data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 #define XFRAME_MENUBAR_DATA_UPTODATE(frame) (XCDR ((frame)->menubar_data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 /* This is a bogus subclass of GtkMenuBar so that the menu never tries
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 ** to be bigger than the text widget. This prevents weird resizing
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 ** when jumping around between buffers with radically different menu
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64 ** sizes.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 #define GTK_XEMACS_MENUBAR(obj) GTK_CHECK_CAST (obj, gtk_xemacs_menubar_get_type (), GtkXEmacsMenubar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 #define GTK_XEMACS_MENUBAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_xemacs_menubar_get_type (), GtkXEmacsMenubarClass)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 #define GTK_IS_XEMACS_MENUBAR(obj) GTK_CHECK_TYPE (obj, gtk_xemacs_menubar_get_type ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70 #define GTK_XEMACS_MENUBAR_FRAME(obj) GTK_XEMACS_MENUBAR (obj)->f
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72 typedef struct _GtkXEmacsMenubar GtkXEmacsMenubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73 typedef struct _GtkXEmacsMenubarClass GtkXEmacsMenubarClass;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
75 struct _GtkXEmacsMenubar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 GtkMenuBar menu;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 struct frame *frame;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 };
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 struct _GtkXEmacsMenubarClass
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 GtkMenuBarClass parent_class;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84 };
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 guint gtk_xemacs_menubar_get_type (void);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 GtkWidget *gtk_xemacs_menubar_new (struct frame *f);
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 static void gtk_xemacs_menubar_class_init (GtkXEmacsMenubarClass *klass);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 static void gtk_xemacs_menubar_init (GtkXEmacsMenubar *xemacs);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 static void gtk_xemacs_menubar_size_request (GtkWidget *widget, GtkRequisition *requisition);
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 guint
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 gtk_xemacs_menubar_get_type (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 static guint xemacs_menubar_type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 if (!xemacs_menubar_type)
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 static const GtkTypeInfo xemacs_menubar_info =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 "GtkXEmacsMenubar",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 sizeof (GtkXEmacsMenubar),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 sizeof (GtkXEmacsMenubarClass),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 (GtkClassInitFunc) gtk_xemacs_menubar_class_init,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 (GtkObjectInitFunc) gtk_xemacs_menubar_init,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 /* reserved_1 */ NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 /* reserved_2 */ NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 (GtkClassInitFunc) NULL,
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 xemacs_menubar_type = gtk_type_unique (gtk_menu_bar_get_type (), &xemacs_menubar_info);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 }
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 return xemacs_menubar_type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 }
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 static GtkWidgetClass *parent_class;
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 static void gtk_xemacs_menubar_class_init (GtkXEmacsMenubarClass *klass)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 GtkWidgetClass *widget_class;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 widget_class = (GtkWidgetClass*) klass;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 parent_class = (GtkWidgetClass *) gtk_type_class (gtk_menu_bar_get_type ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 widget_class->size_request = gtk_xemacs_menubar_size_request;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 }
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 static void gtk_xemacs_menubar_init (GtkXEmacsMenubar *xemacs)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 {
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 static void gtk_xemacs_menubar_size_request (GtkWidget *widget, GtkRequisition *requisition)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 GtkXEmacsMenubar *x = GTK_XEMACS_MENUBAR (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 GtkRequisition frame_size;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 parent_class->size_request (widget, requisition);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 /* #### BILL!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 ** We should really only do this if the menu has not been detached!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 ** WMP 9/9/2000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 gtk_widget_size_request (FRAME_GTK_TEXT_WIDGET (x->frame), &frame_size);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 requisition->width = frame_size.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 }
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 GtkWidget *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 gtk_xemacs_menubar_new (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 GtkXEmacsMenubar *menubar = gtk_type_new (gtk_xemacs_menubar_get_type ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 menubar->frame = f;
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 return (GTK_WIDGET (menubar));
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162 /* We now return you to your regularly scheduled menus... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 int dockable_menubar;
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 /* #define TEAR_OFF_MENUS */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 int tear_off_menus;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 #endif
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 /* Converting from XEmacs to GTK representation */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 menu_name_to_accelerator (char *name)
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 while (*name) {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 if (*name=='%') {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 ++name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 if (!(*name))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 if (*name=='_' && *(name+1))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 int accelerator = (int) (unsigned char) (*(name+1));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 return make_char (tolower (accelerator));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 ++name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 #define XEMACS_MENU_DESCR_TAG "xemacs::menu::description"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194 #define XEMACS_MENU_FILTER_TAG "xemacs::menu::filter"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195 #define XEMACS_MENU_GUIID_TAG "xemacs::menu::gui_id"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 #define XEMACS_MENU_FIRSTTIME_TAG "xemacs::menu::first_time"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 static void __activate_menu(GtkMenuItem *, gpointer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 __torn_off_sir(GtkMenuItem *item, gpointer user_data)
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 GtkWidget *menu_item = GTK_WIDGET (user_data);
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 if (GTK_TEAROFF_MENU_ITEM (item)->torn_off)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208 /* Menu was just torn off */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 GUI_ID id = new_gui_id ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210 Lisp_Object menu_desc = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 GtkWidget *old_submenu = GTK_MENU_ITEM (menu_item)->submenu;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
213 menu_desc = VOID_TO_LISP (gtk_object_get_data (GTK_OBJECT (menu_item), XEMACS_MENU_DESCR_TAG));
462
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 /* GCPRO all of our very own */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216 gcpro_popup_callbacks (id, menu_desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 /* Hide the now detached menu from the attentions of
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 __activate_menu destroying the old submenu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221 gtk_widget_ref (old_submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), gtk_menu_new ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 gtk_widget_show_all (old_submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 #endif
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 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 #endif
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 /* This is called when a menu is about to be shown... this is what
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 does the delayed creation of the menu items. We populate the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 submenu and away we go. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 __maybe_destroy (GtkWidget *child, GtkWidget *precious)
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 if (GTK_IS_MENU_ITEM (child) && !GTK_IS_TEAROFF_MENU_ITEM (child))
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 if (GTK_WIDGET_VISIBLE (child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 /* If we delete the menu item that was 'active' when the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 menu was cancelled, GTK gets upset because it tries to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 remove the focus rectangle from a (now) dead widget.
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 This widget will eventually get killed because it will
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 not be visible the next time the window is shown.
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 gtk_widget_set_sensitive (child, FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 gtk_widget_hide_all (child);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 gtk_widget_destroy (child);
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 }
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 /* If user_data != 0x00 then we are using a hook to build the menu. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 __activate_menu(GtkMenuItem *item, gpointer user_data)
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 Lisp_Object desc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 gpointer force_clear = gtk_object_get_data (GTK_OBJECT (item), XEMACS_MENU_FIRSTTIME_TAG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 gtk_object_set_data (GTK_OBJECT (item), XEMACS_MENU_FIRSTTIME_TAG, 0x00);
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 /* Delete the old contents of the menu if we are the top level menubar */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 if (GTK_IS_MENU_BAR (GTK_WIDGET (item)->parent) || force_clear)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 GtkWidget *selected = gtk_menu_get_active (GTK_MENU (item->submenu));
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 gtk_container_foreach (GTK_CONTAINER (item->submenu),(GtkCallback) __maybe_destroy,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 selected);
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 else if (gtk_container_children (GTK_CONTAINER (item->submenu)))
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
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
278 desc = VOID_TO_LISP (gtk_object_get_data (GTK_OBJECT (item), XEMACS_MENU_DESCR_TAG));
462
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 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 /* Lets stick in a detacher just for giggles */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 if (tear_off_menus && !gtk_container_children (GTK_CONTAINER (item->submenu)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 GtkWidget *w = gtk_tearoff_menu_item_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 gtk_widget_show (w);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 gtk_menu_append (GTK_MENU (item->submenu), w);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 gtk_signal_connect (GTK_OBJECT (w), "activate", GTK_SIGNAL_FUNC (__torn_off_sir), item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 #endif
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 if (user_data)
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 GUI_ID id = (GUI_ID) gtk_object_get_data (GTK_OBJECT (item), XEMACS_MENU_GUIID_TAG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 Lisp_Object hook_fn;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 struct gcpro gcpro1, gcpro2;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
297 hook_fn = VOID_TO_LISP (gtk_object_get_data (GTK_OBJECT (item), XEMACS_MENU_FILTER_TAG));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 GCPRO2 (desc, hook_fn);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 desc = call1 (hook_fn, desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 ungcpro_popup_callbacks (id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 gcpro_popup_callbacks (id, desc);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 /* Build the child widgets */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 for (; !NILP (desc); desc = Fcdr (desc))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 GtkWidget *next = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 Lisp_Object child = Fcar (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 if (NILP (child)) /* the partition */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 /* Signal an error here? The NILP handling is handled a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 layer higher where appropriate */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 next = menu_descriptor_to_widget_1 (child);
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 if (!next)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 continue;
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 gtk_widget_show_all (next);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331 gtk_menu_append (GTK_MENU (item->submenu), next);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 /* This is called whenever an item with a GUI_ID associated with it is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 destroyed. This allows us to remove the references in gui-gtk.c
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 that made sure callbacks and such were GCPRO-ed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 __remove_gcpro_by_id (gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 ungcpro_popup_callbacks ((GUI_ID) user_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
346 __kill_stupid_gtk_timer (GtkObject *obj, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
347 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
348 GtkMenuItem *mi = GTK_MENU_ITEM (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
350 if (mi->timer)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352 gtk_timeout_remove (mi->timer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
353 mi->timer = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 static char *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358 remove_underscores(const char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
360 char *rval = xmalloc_and_zero (strlen(name) + 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
361 int i,j;
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 for (i = 0, j = 0; name[i]; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365 if (name[i]=='%') {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 i++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
367 if (!(name[i]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
368 continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 if ((name[i] == '_'))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373 rval[j++] = name[i];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375 return rval;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 /* This converts an entire menu into a GtkMenuItem (with an attached
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
379 submenu). A menu is a list of (STRING [:keyword value]+ [DESCR]+)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
380 DESCR is either a list (meaning a submenu), a vector, or nil (if
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
381 you include a :filter keyword) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 static GtkWidget *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 menu_convert (Lisp_Object desc, GtkWidget *reuse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 GtkWidget *menu_item = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 GtkWidget *submenu = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387 Lisp_Object key, val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388 Lisp_Object include_p = Qnil, hook_fn = Qnil, config_tag = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389 Lisp_Object active_p = Qt;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 Lisp_Object accel;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
391 int included_spec = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392 int active_spec = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394 if (STRINGP (XCAR (desc)))
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 accel = menu_name_to_accelerator (XSTRING_DATA (XCAR (desc)));
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 if (!reuse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 char *temp_menu_name = remove_underscores (XSTRING_DATA (XCAR (desc)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 menu_item = gtk_menu_item_new_with_label (temp_menu_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 free (temp_menu_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
403 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 menu_item = reuse;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 submenu = gtk_menu_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 gtk_widget_show (menu_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 gtk_widget_show (submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 if (!reuse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 gtk_signal_connect (GTK_OBJECT (menu_item), "destroy",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 GTK_SIGNAL_FUNC (__kill_stupid_gtk_timer), NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 /* Without this sometimes a submenu gets left on the screen -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 ** urk
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 if (GTK_MENU_ITEM (menu_item)->submenu)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 gtk_widget_destroy (GTK_MENU_ITEM (menu_item)->submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 /* We put this bogus menu item in so that GTK does the right
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 ** thing when the menu is near the screen border.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430 ** Aug 29, 2000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 GtkWidget *bogus_item = gtk_menu_item_new_with_label ("A suitably long label here...");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435 gtk_object_set_data (GTK_OBJECT (menu_item), XEMACS_MENU_FIRSTTIME_TAG, (gpointer)0x01);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436 gtk_widget_show_all (bogus_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437 gtk_menu_append (GTK_MENU (submenu), bogus_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440 desc = Fcdr (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 while (key = Fcar (desc), KEYWORDP (key))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 Lisp_Object cascade = desc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 desc = Fcdr (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 if (NILP (desc))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
447 sferror ("keyword in menu lacks a value",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 cascade);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 val = Fcar (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 desc = Fcdr (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 if (EQ (key, Q_included))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 include_p = val, included_spec = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 else if (EQ (key, Q_config))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 config_tag = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 else if (EQ (key, Q_filter))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 hook_fn = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457 else if (EQ (key, Q_active))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 active_p = val, active_spec = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 else if (EQ (key, Q_accelerator))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462 if ( SYMBOLP (val)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 || CHARP (val))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 wv->accel = LISP_TO_VOID (val);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
466 invalid_argument ("bad keyboard accelerator", val);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 else if (EQ (key, Q_label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
470 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
471 /* implement in 21.2 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
474 invalid_argument ("unknown menu cascade keyword", cascade);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 gtk_object_set_data (GTK_OBJECT (menu_item), XEMACS_MENU_DESCR_TAG, LISP_TO_VOID (desc));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 gtk_object_set_data (GTK_OBJECT (menu_item), XEMACS_MENU_FILTER_TAG, LISP_TO_VOID (hook_fn));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 if ((!NILP (config_tag)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 && NILP (Fmemq (config_tag, Vmenubar_configuration)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482 || (included_spec && NILP (Feval (include_p))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
483 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484 return (NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 if (active_spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
488 active_p = Feval (active_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
490 gtk_widget_set_sensitive (GTK_WIDGET (menu_item), ! NILP (active_p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
492 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
494 invalid_argument ("menu name (first element) must be a string",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
495 desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
496 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
497
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
498 /* If we are reusing a widget, we need to make sure we clean
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
499 ** everything up.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 if (reuse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
502 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503 gpointer id = gtk_object_get_data (GTK_OBJECT (reuse), XEMACS_MENU_GUIID_TAG);
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 if (id)
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 /* If the menu item had a GUI_ID that means it was a filter menu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
508 __remove_gcpro_by_id (id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
509 gtk_signal_disconnect_by_func (GTK_OBJECT (reuse),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
510 GTK_SIGNAL_FUNC (__activate_menu),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 (gpointer) 0x01 );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
512 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
513 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
514 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515 gtk_signal_disconnect_by_func (GTK_OBJECT (reuse),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 GTK_SIGNAL_FUNC (__activate_menu),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517 NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518 }
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 GTK_MENU_ITEM (reuse)->right_justify = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
521 }
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 if (NILP (hook_fn))
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 /* Generic menu builder */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
526 gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527 GTK_SIGNAL_FUNC (__activate_menu),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528 NULL);
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 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532 GUI_ID id = new_gui_id ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534 gtk_object_set_data (GTK_OBJECT (menu_item), XEMACS_MENU_GUIID_TAG,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535 (gpointer) id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
536
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537 /* Make sure we gcpro the menu descriptions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538 gcpro_popup_callbacks (id, desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539 gtk_object_weakref (GTK_OBJECT (menu_item), __remove_gcpro_by_id,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540 (gpointer) id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542 gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543 GTK_SIGNAL_FUNC (__activate_menu),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 (gpointer) 0x01);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
545 }
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 return (menu_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548 }
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 static struct frame *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551 __get_channel (GtkWidget *w)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
552 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
553 struct frame *f = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
554
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
555 for (; w; w = w->parent)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
556 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557 if ((f = (struct frame *) gtk_object_get_data (GTK_OBJECT (w), "xemacs::frame")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558 return (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
559 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
561 return (selected_frame());
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565 /* Called whenever a button, radio, or toggle is selected in the menu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
567 __generic_button_callback (GtkMenuItem *item, gpointer user_data)
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 Lisp_Object callback, function, data, channel;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
571 channel = wrap_frame (__get_channel (GTK_WIDGET (item)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
572
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
573 callback = VOID_TO_LISP (user_data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575 get_gui_callback (callback, &function, &data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577 signal_special_gtk_user_event (channel, function, data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 /* Convert a single menu item descriptor to a suitable GtkMenuItem */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581 /* This function cannot GC.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582 It is only called from menu_item_descriptor_to_widget_value, which
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583 prohibits GC. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584 static GtkWidget *menu_descriptor_to_widget_1 (Lisp_Object descr)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586 if (STRINGP (descr))
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 /* It is a separator. Unfortunately GTK does not allow us to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 specify what our separators look like, so we can't do all the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590 fancy stuff that the X code does.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592 return (gtk_menu_item_new ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594 else if (LISTP (descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596 /* It is a submenu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 return (menu_convert (descr, NULL));
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 else if (VECTORP (descr))
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 /* An actual menu item description! This gets yucky. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
602 Lisp_Object name = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
603 Lisp_Object callback = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
604 Lisp_Object suffix = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
605 Lisp_Object active_p = Qt;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
606 Lisp_Object include_p = Qt;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
607 Lisp_Object selected_p = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
608 Lisp_Object keys = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
609 Lisp_Object style = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
610 Lisp_Object config_tag = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
611 Lisp_Object accel = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
612 GtkWidget *main_label = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
613 int length = XVECTOR_LENGTH (descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
614 Lisp_Object *contents = XVECTOR_DATA (descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
615 int plist_p;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
616 int selected_spec = 0, included_spec = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
617 GtkWidget *widget = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
618
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
619 if (length < 2)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
620 sferror ("button descriptors must be at least 2 long", descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
621
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
622 /* length 2: [ "name" callback ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
623 length 3: [ "name" callback active-p ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
624 length 4: [ "name" callback active-p suffix ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
625 or [ "name" callback keyword value ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
626 length 5+: [ "name" callback [ keyword value ]+ ]
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 plist_p = (length >= 5 || (length > 2 && KEYWORDP (contents [2])));
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 (!plist_p && length > 2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
631 /* the old way */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
632 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
633 name = contents [0];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
634 callback = contents [1];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
635 active_p = contents [2];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
636 if (length == 4)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
637 suffix = contents [3];
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 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
640 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
641 /* the new way */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
642 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
643 if (length & 1)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
644 sferror (
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
645 "button descriptor has an odd number of keywords and values",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
646 descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
647
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
648 name = contents [0];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
649 callback = contents [1];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
650 for (i = 2; i < length;)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
651 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
652 Lisp_Object key = contents [i++];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
653 Lisp_Object val = contents [i++];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
654 if (!KEYWORDP (key))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
655 invalid_argument_2 ("not a keyword", key, descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
656
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
657 if (EQ (key, Q_active)) active_p = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
658 else if (EQ (key, Q_suffix)) suffix = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
659 else if (EQ (key, Q_keys)) keys = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
660 else if (EQ (key, Q_key_sequence)) ; /* ignored for FSF compat */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
661 else if (EQ (key, Q_label)) ; /* implement for 21.0 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
662 else if (EQ (key, Q_style)) style = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
663 else if (EQ (key, Q_selected)) selected_p = val, selected_spec = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
664 else if (EQ (key, Q_included)) include_p = val, included_spec = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
665 else if (EQ (key, Q_config)) config_tag = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
666 else if (EQ (key, Q_accelerator))
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 if ( SYMBOLP (val) || CHARP (val))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
669 accel = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
670 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
671 invalid_argument ("bad keyboard accelerator", val);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
672 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
673 else if (EQ (key, Q_filter))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
674 sferror(":filter keyword not permitted on leaf nodes", descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
675 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
676 invalid_argument_2 ("unknown menu item keyword", key, descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
677 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
678 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
679
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
680 #ifdef HAVE_MENUBARS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
681 if ((!NILP (config_tag) && NILP (Fmemq (config_tag, Vmenubar_configuration)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
682 || (included_spec && NILP (Feval (include_p))))
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 /* the include specification says to ignore this item. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
685 return 0;
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 #endif /* HAVE_MENUBARS */
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 CHECK_STRING (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
690
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
691 if (NILP (accel))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
692 accel = menu_name_to_accelerator (XSTRING_DATA (name));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
693
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
694 if (!NILP (suffix))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
695 suffix = Feval (suffix);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
696
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
697 if (!separator_string_p (XSTRING_DATA (name)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
698 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
699 char *label_buffer = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
700 char *temp_label = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
701
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
702 if (STRINGP (suffix) && XSTRING_LENGTH (suffix))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
703 {
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 833
diff changeset
704 label_buffer = ALLOCA (XSTRING_LENGTH (name) + 15 + XSTRING_LENGTH (suffix));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
705 sprintf (label_buffer, "%s %s ", XSTRING_DATA (name), XSTRING_DATA (suffix));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
706 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
707 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
708 {
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 833
diff changeset
709 label_buffer = ALLOCA (XSTRING_LENGTH (name) + 15);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
710 sprintf (label_buffer, "%s ", XSTRING_DATA (name));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
711 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
712
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
713 temp_label = remove_underscores (label_buffer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
714 main_label = gtk_accel_label_new (temp_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
715 free (temp_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
716 }
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 /* Evaluate the selected and active items now */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
719 if (selected_spec)
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 if (NILP (selected_p) || EQ (selected_p, Qt))
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 /* Do nothing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
724 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
725 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
726 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
727 selected_p = Feval (selected_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
728 }
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
731 if (NILP (active_p) || EQ (active_p, Qt))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
732 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
733 /* Do Nothing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
734 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
735 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
736 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
737 active_p = Feval (active_p);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
740 if (0 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
741 #ifdef HAVE_MENUBARS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
742 menubar_show_keybindings
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
743 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
744 )
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
745 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
746 /* Need to get keybindings */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
747 if (!NILP (keys))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
748 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
749 /* User-specified string to generate key bindings with */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
750 CHECK_STRING (keys);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
751
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
752 keys = Fsubstitute_command_keys (keys);
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 else if (SYMBOLP (callback))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
755 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
756 DECLARE_EISTRING_MALLOC (buf);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
757
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
758 /* #### Warning, dependency here on current_buffer and point */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
759 where_is_to_char (callback, buf);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
760
833
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
761 if (eilen (buf) > 0)
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
762 keys = eimake_string (buf);
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
763 else
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
764 {
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
765
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
766 keys = Qnil;
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
767 }
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
768
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
769 eifree (buf);
462
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
773 /* Now we get down to the dirty business of creating the widgets */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
774 if (NILP (style) || EQ (style, Qtext) || EQ (style, Qbutton))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
775 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
776 /* A normal menu item */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
777 widget = gtk_menu_item_new ();
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 else if (EQ (style, Qtoggle) || EQ (style, Qradio))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
780 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
781 /* They are radio or toggle buttons.
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 XEmacs' menu descriptions are fairly lame in that they do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
784 not have the idea of a 'group' of radio buttons. They
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
785 are exactly like toggle buttons except that they get
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
786 drawn differently.
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 GTK rips us a new one again. If you have a radio button
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
789 in a group by itself, it always draws it as highlighted.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
790 So we dummy up and create a second radio button that does
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
791 not get added to the menu, but gets invisibly set/unset
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
792 when the other gets unset/set. *sigh*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
793
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
794 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
795 if (EQ (style, Qradio))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
796 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
797 GtkWidget *dummy_sibling = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
798 GSList *group = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
799
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
800 dummy_sibling = gtk_radio_menu_item_new (group);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
801 group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (dummy_sibling));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
802 widget = gtk_radio_menu_item_new (group);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
803
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
804 /* We need to notice when the 'real' one gets destroyed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
805 so we can clean up the dummy as well. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
806 gtk_object_weakref (GTK_OBJECT (widget),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
807 (GtkDestroyNotify) gtk_widget_destroy,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
808 dummy_sibling);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
809 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
810 else
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 widget = gtk_check_menu_item_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
813 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
814
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
815 /* What horrible defaults you have GTK dear! The default
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
816 for a toggle menu item is to not show the toggle unless it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
817 is turned on or actively highlighted. How absolutely
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
818 hideous. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
819 gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (widget), TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
820 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
821 NILP (selected_p) ? FALSE : TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
822 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
823 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
824 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
825 invalid_argument_2 ("unknown style", style, descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
826 }
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 gtk_widget_set_sensitive (widget, ! NILP (active_p));
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 gtk_signal_connect (GTK_OBJECT (widget), "activate-item",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
831 GTK_SIGNAL_FUNC (__generic_button_callback),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
832 LISP_TO_VOID (callback));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
833
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
834 gtk_signal_connect (GTK_OBJECT (widget), "activate",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
835 GTK_SIGNAL_FUNC (__generic_button_callback),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
836 LISP_TO_VOID (callback));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
837
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
838 /* We cheat here... GtkAccelLabel usually builds its
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
839 `accel_string' from the widget it is attached to, but we do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
840 not want to go thru the overhead of converting our nice
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
841 string back into the modifier + key format that requires,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
842 just so that they can convert it back into a (possibly
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
843 different/wrong) string
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 We set the label string manually, and things should 'just
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
846 work'
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
847
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
848 In an ideal world we would just subclass GtkLabel ourselves,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
849 but I have known for a very long time that this is not an
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
850 ideal world.
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 #### Should do menu shortcuts `correctly' one of these days.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
853 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
854
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
855 if (main_label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
856 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
857 GtkAccelLabel *l = GTK_ACCEL_LABEL (main_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
858
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
859 gtk_container_add (GTK_CONTAINER (widget), main_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
860
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
861 gtk_accel_label_set_accel_widget (l, NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
862 gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
863
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
864 if (STRINGP (keys) && XSTRING_LENGTH (keys))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
865 {
833
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
866 C_STRING_TO_EXTERNAL_MALLOC (XSTRING_DATA (keys), l->accel_string,
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
867 Qctext);
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
868 stderr_out ("accel: %s\n", l->accel_string);
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
869 }
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
870 else
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
871 {
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
872 // l->accel_string = "";
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
873 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
874 }
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 return (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
877 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
878 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
879 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
880 return (NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
881 /* abort (); ???? */
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 }
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 static GtkWidget *menu_descriptor_to_widget (Lisp_Object descr)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
886 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
887 GtkWidget *rval = NULL;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 714
diff changeset
888 int count = begin_gc_forbidden ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
889
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
890 /* Cannot GC from here on out... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
891 rval = menu_descriptor_to_widget_1 (descr);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 714
diff changeset
892 unbind_to (count);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
893 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
894
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
895 }
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 static gboolean
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
898 menu_can_reuse_widget (GtkWidget *child, const char *label)
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 /* Everything up at the top level was done using
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
901 ** gtk_menu_item_new_with_label(), but we still double check to make
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
902 ** sure we don't seriously foobar ourselves.
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 char *temp_label = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
905 gpointer possible_child = g_list_nth_data (gtk_container_children (GTK_CONTAINER (child)), 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
906
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
907 if (possible_child && GTK_IS_LABEL (possible_child))
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 if (!temp_label) temp_label = remove_underscores (label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
910 if (!strcmp (GTK_LABEL (possible_child)->label, temp_label))
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 free (temp_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
913 return (TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
914 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
915 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
916 if (temp_label) free (temp_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
917 return (FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
918 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
919
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
920 /* Converts a menubar description into a GtkMenuBar... a menubar is a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
921 list of menus or buttons
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 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
924 menu_create_menubar (struct frame *f, Lisp_Object descr)
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 gboolean right_justify = FALSE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
927 Lisp_Object tail = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
928 Lisp_Object value = descr;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
929 Lisp_Object item_descr = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
930 GtkWidget *menubar = FRAME_GTK_MENUBAR_WIDGET (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
931 GUI_ID id = (GUI_ID) gtk_object_get_data (GTK_OBJECT (menubar), XEMACS_MENU_GUIID_TAG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
932 guint menu_position = 0;
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 /* Remove any existing protection for old menu items */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
935 ungcpro_popup_callbacks (id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
936
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
937 /* GCPRO the whole damn thing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
938 gcpro_popup_callbacks (id, descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
939
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
940 EXTERNAL_LIST_LOOP (tail, value)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
941 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
942 gpointer current_child = g_list_nth_data (GTK_MENU_SHELL (menubar)->children, menu_position);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
943
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
944 item_descr = XCAR (tail);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
945
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
946 if (NILP (item_descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
947 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
948 /* Need to start right-justifying menus */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
949 right_justify = TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
950 menu_position--;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
951 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
952 else if (VECTORP (item_descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
953 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
954 /* It is a button description */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
955 GtkWidget *item;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
956
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
957 item = menu_descriptor_to_widget (item_descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
958 gtk_widget_set_name (item, "XEmacsMenuButton");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
959
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
960 if (!item)
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 item = gtk_menu_item_new_with_label ("ITEM CREATION ERROR");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
963 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
964
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
965 gtk_widget_show_all (item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
966 if (current_child) gtk_widget_destroy (GTK_WIDGET (current_child));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
967 gtk_menu_bar_insert (GTK_MENU_BAR (menubar), item, menu_position);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
968 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
969 else if (LISTP (item_descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
970 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
971 /* Need to actually convert it into a menu and slap it in */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
972 GtkWidget *widget;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
973 gboolean reused_p = FALSE;
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 /* We may be able to reuse the widget, let's at least check. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
976 if (current_child && menu_can_reuse_widget (GTK_WIDGET (current_child),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
977 XSTRING_DATA (XCAR (item_descr))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
978 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
979 widget = menu_convert (item_descr, GTK_WIDGET (current_child));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
980 reused_p = TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
981 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
982 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
983 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
984 widget = menu_convert (item_descr, NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
985 if (current_child) gtk_widget_destroy (GTK_WIDGET (current_child));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
986 gtk_menu_bar_insert (GTK_MENU_BAR (menubar), widget, menu_position);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
989 if (widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
990 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
991 if (right_justify) gtk_menu_item_right_justify (GTK_MENU_ITEM (widget));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
992 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
993 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
994 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
995 widget = gtk_menu_item_new_with_label ("ERROR");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
996 /* abort() */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
997 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
998 gtk_widget_show_all (widget);
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 else if (STRINGP (item_descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1001 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1002 /* Do I really want to be this careful? Anything else in a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1003 menubar description is illegal */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1004 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1005 menu_position++;
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1008 /* Need to delete any menu items that were past the bounds of the new one */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1009 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1010 GList *l = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1011
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1012 while ((l = g_list_nth (GTK_MENU_SHELL (menubar)->children, menu_position)))
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 gpointer data = l->data;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1015 g_list_remove_link (GTK_MENU_SHELL (menubar)->children, l);
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 if (data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1018 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1019 gtk_widget_destroy (GTK_WIDGET (data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1020 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1021 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1022 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1023 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1024
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1025
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1026 /* Deal with getting/setting the menubar */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1027 #ifndef GNOME_IS_APP
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1028 #define GNOME_IS_APP(x) 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1029 #define gnome_app_set_menus(x,y)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1030 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1031
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1032 static gboolean
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1033 run_menubar_hook (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1034 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1035 if (!GTK_MENU_SHELL(widget)->active)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1036 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1037 run_hook (Qactivate_menubar_hook);
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 return(FALSE);
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 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1043 create_menubar_widget (struct frame *f)
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 GUI_ID id = new_gui_id ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1046 GtkWidget *handlebox = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1047 GtkWidget *menubar = gtk_xemacs_menubar_new (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1048
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1049 if (GNOME_IS_APP (FRAME_GTK_SHELL_WIDGET (f)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1050 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1051 gnome_app_set_menus (GNOME_APP (FRAME_GTK_SHELL_WIDGET (f)), GTK_MENU_BAR (menubar));
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 else if (dockable_menubar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1054 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1055 handlebox = gtk_handle_box_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1056 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (handlebox), GTK_POS_LEFT);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1057 gtk_container_add (GTK_CONTAINER (handlebox), menubar);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1058 gtk_box_pack_start (GTK_BOX (FRAME_GTK_CONTAINER_WIDGET (f)), handlebox, FALSE, FALSE, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1059 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1060 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1061 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1062 gtk_box_pack_start (GTK_BOX (FRAME_GTK_CONTAINER_WIDGET (f)), menubar, FALSE, FALSE, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1063 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1064
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1065 gtk_signal_connect (GTK_OBJECT (menubar), "button-press-event",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1066 GTK_SIGNAL_FUNC (run_menubar_hook), NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1067
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1068 FRAME_GTK_MENUBAR_WIDGET (f) = menubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1069 gtk_object_set_data (GTK_OBJECT (menubar), XEMACS_MENU_GUIID_TAG, (gpointer) id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1070 gtk_object_weakref (GTK_OBJECT (menubar), __remove_gcpro_by_id, (gpointer) id);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1073 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1074 set_frame_menubar (struct frame *f, int first_time_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1075 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1076 Lisp_Object menubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1077 int menubar_visible;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1078 /* As for the toolbar, the minibuffer does not have its own menubar. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1079 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1080
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1081 if (! FRAME_GTK_P (f))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1082 return 0;
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 /***** first compute the contents of the menubar *****/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1085
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1086 if (! first_time_p)
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 /* evaluate `current-menubar' in the buffer of the selected window
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1089 of the frame in question. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1090 menubar = symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1091 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1092 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1093 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1094 /* That's a little tricky the first time since the frame isn't
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1095 fully initialized yet. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1096 menubar = Fsymbol_value (Qcurrent_menubar);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1097 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1098
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1099 if (NILP (menubar))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1100 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1101 menubar = Vblank_menubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1102 menubar_visible = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1103 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1104 else
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 menubar_visible = !NILP (w->menubar_visible_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1107 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1108
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1109 if (!FRAME_GTK_MENUBAR_WIDGET (f))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1110 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1111 create_menubar_widget (f);
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 /* Populate the menubar, but nothing is shown yet */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1115 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1116 Lisp_Object old_buffer;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1117 int count = specpdl_depth ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1118
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1119 old_buffer = Fcurrent_buffer ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1120 record_unwind_protect (Fset_buffer, old_buffer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1121 Fset_buffer (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer);
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 menu_create_menubar (f, menubar);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1124
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1125 Fset_buffer (old_buffer);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 714
diff changeset
1126 unbind_to (count);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1127 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1128
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1129 FRAME_MENUBAR_DATA (f) = Fcons (XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer, Qt);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1130
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1131 return (menubar_visible);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1132 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1133
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1134 /* Called from gtk_create_widgets() to create the inital menubar of a frame
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1135 before it is mapped, so that the window is mapped with the menubar already
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1136 there instead of us tacking it on later and thrashing the window after it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1137 is visible. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1138 int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1139 gtk_initialize_frame_menubar (struct frame *f)
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 create_menubar_widget (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1142 return set_frame_menubar (f, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1143 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1144
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1145
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1146 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1147 gtk_update_frame_menubar_internal (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1148 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1149 /* We assume the menubar contents has changed if the global flag is set,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1150 or if the current buffer has changed, or if the menubar has never
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1151 been updated before.
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 int menubar_contents_changed =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1154 (f->menubar_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1155 || NILP (FRAME_MENUBAR_DATA (f))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1156 || (!EQ (XFRAME_MENUBAR_DATA_LASTBUFF (f),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1157 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer)));
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 gboolean menubar_was_visible = GTK_WIDGET_VISIBLE (FRAME_GTK_MENUBAR_WIDGET (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1160 gboolean menubar_will_be_visible = menubar_was_visible;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1161 gboolean menubar_visibility_changed;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1162
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1163 if (menubar_contents_changed)
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 menubar_will_be_visible = set_frame_menubar (f, 0);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1168 menubar_visibility_changed = menubar_was_visible != menubar_will_be_visible;
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 (!menubar_visibility_changed)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1171 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1172 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1173 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1174
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1175 /* We hide and show the menubar's parent (which is actually the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1176 GtkHandleBox)... this is to simplify the code that destroys old
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1177 menu items, etc. There is no easy way to get the child out of a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1178 handle box, and I didn't want to add yet another stupid widget
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1179 slot to struct gtk_frame. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1180 if (menubar_will_be_visible)
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 gtk_widget_show_all (FRAME_GTK_MENUBAR_WIDGET (f)->parent);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1183 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1184 else
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 gtk_widget_hide_all (FRAME_GTK_MENUBAR_WIDGET (f)->parent);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1187 }
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 MARK_FRAME_SIZE_SLIPPED (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1190 }
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 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1193 gtk_update_frame_menubars (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1194 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1195 GtkWidget *menubar = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1196
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1197 assert (FRAME_GTK_P (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1198
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1199 menubar = FRAME_GTK_MENUBAR_WIDGET (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1200
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1201 if ((GTK_MENU_SHELL (menubar)->active) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1202 (GTK_MENU_SHELL (menubar)->have_grab) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1203 (GTK_MENU_SHELL (menubar)->have_xgrab))
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 return;
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1208 gtk_update_frame_menubar_internal (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1209 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1210
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1211 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1212 gtk_free_frame_menubars (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1213 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1214 GtkWidget *menubar_widget;
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 assert (FRAME_GTK_P (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1217
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1218 menubar_widget = FRAME_GTK_MENUBAR_WIDGET (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1219 if (menubar_widget)
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 gtk_widget_destroy (menubar_widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1222 }
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 static void popdown_menu_cb (GtkMenuShell *menu, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1226 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1227 popup_up_p--;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1228 }
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 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1231 gtk_popup_menu (Lisp_Object menu_desc, Lisp_Object event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1232 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1233 struct Lisp_Event *eev = NULL;
714
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1234 GtkWidget *widget = NULL;
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1235 GtkWidget *menu = NULL;
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1236 gpointer id = NULL;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1237
714
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1238 /* Do basic error checking first... */
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1239 if (SYMBOLP (menu_desc))
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1240 menu_desc = Fsymbol_value (menu_desc);
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1241 CHECK_CONS (menu_desc);
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1242 CHECK_STRING (XCAR (menu_desc));
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1243
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1244 /* Now lets get down to business... */
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1245 widget = menu_descriptor_to_widget (menu_desc);
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1246 menu = GTK_MENU_ITEM (widget)->submenu;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1247 gtk_widget_set_name (widget, "XEmacsPopupMenu");
714
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1248 id = gtk_object_get_data (GTK_OBJECT (widget), XEMACS_MENU_GUIID_TAG);
462
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 __activate_menu (GTK_MENU_ITEM (widget), id);
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 if (!NILP (event))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1253 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1254 CHECK_LIVE_EVENT (event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1255 eev = XEVENT (event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1256
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1257 if ((eev->event_type != button_press_event) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1258 (eev->event_type != button_release_event))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1259 wrong_type_argument (Qmouse_event_p, event);
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 else if (!NILP (Vthis_command_keys))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1262 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1263 /* If an event wasn't passed, use the last event of the event
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1264 sequence currently being executed, if that event is a mouse
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1265 event. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1266 eev = XEVENT (Vthis_command_keys);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1267 if ((eev->event_type != button_press_event) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1268 (eev->event_type != button_release_event))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1269 eev = NULL;
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1272 gtk_widget_show (menu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1273
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1274 popup_up_p++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1275 gtk_signal_connect (GTK_OBJECT (menu), "deactivate",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1276 GTK_SIGNAL_FUNC (popdown_menu_cb), NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1277
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1278 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1279 eev ? EVENT_BUTTON_BUTTON (eev) : 0,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1280 eev ? eev->timestamp : GDK_CURRENT_TIME);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1281 }
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 DEFUN ("gtk-build-xemacs-menu", Fgtk_build_xemacs_menu, 1, 1, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1284 Returns a GTK menu item from MENU, a standard XEmacs menu description.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1285 See the definition of `popup-menu' for more information on the format of MENU.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1286 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1287 (menu))
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 GtkWidget *w = menu_descriptor_to_widget (menu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1290
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1291 return (w ? build_gtk_object (GTK_OBJECT (w)) : Qnil);
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
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 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1296 syms_of_menubar_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1297 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1298 DEFSUBR (Fgtk_build_xemacs_menu);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1301 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1302 console_type_create_menubar_gtk (void)
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 CONSOLE_HAS_METHOD (gtk, update_frame_menubars);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1305 CONSOLE_HAS_METHOD (gtk, free_frame_menubars);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1306 CONSOLE_HAS_METHOD (gtk, popup_menu);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1309 void reinit_vars_of_menubar_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1310 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1311 dockable_menubar = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1312 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1313 tear_off_menus = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1314 #endif
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1317 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1318 vars_of_menubar_gtk (void)
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 Fprovide (intern ("gtk-menubars"));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1321 DEFVAR_BOOL ("menubar-dockable-p", &dockable_menubar /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1322 If non-nil, the frame menubar can be detached into its own top-level window.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1323 */ );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1324 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1325 DEFVAR_BOOL ("menubar-tearable-p", &tear_off_menus /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1326 If non-nil, menus can be torn off into their own top-level windows.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1327 */ );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1328 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1329 reinit_vars_of_menubar_gtk ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1330 }