diff src/glyphs-gtk.c @ 563:183866b06e0b

[xemacs-hg @ 2001-05-24 07:50:48 by ben] Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c: -- defsymbol -> DEFSYMBOL. -- add an error type to all errors. -- eliminate the error functions in eval.c that let you just use Qerror as the type. -- redo the error API to be more consistent, sensibly named, and easier to use. -- redo the error hierarchy somewhat. create new errors: structure-formation-error, gui-error, invalid-constant, stack-overflow, out-of-memory, process-error, network-error, sound-error, printing-unreadable-object, base64-conversion- error; coding-system-error renamed to text-conversion error; some others. -- fix Mule problems in error strings in emodules.c, tooltalk.c. -- fix error handling in mswin open-network-stream. -- Mule-ize all sound files and clean up the headers. -- nativesound.h -> sound.h and used for all sound files. -- move some shared stuff into glyphs-shared.c: first attempt at eliminating some of the massive GTK code duplication. xemacs.mak: add glyphs-shared.c. xemacs-faq.texi: document how to debug X errors subr.el: fix doc string to reflect reality
author ben
date Thu, 24 May 2001 07:51:33 +0000
parents 0784d089fdc9
children fec27b06b4e5
line wrap: on
line diff
--- a/src/glyphs-gtk.c	Thu May 24 06:30:21 2001 +0000
+++ b/src/glyphs-gtk.c	Thu May 24 07:51:33 2001 +0000
@@ -153,7 +153,6 @@
 #include "bitmaps.h"
 
 DEFINE_IMAGE_INSTANTIATOR_FORMAT (gtk_resource);
-Lisp_Object Q_resource_type, Q_resource_id;
 Lisp_Object Qgtk_resource;
 #ifdef HAVE_WIDGETS
 Lisp_Object Qgtk_widget_instantiate_internal, Qgtk_widget_property_internal;
@@ -624,13 +623,13 @@
 			  width, height, &best_width, &best_height))
     /* this means that an X error of some sort occurred (we trap
        these so they're not fatal). */
-    signal_simple_error ("XQueryBestCursor() failed?", instantiator);
+    gui_error ("XQueryBestCursor() failed?", instantiator);
 
   if (width > best_width || height > best_height)
-    error_with_frob (instantiator,
-		     "pointer too large (%dx%d): "
-		     "server requires %dx%d or smaller",
-		     width, height, best_width, best_height);
+    signal_ferror_with_frob (Qgui_error, instantiator,
+			     "pointer too large (%dx%d): "
+			     "server requires %dx%d or smaller",
+			     width, height, best_width, best_height);
 #endif
 }
 
@@ -727,7 +726,7 @@
   GdkPixmap *pixmap;
 
   if (!DEVICE_GTK_P (XDEVICE (device)))
-    signal_simple_error ("Not a Gtk device", device);
+    gui_error ("Not a Gtk device", device);
 
   d = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
 
@@ -737,13 +736,13 @@
 
   pixmap = gdk_pixmap_new (d, gdk_image->width, gdk_image->height, gdk_image->depth);
   if (!pixmap)
-    signal_simple_error ("Unable to create pixmap", instantiator);
+    gui_error ("Unable to create pixmap", instantiator);
 
   gc = gdk_gc_new (pixmap);
   if (!gc)
     {
       gdk_pixmap_unref (pixmap);
-      signal_simple_error ("Unable to create GC", instantiator);
+      gui_error ("Unable to create GC", instantiator);
     }
 
   gdk_draw_image (GDK_DRAWABLE (pixmap), gc, gdk_image,
@@ -820,14 +819,14 @@
   pixmap = gdk_pixmap_new (d, gdk_image->width, gdk_image->height, gdk_image->depth);
 
   if (!pixmap)
-    signal_simple_error ("Unable to create pixmap", instantiator);
+    gui_error ("Unable to create pixmap", instantiator);
 
   gc = gdk_gc_new (pixmap);
 
   if (!gc)
     {
       gdk_pixmap_unref (pixmap);
-      signal_simple_error ("Unable to create GC", instantiator);
+      gui_error ("Unable to create GC", instantiator);
     }
 
   gdk_draw_image (GDK_DRAWABLE (pixmap), gc, gdk_image, 0, 0, 0, 0,
@@ -923,7 +922,7 @@
   gdk_color_white(cmap, &white);
 
   if (!DEVICE_GTK_P (XDEVICE (device)))
-    signal_simple_error ("Not a Gtk device", device);
+    gui_error ("Not a Gtk device", device);
 
   if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) &&
       (dest_mask & IMAGE_COLOR_PIXMAP_MASK))
@@ -1120,8 +1119,7 @@
 	  unlink (filename_out);
 	  errno = old_errno;
 	}
-      report_file_error ("Creating temp file",
-			 list1 (build_string (filename_out)));
+      report_file_error ("Creating temp file", build_string (filename_out));
     }
 
   CHECK_STRING (string);
@@ -1181,8 +1179,7 @@
 #endif
 
   if (fubar)
-    report_file_error ("Writing temp file",
-		       list1 (build_string (filename_out)));
+    report_file_error ("Writing temp file", build_string (filename_out));
 }
 
 struct color_symbol
@@ -1279,7 +1276,7 @@
   unsigned int w, h;
 
   if (!DEVICE_GTK_P (XDEVICE (device)))
-    signal_simple_error ("Not a Gtk device", device);
+    gui_error ("Not a Gtk device", device);
 
   if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
     type = IMAGE_COLOR_PIXMAP;
@@ -1454,7 +1451,7 @@
     }
 
   if (emsg)
-    signal_simple_error_2 (emsg, data, Qimage);
+    gui_error_2 (emsg, data, Qimage);
 
   bp = bits = (char *) alloca (PIXELS / 8);
 
@@ -1489,43 +1486,16 @@
        NILP (find_keyword_in_vector (instantiator, Q_resource_id))) 
       ||
       NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
-    signal_simple_error ("Must supply :file, :resource-id and :resource-type",
+    sferror ("Must supply :file, :resource-id and :resource-type",
 			 instantiator);
 }
 
 static Lisp_Object
-gtk_resource_normalize (Lisp_Object inst, Lisp_Object console_type, Lisp_Object dest_mask)
+gtk_resource_normalize (Lisp_Object inst, Lisp_Object console_type,
+			Lisp_Object dest_mask)
 {
-  /* This function can call lisp */
-  Lisp_Object file = Qnil;
-  struct gcpro gcpro1, gcpro2;
-  Lisp_Object alist = Qnil;
-
-  GCPRO2 (file, alist);
-
-  file = potential_pixmap_file_instantiator (inst, Q_file, Q_data, 
-					     console_type);
-
-  if (CONSP (file)) /* failure locating filename */
-    signal_double_file_error ("Opening pixmap file",
-			      "no such file or directory",
-			      Fcar (file));
-
-  if (NILP (file)) /* no conversion necessary */
-    RETURN_UNGCPRO (inst);
-
-  alist = tagged_vector_to_alist (inst);
-
-  {
-    alist = remassq_no_quit (Q_file, alist);
-    alist = Fcons (Fcons (Q_file, file), alist);
-  }
-
-  {
-    Lisp_Object result = alist_to_tagged_vector (Qgtk_resource, alist);
-    free_alist (alist);
-    RETURN_UNGCPRO (result);
-  }
+  return shared_resource_normalize (inst, console_type, dest_mask,
+				    Qgtk_resource);
 }
 
 static int
@@ -1572,7 +1542,7 @@
   Lisp_Object resource_id = find_keyword_in_vector (instantiator, Q_resource_id);
 
   if (!DEVICE_GTK_P (XDEVICE (device)))
-    signal_simple_error ("Not a GTK device", device);
+    gui_error ("Not a GTK device", device);
 
   type = resource_symbol_to_type (resource_type);
 
@@ -1599,7 +1569,7 @@
 {
   CHECK_SYMBOL (data);
   if (!resource_symbol_to_type (data))
-    signal_simple_error ("invalid resource type", data);
+    invalid_constant ("invalid resource type", data);
 }
 
 static void
@@ -1613,7 +1583,7 @@
       !resource_name_to_resource (data, IMAGE_BITMAP)
 #endif
       )
-    signal_simple_error ("invalid resource identifier", data);
+    invalid_constant ("invalid resource identifier", data);
 }
 
 #if 0
@@ -1809,11 +1779,11 @@
   Lisp_Object foreground, background;
 
   if (!DEVICE_GTK_P (XDEVICE (device)))
-    signal_simple_error ("Not a Gtk device", device);
+    gui_error ("Not a Gtk device", device);
 
   if (!STRINGP (data) ||
       strncmp ("FONT ", (char *) XSTRING_DATA (data), 5))
-    signal_simple_error ("Invalid font-glyph instantiator",
+    invalid_argument ("Invalid font-glyph instantiator",
 			 instantiator);
 
   if (!(dest_mask & IMAGE_POINTER_MASK))
@@ -1837,10 +1807,10 @@
     count = 4, mask_name[0] = 0;
 
   if (count != 2 && count != 4)
-    signal_simple_error ("invalid cursor specification", data);
+    syntax_error ("invalid cursor specification", data);
   source = gdk_font_load (source_name);
   if (! source)
-    signal_simple_error_2 ("couldn't load font",
+    gui_error_2 ("couldn't load font",
 			   build_string (source_name),
 			   data);
   if (count == 2)
@@ -1852,8 +1822,8 @@
       mask = gdk_font_load (mask_name);
       if (!mask)
 	/* continuable */
-	Fsignal (Qerror, list3 (build_string ("couldn't load font"),
-				build_string (mask_name), data));
+	Fsignal (Qgui_error, list3 (build_string ("couldn't load font"),
+				    build_string (mask_name), data));
     }
   if (!mask)
     mask_char = 0;
@@ -1991,7 +1961,7 @@
   Lisp_Object foreground, background;
 
   if (!DEVICE_GTK_P (XDEVICE (device)))
-    signal_simple_error ("Not a Gtk device", device);
+    gui_error ("Not a Gtk device", device);
 
   if (!(dest_mask & IMAGE_POINTER_MASK))
     incompatible_image_types (instantiator, dest_mask, IMAGE_POINTER_MASK);
@@ -2001,7 +1971,7 @@
 		      Qfile_name);
 
   if ((i = cursor_name_to_index (name_ext)) == -1)
-    signal_simple_error ("Unrecognized cursor-font name", data);
+    invalid_argument ("Unrecognized cursor-font name", data);
 
   gtk_initialize_pixmap_image_instance (ii, 1, IMAGE_POINTER);
   IMAGE_INSTANCE_GTK_CURSOR (ii) = gdk_cursor_new (i);
@@ -2220,7 +2190,7 @@
   Lisp_Object frame = DOMAIN_FRAME (domain);
 
   if (!DEVICE_GTK_P (XDEVICE (device)))
-    signal_simple_error ("Not a GTK device", device);
+    gui_error ("Not a GTK device", device);
 
   IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
 
@@ -2571,13 +2541,11 @@
 void
 syms_of_glyphs_gtk (void)
 {
-  defkeyword (&Q_resource_id, ":resource-id");
-  defkeyword (&Q_resource_type, ":resource-type");
 #ifdef HAVE_WIDGETS
-  defsymbol (&Qgtk_widget_instantiate_internal, "gtk-widget-instantiate-internal");
-  defsymbol (&Qgtk_widget_property_internal, "gtk-widget-property-internal");
-  defsymbol (&Qgtk_widget_redisplay_internal, "gtk-widget-redisplay-internal");
-  defsymbol (&Qgtk_widget_set_style, "gtk-widget-set-style");
+  DEFSYMBOL (Qgtk_widget_instantiate_internal);
+  DEFSYMBOL (Qgtk_widget_property_internal);
+  DEFSYMBOL (Qgtk_widget_redisplay_internal);
+  DEFSYMBOL (Qgtk_widget_set_style);
 #endif
 }