File: gdaui-test-errors.c

package info (click to toggle)
libgda5 5.2.10-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 75,964 kB
  • sloc: ansic: 495,325; xml: 10,486; yacc: 5,165; sh: 4,451; makefile: 4,099; php: 1,416; java: 1,300; javascript: 1,298; python: 896; sql: 879; perl: 116
file content (105 lines) | stat: -rw-r--r-- 3,189 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * Copyright (C) 2010 David King <davidk@openismus.com>
 * Copyright (C) 2010 - 2012 Vivien Malerba <malerba@gnome-db.org>
 * Copyright (C) 2011 Murray Cumming <murrayc@murrayc.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#include <libgda-ui/libgda-ui.h>
#include "../tests/data-model-errors.h"

static void destroy (G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gpointer data)
{
	gtk_main_quit ();
}

static gboolean change_unknow_color (GdauiBasicForm *form)
{
	static gdouble red = .3;
	static gdouble green = .1;
	static gdouble blue = .1;
	static gdouble alpha = .5;

	red += .075;
	if (red >= 1.)
		red = .3;
	gdaui_basic_form_set_unknown_color (form, red, green, blue, alpha);
	return TRUE; /* keep timer */
}

int
main (int argc, char *argv[])
{
	gtk_init (&argc, &argv);
	gdaui_init ();

	/* create data model */
	GdaDataModel *model; 
        model = data_model_errors_new ();
	gda_data_model_dump (model, NULL);
	
	/* create UI */
	GtkWidget *window, *vbox, *button, *form, *grid;
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_window_set_default_size (GTK_WINDOW(window), 400, 200);
	g_signal_connect_swapped (window, "destroy",
				  G_CALLBACK (destroy),
				  window);
	gtk_container_set_border_width (GTK_CONTAINER (window), 10);

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_container_add (GTK_CONTAINER (window), vbox);

	/* main form to list customers */
	form = gdaui_form_new (model);
	gtk_box_pack_start (GTK_BOX (vbox), form, FALSE, FALSE, 0);

	GtkWidget *raw;
	g_object_get (form, "raw-form", &raw, NULL);
	g_timeout_add (80, (GSourceFunc) change_unknow_color, raw);
	g_object_unref (raw);

        g_object_set (G_OBJECT (form),
		      "info-flags",
		      GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
		      GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS |
		      GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS,
		      NULL
		      );

	/* main grid to list customers */
	grid = gdaui_grid_new (model);
	g_object_unref (model);
	gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);

        g_object_set (G_OBJECT (grid),
		      "info-flags",
		      GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
		      GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS,
		      NULL
		      );

	/* button to quit */
	button = gtk_button_new_with_label ("Quit");
	gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
	g_signal_connect_swapped (button, "clicked",
				  G_CALLBACK (gtk_widget_destroy),
				  window);

	gtk_widget_show_all (window);
	gtk_main ();

        return 0;
}