Freeciv-3.1
Loading...
Searching...
No Matches
theme_dlg.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/* client */
24#include "dialogs_g.h"
25#include "options.h"
26
27/* gui-gtk-4.0 */
28#include "gui_main.h"
29#include "gui_stuff.h"
30
31static bool load_theme = FALSE;
32
33/************************************************************************/
36static void theme_suggestion_response(gint arg)
37{
38 load_theme = (arg == GTK_RESPONSE_YES);
39}
40
41/************************************************************************/
45bool popup_theme_suggestion_dialog(const char *theme_name)
46{
47 GtkWidget *dialog, *label;
48 char buf[1024];
49 char *current_name = GUI_GTK_OPTION(default_theme_name);
50
51 if (current_name == NULL) {
52 /* gui option default_theme_name is not yet set.
53 * This can happen when we load tileset requested at command line and
54 * user has not saved theme information to .freeciv-client-rc.A.B. */
55 current_name = FC_GTK4_DEFAULT_THEME_NAME;
56 }
57
58 dialog = gtk_dialog_new_with_buttons(_("Theme suggested"),
59 NULL,
60 0,
61 _("Load theme"),
62 GTK_RESPONSE_YES,
63 _("Keep current theme"),
64 GTK_RESPONSE_NO,
65 NULL);
66 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
67 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
68
69 fc_snprintf(buf, sizeof(buf),
70 _("Tileset suggests using %s theme.\n"
71 "You are currently using %s."),
72 theme_name, current_name);
73
74 label = gtk_label_new(buf);
75 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
76 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
77 gtk_widget_show(label);
78
80
81 gtk_window_destroy(GTK_WINDOW(dialog));
82
83 return load_theme;
84}
#define _(String)
Definition fcintl.h:67
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition theme_dlg.c:46
static bool load_theme
Definition theme_dlg.c:30
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1126
static void theme_suggestion_response(gint arg)
Definition theme_dlg.c:36
#define FC_GTK4_DEFAULT_THEME_NAME
Definition options.h:331
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47