Freeciv-3.2
Loading...
Searching...
No Matches
messagedlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <gtk/gtk.h>
19
20/* utility */
21#include "fcintl.h"
22
23/* common */
24#include "events.h"
25
26/* client */
27#include "options.h"
28
29/* client/gui-gtk-3.22 */
30#include "colors.h"
31#include "gui_main.h"
32#include "gui_stuff.h"
33
34#include "messagedlg.h"
35
36#define NUM_LISTS 1
37
38/*************************************************************************/
39static struct gui_dialog *shell;
41
42static void create_messageopt_dialog(void);
43static void messageopt_response(struct gui_dialog *dlg, int response,
44 gpointer data);
46 gchar *spath, gpointer data);
47
48/**********************************************************************/
52{
53 if (shell == NULL) {
55 }
56
58}
59
60/**********************************************************************/
63static void create_messageopt_dialog(void)
64{
65 GtkWidget *form, *explanation;
66 int n, i = 0, j;
67
69 gui_dialog_set_title(shell, _("Message Options"));
70
72
75
76 explanation = gtk_label_new(NULL);
77 g_object_set(explanation, "margin", 4, NULL);
79 _("Where to display messages?\n"
80 "<b>Out</b>put window ; "
81 "<b>Mes</b>sages window ; "
82 "<b>Pop</b>up individual window"));
83 gtk_widget_set_name(explanation, "comment_label");
85 gtk_widget_show(explanation);
86
89
90 for (n = 0; n < NUM_LISTS; n++) {
93 }
94
96 GtkTreeIter it;
97 GValue value = { 0, };
98
99 n = (i++ % NUM_LISTS);
100
102
105 gtk_list_store_set_value(models[n], &it, 3, &value);
106 g_value_unset(&value);
107
108 gtk_list_store_set(models[n], &it, 4, ev, -1);
109
110 for (j = 0; j < NUM_MW; j++) {
111 gtk_list_store_set(models[n], &it, j, messages_where[ev] & (1<<j), -1);
112 }
114
115 for (n = 0; n < NUM_LISTS; n++) {
116 GtkWidget *view, *sw;
117 GtkCellRenderer *renderer;
119
124
125 renderer = gtk_cell_renderer_text_new();
127 renderer, "text", 3, NULL);
130
131 renderer = gtk_cell_renderer_toggle_new();
132 g_object_set_data(G_OBJECT(renderer), "column", GINT_TO_POINTER(0));
133 g_signal_connect(renderer, "toggled", G_CALLBACK(item_toggled), models[n]);
134
136 -1, _("Out"), renderer,
137 "active", 0, NULL);
138
139 renderer = gtk_cell_renderer_toggle_new();
140 g_object_set_data(G_OBJECT(renderer), "column", GINT_TO_POINTER(1));
141 g_signal_connect(renderer, "toggled", G_CALLBACK(item_toggled), models[n]);
142
144 -1, _("Mes"), renderer,
145 "active", 1, NULL);
146
147 renderer = gtk_cell_renderer_toggle_new();
148 g_object_set_data(G_OBJECT(renderer), "column", GINT_TO_POINTER(2));
149 g_signal_connect(renderer, "toggled", G_CALLBACK(item_toggled), models[n]);
150
152 -1, _("Pop"), renderer,
153 "active", 2, NULL);
154
159
163
165 }
166
169}
170
171/**********************************************************************/
174static void messageopt_response(struct gui_dialog *dlg, int response,
175 gpointer data)
176{
177 if (response == GTK_RESPONSE_OK) {
178 ITree it;
179 gint n, j, i;
180 gboolean toggle;
181
182 for (i = 0; i <= event_type_max(); i++) {
183 /* Include possible undefined messages. */
184 messages_where[i] = 0;
185 }
186
187 for (n = 0; n < NUM_LISTS; n++) {
189
190 for (itree_begin(pmodel, &it); !itree_end(&it); itree_next(&it)) {
191 for (j = 0; j < NUM_MW; j++) {
192 itree_get(&it, j, &toggle, 4, &i, -1);
193
194 if (toggle)
195 messages_where[i] |= (1<<j);
196 }
197 }
198 }
199 }
201}
202
203/**********************************************************************/
207 gchar *spath, gpointer data)
208{
209 GtkTreeModel *model = GTK_TREE_MODEL(data);
210 GtkTreePath *path;
211 GtkTreeIter it;
212 gboolean toggle;
213 gint column;
214
216
218
219 gtk_tree_model_get_iter(model, &it, path);
220 gtk_tree_model_get(model, &it, column, &toggle, -1);
221 toggle ^= 1;
222 gtk_list_store_set(GTK_LIST_STORE(model), &it, column, toggle, -1);
223
224 gtk_tree_path_free(path);
225}
#define n
Definition astring.c:77
char * incite_cost
Definition comments.c:75
const char * get_event_message_text(enum event_type event)
Definition events.c:247
#define sorted_event_iterate_end
Definition events.h:213
#define sorted_event_iterate(event)
Definition events.h:203
#define _(String)
Definition fcintl.h:67
GtkWidget * top_notebook
Definition gui_main.c:129
void gtk_tree_view_focus(GtkTreeView *view)
Definition gui_stuff.c:236
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:954
void itree_get(ITree *it,...)
Definition gui_stuff.c:164
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:865
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:988
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:127
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:919
void itree_next(ITree *it)
Definition gui_stuff.c:144
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
gboolean itree_end(ITree *it)
Definition gui_stuff.c:136
static void item_toggled(GtkCellRendererToggle *cell, gchar *spath, gpointer data)
Definition messagedlg.c:206
static GtkListStore * models[NUM_LISTS]
Definition messagedlg.c:40
void popup_messageopt_dialog(void)
Definition messagedlg.c:51
#define NUM_LISTS
Definition messagedlg.c:36
static void create_messageopt_dialog(void)
Definition messagedlg.c:63
static void messageopt_response(struct gui_dialog *dlg, int response, gpointer data)
Definition messagedlg.c:174
static struct gui_dialog * shell
Definition messagedlg.c:39
int messages_where[E_COUNT]
Definition options.c:5037
#define NUM_MW
Definition options.h:576
GtkWidget * vbox
Definition gui_stuff.h:72
#define TRUE
Definition support.h:46