From 1a3d41266972fbc01971ee044ddb7155dc33fa89 Mon Sep 17 00:00:00 2001 From: lizhuoheng <114734429+LiZhuoheng-coder@users.noreply.github.com> Date: Fri, 21 Apr 2023 16:37:17 +0800 Subject: Added more gtk3 wrapped functions (#720) --- src/include/gtkclass.h | 33 +++++++++++- src/tools/gtkclass.c | 94 +++++++++++++++++++++++++++++++++++ src/wrapped/wrappedgio2_private.h | 26 +++++----- src/wrapped/wrappedgobject2.c | 2 + src/wrapped/wrappedgobject2_private.h | 2 +- src/wrapped/wrappedgtk3.c | 2 + src/wrapped/wrappedgtk3_private.h | 4 +- 7 files changed, 147 insertions(+), 16 deletions(-) diff --git a/src/include/gtkclass.h b/src/include/gtkclass.h index 6e8d302f..beebbda8 100755 --- a/src/include/gtkclass.h +++ b/src/include/gtkclass.h @@ -55,6 +55,35 @@ typedef struct my_GInitiallyUnownedClass_s void* pdummy[6]; } my_GInitiallyUnownedClass_t; +typedef struct my_GApplicationClass_s +{ + void* construct_properties; + void (* startup) (void* application); + void (* activate) (void* application); + void (* open) (void* application, void* files, int n_files, void* hint); + int (* command_line) (void* application, void* command_line); + int (* local_command_line) (void* application, void* arguments, void* exit_status); + void (* before_emit) (void* application, void* platform_data); + void (* after_emit) (void* application, void* platform_data); + void (* add_platform_data) (void* application, void* builder); + void (* quit_mainloop) (void* application); + void (* run_mainloop) (void* application); + void (* shutdown) (void* application); + int (* dbus_register) (void* application, void* connection, void* object_path, void* error); + void (* dbus_unregister) (void* appvoidlication, void* connection, void* object_path); + int (* handle_local_options) (void* application, void* options); + int (* name_lost) (void* application); + uint32_t flags; + void* pdummy[6]; +} my_GApplicationClass_t; + +typedef struct my_GtkApplicationClass_s +{ + my_GApplicationClass_t parent_class; + void (*window_added) (void* application, void* window); + void (*window_removed) (void* application, void* window); +} my_GtkApplicationClass_t; + typedef struct my_GtkObjectClass_s { my_GObjectClass_t parent_class; @@ -657,6 +686,8 @@ void FiniGTKClass(); #define GTKCLASSES() \ GTKCLASS(GObject) \ GTKCLASS(GInitiallyUnowned) \ +GTKCLASS(GApplication) \ +GTKCLASS(GtkApplication) \ GTKCLASS(GtkObject) \ GTKCLASS(GtkWidget2) \ GTKCLASS(GtkWidget3) \ @@ -717,4 +748,4 @@ int my_signal_cb(void* a, void* b, void* c, void* d); void my_add_signal_offset(size_t klass, uint32_t offset, int n); -#endif //__GTKCLASS_H__ \ No newline at end of file +#endif //__GTKCLASS_H__ diff --git a/src/tools/gtkclass.c b/src/tools/gtkclass.c index 0335154e..718e32bc 100755 --- a/src/tools/gtkclass.c +++ b/src/tools/gtkclass.c @@ -221,6 +221,100 @@ static void bridgeGInitiallyUnownedClass(my_GInitiallyUnownedClass_t* class) } #undef SUPERGO +// ----- GApplicationClass ------ +// wrapper x86 -> natives of callbacks +WRAPPER(GApplication, startup, void, (void* application), 1, application); +WRAPPER(GApplication, activate, void, (void* application), 1, application); +WRAPPER(GApplication, open, void, (void* application, void* files, int n_files, void* hint), 4, application, files, n_files, hint); +WRAPPER(GApplication, command_line, void, (void* application, void* command_line), 2, application, command_line); +WRAPPER(GApplication, local_command_line, void, (void* application, void* arguments, void* exit_status), 3, application, arguments, exit_status); +WRAPPER(GApplication, before_emit, void*, (void* application, void* platform_data), 2, application, platform_data); +WRAPPER(GApplication, after_emit, void, (void* application, void* platform_data), 2, application, platform_data); +WRAPPER(GApplication, add_platform_data, void, (void* application, void* builder), 2, application, builder); +WRAPPER(GApplication, quit_mainloop, void, (void* application), 1, application); +WRAPPER(GApplication, run_mainloop, void, (void* application), 1, application); +WRAPPER(GApplication, shutdown, void, (void* application), 1, application); +WRAPPER(GApplication, dbus_register, void, (void* application, void* connection, void* object_path, void* error), 4, application, connection, object_path, error); +WRAPPER(GApplication, dbus_unregister, void, (void* application, void* connection, void* object_path), 3, application, connection, object_path); +WRAPPER(GApplication, handle_local_options, void, (void* application, void* options), 2, application, options); +WRAPPER(GApplication, name_lost, void, (void* application), 1, application); + +#define SUPERGO() \ + GO(startup, vFp); \ + GO(activate, vFp); \ + GO(open, vFppip); \ + GO(command_line, vFpp); \ + GO(local_command_line, vFppp); \ + GO(before_emit, vFpp); \ + GO(after_emit, vFpp); \ + GO(add_platform_data, vFpp); \ + GO(quit_mainloop, vFp); \ + GO(run_mainloop, vFp); \ + GO(shutdown, vFp); \ + GO(dbus_register, vFpppp); \ + GO(dbus_unregister, vFppp); \ + GO(handle_local_options, vFpp); \ + GO(name_lost, vFp); + +// wrap (so bridge all calls, just in case) +static void wrapGApplicationClass(my_GApplicationClass_t* class) +{ + #define GO(A, W) class->A = reverse_##A##_GApplication (W, class->A) + SUPERGO() + #undef GO +} +// unwrap (and use callback if not a native call anymore) +static void unwrapGApplicationClass(my_GApplicationClass_t* class) +{ + #define GO(A, W) class->A = find_##A##_GApplication (class->A) //SUPERGO()全部定义,但并未全部调用 + SUPERGO() + #undef GO +} +// autobridge +static void bridgeGApplicationClass(my_GApplicationClass_t* class) +{ + #define GO(A, W) autobridge_##A##_GApplication (W, class->A) + SUPERGO() + #undef GO +} + +#undef SUPERGO + +// ----- GtkApplicationClass ------ +// wrapper x86 -> natives of callbacks +WRAPPER(GtkApplication, window_added, void, (void* application, void* window), 2, application, window); +WRAPPER(GtkApplication, window_removed, void, (void* application, void* window), 2, application, window); + +#define SUPERGO() \ + GO(window_added, pFpp); \ + GO(window_removed, vFpp); + +static void wrapGtkApplicationClass(my_GtkApplicationClass_t* class) +{ + wrapGApplicationClass(&class->parent_class); + #define GO(A, W) class->A = reverse_##A##_GtkApplication (W, class->A) + SUPERGO() + #undef GO +} + +static void unwrapGtkApplicationClass(my_GtkApplicationClass_t* class) +{ + unwrapGApplicationClass(&class->parent_class); + #define GO(A, W) class->A = find_##A##_GtkApplication (class->A) + SUPERGO() + #undef GO +} + +static void bridgeGtkApplicationClass(my_GtkApplicationClass_t* class) +{ + bridgeGApplicationClass(&class->parent_class); + #define GO(A, W) autobridge_##A##_GtkApplication (W, class->A) + SUPERGO() + #undef GO +} + +#undef SUPERGO + // ----- GtkObjectClass ------ // wrapper x64 -> natives of callbacks WRAPPER(GtkObject, set_arg, void, (void* object, void* arg, uint32_t arg_id), 3, object, arg, arg_id); diff --git a/src/wrapped/wrappedgio2_private.h b/src/wrapped/wrappedgio2_private.h index 24bb36c9..148759ae 100755 --- a/src/wrapped/wrappedgio2_private.h +++ b/src/wrapped/wrappedgio2_private.h @@ -79,9 +79,9 @@ GO(g_app_launch_context_get_type, LFv) //GO(g_app_launch_context_new, //GO(g_app_launch_context_setenv, //GO(g_app_launch_context_unsetenv, -//GO(g_application_activate, +GO(g_application_activate, vFp) //GO(g_application_add_main_option, -//GO(g_application_add_main_option_entries, +GO(g_application_add_main_option_entries, vFpp) //GO(g_application_add_option_group, //GO(g_application_command_line_create_file_for_arg, //GO(g_application_command_line_get_arguments, @@ -107,16 +107,16 @@ GO(g_app_launch_context_get_type, LFv) //GO(g_application_get_is_registered, //GO(g_application_get_is_remote, //GO(g_application_get_resource_base_path, -//GO(g_application_get_type, +GO(g_application_get_type, LFv) //GO(g_application_hold, //GO(g_application_id_is_valid, //GO(g_application_mark_busy, -//GO(g_application_new, -//GO(g_application_open, -//GO(g_application_quit, -//GO(g_application_register, -//GO(g_application_release, -//GO(g_application_run, +GO(g_application_new, pFpi) +GO(g_application_open, vFppip) +GO(g_application_quit, vFp) +GO(g_application_register, iFppp) +GO(g_application_release, vFp) +GO(g_application_run, iFpip) //GO(g_application_send_notification, //GO(g_application_set_action_group, //GO(g_application_set_application_id, @@ -809,7 +809,7 @@ GO(g_file_mount_enclosing_volume_finish, iFppp) //GOM(g_file_mount_mountable, vFEpippBp) GO(g_file_mount_mountable_finish, pFppp) //GOM(g_file_move, iFEppipBpp) -//GO(g_filename_completer_get_completions, +GO(g_filename_completer_get_completions, pFpp) //GO(g_filename_completer_get_completion_suffix, //GO(g_filename_completer_get_type, //GO(g_filename_completer_new, @@ -1360,7 +1360,7 @@ GO(g_settings_schema_source_lookup, pFppi) //GO(g_settings_schema_source_new_from_directory, GO(g_settings_schema_source_ref, pFp) GO(g_settings_schema_source_unref, vFp) -//GO(g_settings_schema_unref, +GO(g_settings_schema_unref, vFp) //GO(g_settings_set, //GO(g_settings_set_boolean, //GO(g_settings_set_double, @@ -1565,9 +1565,9 @@ GO(g_simple_proxy_resolver_get_type, LFv) //GO(g_srv_target_get_weight, //GO(g_srv_target_list_sort, //GO(g_srv_target_new, -//GO(g_static_resource_fini, +GO(g_static_resource_fini, vFp) //GO(g_static_resource_get_resource, -//GO(g_static_resource_init, +GO(g_static_resource_init, vFp) //GO(g_subprocess_communicate, //GO(g_subprocess_communicate_async, //GO(g_subprocess_communicate_finish, diff --git a/src/wrapped/wrappedgobject2.c b/src/wrapped/wrappedgobject2.c index f9fc35b9..fbb54337 100755 --- a/src/wrapped/wrappedgobject2.c +++ b/src/wrapped/wrappedgobject2.c @@ -28,6 +28,7 @@ typedef void*(*pFL_t)(size_t); #define ADDED_FUNCTIONS() \ GO(g_object_get_type, LFv_t) \ GO(g_initially_unowned_get_type, LFv_t) \ + GO(g_application_get_type, LFv_t) \ GO(g_type_name, pFL_t) \ GO(g_type_class_peek, pFL_t) \ @@ -904,6 +905,7 @@ EXPORT void* my_g_type_value_table_peek(x64emu_t* emu, size_t type) getMy(lib); \ SetGObjectID(my->g_object_get_type()); \ SetGInitiallyUnownedID(my->g_initially_unowned_get_type()); \ + SetGApplicationID(my->g_application_get_type()); \ SetGTypeName(my->g_type_name); \ SetGClassPeek(my->g_type_class_peek); \ setNeededLibs(lib, 1, "libglib-2.0.so.0"); diff --git a/src/wrapped/wrappedgobject2_private.h b/src/wrapped/wrappedgobject2_private.h index 4d74c453..0fb5bb02 100755 --- a/src/wrapped/wrappedgobject2_private.h +++ b/src/wrapped/wrappedgobject2_private.h @@ -268,7 +268,7 @@ GO(g_thread_get_type, LFv) GO(g_time_zone_get_type, LFv) //GOM(g_type_add_class_cache_func, vFEpB) GO(g_type_add_class_private, vFpLu) -//GO(g_type_add_instance_private, +GO(g_type_add_instance_private, pFpi) //GOM(g_type_add_interface_check, vFEpB) //GOM(g_type_add_interface_dynamic, vFEiip) GOM(g_type_add_interface_static, vFELLp) diff --git a/src/wrapped/wrappedgtk3.c b/src/wrapped/wrappedgtk3.c index 46adf789..fb14b8b6 100755 --- a/src/wrapped/wrappedgtk3.c +++ b/src/wrapped/wrappedgtk3.c @@ -60,6 +60,7 @@ GO(gtk_progress_bar_get_type, LFv_t) \ GO(gtk_menu_shell_get_type, LFv_t) \ GO(gtk_menu_bar_get_type, LFv_t) \ GO(gtk_action_get_type, LFv_t) \ +GO(gtk_application_get_type, LFv_t) \ GO(gtk_dialog_add_button, pFppi_t) \ GO(gtk_spin_button_get_value, dFp_t) \ GO(gtk_builder_lookup_callback_symbol, pFpp_t) \ @@ -722,6 +723,7 @@ EXPORT void my3_gtk_container_foreach(x64emu_t* emu, void* container, void* cb, libname = lib->name; \ getMy(lib); \ SETALT(my3_); \ + SetGtkApplicationID(my->gtk_application_get_type()); \ SetGtkWidget3ID(my->gtk_widget_get_type()); \ SetGtkContainer3ID(my->gtk_container_get_type()); \ SetGtkTextView3ID(my->gtk_text_view_get_type()); \ diff --git a/src/wrapped/wrappedgtk3_private.h b/src/wrapped/wrappedgtk3_private.h index 75e60333..bbc80b43 100755 --- a/src/wrapped/wrappedgtk3_private.h +++ b/src/wrapped/wrappedgtk3_private.h @@ -191,7 +191,9 @@ GO(gtk_alignment_set_padding, vFpuuuu) GO(gtk_align_get_type, pFv) GO(gtk_alternative_dialog_button_order, iFp) GO(gtk_anchor_type_get_type, pFv) +GO(gtk_application_get_new, pFpi) GO(gtk_application_get_type, pFv) +GO(gtk_application_window_new, pFp) GO(gtk_application_window_get_type, pFv) GO(gtk_app_chooser_button_get_type, pFv) GO(gtk_app_chooser_dialog_get_type, pFv) @@ -2481,7 +2483,7 @@ GO(gtk_recent_info_get_type, pFv) //GO(gtk_recent_info_last_application, //GO(gtk_recent_info_match, //GO(gtk_recent_info_ref, -//GO(gtk_recent_info_unref, +GO(gtk_recent_info_unref, vFp) //GO(gtk_recent_manager_add_full, //GO(gtk_recent_manager_add_item, GO(gtk_recent_manager_error_get_type, pFv) -- cgit 1.4.1