Exemple #1
0
/* panel_append */
static int _panel_append(Panel * panel, PanelPosition position,
		char const * applet)
{
	if(position == PANEL_POSITION_TOP)
		return panel_window_append(panel->windows[PANEL_POSITION_TOP],
				applet);
	return -error_set_code(1, "%s", _("Invalid panel position"));
}
Exemple #2
0
/* panel_load */
int panel_load(Panel * panel, PanelPosition position, char const * applet)
{
	PanelWindow * window;
	PanelAppletHelper * helper;
	Plugin * plugin;
	PanelAppletDefinition * pad;
	PanelApplet * pa;
	GtkWidget * widget = NULL;
	GtkWidget * vbox;

	if(position == PANEL_POSITION_BOTTOM && panel->bottom != NULL)
	{
		window = panel->bottom;
		helper = &panel->bottom_helper;
	}
	else if(position == PANEL_POSITION_TOP && panel->top != NULL)
	{
		window = panel->top;
		helper = &panel->top_helper;
	}
	else
		return -1;
	if((plugin = plugin_new(LIBDIR, PACKAGE, "applets", applet)) == NULL)
		return -1;
	if((pad = plugin_lookup(plugin, "applet")) == NULL
			|| pad->init == NULL || pad->destroy == NULL
			|| (pa = pad->init(helper, &widget)) == NULL)
	{
		plugin_delete(plugin);
		return -1;
	}
	panel_window_append(window, widget, pad->expand, pad->fill);
	if(pad->settings != NULL
			&& (widget = pad->settings(pa, FALSE, FALSE)) != NULL)
	{
		vbox = gtk_vbox_new(FALSE, 4);
		/* XXX ugly */
		g_object_set_data(G_OBJECT(vbox), "definition", pad);
		g_object_set_data(G_OBJECT(vbox), "applet", pa);
		gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
		gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0);
		gtk_widget_show(vbox);
		gtk_notebook_append_page(GTK_NOTEBOOK(panel->pr_notebook),
				vbox, gtk_label_new(pad->name));
	}
	return 0;
}