pike.git / src / post_modules / GTK2 / source / support.c

version» Context lines:

pike.git/src/post_modules/GTK2/source/support.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: support.c,v 1.19 2008/01/29 12:17:26 per Exp $ + || $Id: support.c,v 1.20 2008/01/30 13:29:55 per Exp $   */      #include <version.h>   #include <bignum.h>   #include <stdarg.h>      #ifndef INIT_VARIABLES   extern struct program *image_color_program;   extern struct program *image_program;   #endif
pike.git/src/post_modules/GTK2/source/support.c:270:    call_c_initializers(o);    ((struct object_wrapper *)o->storage)->obj=obj;    pgtk2__init_object(o);       /* Extra ref already added in pgtk2__init_object */    push_object(o);    return;   }       - void push_pgdk2object(void *obj, struct program *def) { + void push_pgdk2object(void *obj, struct program *def, int owned) {    struct object *o;    if (!obj) {    push_int(0);    return;    }    o=low_clone(def);    call_c_initializers(o);    ((struct object_wrapper *)o->storage)->obj=obj; -  -  /* TODO: Check all usage of this function to see that it does not -  * assume 2 refs on the object instead of 1. -  */ +  ((struct object_wrapper *)o->storage)->owned = owned;    push_object(o);    return;   }      GObject *get_pg2object(struct object *from, struct program *type) {    struct object_wrapper * o;    if (!from)    return NULL;    o=(struct object_wrapper *)get_storage(from,type);    if (!o)
pike.git/src/post_modules/GTK2/source/support.c:423:    break;    case GDK_VISUAL_STATIC_GRAY:    res.r=res.g=res.b=(pix*256)/1<<i->visual->depth;    break;    }    return res;   }      void push_atom(GdkAtom a) {    /* this should really be inserted in the GDK.Atom mapping. */ -  push_pgdk2object((void *)a,pgdk2__atom_program); +  push_pgdk2object((void *)a,pgdk2__atom_program,0);   }      void push_Xpseudo32bitstring(void *f, int nelems) {    if (sizeof(long)!=4) {    long *q=(long *)f;    int *res=(int *)xalloc(nelems*4),i;    for (i=0; i<nelems; i++)    res[i]=q[i];    push_string(make_shared_binary_string2((const p_wchar2 *)res,nelems));    xfree(res);
pike.git/src/post_modules/GTK2/source/support.c:458:   */      void push_gdk_event(GdkEvent *e) {    if (e) {    GdkEvent *f=g_malloc(sizeof(GdkEvent));    if (f==NULL) {    push_int(0);    return;    }    *f=*e; -  push_gdkobject(f,event); +  push_gdkobject(f,event,1);    } else    push_int(0);   }      enum { PUSHED_NOTHING, PUSHED_VALUE, NEED_RETURN, };      /*   static int pgtk2_push_selection_data_param( GValue *a )   {    push_pgdk2object( GTK_VALUE_POINTER(*a), pgtk2_selection_data_program);
pike.git/src/post_modules/GTK2/source/support.c:488:      /*   static int pgtk2_push_ctree_node_param(const GValue *a )   {    push_pgdk2object( GTK_VALUE_POINTER(*a), pgtk2_ctree_node_program);    return PUSHED_VALUE;   }   */      static int pgtk2_push_gdk_drag_context_param(const GValue *a) { -  push_gdkobject(g_value_get_pointer(a),drag_context); +  push_gdkobject(g_value_get_pointer(a),drag_context,0);    return PUSHED_VALUE;   }      static int pgtk2_push_gdk_event_param(const GValue *a) {    push_gdk_event(g_value_get_boxed(a));    return NEED_RETURN;   }      static int pgtk2_push_gdk_rectangle_param(const GValue *a) {    GdkRectangle *r = (GdkRectangle *) g_value_get_boxed(a);
pike.git/src/post_modules/GTK2/source/support.c:570:    push_string(empty_pike_string);    return PUSHED_VALUE;   }      static int pgtk2_push_object_param(const GValue *a) {    GObject *obj;    gpointer *gp;    if (g_type_is_a(G_VALUE_TYPE(a),G_TYPE_BOXED)) {    gp=g_value_get_boxed(a);    if (G_VALUE_HOLDS(a,g_type_from_name("GdkColor"))) { -  push_gdkobject(gp,color); +  push_gdkobject(gp,color,0);    } else if (G_VALUE_HOLDS(a,g_type_from_name("GtkTreePath"))) { -  pgtk2_push_gobjectclass(gp,pgtk2_tree_path_program); +  push_pgdk2object(gp,pgtk2_tree_path_program,0);    } else if (G_VALUE_HOLDS(a,g_type_from_name("GdkRectangle"))) { -  push_gdkobject(gp,rectangle); +  push_gdkobject(gp,rectangle,0);    } else if (G_VALUE_HOLDS(a,g_type_from_name("GdkRegion"))) { -  push_gdkobject(gp,region); +  push_gdkobject(gp,region,0);    }    } else {    obj=g_value_get_object(a);    if (obj)    push_gobject(obj);    }    return PUSHED_VALUE;   }      static int pgtk2_push_pike_object_param(const GValue *a) {
pike.git/src/post_modules/GTK2/source/support.c:1124:    case G_TYPE_POINTER:    case G_TYPE_PARAM:    default:    {    if (gps->value_type==g_type_from_name("GdkColor")) {    GdkColor *gc;    gc=g_malloc(sizeof(GdkColor));    if (gc==NULL)    Pike_error("Out of memory allocating %d bytes\n",sizeof(GdkColor));    g_object_get(g,prop,gc,NULL); -  push_gdkobject(gc,color); +  push_gdkobject(gc,color,1);    } else {    Pike_error("Unable to handle type %s.\n",g_type_name(gps->value_type));    }    }    break;    }   }      void pgtk2_destroy_store_data(gpointer data) {    struct store_data *sd=(struct store_data *)data;
pike.git/src/post_modules/GTK2/source/support.c:1251:    default:    Pike_error("Unable to handle type %d - %s.\n",gt,g_type_name(gt));    }   }      int pgtk2_tree_sortable_callback(GtkTreeModel *model, GtkTreeIter *a,    GtkTreeIter *b, struct signal_data *d) {    int res;   /* push_gobjectclass(model,pgtk2_tree_model_program); */    push_gobject(model); -  push_gobjectclass(a,pgtk2_tree_iter_program); -  push_gobjectclass(b,pgtk2_tree_iter_program); +  push_pgdk2object(a,pgtk2_tree_iter_program,0); +  push_pgdk2object(b,pgtk2_tree_iter_program,0);    push_svalue(&d->args);    apply_svalue(&d->cb,4);    res=Pike_sp[-1].u.integer;    pop_stack();    return res;   }      GObject *pgtk2_create_new_obj_with_properties(GType type, struct mapping *m) {    GParamSpec *pspec;    GObject *obj;