Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-gtk-3.22/soundset_dlg.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
soundset_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/* common */
24#include "game.h"
25
26/* client */
27#include "audio.h"
28#include "client_main.h"
29
30/* client/gui-gtk-3.22 */
31#include "gui_main.h"
32#include "gui_stuff.h"
33
34#include "dialogs_g.h"
35
36static void soundset_suggestion_callback(GtkWidget *dlg, gint arg);
37static void musicset_suggestion_callback(GtkWidget *dlg, gint arg);
38
39/************************************************************************/
42 static void soundset_suggestion_callback(GtkWidget *dlg, gint arg)
43{
44 if (arg == GTK_RESPONSE_YES) {
45 /* User accepted soundset loading */
46 audio_restart(game.control.preferred_soundset,
47 music_set_name);
48 }
49}
50
51/************************************************************************/
55 void popup_soundset_suggestion_dialog(void)
56{
57 GtkWidget *dialog, *label;
58 char buf[1024];
59
60 dialog = gtk_dialog_new_with_buttons(_("Preferred soundset"),
61 NULL,
62 0,
63 _("_Load soundset"),
64 GTK_RESPONSE_YES,
65 _("_Keep current soundset"),
66 GTK_RESPONSE_NO,
67 NULL);
68 setup_dialog(dialog, toplevel);
69 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
70 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
71
72 fc_snprintf(buf, sizeof(buf),
73 _("Modpack suggests using %s soundset.\n"
74 "It might not work with other soundsets.\n"
75 "You are currently using soundset %s."),
76 game.control.preferred_soundset, sound_set_name);
77
78 label = gtk_label_new(buf);
79 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
80 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
81 gtk_widget_show(label);
82
83 g_signal_connect(dialog, "response",
84 G_CALLBACK(soundset_suggestion_callback), NULL);
85
86 /* In case incoming rulesets are incompatible with current soundset
87 * we need to block their receive before user has accepted loading
88 * of the correct soundset. */
89 gtk_dialog_run(GTK_DIALOG(dialog));
90
91 gtk_widget_destroy(dialog);
92}
93
94/************************************************************************/
97 static void musicset_suggestion_callback(GtkWidget *dlg, gint arg)
98{
99 if (arg == GTK_RESPONSE_YES) {
100 /* User accepted musicset loading */
101 audio_restart(sound_set_name, game.control.preferred_musicset);
102 }
103}
104
105/************************************************************************/
109 void popup_musicset_suggestion_dialog(void)
110{
111 GtkWidget *dialog, *label;
112 char buf[1024];
113
114 dialog = gtk_dialog_new_with_buttons(_("Preferred musicset"),
115 NULL,
116 0,
117 _("_Load musicset"),
118 GTK_RESPONSE_YES,
119 _("_Keep current musicset"),
120 GTK_RESPONSE_NO,
121 NULL);
122 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
123 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
124
125 fc_snprintf(buf, sizeof(buf),
126 _("Modpack suggests using %s musicset.\n"
127 "It might not work with other musicsets.\n"
128 "You are currently using musicset %s."),
129 game.control.preferred_musicset, music_set_name);
130
131 label = gtk_label_new(buf);
132 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
133 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
134 gtk_widget_show(label);
135
136 g_signal_connect(dialog, "response",
137 G_CALLBACK(musicset_suggestion_callback), NULL);
138
139 /* In case incoming rulesets are incompatible with current musicset
140 * we need to block their receive before user has accepted loading
141 * of the correct musicset. */
142 gtk_dialog_run(GTK_DIALOG(dialog));
143
144 gtk_widget_destroy(dialog);
145}
audio_restart
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:376
audio.h
music_set_name
char music_set_name[512]
Definition client_main.c:143
sound_set_name
char sound_set_name[512]
Definition client_main.c:142
client_main.h
incite_cost
char * incite_cost
Definition comments.c:74
dialogs_g.h
fcintl.h
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:61
game.h
toplevel
GtkWidget * toplevel
Definition gui_main.c:125
setup_dialog
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
popup_musicset_suggestion_dialog
void popup_musicset_suggestion_dialog(void)
Definition soundset_dlg.c:109
popup_soundset_suggestion_dialog
void popup_soundset_suggestion_dialog(void)
Definition soundset_dlg.c:55
musicset_suggestion_callback
static void musicset_suggestion_callback(GtkWidget *dlg, gint arg)
Definition soundset_dlg.c:97
soundset_suggestion_callback
static void soundset_suggestion_callback(GtkWidget *dlg, gint arg)
Definition soundset_dlg.c:42
gui_stuff.h
gui_main.h
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
packet_ruleset_control::preferred_soundset
char preferred_soundset[MAX_LEN_NAME]
Definition packets_gen.h:1460
packet_ruleset_control::preferred_musicset
char preferred_musicset[MAX_LEN_NAME]
Definition packets_gen.h:1461
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
TRUE
#define TRUE
Definition support.h:46