static void collab_sessioncallbacks_class_init (CollabSessionCallbacksClass *klass) { GType argtypes[] = {G_TYPE_POINTER}; g_signal_newv ("joining", (collab_sessioncallbacks_get_type ()), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL /* closure */, NULL /* accumulator */, NULL /* accumulator data */, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE /* return_type */, 1 /* n_params */, argtypes /* param_types */); g_signal_newv ("leaving", (collab_sessioncallbacks_get_type ()), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL /* closure */, NULL /* accumulator */, NULL /* accumulator data */, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE /* return_type */, 1 /* n_params */, argtypes /* param_types */); }
static void maintainr_projectbox_class_init (MaintainrProjectboxClass *klass) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = maintainr_projectbox_finalize; signals [MOVE_TOP] = g_signal_newv ("move-top", G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); signals [CONF_CHANGE] = g_signal_newv ("conf-changed", G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); signals [DELETE_PROJECT] = g_signal_newv ("delete-project", G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); g_type_class_add_private (klass, sizeof (MaintainrProjectboxPrivate)); }
static void wibuti_watcher_class_init(WibutiWatcherClass *klass) { g_signal_newv(WIBUTI_SIGNAL_WINDOW_CHANGED, WIBUTI_TYPE_WATCHER, G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); g_signal_newv(WIBUTI_SIGNAL_NAME_CHANGED, WIBUTI_TYPE_WATCHER, G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); g_signal_newv(WIBUTI_SIGNAL_ICON_CHANGED, WIBUTI_TYPE_WATCHER, G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); }
static void wibuti_widget_class_init(WibutiWidgetClass *klass) { #ifdef WIBUTI_WITH_BUTTONS g_signal_newv(WIBUTI_SIGNAL_MINIMIZE, WIBUTI_TYPE_WIDGET, G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); g_signal_newv(WIBUTI_SIGNAL_MAXIMIZE, WIBUTI_TYPE_WIDGET, G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); g_signal_newv(WIBUTI_SIGNAL_RESTORE, WIBUTI_TYPE_WIDGET, G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); g_signal_newv(WIBUTI_SIGNAL_CLOSE, WIBUTI_TYPE_WIDGET, G_SIGNAL_RUN_LAST, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); #endif // WIBUTI_WITH_BUTTONS }
dt_control_signal_t *dt_control_signal_init() { dt_control_signal_t *ctlsig = g_malloc(sizeof(dt_control_signal_t)); memset(ctlsig, 0, sizeof(dt_control_signal_t)); /* setup dummy gobject typeinfo */ GTypeQuery query; GTypeInfo type_info = { 0, (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0,0, (GInstanceInitFunc) NULL }; g_type_query(G_TYPE_OBJECT, &query); type_info.class_size = query.class_size; type_info.instance_size = query.instance_size; _signal_type = g_type_register_static(G_TYPE_OBJECT, "DarktableSignals", &type_info, 0); /* create our pretty empty gobject */ ctlsig->sink = g_object_new(_signal_type,NULL); /* create the signals */ for (int k=0; k<DT_SIGNAL_COUNT; k++) g_signal_newv(_signal_description[k].name, _signal_type, G_SIGNAL_RUN_LAST,0, _signal_description[k].accumulator,_signal_description[k].accu_data, _signal_description[k].c_marshaller,_signal_description[k].return_type, _signal_description[k].n_params,_signal_description[k].param_types); return ctlsig; }
guint GObjectWrapper::make_signal(GType return_type, guint n_params, GType *param_types) { guint sig_id = next_signal_num_; next_signal_num_++; gchar *name = g_strdup_printf("custom_signal_%d", sig_id); On_scope_exit{g_free(name);}; // TODO find a way to get CLASS without instanciating an unused object MyObject *obj = (MyObject *) g_object_new(my_object_get_type(), nullptr); guint signal_id = g_signal_newv(name, G_TYPE_FROM_CLASS(G_OBJECT_GET_CLASS (obj)), G_SIGNAL_RUN_LAST, 0, nullptr, // GSignalAccumulator nullptr, // gpointer accu_data nullptr, // GSignalCMarshaller return_type, n_params, param_types); g_object_unref(obj); return signal_id; }
static void verve_dbus_service_class_init (VerveDBusServiceClass *klass) { extern const DBusGObjectInfo dbus_glib_verve_dbus_service_object_info; GObjectClass *gobject_class; #if 0 g_type_class_add_private (klass, sizeof (VerveDBusServicePrivate)); #endif verve_dbus_service_parent_class = g_type_class_peek_parent (klass); gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = verve_dbus_service_finalize; /* Register "open-dialog" signal */ klass->open_dialog_signal_id = g_signal_newv ("open-dialog", G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); /* Register "grab-focus" signal */ klass->grab_focus_signal_id = g_signal_newv ("grab-focus", G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); /* Install the D-BUS info */ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_verve_dbus_service_object_info); }
static void test_i_default_init (gpointer g_class) { foo_signal_id = g_signal_newv ("foo", TEST_TYPE_I, G_SIGNAL_RUN_LAST, g_cclosure_new(G_CALLBACK(test_i_foo), NULL, NULL), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); }
static void gydp_list_data_base_init(gpointer klass) { static gboolean initialized = FALSE; if( !initialized ) { gydp_list_data_signals[SIGNAL_CHANGED] = g_signal_newv("changed", GYDP_TYPE_LIST_DATA, G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, /* closure, accumulator, accumulator data */ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0 , NULL); /* return type, params */ initialized = TRUE; } }
static void flow_ssh_master_class_init (FlowSshMasterClass *klass) { if (!g_thread_supported ()) g_thread_init (NULL); g_signal_newv ("connect-finished", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS, NULL, /* Class closure */ NULL, NULL, /* Accumulator, accu data */ g_cclosure_marshal_VOID__VOID, /* Marshaller */ G_TYPE_NONE, /* Return type */ 0, NULL); /* Number of params, param types */ g_signal_newv ("disconnected", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS, NULL, /* Class closure */ NULL, NULL, /* Accumulator, accu data */ g_cclosure_marshal_VOID__VOID, /* Marshaller */ G_TYPE_NONE, /* Return type */ 0, NULL); /* Number of params, param types */ }
/* --- functions --- */ guint gtk_signal_newv (const gchar *name, GtkSignalRunType signal_flags, GtkType object_type, guint function_offset, GtkSignalMarshaller marshaller, GtkType return_val, guint n_params, GtkType *params) { GClosure *closure; g_return_val_if_fail (n_params < SIGNAL_MAX_PARAMS, 0); closure = function_offset ? g_signal_type_cclosure_new (object_type, function_offset) : NULL; return g_signal_newv (name, object_type, (GSignalFlags)signal_flags, closure, NULL, NULL, marshaller, return_val, n_params, params); }
static void flow_connector_class_init (FlowConnectorClass *klass) { FlowElementClass *element_klass = FLOW_ELEMENT_CLASS (klass); /* The FlowSimplexElement default implementation just maps * input to output. That doesn't make sense for us. */ element_klass->output_pad_blocked = NULL; element_klass->output_pad_unblocked = NULL; element_klass->process_input = NULL; g_signal_newv ("connectivity-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS, NULL, /* Class closure */ NULL, NULL, /* Accumulator, accu data */ g_cclosure_marshal_VOID__VOID, /* Marshaller */ G_TYPE_NONE, /* Return type */ 0, NULL); /* Number of params, param types */ }
static void classy_test_class_init (ClassyTestClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = classy_test_finalize; klass->report = classy_test_report; klass->run = classy_test_run; /*Signals*/ klass->finished = g_signal_newv("finished", TYPE_CLASSY_TEST, G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); }
static void ol_config_class_init (OlConfigClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GParamSpec *ol_param_spec = NULL; ol_config_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (OlConfigPrivate)); /* gobject_class->set_property = ol_config_set_property; */ /* gobject_class->get_property = ol_config_get_property; */ gobject_class->dispose = ol_config_despose; gobject_class->finalize = ol_config_finalize; /* initialize properties */ int i; /* for (i = 0; i < ol_get_array_len (config_bool); i++) */ /* { */ /* ol_param_spec = g_param_spec_boolean (config_bool[i].name, */ /* config_bool[i].nick, */ /* config_bool[i].description, */ /* config_bool[i].default_value, */ /* G_PARAM_READWRITE); */ /* g_object_class_install_property (gobject_class, */ /* config_bool[i].key, */ /* ol_param_spec); */ /* } */ /* for (i = 0; i < ol_get_array_len (config_int); i++) */ /* { */ /* ol_param_spec = g_param_spec_int (config_int[i].name, */ /* config_int[i].nick, */ /* config_int[i].description, */ /* config_int[i].min, */ /* config_int[i].max, */ /* config_int[i].default_value, */ /* G_PARAM_READWRITE); */ /* g_object_class_install_property (gobject_class, */ /* config_int[i].key, */ /* ol_param_spec); */ /* } */ /* for (i = 0; i < ol_get_array_len (config_double); i++) */ /* { */ /* ol_param_spec = g_param_spec_double (config_double[i].name, */ /* config_double[i].nick, */ /* config_double[i].description, */ /* config_double[i].min, */ /* config_double[i].max, */ /* config_double[i].default_value, */ /* G_PARAM_READWRITE); */ /* g_object_class_install_property (gobject_class, */ /* config_double[i].key, */ /* ol_param_spec); */ /* } */ /* for (i = 0; i < ol_get_array_len (config_str); i++) */ /* { */ /* ol_param_spec = g_param_spec_string (config_str[i].name, */ /* config_str[i].nick, */ /* config_str[i].description, */ /* config_str[i].default_value, */ /* G_PARAM_READWRITE); */ /* g_object_class_install_property (gobject_class, */ /* config_str[i].key, */ /* ol_param_spec); */ /* } */ /* for (i = 0; i < ol_get_array_len (config_str_list); i++) */ /* { */ /* ol_param_spec = g_param_spec_boxed (config_str_list[i].name, */ /* config_str_list[i].nick, */ /* config_str_list[i].description, */ /* G_TYPE_STRV, */ /* G_PARAM_READWRITE); */ /* g_object_class_install_property (gobject_class, */ /* config_str_list[i].key, */ /* ol_param_spec); */ /* } */ /* initialize singals */ GType signal_type[2]; /* signal_type[0] = OL_TYPE_CONFIG; */ signal_type[0] = G_TYPE_STRING; signal_type[1] = G_TYPE_STRING; klass->signals[CHANGED] = g_signal_newv ("changed", G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL /* closure */, NULL /* accumulator */, NULL /* accumulator data */, ol_marshal_VOID__STRING_STRING, G_TYPE_NONE /* return_type */, 2 /* n_params */, signal_type /* param_types */); ol_debugf ("id of changed signal is: %d\n", klass->signals[CHANGED]); }
static void gopencl_context_class_init (GopenclContextClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); GParamSpec *pspec; GType signal_types[3]; gobject_class->set_property = gopencl_context_set_property; gobject_class->get_property = gopencl_context_get_property; pspec = g_param_spec_pointer("id", "Context ID", "Set context ID", G_PARAM_READWRITE); /** * GopenclContext:id: * * Associated cl_context_id in the OpenCL environment. * * Since: 0.1 */ g_object_class_install_property(gobject_class, PROP_CONTEXT_ID, pspec); pspec = g_param_spec_pointer("devices", "Context associated devices", "Set context devices", G_PARAM_READWRITE); /** * GopenclContext:devices: * * List of devices that build up the context. * * Since: 0.1 */ g_object_class_install_property(gobject_class, PROP_DEVICES, pspec); signal_types[0] = G_TYPE_STRING; signal_types[1] = G_TYPE_POINTER; signal_types[2] = G_TYPE_UINT; /** * GopenclContext::error-ocurred: * @object: the object... * @err_info: * @priv_info: * @cb: * * The ::error-ocurred signal is emitted each time an error within the OpenCL context occurs. * * Since: 0.1 */ signals[ERROR_OCURRED] = g_signal_newv("error-ocurred", G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_POINTER_UINT, G_TYPE_NONE, 3, signal_types); gobject_class->dispose = gopencl_context_dispose; gobject_class->finalize = gopencl_context_finalize; g_type_class_add_private(klass, sizeof(GopenclContextPrivate)); }
int ada_initialize_class_record (GType ancestor, gint nsignals, char* signals[], GType parameters[], gint max_parameters, GType returns[], gint max_returns, AdaGObjectClass klass, gchar* type_name) { // Make this function thread-safe and ensure we only initialize the class // once if (g_once_init_enter (&klass->type)) { /* Note: The memory allocated in this function is never freed. No need to worry, since this is only allocated once per user's widget type, and might be used until the end of the application */ GTypeQuery query; int j; /* We need to know the ancestor's class/instance sizes */ g_type_query (ancestor, &query); /************************* * This code is the equivalent of type_name@@_get_type in C. In Ada, the * type will be accessible only once at least one instance of it has * been created (whereas in C the GType is created at elaboration time). *************************/ GTypeInfo info; info.class_size = query.class_size + nsignals * sizeof (void*); //+ sizeof (AdaGObjectClass); info.base_init = NULL; info.base_finalize = NULL; info.class_init = (GClassInitFunc)(&ada_class_record_init); info.class_finalize = NULL; info.class_data = (gconstpointer)klass; info.instance_size = query.instance_size; info.n_preallocs = 0; info.instance_init = NULL; info.value_table = NULL; GType new_type = g_type_register_static ( ancestor /* parent_type */, type_name /* type_name */, &info /* info */, 0 /* flags */); /************************* * This code is generally called by g_object_new (which itself is called * from type_name_new() in C). Its result is to create and initialized * (via class_init) the class the first time an instance of it is * created. In Ada, we do not us a _class_init, so we initialize the * signals immediately after creating the class. *************************/ for (j = 0; j < nsignals; j++) { int count = 0; GClosure *closure; while (count < max_parameters && (parameters [j * max_parameters + count] != G_TYPE_NONE)) { count++; } closure = g_signal_type_cclosure_new (new_type, query.class_size + j * sizeof (void*)); /* offset */ GType return_type = G_TYPE_NONE; GSignalAccumulator acc = NULL; if (j < max_returns) { return_type = returns[j]; if (return_type == G_TYPE_BOOLEAN) { acc = g_signal_accumulator_true_handled; } } /* id = */ g_signal_newv (signals[j], /* signal_name */ new_type, /* itype */ G_SIGNAL_RUN_LAST, /* signal_flags */ closure, /* class_closure */ acc, /* accumulator */ NULL, /* accu_data */ g_cclosure_marshal_VOID__VOID, /* c_marshaller, unused at the Ada level ??? This probably makes the widget unusable from C */ return_type, /* return_type */ count, /* n_params */ parameters + j * max_parameters); /* param_types */ } /* Do not call g_type_class_ref here, since that would prevent us * from adding interfaces later on. Instead, rely on the class_init * function */ g_once_init_leave (&klass->type, new_type); // sets klass->type return 1; } return 0; }