2
* Copyright © 2005 Richard Hoelscher
3
* Copyright © 2006 Andreas Røsdal
4
* Copyright © 2007 Christian Persch
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* Richard Hoelscher <rah@rahga.com>
28
#include <glib/gi18n.h>
30
#include "games-stock.h"
35
} GamesStockItemTooltip;
38
games_stock_get_tooltip_from_stockid (const char* stockid)
40
static const GamesStockItemTooltip stock_item_tooltip[] = {
41
{ GAMES_STOCK_CONTENTS, N_("View help for this game") },
42
{ GAMES_STOCK_END_GAME, N_("End the current game") },
43
{ GAMES_STOCK_FULLSCREEN, N_("Toggle fullscreen mode") },
44
{ GAMES_STOCK_HINT, N_("Get a hint for your next move") },
45
{ GAMES_STOCK_LEAVE_FULLSCREEN, N_("Leave fullscreen mode") },
46
{ GAMES_STOCK_NETWORK_GAME, N_("Start a new multiplayer network game") },
47
{ GAMES_STOCK_NETWORK_LEAVE, N_("End the current network game and return to network server") },
48
{ GAMES_STOCK_NEW_GAME, N_("Start a new game") },
49
{ GAMES_STOCK_PAUSE_GAME, N_("Pause the game") },
50
{ GAMES_STOCK_PLAYER_LIST, N_("Show a list of players in the network game") },
51
{ GAMES_STOCK_REDO_MOVE, N_("Redo the undone move") },
52
{ GAMES_STOCK_RESTART_GAME, N_("Restart the game") },
53
{ GAMES_STOCK_RESUME_GAME, N_("Resume the paused game") },
54
{ GAMES_STOCK_SCORES, N_("View the scores") },
55
{ GAMES_STOCK_UNDO_MOVE, N_("Undo the last move") },
56
{ GTK_STOCK_ABOUT, N_("About this game") },
57
{ GTK_STOCK_CLOSE, N_("Close this window") },
58
{ GTK_STOCK_PREFERENCES, N_("Configure the game") },
59
{ GTK_STOCK_QUIT, N_("Quit this game") },
63
const char *tooltip = NULL;
68
for (i = 0; i < G_N_ELEMENTS (stock_item_tooltip); i++) {
69
if (strcmp (stock_item_tooltip[i].stock_id, stockid) == 0) {
70
tooltip = stock_item_tooltip[i].tooltip;
75
return tooltip ? _(tooltip) : NULL;
79
menu_item_select_cb (GtkWidget * widget, GtkStatusbar * statusbar)
85
context_id = gtk_statusbar_get_context_id (statusbar, "games-tooltip");
87
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget));
88
g_return_if_fail (action != NULL);
90
g_object_get (action, "tooltip", &tooltip, NULL);
93
gtk_statusbar_push (statusbar, context_id, tooltip);
96
const gchar *stock_tip = NULL;
99
g_object_get (action, "stock-id", &stockid, NULL);
100
if (stockid != NULL) {
101
stock_tip = games_stock_get_tooltip_from_stockid (stockid);
105
if (stock_tip != NULL) {
106
gtk_statusbar_push (statusbar, context_id, stock_tip);
112
menu_item_deselect_cb (GtkWidget * widget, GtkStatusbar * statusbar)
116
context_id = gtk_statusbar_get_context_id (statusbar, "games-tooltip");
117
gtk_statusbar_pop (statusbar, context_id);
121
connect_proxy_cb (GtkUIManager * ui_manager,
123
GtkWidget * proxy, GtkWidget * statusbar)
125
if (!GTK_IS_MENU_ITEM (proxy))
128
g_signal_connect (proxy, "select",
129
G_CALLBACK (menu_item_select_cb), statusbar);
130
g_signal_connect (proxy, "deselect",
131
G_CALLBACK (menu_item_deselect_cb), statusbar);
135
disconnect_proxy_cb (GtkUIManager * ui_manager,
137
GtkWidget * proxy, GtkWidget * statusbar)
139
if (!GTK_IS_MENU_ITEM (proxy))
142
g_signal_handlers_disconnect_by_func
143
(proxy, G_CALLBACK (menu_item_select_cb), statusbar);
144
g_signal_handlers_disconnect_by_func
145
(proxy, G_CALLBACK (menu_item_deselect_cb), statusbar);
149
* Call this once, after creating the UI Manager but before
150
* you start adding actions. Then, whenever an action is added,
151
* connect_proxy() will set tooltips to be displayed in the statusbar.
154
games_stock_prepare_for_statusbar_tooltips (GtkUIManager * ui_manager,
155
GtkWidget * statusbar)
157
g_signal_connect (ui_manager, "connect-proxy",
158
G_CALLBACK (connect_proxy_cb), statusbar);
159
g_signal_connect (ui_manager, "disconnect-proxy",
160
G_CALLBACK (disconnect_proxy_cb), statusbar);
164
register_stock_icon (GtkIconFactory * icon_factory,
165
const char * stock_id,
166
const char * icon_name)
168
GtkIconSource *source;
171
set = gtk_icon_set_new ();
173
source = gtk_icon_source_new ();
174
gtk_icon_source_set_icon_name (source, icon_name);
175
gtk_icon_set_add_source (set, source);
176
gtk_icon_source_free (source);
178
gtk_icon_factory_add (icon_factory, stock_id, set);
179
gtk_icon_set_unref (set);
183
register_stock_icon_bidi (GtkIconFactory * icon_factory,
184
const char * stock_id,
185
const char * icon_name_ltr,
186
const char * icon_name_rtl)
188
GtkIconSource *source;
191
set = gtk_icon_set_new ();
193
source = gtk_icon_source_new ();
194
gtk_icon_source_set_icon_name (source, icon_name_ltr);
195
gtk_icon_source_set_direction (source, GTK_TEXT_DIR_LTR);
196
gtk_icon_source_set_direction_wildcarded (source, FALSE);
197
gtk_icon_set_add_source (set, source);
198
gtk_icon_source_free (source);
200
source = gtk_icon_source_new ();
201
gtk_icon_source_set_icon_name (source, icon_name_rtl);
202
gtk_icon_source_set_direction (source, GTK_TEXT_DIR_RTL);
203
gtk_icon_source_set_direction_wildcarded (source, FALSE);
204
gtk_icon_set_add_source (set, source);
205
gtk_icon_source_free (source);
207
gtk_icon_factory_add (icon_factory, stock_id, set);
208
gtk_icon_set_unref (set);
212
games_stock_init (void)
214
/* These stocks have a gtk stock icon */
215
const char *stock_icon_aliases[][2] = {
216
{ GAMES_STOCK_CONTENTS, "help-contents" },
217
{ GAMES_STOCK_HINT, "dialog-information" },
218
{ GAMES_STOCK_NEW_GAME, "document-new" },
219
{ GAMES_STOCK_START_NEW_GAME, "document-new" },
220
{ GAMES_STOCK_RESET, "edit-clear" },
221
{ GAMES_STOCK_RESTART_GAME, "view-refresh" },
222
{ GAMES_STOCK_FULLSCREEN, "view-fullscreen" },
223
{ GAMES_STOCK_LEAVE_FULLSCREEN, "view-restore" },
224
{ GAMES_STOCK_NETWORK_GAME, "network-idle" },
225
{ GAMES_STOCK_NETWORK_LEAVE, "process-stop" },
226
{ GAMES_STOCK_PLAYER_LIST, "dialog-information" },
227
{ GAMES_STOCK_PAUSE_GAME, "media-playback-pause" },
230
const char *stock_icon_aliases_bidi[][3] = {
231
{ GAMES_STOCK_REDO_MOVE, "edit-redo", "edit-undo" },
232
{ GAMES_STOCK_UNDO_MOVE, "edit-undo", "edit-redo" },
233
{ GAMES_STOCK_RESUME_GAME, "media-playback-start", "media-playback-start" },
236
/* Private icon names */
237
const char *private_icon_names[][2] = {
238
{ GAMES_STOCK_TELEPORT, "teleport" },
239
{ GAMES_STOCK_RTELEPORT, "teleport-random" },
240
{ GAMES_STOCK_SCORES, "scores" },
241
{ GAMES_STOCK_DEAL_CARDS, "cards-deal" }
244
/* Use different accels on GTK/GNOME and Maemo */
246
static const GtkStockItem games_stock_items[] = {
247
{ GAMES_STOCK_CONTENTS, N_("_Contents"), 0, GDK_KEY_F1, NULL },
248
{ GAMES_STOCK_FULLSCREEN, N_("_Fullscreen"), 0, GDK_KEY_F11, NULL },
249
{ GAMES_STOCK_HINT, N_("_Hint"), GDK_CONTROL_MASK, 'h', NULL },
250
/* Translators: This "_New" is for the menu item 'Game->New', implies "New Game" */
251
{ GAMES_STOCK_NEW_GAME, N_("_New"), GDK_CONTROL_MASK, 'n', NULL },
252
/* Translators: This "_New Game" is for the game-over dialogue */
253
{ GAMES_STOCK_START_NEW_GAME, N_("_New Game"), 0, 0, NULL },
254
{ GAMES_STOCK_REDO_MOVE, N_("_Redo Move"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, 'z', NULL },
255
/* Translators: this is the "Reset" scores button in a scores dialogue */
256
{ GAMES_STOCK_RESET, N_("_Reset"), 0, 0, NULL },
257
/* Translators: "_Restart" is the menu item 'Game->Restart', implies "Restart Game" */
258
{ GAMES_STOCK_RESTART_GAME, N_("_Restart"), 0, 0, NULL },
259
{ GAMES_STOCK_UNDO_MOVE, N_("_Undo Move"), GDK_CONTROL_MASK, 'z', NULL },
260
{ GAMES_STOCK_DEAL_CARDS, N_("_Deal"), GDK_CONTROL_MASK, 'd', NULL },
261
{ GAMES_STOCK_LEAVE_FULLSCREEN, N_("_Leave Fullscreen"), 0, GDK_KEY_F11, NULL },
262
{ GAMES_STOCK_NETWORK_GAME, N_("Network _Game"), GDK_CONTROL_MASK, 'g', NULL },
263
{ GAMES_STOCK_NETWORK_LEAVE, N_("L_eave Game"), GDK_CONTROL_MASK, 'e', NULL },
264
{ GAMES_STOCK_PLAYER_LIST, N_("Player _List"), GDK_CONTROL_MASK, 'l', NULL },
265
{ GAMES_STOCK_PAUSE_GAME, N_("_Pause"), 0, GDK_KEY_Pause, NULL },
266
{ GAMES_STOCK_RESUME_GAME, N_("Res_ume"), 0, GDK_KEY_Pause, NULL },
267
{ GAMES_STOCK_SCORES, N_("_Scores"), 0, 0, NULL },
268
{ GAMES_STOCK_END_GAME, N_("_End Game"), 0, 0, NULL },
272
GtkIconFactory *icon_factory;
274
icon_factory = gtk_icon_factory_new ();
276
for (i = 0; i < G_N_ELEMENTS (stock_icon_aliases); ++i) {
277
register_stock_icon (icon_factory,
278
stock_icon_aliases[i][0],
279
stock_icon_aliases[i][1]);
282
for (i = 0; i < G_N_ELEMENTS (stock_icon_aliases_bidi); ++i) {
283
register_stock_icon_bidi (icon_factory,
284
stock_icon_aliases_bidi[i][0],
285
stock_icon_aliases_bidi[i][1],
286
stock_icon_aliases_bidi[i][2]);
289
/* Register our private themeable icons */
290
for (i = 0; i < G_N_ELEMENTS (private_icon_names); i++) {
291
register_stock_icon (icon_factory,
292
private_icon_names[i][0],
293
private_icon_names[i][1]);
296
gtk_icon_factory_add_default (icon_factory);
297
g_object_unref (icon_factory);
299
/* GtkIconTheme will then look in our custom hicolor dir
300
* for icons as well as the standard search paths.
302
/* FIXME: multi-head! */
303
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), ICON_THEME_DIRECTORY);
305
gtk_stock_add_static (games_stock_items, G_N_ELEMENTS (games_stock_items));
308
/* Returns a GPL N+ license string for a specific game. */
310
games_get_license_version (const gchar * game_name,
313
gchar *license_trans, *license_str;
315
static const char license0[] =
316
/* %s is replaced with the name of the game in gnome-games. */
317
N_("%s is free software; you can redistribute it and/or modify "
318
"it under the terms of the GNU General Public License as published by "
319
"the Free Software Foundation; either version %d of the License, or "
320
"(at your option) any later version.");
321
static const char license1[] =
322
N_("%s is distributed in the hope that it will be useful, "
323
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
324
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
325
"GNU General Public License for more details.");
326
static const char license2[] =
327
N_("You should have received a copy of the GNU General Public License "
328
"along with %s; if not, write to the Free Software Foundation, Inc., "
329
"51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA");
330
static const char license3[] =
331
N_("You should have received a copy of the GNU General Public License "
332
"along with this program. If not, see <http://www.gnu.org/licenses/>.");
335
license_trans = g_strjoin ("\n\n", _(license0), _(license1), _(license3), NULL);
337
license_trans = g_strjoin ("\n\n", _(license0), _(license1), _(license2), NULL);
340
g_strdup_printf (license_trans, game_name, version, game_name, game_name);
341
g_free (license_trans);
347
* gamess_get_licence:
349
* Returns: a newly allocated string with a GPL licence notice. The GPL version used
350
* depends on the game and the configure options and is determined from
351
* games_runtime_get_gpl_version()
354
games_get_license (const gchar * game_name)
356
return games_get_license_version (game_name, 2);