2 * Copyright (C) 2007 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "avaliacao.h"
29 gtk_container_remove_r (GtkWidget *widget, gpointer data)
31 gtk_container_remove (data, widget);
35 gtk_container_remove_all (GtkContainer *container)
37 gtk_container_foreach (container, gtk_container_remove_r, container);
42 addcur (const gchar *key, const gchar *val)
47 smap = vlcurval (db, &slen);
48 map = cbmapload (smap, slen);
49 cbmapput (map, key, -1, val, -1, 1);
51 smap = cbmapdump (map, &slen);
53 vlcurput (db, smap, slen, VL_CPCURRENT);
57 showcur (gpointer data)
67 sgroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
68 gtk_container_remove_all (GTK_CONTAINER (data));
69 val = vlcurval (db, &vlen);
70 map = cbmapload (val, vlen);
72 for (mapkey = cbmapiternext (map, NULL); mapkey != NULL;
73 mapkey = cbmapiternext (map, NULL))
76 mapval = cbmapget (map, mapkey, -1, NULL);
77 hbox = gtk_hbox_new (FALSE, 5);
78 gtk_box_pack_start (GTK_BOX (data), hbox, FALSE, FALSE, 0);
79 label = gtk_label_new (mapkey);
80 g_object_set (G_OBJECT (label), "xalign", 0.0, NULL);
81 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
82 entry = gtk_entry_new ();
83 gtk_entry_set_text (GTK_ENTRY (entry), mapval);
84 gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
85 gtk_size_group_add_widget (sgroup, label);
88 g_object_unref (sgroup);
89 gtk_widget_show_all (GTK_WIDGET (data));
94 first (GtkButton *button, gpointer data)
101 next (GtkButton *button, gpointer data)
108 prev (GtkButton *button, gpointer data)
115 last (GtkButton *button, gpointer data)
122 removecur (GtkButton *button, gpointer data)
129 addfield (GtkButton *button, gpointer data)
134 children = gtk_container_get_children (GTK_CONTAINER (data));
135 key = children->data;
136 value = children->next->data;
137 g_list_free (children);
138 addcur (gtk_entry_get_text (key), gtk_entry_get_text (value));
142 viewcur (GtkButton *button, gpointer data)
144 GtkTextBuffer *buffer;
146 message = regex_create_message ();
147 buffer = gtk_text_buffer_new (NULL);
148 gtk_text_buffer_set_text (buffer, message, -1);
150 gtk_text_view_set_buffer (GTK_TEXT_VIEW (data), buffer);
170 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
171 gtk_container_set_border_width (GTK_CONTAINER (window), 10);
172 g_signal_connect (G_OBJECT (window), "destroy", gtk_main_quit, NULL);
176 vbox = gtk_vbox_new (FALSE, 5);
177 gtk_container_add (GTK_CONTAINER (window), vbox);
179 hbox = gtk_hbox_new (FALSE, 5);
180 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
182 form = gtk_vbox_new (FALSE, 5);
183 gtk_box_pack_start (GTK_BOX (vbox), form, FALSE, FALSE, 0);
186 button = gtk_button_new_with_label ("First");
187 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
188 g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK(first), form);
189 button = gtk_button_new_with_label ("Prev");
190 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
191 g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK(prev), form);
192 button = gtk_button_new_with_label ("Next");
193 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
194 g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK(next), form);
195 button = gtk_button_new_with_label ("Last");
196 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
197 g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK(last), form);
200 hbox2 = gtk_hbox_new (FALSE, 5);
201 gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
203 entry = gtk_entry_new ();
204 gtk_box_pack_start (GTK_BOX (hbox2), entry, FALSE, FALSE, 0);
205 entry = gtk_entry_new ();
206 gtk_box_pack_start (GTK_BOX (hbox2), entry, FALSE, FALSE, 0);
207 button2 = gtk_button_new_with_label ("Add");
208 gtk_box_pack_start (GTK_BOX (hbox2), button2, FALSE, FALSE, 0);
209 g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (addfield), hbox2);
211 button2 = gtk_button_new_with_label ("Remove");
212 gtk_box_pack_start (GTK_BOX (hbox), button2, FALSE, FALSE, 0);
213 g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (removecur), form);
215 text = gtk_text_view_new ();
216 gtk_box_pack_start (GTK_BOX (vbox), text, TRUE, TRUE, 0);
218 button2 = gtk_button_new_with_label ("View");
219 gtk_box_pack_start (GTK_BOX (hbox), button2, FALSE, FALSE, 0);
220 g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (viewcur), text);
222 gtk_widget_show_all (window);
227 int main (int argc, char **argv)
229 gtk_init (&argc, &argv);
231 db = vlopen ("palestras.vl", VL_OWRITER, VL_CMPINT);