Gnome2-PanelApplet

 view release on metacpan or  search on metacpan

xs/PanelApplet.xs  view on Meta::CPAN

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:

  <popup name="button3">
    <menuitem name="Properties Item"
              verb="Properties"
              _label="Properties ..."
              pixtype="stock"
              pixname="gtk-properties"/>
    <menuitem name="Help Item"
              verb="Help"
              _label="Help"
              pixtype="stock"
              pixname="gtk-help"/>
    <menuitem name="About Item"
              verb="About"
              _label="About ..."
              pixtype="stock"
              pixname="gnome-stock-about"/>
  </popup>

The verbs specified in this description can be mapped to callbacks in the
C<$verb_list>:

  $verb_list = {
    Properties => [\&properties_callback, 'data'],
    Help => \&help_callback,
    About => sub { about_callback(@_) },
  };

As you can see, the usual ways of specifying callbacks can be used:

=over

=item o Bare code references as in C<\&help_callback>

=item o Code references with data as in C<[\&properties_callback, 'data']>

=item o Closures as in C<sub { about_callback(@_) }>

=back

If you use the first or last form, i.e. if you don't specify user data, the
callback will be passed C<$default_data>.

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;



( run in 1.050 second using v1.01-cache-2.11-cpan-364913b4093 )