Debian Codegraph @

src/tools/dlgedit/gui_circle_events.cc

raw
1 /*
2 Copyright (C) 2002/2004 Kai Sterker <[email protected]>
3 Part of the Adonthell Project <http://adonthell.nongnu.org>
4
5 Dlgedit is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 Dlgedit is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Dlgedit. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /**
20 * @file gui_circle_events.cc
21 *
22 * @author Kai Sterker
23 * @brief Callbacks of the Edit Circle dialog
24 */
25
26 #include "gui_circle_events.h"
27 #include "gui_circle.h"
28
29 // Colorize the dialogue text according to the character it is assigned to
30 void on_radio_button_pressed (GtkButton * button, gpointer user_data)
31 {
32 GtkWidget *entry = (GtkWidget *) user_data;
33 GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (entry));
34
35 int type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "type"));
36 GdkColor color = { 0, 0, 0, 0 };
37
38 switch (type)
39 {
40 case PLAYER:
41 color.blue = 35000;
42 break;
43 case NARRATOR:
44 color.green = 27300;
45 color.blue = 15600;
46 break;
47 }
48
49 // Change the color of the text entry
50 gtk_widget_modify_text (entry, GTK_STATE_NORMAL, &color);
51
52 // remember the type of the text
53 g_object_set_data (G_OBJECT (buf), "type", GINT_TO_POINTER (type));
54 }
55
56 // close the dialog and keep all changes
57 void on_circle_ok_button_pressed (GtkButton * button, gpointer user_data)
58 {
59 GuiCircle *dialog = (GuiCircle *) user_data;
60
61 dialog->applyChanges ();
62 dialog->okButtonPressed (true);
63
64 // clean up
65 gtk_main_quit ();
66 }
67
68 // close dialog and dismiss all changes
69 void on_circle_cancel_button_pressed (GtkButton * button, gpointer user_data)
70 {
71 // clean up
72 gtk_main_quit ();
73 }
74