Skip to content

Instantly share code, notes, and snippets.

@fxff
fxff / gtk-method-patching.c
Created December 9, 2019 09:49
GTK method patching
// gtk-method-patching.c: an example of patching GTK methods.
// gcc `pkg-config --libs --cflags gtk+-3.0` gtk-method-patching.c
#include <gtk/gtk.h>
typedef void (* get_preferred_width) (GtkWidget *, gint *, gint *);
get_preferred_width original; // A place to store real function
void patched_gpw (GtkWidget *w, gint *min_w, gint *nat_w)
#include <stdio.h>
typedef struct {
int foo;
int bar;
} A;
typedef struct {
char foo;
char bar;
} B;