Merge branch 'wip/baedert/test-cflags' into 'master'

Pass (almost) all our cflags to tests, testsuite, examples, demos, ...

See merge request GNOME/gtk!1516
This commit is contained in:
Matthias Clasen 2020-03-13 18:40:46 +00:00
commit 66a0a8d53e
130 changed files with 555 additions and 586 deletions

View File

@ -308,17 +308,17 @@ save_response_cb (GtkNativeDialog *dialog,
&error);
if (error != NULL)
{
GtkWidget *dialog;
GtkWidget *message_dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (message_dialog);
g_error_free (error);
}

View File

@ -77,7 +77,7 @@ update_weak_position (ConstraintView *self,
GTK_CONSTRAINT_RELATION_EQ,
x,
GTK_CONSTRAINT_STRENGTH_WEAK);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "x-constraint", constraint);
@ -97,7 +97,7 @@ update_weak_position (ConstraintView *self,
GTK_CONSTRAINT_RELATION_EQ,
y,
GTK_CONSTRAINT_STRENGTH_WEAK);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "y-constraint", constraint);
@ -258,7 +258,7 @@ constraint_view_add_guide (ConstraintView *view,
frame = gtk_frame_new (NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "guide");
g_object_set_data (G_OBJECT (frame), "internal", "yes");
g_object_set_data (G_OBJECT (frame), "internal", (char *)"yes");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL);
@ -276,7 +276,7 @@ constraint_view_add_guide (ConstraintView *view,
names[i].attr,
1.0, 0.0,
GTK_CONSTRAINT_STRENGTH_REQUIRED);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (layout, constraint);
g_object_set_data (G_OBJECT (guide), names[i].name, constraint);
}

View File

@ -78,7 +78,7 @@ get_strength (const char *id)
return strength;
}
const char *
static const char *
get_strength_nick (GtkConstraintStrength strength)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);

View File

@ -13,6 +13,7 @@ constraint_editor_resources = gnome.compile_resources('constraint_editor_resourc
executable('gtk4-constraint-editor',
constraint_editor_sources, constraint_editor_resources,
c_args: common_cflags,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,

View File

@ -6,6 +6,7 @@
typedef GtkApplication DemoApplication;
typedef GtkApplicationClass DemoApplicationClass;
static GType demo_application_get_type (void);
G_DEFINE_TYPE (DemoApplication, demo_application, GTK_TYPE_APPLICATION)
typedef struct {
@ -25,6 +26,7 @@ typedef struct {
} DemoApplicationWindow;
typedef GtkApplicationWindowClass DemoApplicationWindowClass;
static GType demo_application_window_get_type (void);
G_DEFINE_TYPE (DemoApplicationWindow, demo_application_window, GTK_TYPE_APPLICATION_WINDOW)
static void create_window (GApplication *app, const char *contents);

View File

@ -7,7 +7,7 @@
#include <gtk/gtk.h>
static GtkWidget *assistant = NULL;
/*static GtkWidget *assistant = NULL;*/
static GtkWidget *progress_bar = NULL;
static gboolean
@ -27,8 +27,7 @@ apply_changes_gradually (gpointer data)
else
{
/* Close automatically once changes are fully applied. */
gtk_widget_destroy (assistant);
assistant = NULL;
gtk_widget_destroy (data);
return G_SOURCE_REMOVE;
}
}
@ -37,7 +36,7 @@ static void
on_assistant_apply (GtkWidget *widget, gpointer data)
{
/* Start a timer to simulate changes taking a few seconds to apply. */
g_timeout_add (100, apply_changes_gradually, NULL);
g_timeout_add (100, apply_changes_gradually, widget);
}
static void
@ -173,6 +172,8 @@ create_page4 (GtkWidget *assistant)
GtkWidget*
do_assistant (GtkWidget *do_widget)
{
static GtkWidget *assistant;
if (!assistant)
{
assistant = gtk_assistant_new ();

View File

@ -15,7 +15,7 @@
static GtkWidget *window = NULL;
void
static void
copy_button_clicked (GtkWidget *button,
gpointer user_data)
{
@ -31,7 +31,7 @@ copy_button_clicked (GtkWidget *button,
gdk_clipboard_set_text (clipboard, gtk_editable_get_text (GTK_EDITABLE (entry)));
}
void
static void
paste_received (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
@ -75,7 +75,7 @@ paste_received (GObject *source_object,
}
}
void
static void
paste_button_clicked (GtkWidget *button,
gpointer user_data)
{
@ -116,6 +116,9 @@ get_image_paintable (GtkImage *image)
if (icon == NULL)
return NULL;
return GDK_PAINTABLE (icon);
case GTK_IMAGE_EMPTY:
case GTK_IMAGE_GICON:
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));

View File

@ -16,7 +16,7 @@ static GtkWidget *frame;
/* draw callback for the drawing area
*/
static void
draw_function (GtkDrawingArea *da,
draw_function (GtkDrawingArea *drawing_area,
cairo_t *cr,
int width,
int height,

View File

@ -19,7 +19,7 @@ enum
static GtkTreeModel *
create_icon_store (void)
{
const gchar *icon_names[6] = {
const char *icon_names[6] = {
"dialog-warning",
"process-stop",
"document-new",
@ -27,7 +27,7 @@ create_icon_store (void)
NULL,
"document-open"
};
const gchar *labels[6] = {
const char *labels[6] = {
N_("Warning"),
N_("Stop"),
N_("New"),
@ -111,8 +111,8 @@ static GtkTreeModel *
create_capital_store (void)
{
struct {
gchar *group;
gchar *capital;
const char *group;
const char *capital;
} capitals[] = {
{ "A - B", NULL },
{ NULL, "Albany" },
@ -234,7 +234,7 @@ typedef struct _MaskEntry MaskEntry;
struct _MaskEntry
{
GtkEntry entry;
gchar *mask;
const char *mask;
};
typedef struct _MaskEntryClass MaskEntryClass;
@ -246,6 +246,7 @@ struct _MaskEntryClass
static void mask_entry_editable_init (GtkEditableInterface *iface);
static GType mask_entry_get_type (void);
G_DEFINE_TYPE_WITH_CODE (MaskEntry, mask_entry, GTK_TYPE_ENTRY,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
mask_entry_editable_init));

View File

@ -11,8 +11,8 @@
* These are the available blend modes.
*/
struct {
gchar *name;
gchar *id;
const char *name;
const char *id;
} blend_modes[] =
{
{ "Color", "color" },

View File

@ -58,7 +58,7 @@ apply_css (GtkWidget *widget, GtkStyleProvider *provider)
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
}
GtkWidget *
static GtkWidget *
create_toolbar (void)
{
GtkWidget *toolbar;

View File

@ -42,7 +42,7 @@ free_demo_widget (gpointer data)
}
#define GTK_TYPE_DEMO_WIDGET (gtk_demo_widget_get_type ())
static GType gtk_demo_widget_get_type (void);
G_DEFINE_BOXED_TYPE (GtkDemoWidget, gtk_demo_widget, copy_demo_widget, free_demo_widget)
static GtkDemoWidget *

View File

@ -275,6 +275,9 @@ cell_edited (GtkCellRendererText *cell,
g_array_index (articles, Item, i).product, -1);
}
break;
default:
g_assert_not_reached ();
}
gtk_tree_path_free (path);

View File

@ -9,7 +9,7 @@
#include <gtk/gtk.h>
/* Creates a tree model containing the completions */
GtkTreeModel *
static GtkTreeModel *
create_completion_model (void)
{
GtkListStore *store;

View File

@ -37,6 +37,7 @@ get_random_icon_name (GtkIconTheme *theme)
return icon_names[g_random_int_range(0, n_icon_names)];
}
/* Can't be static because it's also used in iconscroll.c */
GtkWidget *
create_icon (void)
{

View File

@ -25,14 +25,14 @@
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
static GtkWidget *label;
static GtkWidget *the_label;
static GtkWidget *settings;
static GtkWidget *description;
static GtkWidget *font;
static GtkWidget *script_lang;
static GtkWidget *resetbutton;
static GtkWidget *stack;
static GtkWidget *entry;
static GtkWidget *the_entry;
static GtkWidget *variations_heading;
static GtkWidget *variations_grid;
static GtkWidget *instance_combo;
@ -301,9 +301,9 @@ update_display (void)
char *font_desc;
char *features;
text = gtk_editable_get_text (GTK_EDITABLE (entry));
text = gtk_editable_get_text (GTK_EDITABLE (the_entry));
if (gtk_label_get_selection_bounds (GTK_LABEL (label), &ins, &bound))
if (gtk_label_get_selection_bounds (GTK_LABEL (the_label), &ins, &bound))
{
start = g_utf8_offset_to_pointer (text, ins) - text;
end = g_utf8_offset_to_pointer (text, bound) - text;
@ -409,8 +409,8 @@ update_display (void)
gtk_label_set_text (GTK_LABEL (description), font_desc);
gtk_label_set_text (GTK_LABEL (settings), features);
gtk_label_set_text (GTK_LABEL (label), text);
gtk_label_set_attributes (GTK_LABEL (label), attrs);
gtk_label_set_text (GTK_LABEL (the_label), text);
gtk_label_set_attributes (GTK_LABEL (the_label), attrs);
g_free (font_desc);
pango_font_description_free (desc);
@ -548,7 +548,7 @@ update_script_combo (void)
{
const char *langname;
char langbuf[5];
GtkTreeIter iter;
GtkTreeIter tree_iter;
if (pair->lang_tag == HB_OT_TAG_DEFAULT_LANGUAGE)
langname = NC_("Language", "Default");
@ -563,7 +563,7 @@ update_script_combo (void)
}
}
gtk_list_store_insert_with_values (store, &iter, -1,
gtk_list_store_insert_with_values (store, &tree_iter, -1,
0, langname,
1, pair->script_index,
2, pair->lang_index,
@ -572,7 +572,7 @@ update_script_combo (void)
if (pair->lang_tag == active)
{
have_active = TRUE;
active_iter = iter;
active_iter = tree_iter;
}
}
@ -751,7 +751,7 @@ add_font_variations (GString *s)
GHashTableIter iter;
Axis *axis;
char buf[G_ASCII_DTOSTR_BUF_SIZE];
char *sep = "";
const char *sep = "";
g_hash_table_iter_init (&iter, axes);
while (g_hash_table_iter_next (&iter, (gpointer *)NULL, (gpointer *)&axis))
@ -1129,7 +1129,7 @@ font_features_reset_features (void)
{
GList *l;
gtk_label_select_region (GTK_LABEL (label), 0, 0);
gtk_label_select_region (GTK_LABEL (the_label), 0, 0);
g_list_free_full (ranges, free_range);
ranges = NULL;
@ -1156,9 +1156,9 @@ static char *text;
static void
switch_to_entry (void)
{
text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (entry)));
text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (the_entry)));
gtk_stack_set_visible_child_name (GTK_STACK (stack), "entry");
gtk_widget_grab_focus (entry);
gtk_widget_grab_focus (the_entry);
}
static void
@ -1217,20 +1217,20 @@ do_font_features (GtkWidget *do_widget)
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
feature_list = GTK_WIDGET (gtk_builder_get_object (builder, "feature_list"));
label = GTK_WIDGET (gtk_builder_get_object (builder, "label"));
the_label = GTK_WIDGET (gtk_builder_get_object (builder, "label"));
settings = GTK_WIDGET (gtk_builder_get_object (builder, "settings"));
description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
resetbutton = GTK_WIDGET (gtk_builder_get_object (builder, "reset"));
font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
script_lang = GTK_WIDGET (gtk_builder_get_object (builder, "script_lang"));
stack = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
the_entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
edit_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "edit_toggle"));
controller = gtk_event_controller_key_new ();
g_object_set_data_full (G_OBJECT (entry), "controller", g_object_ref (controller), g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (entry_key_press), entry);
gtk_widget_add_controller (entry, controller);
g_object_set_data_full (G_OBJECT (the_entry), "controller", g_object_ref (controller), g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (entry_key_press), the_entry);
gtk_widget_add_controller (the_entry, controller);
add_check_group (feature_list, _("Kerning"), (const char *[]){ "kern", NULL });
add_check_group (feature_list, _("Ligatures"), (const char *[]){ "liga",

View File

@ -43,7 +43,6 @@ update_image (void)
cairo_font_options_t *fopt;
cairo_hint_style_t hintstyle;
cairo_hint_metrics_t hintmetrics;
int i;
if (!context)
context = gtk_widget_create_pango_context (image);
@ -116,6 +115,7 @@ update_image (void)
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_grid)))
{
int i;
cairo_set_source_rgba (cr, 0.2, 0, 0, 0.2);
for (i = 1; i < ink.height + 20; i++)
{

View File

@ -17,9 +17,9 @@ typedef struct _Demo Demo;
struct _Demo
{
gchar *name;
gchar *title;
gchar *filename;
const char *name;
const char *title;
const char *filename;
GDoDemoFunc func;
Demo *children;
};

View File

@ -383,7 +383,7 @@ close_window (GtkWidget *widget)
rotation_angles[Z_AXIS] = 0.0;
}
GtkWidget *
static GtkWidget *
create_glarea_window (GtkWidget *do_widget)
{
GtkWidget *window, *box, *button, *controls;

View File

@ -17,7 +17,7 @@
static void
insert_link (GtkTextBuffer *buffer,
GtkTextIter *iter,
gchar *text,
const char *text,
gint page)
{
GtkTextTag *tag;

View File

@ -16,10 +16,9 @@ typedef struct
{
const gboolean fixed;
const guint number;
const gchar *severity;
const gchar *description;
}
Bug;
const char *severity;
const char *description;
} Bug;
enum
{
@ -34,7 +33,7 @@ enum
NUM_COLUMNS
};
static Bug data[] =
static Bug bugs[] =
{
{ FALSE, 60482, "Normal", "scrollable notebooks and hidden tabs" },
{ FALSE, 60620, "Critical", "gdk_surface_clear_area (gdksurface-win32.c) is not thread-safe" },
@ -98,9 +97,9 @@ create_model (void)
G_TYPE_BOOLEAN);
/* add data to the list store */
for (i = 0; i < G_N_ELEMENTS (data); i++)
for (i = 0; i < G_N_ELEMENTS (bugs); i++)
{
gchar *icon_name;
const char *icon_name;
gboolean sensitive;
if (i == 1 || i == 3)
@ -113,10 +112,10 @@ create_model (void)
sensitive = TRUE;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
COLUMN_FIXED, data[i].fixed,
COLUMN_NUMBER, data[i].number,
COLUMN_SEVERITY, data[i].severity,
COLUMN_DESCRIPTION, data[i].description,
COLUMN_FIXED, bugs[i].fixed,
COLUMN_NUMBER, bugs[i].number,
COLUMN_SEVERITY, bugs[i].severity,
COLUMN_DESCRIPTION, bugs[i].description,
COLUMN_PULSE, 0,
COLUMN_ICON, icon_name,
COLUMN_ACTIVE, FALSE,
@ -129,23 +128,23 @@ create_model (void)
static void
fixed_toggled (GtkCellRendererToggle *cell,
gchar *path_str,
char *path_str,
gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *)data;
GtkTreeModel *tree_model = (GtkTreeModel *)data;
GtkTreeIter iter;
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
gboolean fixed;
/* get toggled iter */
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, COLUMN_FIXED, &fixed, -1);
gtk_tree_model_get_iter (tree_model, &iter, path);
gtk_tree_model_get (tree_model, &iter, COLUMN_FIXED, &fixed, -1);
/* do something with the value */
fixed ^= 1;
/* set new value */
gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_FIXED, fixed, -1);
gtk_list_store_set (GTK_LIST_STORE (tree_model), &iter, COLUMN_FIXED, fixed, -1);
/* clean up */
gtk_tree_path_free (path);
@ -156,7 +155,6 @@ add_columns (GtkTreeView *treeview)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
/* column for fixed toggles */
renderer = gtk_cell_renderer_toggle_new ();

View File

@ -205,14 +205,14 @@ enum {
STATE_IN_COMMENT
};
static gchar *tokens[] =
static const char *tokens[] =
{
"/*",
"\"",
NULL
};
static gchar *types[] =
static const char *types[] =
{
"static",
"const ",
@ -337,7 +337,7 @@ static gchar *types[] =
NULL
};
static gchar *control[] =
static const char *control[] =
{
" if ",
" while ",
@ -351,11 +351,11 @@ static gchar *control[] =
NULL
};
void
parse_chars (gchar *text,
gchar **end_ptr,
gint *state,
gchar **tag,
gboolean start)
parse_chars (gchar *text,
gchar **end_ptr,
gint *state,
const char **tag,
gboolean start)
{
gint i;
gchar *next_token;
@ -494,7 +494,7 @@ fontify (GtkTextBuffer *source_buffer)
gint state;
gchar *text;
gchar *start_ptr, *end_ptr;
gchar *tag;
const char *tag;
gtk_text_buffer_create_tag (source_buffer, "source",
"font", "monospace",
@ -868,7 +868,7 @@ load_file (const gchar *demoname,
p = lines[i];
state++;
/* Fall through */
G_GNUC_FALLTHROUGH;
case 3:
/* Reading program body */
@ -876,6 +876,9 @@ load_file (const gchar *demoname,
if (lines[i+1] != NULL)
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
break;
default:
g_assert_not_reached ();
}
}
@ -975,7 +978,7 @@ startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *appmenu;
gchar *ids[] = { "appmenu", NULL };
const char *ids[] = { "appmenu", NULL };
builder = gtk_builder_new ();
gtk_builder_add_objects_from_resource (builder, "/ui/appmenu.ui", ids, NULL);

View File

@ -112,9 +112,16 @@ gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
'demo.gresource.xml',
source_dir: '.')
demo_cflags = []
foreach flag: common_cflags
if flag not in ['-Werror=missing-prototypes', '-Werror=missing-declarations', '-fvisibility=hidden']
demo_cflags += flag
endif
endforeach
executable('gtk4-demo',
demos, demos_h, extra_demo_sources, gtkdemo_resources,
c_args: gtkdemo_args,
c_args: gtkdemo_args + demo_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
gui_app: true,
@ -123,7 +130,7 @@ executable('gtk4-demo',
executable('gtk4-demo-application',
'application.c', gtkdemo_resources,
c_args: gtkdemo_args,
c_args: gtkdemo_args + common_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
gui_app: true,

View File

@ -47,6 +47,7 @@ static const gchar *pad_colors[] = {
"orange"
};
static GType drawing_area_get_type (void);
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
static void drawing_area_set_color (DrawingArea *area,
@ -340,7 +341,7 @@ drawing_area_init (DrawingArea *area)
area->draw_color = (GdkRGBA) { 0, 0, 0, 1 };
}
GtkWidget *
static GtkWidget *
drawing_area_new (void)
{
return g_object_new (drawing_area_get_type (), NULL);

View File

@ -13,7 +13,7 @@
#include <gtk/gtk.h>
void
static void
toggle_resize (GtkWidget *widget,
GtkWidget *child)
{
@ -47,7 +47,7 @@ toggle_resize (GtkWidget *widget,
g_object_unref (child);
}
void
static void
toggle_shrink (GtkWidget *widget,
GtkWidget *child)
{
@ -81,7 +81,7 @@ toggle_shrink (GtkWidget *widget,
g_object_unref (child);
}
GtkWidget *
static GtkWidget *
create_pane_options (GtkPaned *paned,
const gchar *frame_label,
const gchar *label1,

View File

@ -28,26 +28,23 @@ fancy_shape_renderer (cairo_t *cr,
(double) attr->ink_rect.width / PANGO_SCALE,
(double) attr->ink_rect.height / PANGO_SCALE);
switch (GPOINTER_TO_UINT (attr->data))
if (GPOINTER_TO_UINT (attr->data) == 0x2664) /* U+2665 BLACK HEART SUIT */
{
case 0x2665: /* U+2665 BLACK HEART SUIT */
{
cairo_move_to (cr, .5, .0);
cairo_line_to (cr, .9, -.4);
cairo_curve_to (cr, 1.1, -.8, .5, -.9, .5, -.5);
cairo_curve_to (cr, .5, -.9, -.1, -.8, .1, -.4);
cairo_close_path (cr);
}
break;
cairo_move_to (cr, .5, .0);
cairo_line_to (cr, .9, -.4);
cairo_curve_to (cr, 1.1, -.8, .5, -.9, .5, -.5);
cairo_curve_to (cr, .5, -.9, -.1, -.8, .1, -.4);
cairo_close_path (cr);
}
if (!do_path) {
cairo_set_source_rgb (cr, 1., 0., 0.);
cairo_fill (cr);
}
if (!do_path)
{
cairo_set_source_rgb (cr, 1., 0., 0.);
cairo_fill (cr);
}
}
PangoAttrList *
static PangoAttrList *
create_fancy_attr_list_for_layout (PangoLayout *layout)
{
PangoAttrList *attrs;
@ -145,13 +142,13 @@ rotated_text_draw (GtkDrawingArea *da,
/* Draw the layout N_WORDS times in a circle */
for (i = 0; i < N_WORDS; i++)
{
int width, height;
int layout_width, layout_height;
/* Inform Pango to re-layout the text with the new transformation matrix */
pango_cairo_update_layout (cr, layout);
pango_layout_get_pixel_size (layout, &width, &height);
cairo_move_to (cr, - width / 2, - RADIUS * .9);
pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
cairo_move_to (cr, - layout_width / 2, - RADIUS * .9);
pango_cairo_show_layout (cr, layout);
/* Rotate for the next turn */

View File

@ -185,13 +185,13 @@ text_changed (GObject *object,
gpointer data)
{
GtkEntry *entry = GTK_ENTRY (object);
GActionMap *actions = data;
GActionMap *action_map = data;
GAction *action;
gboolean has_text;
has_text = gtk_entry_get_text_length (entry) > 0;
action = g_action_map_lookup_action (actions, "clear");
action = g_action_map_lookup_action (action_map, "clear");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), has_text);
}

View File

@ -277,7 +277,7 @@ puzzle_button_pressed (GtkGestureClick *gesture,
}
static void
start_puzzle (GdkPaintable *puzzle)
start_puzzle (GdkPaintable *paintable)
{
GtkWidget *picture, *grid;
GtkEventController *controller;
@ -293,7 +293,7 @@ start_puzzle (GdkPaintable *puzzle)
grid = gtk_grid_new ();
gtk_widget_set_can_focus (grid, TRUE);
gtk_container_add (GTK_CONTAINER (frame), grid);
aspect_ratio = gdk_paintable_get_intrinsic_aspect_ratio (puzzle);
aspect_ratio = gdk_paintable_get_intrinsic_aspect_ratio (paintable);
if (aspect_ratio == 0.0)
aspect_ratio = 1.0;
gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.5, 0.5, aspect_ratio, FALSE);
@ -332,7 +332,7 @@ start_puzzle (GdkPaintable *puzzle)
if (x == pos_x && y == pos_y)
piece = NULL;
else
piece = gtk_puzzle_piece_new (puzzle,
piece = gtk_puzzle_piece_new (paintable,
x, y,
width, height);
picture = gtk_picture_new_for_paintable (piece);
@ -390,7 +390,7 @@ reconfigure (void)
}
static void
add_choice (GtkWidget *choices,
add_choice (GtkWidget *container,
GdkPaintable *paintable)
{
GtkWidget *icon;
@ -398,7 +398,7 @@ add_choice (GtkWidget *choices,
icon = gtk_image_new_from_paintable (paintable);
gtk_image_set_icon_size (GTK_IMAGE (icon), GTK_ICON_SIZE_LARGE);
gtk_container_add (GTK_CONTAINER (choices), icon);
gtk_container_add (GTK_CONTAINER (container), icon);
}
GtkWidget *

View File

@ -106,7 +106,7 @@ spinbutton_time_spin_output (GtkSpinButton *spin_button)
return TRUE;
}
static gchar *month[12] = {
static const char *month[12] = {
"January",
"February",
"March",

View File

@ -48,9 +48,9 @@ static void
fullscreen_clicked_cb (GtkWidget *button,
gpointer unused)
{
GtkWidget *window = GTK_WIDGET (gtk_widget_get_root (button));
GtkWidget *widget_window = GTK_WIDGET (gtk_widget_get_root (button));
gtk_window_fullscreen (GTK_WINDOW (window));
gtk_window_fullscreen (GTK_WINDOW (widget_window));
}
GtkWidget *

View File

@ -383,6 +383,8 @@ get_image_paintable (GtkImage *image)
if (icon == NULL)
return NULL;
return GDK_PAINTABLE (icon);
case GTK_IMAGE_GICON:
case GTK_IMAGE_EMPTY:
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));

View File

@ -11,6 +11,7 @@ iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
executable('gtk4-icon-browser',
iconbrowser_sources, iconbrowser_resources,
c_args: common_cflags,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,

View File

@ -13,7 +13,9 @@ executable('gtk4-node-editor',
node_editor_sources, node_editor_resources,
dependencies: libgtk_dep,
include_directories: confinc,
c_args: ['-DNODE_EDITOR_SOURCE_DIR="@0@/../../testsuite/gsk/compare/"'.format(meson.current_source_dir())],
c_args: [
'-DNODE_EDITOR_SOURCE_DIR="@0@/../../testsuite/gsk/compare/"'.format(meson.current_source_dir())
] + common_cflags,
gui_app: true,
link_args: extra_demo_ldflags,
install: false)

View File

@ -425,17 +425,17 @@ save_response_cb (GtkWidget *dialog,
&error);
if (error != NULL)
{
GtkWidget *dialog;
GtkWidget *message_dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (message_dialog);
g_error_free (error);
}

View File

@ -6,6 +6,7 @@ widgetfactory_resources = gnome.compile_resources('widgetfactory_resources',
executable('gtk4-widget-factory',
'widget-factory.c', widgetfactory_resources,
c_args: common_cflags,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,

View File

@ -1075,6 +1075,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
@ -1446,6 +1447,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
@ -1484,7 +1486,7 @@ acquire_async (GPermission *permission,
g_object_unref (task);
}
gboolean
static gboolean
acquire_finish (GPermission *permission,
GAsyncResult *res,
GError **error)
@ -1513,7 +1515,7 @@ release_async (GPermission *permission,
g_object_unref (task);
}
gboolean
static gboolean
release_finish (GPermission *permission,
GAsyncResult *result,
GError **error)

View File

@ -17,7 +17,7 @@ foreach ex : examples
'-DGDK_DISABLE_DEPRECATED',
'-DGTK_DISABLE_DEPRECATED',
'-DGTK_SRCDIR="@0@"'.format(meson.current_source_dir()),
],
] + common_cflags,
dependencies: libgtk_dep)
endforeach

View File

@ -135,6 +135,7 @@ plug_man_open (GApplication *application,
typedef GtkApplication PlugMan;
typedef GtkApplicationClass PlugManClass;
static GType plug_man_get_type (void);
G_DEFINE_TYPE (PlugMan, plug_man, GTK_TYPE_APPLICATION)
static void
@ -376,10 +377,10 @@ configure_plugins (GSimpleAction *action,
dialog = (GtkWidget *)gtk_builder_get_object (builder, "plugin-dialog");
check = (GtkWidget *)gtk_builder_get_object (builder, "red-plugin");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), plugin_enabled ("red"));
g_signal_connect (check, "toggled", G_CALLBACK (enable_or_disable_plugin), "red");
g_signal_connect (check, "toggled", G_CALLBACK (enable_or_disable_plugin), (char *) "red");
check = (GtkWidget *)gtk_builder_get_object (builder, "black-plugin");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), plugin_enabled ("black"));
g_signal_connect (check, "toggled", G_CALLBACK (enable_or_disable_plugin), "black");
g_signal_connect (check, "toggled", G_CALLBACK (enable_or_disable_plugin), (char *) "black");
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
@ -481,7 +482,7 @@ plug_man_class_init (PlugManClass *class)
}
PlugMan *
static PlugMan *
plug_man_new (void)
{
return g_object_new (plug_man_get_type (),

View File

@ -70,6 +70,7 @@ open (GApplication *application,
typedef GtkApplication MenuButton;
typedef GtkApplicationClass MenuButtonClass;
static GType menu_button_get_type (void);
G_DEFINE_TYPE (MenuButton, menu_button, GTK_TYPE_APPLICATION)
static void
@ -176,7 +177,7 @@ menu_button_class_init (MenuButtonClass *class)
application_class->open = open;
}
MenuButton *
static MenuButton *
menu_button_new (void)
{
return g_object_new (menu_button_get_type (),

View File

@ -1151,7 +1151,7 @@ gtk_builder_add_from_file (GtkBuilder *builder,
gboolean
gtk_builder_add_objects_from_file (GtkBuilder *builder,
const gchar *filename,
gchar **object_ids,
const char **object_ids,
GError **error)
{
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
@ -1352,7 +1352,7 @@ gtk_builder_add_from_resource (GtkBuilder *builder,
gboolean
gtk_builder_add_objects_from_resource (GtkBuilder *builder,
const gchar *resource_path,
gchar **object_ids,
const char **object_ids,
GError **error)
{
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
@ -1483,7 +1483,7 @@ gboolean
gtk_builder_add_objects_from_string (GtkBuilder *builder,
const gchar *buffer,
gssize length,
gchar **object_ids,
const char **object_ids,
GError **error)
{
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);

View File

@ -114,18 +114,18 @@ gboolean gtk_builder_add_from_string (GtkBuilder *builder,
GDK_AVAILABLE_IN_ALL
gboolean gtk_builder_add_objects_from_file (GtkBuilder *builder,
const gchar *filename,
gchar **object_ids,
const char **object_ids,
GError **error);
GDK_AVAILABLE_IN_ALL
gboolean gtk_builder_add_objects_from_resource(GtkBuilder *builder,
const gchar *resource_path,
gchar **object_ids,
const char **object_ids,
GError **error);
GDK_AVAILABLE_IN_ALL
gboolean gtk_builder_add_objects_from_string (GtkBuilder *builder,
const gchar *buffer,
gssize length,
gchar **object_ids,
const char **object_ids,
GError **error);
GDK_AVAILABLE_IN_ALL
GObject* gtk_builder_get_object (GtkBuilder *builder,

View File

@ -1542,7 +1542,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
const gchar *filename,
const gchar *buffer,
gssize length,
gchar **requested_objs,
const char **requested_objs,
GError **error)
{
const gchar* domain;

View File

@ -134,7 +134,7 @@ typedef struct {
GSList *finalizers;
GSList *custom_finalizers;
char **requested_objects; /* NULL if all the objects are requested */
const char **requested_objects; /* NULL if all the objects are requested */
gboolean inside_requested_object;
gint requested_object_level;
gint cur_object_level;
@ -160,7 +160,7 @@ void _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
const gchar *filename,
const gchar *buffer,
gssize length,
gchar **requested_objs,
const char **requested_objs,
GError **error);
GObject * _gtk_builder_construct (GtkBuilder *builder,
ObjectInfo *info,

View File

@ -7175,7 +7175,8 @@ list_selection_changed (GtkTreeSelection *selection,
if (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view)) == NULL)
return;
if (priv->location_entry)
if (priv->location_entry &&
priv->browse_files_model)
update_chooser_entry (impl);
location_bar_update (impl);

View File

@ -1641,7 +1641,7 @@ _gtk_gesture_get_pointer_emulating_sequence (GtkGesture *gesture,
case GDK_TOUCH_END:
if (!gdk_touch_event_get_emulating_pointer (data->event))
continue;
/* Fall through */
G_GNUC_FALLTHROUGH;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_MOTION_NOTIFY:

View File

@ -84,7 +84,7 @@ struct _GtkPadController {
GActionGroup *action_group;
GdkDevice *pad;
GList *entries;
GArray *action_entries;
};
struct _GtkPadControllerClass {
@ -98,42 +98,31 @@ enum {
N_PROPS
};
typedef struct
{
GtkPadActionType type;
int index;
int mode;
char *label;
char *action_name;
} ActionEntryData;
static GParamSpec *pspecs[N_PROPS] = { NULL };
G_DEFINE_TYPE (GtkPadController, gtk_pad_controller, GTK_TYPE_EVENT_CONTROLLER)
static GtkPadActionEntry *
gtk_pad_action_entry_copy (const GtkPadActionEntry *entry)
{
GtkPadActionEntry *copy;
copy = g_slice_new0 (GtkPadActionEntry);
*copy = *entry;
copy->label = g_strdup (entry->label);
copy->action_name = g_strdup (entry->action_name);
return copy;
}
static void
gtk_pad_action_entry_free (GtkPadActionEntry *entry)
{
g_free (entry->label);
g_free (entry->action_name);
g_slice_free (GtkPadActionEntry, entry);
}
static const GtkPadActionEntry *
static const ActionEntryData *
gtk_pad_action_find_match (GtkPadController *controller,
GtkPadActionType type,
gint index,
gint mode)
{
GList *l;
guint i;
for (l = controller->entries; l; l = l->next)
for (i = 0; i < controller->action_entries->len; i++)
{
GtkPadActionEntry *entry = l->data;
const ActionEntryData *entry = &g_array_index (controller->action_entries,
ActionEntryData, i);
gboolean match_index = FALSE, match_mode = FALSE;
if (entry->type != type)
@ -151,7 +140,7 @@ gtk_pad_action_find_match (GtkPadController *controller,
static void
gtk_pad_controller_activate_action (GtkPadController *controller,
const GtkPadActionEntry *entry)
const ActionEntryData *entry)
{
g_action_group_activate_action (controller->action_group,
entry->action_name,
@ -160,7 +149,7 @@ gtk_pad_controller_activate_action (GtkPadController *controller,
static void
gtk_pad_controller_activate_action_with_axis (GtkPadController *controller,
const GtkPadActionEntry *entry,
const ActionEntryData *entry,
gdouble value)
{
g_action_group_activate_action (controller->action_group,
@ -177,7 +166,7 @@ gtk_pad_controller_handle_mode_switch (GtkPadController *controller,
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gdk_device_get_display (pad)))
{
const GtkPadActionEntry *entry;
const ActionEntryData *entry;
gint elem, idx, n_features;
for (elem = GTK_PAD_ACTION_BUTTON; elem <= GTK_PAD_ACTION_STRIP; elem++)
@ -235,7 +224,7 @@ gtk_pad_controller_handle_event (GtkEventController *controller,
{
GtkPadController *pad_controller = GTK_PAD_CONTROLLER (controller);
GdkEventType event_type = gdk_event_get_event_type (event);
const GtkPadActionEntry *entry;
const ActionEntryData *entry;
GtkPadActionType type;
guint index, mode, group;
gdouble value = 0;
@ -346,8 +335,17 @@ static void
gtk_pad_controller_finalize (GObject *object)
{
GtkPadController *controller = GTK_PAD_CONTROLLER (object);
guint i;
g_list_free_full (controller->entries, (GDestroyNotify) gtk_pad_action_entry_free);
for (i = 0; i < controller->action_entries->len; i++)
{
const ActionEntryData *entry = &g_array_index (controller->action_entries,
ActionEntryData, i);
g_free (entry->label);
g_free (entry->action_name);
}
g_array_free (controller->action_entries, TRUE);
G_OBJECT_CLASS (gtk_pad_controller_parent_class)->finalize (object);
}
@ -385,6 +383,7 @@ gtk_pad_controller_class_init (GtkPadControllerClass *klass)
static void
gtk_pad_controller_init (GtkPadController *controller)
{
controller->action_entries = g_array_new (FALSE, TRUE, sizeof (ActionEntryData));
}
/**
@ -444,11 +443,25 @@ static void
gtk_pad_controller_add_entry (GtkPadController *controller,
const GtkPadActionEntry *entry)
{
GtkPadActionEntry *copy;
guint i;
const ActionEntryData new_entry = {
.type = entry->type,
.index = entry->index,
.mode = entry->mode,
.label= g_strdup (entry->label),
.action_name = g_strdup (entry->action_name)
};
copy = gtk_pad_action_entry_copy (entry);
controller->entries = g_list_insert_sorted (controller->entries, copy,
(GCompareFunc) entry_compare_func);
g_array_set_size (controller->action_entries, controller->action_entries->len + 1);
for (i = 0; i < controller->action_entries->len; i++)
{
if (entry_compare_func (&new_entry,
&g_array_index (controller->action_entries, ActionEntryData, i)) == 0)
break;
}
g_array_insert_val (controller->action_entries, i, new_entry);
}
/**
@ -496,13 +509,12 @@ gtk_pad_controller_set_action_entries (GtkPadController *controller,
void
gtk_pad_controller_set_action (GtkPadController *controller,
GtkPadActionType type,
gint index,
gint mode,
const gchar *label,
const gchar *action_name)
int index,
int mode,
const char *label,
const char *action_name)
{
GtkPadActionEntry entry = { type, index, mode,
(gchar *) label, (gchar *) action_name };
const GtkPadActionEntry entry = { type, index, mode, label, action_name };
g_return_if_fail (GTK_IS_PAD_CONTROLLER (controller));
g_return_if_fail (type <= GTK_PAD_ACTION_STRIP);

View File

@ -68,10 +68,10 @@ typedef enum {
*/
struct _GtkPadActionEntry {
GtkPadActionType type;
gint index;
gint mode;
gchar *label;
gchar *action_name;
int index;
int mode;
const char *label;
const char *action_name;
};
GDK_AVAILABLE_IN_ALL

View File

@ -3631,7 +3631,7 @@ gtk_text_move_cursor (GtkText *self,
case GTK_MOVEMENT_WORDS:
if (priv->resolved_dir == PANGO_DIRECTION_RTL)
count *= -1;
/* Fall through */
G_GNUC_FALLTHROUGH;
case GTK_MOVEMENT_LOGICAL_POSITIONS:
if (count < 0)

View File

@ -237,6 +237,7 @@ if cc.get_id() == 'msvc'
elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
test_cflags = [
'-fno-strict-aliasing',
'-Wno-typedef-redefinition',
'-Wcast-align',
'-Wduplicated-branches',
'-Wduplicated-cond',

View File

@ -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)
{

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -682,14 +682,14 @@ static const gchar ui_info[] =
"</interface>";
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)

View File

@ -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 ();

View File

@ -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)

View File

@ -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)

View File

@ -19,7 +19,7 @@
#include <gtk/gtk.h>
void
static void
hello (void)
{
g_print ("hello world\n");

View File

@ -1,5 +1,5 @@
/* XPM */
static char *openfile[] = {
static const char *openfile[] = {
/* width height num_colors chars_per_pixel */
" 20 19 66 2",
/* colors */

View File

@ -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);
}

View File

@ -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;

View File

@ -677,7 +677,7 @@ create_page_flipping_assistant (GtkWidget *widget)
}
struct {
gchar *text;
const char *text;
void (*func) (GtkWidget *widget);
} buttons[] =
{

View File

@ -18,7 +18,7 @@
#include <gtk/gtk.h>
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),

View File

@ -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)

View File

@ -50,7 +50,7 @@ enum
static char *
calendar_date_to_string (CalendarData *data,
char *format)
const char *format)
{
GDateTime *date;
char *str;

View File

@ -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 */

View File

@ -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;

View File

@ -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--;

View File

@ -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

View File

@ -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))

View File

@ -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;

View File

@ -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;

View File

@ -140,123 +140,6 @@ filter_changed (GtkFileChooserDialog *dialog,
#include <errno.h>
#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);

View File

@ -31,7 +31,7 @@
#include <gtk/gtk.h>
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+" },

View File

@ -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);

View File

@ -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");
}

View File

@ -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 ();

View File

@ -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;
@ -4828,7 +4830,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");
@ -4840,7 +4842,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");
@ -4949,7 +4951,7 @@ get_state_controls (GtkWidget *window)
return vbox;
}
void
static void
create_surface_states (GtkWidget *widget)
{
static GtkWidget *window = NULL;
@ -5240,7 +5242,7 @@ window_controls (GtkWidget *window)
return control_window;
}
void
static void
create_window_sizing (GtkWidget *widget)
{
static GtkWidget *window = NULL;
@ -5302,7 +5304,7 @@ typedef struct _ProgressData {
gboolean activity;
} ProgressData;
gboolean
static gboolean
progress_timeout (gpointer data)
{
ProgressData *pdata = data;
@ -5421,7 +5423,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;
@ -5434,7 +5436,7 @@ create_progress_bar (GtkWidget *widget)
GtkWidget *label;
static ProgressData *pdata = NULL;
static gchar *items1[] =
static const char *items1[] =
{
"Left-Right",
"Right-Left",
@ -5442,7 +5444,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,
@ -5578,7 +5580,7 @@ create_progress_bar (GtkWidget *widget)
static int timer = 0;
gint
static int
timeout_test (GtkWidget *label)
{
static int count = 0;
@ -5590,7 +5592,7 @@ timeout_test (GtkWidget *label)
return TRUE;
}
void
static void
start_timeout_test (GtkWidget *widget,
GtkWidget *label)
{
@ -5600,7 +5602,7 @@ start_timeout_test (GtkWidget *widget,
}
}
void
static void
stop_timeout_test (GtkWidget *widget,
gpointer data)
{
@ -5611,7 +5613,7 @@ stop_timeout_test (GtkWidget *widget,
}
}
void
static void
destroy_timeout_test (GtkWidget *widget,
GtkWidget **window)
{
@ -5620,7 +5622,7 @@ destroy_timeout_test (GtkWidget *widget,
*window = NULL;
}
void
static void
create_timeout_test (GtkWidget *widget)
{
static GtkWidget *window = NULL;
@ -5912,6 +5914,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 ();
}
}
@ -5922,7 +5926,7 @@ destroy_native (GtkFileChooserNative *native)
g_object_unref (native);
}
void
static void
create_native_dialogs (GtkWidget *widget)
{
static GtkWidget *window = NULL;
@ -6028,7 +6032,7 @@ create_native_dialogs (GtkWidget *widget)
* Main Window and Exit
*/
void
static void
do_exit (GtkWidget *widget, GtkWidget *window)
{
gtk_widget_destroy (window);
@ -6037,7 +6041,7 @@ do_exit (GtkWidget *widget, GtkWidget *window)
}
struct {
char *label;
const char *label;
void (*func) (GtkWidget *widget);
gboolean do_not_benchmark;
} buttons[] =
@ -6083,16 +6087,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;
@ -6203,8 +6207,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;
@ -6239,7 +6243,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;
@ -6276,7 +6280,7 @@ do_bench (char* what, int num)
}
}
void
static void
usage (void)
{
fprintf (stderr, "Usage: testgtk [--bench ALL|<bench>[:<count>]]\n");

View File

@ -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);
}

View File

@ -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)
{

View File

@ -77,7 +77,7 @@ visible_func (GtkTreeModel *model,
return visible;
}
GtkTreeModel *
static GtkTreeModel *
get_filter_model (gboolean first)
{
GtkTreeModelFilter *model;

View File

@ -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));

View File

@ -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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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 ();

View File

@ -20,10 +20,10 @@
*/
#include <gtk/gtk.h>
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)
{

View File

@ -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);

View File

@ -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,

View File

@ -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));

View File

@ -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);
}

View File

@ -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)

View File

@ -16,7 +16,6 @@
<property name="valign">center</property>
<signal name="clicked" handler="go_to_secondary"/>
</object>
<packing/>
</child>
<child type="title">
<object class="GtkStackSwitcher">
@ -38,7 +37,6 @@
<property name="valign">center</property>
<signal name="clicked" handler="back_to_main"/>
</object>
<packing/>
</child>
</object>
</property>

View File

@ -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);

View File

@ -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

View File

@ -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)
{

View File

@ -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))

View File

@ -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);

View File

@ -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 ();
}
}

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More