Fix compiler warnings across tests and modules

This commit is contained in:
Daemonratte 2026-04-24 19:10:41 +02:00
commit ef8c6add6a
19 changed files with 101 additions and 121 deletions

View file

@ -932,7 +932,6 @@ main (int argc, char **argv)
GtkWidget *notebook;
GtkWidget *hbox;
GtkWidget *tree;
GtkTextTag *tag;
/* Most code in gtk-demo is intended to be exemplary, but not
* these few lines, which are just a hack so gtk-demo will work
@ -968,38 +967,38 @@ main (int argc, char **argv)
create_text (&info_buffer, FALSE),
gtk_label_new_with_mnemonic ("_Info"));
tag = gtk_text_buffer_create_tag (info_buffer, "title",
"font", "Sans 18",
NULL);
g_object_unref (info_buffer);
gtk_text_buffer_create_tag (info_buffer, "title",
"font", "Sans 18",
NULL);
g_object_unref (info_buffer);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
create_text (&source_buffer, TRUE),
gtk_label_new_with_mnemonic ("_Source"));
tag = gtk_text_buffer_create_tag (source_buffer, "comment",
"foreground", "DodgerBlue",
NULL);
tag = gtk_text_buffer_create_tag (source_buffer, "type",
"foreground", "ForestGreen",
NULL);
tag = gtk_text_buffer_create_tag (source_buffer, "string",
"foreground", "RosyBrown",
"weight", PANGO_WEIGHT_BOLD,
NULL);
tag = gtk_text_buffer_create_tag (source_buffer, "control",
"foreground", "purple",
NULL);
tag = gtk_text_buffer_create_tag (source_buffer, "preprocessor",
"style", PANGO_STYLE_OBLIQUE,
"foreground", "burlywood4",
NULL);
tag = gtk_text_buffer_create_tag (source_buffer, "function",
"weight", PANGO_WEIGHT_BOLD,
"foreground", "DarkGoldenrod4",
NULL);
g_object_unref (source_buffer);
gtk_text_buffer_create_tag (source_buffer, "comment",
"foreground", "DodgerBlue",
NULL);
gtk_text_buffer_create_tag (source_buffer, "type",
"foreground", "ForestGreen",
NULL);
gtk_text_buffer_create_tag (source_buffer, "string",
"foreground", "RosyBrown",
"weight", PANGO_WEIGHT_BOLD,
NULL);
gtk_text_buffer_create_tag (source_buffer, "control",
"foreground", "purple",
NULL);
gtk_text_buffer_create_tag (source_buffer, "preprocessor",
"style", PANGO_STYLE_OBLIQUE,
"foreground", "burlywood4",
NULL);
gtk_text_buffer_create_tag (source_buffer, "function",
"weight", PANGO_WEIGHT_BOLD,
"foreground", "DarkGoldenrod4",
NULL);
g_object_unref (source_buffer);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_widget_show_all (window);

View file

@ -132,7 +132,6 @@ insert_text (GtkTextBuffer *buffer)
GtkTextIter start, end;
GdkPixbuf *pixbuf;
GdkPixbuf *scaled;
GtkTextChildAnchor *anchor;
char *filename;
/* demo_find_file() looks in the current directory first,
@ -311,15 +310,15 @@ insert_text (GtkTextBuffer *buffer)
"rtl_quote", NULL);
gtk_text_buffer_insert (buffer, &iter, "You can put widgets in the buffer: Here's a button: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " and a menu: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " and a scale: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " and an animation: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " finally a text entry: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
gtk_text_buffer_insert (buffer, &iter, "\n\nThis demo doesn't demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text, tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...", -1);

View file

@ -121,8 +121,7 @@ take_window_shot (Window child,
gboolean include_decoration)
{
GdkWindow *window;
Display *disp;
Window w, xid;
Window xid;
gint x_orig, y_orig;
gint x = 0, y = 0;
gint width, height;
@ -130,9 +129,6 @@ take_window_shot (Window child,
GdkPixbuf *tmp, *tmp2;
GdkPixbuf *retval;
disp = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
w = GDK_ROOT_WINDOW ();
if (include_decoration)
xid = find_toplevel_window (child);
else

View file

@ -2505,11 +2505,9 @@ test_file (const gchar *filename)
if (GTK_IS_DIALOG (obj))
{
int response;
g_print ("Running dialog %s.\n",
gtk_widget_get_name (GTK_WIDGET (obj)));
response = gtk_dialog_run (GTK_DIALOG (obj));
gtk_dialog_run (GTK_DIALOG (obj));
}
else if (GTK_IS_WINDOW (obj))
{

View file

@ -2338,6 +2338,9 @@ specific_filter_add_child (void)
gtk_tree_store_set (store, &iter, 0, "Hello", -1);
gtk_tree_store_append (store, &child, &iter_first);
gtk_tree_store_set (store, &child, 0, "Hello", -1);
g_object_unref (filter);
g_object_unref (store);
}
static void
@ -2362,6 +2365,10 @@ specific_list_store_clear (void)
view = gtk_tree_view_new_with_model (filter);
gtk_list_store_clear (list);
gtk_widget_destroy (view);
g_object_unref (filter);
g_object_unref (list);
}
static void
@ -2475,6 +2482,11 @@ specific_bug_301558 (void)
add = !add;
}
gtk_widget_destroy (view);
g_object_unref (filter);
g_object_unref (sort);
g_object_unref (tree);
}
@ -2501,7 +2513,6 @@ specific_bug_311955 (void)
GtkTreeModel *sort;
GtkTreeModel *filter;
GtkWidget *window;
GtkWidget *tree_view;
int i;
int n;
@ -2524,7 +2535,6 @@ specific_bug_311955 (void)
specific_bug_311955_filter_func,
NULL, NULL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
tree_view = gtk_tree_view_new_with_model (filter);
g_object_unref (store);
@ -2698,6 +2708,10 @@ specific_bug_464173 (void)
visible = FALSE;
gtk_tree_model_filter_refilter (f_model);
gtk_widget_destroy (view);
g_object_unref (f_model);
g_object_unref (model);
}
@ -2743,12 +2757,15 @@ specific_bug_540201 (void)
gtk_tree_store_append (store, &iter, &root);
gtk_tree_store_set (store, &iter, 0, 22, -1);
gtk_tree_store_append (store, &root, NULL);
gtk_tree_store_set (store, &root, 0, 33, -1);
gtk_tree_store_append (store, &iter, &root);
gtk_tree_store_set (store, &iter, 0, 22, -1);
gtk_widget_destroy (tree_view);
g_object_unref (filter);
g_object_unref (store);
}
@ -2819,6 +2836,10 @@ specific_bug_549287 (void)
/* since we inserted something, we changed the visibility conditions: */
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filtered));
}
gtk_widget_destroy (view);
g_object_unref (filtered);
g_object_unref (store);
}
/* main */

View file

@ -271,7 +271,7 @@ typedef struct
static void
_send_to_magnifier(gint x, gint y, gint w, gint h)
{
int desc, length_msg;
int desc;
gchar buff[100];
sprintf (buff, "~5:%d,%d", x+w/2, y+h/2);
@ -303,7 +303,7 @@ _send_to_magnifier(gint x, gint y, gint w, gint h)
return;
}
length_msg = write(desc,buff,strlen(buff));
write(desc,buff,strlen(buff));
unlink("/tmp/mag_client");
return;
}
@ -1330,12 +1330,9 @@ _print_text_attributes (AtkText *aobject)
gchar *output_str, *label_str;
gint start_offset, end_offset, caret_offset;
gint attribute_set_len, attribute_offset, i;
gint n_chars;
gint group_num;
TabNumber tab_n = TEXT;
n_chars = atk_text_get_character_count(aobject);
group_num = _print_groupname (tab_n, TEXT_ATTRIBUTES,
"Text Attributes at Caret");

View file

@ -16,7 +16,6 @@ static void _check_children (AtkObject *obj)
gint n_children, i, j;
AtkObject *child;
AtkObject *grand_child;
AtkObject *parent;
n_children = atk_object_get_n_accessible_children (obj);
@ -30,7 +29,6 @@ static void _check_children (AtkObject *obj)
{
child = atk_object_ref_accessible_child (obj, 1);
g_return_if_fail (atk_object_get_role (child) == ATK_ROLE_TEXT);
parent = atk_object_get_parent (child);
j = atk_object_get_index_in_parent (child);
if (j != 1)
g_print ("*** inconsistency between parent and children %d %d ***\n",
@ -40,7 +38,6 @@ static void _check_children (AtkObject *obj)
child = atk_object_ref_accessible_child (obj, 0);
g_return_if_fail (atk_object_get_role (child) == ATK_ROLE_LIST);
parent = atk_object_get_parent (child);
j = atk_object_get_index_in_parent (child);
if (j != 0)
g_print ("*** inconsistency between parent and children %d %d ***\n",

View file

@ -553,7 +553,6 @@ _create_select_tests_window (AtkObject *obj,
TLruntest runtest,
OutputWindow **outwin)
{
AtkText *textwidget;
GtkWidget *hbuttonbox;
GtkWidget *scrolledWindow;
@ -561,8 +560,6 @@ _create_select_tests_window (AtkObject *obj,
{
md[window_no] = (MainDialog *) malloc (sizeof(MainDialog));
textwidget = ATK_TEXT (obj);
/* Setup Window */
md[window_no]->selecttestsTitle = "Test Setting";
md[window_no]->selecttestsWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);

View file

@ -52,11 +52,8 @@ static gint _test_paned (gpointer data)
{
AtkObject *obj = ATK_OBJECT (data);
AtkRole role = atk_object_get_role (obj);
GtkWidget *widget;
static gint times = 0;
widget = GTK_ACCESSIBLE (obj)->widget;
if (role == ATK_ROLE_SPLIT_PANE)
{
GValue *value, val;

View file

@ -541,7 +541,6 @@ preview_cb (GtkPrintOperation *op,
GtkWindow *parent,
gpointer data)
{
GtkPrintSettings *settings;
GtkWidget *window, *close, *page, *hbox, *vbox, *da;
gdouble width, height;
cairo_t *cr;
@ -551,7 +550,6 @@ preview_cb (GtkPrintOperation *op,
pop = g_new0 (PreviewOp, 1);
pop->data = print_data;
settings = gtk_print_operation_get_print_settings (op);
width = 200;
height = 300;

View file

@ -31,7 +31,6 @@ int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
/* FIXME: This is not allowable - what is this supposed to be? */
/* gdk_progclass = g_strdup ("XTerm"); */
@ -47,13 +46,13 @@ main (int argc, char *argv[])
NULL),
"signal::destroy", gtk_main_quit, NULL,
NULL);
button = g_object_connect (g_object_new (gtk_button_get_type (),
"GtkButton::label", "hello world",
"GtkWidget::parent", window,
"GtkWidget::visible", TRUE,
NULL),
"signal::clicked", hello, NULL,
NULL);
g_object_connect (g_object_new (gtk_button_get_type (),
"GtkButton::label", "hello world",
"GtkWidget::parent", window,
"GtkWidget::visible", TRUE,
NULL),
"signal::clicked", hello, NULL,
NULL);
gtk_widget_show (window);
gtk_main ();

View file

@ -74,7 +74,6 @@ main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *button;
gtk_init (&argc, &argv);
@ -96,20 +95,20 @@ main (int argc, char **argv)
"GtkWidget::parent", window,
"GtkWidget::visible", TRUE,
NULL);
button = g_object_connect (g_object_new (gtk_button_get_type (),
"GtkButton::label", "send known client message",
"GtkWidget::parent", vbox,
"GtkWidget::visible", TRUE,
NULL),
"signal::clicked", send_known, NULL,
NULL);
button = g_object_connect (g_object_new (gtk_button_get_type (),
"GtkButton::label", "send random client message",
"GtkWidget::parent", vbox,
"GtkWidget::visible", TRUE,
NULL),
"signal::clicked", send_random, NULL,
NULL);
g_object_connect (g_object_new (gtk_button_get_type (),
"GtkButton::label", "send known client message",
"GtkWidget::parent", vbox,
"GtkWidget::visible", TRUE,
NULL),
"signal::clicked", send_known, NULL,
NULL);
g_object_connect (g_object_new (gtk_button_get_type (),
"GtkButton::label", "send random client message",
"GtkWidget::parent", vbox,
"GtkWidget::visible", TRUE,
NULL),
"signal::clicked", send_random, NULL,
NULL);
gdk_display_add_client_message_filter (gdk_display_get_default (),
my_type,
filter_func,

View file

@ -481,7 +481,6 @@ main (int argc, char **argv)
GtkWidget *vbbox;
GtkWidget *button;
GtkWidget *dialog;
GtkWidget *prop_editor;
GtkWidget *extra;
GtkFileFilter *filter;
GtkWidget *preview_vbox;
@ -648,7 +647,7 @@ main (int argc, char **argv)
/* Extra controls for manipulating the test environment
*/
prop_editor = create_prop_editor (G_OBJECT (dialog), GTK_TYPE_FILE_CHOOSER);
create_prop_editor (G_OBJECT (dialog), GTK_TYPE_FILE_CHOOSER);
control_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

View file

@ -113,7 +113,6 @@ build_option_menu (gchar *items[],
{
GtkWidget *omenu;
GtkWidget *menu;
GSList *group;
gint i;
omenu = gtk_combo_box_text_new ();
@ -121,7 +120,6 @@ build_option_menu (gchar *items[],
G_CALLBACK (func), data);
menu = gtk_menu_new ();
group = NULL;
for (i = 0; i < num_items; i++)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (omenu), items[i]);
@ -5731,7 +5729,6 @@ cursor_expose_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
GtkDrawingArea *darea;
GdkDrawable *drawable;
guint max_width;
guint max_height;
@ -5740,7 +5737,6 @@ cursor_expose_event (GtkWidget *widget,
g_return_val_if_fail (widget != NULL, TRUE);
g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), TRUE);
darea = GTK_DRAWING_AREA (widget);
drawable = widget->window;
max_width = widget->allocation.width;
max_height = widget->allocation.height;
@ -11855,8 +11851,6 @@ static void
query_properties (GtkButton *button,
struct PropertiesData *data)
{
gint failure;
g_signal_connect (button, "event",
G_CALLBACK (property_query_event), data);
@ -11865,12 +11859,12 @@ query_properties (GtkButton *button,
data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (button)),
GDK_TARGET);
failure = gdk_pointer_grab (GTK_WIDGET (button)->window,
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
gdk_pointer_grab (GTK_WIDGET (button)->window,
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
gtk_grab_add (GTK_WIDGET (button));
@ -12015,8 +12009,6 @@ static void
snapshot_widget (GtkButton *button,
struct SnapshotData *data)
{
gint failure;
g_signal_connect (button, "event",
G_CALLBACK (snapshot_widget_event), data);
@ -12026,12 +12018,12 @@ snapshot_widget (GtkButton *button,
data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (button)),
GDK_TARGET);
failure = gdk_pointer_grab (GTK_WIDGET (button)->window,
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
gdk_pointer_grab (GTK_WIDGET (button)->window,
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
gtk_grab_add (GTK_WIDGET (button));

View file

@ -79,13 +79,9 @@ draw_page (GtkPrintOperation *operation,
int
main (int argc, char **argv)
{
GMainLoop *loop;
GtkPrintOperation *print;
GtkPrintOperationResult res;
GtkPrintSettings *settings;
loop = g_main_loop_new (NULL, TRUE);
settings = gtk_print_settings_new ();
/* gtk_print_settings_set_printer (settings, "printer"); */
@ -94,7 +90,7 @@ main (int argc, char **argv)
gtk_print_operation_set_n_pages (print, 1);
gtk_print_operation_set_unit (print, GTK_UNIT_MM);
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT, NULL, NULL);
gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT, NULL, NULL);
return 0;
}

View file

@ -98,7 +98,6 @@ int
main (int argc, char **argv)
{
GtkPrintOperation *print;
GtkPrintOperationResult res;
TestPrintFileOperation *print_file;
gtk_init (&argc, &argv);
@ -110,13 +109,13 @@ main (int argc, char **argv)
gtk_print_operation_set_export_filename (print, "test.pdf");
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
g_signal_connect (print, "request_page_setup", G_CALLBACK (request_page_setup), NULL);
res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, NULL);
gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, NULL);
/* Test subclassing of GtkPrintOperation */
print_file = test_print_file_operation_new ("testprint.c");
test_print_file_operation_set_font_size (print_file, 12.0);
gtk_print_operation_set_export_filename (GTK_PRINT_OPERATION (print_file), "test2.pdf");
res = gtk_print_operation_run (GTK_PRINT_OPERATION (print_file), GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, NULL);
gtk_print_operation_run (GTK_PRINT_OPERATION (print_file), GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, NULL);
return 0;
}

View file

@ -111,7 +111,6 @@ main (int argc,
GtkWidget *vbbox;
GtkWidget *button;
GtkWidget *dialog;
GtkWidget *prop_editor;
GtkRecentFilter *filter;
gint i;
gboolean multiple = FALSE;
@ -172,7 +171,7 @@ main (int argc,
gtk_widget_show_all (dialog);
prop_editor = create_prop_editor (G_OBJECT (dialog), GTK_TYPE_RECENT_CHOOSER);
create_prop_editor (G_OBJECT (dialog), GTK_TYPE_RECENT_CHOOSER);
control_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

View file

@ -2739,7 +2739,6 @@ get_lines (GtkTextView *text_view,
{
GtkTextIter iter;
gint count;
gint size;
g_array_set_size (buffer_coords, 0);
g_array_set_size (numbers, 0);
@ -2751,7 +2750,6 @@ get_lines (GtkTextView *text_view,
* Stop when we pass last_y
*/
count = 0;
size = 0;
while (!gtk_text_iter_is_end (&iter))
{

View file

@ -627,10 +627,10 @@ create_tree_model (void)
GtkTreeStore *store;
gint i;
GType *t;
volatile GType dummy; /* G_GNUC_CONST makes the optimizer remove
* get_type calls if you don't do something
* like this
*/
volatile GType dummy G_GNUC_UNUSED; /* G_GNUC_CONST makes the optimizer remove
* get_type calls if you don't do something
* like this
*/
/* Make the tree more interesting */
dummy = gtk_scrolled_window_get_type ();