Gnome2-PanelApplet

 view release on metacpan or  search on metacpan

xs/PanelApplet.xs  view on Meta::CPAN


	return verb_list;
}

static void
destroy_verb_list (BonoboUIVerb *verb_list)
{
	BonoboUIVerb *verb;

	warn ("verb list %p ...", verb_list);

	/* verb_list is NULL-terminated */
	for (verb = verb_list; verb != NULL; verb++) {
		GPerlCallback *callback = verb->user_data;
		warn ("  freeing associated callback %p", callback);
		gperl_callback_destroy (callback);
	}

	warn ("  freeing the verb list itself");
	g_free (verb_list);
}

/* ------------------------------------------------------------------------- */

MODULE = Gnome2::PanelApplet	PACKAGE = Gnome2::PanelApplet	PREFIX = panel_applet_

BOOT:
#include "register.xsh"
#include "boot.xsh"
	gperl_signal_set_marshaller_for (PANEL_TYPE_APPLET, "change-orient",
	                                 change_orient_marshal);

=for object Gnome2::PanelApplet::main (Gnome2::PanelApplet)
=cut

# FIXME: Segfaults for me in some locking function.
# GtkWidget * panel_applet_new (void);
# GtkWidget_ornull *
# panel_applet_new (class)
#     C_ARGS:
# 	/* void */

PanelAppletOrient panel_applet_get_orient (PanelApplet *applet);

guint panel_applet_get_size (PanelApplet *applet);

=for apidoc

=for signature (type, color, pixmap) = $applet->get_background

Depending on I<type>, I<color> or I<pixmap>, or both, may be I<undef>.

=cut
# PanelAppletBackgroundType panel_applet_get_background (PanelApplet *applet, GdkColor *color, GdkPixmap **pixmap);
void
panel_applet_get_background (PanelApplet *applet)
    PREINIT:
	PanelAppletBackgroundType type;
	GdkColor color;
	GdkPixmap *pixmap = NULL;
    PPCODE:
	type = panel_applet_get_background (applet, &color, &pixmap);
	EXTEND (sp, 3);
	PUSHs (sv_2mortal (newSVPanelAppletBackgroundType (type)));
	switch (type) {
	    case PANEL_NO_BACKGROUND:
		PUSHs (&PL_sv_undef);
		PUSHs (&PL_sv_undef);
	    case PANEL_COLOR_BACKGROUND:
		PUSHs (sv_2mortal (newSVGdkColor_copy (&color)));
		PUSHs (&PL_sv_undef);
	    case PANEL_PIXMAP_BACKGROUND:
		PUSHs (&PL_sv_undef);
		PUSHs (sv_2mortal (newSVGdkPixmap_noinc (pixmap)));
	}

gchar_own_ornull * panel_applet_get_preferences_key (PanelApplet *applet);

=for apidoc __gerror__
=cut
# void panel_applet_add_preferences (PanelApplet *applet, const gchar *schema_dir, GError **opt_error);
void
panel_applet_add_preferences (PanelApplet *applet, const gchar *schema_dir)
    PREINIT:
	GError *opt_error = NULL;
    CODE:
	panel_applet_add_preferences (applet, schema_dir, &opt_error);
	if (opt_error)
		gperl_croak_gerror (NULL, opt_error);

PanelAppletFlags panel_applet_get_flags (PanelApplet *applet);

void panel_applet_set_flags (PanelApplet *applet, PanelAppletFlags flags);

# void panel_applet_set_size_hints (PanelApplet *applet, const int *size_hints, int n_elements, int base_size);
void
panel_applet_set_size_hints (PanelApplet *applet, SV *size_hints, int base_size)
    PREINIT:
	AV *av;
	int *real_size_hints, n_elements, i;
    CODE:
	if (! (SvOK (size_hints) && SvRV (size_hints) && SvTYPE (SvRV (size_hints)) == SVt_PVAV))
		croak ("size hints must be an array reference");
	av = (AV *) SvRV (size_hints);
	n_elements = av_len (av) + 1;
	real_size_hints = g_new0 (int, n_elements);
	for (i = 0; i < n_elements; i++) {
		SV **svp = av_fetch (av, i, 0);
		if (svp && SvOK (*svp))
			real_size_hints[i] = SvIV (*svp);
	}
	panel_applet_set_size_hints (applet, real_size_hints, n_elements, base_size);

# FIXME: These need bonobo bindings.
# BonoboControl * panel_applet_get_control (PanelApplet *applet);
# BonoboUIComponent * panel_applet_get_popup_component (PanelApplet *applet);

=for apidoc

This method sets up menu entries for your applet and binds them to callbacks.
The XML for C<$xml> needs to have the following format:

xs/PanelApplet.xs  view on Meta::CPAN

The callbacks will be passed three arguments: the bonobo component they belong
to, the user data, and the verb they were installed for.  Currently, the bonobo
component will always be C<undef>, since we have no bonobo Perl bindings yet.

=cut
# void panel_applet_setup_menu (PanelApplet *applet, const gchar *xml, const BonoboUIVerb *verb_list, gpointer user_data);
void
panel_applet_setup_menu (PanelApplet *applet, const gchar *xml, SV *verb_list, SV *default_data=NULL)
    PREINIT:
	BonoboUIVerb *real_verb_list;
    CODE:
	real_verb_list = sv_to_verb_list (verb_list, default_data);
	/* We pass NULL for user_data here since, if it's non-NULL,
	 * panel_applet_setup_menu prefers it over the user data in the verbs.
	 * But that's where our GPerlCallbacks are, so we can't let that
	 * happen. */
	panel_applet_setup_menu (applet, xml, real_verb_list, NULL);
	/* FIXME: Looks like destroy_verb_list is never called.  Do we leak the
	 * whole applet? */
	g_object_set_data_full (G_OBJECT (applet),
			        "panel-perl-verb-list-key",
			        real_verb_list,
				(GDestroyNotify) destroy_verb_list);

# void panel_applet_setup_menu_from_file (PanelApplet *applet, const gchar *opt_datadir, const gchar *file, const gchar *opt_app_name, const BonoboUIVerb *verb_list, gpointer user_data);
void
panel_applet_setup_menu_from_file (applet, opt_datadir, file, opt_app_name, verb_list, default_data=NULL)
	PanelApplet *applet
	const gchar_ornull *opt_datadir
	const gchar *file
	const gchar_ornull *opt_app_name
	SV *verb_list
	SV *default_data
    PREINIT:
	BonoboUIVerb *real_verb_list;
    CODE:
	real_verb_list = sv_to_verb_list (verb_list, default_data);
	/* See comment above for an explanation for the NULL user data. */
	panel_applet_setup_menu_from_file (applet, opt_datadir, file, opt_app_name, real_verb_list, NULL);
	g_object_set_data_full (G_OBJECT (applet),
			        "panel-perl-verb-list-key",
			        real_verb_list,
				(GDestroyNotify) destroy_verb_list);

#if PANEL_APPLET_CHECK_VERSION(2, 10, 0)

gboolean panel_applet_get_locked_down (PanelApplet *applet);

void panel_applet_request_focus (PanelApplet *applet, guint32 timestamp);

#endif

#if PANEL_APPLET_CHECK_VERSION(2, 14, 0)

void panel_applet_set_background_widget (PanelApplet *applet, GtkWidget *widget);

#endif

void
GET_VERSION_INFO (class)
    PPCODE:
	EXTEND (SP, 3);
	PUSHs (sv_2mortal (newSViv (PANEL_APPLET_MAJOR_VERSION)));
	PUSHs (sv_2mortal (newSViv (PANEL_APPLET_MINOR_VERSION)));
	PUSHs (sv_2mortal (newSViv (PANEL_APPLET_MICRO_VERSION)));
	PERL_UNUSED_VAR (ax);

bool
CHECK_VERSION (class, major, minor, micro)
	int major
	int minor
	int micro
    CODE:
	RETVAL = PANEL_APPLET_CHECK_VERSION (major, minor, micro);
    OUTPUT:
	RETVAL

# --------------------------------------------------------------------------- #

MODULE = Gnome2::PanelApplet	PACKAGE = Gnome2::PanelApplet::Factory	PREFIX = panel_applet_factory_

=for apidoc
=for arg iid the IID string
=for arg applet_type the Perl package name (usually, 'Gnome2::PanelApplet')
=for arg func a callback (must return FALSE on failure)
=for arg data optional data to pass to the callback
=cut
# int panel_applet_factory_main (const gchar *iid, GType applet_type, PanelAppletFactoryCallback callback, gpointer data);
# int panel_applet_factory_main_closure (const gchar *iid, GType applet_type, GClosure *closure);
int
panel_applet_factory_main (class, const gchar *iid, const char *applet_type, SV *func, SV *data=NULL)
    PREINIT:
	GPerlCallback *callback;
    CODE:
	callback = factory_callback_create (func, data);
	RETVAL = panel_applet_factory_main (iid,
					    gperl_type_from_package (applet_type),
					    factory_callback,
					    callback);
	gperl_callback_destroy (callback);
    OUTPUT:
	RETVAL



( run in 1.075 second using v1.01-cache-2.11-cpan-5511b514fd6 )