static WatchNameData * watch_name_data_new (GClosure *name_appeared_closure, GClosure *name_vanished_closure) { WatchNameData *data; data = g_new0 (WatchNameData, 1); if (name_appeared_closure != NULL) { data->name_appeared_closure = g_closure_ref (name_appeared_closure); g_closure_sink (name_appeared_closure); if (G_CLOSURE_NEEDS_MARSHAL (name_appeared_closure)) g_closure_set_marshal (name_appeared_closure, g_cclosure_marshal_generic); } if (name_vanished_closure != NULL) { data->name_vanished_closure = g_closure_ref (name_vanished_closure); g_closure_sink (name_vanished_closure); if (G_CLOSURE_NEEDS_MARSHAL (name_vanished_closure)) g_closure_set_marshal (name_vanished_closure, g_cclosure_marshal_generic); } return data; }
static OwnNameData * own_name_data_new (GClosure *bus_acquired_closure, GClosure *name_acquired_closure, GClosure *name_lost_closure) { OwnNameData *data; data = g_new0 (OwnNameData, 1); if (bus_acquired_closure != NULL) { data->bus_acquired_closure = g_closure_ref (bus_acquired_closure); g_closure_sink (bus_acquired_closure); if (G_CLOSURE_NEEDS_MARSHAL (bus_acquired_closure)) g_closure_set_marshal (bus_acquired_closure, g_cclosure_marshal_generic); } if (name_acquired_closure != NULL) { data->name_acquired_closure = g_closure_ref (name_acquired_closure); g_closure_sink (name_acquired_closure); if (G_CLOSURE_NEEDS_MARSHAL (name_acquired_closure)) g_closure_set_marshal (name_acquired_closure, g_cclosure_marshal_generic); } if (name_lost_closure != NULL) { data->name_lost_closure = g_closure_ref (name_lost_closure); g_closure_sink (name_lost_closure); if (G_CLOSURE_NEEDS_MARSHAL (name_lost_closure)) g_closure_set_marshal (name_lost_closure, g_cclosure_marshal_generic); } return data; }
void dt_lua_async_call_alien_internal(const char * call_function, int line,lua_CFunction pusher,int nresults,dt_lua_finish_callback cb, void*cb_data, dt_lua_async_call_arg_type arg_type,...) { #ifdef _DEBUG dt_print(DT_DEBUG_LUA,"LUA DEBUG : %s called from %s %d\n",__FUNCTION__,call_function,line); #endif async_call_data*data = malloc(sizeof(async_call_data)); data->pusher = pusher; data->extra=NULL; data->cb = cb; data->cb_data = cb_data; data->nresults = nresults; va_list ap; va_start(ap,arg_type); dt_lua_async_call_arg_type cur_type = arg_type; while(cur_type != LUA_ASYNC_DONE){ data->extra=g_list_append(data->extra,GINT_TO_POINTER(cur_type)); switch(cur_type) { case LUA_ASYNC_TYPEID: data->extra=g_list_append(data->extra,GINT_TO_POINTER(va_arg(ap,luaA_Type))); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); break; case LUA_ASYNC_TYPEID_WITH_FREE: { data->extra=g_list_append(data->extra,GINT_TO_POINTER(va_arg(ap,luaA_Type))); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); GClosure* closure = va_arg(ap,GClosure*); g_closure_ref (closure); g_closure_sink (closure); g_closure_set_marshal(closure, g_cclosure_marshal_generic); data->extra=g_list_append(data->extra,closure); } break; case LUA_ASYNC_TYPENAME: data->extra=g_list_append(data->extra,va_arg(ap,char *)); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); break; case LUA_ASYNC_TYPENAME_WITH_FREE: { data->extra=g_list_append(data->extra,va_arg(ap,char *)); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); GClosure* closure = va_arg(ap,GClosure*); g_closure_ref (closure); g_closure_sink (closure); g_closure_set_marshal(closure, g_cclosure_marshal_generic); data->extra=g_list_append(data->extra,closure); } break; default: // should never happen g_assert(false); break; } cur_type = va_arg(ap,dt_lua_async_call_arg_type); } va_end(ap); g_async_queue_push(darktable.lua_state.alien_job_queue,(gpointer)data); g_main_context_wakeup(darktable.lua_state.context); }
/** * g_source_set_closure: * @source: the source * @closure: a #GClosure * * Set the callback for a source as a #GClosure. * * If the source is not one of the standard GLib types, the @closure_callback * and @closure_marshal fields of the #GSourceFuncs structure must have been * filled in with pointers to appropriate functions. */ void g_source_set_closure (GSource *source, GClosure *closure) { g_return_if_fail (source != NULL); g_return_if_fail (closure != NULL); if (!source->source_funcs->closure_callback && source->source_funcs != &g_io_watch_funcs && source->source_funcs != &g_timeout_funcs && source->source_funcs != &g_idle_funcs) { g_critical (G_STRLOC ": closure can not be set on closure without GSourceFuncs::closure_callback\n"); return; } g_closure_ref (closure); g_closure_sink (closure); g_source_set_callback_indirect (source, closure, &closure_callback_funcs); if (G_CLOSURE_NEEDS_MARSHAL (closure)) { GClosureMarshal marshal = (GClosureMarshal)source->source_funcs->closure_marshal; if (!marshal) { if (source->source_funcs == &g_idle_funcs || source->source_funcs == &g_timeout_funcs) marshal = source_closure_marshal_BOOLEAN__VOID; else if (source->source_funcs == &g_io_watch_funcs) marshal = g_cclosure_marshal_BOOLEAN__FLAGS; } if (marshal) g_closure_set_marshal (closure, marshal); } }
/* * clutter_alpha_set_closure_internal: * @alpha: a #ClutterAlpha * @closure: a #GClosure * * Sets the @closure for @alpha. This function does not * set the #ClutterAlpha:mode property and does not emit * the #GObject::notify signal for it. */ static inline void clutter_alpha_set_closure_internal (ClutterAlpha *alpha, GClosure *closure) { ClutterAlphaPrivate *priv = alpha->priv; if (priv->notify != NULL) priv->notify (priv->user_data); else if (priv->closure != NULL) g_closure_unref (priv->closure); priv->func = NULL; priv->user_data = NULL; priv->notify = NULL; if (closure == NULL) return; /* need to take ownership of the closure before sinking it */ priv->closure = g_closure_ref (closure); g_closure_sink (closure); /* set the marshaller */ if (G_CLOSURE_NEEDS_MARSHAL (closure)) { GClosureMarshal marshal = _clutter_marshal_DOUBLE__VOID; g_closure_set_marshal (priv->closure, marshal); } }
/** * pyg_closure_new: * callback: a Python callable object * extra_args: a tuple of extra arguments, or None/NULL. * swap_data: an alternative python object to pass first. * * Creates a GClosure wrapping a Python callable and optionally a set * of additional function arguments. This is needed to attach python * handlers to signals, for instance. * * Returns: the new closure. */ GClosure * pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data) { GClosure *closure; g_return_val_if_fail(callback != NULL, NULL); closure = g_closure_new_simple(sizeof(PyGClosure), NULL); g_closure_add_invalidate_notifier(closure, NULL, pyg_closure_invalidate); g_closure_set_marshal(closure, pyg_closure_marshal); Py_INCREF(callback); ((PyGClosure *)closure)->callback = callback; if (extra_args && extra_args != Py_None) { Py_INCREF(extra_args); if (!PyTuple_Check(extra_args)) { PyObject *tmp = PyTuple_New(1); PyTuple_SetItem(tmp, 0, extra_args); extra_args = tmp; } ((PyGClosure *)closure)->extra_args = extra_args; } if (swap_data) { Py_INCREF(swap_data); ((PyGClosure *)closure)->swap_data = swap_data; closure->derivative_flag = TRUE; } return closure; }
nsresult nsAlertsIconListener::ShowAlert(GdkPixbuf* aPixbuf) { mNotification = notify_notification_new(mAlertTitle.get(), mAlertText.get(), nullptr, nullptr); if (!mNotification) return NS_ERROR_OUT_OF_MEMORY; if (aPixbuf) notify_notification_set_icon_from_pixbuf(mNotification, aPixbuf); NS_ADDREF(this); if (mAlertHasAction) { // What we put as the label doesn't matter here, if the action // string is "default" then that makes the entire bubble clickable // rather than creating a button. notify_notification_add_action(mNotification, "default", "Activate", notify_action_cb, this, nullptr); } // Fedora 10 calls NotifyNotification "closed" signal handlers with a // different signature, so a marshaller is used instead of a C callback to // get the user_data (this) in a parseable format. |closure| is created // with a floating reference, which gets sunk by g_signal_connect_closure(). GClosure* closure = g_closure_new_simple(sizeof(GClosure), this); g_closure_set_marshal(closure, notify_closed_marshal); mClosureHandler = g_signal_connect_closure(mNotification, "closed", closure, FALSE); gboolean result = notify_notification_show(mNotification, nullptr); return result ? NS_OK : NS_ERROR_FAILURE; }
GtkWidget * aw_popup_dialog_append (AwPopupDialog *dialog, const char *title, const char *details, AwPopupDialogCallback callback, gpointer user_data) { GtkWidget *button, *content_area; GClosure *closure; g_return_val_if_fail (AW_IS_POPUP_DIALOG (dialog), NULL); button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL, title, details); closure = g_cclosure_new (G_CALLBACK (callback), user_data, NULL); g_closure_set_marshal (closure, aw_cclosure_marshal_BOOLEAN__VOID); g_signal_connect_data (button, "clicked", G_CALLBACK (aw_popup_dialog_clicked_cb), closure, (GClosureNotify) g_closure_unref, 0); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_container_add (GTK_CONTAINER (content_area), button); gtk_widget_show (button); return button; }
/** * _nm_dbus_signal_connect_data: * @proxy: a #GDBusProxy * @signal_name: the D-Bus signal to connect to * @signature: (allow-none): the signal's type signature (must be a tuple) * @c_handler: the signal handler function * @data: (allow-none): data to pass to @c_handler * @destroy_data: (allow-none): closure destroy notify for @data * @connect_flags: connection flags * * Connects to the D-Bus signal @signal_name on @proxy. @c_handler must be a * void function whose first argument is a #GDBusProxy, followed by arguments * for each element of @signature, ending with a #gpointer argument for @data. * * The argument types in @c_handler correspond to the types output by * g_dbus_gvariant_to_gvalue(), except for 'ay' and 'aay'. In particular: * - both 16-bit and 32-bit integers are passed as #gint/#guint * - 'as' values are passed as #GStrv (char **) * - all other array, tuple, and dict types are passed as #GVariant * * If @signature is %NULL, then the signal's parameters will be ignored, and * @c_handler should take only the #GDBusProxy and #gpointer arguments. * * Returns: the signal handler ID, which can be used with * g_signal_handler_remove(). Beware that because of the way the signal is * connected, you will not be able to remove it with * g_signal_handlers_disconnect_by_func(), although * g_signal_handlers_disconnect_by_data() will work correctly. */ gulong _nm_dbus_signal_connect_data (GDBusProxy *proxy, const char *signal_name, const GVariantType *signature, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags) { NMDBusSignalData *sd; GClosure *closure; gboolean swapped = !!(connect_flags & G_CONNECT_SWAPPED); gboolean after = !!(connect_flags & G_CONNECT_AFTER); g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), 0); g_return_val_if_fail (signal_name != NULL, 0); g_return_val_if_fail (signature == NULL || g_variant_type_is_tuple (signature), 0); g_return_val_if_fail (c_handler != NULL, 0); sd = g_slice_new (NMDBusSignalData); sd->signal_name = g_strdup (signal_name); sd->signature = signature; closure = (swapped ? g_cclosure_new_swap : g_cclosure_new) (c_handler, data, destroy_data); g_closure_set_marshal (closure, g_cclosure_marshal_generic); g_closure_set_meta_marshal (closure, sd, dbus_signal_meta_marshal); g_closure_add_finalize_notifier (closure, sd, dbus_signal_data_free); return g_signal_connect_closure (proxy, "g-signal", closure, after); }
/* Hack. We iterate over the accel map instead of the actions, * in order to pull the parameters out of accel map entries */ static void add_accel_closure (gpointer data, const gchar *accel_path, guint accel_key, GdkModifierType accel_mods, gboolean changed) { GtkApplicationWindow *window = data; GActionGroup *actions; const gchar *path; const gchar *p; gchar *action_name; GVariant *parameter; AccelClosure *closure; if (accel_key == 0) return; if (!g_str_has_prefix (accel_path, "<GAction>/")) return; path = accel_path + strlen ("<GAction>/"); p = strchr (path, '/'); if (p) { action_name = g_strndup (path, p - path); parameter = g_variant_parse (NULL, p + 1, NULL, NULL, NULL); if (!parameter) g_warning ("Failed to parse parameter from '%s'\n", accel_path); } else { action_name = g_strdup (path); parameter = NULL; } actions = G_ACTION_GROUP (_gtk_widget_get_action_muxer (GTK_WIDGET (window))); if (g_action_group_has_action (actions, action_name)) { closure = (AccelClosure*) g_closure_new_object (sizeof (AccelClosure), g_object_ref (actions)); g_closure_set_marshal (&closure->closure, accel_activate); closure->action_name = g_strdup (action_name); closure->parameter = parameter ? g_variant_ref_sink (parameter) : NULL; window->priv->accel_closures = g_slist_prepend (window->priv->accel_closures, g_closure_ref (&closure->closure)); g_closure_sink (&closure->closure); gtk_accel_group_connect_by_path (window->priv->accels, accel_path, &closure->closure); } else if (parameter) { g_variant_unref (parameter); } g_free (action_name); }
CALLER_OWN GClosure *owl_variable_make_closure(owl_variable *v, GCallback fn, GClosureMarshal marshal) { GClosure *closure = g_cclosure_new_swap(fn, v, NULL); g_closure_set_marshal(closure,marshal); g_closure_ref(closure); g_closure_sink(closure); return closure; }
static inline GClosure *createCppClosure(ClosureDataBase *closureData) { GClosure *closure = g_closure_new_simple(sizeof(GClosure), closureData); g_closure_set_marshal(closure, &c_marshaller); g_closure_add_finalize_notifier(closure, NULL, &closureDestroyNotify); g_closure_ref(closure); g_closure_sink(closure); return closure; }
/** * pka_subscription_set_handlers: * @subscription: A #PkaSubscription. * @context: A #PkaContext. * @manifest_func: A manifest callback function. * @manifest_data: Data for @manifest_func. * @manifest_destroy: A #GDestroyNotify to call when @manifest_func is no * longer needed. * @sample_func: A sample callback function. * @sample_data: Data for @sample_func. * @sample_destroy: A #GDestroyNotify to call when @sample_func is no * longer needed. * * Sets the manifest and sample callback methods for the subscription. * @manifest_func will be called when a manifest is received from a source * on the subscription. @sample_func will be called when a sample is received * from the subscription. * * Returns: None. * Side effects: None. */ void pka_subscription_set_handlers (PkaSubscription *subscription, /* IN */ PkaContext *context, /* IN */ PkaManifestFunc manifest_func, /* IN */ gpointer manifest_data, /* IN */ GDestroyNotify manifest_destroy, /* IN */ PkaSampleFunc sample_func, /* IN */ gpointer sample_data, /* IN */ GDestroyNotify sample_destroy, /* IN */ GError **error) /* IN */ { GClosure *manifest; GClosure *sample; g_return_if_fail(subscription != NULL); g_return_if_fail(context != NULL); ENTRY; /* * Create the closures and set the marshaller. */ manifest = g_cclosure_new(G_CALLBACK(manifest_func), manifest_data, (GClosureNotify)manifest_destroy); sample = g_cclosure_new(G_CALLBACK(sample_func), sample_data, (GClosureNotify)sample_destroy); g_closure_set_marshal(manifest, pka_marshal_VOID__POINTER_ULONG); g_closure_set_marshal(sample, pka_marshal_VOID__POINTER_ULONG); /* * Store the closures. Requires writer lock. */ g_static_rw_lock_writer_lock(&subscription->rw_lock); if (subscription->manifest_closure) { g_closure_unref(subscription->manifest_closure); } if (subscription->sample_closure) { g_closure_unref(subscription->sample_closure); } subscription->manifest_closure = manifest; subscription->sample_closure = sample; g_static_rw_lock_writer_unlock(&subscription->rw_lock); EXIT; }
Gtk$GObject$Closure_t *_from_val(Std$Object_t *Function) { val_closure_t *Handle = (val_closure_t *)g_closure_new_simple(sizeof(val_closure_t), 0); Handle->Function = Function; g_closure_set_marshal((GClosure *)Handle, (GClosureMarshal)__marshal_val); Gtk$GObject$Closure_t *Closure = new(Gtk$GObject$Closure_t); Closure->Type = T; Closure->Handle = (GClosure *)Handle; Handle->Closure = Closure; return Closure; };
void _owr_session_set_on_local_candidate_change(OwrSession *session, GClosure *on_local_candidate_change) { g_return_if_fail(OWR_IS_SESSION(session)); g_return_if_fail(on_local_candidate_change); if (session->priv->on_local_candidate_change) g_closure_unref(session->priv->on_local_candidate_change); session->priv->on_local_candidate_change = on_local_candidate_change; g_closure_set_marshal(session->priv->on_local_candidate_change, g_cclosure_marshal_generic); }
/** * _owr_session_set_on_remote_candidate: * @session: * @on_remote_candidate: (transfer full): * */ void _owr_session_set_on_remote_candidate(OwrSession *session, GClosure *on_remote_candidate) { g_return_if_fail(session); g_return_if_fail(on_remote_candidate); if (session->priv->on_remote_candidate) g_closure_unref(session->priv->on_remote_candidate); session->priv->on_remote_candidate = on_remote_candidate; g_closure_set_marshal(session->priv->on_remote_candidate, g_cclosure_marshal_generic); }
Gtk$GObject$Closure_t *_from_ref(Std$Object_t **Function) { ref_closure_t *Handle = g_closure_new_simple(sizeof(ref_closure_t), 0); Handle->Function = Function; g_closure_set_marshal(Handle, __marshal_ref); Gtk$GObject$Closure_t *Closure = new(Gtk$GObject$Closure_t); Closure->Type = T; Closure->Handle = Handle; Handle->Closure = Closure; return Closure; };
/** * g_source_set_closure: * @source: the source * @closure: a #GClosure * * Set the callback for a source as a #GClosure. * * If the source is not one of the standard GLib types, the @closure_callback * and @closure_marshal fields of the #GSourceFuncs structure must have been * filled in with pointers to appropriate functions. */ void g_source_set_closure (GSource *source, GClosure *closure) { g_return_if_fail (source != NULL); g_return_if_fail (closure != NULL); if (!source->source_funcs->closure_callback && #ifdef G_OS_UNIX source->source_funcs != &g_unix_fd_source_funcs && source->source_funcs != &g_unix_signal_funcs && #endif source->source_funcs != &g_child_watch_funcs && source->source_funcs != &g_io_watch_funcs && source->source_funcs != &g_timeout_funcs && source->source_funcs != &g_idle_funcs) { g_critical (G_STRLOC ": closure cannot be set on GSource without GSourceFuncs::closure_callback\n"); return; } g_closure_ref (closure); g_closure_sink (closure); g_source_set_callback_indirect (source, closure, &closure_callback_funcs); g_closure_add_invalidate_notifier (closure, source, closure_invalidated); if (G_CLOSURE_NEEDS_MARSHAL (closure)) { GClosureMarshal marshal = (GClosureMarshal)source->source_funcs->closure_marshal; if (marshal) g_closure_set_marshal (closure, marshal); else if (source->source_funcs == &g_idle_funcs || #ifdef G_OS_UNIX source->source_funcs == &g_unix_signal_funcs || #endif source->source_funcs == &g_timeout_funcs) g_closure_set_marshal (closure, source_closure_marshal_BOOLEAN__VOID); else g_closure_set_marshal (closure, g_cclosure_marshal_generic); } }
/** * pacman_manager_set_transfer_handler: * @manager: A #PacmanManager. * @func: A #PacmanTransferFunc function, or %NULL to download files internally. * @user_data: User data to pass to @func. * @destroy_data: A #GClosureNotify to be called when @user_data is no longer needed. * * Sets the function that pacman will use to download files to @func. See #PacmanTransferFunc. */ void pacman_manager_set_transfer_handler (PacmanManager *manager, PacmanTransferFunc func, gpointer user_data, GClosureNotify destroy_data) { g_return_if_fail (manager != NULL); if (func == NULL) { pacman_manager_set_transfer_closure (manager, NULL); } else { GClosure *closure = g_cclosure_new (G_CALLBACK (func), user_data, destroy_data); g_closure_set_marshal (closure, g_cclosure_user_marshal_INT__STRING_STRING_BOOLEAN); pacman_manager_set_transfer_closure (manager, closure); } }
GClosure* gjs_closure_new_marshaled (JSContext *context, JSObject *callable, const char *description) { GClosure *closure; closure = gjs_closure_new(context, callable, description, TRUE); g_closure_set_marshal(closure, closure_marshal); return closure; }
/** * g_object_bind_property_with_closures: * @source: (type GObject.Object): the source #GObject * @source_property: the property on @source to bind * @target: (type GObject.Object): the target #GObject * @target_property: the property on @target to bind * @flags: flags to pass to #GBinding * @transform_to: a #GClosure wrapping the transformation function * from the @source to the @target, or %NULL to use the default * @transform_from: a #GClosure wrapping the transformation function * from the @target to the @source, or %NULL to use the default * * Creates a binding between @source_property on @source and @target_property * on @target, allowing you to set the transformation functions to be used by * the binding. * * This function is the language bindings friendly version of * g_object_bind_property_full(), using #GClosure<!-- -->s instead of * function pointers. * * Rename to: g_object_bind_property_full * * Return value: (transfer none): the #GBinding instance representing the * binding between the two #GObject instances. The binding is released * whenever the #GBinding reference count reaches zero. * * Since: 2.26 */ GBinding * g_object_bind_property_with_closures (gpointer source, const gchar *source_property, gpointer target, const gchar *target_property, GBindingFlags flags, GClosure *transform_to, GClosure *transform_from) { TransformData *data; data = g_slice_new0 (TransformData); if (transform_to != NULL) { if (G_CLOSURE_NEEDS_MARSHAL (transform_to)) g_closure_set_marshal (transform_to, g_cclosure_marshal_BOOLEAN__BOXED_BOXED); data->transform_to_closure = g_closure_ref (transform_to); g_closure_sink (data->transform_to_closure); } if (transform_from != NULL) { if (G_CLOSURE_NEEDS_MARSHAL (transform_from)) g_closure_set_marshal (transform_from, g_cclosure_marshal_BOOLEAN__BOXED_BOXED); data->transform_from_closure = g_closure_ref (transform_from); g_closure_sink (data->transform_from_closure); } return g_object_bind_property_full (source, source_property, target, target_property, flags, transform_to != NULL ? bind_with_closures_transform_to : NULL, transform_from != NULL ? bind_with_closures_transform_from : NULL, data, bind_with_closures_free_func); }
GObjectEventListener::GObjectEventListener(GObject* target, EventTarget* coreTarget, const char* domEventName, GClosure* handler, bool capture) : EventListener(GObjectEventListenerType) , m_target(target) , m_coreTarget(coreTarget) , m_domEventName(domEventName) , m_handler(handler) , m_capture(capture) { ASSERT(m_coreTarget); if (G_CLOSURE_NEEDS_MARSHAL(m_handler.get())) g_closure_set_marshal(m_handler.get(), g_cclosure_marshal_generic); g_object_weak_ref(m_target, reinterpret_cast<GWeakNotify>(GObjectEventListener::gobjectDestroyedCallback), this); }
/** * _owr_data_channel_set_on_request_bytes_sent: * @data_channel: * @on_request_bytes_sent: (transfer full): * */ void _owr_data_channel_set_on_request_bytes_sent(OwrDataChannel *data_channel, GClosure *on_request_bytes_sent) { OwrDataChannelPrivate *priv = data_channel->priv; if (priv->on_request_bytes_sent) { g_closure_invalidate(priv->on_request_bytes_sent); g_closure_unref(priv->on_request_bytes_sent); } priv->on_request_bytes_sent = on_request_bytes_sent; if (on_request_bytes_sent) g_closure_set_marshal(priv->on_request_bytes_sent, g_cclosure_marshal_generic); }
/** * _owr_data_channel_set_on_send: * @data_channel: * @on_datachannel_send: (transfer full): * */ void _owr_data_channel_set_on_send(OwrDataChannel *data_channel, GClosure *on_datachannel_send) { OwrDataChannelPrivate *priv = data_channel->priv; if (priv->on_datachannel_send) { g_closure_invalidate(priv->on_datachannel_send); g_closure_unref(priv->on_datachannel_send); } priv->on_datachannel_send = on_datachannel_send; if (on_datachannel_send) g_closure_set_marshal(priv->on_datachannel_send, g_cclosure_marshal_generic); }
/** * pyg_signal_class_closure_get: * * Returns the GClosure used for the class closure of signals. When * called, it will invoke the method do_signalname (for the signal * "signalname"). * * Returns: the closure. */ GClosure * pyg_signal_class_closure_get(void) { static GClosure *closure; if (closure == NULL) { closure = g_closure_new_simple(sizeof(GClosure), NULL); g_closure_set_marshal(closure, pyg_signal_class_closure_marshal); g_closure_ref(closure); g_closure_sink(closure); } return closure; }
void moo_plugin_method_newv (const char *name, GType ptype, GClosure *closure, GClosureMarshal c_marshaller, GType return_type, guint n_params, const GType *param_types) { MooPluginMeth *m; GHashTable *meths; char *norm_name; g_return_if_fail (g_type_is_a (ptype, MOO_TYPE_PLUGIN)); g_return_if_fail (name != NULL); g_return_if_fail (closure != NULL); g_return_if_fail (c_marshaller != NULL); g_return_if_fail (!n_params || param_types); norm_name = g_strdelimit (g_strdup (name), "_", '-'); meths = g_type_get_qdata (ptype, MOO_PLUGIN_METHS_QUARK); if (meths) { if (g_hash_table_lookup (meths, norm_name) != NULL) { g_warning ("method '%s' is already registered for type '%s'", name, g_type_name (ptype)); g_free (norm_name); return; } } else { meths = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) meth_free); g_type_set_qdata (ptype, MOO_PLUGIN_METHS_QUARK, meths); } m = g_new0 (MooPluginMeth, 1); m->ptype = ptype; m->return_type = return_type; m->n_params = n_params; m->param_types = n_params ? g_memdup (param_types, n_params * sizeof (GType)) : NULL; m->closure = g_closure_ref (closure); g_closure_sink (closure); g_closure_set_marshal (closure, c_marshaller); g_hash_table_insert (meths, norm_name, m); }
gulong connect_to_signal(void* obj, gchar* name, gint64 id) { gint64 *pgint64 = (gint64*)malloc(sizeof(gint64)); *pgint64 = id; GClosure* c = g_cclosure_new_swap(G_CALLBACK(func_handler), (gpointer)pgint64, destroy_id); g_closure_set_marshal(c, simple_go_marshal); gulong handler_id = g_signal_connect_closure((gpointer)obj, name, c, TRUE); return handler_id; }
void panel_lockdown_notify_add (GCallback callback_func, gpointer user_data) { GClosure *closure; g_assert (panel_lockdown_notify_find (panel_lockdown.closures, callback_func, user_data) == NULL); closure = g_cclosure_new (callback_func, user_data, NULL); g_closure_set_marshal (closure, marshal_user_data); panel_lockdown.closures = g_slist_append (panel_lockdown.closures, closure); }
static inline GClosure* mgtk_closure_new(gpointer callback_id) { GClosure *closure; /* printf("register id = %i\n",(int) callback_id); */ closure = g_closure_new_simple(sizeof(GClosure), callback_id); g_closure_set_marshal (closure, mgtk_callback_dispatch); g_closure_add_finalize_notifier (closure, callback_id, mgtk_callback_destroy); return closure; }
void er_dtls_connection_set_send_callback(ErDtlsConnection *self, GClosure *closure) { g_return_if_fail(ER_IS_DTLS_CONNECTION(self)); LOG_TRACE(self, "locking @ set_send_callback"); g_mutex_lock(&self->priv->mutex); LOG_TRACE(self, "locked @ set_send_callback"); self->priv->send_closure = closure; if (closure && G_CLOSURE_NEEDS_MARSHAL(closure)) { g_closure_set_marshal(closure, g_cclosure_marshal_generic); } LOG_TRACE(self, "unlocking @ set_send_callback"); g_mutex_unlock(&self->priv->mutex); }