111
113
action.activate += on_menu_game_new;
112
114
action_group.add_action_with_accel (action, "<control>N");
116
action = new Gtk.Action ("HintAction", _("_Hint"), null, null);
117
action.activate += on_menu_game_hint;
118
action_group.add_action_with_accel (action, "<control>H");
119
this.hint_action = action;
114
121
action = new Gtk.Action ("SolveAction", _("_Solve"), null, null);
115
122
action.activate += on_menu_game_solve;
116
123
action_group.add_action (action);
127
134
action.activate += on_menu_help_about;
128
135
action_group.add_action (action);
133
<menu name=\"GameMenu\" action=\"GameMenuAction\">\
134
<menuitem name=\"New\" action=\"NewAction\" />\
136
<menuitem name=\"Solve\" action=\"SolveAction\" />\
138
<menuitem name=\"Close\" action=\"CloseAction\" />\
140
<menu name=\"HelpMenu\" action=\"HelpMenuAction\">\
141
<menuitem name=\"About\" action=\"AboutAction\"/>\
140
<menu name="GameMenu" action="GameMenuAction">
141
<menuitem name="New" action="NewAction" />
143
<menuitem name="Hint" action="HintAction" />
144
<menuitem name="Solve" action="SolveAction" />
146
<menuitem name="Close" action="CloseAction" />
148
<menu name="HelpMenu" action="HelpMenuAction">
149
<menuitem name="About" action="AboutAction"/>
146
154
var manager = new Gtk.UIManager ();
156
164
menu_item.select += on_menu_select_new;
157
165
menu_item.deselect += on_menu_deselect;
167
menu_item = (Gtk.Item)manager.get_widget ("/ui/menubar/GameMenu/Hint");
168
menu_item.select += on_menu_select_hint;
169
menu_item.deselect += on_menu_deselect;
159
171
menu_item = (Gtk.Item)manager.get_widget ("/ui/menubar/GameMenu/Solve");
160
172
menu_item.select += on_menu_select_solve;
161
173
menu_item.deselect += on_menu_deselect;
238
250
switch (response)
240
252
case MultPuzzleGuessStatus.WRONG:
241
// Translators: %1$s is the letter, %2$s is the digit
253
// Translators: First argument is letter, second is digit
242
254
message_pattern = _("Incorrect — %1$s is not %2$s");
244
256
case MultPuzzleGuessStatus.CORRECT:
245
// Translators: %1$s is the letter, %2$s is the digit
257
// Translators: First argument is letter, second is digit
246
258
message_pattern = _("Correct — %1$s is %2$s");
338
351
status.push (context_id, _("Solve this game"));
354
private void on_menu_game_hint()
358
// Pick a random unknown digit. Keep trying until we actually solve one
359
// (because the digit may not have been in the puzzle -- we want to be
360
// more useful than that.
361
var character = MultPuzzleChar.INVALID;
363
var needed = this.puzzle.get_needed_digits();
365
foreach (bool n in needed)
366
num_needed += n ? 1 : 0;
367
if (num_needed == 0) // shouldn't happen
370
var choice = Random.int_range(0, num_needed);
371
for (int i = 0; i < 10; ++i) {
372
if (needed[i] && choice == 0) {
373
character = this.puzzle.solve_digit(i);
381
var context_id = status.get_context_id ("guess-feedback");
383
// Clear any previous message
384
status.pop (context_id);
385
if (status_timeout_id != 0)
386
Source.remove (status_timeout_id);
387
status_timeout_id = 0;
389
// Translators: First argument is letter, second is digit
390
var message_pattern = _("%1$s is %2$s");
391
var letter_str = _("%c".printf ((char)character));
392
var digit_str = _("%i".printf (digit));
393
status.push (context_id, message_pattern.printf (letter_str, digit_str));
394
status_timeout_id = Timeout.add_seconds (5, pop_guess_feedback);
399
private void on_menu_select_hint ()
401
var context_id = status.get_context_id ("menu-hover");
402
status.push (context_id, _("Reveal a digit at random"));
341
405
private void handle_about_uri (Gtk.AboutDialog about, string link)
343
407
AppLaunchContext context = new AppLaunchContext ();