source: trunk/third/rep-gtk/gnome-canvas-support.c @ 18404

Revision 18404, 3.6 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18403, which included commits to RCS files with non-trunk default branches.
RevLine 
[15285]1/* gnome-canvas-support.c -- helper functions for GNOME Canvas binding
[18403]2   $Id: gnome-canvas-support.c,v 1.1.1.2 2003-01-05 00:30:06 ghudson Exp $ */
[15285]3
4#include <config.h>
5#include <assert.h>
6#include <gnome.h>
7#include "rep-gtk.h"
8#include "rep-gnome.h"
9#include <string.h>
10
11static int
12list_length (repv list)
13{
14    repv len = Flength (list);
15    return (len && rep_INTP (len)) ? rep_INT (len) : 0;
16}
17
18DEFUN ("gnome-canvas-item-new", Fgnome_canvas_item_new,
19       Sgnome_canvas_item_new, (repv p_group, repv type_sym, repv scm_args),
20       rep_Subr3)
21{
[18403]22#ifdef XXX_FINISHED_PORTING
[15285]23    /* from guile-gnome/gnomeg.c */
24
25  GnomeCanvasItem* cr_ret;
26  GnomeCanvasGroup* c_group;
27
28  int n_args;
29  sgtk_object_info *info;
[18403]30  GParameter *args;
31  GObjectClass *objclass;
[15285]32
33  rep_DECLARE (1, p_group, sgtk_is_a_gtkobj (gnome_canvas_group_get_type (), p_group));
34  rep_DECLARE (2, type_sym, rep_SYMBOLP(type_sym));
35  n_args = list_length (scm_args);
36  rep_DECLARE (3, scm_args, n_args >= 0 && (n_args%2) == 0);
37  n_args = n_args/2;
38
39  info = sgtk_find_object_info (rep_STR(rep_SYM(type_sym)->name));
40  rep_DECLARE (2, type_sym, info != NULL);
41
42  c_group = (GnomeCanvasGroup*)sgtk_get_gtkobj (p_group);
[18403]43  objclass = g_type_class_ref (info->header.type);
44  args = sgtk_build_args (objclass, &n_args, scm_args,
[15285]45                          (char *) &Sgnome_canvas_item_new);
[18403]46  cr_ret = gnome_canvas_item_new (c_group, info->header.type, NULL);
47  gnome_canvas_item_construct (c_group, info->header.type,
48n_args, args);
49  sgtk_free_args (args, n_args);
50  g_type_class_unref (objclass);
[15285]51
52  return sgtk_wrap_gtkobj ((GtkObject*)cr_ret);
[18403]53#else
54  return Qnil;
55#endif
[15285]56}
57
58DEFUN ("gnome-canvas-item-set", Fgnome_canvas_item_set,
59       Sgnome_canvas_item_set, (repv p_item, repv scm_args), rep_Subr2)
60{
[18403]61#ifdef XXX_FINISHED_PORTING
[15285]62    /* from guile-gnome/gnomeg.c */
63
64  GnomeCanvasItem* c_item;
65  int n_args;
66  sgtk_object_info *info;
[18403]67  GParameter *args;
68  GObjectClass *objclass;
[15285]69
70  rep_DECLARE (1, p_item, sgtk_is_a_gtkobj (gnome_canvas_item_get_type (), p_item));
71  n_args = list_length (scm_args);
72  rep_DECLARE (2, scm_args, n_args >= 0 && (n_args%2) == 0);
73  n_args = n_args/2;
74
75  c_item = (GnomeCanvasItem*)sgtk_get_gtkobj (p_item);
76  info = sgtk_find_object_info_from_type (GTK_OBJECT_TYPE(c_item));
77  rep_DECLARE (1, p_item, info != NULL);
78 
[18403]79  objclass = g_type_class_ref (info->header.type);
80  args = sgtk_build_args (objclass, &n_args, scm_args, /* XXX p_item, */
[15285]81                          (char *) &Sgnome_canvas_item_set);
82  gnome_canvas_item_setv (c_item, n_args, args);
[18403]83  sgtk_free_args (args, n_args);
84  g_type_class_unref (objclass);
85#endif
[15285]86  return Qnil;
87}
88
89GnomeCanvasPoints *
90sgtk_gnome_canvas_points_new (repv data)
91{
92    repv len = Flength (data);
93    if (len && rep_INT (len) % 2 == 0)
94    {
95        int i, count = rep_INT (len);
96        GnomeCanvasPoints *p = gnome_canvas_points_new (count / 2);
97        if (rep_CONSP (data))
98        {
99            for (i = 0; i < count; i++)
100            {
101                p->coords[i] = sgtk_rep_to_double (rep_CAR (data));
102                data = rep_CDR (data);
103            }
104        }
105        else if (rep_VECTORP (data))
106        {
107            for (i = 0; i < count; i++)
108                p->coords[i] = sgtk_rep_to_double (rep_VECTI (data, i));
109        }
110        return p;
111    }
112    else
113        return 0;
114}
115
116repv
117sgtk_gnome_canvas_points_conversion (repv arg)
118{
119    extern repv Fgnome_canvas_points_new (repv);
120
121    if (rep_LISTP (arg) || rep_VECTORP (arg))
122        return Fgnome_canvas_points_new (arg);
123    else
124        return arg;
125}
126
127
128/* dl hooks / init */
129
130repv
131rep_dl_init (void)
132{
[18403]133    repv s = rep_push_structure ("gui.gtk-2.gnome-canvas");
[15285]134    sgtk_gnome_init_gnome_canvas_glue ();
[18403]135    gdk_rgb_init ();
[15285]136    rep_ADD_SUBR (Sgnome_canvas_item_new);
137    rep_ADD_SUBR (Sgnome_canvas_item_set);
138    return rep_pop_structure (s);
139}
Note: See TracBrowser for help on using the repository browser.