32
32
#include <gtk/gtk.h>
33
33
#include <gdk/gdk.h>
34
34
35
+ #include <girffi.h>
36
+
35
37
typedef void (* gtk_window_buildable_add_child_t ) (GtkBuildable * buildable , GtkBuilder * builder , GObject * child , const gchar * type );
36
38
typedef GObject * (* gtk_dialog_constructor_t ) (GType type , guint n_construct_properties , GObjectConstructParam * construct_params );
37
39
typedef char * (* gtk_check_version_t ) (guint required_major , guint required_minor , guint required_micro );
42
44
GDK_LIBRARY ,
43
45
GOBJECT_LIBRARY ,
44
46
GLIB_LIBRARY ,
47
+ GIREPOSITORY_LIBRARY ,
45
48
NUM_LIBRARIES
46
49
};
47
50
@@ -61,17 +64,23 @@ enum {
61
64
#define GLIB_LIBRARY_SONAME "libglib-2.0.so"
62
65
#endif
63
66
67
+ #ifndef GIREPOSITORY_LIBRARY_SONAME
68
+ #define GIREPOSITORY_LIBRARY_SONAME "libgirepository-1.0.so.1"
69
+ #endif
70
+
64
71
static const char * library_sonames [NUM_LIBRARIES ] = {
65
72
GTK_LIBRARY_SONAME ,
66
73
GDK_LIBRARY_SONAME ,
67
74
GOBJECT_LIBRARY_SONAME ,
68
- GLIB_LIBRARY_SONAME
75
+ GLIB_LIBRARY_SONAME ,
76
+ GIREPOSITORY_LIBRARY_SONAME
69
77
};
70
78
71
79
static void * volatile library_handles [NUM_LIBRARIES ] = {
72
80
NULL ,
73
81
NULL ,
74
82
NULL ,
83
+ NULL ,
75
84
NULL
76
85
};
77
86
@@ -171,6 +180,7 @@ RUNTIME_IMPORT_FUNCTION(GOBJECT_LIBRARY, g_type_instance_get_private, gpointer,
171
180
RUNTIME_IMPORT_FUNCTION (GOBJECT_LIBRARY , g_signal_connect_data , gulong , (gpointer instance , const gchar * detailed_signal , GCallback c_handler , gpointer data , GClosureNotify destroy_data , GConnectFlags connect_flags ), (instance , detailed_signal , c_handler , data , destroy_data , connect_flags ))
172
181
RUNTIME_IMPORT_FUNCTION (GLIB_LIBRARY , g_getenv , gchar * , (const char * name ), (name ))
173
182
RUNTIME_IMPORT_FUNCTION (GLIB_LIBRARY , g_logv , void , (const gchar * log_domain , GLogLevelFlags log_level , const gchar * format , va_list args ), (log_domain , log_level , format , args ))
183
+ RUNTIME_IMPORT_FUNCTION (GIREPOSITORY_LIBRARY , g_function_info_prep_invoker , gboolean , (GIFunctionInfo * info , GIFunctionInvoker * invoker , GError * * error ), (info , invoker , error ))
174
184
175
185
/* All methods that we want to overwrite are named orig_, all methods
176
186
* that we just want to call (either directly or indirectrly)
@@ -209,6 +219,7 @@ RUNTIME_IMPORT_FUNCTION(GLIB_LIBRARY, g_logv, void, (const gchar *log_domain, GL
209
219
#define g_getenv rtlookup_g_getenv
210
220
#define g_logv rtlookup_g_logv
211
221
#define g_log static_g_log
222
+ #define orig_g_function_info_prep_invoker rtlookup_g_function_info_prep_invoker
212
223
213
224
/* Forwarding of varadic functions is tricky. */
214
225
static void static_g_log (const gchar * log_domain , GLogLevelFlags log_level , const gchar * format , ...)
@@ -679,3 +690,24 @@ static gtk_window_private_info_t gtk_window_private_info ()
679
690
}
680
691
return info ;
681
692
}
693
+
694
+ gboolean g_function_info_prep_invoker (GIFunctionInfo * info , GIFunctionInvoker * invoker , GError * * error )
695
+ {
696
+ static gpointer orig_set_titlebar = NULL , orig_set_show_close_button = NULL ;
697
+ gboolean result ;
698
+
699
+ if (!orig_set_titlebar )
700
+ orig_set_titlebar = (gpointer ) find_orig_function (GTK_LIBRARY , "gtk_window_set_titlebar" );
701
+ if (!orig_set_show_close_button )
702
+ orig_set_show_close_button = (gpointer ) find_orig_function (GTK_LIBRARY , "gtk_header_bar_set_show_close_button" );
703
+
704
+ result = orig_g_function_info_prep_invoker (info , invoker , error );
705
+ if (result ) {
706
+ if (G_UNLIKELY (invoker -> native_address == orig_set_titlebar ))
707
+ invoker -> native_address = gtk_window_set_titlebar ;
708
+ if (G_UNLIKELY (invoker -> native_address == orig_set_show_close_button ))
709
+ invoker -> native_address = gtk_header_bar_set_show_close_button ;
710
+ }
711
+
712
+ return result ;
713
+ }
0 commit comments