Пример #1
0
static void _preferences_window_applets_plugin_add(GtkListStore * store,
		char const * name)
{
	Plugin * p;
	PanelAppletDefinition * pad;
	GtkTreeIter iter;
	GtkIconTheme * theme;
	GdkPixbuf * pixbuf = NULL;

	if((p = plugin_new(LIBDIR, PACKAGE, "applets", name)) == NULL)
		return;
	if((pad = plugin_lookup(p, "applet")) == NULL)
	{
		plugin_delete(p);
		return;
	}
	theme = gtk_icon_theme_get_default();
	if(pad->icon != NULL)
		pixbuf = gtk_icon_theme_load_icon(theme, pad->icon, 24, 0,
				NULL);
	if(pixbuf == NULL)
		pixbuf = gtk_icon_theme_load_icon(theme, "gnome-settings", 24,
				0, NULL);
	gtk_list_store_append(store, &iter);
	gtk_list_store_set(store, &iter, 0, name, 1, pixbuf, 2, pad->name, -1);
	plugin_delete(p);
}
Пример #2
0
/* code_delete */
int code_delete(Code * code)
{
	int ret = 0;
	CodeScope * scope;
	size_t i;

	DEBUG_FUNC();
	if(code->plugin != NULL)
	{
		if(code->target != NULL)
			ret = _code_target_exit(code);
		plugin_delete(code->plugin);
	}
	/* free the context */
	_code_context_flush(code);
	/* free the scopes */
	/* do it ourselves as code_scope_pop() stops at the global */
	for(; code->scopes_cnt > 0; code->scopes_cnt--)
	{
		scope = &code->scopes[code->scopes_cnt - 1];
		for(i = 0; i < scope->variables_cnt; i++)
			free(scope->variables[i].name);
		free(scope->variables);
	}
	free(code->scopes);
	/* free the types */
	for(i = 0; i < code->types_cnt; i++)
		free(code->types[i].name);
	free(code->types);
	object_delete(code);
	return ret;
}
Пример #3
0
/* panel_window_append */
int panel_window_append(PanelWindow * panel, char const * applet)
{
	PanelAppletHelper * helper = panel->helper;
	PanelApplet * pa;

	if((pa = realloc(panel->applets, sizeof(*pa)
					* (panel->applets_cnt + 1))) == NULL)
		return -error_set_code(1, "%s", strerror(errno));
	panel->applets = pa;
	pa = &panel->applets[panel->applets_cnt];
	if((pa->plugin = plugin_new(LIBDIR, PACKAGE, "applets", applet))
			== NULL)
		return -1;
	pa->widget = NULL;
	if((pa->pad = plugin_lookup(pa->plugin, "applet")) == NULL
			|| (pa->pa = pa->pad->init(helper, &pa->widget)) == NULL
			|| pa->widget == NULL)
	{
		if(pa->pa != NULL)
			pa->pad->destroy(pa->pa);
		plugin_delete(pa->plugin);
		return -1;
	}
	gtk_box_pack_start(GTK_BOX(panel->box), pa->widget, pa->pad->expand,
			pa->pad->fill, 0);
	gtk_widget_show_all(pa->widget);
	panel->applets_cnt++;
	return 0;
}
Пример #4
0
/* desktop_widget_delete */
void desktop_widget_delete(DesktopWidget * widget)
{
	if(widget->definition != NULL && widget->dplugin != NULL)
		widget->definition->destroy(widget->dplugin);
	if(widget->plugin != NULL)
		plugin_delete(widget->plugin);
	object_delete(widget);
}
Пример #5
0
/* arch_delete */
void arch_delete(AsmArch * arch)
{
#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
	plugin_delete(arch->handle);
	object_delete(arch);
}
Пример #6
0
/* modem_delete */
void modem_delete(Modem * modem)
{
	if(modem->modem != NULL)
		modem_stop(modem);
	if(modem->plugin != NULL)
		plugin_delete(modem->plugin);
	string_delete(modem->name);
	object_delete(modem);
}
Пример #7
0
/* format_delete */
void format_delete(AsmFormat * format)
{
#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
	format_exit(format);
	if(format->handle != NULL)
		plugin_delete(format->handle);
	object_delete(format);
}
Пример #8
0
/* panel_window_remove_all */
void panel_window_remove_all(PanelWindow * panel)
{
	size_t i;
	PanelApplet * pa;

	for(i = 0; i < panel->applets_cnt; i++)
	{
		pa = &panel->applets[i];
		pa->pad->destroy(pa->pa);
		plugin_delete(pa->plugin);
	}
	free(panel->applets);
	panel->applets = NULL;
	panel->applets_cnt = 0;
}
Пример #9
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;
}
Пример #10
0
/* format_new */
AsmFormat * format_new(char const * format)
{
	AsmFormat * f;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, format);
#endif
	if(format == NULL)
	{
		error_set_code(1, "%s", strerror(EINVAL));
		return NULL;
	}
	if((f = object_new(sizeof(*f))) == NULL)
		return NULL;
	if((f->handle = plugin_new(LIBDIR, PACKAGE, "format", format)) == NULL
			|| (f->definition = plugin_lookup(f->handle,
					"format_plugin")) == NULL)
	{
		if(f->handle != NULL)
			plugin_delete(f->handle);
		object_delete(f);
		return NULL;
	}
	f->plugin = NULL;
	memset(&f->helper, 0, sizeof(f->helper));
	f->helper.format = f;
	f->helper.decode = _format_helper_decode;
	f->helper.get_filename = _format_helper_get_filename;
	f->helper.get_function_by_id = _format_helper_get_function_by_id;
	f->helper.get_functions = _format_helper_get_functions;
	f->helper.get_section_by_id = _format_helper_get_section_by_id;
	f->helper.get_string_by_id = _format_helper_get_string_by_id;
	f->helper.set_function = _format_helper_set_function;
	f->helper.set_section = _format_helper_set_section;
	f->helper.set_string = _format_helper_set_string;
	f->helper.read = _format_helper_read;
	f->helper.seek = _format_helper_seek;
	f->helper.write = _format_helper_write;
	return f;
}
Пример #11
0
/* arch_new */
AsmArch * arch_new(char const * name)
{
	AsmArch * a;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, name);
#endif
	if((a = object_new(sizeof(*a))) == NULL)
		return NULL;
	memset(&a->helper, 0, sizeof(a->helper));
	if((a->handle = plugin_new(LIBDIR, PACKAGE, "arch", name)) == NULL
			|| (a->definition = plugin_lookup(a->handle,
					"arch_plugin")) == NULL)
	{
		if(a->handle != NULL)
			plugin_delete(a->handle);
		object_delete(a);
		return NULL;
	}
	a->plugin = NULL;
#if 1 /* XXX should be done when initializing */
	a->instructions_cnt = 0;
	if(a->definition->instructions != NULL)
		for(; a->definition->instructions[a->instructions_cnt].name
				!= NULL; a->instructions_cnt++);
	a->registers_cnt = 0;
	if(a->definition->registers != NULL)
		for(; a->definition->registers[a->registers_cnt].name != NULL;
				a->registers_cnt++);
#endif
	a->filename = NULL;
	a->fp = NULL;
	a->buffer = NULL;
	a->buffer_cnt = 0;
	a->buffer_pos = 0;
	return a;
}