diff options
| author | Simon Tatham <anakin@pobox.com> | 2022-07-31 09:00:21 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2022-07-31 09:02:45 +0100 |
| commit | b34f8b1ee33163af988c75587e6ac99739b7684f (patch) | |
| tree | 7ffad4814070b6b262b0a8a788fb238117de7782 | |
| parent | f0f974055b7f8ee91bae6505aad166923ec7117f (diff) | |
| download | puzzles-b34f8b1ee33163af988c75587e6ac99739b7684f.zip puzzles-b34f8b1ee33163af988c75587e6ac99739b7684f.tar.gz puzzles-b34f8b1ee33163af988c75587e6ac99739b7684f.tar.bz2 puzzles-b34f8b1ee33163af988c75587e6ac99739b7684f.tar.xz | |
Style cleanups from the previous fixes.
Reordered the statements in the fixed Unruly blank_state so that there
doesn't need to be a double if statement (and I think it's more
sensible in any case to put each memset of a freshly allocated array
immediately after the alloc).
In GTK set_window_background, the nest of #ifdefs is now complicated
enough to deserve a few comments on the #else and #endif lines. And
while I was there I switched the gboolean to a bool, on my general
principle that platform-specific boolean types are only worth using
when you're passing them to a platform API function (and perhaps not
even then, if it's not passed by reference).
| -rw-r--r-- | gtk.c | 10 | ||||
| -rw-r--r-- | unruly.c | 7 |
2 files changed, 8 insertions, 9 deletions
@@ -399,14 +399,14 @@ static void set_window_background(frontend *fe, int colour) * menu and status bars unreadable. This might be visible through * the gtk-application-prefer-dark-theme flag or else we have to * work it out from the name. */ - gboolean dark_theme = FALSE; + bool dark_theme = false; char *theme_name = NULL; g_object_get(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", &dark_theme, "gtk-theme-name", &theme_name, NULL); if (theme_name && strcasestr(theme_name, "-dark")) - dark_theme = TRUE; + dark_theme = true; g_free(theme_name); #if GTK_CHECK_VERSION(3,20,0) char css_buf[512]; @@ -430,7 +430,7 @@ static void set_window_background(frontend *fe, int colour) gtk_widget_get_style_context(fe->area), GTK_STYLE_PROVIDER(fe->css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); -#else +#else // still at least GTK 3.0 but less than 3.20 GdkRGBA rgba; rgba.red = fe->colours[3*colour + 0]; rgba.green = fe->colours[3*colour + 1]; @@ -440,8 +440,8 @@ static void set_window_background(frontend *fe, int colour) if (!dark_theme) gdk_window_set_background_rgba(gtk_widget_get_window(fe->window), &rgba); -#endif -#else +#endif // GTK_CHECK_VERSION(3,20,0) +#else // GTK 2 version comes next GdkColormap *colmap; colmap = gdk_colormap_get_system(); @@ -360,15 +360,14 @@ static game_state *blank_state(int w2, int h2, bool unique, bool new_common) state->h2 = h2; state->unique = unique; state->grid = snewn(s, char); + memset(state->grid, EMPTY, s); + if (new_common) { state->common = snew(unruly_common); state->common->refcount = 1; state->common->immutable = snewn(s, bool); - } - - memset(state->grid, EMPTY, s); - if (new_common) memset(state->common->immutable, 0, s*sizeof(bool)); + } state->completed = state->cheated = false; |