Example #1
0
GtkWidget * ColorToolItem::getNewToolIconImpl() {
	XOJ_CHECK_TYPE(ColorToolItem);

	GtkWidget * iconWidget = selectcolor_new(this->color);
	selectcolor_set_circle(iconWidget, !isSelector());

	return iconWidget;
}
Example #2
0
GtkToolItem * ColorToolItem::newItem() {
	XOJ_CHECK_TYPE(ColorToolItem);

	this->iconWidget = selectcolor_new(this->color);

	selectcolor_set_circle(this->iconWidget, !isSelector());
	GtkToolItem * it = gtk_toggle_tool_button_new();

	gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(it), this->name.c_str());
	gtk_tool_button_set_label(GTK_TOOL_BUTTON(it), this->name.c_str());

	gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(it), this->iconWidget);

	return it;
}
SelectBackgroundColorDialog::SelectBackgroundColorDialog(GladeSearchpath* gladeSearchPath, Control* control) :
		GladeGui(gladeSearchPath, "page-background-color.glade", "pageBgColorDialog")
{

	XOJ_INIT_TYPE(SelectBackgroundColorDialog);

	this->control = control;
	this->selected = -1;
	this->colorDlg = NULL;

	ColorEntry* e = new ColorEntry(this, -1, true);
	this->colors.push_back(e);

	int predef_bgcolors_rgba[] = { 0xffffff, 0xa0e8ff, 0x80ffc0, 0xffc0d4, 0xffc080, 0xffff80 };

	GtkWidget* toolbar = get("tbPredefinedColors");

	for (int color : predef_bgcolors_rgba)
	{
		ColorEntry* e = new ColorEntry(this, color, false);
		this->colors.push_back(e);

		GtkWidget* iconWidget = selectcolor_new(color);
		selectcolor_set_size(iconWidget, 32);
		selectcolor_set_circle(iconWidget, true);
		GtkToolItem* it = gtk_tool_button_new(iconWidget, "");
		gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(it), -1);
		g_signal_connect(it, "clicked", G_CALLBACK(&buttonSelectedCallback), e);
	}

	gtk_widget_show_all(toolbar);

	toolbar = get("tbLastUsedColors");

	Settings* settings = control->getSettings();
	SElement& el = settings->getCustomElement("lastUsedPageBgColor");

	int count = 0;
	el.getInt("count", count);

	for (int i = 0; i < count; i++)
	{
		int color = -1;
		char* settingName = g_strdup_printf("color%02i", i);
		bool read = el.getInt(settingName, color);
		g_free(settingName);

		if (!read)
		{
			continue;
		}

		ColorEntry* e = new ColorEntry(this, color, true);
		this->colors.push_back(e);

		GtkWidget* iconWidget = selectcolor_new(color);
		selectcolor_set_size(iconWidget, 32);
		selectcolor_set_circle(iconWidget, true);
		GtkToolItem* it = gtk_tool_button_new(iconWidget, "");
		gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(it), -1);
		g_signal_connect(it, "clicked", G_CALLBACK(&buttonSelectedCallback), e);
	}
	gtk_widget_show_all(toolbar);

	if (count == 0)
	{
		// no colors => not title
		GtkWidget* w = get("lbLastUsed");
		gtk_widget_hide(w);
	}

	g_signal_connect(get("cbSelect"), "clicked", G_CALLBACK(&buttonCustomCallback), this);
}