public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* Added a bunch of GDK routines.
@ 2003-05-02  1:25 Marko Rauhamaa
  2003-05-11 23:28 ` Kevin Ryde
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Marko Rauhamaa @ 2003-05-02  1:25 UTC (permalink / raw)
  To: guile-gtk

Summary: Added a bunch of GDK routines.

Detailed Notes:

 - The new code is mainly additional functionality. It compiles but I
   haven't run any of the code yet.

 - build-guile-gtk-1.2: Added a new predefined type 'char for
   gdk_gc_set_dashes.

 - build-guile-gtk-1.2 and guile-gtk.[ch]: Added a new predefined type
   'segment for gdk_draw_segments.

 - gdk-1.2.defs: Chose not to implement these functions:

   * gdk_init, gdk_init_check, gdk_exit (because gtk+ calls them
     automatically)

   * gdk_set_sm_client_id (because I don't understand it yet)

   * gdk_get_use_xshm, gdk_set_use_xshm (because they are unlikely to be
     of concern to guile applications)

   * gdk_gc_new_with_values (because the individual field setters and
     gdk_gc_new are fully sufficient and convenient).

 - gdk-1.2.defs and guile-gtk.h: Added a new auxiliary data type
   sgtk_timestamp, which is typedef'ed from guint32; that way
   'current-time can be specified symbolically in scheme code.

 - gdk-1.2.defs: Removed GdkGCValuesMask. It was never used and, I
   think, will not be needed (see also gdk_gc_get_values below).

 - gdk-1.2.defs: Defined an alias GdkWChar for uint for
   gdk_draw_text_wc. (I trust uint to correspond to guint32 because
   currently there is no alternative.)

 - gdk-1.2.defs: Added the types GdkFillRule and GdkRegion for GDK's
   region routines.

 - gdk-1.2.defs: Added the functions gdk_gc_copy, gdk_gc_set_dashes,
   gdk_rectangle_intersect, gdk_rectangle_union, gdk_region_new,
   gdk_region_polygon, gdk_region_destroy, gdk_regions_intersect,
   gdk_regions_union, gdk_regions_subtract, gdk_regions_xor,
   gdk_region_union_with_rect, gdk_region_offset, gdk_region_shrink,
   gdk_region_empty, gdk_region_equal, gdk_region_point_in,
   gdk_region_rect_in, gdk_region_get_clipbox, gdk_draw_segments,
   gdk_draw_text_wc, gdk_wcstombs, gdk_mbstowcs, gdk_get_display,
   gdk_pointer_grab, gdk_pointer_ungrab, gdk_pointer_is_grabbed,
   gdk_keyboard_grab, gdk_keyboard_ungrab, gdk_key_repeat_disable,
   gdk_key_repeat_restore, gdk_error_trap_push, gdk_error_trap_pop.

 - gdk-1.2.defs: Added the function gdk_gc_get_values. Instead of
   GdkGCValuesMask, it returns a list with the GC values as elements.
   (See also gdk_gc_get_values_scm below.)

 - gdk-support.c and guile-gtk.h: Added extra glue code for
   gdk_wcstombs_scm, gdk_mbstowcs_scm, gdk_rectangle_intersect_scm,
   gdk_rectangle_union_scm, gdk_region_union_with_rect_scm,
   gdk_region_rect_in_scm, gdk_region_get_clipbox_scm. (Note how much
   manual coding is still necessary!)

 - gdk-support.c and guile-gtk.h: Added also the extra glue function
   gdk_gc_get_values_scm. Had to resort to direct extern references to
   gdk-glue.c:

   extern sgtk_boxed_info sgtk_gdk_color_info, sgtk_gdk_font_info,
     sgtk_gdk_window_info;

   extern sgtk_enum_info sgtk_gdk_function_info, sgtk_gdk_fill_info,
     sgtk_gdk_subwindow_mode_info, sgtk_gdk_line_style_info,
     sgtk_gdk_cap_style_info, sgtk_gdk_join_style_info;

   There should maybe be a cleaner way to refer to entities defined in
   gdk-1.2.defs.

 - guile-gtk.[ch]: Made xmalloc and xrealloc non-static so I could use
   xmalloc in gdk_wcstombs_scm and gdk_mbstowcs_scm.

 - guile-gtk.h: Removed duplicate declarations of gtk_style_fg_gc and
   gtk_style_bg_gc.

-- 
Marko Rauhamaa      mailto:marko@pacujo.net     http://pacujo.net/marko/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Added a bunch of GDK routines.
  2003-05-02  1:25 Added a bunch of GDK routines Marko Rauhamaa
@ 2003-05-11 23:28 ` Kevin Ryde
  2003-05-12 18:06   ` Marko Rauhamaa
  2003-06-06 22:23 ` GdkWChar (was: Added a bunch of GDK routines.) Kevin Ryde
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Kevin Ryde @ 2003-05-11 23:28 UTC (permalink / raw)
  To: Marko Rauhamaa; +Cc: guile-gtk

Marko Rauhamaa <marko@pacujo.net> writes:
>
>    * gdk_gc_new_with_values (because the individual field setters and
>      gdk_gc_new are fully sufficient and convenient).

Personally I'd found individual set calls a bit tedious, and instead
made myself a keyword version, eg.

    (c-gdk-gc-new-with-attrs (gtk-widget-window draw)
			      #:foreground      cross-colour
			      #:exposures       #f
			      #:line-attributes '(1 on-off-dash butt miter))
  
I think the individual calls get combined at the X level, so I guess
there's nothing lost by not having a with_values variant.

GdkGCValues might still have a use for gtk_gc_get, though I don't know
whether that function can be made to work.  I guess the GdkGC returned
would have to know to call gtk_gc_release.

>  - guile-gtk.[ch]: Made xmalloc and xrealloc non-static

Might be prudent to rename them to sgtk_something.

I guess it might be nice to use scm_malloc to gc if out of memory, but
I'm not smart enough to know if that'd cause subtle problems.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Added a bunch of GDK routines.
  2003-05-11 23:28 ` Kevin Ryde
@ 2003-05-12 18:06   ` Marko Rauhamaa
  2003-05-12 18:56     ` Marko Rauhamaa
  0 siblings, 1 reply; 7+ messages in thread
From: Marko Rauhamaa @ 2003-05-12 18:06 UTC (permalink / raw)
  To: guile-gtk

Kevin Ryde <user42@zip.com.au>:

> Marko Rauhamaa <marko@pacujo.net> writes:
> >  - guile-gtk.[ch]: Made xmalloc and xrealloc non-static
> 
> Might be prudent to rename them to sgtk_something.

Might be.

> I guess it might be nice to use scm_malloc to gc if out of memory, but
> I'm not smart enough to know if that'd cause subtle problems.

The current situation is not perfect since we are not telling the
garbage collector of the "hidden" memory we are allocating. Even when we
are not using scm_must_malloc, we should call scm_done_malloc with a
positive argument during allocation and with a negative argument when we
free memory to let GC have an idea of memory consumption
(http://home.thezone.net/~gharvey/guile/gc/gc-mistakes_3.html).

If we call scm_must_malloc (and we should), we scm_done_malloc is not
necessary during allocation, but you still have to call it with a
negative size at freeing time.

Finally, the GTK, GDK and Xlib routines also allocate memory, and
ideally we'd like to be able to report it to guile's GC. The 'size
option is already there (albeit currently unused) to report the size to
build-guile-gtk-1.2.

The only "subtlety" I'm aware of is smobs that are not yet tied to
other smobs. They might accidentally get wiped out during GC.


Marko

-- 
Marko Rauhamaa      mailto:marko@pacujo.net     http://pacujo.net/marko/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Added a bunch of GDK routines.
  2003-05-12 18:06   ` Marko Rauhamaa
@ 2003-05-12 18:56     ` Marko Rauhamaa
  0 siblings, 0 replies; 7+ messages in thread
From: Marko Rauhamaa @ 2003-05-12 18:56 UTC (permalink / raw)
  To: guile-gtk

Marko Rauhamaa <marko@pacujo.net>:

> If we call scm_must_malloc (and we should), we scm_done_malloc is not
> necessary during allocation, but you still have to call it with a
> negative size at freeing time.

I remade gdk-support.c independent of xmalloc and started using
scm_must_malloc. guile-gtk.c still uses xmalloc.

	* guile-gtk.h, guile-gtk.c (xmalloc, xrealloc): Make static again.
	* gdk-support.c (gdk_wcstombs_interp): Rely on null-termination.
	* gdk-support.c (gdk_mbstowcs_interp,
	gdk_colormap_alloc_colors_interp): Use scm_must_malloc instead of
	xmalloc.


Marko

-- 
Marko Rauhamaa      mailto:marko@pacujo.net     http://pacujo.net/marko/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* GdkWChar (was: Added a bunch of GDK routines.)
  2003-05-02  1:25 Added a bunch of GDK routines Marko Rauhamaa
  2003-05-11 23:28 ` Kevin Ryde
@ 2003-06-06 22:23 ` Kevin Ryde
  2003-06-14 23:58 ` gdk-gc-copy comments " Kevin Ryde
  2003-06-20 23:54 ` sgtk_timestamp returns " Kevin Ryde
  3 siblings, 0 replies; 7+ messages in thread
From: Kevin Ryde @ 2003-06-06 22:23 UTC (permalink / raw)
  To: guile-gtk

Marko Rauhamaa <marko@pacujo.net> writes:
>
>  - gdk-1.2.defs: Defined an alias GdkWChar for uint for
>    gdk_draw_text_wc. (I trust uint to correspond to guint32 because
>    currently there is no alternative.)

Presumably one day guile will get its own notion of chars bigger than
a byte.  Probably no alternative to plain integers until then.  I'm
thinking the words below can cover the present situation at least.


[General conventions:]

Strings
     Gtk generally uses strings encoded in UTF-8.  Guile (version 1.6)
     has no direct notion of multi-byte characters in strings, so
     applications will need to take care when in a non-ASCII or
     non-Latin locale.

     Converting to `GdkWChar' with `gdk-mbstowc' (*note Gdk Module::) is
     one way to identify character boundaries at least.


[Gdk Module:]

`GdkWChar'
     Currently `GdkWChar' values are represented as integers, and
     `GdkWChar' strings as vectors of integers.  So for instance
     `gdk-mbstowc' returns such a vector (or `#f' if conversion fails).

     Note that this representation might change in the future if Guile
     gets its own notion of characters bigger than 8 bits.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* gdk-gc-copy comments (was: Added a bunch of GDK routines.)
  2003-05-02  1:25 Added a bunch of GDK routines Marko Rauhamaa
  2003-05-11 23:28 ` Kevin Ryde
  2003-06-06 22:23 ` GdkWChar (was: Added a bunch of GDK routines.) Kevin Ryde
@ 2003-06-14 23:58 ` Kevin Ryde
  2003-06-20 23:54 ` sgtk_timestamp returns " Kevin Ryde
  3 siblings, 0 replies; 7+ messages in thread
From: Kevin Ryde @ 2003-06-14 23:58 UTC (permalink / raw)
  To: guile-gtk

[-- Attachment #1: Type: text/plain, Size: 717 bytes --]

Marko Rauhamaa <marko@pacujo.net> writes:
>
>  - gdk-1.2.defs: Added the functions gdk_gc_copy,

I found the comments in the defs file for this a bit confusing.  At
first I thought it was saying there was something wrong with
gdk-gc-copy (which there's not).

I suppose it could be made clear that what's being talked about is a
new sort of duplicate or create-and-copy operation, but since as
stated that's either not possible or not very natural, I'd propose
just to remove the remarks.  If one really started writing about all
the stylistic idiosyncrasies of gtk and X it could quickly turn into a
small book :-).

        * gdk-1.2.defs (gdk_gc_copy): Remove comments about hypothetical
        create-and-copy.


[-- Attachment #2: gdk-1.2.defs.gc-copy-comment.diff --]
[-- Type: text/plain, Size: 663 bytes --]

--- gdk-1.2.defs.~1.32.~	2003-06-15 09:28:33.000000000 +1000
+++ gdk-1.2.defs	2003-06-15 09:48:51.000000000 +1000
@@ -538,17 +538,6 @@
   (GdkGC (copy #f))
   ((GdkWindow window)))
 
-; You can't convert gdk_gc_copy into one that returns the copy because
-; there is no way to determine the window of src_gc, and you can't
-; create dst_gc without a window. You could create a function like this:
-;
-;   (define-func gdk_gc_copy_interp
-;     GdkGC
-;     ((GdkWindow window)
-;      (GdkGC gc)))
-;
-; but it would not be any more natural or flexible to use than the
-; interface of the original C function.
 (define-func gdk_gc_copy
   none
   ((GdkGC dst_gc)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* sgtk_timestamp returns (was: Added a bunch of GDK routines.)
  2003-05-02  1:25 Added a bunch of GDK routines Marko Rauhamaa
                   ` (2 preceding siblings ...)
  2003-06-14 23:58 ` gdk-gc-copy comments " Kevin Ryde
@ 2003-06-20 23:54 ` Kevin Ryde
  3 siblings, 0 replies; 7+ messages in thread
From: Kevin Ryde @ 2003-06-20 23:54 UTC (permalink / raw)
  To: guile-gtk

[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]

Marko Rauhamaa <marko@pacujo.net> writes:
>
>  - gdk-1.2.defs and guile-gtk.h: Added a new auxiliary data type
>    sgtk_timestamp, which is typedef'ed from guint32; that way
>    'current-time can be specified symbolically in scheme code.

I believe this change has broken gdk-event-time and
gdk-event-get-time.  The reason for naming things in the ChangeLog is
so it's not a matter of guesswork whey they were last touched.  Any
change to working code also needs to be actually run to see it has the
desired effect.

The following program exhibits the problem.  Moving the mouse over the
resulting window produces an error popup from the default trampoline
about enum->symbol in gdk-event-time.

        (use-modules (gtk gtk)
                     (gtk gdk))
        (define w (gtk-window-new 'toplevel))
        (gtk-widget-add-events w '(pointer-motion-mask))
        (gtk-signal-connect w "motion_notify_event"
                            (lambda (event)
                              (gdk-event-time event)))
        (gtk-widget-show-all w)
        (gtk-main)

I propose to make the following,

        * gdk-1.2.defs (gdk_event_get_time, gdk_event_time): Revert change by
        Marko to return sgtk_timestamp, it doesn't work for arbitrary time
        values.  Go back to return plain uint.


[-- Attachment #2: gdk-1.2.defs.timestamp-return.diff --]
[-- Type: text/plain, Size: 736 bytes --]

--- gdk-1.2.defs.~1.34.~	2003-06-19 11:00:16.000000000 +1000
+++ gdk-1.2.defs	2003-06-20 18:32:23.000000000 +1000
@@ -23,6 +23,10 @@
 
 ;;; Gdk enums
 
+;; Note that sgtk_timestamp cannot be used for a timestamp return value,
+;; since an of course an actual timestamp value is an arbitrary number, not
+;; merely the value here.
+;;
 (define-enum sgtk_timestamp
   (current-time GDK_CURRENT_TIME))
 
@@ -1493,7 +1497,7 @@
   ((GdkEvent event)))
 
 (define-func gdk_event_get_time
-  sgtk_timestamp
+  uint
   ((GdkEvent event)))
 
 (define-func gdk_event_send_client_message_interp
@@ -1545,7 +1549,7 @@
   ((GdkEvent event)))
 
 (define-func gdk_event_time
-  sgtk_timestamp
+  uint
   ((GdkEvent event)))
 
 (define-func gdk_event_x

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-06-20 23:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-02  1:25 Added a bunch of GDK routines Marko Rauhamaa
2003-05-11 23:28 ` Kevin Ryde
2003-05-12 18:06   ` Marko Rauhamaa
2003-05-12 18:56     ` Marko Rauhamaa
2003-06-06 22:23 ` GdkWChar (was: Added a bunch of GDK routines.) Kevin Ryde
2003-06-14 23:58 ` gdk-gc-copy comments " Kevin Ryde
2003-06-20 23:54 ` sgtk_timestamp returns " Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).