Gtk-Perl

 view release on metacpan or  search on metacpan

Gtk/xs/Gtk.xs  view on Meta::CPAN

		int type;
		struct ufuncs *ufp;
		watch_var_data *wdata;
		MAGIC **mgp;
		MAGIC *mg;
		MAGIC *mg_list;
		
		if (SvROK(sv) && SvRV(sv)) {
			sv = (SV*)SvRV(sv);
		}
		/* code basically stolen from perl-tk */
		if (SvTHINKFIRST(sv) && SvREADONLY(sv))
			croak("Cannot trace readonly variable");
		SvUPGRADE(sv, SVt_PVMG);
		mg_list = SvMAGIC(sv);
		SvMAGIC(sv) = NULL;
		sv_magic(sv, 0, 'U', 0, 0);
		wdata = g_new0(watch_var_data, 1);
		wdata->id = WATCH_VAR_ID;
		ufp = g_new0(struct ufuncs, 1);
		ufp->uf_val = watch_var_val;
		ufp->uf_set = watch_var_set;
		ufp->uf_index = (IV)wdata;
		
		mg = SvMAGIC(sv);
		mg->mg_ptr = (char *) ufp;
		mg->mg_len = sizeof(struct ufuncs);
		SvMAGIC(sv) = mg_list;
		mgp = &SvMAGIC(sv);
		while ((mg_list = *mgp))
			mgp = &mg_list->mg_moremagic;
		*mgp = mg;
		
		args = newAV();
		
		PackCallbackST(args, 3);
		
		wdata->sv = sv;
		wdata->args = args;
		RETVAL = g_source_add(priority, TRUE, &watch_var_funcs, wdata,
			NULL, NULL);
		
	}
	OUTPUT:
	RETVAL

void
watch_remove(Class, tag)
	int	tag
	CODE:
	g_source_remove(tag);

 #DESC: Remove a timeout handler identified by tag.
void
timeout_remove(Class, tag)
	int	tag
	CODE:
	gtk_timeout_remove(tag);

 #DESC: Add an idle handler (a function that gets called when the main loop
 #is not busy servicing toolkit events).
 #handler is called with the additional arguments as parameters.
 #RETURNS: An integer that identifies the handler 
 #(for use in Gtk::idle_remove)..
 #ARG: $handler subroutine (generic subroutine)
 #ARG: ... list (additional args for $handler)
 #SEEALSO: Gtk::idle_remove, Gtk::timeout_remove, Gtk::timeout_add, Gtk::idle_add_priority
int
idle_add(Class, handler, ...)
	SV *	Class
	SV *	handler
	CODE:
	{
		AV * args = newAV();
		/*SV * arg;
		int i,j;
		int type;
		args = newAV();*/
		
		PackCallbackST(args, 1);
		
		RETVAL = gtk_idle_add_full(GTK_PRIORITY_DEFAULT, NULL, 
				pgtk_generic_handler, (gpointer)args, pgtk_destroy_handler);
		
	}
	OUTPUT:
	RETVAL

 #DESC: Add an idle handler (a function that gets called when the main loop
 #is not busy servicing toolkit events).
 #handler is called with the additional arguments as parameters.
 #The lower the value of priority, the highter the priority of the handler.
 #RETURNS: An integer that identifies the handler 
 #(for use in Gtk::idle_remove)..
 #ARG: $handler subroutine (generic subroutine)
 #ARG: ... list (additional args for $handler)
 #SEEALSO: Gtk::idle_remove, Gtk::timeout_remove, Gtk::timeout_add
int
idle_add_priority (Class, priority, handler, ...)
	SV *	Class
	int     priority
	SV *	handler
	CODE:
	{
		AV * args;
		SV * arg;
		int i,j;
		int type;
		args = newAV();
		
		PackCallbackST(args, 2);
		
		RETVAL = gtk_idle_add_full(priority, NULL, 
				pgtk_generic_handler, (gpointer)args, pgtk_destroy_handler);
		
	}
	OUTPUT:
	RETVAL

 #DESC: Remove an idle handler identified by tag.
void
idle_remove(Class, tag)
	SV *	Class
	int	tag
	CODE:
	gtk_idle_remove(tag);

 #DESC: Add an handler to be called at initialization time.
 #ARG: $handler subroutine (generic subroutine)
 #ARG: ... list (additional args for $handler)
void
init_add(Class, handler, ...)
	SV *	Class
	SV *	handler
	CODE:
	{
		AV * args;
		SV * arg;
		int i,j;
		int type;
		args = newAV();
		
		PackCallbackST(args, 1);
		
		gtk_init_add(init_handler, (gpointer)args);
	}

void
mod_init_add(Class, module, handler, ...)
	SV *	Class



( run in 3.619 seconds using v1.01-cache-2.11-cpan-2398b32b56e )