[yelp/wip/kill-gnome-common: 7/8] Fix compiler warnings in tests
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp/wip/kill-gnome-common: 7/8] Fix compiler warnings in tests
- Date: Wed, 28 Jan 2015 16:53:19 +0000 (UTC)
commit 26cb833e47715c64b20d43087aca1986f50c2f17
Author: David King <amigadave amigadave com>
Date: Wed Jan 28 16:51:53 2015 +0000
Fix compiler warnings in tests
tests/test-bz2.c | 5 +-
tests/test-lzma.c | 5 +-
tests/test-magic.c | 5 +-
tests/test-settings.c | 112 +++++++++++++++++++++++------------------------
tests/test-transform.c | 16 +++---
tests/test-uri.c | 6 ++-
tests/test-view.c | 11 ++---
7 files changed, 82 insertions(+), 78 deletions(-)
---
diff --git a/tests/test-bz2.c b/tests/test-bz2.c
index bcc7e63..f663414 100644
--- a/tests/test-bz2.c
+++ b/tests/test-bz2.c
@@ -43,8 +43,9 @@ main (int argc, char **argv)
file = g_file_new_for_path (argv[1]);
file_stream = g_file_read (file, NULL, NULL);
- converter = yelp_bz2_decompressor_new ();
- stream = g_converter_input_stream_new (file_stream, converter);
+ converter = G_CONVERTER (yelp_bz2_decompressor_new ());
+ stream = g_converter_input_stream_new (G_INPUT_STREAM (file_stream),
+ converter);
while ((bytes = g_input_stream_read (stream, buf, 1024, NULL, NULL)) > 0) {
gchar *out = g_strndup (buf, bytes);
diff --git a/tests/test-lzma.c b/tests/test-lzma.c
index 6f02643..32a1431 100644
--- a/tests/test-lzma.c
+++ b/tests/test-lzma.c
@@ -43,8 +43,9 @@ main (int argc, char **argv)
file = g_file_new_for_path (argv[1]);
file_stream = g_file_read (file, NULL, NULL);
- converter = yelp_lzma_decompressor_new ();
- stream = g_converter_input_stream_new (file_stream, converter);
+ converter = G_CONVERTER (yelp_lzma_decompressor_new ());
+ stream = g_converter_input_stream_new (G_INPUT_STREAM (file_stream),
+ converter);
while ((bytes = g_input_stream_read (stream, buf, 1024, NULL, NULL)) > 0) {
gchar *out = g_strndup (buf, bytes);
diff --git a/tests/test-magic.c b/tests/test-magic.c
index ecacd14..e0f3fc8 100644
--- a/tests/test-magic.c
+++ b/tests/test-magic.c
@@ -43,8 +43,9 @@ main (int argc, char **argv)
file = g_file_new_for_path (argv[1]);
file_stream = g_file_read (file, NULL, NULL);
- converter = yelp_magic_decompressor_new ();
- stream = g_converter_input_stream_new (file_stream, converter);
+ converter = G_CONVERTER (yelp_magic_decompressor_new ());
+ stream = g_converter_input_stream_new (G_INPUT_STREAM (file_stream),
+ converter);
while ((bytes = g_input_stream_read (stream, buf, 1024, NULL, NULL)) > 0) {
gchar *out = g_strndup (buf, bytes);
diff --git a/tests/test-settings.c b/tests/test-settings.c
index cb74a60..6a8d31e 100644
--- a/tests/test-settings.c
+++ b/tests/test-settings.c
@@ -33,43 +33,43 @@ static GtkWidget *icon_choosers[YELP_SETTINGS_NUM_ICONS];
static GtkWidget *icon_images[YELP_SETTINGS_NUM_ICONS];
static GtkWidget *font_choosers[YELP_SETTINGS_NUM_FONTS];
+#define FORMAT_TMPL "<html><head>" \
+ "<style>" \
+ "body { background-color: %s; color: %s; }" \
+ "div, pre {" \
+ " margin: 0.5em; padding: 0.2em;" \
+ " border: solid 3px %s;" \
+ "}" \
+ "</style>" \
+ "</head><body>" \
+ "<pre>SOME\nMONOSPACE\nTEXT</pre>" \
+ "<div><table>" \
+ "<tr><td>YELP_SETTINGS_COLOR_BASE:</td><td>%s</td></tr>" \
+ "<tr style='color: %s'><td>YELP_SETTINGS_COLOR_TEXT:</td><td>%s</td></tr>" \
+ "<tr style='color: %s'><td>YELP_SETTINGS_COLOR_TEXT_LIGHT:</td><td>%s</td></tr>" \
+ "<tr style='color: %s'><td>YELP_SETTINGS_COLOR_LINK:</td><td>%s</td></tr>" \
+ "<tr style='color: %s'><td>YELP_SETTINGS_COLOR_LINK_VISITED:</td><td>%s</td></tr>" \
+ "</table></div>" \
+ "<div style='background-color:%s;border-color:%s'>" \
+ "<table><tr><td>YELP_SETTINGS_COLOR_GRAY_BASE:</td><td>%s</td></tr>" \
+ "<tr><td>YELP_SETTINGS_COLOR_GRAY_BORDER:</td><td>%s</tr></table></div>" \
+ "<div style='background-color:%s;border-color:%s'>" \
+ "<table><tr><td>YELP_SETTINGS_COLOR_BLUE_BASE:</td><td>%s</td></tr>" \
+ "<tr><td>YELP_SETTINGS_COLOR_BLUE_BORDER:</td><td>%s</tr></table></div>" \
+ "<div style='background-color:%s;border-color:%s'>" \
+ "<table><tr><td>YELP_SETTINGS_COLOR_RED_BASE:</td><td>%s</td></tr>" \
+ "<tr><td>YELP_SETTINGS_COLOR_RED_BORDER:</td><td>%s</tr></table></div>" \
+ "<div style='background-color:%s;border-color:%s'>" \
+ "<table><tr><td>YELP_SETTINGS_COLOR_YELLOW_BASE:</td><td>%s</td></tr>" \
+ "<tr><td>YELP_SETTINGS_COLOR_YELLOW_BORDER:</td><td>%s</tr></table></div>" \
+ "</body></html>"
+
static void
-colors_changed (YelpSettings *settings, gpointer user_data)
+colors_changed (YelpSettings *unused_settings, gpointer user_data)
{
- static const gchar *tmpl =
- "<html><head>"
- "<style>"
- "body { background-color: %s; color: %s; }"
- "div, pre {"
- " margin: 0.5em; padding: 0.2em;"
- " border: solid 3px %s;"
- "}"
- "</style>"
- "</head><body>"
- "<pre>SOME\nMONOSPACE\nTEXT</pre>"
- "<div><table>"
- "<tr><td>YELP_SETTINGS_COLOR_BASE:</td><td>%s</td></tr>"
- "<tr style='color: %s'><td>YELP_SETTINGS_COLOR_TEXT:</td><td>%s</td></tr>"
- "<tr style='color: %s'><td>YELP_SETTINGS_COLOR_TEXT_LIGHT:</td><td>%s</td></tr>"
- "<tr style='color: %s'><td>YELP_SETTINGS_COLOR_LINK:</td><td>%s</td></tr>"
- "<tr style='color: %s'><td>YELP_SETTINGS_COLOR_LINK_VISITED:</td><td>%s</td></tr>"
- "</table></div>"
- "<div style='background-color:%s;border-color:%s'>"
- "<table><tr><td>YELP_SETTINGS_COLOR_GRAY_BASE:</td><td>%s</td></tr>"
- "<tr><td>YELP_SETTINGS_COLOR_GRAY_BORDER:</td><td>%s</tr></table></div>"
- "<div style='background-color:%s;border-color:%s'>"
- "<table><tr><td>YELP_SETTINGS_COLOR_BLUE_BASE:</td><td>%s</td></tr>"
- "<tr><td>YELP_SETTINGS_COLOR_BLUE_BORDER:</td><td>%s</tr></table></div>"
- "<div style='background-color:%s;border-color:%s'>"
- "<table><tr><td>YELP_SETTINGS_COLOR_RED_BASE:</td><td>%s</td></tr>"
- "<tr><td>YELP_SETTINGS_COLOR_RED_BORDER:</td><td>%s</tr></table></div>"
- "<div style='background-color:%s;border-color:%s'>"
- "<table><tr><td>YELP_SETTINGS_COLOR_YELLOW_BASE:</td><td>%s</td></tr>"
- "<tr><td>YELP_SETTINGS_COLOR_YELLOW_BORDER:</td><td>%s</tr></table></div>"
- "</body></html>";
gchar **colors = yelp_settings_get_colors (settings);
gchar *page;
- page = g_strdup_printf (tmpl,
+ page = g_strdup_printf (FORMAT_TMPL,
colors[YELP_SETTINGS_COLOR_BASE], colors[YELP_SETTINGS_COLOR_TEXT],
colors[YELP_SETTINGS_COLOR_BASE], colors[YELP_SETTINGS_COLOR_BASE],
colors[YELP_SETTINGS_COLOR_TEXT], colors[YELP_SETTINGS_COLOR_TEXT],
@@ -94,7 +94,7 @@ colors_changed (YelpSettings *settings, gpointer user_data)
}
static void
-icons_changed (YelpSettings *settings, gpointer user_data)
+icons_changed (YelpSettings *unused_settings, gpointer user_data)
{
gint i;
for (i = 0; i < YELP_SETTINGS_NUM_ICONS; i++) {
@@ -107,7 +107,7 @@ icons_changed (YelpSettings *settings, gpointer user_data)
}
static void
-fonts_changed (YelpSettings *settings, gpointer user_data)
+fonts_changed (YelpSettings *unused_settings, gpointer user_data)
{
g_object_set (websettings,
"default-font-family", yelp_settings_get_font_family (settings,
YELP_SETTINGS_FONT_VARIABLE),
@@ -121,7 +121,7 @@ static void
color_set (GtkColorButton *button,
gpointer user_data)
{
- GdkColor color;
+ GdkRGBA rgba;
gchar str[8];
gint i;
for (i = 0; i < YELP_SETTINGS_NUM_COLORS; i++)
@@ -129,8 +129,8 @@ color_set (GtkColorButton *button,
break;
g_return_if_fail (i < YELP_SETTINGS_NUM_COLORS);
- gtk_color_button_get_color (button, &color);
- g_snprintf (str, 8, "#%02X%02X%02X", color.red / 255, color.green / 255, color.blue / 255);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
+ g_snprintf (str, 8, "#%02g%02g%02g", rgba.red * 255, rgba.green * 255, rgba.blue * 255);
yelp_settings_set_colors (settings, i, str, -1);
}
@@ -225,7 +225,7 @@ main (int argc, char **argv)
g_signal_connect (widget, "toggled", G_CALLBACK (use_gtk_settings_toggled), NULL);
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
- color_table = gtk_table_new (2, 7, TRUE);
+ color_table = gtk_grid_new ();
gtk_widget_set_sensitive (color_table, FALSE);
gtk_box_pack_start (GTK_BOX (vbox), color_table, FALSE, FALSE, 0);
@@ -233,16 +233,15 @@ main (int argc, char **argv)
color_buttons[i] = gtk_color_button_new ();
g_signal_connect (color_buttons[i], "color-set", G_CALLBACK (color_set), NULL);
if (i == 0) {
- gtk_table_attach (GTK_TABLE (color_table), color_buttons[i],
- 0, 1, 0, 2, 0, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (color_table), color_buttons[i],
+ 0, 1, 0, 2);
}
else {
- gtk_table_attach (GTK_TABLE (color_table), color_buttons[i],
+ gtk_grid_attach (GTK_GRID (color_table), color_buttons[i],
(i + 1) / 2,
(i + 1) / 2 + 1,
(i + 1) % 2,
- (i + 1) % 2 + 1,
- 0, 0, 0, 0);
+ (i + 1) % 2 + 1);
}
}
@@ -260,30 +259,28 @@ main (int argc, char **argv)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
- table = gtk_table_new (2, 2, FALSE);
+ table = gtk_grid_new ();
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
widget = gtk_label_new ("Variable");
g_object_set (widget, "xalign", 0.0, NULL);
- gtk_table_attach (GTK_TABLE (table), widget, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), widget, 0, 1, 0, 1);
font_choosers[YELP_SETTINGS_FONT_VARIABLE] = gtk_font_button_new ();
g_signal_connect (font_choosers[YELP_SETTINGS_FONT_VARIABLE], "notify::font-name",
G_CALLBACK (font_set), NULL);
gtk_font_button_set_font_name (GTK_FONT_BUTTON (font_choosers[YELP_SETTINGS_FONT_VARIABLE]),
"Sans 8");
- gtk_table_attach (GTK_TABLE (table), font_choosers[YELP_SETTINGS_FONT_VARIABLE],
- 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 6, 0);
+ gtk_grid_attach (GTK_GRID (table), widget, 1, 2, 0, 1);
widget = gtk_label_new ("Fixed");
g_object_set (widget, "xalign", 0.0, NULL);
- gtk_table_attach (GTK_TABLE (table), widget, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), widget, 0, 1, 1, 2);
font_choosers[YELP_SETTINGS_FONT_FIXED] = gtk_font_button_new ();
g_signal_connect (font_choosers[YELP_SETTINGS_FONT_FIXED], "notify::font-name",
G_CALLBACK (font_set), NULL);
gtk_font_button_set_font_name (GTK_FONT_BUTTON (font_choosers[YELP_SETTINGS_FONT_FIXED]),
"Monospace 8");
- gtk_table_attach (GTK_TABLE (table), font_choosers[YELP_SETTINGS_FONT_FIXED],
- 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 6, 0);
+ gtk_grid_attach (GTK_GRID (table), widget, 1, 2, 1, 2);
widget = gtk_check_button_new_with_label ("Use GtkIconTheme");
g_object_set (widget, "active", TRUE, NULL);
@@ -294,20 +291,19 @@ main (int argc, char **argv)
g_signal_connect (widget, "toggled", G_CALLBACK (use_small_icons_toggled), NULL);
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
- icon_table = gtk_table_new (6, 2, FALSE);
+ icon_table = gtk_grid_new ();
gtk_widget_set_sensitive (icon_table, FALSE);
gtk_box_pack_start (GTK_BOX (vbox), icon_table, FALSE, FALSE, 0);
for (i = 0; i < YELP_SETTINGS_NUM_ICONS; i++) {
const gchar *labels[YELP_SETTINGS_NUM_ICONS] =
- {"BUG", "CAUTION", "IMPORTANT", "NOTE", "TIP", "WARNING"};
+ {"BUG", "IMPORTANT", "NOTE", "TIP", "WARNING"};
widget = gtk_label_new (labels[i]);
g_object_set (widget, "xalign", 0.0, NULL);
- gtk_table_attach (GTK_TABLE (icon_table), widget,
- 0, 1, i, i + 1, GTK_FILL, 0, 0, 0);
+ gtk_grid_attach (GTK_GRID (icon_table), widget, 0, 1, i, i + 1);
icon_choosers[i] = gtk_file_chooser_button_new (labels[i], GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_table_attach (GTK_TABLE (icon_table), icon_choosers[i],
- 1, 2, i, i + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 6, 0);
+ gtk_grid_attach (GTK_GRID (icon_table), icon_choosers[i],
+ 1, 2, i, i + 1);
g_signal_connect (icon_choosers[i], "file-set", G_CALLBACK (icon_file_set), NULL);
}
@@ -329,4 +325,6 @@ main (int argc, char **argv)
gtk_widget_show_all (GTK_WIDGET (window));
gtk_main ();
+
+ return 0;
}
diff --git a/tests/test-transform.c b/tests/test-transform.c
index 88de0fe..5d3304a 100644
--- a/tests/test-transform.c
+++ b/tests/test-transform.c
@@ -114,7 +114,7 @@ main (gint argc, gchar **argv)
xmlDocPtr doc;
YelpTransform *transform;
gchar **params;
- gchar *stylesheet;
+ const gchar *stylesheet;
gchar *file;
context = g_option_context_new ("[STYLESHEET] FILE");
@@ -135,12 +135,12 @@ main (gint argc, gchar **argv)
}
params = g_new0 (gchar *, 7);
- params[0] = "db.chunk.extension";
- params[1] = "\"\"";
- params[2] = "db.chunk.info_basename";
- params[3] = "\"x-yelp-titlepage\"";
- params[4] = "db.chunk.max_depth";
- params[5] = "2";
+ params[0] = g_strdup ("db.chunk.extension");
+ params[1] = g_strdup ("\"\"");
+ params[2] = g_strdup ("db.chunk.info_basename");
+ params[3] = g_strdup ("\"x-yelp-titlepage\"");
+ params[4] = g_strdup ("db.chunk.max_depth");
+ params[5] = g_strdup ("2");
params[6] = NULL;
transform = yelp_transform_new (stylesheet);
@@ -160,7 +160,7 @@ main (gint argc, gchar **argv)
xmlXIncludeProcessFlags (doc,
XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA |
XML_PARSE_NOENT | XML_PARSE_NONET );
- if (!yelp_transform_start (transform, doc, params, NULL))
+ if (!yelp_transform_start (transform, doc, (xmlDocPtr)params, NULL))
return 1;
if (random_timeout) {
diff --git a/tests/test-uri.c b/tests/test-uri.c
index 73106e3..0f50abf 100644
--- a/tests/test-uri.c
+++ b/tests/test-uri.c
@@ -33,7 +33,8 @@ static void
print_uri (gchar *orig, YelpUri *uri, GOutputStream *stream)
{
GFile *file;
- gchar *type = NULL, *tmp, **tmpv, *out;
+ const gchar *type = NULL;
+ gchar *tmp, **tmpv, *out;
g_output_stream_write (stream, orig, strlen (orig), NULL, NULL);
g_output_stream_write (stream, "\n", 1, NULL, NULL);
@@ -75,6 +76,9 @@ print_uri (gchar *orig, YelpUri *uri, GOutputStream *stream)
case YELP_URI_DOCUMENT_TYPE_UNRESOLVED:
type = "UNRESOLVED";
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
out = g_strdup_printf ("DOCUMENT TYPE: %s\n", type);
diff --git a/tests/test-view.c b/tests/test-view.c
index bab71dc..0d6f3a8 100644
--- a/tests/test-view.c
+++ b/tests/test-view.c
@@ -61,9 +61,6 @@ int
main (int argc, char **argv)
{
GtkWidget *window, *vbox, *entry, *scroll, *view;
- YelpUri *uri;
- YelpDocument *document;
- GCancellable *cancellable;
gtk_init (&argc, &argv);
@@ -93,17 +90,19 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (scroll), view);
- g_signal_connect (entry, "activate", activate_cb, view);
+ g_signal_connect (entry, "activate", G_CALLBACK (activate_cb), view);
if (argc >= 2) {
/* I put in the double-load to test some race condition bugs.
* I decided to leave it in.
*/
- yelp_view_load (view, argv[1]);
- yelp_view_load (view, argv[1]);
+ yelp_view_load (YELP_VIEW (view), argv[1]);
+ yelp_view_load (YELP_VIEW (view), argv[1]);
}
gtk_widget_show_all (GTK_WIDGET (window));
gtk_main ();
+
+ return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]