From d1cd6aacba55ea86d8b53638a18208cb19208f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 6 Mar 2020 18:05:43 +0100 Subject: [PATCH] tests: Add common_cflags to build And fix all the errors and warnings resulting from that See #2491 --- tests/frame-stats.c | 6 +- tests/gtkgears.c | 2 +- tests/listmodel.c | 1 + tests/meson.build | 2 +- tests/print-editor.c | 4 +- tests/rendernode-create-tests.c | 20 +++--- tests/scrolling-performance.c | 5 +- tests/showrendernode.c | 6 +- tests/simple.c | 2 +- tests/test.xpm | 2 +- tests/testadjustsize.c | 4 +- tests/testappchooserbutton.c | 4 +- tests/testassistant.c | 2 +- tests/testbaseline.c | 6 +- tests/testblur.c | 2 +- tests/testcalendar.c | 2 +- tests/testcellrenderertext.c | 4 +- tests/testcolorchooser.c | 6 +- tests/testcombochange.c | 6 +- tests/testdialog.c | 2 + tests/testdnd.c | 38 +++------- tests/testdnd2.c | 4 +- tests/testentrycompletion.c | 12 ++-- tests/testfilechooser.c | 119 +------------------------------- tests/testfilechooserbutton.c | 2 +- tests/testflowbox.c | 2 + tests/testgaction.c | 16 +++-- tests/testgmenu.c | 10 +-- tests/testgtk.c | 104 ++++++++++++++-------------- tests/testheaderbar.c | 6 +- tests/testicontheme.c | 2 +- tests/testiconview-keynav.c | 2 +- tests/testkineticscrolling.c | 16 ++--- tests/testlist.c | 3 +- tests/testlist4.c | 3 +- tests/testlockbutton.c | 7 +- tests/testmenubutton.c | 8 +-- tests/testnotebookdnd.c | 20 +++--- tests/testoverlay.c | 8 +-- tests/testpixbuf-scale.c | 6 +- tests/testselectionmode.c | 5 +- tests/teststack.c | 20 +++--- tests/teststackedheaders.c | 8 ++- tests/teststackedheaders.ui | 2 - tests/testtextview.c | 1 + tests/testtooltips.c | 1 + tests/testtreecolumns.c | 18 +++-- tests/testtreednd.c | 1 + tests/testtreeedit.c | 2 + tests/testtreeflow.c | 4 +- tests/testtreelistmodel.c | 10 +-- tests/testtreemodel.c | 2 +- tests/testtreesort.c | 20 ++---- tests/testtreeview.c | 8 ++- tests/testwidgetfocus.c | 8 +-- tests/testwidgettransforms.c | 6 +- tests/treestoretest.c | 8 ++- tests/video-timer.c | 3 + 58 files changed, 255 insertions(+), 348 deletions(-) diff --git a/tests/frame-stats.c b/tests/frame-stats.c index a9fb004072..acfd668e90 100644 --- a/tests/frame-stats.c +++ b/tests/frame-stats.c @@ -130,7 +130,7 @@ on_frame_clock_after_paint (GdkFrameClock *frame_clock, } } -void +static void on_window_realize (GtkWidget *window, FrameStats *frame_stats) { @@ -139,7 +139,7 @@ on_window_realize (GtkWidget *window, G_CALLBACK (on_frame_clock_after_paint), frame_stats); } -void +static void on_window_unrealize (GtkWidget *window, FrameStats *frame_stats) { @@ -149,7 +149,7 @@ on_window_unrealize (GtkWidget *window, frame_stats->frame_clock = NULL; } -void +static void on_window_destroy (GtkWidget *window, FrameStats *stats) { diff --git a/tests/gtkgears.c b/tests/gtkgears.c index 32a24dafb4..8a677969c7 100644 --- a/tests/gtkgears.c +++ b/tests/gtkgears.c @@ -511,7 +511,7 @@ invert(GLfloat *m) * @param zNear the near clipping plane * @param zFar the far clipping plane */ -void perspective(GLfloat *m, GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) +static void perspective(GLfloat *m, GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) { GLfloat tmp[16]; double sine, cosine, cotangent, deltaZ; diff --git a/tests/listmodel.c b/tests/listmodel.c index 6bd64960fe..ee61a053f0 100644 --- a/tests/listmodel.c +++ b/tests/listmodel.c @@ -22,6 +22,7 @@ typedef struct GObjectClass parent_class; } MyObjectClass; +static GType my_object_get_type (void); G_DEFINE_TYPE (MyObject, my_object, G_TYPE_OBJECT) static void diff --git a/tests/meson.build b/tests/meson.build index e13cbe4179..abf681fcc3 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -145,7 +145,7 @@ foreach t: gtk_tests test_srcs = ['@0@.c'.format(test_name), t.get(1, [])] executable(test_name, test_srcs, include_directories: [confinc, gdkinc], - c_args: test_args, + c_args: test_args + common_cflags, dependencies: [libgtk_dep, libm]) endforeach diff --git a/tests/print-editor.c b/tests/print-editor.c index 7e2d0f0796..944e4cdcce 100644 --- a/tests/print-editor.c +++ b/tests/print-editor.c @@ -682,14 +682,14 @@ static const gchar ui_info[] = ""; static void -buffer_changed_callback (GtkTextBuffer *buffer) +buffer_changed_callback (GtkTextBuffer *text_buffer) { file_changed = TRUE; update_statusbar (); } static void -mark_set_callback (GtkTextBuffer *buffer, +mark_set_callback (GtkTextBuffer *text_buffer, const GtkTextIter *new_location, GtkTextMark *mark, gpointer data) diff --git a/tests/rendernode-create-tests.c b/tests/rendernode-create-tests.c index c81a457169..97418a60cf 100644 --- a/tests/rendernode-create-tests.c +++ b/tests/rendernode-create-tests.c @@ -78,7 +78,7 @@ hsv_to_rgb (GdkRGBA *rgba, } } -GskRenderNode * +static GskRenderNode * rounded_borders (guint n) { GskRenderNode **nodes = g_newa (GskRenderNode *, n); @@ -112,7 +112,7 @@ rounded_borders (guint n) return container; } -GskRenderNode * +static GskRenderNode * rounded_backgrounds (guint n) { GskRenderNode **nodes = g_newa (GskRenderNode *, n); @@ -145,7 +145,7 @@ rounded_backgrounds (guint n) return container; } -GskRenderNode * +static GskRenderNode * colors (guint n) { GskRenderNode **nodes = g_new (GskRenderNode *, 10 * n); @@ -174,7 +174,7 @@ colors (guint n) return container; } -GskRenderNode * +static GskRenderNode * clipped_colors (guint n) { GskRenderNode **nodes = g_newa (GskRenderNode *,n); @@ -241,7 +241,7 @@ compare_color_stops (gconstpointer a, return 0; } -GskRenderNode * +static GskRenderNode * linear_gradient (guint n) { GskRenderNode **nodes = g_newa (GskRenderNode *, n); @@ -306,7 +306,7 @@ linear_gradient (guint n) return container; } -GskRenderNode * +static GskRenderNode * borders (guint n) { GskRenderNode **nodes = g_newa (GskRenderNode *, n); @@ -355,7 +355,7 @@ const char *example = "Beware the Jubjub bird, and shun\n" "The frumious Bandersnatch!'"; -GskRenderNode * +static GskRenderNode * text (guint n) { GPtrArray *nodes; @@ -447,7 +447,7 @@ text (guint n) return container; } -GskRenderNode * +static GskRenderNode * cairo_node (guint n) { GskRenderNode **nodes = g_newa (GskRenderNode *, n); @@ -472,7 +472,7 @@ cairo_node (guint n) return container; } -GskRenderNode * +static GskRenderNode * box_shadows (guint n) { GskRenderNode **nodes = g_newa (GskRenderNode *, n); @@ -540,7 +540,7 @@ main (int argc, char **argv) GError *error = NULL; GskRenderNode *node; GPatternSpec *matcher; - char *pattern; + const char *pattern; guint i, n; gtk_init (); diff --git a/tests/scrolling-performance.c b/tests/scrolling-performance.c index ed6d0175bf..65a1c03f18 100644 --- a/tests/scrolling-performance.c +++ b/tests/scrolling-performance.c @@ -17,6 +17,7 @@ typedef struct typedef GtkTextViewClass MyTextViewClass; +static GType my_text_view_get_type (void); G_DEFINE_TYPE (MyTextView, my_text_view, GTK_TYPE_TEXT_VIEW) static void @@ -27,7 +28,7 @@ my_text_view_class_init (MyTextViewClass *tv_class) {} -GtkWidget * +static GtkWidget * create_widget_factory_content (void) { GError *error = NULL; @@ -64,7 +65,7 @@ set_adjustment_to_fraction (GtkAdjustment *adjustment, fraction * (upper - page_size)); } -gboolean +static gboolean scroll_viewport (GtkWidget *viewport, GdkFrameClock *frame_clock, gpointer user_data) diff --git a/tests/showrendernode.c b/tests/showrendernode.c index 0b30e8b462..02e30e7ca2 100644 --- a/tests/showrendernode.c +++ b/tests/showrendernode.c @@ -187,8 +187,8 @@ main (int argc, char **argv) if (write_to_filename != NULL) { - GdkSurface *window = gdk_surface_new_toplevel (gdk_display_get_default(), 10 , 10); - GskRenderer *renderer = gsk_renderer_new_for_surface (window); + GdkSurface *surface = gdk_surface_new_toplevel (gdk_display_get_default(), 10 , 10); + GskRenderer *renderer = gsk_renderer_new_for_surface (surface); GdkTexture *texture = gsk_renderer_render_texture (renderer, GTK_NODE_VIEW (nodeview)->node, NULL); g_message ("Writing .node file to .png using %s", G_OBJECT_TYPE_NAME (renderer)); @@ -201,7 +201,7 @@ main (int argc, char **argv) g_object_unref (texture); g_object_unref (renderer); - g_object_unref (window); + g_object_unref (surface); } if (compare_node) diff --git a/tests/simple.c b/tests/simple.c index 495e86031e..5cabb59cf5 100644 --- a/tests/simple.c +++ b/tests/simple.c @@ -19,7 +19,7 @@ #include -void +static void hello (void) { g_print ("hello world\n"); diff --git a/tests/test.xpm b/tests/test.xpm index 9b0d2efdb2..94ba706ce4 100644 --- a/tests/test.xpm +++ b/tests/test.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char *openfile[] = { +static const char *openfile[] = { /* width height num_colors chars_per_pixel */ " 20 19 66 2", /* colors */ diff --git a/tests/testadjustsize.c b/tests/testadjustsize.c index b2e67a2db4..18c7a83c24 100644 --- a/tests/testadjustsize.c +++ b/tests/testadjustsize.c @@ -62,9 +62,9 @@ static void quit_cb (GtkWidget *widget, gpointer data) { - gboolean *done = data; + gboolean *is_done = data; - *done = TRUE; + *is_done = TRUE; g_main_context_wakeup (NULL); } diff --git a/tests/testappchooserbutton.c b/tests/testappchooserbutton.c index 032c54855c..9d69ce0189 100644 --- a/tests/testappchooserbutton.c +++ b/tests/testappchooserbutton.c @@ -27,12 +27,12 @@ static GtkWidget *toplevel, *button, *box; static GtkWidget *sel_image, *sel_name; static void -combo_changed_cb (GtkAppChooserButton *button, +combo_changed_cb (GtkAppChooserButton *chooser_button, gpointer user_data) { GAppInfo *app_info; - app_info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (button)); + app_info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser_button)); if (app_info == NULL) return; diff --git a/tests/testassistant.c b/tests/testassistant.c index 2f1c8cf7ab..365e8bd9f3 100644 --- a/tests/testassistant.c +++ b/tests/testassistant.c @@ -677,7 +677,7 @@ create_page_flipping_assistant (GtkWidget *widget) } struct { - gchar *text; + const char *text; void (*func) (GtkWidget *widget); } buttons[] = { diff --git a/tests/testbaseline.c b/tests/testbaseline.c index d4575ab678..e825e6adea 100644 --- a/tests/testbaseline.c +++ b/tests/testbaseline.c @@ -18,7 +18,7 @@ #include -static char *baseline_pos_str[] = { +static const char *baseline_pos_str[] = { "BASELINE_POSITION_TOP", "BASELINE_POSITION_CENTER", "BASELINE_POSITION_BOTTOM" @@ -114,7 +114,7 @@ main (int argc, hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_container_add (GTK_CONTAINER (vbox), hbox); - char *aligns_names[] = { "FILL", "BASELINE" }; + const char *aligns_names[] = { "FILL", "BASELINE" }; GtkAlign aligns[] = { GTK_ALIGN_FILL, GTK_ALIGN_BASELINE}; label = gtk_label_new (aligns_names[j]); @@ -251,7 +251,7 @@ main (int argc, for (j = 0; j < 4; j++) { - char *labels[] = { "Normal:", "Baseline (top):", "Baseline (center):", "Baseline (bottom):"}; + const char *labels[] = { "Normal:", "Baseline (top):", "Baseline (center):", "Baseline (bottom):"}; label = gtk_label_new (labels[j]); gtk_grid_attach (GTK_GRID (grid), diff --git a/tests/testblur.c b/tests/testblur.c index 8c3a7a0da1..6baf0b01f9 100644 --- a/tests/testblur.c +++ b/tests/testblur.c @@ -17,7 +17,7 @@ struct _GtkBlurBoxClass }; typedef struct _GtkBlurBoxClass GtkBlurBoxClass; - +static GType gtk_blur_box_get_type (void); G_DEFINE_TYPE (GtkBlurBox, gtk_blur_box, GTK_TYPE_BOX) diff --git a/tests/testcalendar.c b/tests/testcalendar.c index 49dfc42b83..443e7cc91a 100644 --- a/tests/testcalendar.c +++ b/tests/testcalendar.c @@ -50,7 +50,7 @@ enum static char * calendar_date_to_string (CalendarData *data, - char *format) + const char *format) { GDateTime *date; char *str; diff --git a/tests/testcellrenderertext.c b/tests/testcellrenderertext.c index eb572ff94a..d33b721c54 100644 --- a/tests/testcellrenderertext.c +++ b/tests/testcellrenderertext.c @@ -26,8 +26,8 @@ #define NUM_COLS 17 /* change this when adding columns */ struct cell_params { - char *description; /* 0 */ - char *test; /* 1 */ + const char *description; /* 0 */ + const char *test; /* 1 */ int xpad; /* 2 */ int ypad; /* 3 */ double xalign; /* 4 */ diff --git a/tests/testcolorchooser.c b/tests/testcolorchooser.c index ee0d643cb7..b438547877 100644 --- a/tests/testcolorchooser.c +++ b/tests/testcolorchooser.c @@ -61,13 +61,13 @@ main (int argc, char *argv[]) const gchar *c[9] = { "red", "maroon", "yellow", "green", "blue", "magenta", "DarkOliveGreen4", "khaki2", "thistle1" }; GdkRGBA color; GdkRGBA colors[9*9]; - gint i,j; + gint k,j; gdouble f[5] = { 0.2, 0.35, 0.5, 0.65, 0.8 }; g_print ("setting custom palette\n"); - for (i = 0; i < 9; i++) + for (k = 0; k < 9; k++) { - gdk_rgba_parse (&color, c[i]); + gdk_rgba_parse (&color, c[k]); for (j = 0; j < 5; j++) { colors[i*9 + j].red = f[j]*color.red; diff --git a/tests/testcombochange.c b/tests/testcombochange.c index ea52eb4943..bdaadf19ca 100644 --- a/tests/testcombochange.c +++ b/tests/testcombochange.c @@ -33,9 +33,9 @@ test_init (void) g_setenv ("GTK_IM_MODULE_FILE", "../modules/input/immodules.cache", TRUE); } -static void +G_GNUC_PRINTF (1, 2) static void combochange_log (const char *fmt, - ...) + ...) { GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); GtkTextIter iter; @@ -204,6 +204,8 @@ animation_timer (gpointer data) case 2: on_reorder (); break; + default: + g_assert_not_reached (); } n_animations--; diff --git a/tests/testdialog.c b/tests/testdialog.c index d53874e3b6..7b68f8a15d 100644 --- a/tests/testdialog.c +++ b/tests/testdialog.c @@ -200,6 +200,7 @@ typedef struct { GtkDialogClass parent_class; } MyDialogClass; +static GType my_dialog_get_type (void); G_DEFINE_TYPE (MyDialog, my_dialog, GTK_TYPE_DIALOG); static void @@ -270,6 +271,7 @@ typedef struct { GtkDialogClass parent_class; } MyDialog2Class; +static GType my_dialog2_get_type (void); G_DEFINE_TYPE (MyDialog2, my_dialog2, GTK_TYPE_DIALOG); static void diff --git a/tests/testdnd.c b/tests/testdnd.c index ec1a5c2a08..7f4f1626cb 100644 --- a/tests/testdnd.c +++ b/tests/testdnd.c @@ -307,7 +307,7 @@ action_make_unique (GdkDragAction action) return 0; } -GdkDragAction +static GdkDragAction trash_drag_enter (GtkDropTarget *dest, GdkDrop *drop, double x, @@ -325,7 +325,7 @@ trash_drag_enter (GtkDropTarget *dest, return action_make_unique (gdk_drop_get_actions (drop));; } -GdkDragAction +static GdkDragAction trash_drag_leave (GtkDropTarget *dest, GdkDrop *drop, GtkWidget *widget) @@ -341,7 +341,7 @@ trash_drag_leave (GtkDropTarget *dest, return action_make_unique (gdk_drop_get_actions (drop)); } -gboolean +static gboolean trash_drag_drop (GtkDropTarget *dest, GdkDrop *drop, double x, @@ -359,7 +359,7 @@ trash_drag_drop (GtkDropTarget *dest, return TRUE; } -gboolean +static gboolean label_drag_drop (GtkDropTarget *dest, const GValue *value, int x, @@ -381,7 +381,7 @@ static gboolean in_popup = FALSE; static guint popdown_timer = 0; static guint popup_timer = 0; -gint +static int popdown_cb (gpointer data) { popdown_timer = 0; @@ -392,7 +392,7 @@ popdown_cb (gpointer data) return FALSE; } -void +static void popup_enter (GtkDropTarget *dest) { g_print ("popup enter\n"); @@ -408,7 +408,7 @@ popup_enter (GtkDropTarget *dest) } } -void +static void popup_leave (GtkDropTarget *dest) { g_print ("popup leave\n"); @@ -430,7 +430,7 @@ popup_drop (GtkDropTarget *dest) return TRUE; } -gboolean +static gboolean popup_cb (gpointer data) { if (!popped_up) @@ -474,16 +474,7 @@ popup_cb (gpointer data) return FALSE; } -gboolean -popsite_motion (GtkDropTarget *dest, - int x, - int y, - GtkWidget *widget) -{ - return TRUE; -} - -void +static void popsite_enter (GtkDropControllerMotion *motion) { g_print ("popsite enter\n"); @@ -491,7 +482,7 @@ popsite_enter (GtkDropControllerMotion *motion) popup_timer = g_timeout_add (500, popup_cb, NULL); } -void +static void popsite_leave (GtkDropControllerMotion *motion) { g_print ("popsite leave\n"); @@ -502,14 +493,7 @@ popsite_leave (GtkDropControllerMotion *motion) } } -void -source_drag_data_delete (GtkWidget *widget, - gpointer data) -{ - g_print ("Delete the data!\n"); -} - -void +static void test_init (void) { if (g_file_test ("../modules/input/immodules.cache", G_FILE_TEST_EXISTS)) diff --git a/tests/testdnd2.c b/tests/testdnd2.c index 2294b2539e..cf64e69035 100644 --- a/tests/testdnd2.c +++ b/tests/testdnd2.c @@ -79,6 +79,8 @@ get_image_texture (GtkImage *image) 0); paintable = GDK_PAINTABLE (icon); break; + case GTK_IMAGE_GICON: + case GTK_IMAGE_EMPTY: default: g_warning ("Image storage type %d not handled", gtk_image_get_storage_type (image)); @@ -323,7 +325,7 @@ drag_cancel (GtkDragSource *source, return FALSE; } -GtkWidget * +static GtkWidget * make_image (const gchar *icon_name, int hotspot) { GtkWidget *image; diff --git a/tests/testentrycompletion.c b/tests/testentrycompletion.c index c24478cf2e..39bd22719d 100644 --- a/tests/testentrycompletion.c +++ b/tests/testentrycompletion.c @@ -24,7 +24,7 @@ /* Don't copy this bad example; inline RGB data is always a better * idea than inline XPMs. */ -static char *book_closed_xpm[] = { +static const char *book_closed_xpm[] = { "16 16 6 1", " c None s None", ". c black", @@ -54,7 +54,7 @@ static GtkWidget *window = NULL; /* Creates a tree model containing the completions */ -GtkTreeModel * +static GtkTreeModel * create_simple_completion_model (void) { GtkListStore *store; @@ -120,7 +120,7 @@ create_simple_completion_model (void) } /* Creates a tree model containing the completions */ -GtkTreeModel * +static GtkTreeModel * create_completion_model (void) { GtkListStore *store; @@ -192,7 +192,7 @@ activated_cb (GtkEntryCompletion *completion, static gint timer_count = 0; -static gchar *dynamic_completions[] = { +static const char *dynamic_completions[] = { "GNOME", "gnominious", "Gnomonic projection", @@ -269,7 +269,7 @@ animation_timer (GtkEntryCompletion *completion) return TRUE; } -gboolean +static gboolean match_selected_cb (GtkEntryCompletion *completion, GtkTreeModel *model, GtkTreeIter *iter) @@ -297,7 +297,7 @@ quit_cb (GtkWidget *widget, g_main_context_wakeup (NULL); } -int +int main (int argc, char *argv[]) { GtkWidget *vbox; diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c index 32f36eae06..0a9e19e2bf 100644 --- a/tests/testfilechooser.c +++ b/tests/testfilechooser.c @@ -140,123 +140,6 @@ filter_changed (GtkFileChooserDialog *dialog, #include #define _(s) (s) -static void -size_prepared_cb (GdkPixbufLoader *loader, - int width, - int height, - int *data) -{ - int des_width = data[0]; - int des_height = data[1]; - - if (des_height >= height && des_width >= width) { - /* Nothing */ - } else if ((double)height * des_width > (double)width * des_height) { - width = 0.5 + (double)width * des_height / (double)height; - height = des_height; - } else { - height = 0.5 + (double)height * des_width / (double)width; - width = des_width; - } - - gdk_pixbuf_loader_set_size (loader, width, height); -} - -GdkPixbuf * -my_new_from_file_at_size (const char *filename, - int width, - int height, - GError **error) -{ - GdkPixbufLoader *loader; - GdkPixbuf *pixbuf; - int info[2]; - struct stat st; - - guchar buffer [4096]; - int length; - FILE *f; - - g_return_val_if_fail (filename != NULL, NULL); - g_return_val_if_fail (width > 0 && height > 0, NULL); - - if (stat (filename, &st) != 0) { - int errsv = errno; - - g_set_error (error, - G_FILE_ERROR, - g_file_error_from_errno (errsv), - _("Could not get information for file '%s': %s"), - filename, g_strerror (errsv)); - return NULL; - } - - if (!S_ISREG (st.st_mode)) - return NULL; - - f = fopen (filename, "rb"); - if (!f) { - int errsv = errno; - - g_set_error (error, - G_FILE_ERROR, - g_file_error_from_errno (errsv), - _("Failed to open file '%s': %s"), - filename, g_strerror (errsv)); - return NULL; - } - - loader = gdk_pixbuf_loader_new (); -#ifdef DONT_PRESERVE_ASPECT - gdk_pixbuf_loader_set_size (loader, width, height); -#else - info[0] = width; - info[1] = height; - g_signal_connect (loader, "size-prepared", G_CALLBACK (size_prepared_cb), info); -#endif - - while (!feof (f)) { - length = fread (buffer, 1, sizeof (buffer), f); - if (length > 0) - if (!gdk_pixbuf_loader_write (loader, buffer, length, error)) { - gdk_pixbuf_loader_close (loader, NULL); - fclose (f); - g_object_unref (loader); - return NULL; - } - } - - fclose (f); - - g_assert (*error == NULL); - if (!gdk_pixbuf_loader_close (loader, error)) { - g_object_unref (loader); - return NULL; - } - - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - - if (!pixbuf) { - g_object_unref (loader); - - /* did the loader set an error? */ - if (*error != NULL) - return NULL; - - g_set_error (error, - GDK_PIXBUF_ERROR, - GDK_PIXBUF_ERROR_FAILED, - _("Failed to load image '%s': reason not known, probably a corrupt image file"), - filename); - return NULL; - } - - g_object_ref (pixbuf); - - g_object_unref (loader); - - return pixbuf; -} static void set_current_folder (GtkFileChooser *chooser, @@ -487,6 +370,8 @@ main (int argc, char **argv) _("_Save"), GTK_RESPONSE_OK, NULL); break; + default: + g_assert_not_reached (); } gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); diff --git a/tests/testfilechooserbutton.c b/tests/testfilechooserbutton.c index 2113fa65ea..da1d6e708c 100644 --- a/tests/testfilechooserbutton.c +++ b/tests/testfilechooserbutton.c @@ -31,7 +31,7 @@ #include -static gchar *backend = "gtk+"; +static const char *backend = "gtk+"; static gboolean rtl = FALSE; static GOptionEntry entries[] = { { "backend", 'b', 0, G_OPTION_ARG_STRING, &backend, "The filesystem backend to use.", "gtk+" }, diff --git a/tests/testflowbox.c b/tests/testflowbox.c index 2350b64c82..91d178753a 100644 --- a/tests/testflowbox.c +++ b/tests/testflowbox.c @@ -94,6 +94,8 @@ populate_flowbox_focus (GtkFlowBox *flowbox) widget = gtk_label_new ("bla"); sensitive = FALSE; break; + default: + g_assert_not_reached (); } gtk_container_add (GTK_CONTAINER (box), widget); diff --git a/tests/testgaction.c b/tests/testgaction.c index ac3cead041..0800a15eb0 100644 --- a/tests/testgaction.c +++ b/tests/testgaction.c @@ -4,26 +4,34 @@ GtkWidget *label; static void -change_label_button () +change_label_button (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { gtk_label_set_label (GTK_LABEL (label), "Text set from button"); } static void -normal_menu_item () +normal_menu_item (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { gtk_label_set_label (GTK_LABEL (label), "Text set from normal menu item"); } static void -toggle_menu_item () +toggle_menu_item (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { gtk_label_set_label (GTK_LABEL (label), "Text set from toggle menu item"); } static void -submenu_item () +submenu_item (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { gtk_label_set_label (GTK_LABEL (label), "Text set from submenu item"); } diff --git a/tests/testgmenu.c b/tests/testgmenu.c index 98d45c51f9..87134a124c 100644 --- a/tests/testgmenu.c +++ b/tests/testgmenu.c @@ -349,17 +349,17 @@ create_action_treeview (GActionGroup *group) GtkTreeIter iter; GtkTreeViewColumn *column; GtkCellRenderer *cell; - gchar **actions; + gchar **group_actions; gint i; store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - actions = g_action_group_list_actions (group); - for (i = 0; actions[i]; i++) + group_actions = g_action_group_list_actions (group); + for (i = 0; group_actions[i]; i++) { gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, actions[i], -1); + gtk_list_store_set (store, &iter, 0, group_actions[i], -1); } - g_strfreev (actions); + g_strfreev (group_actions); g_object_set_data (G_OBJECT (store), "group", group); tv = gtk_tree_view_new (); diff --git a/tests/testgtk.c b/tests/testgtk.c index 77fa65e7f0..b5ec4d64b0 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -51,7 +51,7 @@ static gboolean done = FALSE; -gboolean +static gboolean file_exists (const char *filename) { struct stat statbuf; @@ -60,7 +60,7 @@ file_exists (const char *filename) } static GtkWidget * -build_option_menu (gchar *items[], +build_option_menu (const char *items[], gint num_items, gint history, void (*func) (GtkWidget *widget, gpointer data), @@ -91,7 +91,7 @@ typedef struct sTreeButtons { /* end of tree section */ static GtkWidget * -build_option_menu (gchar *items[], +build_option_menu (const char *items[], gint num_items, gint history, void (*func)(GtkWidget *widget, gpointer data), @@ -180,7 +180,7 @@ on_composited_changed (GdkDisplay *display, gtk_widget_queue_draw (GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (label)))); } -void +static void create_alpha_window (GtkWidget *widget) { static GtkWidget *window; @@ -599,8 +599,8 @@ create_radio_buttons (GtkWidget *widget) */ static GtkWidget* -new_pixbuf (char *filename, - GdkSurface *window) +new_pixbuf (const char *filename, + GdkSurface *window) { GtkWidget *widget; GdkPixbuf *pixbuf; @@ -674,7 +674,7 @@ statusbar_popped (GtkStatusbar *statusbar, static void statusbar_contexts (GtkStatusbar *statusbar) { - gchar *string; + const char *string; string = "any context"; g_print ("GtkStatusBar: context=\"%s\", context_id=%d\n", @@ -916,7 +916,7 @@ activate_link (GtkWidget *label, const gchar *uri, gpointer data) return FALSE; } -void create_labels (GtkWidget *widget) +static void create_labels (GtkWidget *widget) { static GtkWidget *window = NULL; GtkWidget *hbox; @@ -1132,7 +1132,7 @@ on_rotated_text_draw (GtkDrawingArea *drawing_area, n_words = G_N_ELEMENTS (words); for (i = 0; i < n_words; i++) { - int width, height; + int layout_width, layout_height; cairo_save (cr); @@ -1140,9 +1140,9 @@ on_rotated_text_draw (GtkDrawingArea *drawing_area, pango_cairo_update_layout (cr, layout); pango_layout_set_text (layout, words[i], -1); - pango_layout_get_size (layout, &width, &height); + pango_layout_get_size (layout, &layout_width, &layout_height); - cairo_move_to (cr, - width / 2 / PANGO_SCALE, - DEFAULT_TEXT_RADIUS); + cairo_move_to (cr, - layout_width / 2 / PANGO_SCALE, - DEFAULT_TEXT_RADIUS); pango_cairo_show_layout (cr, layout); cairo_restore (cr); @@ -2509,7 +2509,7 @@ spin_button_month_input_func (GtkSpinButton *spin_button, gdouble *new_val) { gint i; - static gchar *month[12] = { "January", "February", "March", "April", + static const char *month[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; gchar *tmp1, *tmp2; @@ -2541,7 +2541,7 @@ spin_button_month_output_func (GtkSpinButton *spin_button) GtkAdjustment *adjustment; gdouble value; gint i; - static gchar *month[12] = { "January", "February", "March", "April", + static const char *month[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; @@ -3168,7 +3168,7 @@ create_cursors (GtkWidget *widget) * GtkColorSelection */ -void +static void create_color_selection (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -3206,7 +3206,7 @@ create_color_selection (GtkWidget *widget) gtk_widget_destroy (window); } -void +static void flipping_toggled_cb (GtkWidget *widget, gpointer data) { int state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); @@ -3243,7 +3243,7 @@ orientable_toggle_orientation (GtkOrientable *orientable) } } -void +static void flipping_orientation_toggled_cb (GtkWidget *widget, gpointer data) { GtkWidget *content_area; @@ -3285,7 +3285,7 @@ create_forward_back (const char *title, return frame; } -void +static void create_flipping (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -3345,7 +3345,7 @@ create_flipping (GtkWidget *widget) * GtkFontSelection */ -void +static void create_font_selection (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -3530,13 +3530,13 @@ screen_display_check (GtkWidget *widget, ScreenDisplaySelection *data) } } -void +static void screen_display_destroy_diag (GtkWidget *widget, GtkWidget *data) { gtk_widget_destroy (data); } -void +static void create_display_screen (GtkWidget *widget) { GtkWidget *grid, *frame, *window, *combo_dpy, *vbox; @@ -3966,6 +3966,8 @@ notebook_type_changed (GtkWidget *optionmenu, return; break; + default: + g_assert_not_reached (); } if (gtk_notebook_get_n_pages (notebook) == 15) @@ -3994,7 +3996,7 @@ create_notebook (GtkWidget *widget) GtkWidget *omenu; GtkWidget *label; - static gchar *items[] = + static const char *items[] = { "Standard", "No tabs", @@ -4103,7 +4105,7 @@ create_notebook (GtkWidget *widget) * GtkPanes */ -void +static void toggle_resize (GtkWidget *widget, GtkWidget *child) { GtkPaned *paned = GTK_PANED (gtk_widget_get_parent (child)); @@ -4117,7 +4119,7 @@ toggle_resize (GtkWidget *widget, GtkWidget *child) g_object_set (paned, prop, !resize, NULL); } -void +static void toggle_shrink (GtkWidget *widget, GtkWidget *child) { GtkPaned *paned = GTK_PANED (gtk_widget_get_parent (child)); @@ -4131,7 +4133,7 @@ toggle_shrink (GtkWidget *widget, GtkWidget *child) g_object_set (paned, prop, !resize, NULL); } -GtkWidget * +static GtkWidget * create_pane_options (GtkPaned *paned, const gchar *frame_label, const gchar *label1, @@ -4190,7 +4192,7 @@ create_pane_options (GtkPaned *paned, return frame; } -void +static void create_panes (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -4642,7 +4644,7 @@ create_paned_keyboard_navigation (GtkWidget *widget) * WM Hints demo */ -void +static void create_wmhints (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -4836,7 +4838,7 @@ tracking_label (GtkWidget *window) return hbox; } -void +static void keep_window_above (GtkToggleButton *togglebutton, gpointer data) { GtkWidget *button = g_object_get_data (G_OBJECT (togglebutton), "radio"); @@ -4848,7 +4850,7 @@ keep_window_above (GtkToggleButton *togglebutton, gpointer data) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE); } -void +static void keep_window_below (GtkToggleButton *togglebutton, gpointer data) { GtkWidget *button = g_object_get_data (G_OBJECT (togglebutton), "radio"); @@ -4957,7 +4959,7 @@ get_state_controls (GtkWidget *window) return vbox; } -void +static void create_surface_states (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -5248,7 +5250,7 @@ window_controls (GtkWidget *window) return control_window; } -void +static void create_window_sizing (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -5310,7 +5312,7 @@ typedef struct _ProgressData { gboolean activity; } ProgressData; -gboolean +static gboolean progress_timeout (gpointer data) { ProgressData *pdata = data; @@ -5429,7 +5431,7 @@ entry_changed (GtkWidget *widget, ProgressData *pdata) gtk_editable_get_text (GTK_EDITABLE (pdata->entry))); } -void +static void create_progress_bar (GtkWidget *widget) { GtkWidget *content_area; @@ -5442,7 +5444,7 @@ create_progress_bar (GtkWidget *widget) GtkWidget *label; static ProgressData *pdata = NULL; - static gchar *items1[] = + static const char *items1[] = { "Left-Right", "Right-Left", @@ -5450,7 +5452,7 @@ create_progress_bar (GtkWidget *widget) "Top-Bottom" }; - static char *ellipsize_items[] = { + static const char *ellipsize_items[] = { "None", // PANGO_ELLIPSIZE_NONE, "Start", // PANGO_ELLIPSIZE_START, "Middle", // PANGO_ELLIPSIZE_MIDDLE, @@ -5586,7 +5588,7 @@ create_progress_bar (GtkWidget *widget) static int timer = 0; -gint +static int timeout_test (GtkWidget *label) { static int count = 0; @@ -5598,7 +5600,7 @@ timeout_test (GtkWidget *label) return TRUE; } -void +static void start_timeout_test (GtkWidget *widget, GtkWidget *label) { @@ -5608,7 +5610,7 @@ start_timeout_test (GtkWidget *widget, } } -void +static void stop_timeout_test (GtkWidget *widget, gpointer data) { @@ -5619,7 +5621,7 @@ stop_timeout_test (GtkWidget *widget, } } -void +static void destroy_timeout_test (GtkWidget *widget, GtkWidget **window) { @@ -5628,7 +5630,7 @@ destroy_timeout_test (GtkWidget *widget, *window = NULL; } -void +static void create_timeout_test (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -5920,6 +5922,8 @@ native_filter_changed (GtkWidget *combo, gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (native), filter); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (native), filter); break; + default: + g_assert_not_reached (); } } @@ -5930,7 +5934,7 @@ destroy_native (GtkFileChooserNative *native) g_object_unref (native); } -void +static void create_native_dialogs (GtkWidget *widget) { static GtkWidget *window = NULL; @@ -6036,7 +6040,7 @@ create_native_dialogs (GtkWidget *widget) * Main Window and Exit */ -void +static void do_exit (GtkWidget *widget, GtkWidget *window) { gtk_widget_destroy (window); @@ -6045,7 +6049,7 @@ do_exit (GtkWidget *widget, GtkWidget *window) } struct { - char *label; + const char *label; void (*func) (GtkWidget *widget); gboolean do_not_benchmark; } buttons[] = @@ -6091,16 +6095,16 @@ int nbuttons = sizeof (buttons) / sizeof (buttons[0]); static void quit_cb (GtkWidget *widget, - gpointer data) + gpointer user_data) { - gboolean *done = data; + gboolean *is_done = user_data; - *done = TRUE; + *is_done = TRUE; g_main_context_wakeup (NULL); } -void +static void create_main_window (void) { GtkWidget *window; @@ -6211,8 +6215,8 @@ bench_iteration (GtkWidget *widget, void (* fn) (GtkWidget *widget)) while (g_main_context_iteration (NULL, FALSE)); } -void -do_real_bench (GtkWidget *widget, void (* fn) (GtkWidget *widget), char *name, int num) +static void +do_real_bench (GtkWidget *widget, void (* fn) (GtkWidget *widget), const char *name, int num) { GTimeVal tv0, tv1; double dt_first; @@ -6247,7 +6251,7 @@ do_real_bench (GtkWidget *widget, void (* fn) (GtkWidget *widget), char *name, i g_print ("%10.1f\n", dt_first); } -void +static void do_bench (char* what, int num) { int i; @@ -6284,7 +6288,7 @@ do_bench (char* what, int num) } } -void +static void usage (void) { fprintf (stderr, "Usage: testgtk [--bench ALL|[:]]\n"); diff --git a/tests/testheaderbar.c b/tests/testheaderbar.c index 386475d216..87f14492c7 100644 --- a/tests/testheaderbar.c +++ b/tests/testheaderbar.c @@ -74,11 +74,11 @@ static gboolean done = FALSE; static void quit_cb (GtkWidget *widget, - gpointer data) + gpointer user_data) { - gboolean *done = data; + gboolean *is_done = user_data; - *done = TRUE; + *is_done = TRUE; g_main_context_wakeup (NULL); } diff --git a/tests/testicontheme.c b/tests/testicontheme.c index 5acd943d15..03495125bb 100644 --- a/tests/testicontheme.c +++ b/tests/testicontheme.c @@ -47,7 +47,6 @@ int main (int argc, char *argv[]) { GtkIconTheme *icon_theme; - GtkIconPaintable *icon; char *themename; int size = 48; int scale = 1; @@ -127,6 +126,7 @@ main (int argc, char *argv[]) else if (strcmp (argv[1], "lookup") == 0) { GFile *file; + GtkIconPaintable *icon; if (argc < 4) { diff --git a/tests/testiconview-keynav.c b/tests/testiconview-keynav.c index 5443c6da6c..50277502d2 100644 --- a/tests/testiconview-keynav.c +++ b/tests/testiconview-keynav.c @@ -77,7 +77,7 @@ visible_func (GtkTreeModel *model, return visible; } -GtkTreeModel * +static GtkTreeModel * get_filter_model (gboolean first) { GtkTreeModelFilter *model; diff --git a/tests/testkineticscrolling.c b/tests/testkineticscrolling.c index ca9f2581e4..1ade83fc03 100644 --- a/tests/testkineticscrolling.c +++ b/tests/testkineticscrolling.c @@ -10,11 +10,11 @@ static gboolean done = FALSE; static void quit_cb (GtkWidget *widget, - gpointer data) + gpointer user_data) { - gboolean *done = data; + gboolean *is_done = user_data; - *done = TRUE; + *is_done = TRUE; g_main_context_wakeup (NULL); } @@ -56,16 +56,16 @@ kinetic_scrolling (void) button_grid = gtk_grid_new (); for (i = 0; i < 80; i++) { - gchar *label = g_strdup_printf ("Button number %d", i); + char *button_label = g_strdup_printf ("Button number %d", i); - button = gtk_button_new_with_label (label); + button = gtk_button_new_with_label (button_label); gtk_grid_attach (GTK_GRID (button_grid), button, 0, i, 1, 1); gtk_widget_set_hexpand (button, TRUE); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (on_button_clicked), GINT_TO_POINTER (i)); - g_free (label); + g_free (button_label); } swindow = gtk_scrolled_window_new (NULL, NULL); @@ -99,10 +99,10 @@ kinetic_scrolling (void) for (i = 0; i < 80; i++) { GtkTreeIter iter; - gchar *label = g_strdup_printf ("Row number %d", i); + gchar *iter_label = g_strdup_printf ("Row number %d", i); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, label, -1); + gtk_list_store_set (store, &iter, 0, iter_label, -1); g_free (label); } gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store)); diff --git a/tests/testlist.c b/tests/testlist.c index 9a432fdd87..fb0600ef90 100644 --- a/tests/testlist.c +++ b/tests/testlist.c @@ -30,6 +30,7 @@ const char *css = "background-color: red;" "}"; +static GType row_get_type (void); G_DEFINE_TYPE (Row, row, GTK_TYPE_LIST_BOX_ROW) static void @@ -42,7 +43,7 @@ row_class_init (RowClass *class) { } -GtkWidget * +static GtkWidget * row_new (const gchar* text, gint sort_id) { Row *row; diff --git a/tests/testlist4.c b/tests/testlist4.c index 0349458e8b..96deaf3765 100644 --- a/tests/testlist4.c +++ b/tests/testlist4.c @@ -7,6 +7,7 @@ typedef struct typedef GtkApplicationClass TestAppClass; +static GType test_app_get_type (void); G_DEFINE_TYPE (TestApp, test_app, GTK_TYPE_APPLICATION) static GtkWidget *create_row (const gchar *label); @@ -193,7 +194,7 @@ test_app_class_init (TestAppClass *class) G_APPLICATION_CLASS (class)->activate = test_app_activate; } -TestApp * +static TestApp * test_app_new (void) { TestApp *test_app; diff --git a/tests/testlockbutton.c b/tests/testlockbutton.c index 75d1bc657f..e6622b4486 100644 --- a/tests/testlockbutton.c +++ b/tests/testlockbutton.c @@ -43,6 +43,7 @@ struct _GTestPermissionClass GPermissionClass parent_class; }; +static GType g_test_permission_get_type (void); G_DEFINE_TYPE (GTestPermission, g_test_permission, G_TYPE_PERMISSION) static void @@ -101,7 +102,7 @@ acquire_async (GPermission *permission, g_object_unref (result); } -gboolean +static gboolean acquire_finish (GPermission *permission, GAsyncResult *result, GError **error) @@ -135,7 +136,7 @@ release_async (GPermission *permission, g_object_unref (result); } -gboolean +static gboolean release_finish (GPermission *permission, GAsyncResult *result, GError **error) @@ -158,7 +159,7 @@ g_test_permission_class_init (GTestPermissionClass *class) permission_class->release_finish = release_finish; } -void +static void g_test_permission_set_success (GTestPermission *permission, gboolean success) { diff --git a/tests/testmenubutton.c b/tests/testmenubutton.c index b5a2404e97..f165d88aa7 100644 --- a/tests/testmenubutton.c +++ b/tests/testmenubutton.c @@ -108,15 +108,15 @@ int main (int argc, char **argv) /* Button with GMenuModel */ menu = g_menu_new (); for (i = 5; i > 0; i--) { - char *label; + char *item_label; GMenuItem *item; - label = g_strdup_printf ("Item _%d", i); - item = g_menu_item_new (label, NULL); + item_label = g_strdup_printf ("Item _%d", i); + item = g_menu_item_new (item_label, NULL); if (i == 3) g_menu_item_set_attribute (item, "icon", "s", "preferences-desktop-locale-symbolic"); g_menu_insert_item (menu, 0, item); g_object_unref (item); - g_free (label); + g_free (item_label); } button = gtk_menu_button_new (); diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c index d8d8077d63..a93c6d4dcb 100644 --- a/tests/testnotebookdnd.c +++ b/tests/testnotebookdnd.c @@ -20,10 +20,10 @@ */ #include -static gpointer GROUP_A = "GROUP_A"; -static gpointer GROUP_B = "GROUP_B"; +static gconstpointer GROUP_A = "GROUP_A"; +static gconstpointer GROUP_B = "GROUP_B"; -gchar *tabs1 [] = { +const char *tabs1 [] = { "aaaaaaaaaa", "bbbbbbbbbb", "cccccccccc", @@ -31,7 +31,7 @@ gchar *tabs1 [] = { NULL }; -gchar *tabs2 [] = { +const char *tabs2 [] = { "1", "2", "3", @@ -40,13 +40,13 @@ gchar *tabs2 [] = { NULL }; -gchar *tabs3 [] = { +const char *tabs3 [] = { "foo", "bar", NULL }; -gchar *tabs4 [] = { +const char *tabs4 [] = { "beer", "water", "lemonade", @@ -133,8 +133,8 @@ action_clicked_cb (GtkWidget *button, } static GtkWidget* -create_notebook (gchar **labels, - const gchar *group, +create_notebook (const char **labels, + const char *group, GtkPositionType pos) { GtkWidget *notebook, *title, *page, *action_widget; @@ -174,7 +174,7 @@ create_notebook (gchar **labels, } static GtkWidget* -create_notebook_non_dragable_content (gchar **labels, +create_notebook_non_dragable_content (const char **labels, const gchar *group, GtkPositionType pos) { @@ -225,7 +225,7 @@ create_notebook_non_dragable_content (gchar **labels, } static GtkWidget* -create_notebook_with_notebooks (gchar **labels, +create_notebook_with_notebooks (const char **labels, const gchar *group, GtkPositionType pos) { diff --git a/tests/testoverlay.c b/tests/testoverlay.c index e4bc2f5318..c2d3859e98 100644 --- a/tests/testoverlay.c +++ b/tests/testoverlay.c @@ -364,7 +364,7 @@ test_chase (void) GtkWidget *sw; GtkWidget *text; GtkWidget *child; - GtkTextBuffer *buffer; + GtkTextBuffer *text_buffer; gchar *contents; gsize len; GtkEventController *controller; @@ -381,15 +381,15 @@ test_chase (void) gtk_container_add (GTK_CONTAINER (overlay), sw); text = gtk_text_view_new (); - buffer = gtk_text_buffer_new (NULL); + text_buffer = gtk_text_buffer_new (NULL); if (!g_file_get_contents ("testoverlay.c", &contents, &len, NULL)) { contents = g_strdup ("Text should go here..."); len = strlen (contents); } - gtk_text_buffer_set_text (buffer, contents, len); + gtk_text_buffer_set_text (text_buffer, contents, len); g_free (contents); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), buffer); + gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), text_buffer); gtk_widget_set_hexpand (text, TRUE); gtk_widget_set_vexpand (text, TRUE); diff --git a/tests/testpixbuf-scale.c b/tests/testpixbuf-scale.c index 69ae4be6a5..8d4ec92fc5 100644 --- a/tests/testpixbuf-scale.c +++ b/tests/testpixbuf-scale.c @@ -9,7 +9,7 @@ int overall_alpha = 255; GdkPixbuf *pixbuf; GtkWidget *darea; -void +static void set_interp_type (GtkWidget *widget, gpointer data) { guint types[] = { GDK_INTERP_NEAREST, @@ -21,7 +21,7 @@ set_interp_type (GtkWidget *widget, gpointer data) gtk_widget_queue_draw (darea); } -void +static void overall_changed_cb (GtkAdjustment *adjustment, gpointer data) { if (gtk_adjustment_get_value (adjustment) != overall_alpha) @@ -32,7 +32,7 @@ overall_changed_cb (GtkAdjustment *adjustment, gpointer data) } static void -draw_func (GtkDrawingArea *darea, +draw_func (GtkDrawingArea *area, cairo_t *cr, int width, int height, diff --git a/tests/testselectionmode.c b/tests/testselectionmode.c index 53fc020dc4..d99b105dfe 100644 --- a/tests/testselectionmode.c +++ b/tests/testselectionmode.c @@ -12,6 +12,7 @@ typedef struct { GtkListBoxRowClass parent_class; } SelectableRowClass; +static GType selectable_row_get_type (void); G_DEFINE_TYPE (SelectableRow, selectable_row, GTK_TYPE_LIST_BOX_ROW) static void @@ -34,7 +35,7 @@ selectable_row_init (SelectableRow *row) gtk_container_add (GTK_CONTAINER (row->revealer), row->check); } -void +static void selectable_row_add (SelectableRow *row, GtkWidget *child) { gtk_container_add (GTK_CONTAINER (row->box), child); @@ -73,7 +74,7 @@ selectable_row_class_init (SelectableRowClass *class) { } -GtkWidget * +static GtkWidget * selectable_row_new (void) { return GTK_WIDGET (g_object_new (selectable_row_get_type (), NULL)); diff --git a/tests/teststack.c b/tests/teststack.c index b0eee9668f..3e0affc23f 100644 --- a/tests/teststack.c +++ b/tests/teststack.c @@ -49,58 +49,58 @@ toggle_transitions (GtkWidget *combo, gpointer data) } static void -on_back_button_clicked (GtkButton *button, GtkStack *stack) +on_back_button_clicked (GtkButton *button, gpointer user_data) { const gchar *seq[] = { "1", "2", "3" }; const gchar *vis; gint i; - vis = gtk_stack_get_visible_child_name (stack); + vis = gtk_stack_get_visible_child_name (GTK_STACK (stack)); for (i = 1; i < G_N_ELEMENTS (seq); i++) { if (g_strcmp0 (vis, seq[i]) == 0) { - gtk_stack_set_visible_child_full (stack, seq[i - 1], GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT); + gtk_stack_set_visible_child_full (GTK_STACK (stack), seq[i - 1], GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT); break; } } } static void -on_forward_button_clicked (GtkButton *button, GtkStack *stack) +on_forward_button_clicked (GtkButton *button, gpointer user_data) { const gchar *seq[] = { "1", "2", "3" }; const gchar *vis; gint i; - vis = gtk_stack_get_visible_child_name (stack); + vis = gtk_stack_get_visible_child_name (GTK_STACK (stack)); for (i = 0; i < G_N_ELEMENTS (seq) - 1; i++) { if (g_strcmp0 (vis, seq[i]) == 0) { - gtk_stack_set_visible_child_full (stack, seq[i + 1], GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); + gtk_stack_set_visible_child_full (GTK_STACK (stack), seq[i + 1], GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); break; } } } static void -update_back_button_sensitivity (GtkStack *stack, GParamSpec *pspec, GtkWidget *button) +update_back_button_sensitivity (GtkStack *_stack, GParamSpec *pspec, GtkWidget *button) { const gchar *vis; - vis = gtk_stack_get_visible_child_name (stack); + vis = gtk_stack_get_visible_child_name (GTK_STACK (stack)); gtk_widget_set_sensitive (button, g_strcmp0 (vis, "1") != 0); } static void -update_forward_button_sensitivity (GtkStack *stack, GParamSpec *pspec, GtkWidget *button) +update_forward_button_sensitivity (GtkStack *_stack, GParamSpec *pspec, GtkWidget *button) { const gchar *vis; - vis = gtk_stack_get_visible_child_name (stack); + vis = gtk_stack_get_visible_child_name (GTK_STACK (stack)); gtk_widget_set_sensitive (button, g_strcmp0 (vis, "3") != 0); } diff --git a/tests/teststackedheaders.c b/tests/teststackedheaders.c index 0e40b62237..2f19db1b97 100644 --- a/tests/teststackedheaders.c +++ b/tests/teststackedheaders.c @@ -4,19 +4,21 @@ static GtkWidget *header_stack; static GtkWidget *page_stack; -void +#if 0 +static void back_to_main (GtkButton *button) { gtk_stack_set_visible_child_name (GTK_STACK (header_stack), "main"); gtk_stack_set_visible_child_name (GTK_STACK (page_stack), "page1"); } -void +static void go_to_secondary (GtkButton *button) { gtk_stack_set_visible_child_name (GTK_STACK (header_stack), "secondary"); gtk_stack_set_visible_child_name (GTK_STACK (page_stack), "secondary"); } +#endif int main (int argc, char *argv[]) @@ -37,6 +39,8 @@ main (int argc, char *argv[]) header_stack = (GtkWidget *)gtk_builder_get_object (builder, "header_stack"); page_stack = (GtkWidget *)gtk_builder_get_object (builder, "page_stack"); + g_assert (header_stack); + gtk_window_present (GTK_WINDOW (win)); while (TRUE) diff --git a/tests/teststackedheaders.ui b/tests/teststackedheaders.ui index 932150ece4..96a6012b1a 100644 --- a/tests/teststackedheaders.ui +++ b/tests/teststackedheaders.ui @@ -16,7 +16,6 @@ center - @@ -38,7 +37,6 @@ center - diff --git a/tests/testtextview.c b/tests/testtextview.c index 2711a8fd52..922606ae83 100644 --- a/tests/testtextview.c +++ b/tests/testtextview.c @@ -11,6 +11,7 @@ typedef struct { GtkTextViewClass parent_class; } MyTextViewClass; +static GType my_text_view_get_type (void); G_DEFINE_TYPE (MyTextView, my_text_view, GTK_TYPE_TEXT_VIEW); static void snapshot_background (GtkWidget *widget, GtkSnapshot *snapshot); diff --git a/tests/testtooltips.c b/tests/testtooltips.c index 28e4070eea..b8b33b5586 100644 --- a/tests/testtooltips.c +++ b/tests/testtooltips.c @@ -37,6 +37,7 @@ struct _MyTooltipClass GtkBinClass parent_class; }; +static GType my_tooltip_get_type (void); G_DEFINE_TYPE (MyTooltip, my_tooltip, GTK_TYPE_BIN) static void diff --git a/tests/testtreecolumns.c b/tests/testtreecolumns.c index 74f55a3c19..a4c1b8dcd0 100644 --- a/tests/testtreecolumns.c +++ b/tests/testtreecolumns.c @@ -76,6 +76,19 @@ struct _ViewColumnModelClass GtkListStoreClass parent_class; }; +static void view_column_model_tree_model_init (GtkTreeModelIface *iface); +static void view_column_model_drag_source_init (GtkTreeDragSourceIface *iface); +static void view_column_model_drag_dest_init (GtkTreeDragDestIface *iface); + + +static GType view_column_model_get_type (void); +G_DEFINE_TYPE_WITH_CODE (ViewColumnModel, view_column_model, GTK_TYPE_LIST_STORE, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, view_column_model_tree_model_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, view_column_model_drag_source_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_DEST, view_column_model_drag_dest_init)) + + + static void view_column_model_init (ViewColumnModel *model) { model->stamp = g_random_int (); @@ -368,11 +381,6 @@ view_column_model_class_init (ViewColumnModelClass *klass) { } -G_DEFINE_TYPE_WITH_CODE (ViewColumnModel, view_column_model, GTK_TYPE_LIST_STORE, - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, view_column_model_tree_model_init) - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, view_column_model_drag_source_init) - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_DEST, view_column_model_drag_dest_init)) - static void update_columns (GtkTreeView *view, ViewColumnModel *view_model) { diff --git a/tests/testtreednd.c b/tests/testtreednd.c index 04450938e2..3bf664dd70 100644 --- a/tests/testtreednd.c +++ b/tests/testtreednd.c @@ -5,6 +5,7 @@ typedef GtkListStoreClass MyModelClass; static void my_model_drag_source_init (GtkTreeDragSourceIface *iface); +static GType my_model_get_type (void); G_DEFINE_TYPE_WITH_CODE (MyModel, my_model, GTK_TYPE_LIST_STORE, G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, my_model_drag_source_init)) diff --git a/tests/testtreeedit.c b/tests/testtreeedit.c index 374e16e48a..c32499d798 100644 --- a/tests/testtreeedit.c +++ b/tests/testtreeedit.c @@ -204,6 +204,8 @@ create_control (GtkWidget *box, gint number, gint cntl, CallbackData *data) name = g_strdup_printf ("Fix size Cell #%d", number); callback = G_CALLBACK (fixed_cell_toggled); break; + default: + g_assert_not_reached (); } checkbutton = gtk_check_button_new_with_label (name); diff --git a/tests/testtreeflow.c b/tests/testtreeflow.c index 11fd65e774..e7c90662d7 100644 --- a/tests/testtreeflow.c +++ b/tests/testtreeflow.c @@ -28,7 +28,7 @@ enum NUM_COLUMNS }; -static char *words[] = +static const char *words[] = { "Boom", "Borp", @@ -102,6 +102,8 @@ futz_row (void) TEXT_COLUMN, words[g_rand_int_range (grand, 0, NUM_WORDS)], -1); break; + default: + g_assert_not_reached (); } } diff --git a/tests/testtreelistmodel.c b/tests/testtreelistmodel.c index 621cb00c58..4b2dbb7f9e 100644 --- a/tests/testtreelistmodel.c +++ b/tests/testtreelistmodel.c @@ -61,16 +61,16 @@ start_enumerate (GListStore *store) static void got_files (GObject *enumerate, GAsyncResult *res, - gpointer store) + gpointer user_data) { GList *l, *files; - GFile *file = g_object_get_data (store, "file"); + GFile *file = g_object_get_data (user_data, "file"); GPtrArray *array; files = g_file_enumerator_next_files_finish (G_FILE_ENUMERATOR (enumerate), res, NULL); if (files == NULL) { - g_object_unref (store); + g_object_unref (user_data); if (pending) { GListStore *store = pending->data; @@ -94,7 +94,7 @@ got_files (GObject *enumerate, } g_list_free (files); - g_list_store_splice (store, g_list_model_get_n_items (store), 0, array->pdata, array->len); + g_list_store_splice (user_data, g_list_model_get_n_items (user_data), 0, array->pdata, array->len); g_ptr_array_unref (array); g_file_enumerator_next_files_async (G_FILE_ENUMERATOR (enumerate), @@ -102,7 +102,7 @@ got_files (GObject *enumerate, G_PRIORITY_DEFAULT_IDLE, NULL, got_files, - store); + user_data); } static int diff --git a/tests/testtreemodel.c b/tests/testtreemodel.c index 031dab580a..2becbd0d1b 100644 --- a/tests/testtreemodel.c +++ b/tests/testtreemodel.c @@ -204,7 +204,7 @@ tree_store_insert_deep (GtkTreeModel *model, static void -test_run (gchar *title, +test_run (const char *title, GtkTreeModel *store, ClearFunc *clear, InsertFunc *insert) diff --git a/tests/testtreesort.c b/tests/testtreesort.c index 68d5de3728..d6784ab867 100644 --- a/tests/testtreesort.c +++ b/tests/testtreesort.c @@ -68,26 +68,14 @@ enum NUM_COLUMNS }; -gboolean -select_func (GtkTreeSelection *selection, - GtkTreeModel *model, - GtkTreePath *path, - gboolean path_currently_selected, - gpointer data) -{ - if (gtk_tree_path_get_depth (path) > 1) - return TRUE; - return FALSE; -} - static void switch_search_method (GtkWidget *button, gpointer tree_view) { if (!gtk_tree_view_get_search_entry (GTK_TREE_VIEW (tree_view))) { - gpointer data = g_object_get_data (tree_view, "my-search-entry"); - gtk_tree_view_set_search_entry (GTK_TREE_VIEW (tree_view), GTK_EDITABLE (data)); + gpointer search_entry = g_object_get_data (tree_view, "my-search-entry"); + gtk_tree_view_set_search_entry (GTK_TREE_VIEW (tree_view), GTK_EDITABLE (search_entry)); } else gtk_tree_view_set_search_entry (GTK_TREE_VIEW (tree_view), NULL); @@ -95,9 +83,9 @@ switch_search_method (GtkWidget *button, static void quit_cb (GtkWidget *widget, - gpointer data) + gpointer user_data) { - gboolean *done = data; + gboolean *done = user_data; *done = TRUE; diff --git a/tests/testtreeview.c b/tests/testtreeview.c index af670e313d..f7843dc67c 100644 --- a/tests/testtreeview.c +++ b/tests/testtreeview.c @@ -23,7 +23,7 @@ /* Don't copy this bad example; inline RGB data is always a better * idea than inline XPMs. */ -static char *book_closed_xpm[] = { +static const char *book_closed_xpm[] = { "16 16 6 1", " c None s None", ". c black", @@ -132,7 +132,7 @@ typedef enum COLUMNS_LAST } ColumnsType; -static gchar *column_type_names[] = { +static const char *column_type_names[] = { "No columns", "One column", "Many columns" @@ -459,6 +459,8 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type) NULL); gtk_tree_view_insert_column (GTK_TREE_VIEW (tree_view), col, 0); + break; + case COLUMNS_LAST: default: break; } @@ -632,7 +634,7 @@ columns_selected (GtkComboBox *combo_box, gpointer data) } } -void +static void on_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, diff --git a/tests/testwidgetfocus.c b/tests/testwidgetfocus.c index 1a76f25490..6441b34f87 100644 --- a/tests/testwidgetfocus.c +++ b/tests/testwidgetfocus.c @@ -267,17 +267,17 @@ gtk_focus_widget_class_init (GtkFocusWidgetClass *klass) static void quit_cb (GtkWidget *widget, - gpointer data) + gpointer user_data) { - gboolean *done = data; + gboolean *is_done = user_data; - *done = TRUE; + *is_done = TRUE; g_main_context_wakeup (NULL); } int -main() +main(int argc, char **argv) { GtkWidget *window; GtkWidget *widget; diff --git a/tests/testwidgettransforms.c b/tests/testwidgettransforms.c index 4d690b54fc..f48c9489a0 100644 --- a/tests/testwidgettransforms.c +++ b/tests/testwidgettransforms.c @@ -261,12 +261,12 @@ tick_cb (GtkWidget *widget, static void gtk_transform_tester_set_test_widget (GtkTransformTester *self, - GtkWidget *test_widget) + GtkWidget *widget) { g_assert (!self->test_widget); - self->test_widget = test_widget; - gtk_widget_set_parent (test_widget, (GtkWidget *)self); + self->test_widget = widget; + gtk_widget_set_parent (widget, (GtkWidget *)self); gtk_widget_add_tick_callback (GTK_WIDGET (self), tick_cb, NULL, NULL); } diff --git a/tests/treestoretest.c b/tests/treestoretest.c index 0b2c933665..c461c25b37 100644 --- a/tests/treestoretest.c +++ b/tests/treestoretest.c @@ -280,11 +280,11 @@ static gboolean done = FALSE; static void quit_cb (GtkWidget *widget, - gpointer data) + gpointer user_data) { - gboolean *done = data; + gboolean *is_done = user_data; - *done = TRUE; + *is_done = TRUE; g_main_context_wakeup (NULL); } @@ -312,6 +312,8 @@ make_window (gint view_type) case 1: gtk_window_set_title (GTK_WINDOW (window), "Sorted list"); break; + default: + g_assert_not_reached (); } vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); diff --git a/tests/video-timer.c b/tests/video-timer.c index 84744bfee9..2d9e12fb42 100644 --- a/tests/video-timer.c +++ b/tests/video-timer.c @@ -317,6 +317,8 @@ on_update (GdkFrameClock *frame_clock, &refresh_interval, NULL); pending_frame = peek_pending_frame (); + g_assert (pending_frame); + if (stream_time_to_clock_time (pending_frame->stream_time) < predicted_presentation_time + refresh_interval / 2) { @@ -341,6 +343,7 @@ on_update (GdkFrameClock *frame_clock, n_frames++; displayed_frame = unqueue_frame (); + g_assert (displayed_frame); displayed_frame->clock_time = stream_time_to_clock_time (displayed_frame->stream_time); displayed_frame->frame_counter = gdk_frame_timings_get_frame_counter (timings);