Merge branch 'test-coverage' into 'main'

gtk-demo: Fix icon theme breakage

See merge request GNOME/gtk!4878
This commit is contained in:
Matthias Clasen
2022-07-16 14:08:37 +00:00
15 changed files with 72 additions and 20 deletions

View File

@@ -428,6 +428,8 @@
<file>icons/16x16/emotes/face-laugh-symbolic.symbolic.png</file>
<file>icons/16x16/status/battery-caution-charging-symbolic.symbolic.png</file>
<file>icons/16x16/categories/applications-other.png</file>
<file>icons/48x48/status/starred.png</file>
<file alias="icons/scalable/apps/org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
</gresource>
<gresource prefix="/org/gtk/Demo4/gtk">
<file preprocess="xml-stripblanks">help-overlay.ui</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -5,6 +5,7 @@
* small sliding puzzle game.
*/
#include "config.h"
#include <gtk/gtk.h>
/* Include the header for the puzzle piece */
@@ -24,6 +25,30 @@ static guint height = 3;
static guint pos_x;
static guint pos_y;
static void
ended (GObject *object)
{
g_object_unref (object);
}
static void
celebrate (gboolean win)
{
char *path;
GtkMediaStream *stream;
if (win)
path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "complete.oga", NULL);
else
path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "dialog-error.oga", NULL);
stream = gtk_media_file_new_for_filename (path);
gtk_media_stream_set_volume (stream, 1.0);
gtk_media_stream_play (stream);
g_signal_connect (stream, "notify::ended", G_CALLBACK (ended), NULL);
g_free (path);
}
static gboolean
move_puzzle (GtkWidget *grid,
int dx,
@@ -157,6 +182,8 @@ check_solved (GtkWidget *grid)
picture = gtk_grid_get_child_at (GTK_GRID (grid), pos_x, pos_y);
gtk_picture_set_paintable (GTK_PICTURE (picture), piece);
celebrate (TRUE);
return TRUE;
}

View File

@@ -199,22 +199,6 @@ gdk_keymap_init (GdkKeymap *keymap)
keymap->cache = g_hash_table_new (g_direct_hash, g_direct_equal);
}
/*< private >
* gdk_keymap_get_display:
* @keymap: a `GdkKeymap`
*
* Retrieves the `GdkDisplay` associated to the @keymap.
*
* Returns: (transfer none): a `GdkDisplay`
*/
GdkDisplay *
gdk_keymap_get_display (GdkKeymap *keymap)
{
g_return_val_if_fail (GDK_IS_KEYMAP (keymap), NULL);
return keymap->display;
}
/* Other key-handling stuff
*/

View File

@@ -89,8 +89,6 @@ struct _GdkKeymap
GType gdk_keymap_get_type (void) G_GNUC_CONST;
GdkDisplay * gdk_keymap_get_display (GdkKeymap *keymap);
guint gdk_keymap_lookup_key (GdkKeymap *keymap,
const GdkKeymapKey *key);
gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,

View File

@@ -184,7 +184,8 @@ gdk_load_png (GBytes *bytes,
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb (png);
if (color_type == PNG_COLOR_TYPE_GRAY)
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_expand_gray_1_2_4_to_8 (png);
if (png_get_valid (png, info, PNG_INFO_tRNS))

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Binary file not shown.

View File

@@ -89,6 +89,8 @@ test_save_image (gconstpointer test_data)
bytes = gdk_save_png (texture);
else if (g_str_has_suffix (filename, ".tiff"))
bytes = gdk_save_tiff (texture);
else if (g_str_has_suffix (filename, ".jpeg"))
bytes = gdk_save_jpeg (texture);
else
g_assert_not_reached ();
@@ -104,7 +106,9 @@ test_save_image (gconstpointer test_data)
texture2 = gdk_texture_new_from_file (file2, &error);
g_assert_no_error (error);
assert_texture_equal (texture, texture2);
if (!g_str_has_suffix (filename, ".jpeg"))
assert_texture_equal (texture, texture2);
g_bytes_unref (bytes);
g_object_unref (texture2);
@@ -120,10 +124,18 @@ main (int argc, char *argv[])
(g_test_init) (&argc, &argv, NULL);
g_test_add_data_func ("/image/load/png", "image.png", test_load_image);
g_test_add_data_func ("/image/load/png2", "image-gray.png", test_load_image);
g_test_add_data_func ("/image/load/png3", "image-palette.png", test_load_image);
g_test_add_data_func ("/image/load/tiff", "image.tiff", test_load_image);
g_test_add_data_func ("/image/load/tiff2", "image-unassoc.tiff", test_load_image);
g_test_add_data_func ("/image/load/tiff3", "image-tile.tiff", test_load_image);
g_test_add_data_func ("/image/load/tiff4", "image-float.tiff", test_load_image);
g_test_add_data_func ("/image/load/jpeg", "image.jpeg", test_load_image);
g_test_add_data_func ("/image/load/jpeg2", "image-cmyk.jpeg", test_load_image);
g_test_add_data_func ("/image/load/jpeg3", "image-gray.jpeg", test_load_image);
g_test_add_data_func ("/image/save/png", "image.png", test_save_image);
g_test_add_data_func ("/image/save/tiff", "image.tiff", test_save_image);
g_test_add_data_func ("/image/save/jpeg", "image.jpeg", test_save_image);
return g_test_run ();
}

View File

@@ -178,6 +178,33 @@ test_color_parse_nonsense (void)
res = gdk_rgba_parse (&color, "rgb(0,0,0) moo");
g_assert_false (res);
res = gdk_rgba_parse (&color, "#XGB");
g_assert_false (res);
res = gdk_rgba_parse (&color, "#XGBQ");
g_assert_false (res);
res = gdk_rgba_parse (&color, "#AAAAXGBQ");
g_assert_false (res);
}
static void
test_color_hash (void)
{
GdkRGBA color1;
GdkRGBA color2;
guint hash1, hash2;
gdk_rgba_parse (&color1, "hsla (120, 255, 50%, 0.1)");
gdk_rgba_parse (&color2, "rgb(0,0,0)");
hash1 = gdk_rgba_hash (&color1);
hash2 = gdk_rgba_hash (&color2);
g_assert_cmpuint (hash1, !=, 0);
g_assert_cmpuint (hash2, !=, 0);
g_assert_cmpuint (hash1, !=, hash2);
}
int
@@ -189,6 +216,7 @@ main (int argc, char *argv[])
g_test_add_func ("/rgba/parse/nonsense", test_color_parse_nonsense);
g_test_add_func ("/rgba/to-string", test_color_to_string);
g_test_add_func ("/rgba/copy", test_color_copy);
g_test_add_func ("/rgba/hash", test_color_hash);
return g_test_run ();
}