Freeciv-3.3
Loading...
Searching...
No Matches
choice_dialog.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team
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#ifdef HAVE_CONFIG_H
14#include <fc_config.h>
15#endif
16
17#include <stdarg.h>
18
19#include <gtk/gtk.h>
20
21/* utility */
22#include "support.h"
23
24/* gui-gtk-4.0 */
25#include "gui_main.h"
26#include "gui_stuff.h"
27
28#include "choice_dialog.h"
29
30/***********************************************************************
31 Choice dialog: A dialog with a label and a list of buttons
32 placed vertically
33***********************************************************************/
34
35/*******************************************************************/
42
43/*******************************************************************/
47 int button)
48{
49 char button_name[512];
50 GtkWidget *b;
51
52 fc_snprintf(button_name, sizeof(button_name), "button%d", button);
53
55
56 return b;
57}
58
59/*******************************************************************/
67
68/*******************************************************************/
72 const char *label)
73{
74 GtkWidget* button = choice_dialog_get_nth_button(cd, number);
75 gtk_button_set_label(GTK_BUTTON(button), label);
76}
77
78/*******************************************************************/
82 const char *tool_tip)
83{
84 GtkWidget* button = choice_dialog_get_nth_button(cd, number);
86}
87
88/*******************************************************************/
99
100/*******************************************************************/
139
140/*******************************************************************/
145{
146 if (g_object_get_data(G_OBJECT(data), "hide")) {
148 } else {
150 }
151}
152
153/*******************************************************************/
158 bool meta, const gchar *tool_tip)
159{
160 GtkWidget *button, *bbox;
161 char name[512];
162 int nbuttons;
163
167
168 fc_snprintf(name, sizeof(name), "button%d", nbuttons);
169
170 button = gtk_button_new_with_mnemonic(label);
171 gtk_box_append(GTK_BOX(bbox), button);
173
174 if (handler) {
175 g_signal_connect(button, "clicked", handler, data);
176 }
177
178 if (!meta) {
179 /* This button makes the choice. */
180 g_signal_connect_after(button, "clicked",
182 }
183
184 if (tool_tip != NULL) {
186 }
187}
188
189/*******************************************************************/
201
202/*******************************************************************/
209
210/*******************************************************************/
214 const gchar *text, ...)
215{
217 va_list args;
218 gchar *name;
219
221
222 va_start(args, text);
223
224 while ((name = va_arg(args, gchar *))) {
226 gpointer data;
227
228 handler = va_arg(args, GCallback);
229 data = va_arg(args, gpointer);
230
232 }
233
234 va_end(args);
235
237
238 return dshell;
239}
240
241/*******************************************************************/
245{
246 if (dlg != NULL) {
248 }
249}
char * incite_cost
Definition comments.c:76
GtkWidget * choice_dialog_start(GtkWindow *parent, const gchar *name, const gchar *text)
void choice_dialog_end(GtkWidget *dshell)
static GtkWidget * choice_dialog_get_nth_button(GtkWidget *cd, int button)
int choice_dialog_get_number_of_buttons(GtkWidget *cd)
void choice_dialog_button_set_tooltip(GtkWidget *cd, int number, const char *tool_tip)
static void choice_dialog_clicked(GtkWidget *w, gpointer data)
void choice_dialog_button_move_to_the_end(GtkWidget *cd, const int number)
void choice_dialog_set_hide(GtkWidget *dshell, gboolean setting)
void choice_dialog_add(GtkWidget *dshell, const gchar *label, GCallback handler, gpointer data, bool meta, const gchar *tool_tip)
void choice_dialog_button_set_label(GtkWidget *cd, int number, const char *label)
void choice_dialog_button_set_sensitive(GtkWidget *cd, int button, gboolean state)
GtkWidget * popup_choice_dialog(GtkWindow *parent, const gchar *dialogname, const gchar *text,...)
static GtkWidget * dshell
Definition gotodlg.c:56
GtkWidget * toplevel
Definition gui_main.c:126
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void choice_dialog_destroy(GtkWidget *dlg)
const char * name
Definition inputfile.c:127
static QString button_name(Qt::MouseButton bt)
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47