Exemplo n.º 1
0
void add_color_to_treeview (void) {
	GtkTreePath *path;

	/* add color to tree view */
	add_list_color (hex_value (colorvalue), TRUE);

	/* scroll tree view so user sees new color */
	if (selection) {
		if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
			path = gtk_tree_model_get_path (gtk_tree_view_get_model (GTK_TREE_VIEW(tree)), &iter);
			gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(tree), path, NULL, FALSE, 0, 0);
			gtk_tree_path_free (path);
		}
	}
}
Exemplo n.º 2
0
void add_color_to_treeview ()
{
	GtkTreeView      *treeview;
	GtkTreeSelection *selection;
	
	/* add color to tree view */
	add_list_color (hex_value (colorvalue), colorname, USER_COLOR, TRUE);
	
	/* scroll tree view so user sees new color */
	treeview = GTK_TREE_VIEW (lookup_widget (gcolor2, "treeview"));
	selection = gtk_tree_view_get_selection (treeview);
	if (selection)
	{
		GtkTreeIter iter;
		if (gtk_tree_selection_get_selected (selection, NULL, &iter) )
		{
			GtkTreePath *path = gtk_tree_model_get_path (gtk_tree_view_get_model (treeview),
			                                             &iter);
			gtk_tree_view_scroll_to_cell (treeview, path, NULL, FALSE, 0, 0);
			gtk_tree_path_free (path);
		}
	}
}
Exemplo n.º 3
0
void add_rgb_file (gchar *file) {
	FILE *fp;
	gchar *p, buffer[512], spec[8];
	gint r, g, b;

	fp = fopen (file, "r");
	if (!fp)
		return; /* silently fail */

	while ((p = fgets (buffer, sizeof buffer, fp)) != NULL) {
		if (buffer[0] == '!')
			continue;
		r = g_ascii_strtoull (p, &p, 10);
		g = g_ascii_strtoull (p, &p, 10);
		b = g_ascii_strtoull (p, &p, 10);
		p += strspn (p, " \t");
		g_sprintf (spec, "#%.2X%.2X%.2X", r, g, b);
		colorname = g_strchomp (g_strdup (p));
		add_list_color (spec, FALSE);
	}
	g_free(p);
	fclose (fp);
}