126 Commits

Author SHA1 Message Date
fd7882fb45 GTK 3 prep: make the server-side backing pixmap optional.
When GDK_DISABLE_DEPRECATED is defined, we now don't have fe->pixmap;
instead we just maintain our client-side window contents in fe->image,
and draw from there directly to the window in the expose handler.
2015-10-03 16:07:04 +01:00
07906104a2 GTK 3 prep: use gtk_radio_menu_item_get_group().
Replaces the previous deprecated spelling. We now build cleanly with
-DGTK_DISABLE_DEPRECATED.
2015-10-03 16:07:04 +01:00
2c1b00086d GTK 3 prep: use GtkComboBox for drop-down lists.
The previous GtkOptionMenu was long since deprecated.
2015-10-03 16:07:04 +01:00
71c7bcd981 GTK 3 prep: use the glib names for base object types. 2015-10-03 16:07:04 +01:00
0dc2fd1ea3 GTK 3 prep: use GTK_KEY_* constants. 2015-10-03 16:07:04 +01:00
238cd9dc83 GTK 3 prep: use accessors instead of direct field access.
We now build cleanly with -DGSEAL_ENABLE.
2015-10-03 16:07:04 +01:00
7242dcc4ef Fix packing direction of config boxes.
We were packing the GtkTable into the dialog's content area using
gtk_box_pack_end, which had the slightly silly effect that resizing
the config box vertically would keep all the controls aligned to the
_bottom_ rather than the top.
2015-10-03 16:07:04 +01:00
8b491946ef Don't refresh backing store on a no-op configure event.
Sometimes, we can get a "configure_area" event telling us that the
drawing area has changed size to the same size it already was. This
can happen when we change puzzle presets in a way that doesn't change
the size, and also sometimes seems to happen as a side effect of
changing the text in the status line.

In that situation, it's a waste of effort - and can cause visible
on-screen flicker - to throw away the window's backing image and
pixmap and regenerate them from scratch. So now we detect a non-resize
and avoid doing all that.

The only thing we retain unconditionally in configure_area is the
midend_force_redraw, because that's the place where a puzzle redraw is
forced when changing presets or loading a new game.
2015-10-03 16:07:01 +01:00
8f8333a351 Fix puzzle window resize behaviour on Unity.
Unity hijacks the menu bar and prevents it from appearing in the main
puzzle window. And we wait for the menu bar to appear before reducing
the puzzle drawing area's size request. These two behaviours go
together badly.

Fixed by detecting the extra GTK property that the Unity patches
invented, and using that to know whether to expect the menu bar to
show up at all.
2015-01-04 18:11:28 +00:00
f806528a30 Remove another erroneous GINT_TO_POINTER.
This one shouldn't have been there at all - it had a pointer argument
already, not an int.
2014-11-29 10:39:00 +00:00
69ab4b2205 Fix a GINT_TO_POINTER that was back to front.
Spotted by clang, which I just tried building this codebase with out
of curiosity.
2014-11-29 10:24:05 +00:00
120f6de605 Introduce some extra testing and benchmarking command-line options to
the GTK front end, plus a 'make test' target in the GTK makefile which
uses them to automatically generate 100 puzzles for each game at each
preset configuration, test-run them back through the solver without
their aux_info to ensure that can cope, and produce an HTML box plot
of game generation times for each preset.

As part of this work I've removed the TESTSOLVE mechanism from r9549,
since the new --test-solve option does the same thing better (in that
when something goes wrong it prints the random seed that caused the
problem).

[originally from svn r9825]
[r9549 == 5a095b8a08fa9f087b93c86aea0fa027138b028d]
2013-04-11 12:51:06 +00:00
261a784d1e Actually do what the comment says at the top of main() regarding not
bombing out due to an option that we don't recognise but GTK will.
Somehow my basically workable plan had been completely nullified by
putting the error check in the wrong place.

[originally from svn r9733]
2012-12-28 11:22:13 +00:00
e17bf4abec Fix overnight build failure last night, by making the new call to
gtk_widget_get_allocation conditional on GTK being new enough to have
that function.

I'm assuming until someone proves otherwise that if it isn't that new,
then it also isn't one of the versions of GTK which exhibit the bug
which that call was working around (since gtk_widget_get_allocation
came in 2.18, and the problem seems to have arisen since 2.20).

[originally from svn r9712]
2012-11-21 18:45:07 +00:00
2a2520b8e7 Work around an annoying GTK behaviour I noticed the other day on my
Ubuntu 12.04 machine. What seems to happen is that we set up a window
containing a menu bar, a drawing area and a status bar, and set the
size of the drawing area; then the window is displayed _without_ the
menu bar; then we reduce the drawing area's size request to (1,1) to
let the user resize the window smaller; and now GTK gets round to
constructing the menu bar, and the drawing area helpfully shrinks a
bit to make room for it.

My fix is to set a 'shrink pending' flag instead of shrinking the
drawing area's size request, and defer the actual shrink operation
until the menu bar and status bar are both present.

[originally from svn r9711]
2012-11-20 20:05:27 +00:00
7024735f89 Allow --save to work with --soln, causing saved game files to be
written out with the Solve operation having already been performed.

[originally from svn r9375]
2011-12-28 18:17:30 +00:00
b5cb02b61a Fix bug in error reporting for --save caused by freeing 'realname'
before the error messages wanted to use it.

[originally from svn r9374]
2011-12-28 18:07:46 +00:00
236f965093 Fix bug in --save caused by failure to initialise ctx.error to zero
before later checking to see if an errno code was dumped in it.

[originally from svn r9373]
2011-12-28 18:07:46 +00:00
4d41f0f717 Fixes to r8997: firstly, move the fix out of #ifdef CAIRO so that it
applies to both drawing mechanisms, and secondly, make sure to paint
the spare pieces of window in the _puzzle's_ background colour
rather than the (sometimes slightly different) system default.

[originally from svn r9021]
[r8997 == 26c669a6b2892b97b4a9bc6842f633291951fdbd]
2010-11-06 17:47:46 +00:00
26c669a6b2 Jonas Koelker reports that using the version of GTK currently in
Debian sid (2.20.1), there's a redraw problem when the window has a
different aspect ratio from the puzzle (due to resizing or
maximising): pieces of the window outside the real puzzle rectangle
don't get redrawn when exposed (e.g. by the drop-down menus).

Introduced code to explicitly redraw the whole exposed area,
including the parts that fall outside the pixmap. This makes the
problem go away in my hasty test install of sid, and doesn't seem to
affect the build on lenny.

[originally from svn r8997]
2010-09-14 10:55:06 +00:00
9cd182ffa9 Patch from Mark Wooding to introduce a draw_thick_line() function in
the drawing API, for use by Loopy. It's optional: drawing.c will
construct an acceptable alternative using a filled polygon if the
front end doesn't provide it.

Net and Netslide previously had static functions called
draw_thick_line(), whose claim to the name is less justified and so
they've been renamed.

[originally from svn r8962]
2010-05-29 15:43:46 +00:00
ef6e78c6ac Patch from Mark Wooding to (optionally at compile time) use the
Cairo rendering library in place of GDK, which provides pretty
antialiased graphics much like we get on MacOS. Inertia and Untangle
are perhaps the two games most obviously improved by this.

[originally from svn r8961]
2010-05-29 15:43:42 +00:00
9ce82b0feb Patch from Mark Wooding to disable GTK's internal double buffering,
which I didn't know about, but which is clearly a waste of effort
since we keep our own backing pixmap for the puzzle window.

[originally from svn r8960]
2010-05-29 15:43:41 +00:00
d040a921ba Patch from Mark Wooding to use GTK stock items for standard 'OK',
'Yes' and 'No' buttons, which means they get the standard icons that
go on those button types. Also reorders yes/no boxes so that they're
the GNOME standard way round.

[originally from svn r8959]
2010-05-29 15:43:40 +00:00
5062bee2ec Patch from Debian, to bring the use of the X selection/clipboard in
line with freedesktop.org. (This is relatively simple for Puzzles,
since it only writes to the clipboard and never reads it, so the
question of which selection to use when is most easily dealt with by
always writing to both.)

[originally from svn r8929]
2010-04-25 14:57:19 +00:00
9fbb365684 Introduce, and implement as usefully as I can in all front ends, a
new function in the drawing API which permits the display of text
from outside basic ASCII. A fallback mechanism is provided so that
puzzles can give a list of strings they'd like to display in order
of preference and the system will return the best one it can manage;
puzzles are required to cope with ASCII-only front ends.

[originally from svn r8793]
2009-12-27 10:01:16 +00:00
6d5245d8bf Patch from Frode Austvik to tinker with the GTK interface if
compiling gtk.c with STYLUS_BASED defined: most notably, it provides
a row of numeric 'keys' made of GTK button widgets for puzzles that
want a numeric keypad.

[originally from svn r8783]
2009-12-17 18:12:18 +00:00
652f03a8ae Patch from Mark Wooding: when I did r7980 I had completely failed to
notice that there was an _official_ way to have menu items marked as
selected or unselected, which is the GtkRadioMenuItem class. Replace
my ad-hoc use of bullet characters with that.

[originally from svn r8601]
[r7980 == ae6c7381272f84c0fd398f6d3e496f571ba42ec8]
2009-06-21 13:49:09 +00:00
93cd7ae62c Patch from Mark Wooding: use gdk_event_request_motions() where
available, which magically seems to eliminate most if not all of the
update lag when dragging a point in a large (say 250-point)
Untangle. I don't fully understand how this works, but it seems to!

[originally from svn r8600]
2009-06-21 13:39:54 +00:00
ec29642539 Patch from Mark Wooding: stop setting GTK_EXPAND for the x-direction
on labels in tables. The effect is that if you resize (e.g.) Solo's
configuration panel, the labels to the left of the various input
boxes will remain just big enough to fit their text in, and all the
extra space will be taken up by the useful part, i.e. the input
boxes themselves. Previously the labels and input boxes would expand
in a 1:1 ratio, causing lots of space to the right of the label text
that wasn't used for anything.

[originally from svn r8599]
2009-06-21 13:34:50 +00:00
99ca11bf8b Make menus accessible from the keyboard in the Gtk front-end.
[originally from svn r8486]
2009-03-01 13:51:32 +00:00
d2b0d8cf3f Switch over to using the new-style GtkFileChooser in place of the
deprecated GtkFileSelection, at least when the latter is available.
Patch mostly due to Ori Avtalion.

[originally from svn r8431]
2009-01-26 19:11:34 +00:00
ff62f0aaff Add an automatic check for HAVE_SENSIBLE_ABSOLUTE_SIZE_FUNCTION by
using PANGO_CHECK_VERSION. (Irritatingly, the latter is not
available in all versions of Pango, so we have to be cautious about
using it at all. *sigh*)

[originally from svn r8430]
2009-01-24 17:58:42 +00:00
ba08d8ab28 Add missing call to gtk_selection_clear_targets(), without which the
list of selection targets offered by GTK Puzzles grows an extra copy
of each of the three supported text formats every time the user
makes a selection!

[originally from svn r8365]
2008-12-01 23:04:17 +00:00
6aa7ccfa06 The other day I found it useful for a (silly) special purpose to
generate a thousand saved-game files of randomly generated puzzles.
On the general principle that if I find it useful someone else
conceivably might too, add a --save option to the Unix puzzle
binaries, for use with --generate in much the same way as --print.

[originally from svn r8351]
2008-11-29 08:50:50 +00:00
23fb0e7753 Check return values from fwrite when saving files.
[originally from svn r8278]
2008-11-04 23:02:07 +00:00
ba2a002c02 Lambros provides this workaround for a compiler warning on his
Ubuntu system. I'm inclined to think the real problem is in his gtk
headers, but this is a harmless enough change to avoid hassle.

[originally from svn r8181]
2008-09-14 08:52:59 +00:00
ca20d86a06 Don't call changed_preset() until after we've initialised
fe->copy_menu_item.

[originally from svn r8163]
2008-09-06 17:33:04 +00:00
a7431c0b7c New infrastructure feature. Games are now permitted to be
_conditionally_ able to format the current puzzle as text to be sent
to the clipboard. For instance, if a game were to support playing on
a square grid and on other kinds of grid such as hexagonal, then it
might reasonably feel that only the former could be sensibly
rendered in ASCII art; so it can now arrange for the "Copy" menu
item to be greyed out depending on the game_params.

To do this I've introduced a new backend function
(can_format_as_text_now()), and renamed the existing static backend
field "can_format_as_text" to "can_format_as_text_ever". The latter
will cause compile errors for anyone maintaining a third-party front
end; if any such person is reading this, I apologise to them for the
inconvenience, but I did do it deliberately so that they'd know to
update their front end.

As yet, no checked-in game actually uses this feature; all current
games can still either copy always or copy never.

[originally from svn r8161]
2008-09-06 09:27:56 +00:00
ae6c738127 New feature in midend.c which allows us to ask for the number of the
currently selected preset, if any. I've used this in the GTK front
end to have the Type menu mark the currently selected menu item.
(After considerable beating of GTK with sticks, I might add. Grr.)
Currently the same UI feature is not yet supported on Windows or
MacOS, but I hope to do those too at some point if it's feasible.

[originally from svn r7980]
2008-04-08 16:25:39 +00:00
c1b0c1d091 Ben Hutchings' patch to allow Gtk windows to be shrunk as well as grown
(from Debian bug#379452).
Tested on Gtk 2. I've been unable to find a Gtk+-1.2 installation on which
Puzzles compiles, so not tested there.

[originally from svn r7367]
2007-03-03 22:39:17 +00:00
d916cd7ff9 Refactoring patch from Ben Hutchings: move all the Gtk resize code into one
place. (From Debian bug#379452)

[originally from svn r7366]
2007-03-03 22:05:05 +00:00
7c59e7259f In Windows/Gtk front-ends, consistently use the ellipsis convention for naming
menu items which bring up dialogs.

[originally from svn r7058]
2007-01-04 19:24:43 +00:00
14ed4e9b1e Phil Bordelon's patch yesterday should have initialised the GError
to NULL.

[originally from svn r7052]
2007-01-03 09:51:42 +00:00
7848918bac Phil Bordelon points out that my invocation of gdk_pixbuf_save()
isn't quite right.

[originally from svn r7050]
2007-01-02 19:45:19 +00:00
fc59e33845 Make errors in option parsing actually _do_ something in interactive mode.
[originally from svn r7039]
2006-12-30 00:26:16 +00:00
197c2ebc12 Aha, this seems to be a more sensible way of getting screenshots:
instead of having the puzzle binary export its window ID to a script
which then runs xwd, we can use the gdk-pixbuf library to have the
puzzle binary _itself_ read its own internal pixmap and save it
straight to a PNG. How handy. And faster, and less timing-sensitive.

[originally from svn r7022]
2006-12-27 15:21:55 +00:00
61b983ae3a Support for run-time icons in the GTK puzzles. This involved another
mkfiles.pl change (I don't seem to be planning ahead very well this
week), this time to provide a list of fallback options for an object
file. That way, I have a no-icon.c which quietly replaces
icons/foo-icon.c if the latter doesn't exist, and so again people
checking straight out from Subversion shouldn't have trouble.

[originally from svn r7021]
2006-12-27 15:10:59 +00:00
d55ad9fc42 New mechanism for automatic generation of the puzzle screenshots on
the web, which I hope will also end up being extended to generate
both Windows and X icons for each individual puzzle. The mechanism
is: for each puzzle there's a save file in the `icons' subdirectory
showing a game state which I think is a decent illustration of the
puzzle, and then there's a nasty set of scripts which runs each
puzzle binary, loads that save file, grabs a screenshot using xwd,
and munges it into shape.

In order to support this I've added two new options (--redo and
--windowid) to all the GTK puzzles, which I don't expect ever to be
used outside the icons makefile. I've also added two more options
(--load and --id) which force a GTK puzzle to treat its command-line
option as a save file or as a game ID respectively (the previous
behaviour was always to guess, and sometimes it guessed wrong).

[originally from svn r7014]
2006-12-26 16:47:28 +00:00
cfcd8cf8c5 Since r6711, puzzles built with Gtk 1.2 would take double actions when a menu
accelerator key (N/U/R/Q) was pressed -- once for the menu accelerator, and
once more in key_event().
This workaround, while unlovely, should at least not break in future (since the
things it relies on are unlikely to change).

[originally from svn r6745]
[r6711 == 077aa510c78f3273bd0d4ca4f1ca14780822ebf9]
2006-06-26 22:01:51 +00:00