Mercurial > hg > xemacs-beta
view src/gtk-glue.c @ 4908:b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-01 Ben Wing <ben@xemacs.org>
* compiler.h:
Create a USED() macro to force unused-var warnings to go away,
in certain cases where it's inconvenient to do otherwise (e.g.
when THIS_IS_GTK in redisplay-xlike-inc.c).
* console-x.h:
Remove unneeded decls, make some static.
* redisplay-xlike-inc.c:
* console-xlike-inc.h: New file. Include defns from
redisplay-xlike-inc.c that may be useful in other XLIKE files.
Correct the handling of colors and font-style setting functions
in the xlike defns. Lots of fixes in the GTK-specific defns.
* depend: Regenerate.
* event-xlike-inc.c:
* event-xlike-inc.c (USE_UNICODE_MAP):
* event-xlike-inc.c (endif):
* gccache-gtk.c:
* gtk-glue.c (xemacs_list_to_gtklist):
* gtk-glue.c (xemacs_gtklist_to_list):
* gtk-glue.c (FROB):
* gtk-glue.c (face_to_gc):
* gtk-glue.c (face_to_style):
* gtk-glue.c (gdk_event_to_emacs_event):
* gtk-xemacs.h (struct _GtkXEmacs):
* gtk-xemacs.h (struct _GtkXEmacsClass):
* objects-xlike-inc.c:
Cosmetic, comment fixes.
* glyphs.c (pixmap_to_lisp_data):
Unused var fixes.
* gtk-glue.c:
* gccache-gtk.c:
* gtk-xemacs.c:
* gtk-xemacs.h:
* objects-xlike-inc.c:
* ui-gtk.c:
* ui-gtk.h:
* xgccache.c:
* xgccache.c (GC_CACHE_SIZE):
* xgccache.h:
Misc include-file fixes.
* objects-xlike-inc.c (XFUN):
* objects-xlike-inc.c (xlistfonts_checking_charset):
Combine some ifdeffed stuff using defs in console-xlike-inc.h.
* redisplay-gtk.c:
* redisplay-gtk.c (THIS_IS_GTK):
* redisplay-gtk.c (XLIKE_bevel_area):
* redisplay-gtk.c (XLIKE_ring_bell):
* redisplay-gtk.c (gdk_draw_text_image):
Fix numerous compile problems. Delete gtk_output_shadows(),
which mostly duplicates generic bevel_modeline(). Fix up
gtk_bevel_modeline() into XLIKE_bevel_area() and make use of
the style var properly to set the appropriate GTK constant.
* redisplay-x.c:
* redisplay-x.c (XLIKE_window_output_begin):
* redisplay-x.c (XLIKE_window_output_end):
* redisplay-x.c (XLIKE_bevel_area):
* redisplay-x.c (x_output_shadows):
* redisplay-x.c (XLIKE_ring_bell):
Make x_output_shadows be static. Change the defn of various
functions to look like XLIKE_foo() so it matches the calling
convention elsewhere.
* redisplay-xlike-inc.c:
* redisplay-xlike-inc.c (NEED_GCCACHE_H):
* redisplay-xlike-inc.c (XLIKE_text_width):
* redisplay-xlike-inc.c (XLIKE_get_gc):
* redisplay-xlike-inc.c (XLIKE_text_width_single_run):
* redisplay-xlike-inc.c (XFT_FROB_LISP_COLOR):
* redisplay-xlike-inc.c (XLIKE_output_xlike_pixmap):
* redisplay-xlike-inc.c (XLIKE_output_pixmap):
* redisplay-xlike-inc.c (XLIKE_output_vertical_divider):
* redisplay-xlike-inc.c (XLIKE_flash):
Lots of header fixes. Lots of stuff moved to console-xlike-inc.h.
Use XFUN() to generate function names instead of directly
calling XLIKE_PASTE(). Remove unnecessary prototypes.
Unify calls to text_width funs. Make XLIKE_get_gc non-static
since it's called from gtk. Change the color-function calls
and fill-style-setting calls to match the changes in
console-xlike-inc.h. Use USED() to avoid some warnings.
* symsinit.h:
Sort the prototypes, and add a fun `sort-symsinit' in a comment
that does the sorting (using sort-regexp-fields).
* symsinit.h (init_number):
* sysgtk.h: New file, wraps the various GTK headers.
* sysgdkx.h: New file, wraps <gtk/gdkx.h>. Keep this separate to
* event-gtk.h: Delete. Combine stuff into console-gtk.h.
help isolate X-specific code from GTK.
* device-gtk.c:
* event-gtk.c:
* console-gtk.h:
* frame-gtk.c:
* gccache-gtk.c:
* gccache-gtk.h:
* glyphs-gtk.c (gtk_colorize_image_instance):
* glyphs-gtk.h:
* gtk-xemacs.h:
* objects-gtk.c:
* objects-gtk.c (MAX_FONT_COUNT):
* ui-gtk.h:
Use sysgtk.h or sysgdkx.h instead of directly including GTK
headers. Don't include event-gtk.h.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 01 Feb 2010 02:15:28 -0600 |
parents | db7068430402 |
children | e813cf16c015 |
line wrap: on
line source
/* This file is part of XEmacs. XEmacs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. XEmacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with XEmacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02111-1301, USA. */ GtkType GTK_TYPE_ARRAY = 0; GtkType GTK_TYPE_STRING_ARRAY = 0; GtkType GTK_TYPE_FLOAT_ARRAY = 0; GtkType GTK_TYPE_INT_ARRAY = 0; GtkType GTK_TYPE_LISTOF = 0; GtkType GTK_TYPE_STRING_LIST = 0; GtkType GTK_TYPE_OBJECT_LIST = 0; GtkType GTK_TYPE_GDK_GC = 0; #include "console-gtk.h" #include "objects-gtk-impl.h" static GtkType xemacs_type_register (gchar *name, GtkType parent) { GtkType type_id; GtkTypeInfo info; info.type_name = name; info.object_size = 0; info.class_size = 0; info.class_init_func = NULL; info.object_init_func = NULL; info.reserved_1 = NULL; info.reserved_2 = NULL; type_id = gtk_type_unique (parent, &info); return (type_id); } static void xemacs_init_gtk_classes (void) { if (!GTK_TYPE_ARRAY) { GTK_TYPE_ARRAY = xemacs_type_register ("GtkArrayOf", 0); GTK_TYPE_STRING_ARRAY = xemacs_type_register ("GtkArrayOfString", GTK_TYPE_ARRAY); GTK_TYPE_FLOAT_ARRAY = xemacs_type_register ("GtkArrayOfFloat", GTK_TYPE_ARRAY); GTK_TYPE_INT_ARRAY = xemacs_type_register ("GtkArrayOfInteger", GTK_TYPE_ARRAY); GTK_TYPE_LISTOF = xemacs_type_register ("GtkListOf", 0); GTK_TYPE_STRING_LIST = xemacs_type_register ("GtkListOfString", GTK_TYPE_LISTOF); GTK_TYPE_OBJECT_LIST = xemacs_type_register ("GtkListOfObject", GTK_TYPE_LISTOF); GTK_TYPE_GDK_GC = xemacs_type_register ("GdkGC", GTK_TYPE_BOXED); } } static void xemacs_list_to_gtklist (Lisp_Object obj, GtkArg *arg) { CHECK_LIST (obj); if (arg->type == GTK_TYPE_STRING_LIST) { Lisp_Object temp = obj; GList *strings = NULL; while (!NILP (temp)) { CHECK_STRING (XCAR (temp)); temp = XCDR (temp); } temp = obj; while (!NILP (temp)) { strings = g_list_append (strings, XSTRING_DATA (XCAR (temp))); temp = XCDR (temp); } GTK_VALUE_POINTER (*arg) = strings; } else if (arg->type == GTK_TYPE_OBJECT_LIST) { Lisp_Object temp = obj; GList *objects = NULL; while (!NILP (temp)) { CHECK_GTK_OBJECT (XCAR (temp)); temp = XCDR (temp); } temp = obj; while (!NILP (temp)) { objects = g_list_append (objects, XGTK_OBJECT (XCAR (temp))->object); temp = XCDR (temp); } GTK_VALUE_POINTER (*arg) = objects; } else { ABORT (); } } static void __make_gtk_object_mapper (gpointer data, gpointer user_data) { Lisp_Object *rv = (Lisp_Object *) user_data; *rv = Fcons (build_gtk_object (GTK_OBJECT (data)), *rv); } static void __make_string_mapper (gpointer data, gpointer user_data) { Lisp_Object *rv = (Lisp_Object *) user_data; *rv = Fcons (build_string ((char *)data), *rv); } static Lisp_Object xemacs_gtklist_to_list (GtkArg *arg) { Lisp_Object rval = Qnil; if (GTK_VALUE_POINTER (*arg)) { if (arg->type == GTK_TYPE_STRING_LIST) { g_list_foreach ((GList*) GTK_VALUE_POINTER (*arg), __make_string_mapper, &rval); } else if (arg->type == GTK_TYPE_OBJECT_LIST) { g_list_foreach ((GList*) GTK_VALUE_POINTER (*arg), __make_gtk_object_mapper, &rval); } else { ABORT (); } } return (rval); } static void xemacs_list_to_array (Lisp_Object obj, GtkArg *arg) { CHECK_LIST (obj); #define FROB(ret_type,check_fn,extract_fn) \ do { \ Lisp_Object temp = obj; \ int length = 0; \ ret_type *array = NULL; \ \ while (!NILP (temp)) \ { \ check_fn (XCAR (temp)); \ length++; \ temp = XCDR (temp); \ } \ \ array = xnew_array_and_zero (ret_type, length + 2); \ temp = obj; \ length = 0; \ \ while (!NILP (temp)) \ { \ array[length++] = extract_fn (XCAR (temp)); \ temp = XCDR (temp); \ } \ \ GTK_VALUE_POINTER (*arg) = array; \ } while (0); if (arg->type == GTK_TYPE_STRING_ARRAY) { FROB (gchar *, CHECK_STRING, (gchar*) XSTRING_DATA); } else if (arg->type == GTK_TYPE_FLOAT_ARRAY) { FROB (gfloat, CHECK_FLOAT, extract_float); } else if (arg->type == GTK_TYPE_INT_ARRAY) { FROB (gint, CHECK_INT, XINT); } else { ABORT (); } #undef FROB } static GdkGC * face_to_gc (Lisp_Object face) { Lisp_Object device = Fselected_device (Qnil); return (gtk_get_gc (XDEVICE (device), Fspecifier_instance (Fget (face, Qfont, Qnil), device, Qnil, Qnil), Fspecifier_instance (Fget (face, Qforeground, Qnil), device, Qnil, Qnil), Fspecifier_instance (Fget (face, Qbackground, Qnil), device, Qnil, Qnil), Fspecifier_instance (Fget (face, Qbackground_pixmap, Qnil), device, Qnil, Qnil), Qnil)); } static GtkStyle * face_to_style (Lisp_Object face) { Lisp_Object device = Fselected_device (Qnil); GtkStyle *style = gtk_style_new (); int i; Lisp_Object font = Fspecifier_instance (Fget (face, Qfont, Qnil), device, Qnil, Qnil); Lisp_Object fg = Fspecifier_instance (Fget (face, Qforeground, Qnil), device, Qnil, Qnil); Lisp_Object bg = Fspecifier_instance (Fget (face, Qbackground, Qnil), device, Qnil, Qnil); Lisp_Object pm = Fspecifier_instance (Fget (face, Qbackground_pixmap, Qnil), device, Qnil, Qnil); for (i = 0; i < 5; i++) style->fg[i] = *COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (fg)); for (i = 0; i < 5; i++) style->bg[i] = *COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (bg)); if (IMAGE_INSTANCEP (pm)) { for (i = 0; i < 5; i++) style->bg_pixmap[i] = XIMAGE_INSTANCE_GTK_PIXMAP (pm); } style->font = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (font)); return (style); } static Lisp_Object gdk_event_to_emacs_event (GdkEvent *ev) { Lisp_Object event = Qnil; if (ev) { Lisp_Event *emacs_event; event = Fmake_event (Qnil, Qnil); emacs_event = XEVENT (event); if (!gtk_event_to_emacs_event (NULL, ev, emacs_event)) { /* We need to handle a few more cases than the normal event ** loop does. Mainly the double/triple click events. */ if ((ev->type == GDK_2BUTTON_PRESS) || (ev->type == GDK_3BUTTON_PRESS)) { set_event_type (emacs_event, misc_user_event); SET_EVENT_MISC_USER_BUTTON (emacs_event, ev->button.button); SET_EVENT_MISC_USER_MODIFIERS (emacs_event, 0); SET_EVENT_MISC_USER_X (emacs_event, (int) ev->button.x); SET_EVENT_MISC_USER_Y (emacs_event, (int) ev->button.y); if (ev->type == GDK_2BUTTON_PRESS) SET_EVENT_MISC_USER_FUNCTION (emacs_event, intern ("double-click")); else SET_EVENT_MISC_USER_FUNCTION (emacs_event, intern ("triple-click")); } else { Fdeallocate_event (event); event = Qnil; } } } return (event); }