예제 #1
0
static void
bus_watch_name_free_func (gpointer user_data)
{
  WatchNameData *data = user_data;

  if (data->name_appeared_closure != NULL)
    g_closure_unref (data->name_appeared_closure);

  if (data->name_vanished_closure != NULL)
    g_closure_unref (data->name_vanished_closure);

  g_free (data);
}
예제 #2
0
static void
bind_with_closures_free_func (gpointer data)
{
  TransformData *t_data = data;

  if (t_data->transform_to_closure != NULL)
    g_closure_unref (t_data->transform_to_closure);

  if (t_data->transform_from_closure != NULL)
    g_closure_unref (t_data->transform_from_closure);

  g_slice_free (TransformData, t_data);
}
예제 #3
0
void _owr_session_clear_closures(OwrSession *session)
{
    if (session->priv->on_remote_candidate) {
        g_closure_invalidate(session->priv->on_remote_candidate);
        g_closure_unref(session->priv->on_remote_candidate);
        session->priv->on_remote_candidate = NULL;
    }
    if (session->priv->on_local_candidate_change) {
        g_closure_invalidate(session->priv->on_local_candidate_change);
        g_closure_unref(session->priv->on_local_candidate_change);
        session->priv->on_local_candidate_change = NULL;
    }
}
예제 #4
0
파일: variable.c 프로젝트: barnowl/barnowl
void owl_variable_delete(owl_variable *v)
{
  g_free(v->name);
  g_free(v->summary);
  g_free(v->description);
  g_free(v->default_str);
  g_free(v->validsettings);
  if (v->type != OWL_VARIABLE_OTHER)
    g_value_unset(&(v->val));
  g_closure_unref(v->get_tostring_fn);
  g_closure_unref(v->set_fromstring_fn);

  g_slice_free(owl_variable, v);
}
예제 #5
0
static void
thunar_uca_provider_child_watch_destroy (gpointer  user_data,
                                         GClosure *closure)
{
  ThunarUcaProvider *uca_provider = THUNAR_UCA_PROVIDER (user_data);
  GClosure          *child_watch;

  /* leave if the closure is not the one we're watching */
  if (uca_provider->child_watch == closure
      || closure == NULL)
    {
      /* reset child watch and path */
      if (G_UNLIKELY (uca_provider->child_watch != NULL))
        {
          child_watch = uca_provider->child_watch;
          uca_provider->child_watch = NULL;

          g_closure_invalidate (child_watch);
          g_closure_unref (child_watch);
        }

      g_free (uca_provider->child_watch_path);
      uca_provider->child_watch_path = NULL;
    }
}
예제 #6
0
void PasteboardHelper::writeClipboardContents(GtkClipboard* clipboard, SmartPasteInclusion includeSmartPaste, GClosure* callback)
{
    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
    GtkTargetList* list = targetListForDataObject(dataObject, includeSmartPaste);

    int numberOfTargets;
    GtkTargetEntry* table = gtk_target_table_new_from_list(list, &numberOfTargets);

    if (numberOfTargets > 0 && table) {
        settingClipboardDataObject = dataObject;

        if (gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, getClipboardContentsCallback, clearClipboardContentsCallback, callback ? g_closure_ref(callback) : nullptr))
            gtk_clipboard_set_can_store(clipboard, nullptr, 0);
        else {
            // When gtk_clipboard_set_with_data fails the callbacks are ignored, so we need to release the reference we were passing to clearClipboardContentsCallback.
            if (callback)
                g_closure_unref(callback);
        }

        settingClipboardDataObject = nullptr;

    } else
        gtk_clipboard_clear(clipboard);

    if (table)
        gtk_target_table_free(table, numberOfTargets);
    gtk_target_list_unref(list);
}
예제 #7
0
static void
bus_own_name_free_func (gpointer user_data)
{
  OwnNameData *data = user_data;

  if (data->bus_acquired_closure != NULL)
    g_closure_unref (data->bus_acquired_closure);

  if (data->name_acquired_closure != NULL)
    g_closure_unref (data->name_acquired_closure);

  if (data->name_lost_closure != NULL)
    g_closure_unref (data->name_lost_closure);

  g_free (data);
}
예제 #8
0
/**
 * clutter_alpha_set_func:
 * @alpha: A #ClutterAlpha
 * @func: A #ClutterAlphaFunc
 * @data: user data to be passed to the alpha function, or %NULL
 * @destroy: notify function used when disposing the alpha function
 *
 * Sets the #ClutterAlphaFunc function used to compute
 * the alpha value at each frame of the #ClutterTimeline
 * bound to @alpha.
 *
 * This function will not register @func as a global alpha function.
 *
 * Since: 0.2
 *
 * Deprecated: 1.12
 */
void
clutter_alpha_set_func (ClutterAlpha    *alpha,
		        ClutterAlphaFunc func,
                        gpointer         data,
                        GDestroyNotify   destroy)
{
  ClutterAlphaPrivate *priv;

  g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
  g_return_if_fail (func != NULL);

  priv = alpha->priv;

  if (priv->notify != NULL)
    {
      priv->notify (priv->user_data);
    }
  else if (priv->closure != NULL)
    {
      g_closure_unref (priv->closure);
      priv->closure = NULL;
    }

  priv->func = func;
  priv->user_data = data;
  priv->notify = destroy;

  priv->mode = CLUTTER_CUSTOM_MODE;

  g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_MODE]);
}
예제 #9
0
/*
 * 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);
    }
}
예제 #10
0
파일: mooplugin.c 프로젝트: cmotc/medit
void
moo_plugin_method_new (const char     *name,
                       GType           ptype,
                       GCallback       method,
                       GClosureMarshal c_marshaller,
                       GType           return_type,
                       guint           n_params,
                       ...)
{
    va_list args;
    GClosure *closure;

    g_return_if_fail (g_type_is_a (ptype, MOO_TYPE_PLUGIN));
    g_return_if_fail (name != NULL);
    g_return_if_fail (method != NULL);
    g_return_if_fail (c_marshaller != NULL);

    closure = g_cclosure_new (method, NULL, NULL);
    g_closure_sink (g_closure_ref (closure));

    va_start (args, n_params);
    moo_plugin_method_new_valist (name, ptype, closure, c_marshaller,
                                  return_type, n_params, args);
    va_end (args);

    g_closure_unref (closure);
}
예제 #11
0
static void
carbon_menu_item_update_accel_closure (CarbonMenuItem *carbon_item,
				       GtkWidget      *widget)
{
  GtkAccelGroup *group;
  GtkWidget     *label;

  get_menu_label_text (widget, &label);

  if (carbon_item->accel_closure)
    {
      group = gtk_accel_group_from_accel_closure (carbon_item->accel_closure);

      g_signal_handlers_disconnect_by_func (group,
					    carbon_menu_item_accel_changed,
					    widget);

      g_closure_unref (carbon_item->accel_closure);
      carbon_item->accel_closure = NULL;
    }

  if (GTK_IS_ACCEL_LABEL (label))
    g_object_get (label, "accel-closure", &carbon_item->accel_closure, NULL);

  if (carbon_item->accel_closure)
    {
      group = gtk_accel_group_from_accel_closure (carbon_item->accel_closure);

      g_signal_connect_object (group, "accel-changed",
			       G_CALLBACK (carbon_menu_item_accel_changed),
			       widget, 0);
    }

  carbon_menu_item_update_accelerator (carbon_item, widget);
}
예제 #12
0
static void
carbon_menu_item_accel_changed (GtkAccelGroup   *accel_group,
				guint            keyval,
				GdkModifierType  modifier,
				GClosure        *accel_closure,
				GtkWidget       *widget)
{
  CarbonMenuItem *carbon_item = carbon_menu_item_get (widget);
  GtkWidget      *label;

  get_menu_label_text (widget, &label);

  if (GTK_IS_ACCEL_LABEL (label))
    {
      GClosure *closure;

      g_object_get (label, "accel-closure", &closure, NULL);

      if (closure)
	{
	  if (closure == accel_closure)
	    carbon_menu_item_update_accelerator (carbon_item, widget);

	  g_closure_unref (closure);
	}
    }
}
예제 #13
0
void dt_accel_rename_global(const gchar *path,const gchar *new_path)
{
  dt_accel_t *accel;
  GSList * l = darktable.control->accelerator_list;
  char build_path[1024];
  dt_accel_path_global(build_path, 1024,path);
  while(l)
  {
    accel = (dt_accel_t*)l->data;
    if(!strncmp(accel->path, build_path, 1024))
    {
      GtkAccelKey tmp_key = *(gtk_accel_group_find(darktable.control->accelerators,find_accel_internal,accel->closure));
      dt_accel_deregister_global(path);
      g_closure_ref(accel->closure);
      dt_accel_register_global(new_path,tmp_key.accel_key,tmp_key.accel_mods);
      dt_accel_connect_global(new_path,accel->closure);
      g_closure_unref(accel->closure);
      l = NULL;
    }
    else
    {
      l = g_slist_next(l);
    }
  }
}
예제 #14
0
파일: closure.cpp 프로젝트: smspillaz/gjs
static void
global_context_finalized(JSObject *obj,
                         void     *data)
{
    Closure *c;
    gboolean need_unref;

    c = (Closure *) data;

    gjs_debug_closure("Context global object destroy notifier on closure %p "
                      "which calls object %p",
                      c, c->obj);

    /* invalidate_js_pointers() could free us so check flag now to avoid
     * invalid memory access
     */
    need_unref = c->unref_on_global_object_finalized;
    c->unref_on_global_object_finalized = FALSE;

    if (c->obj != NULL) {
        g_assert(c->obj == obj);

        invalidate_js_pointers(c);
    }

    if (need_unref) {
        g_closure_unref(&c->base);
    }
}
예제 #15
0
void
panel_lockdown_finalize (void)
{
        GSList *l;

        g_assert (panel_lockdown.initialized != FALSE);

        if (panel_lockdown.disabled_applets) {
                g_strfreev (panel_lockdown.disabled_applets);
                panel_lockdown.disabled_applets = NULL;
        }

        if (panel_lockdown.panel_settings) {
                g_object_unref (panel_lockdown.panel_settings);
                panel_lockdown.panel_settings = NULL;
        }
        if (panel_lockdown.lockdown_settings) {
                g_object_unref (panel_lockdown.lockdown_settings);
                panel_lockdown.lockdown_settings = NULL;
        }

        for (l = panel_lockdown.closures; l; l = l->next)
                g_closure_unref (l->data);
        g_slist_free (panel_lockdown.closures);
        panel_lockdown.closures = NULL;

        panel_lockdown.initialized = FALSE;
}
예제 #16
0
static void
carbon_menu_item_free (CarbonMenuItem *menu_item)
{
  if (menu_item->accel_closure)
    g_closure_unref (menu_item->accel_closure);

  g_slice_free (CarbonMenuItem, menu_item);
}
예제 #17
0
static void
rb_plugin_install_context_free (RBPluginInstallContext *ctx)
{
	rb_debug ("cleaning up plugin install context %p", ctx);
	g_strfreev (ctx->details);
	g_closure_unref (ctx->closure);
	g_free (ctx);
}
예제 #18
0
/**
 * 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;
}
예제 #19
0
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);
}
예제 #20
0
/**
 * _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);
}
예제 #21
0
파일: mainloop.c 프로젝트: sjokkis/gjs
static void
closure_destroy_notify(void *data)
{
    GClosure *closure;

    closure = data;

    g_closure_invalidate(closure);
    g_closure_unref(closure);
}
예제 #22
0
파일: mooplugin.c 프로젝트: cmotc/medit
static void
meth_free (MooPluginMeth *meth)
{
    if (meth)
    {
        g_free (meth->param_types);
        g_closure_invalidate (meth->closure);
        g_closure_unref (meth->closure);
        g_free (meth);
    }
}
예제 #23
0
static void
test_closure (GClosure *closure)
{
  /* try to produce high contention in closure->ref_count */
  guint i = 0, n = quick_rand32() % 199;
  for (i = 0; i < n; i++)
    g_closure_ref (closure);
  g_closure_sink (closure); /* NOP */
  for (i = 0; i < n; i++)
    g_closure_unref (closure);
}
예제 #24
0
/**
 * pka_subscription_destroy:
 * @subscription: A #PkaSubscription.
 *
 * Destroy handler when the reference count has reached zero.
 *
 * Returns: None.
 * Side effects: Armageddon.
 */
static void
pka_subscription_destroy (PkaSubscription *subscription) /* IN */
{
	g_return_if_fail(subscription != NULL);

	ENTRY;
	g_tree_unref(subscription->channels);
	g_tree_unref(subscription->sources);
	g_tree_unref(subscription->manifests);
	if (subscription->manifest_closure) {
		g_closure_unref(subscription->manifest_closure);
	}
	if (subscription->sample_closure) {
		g_closure_unref(subscription->sample_closure);
	}
	if (subscription->encoder) {
		g_object_unref(subscription->encoder);
	}
	EXIT;
}
예제 #25
0
void _owr_data_channel_clear_closures(OwrDataChannel *data_channel)
{
    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 = NULL;
    }
    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 = NULL;
    }

    if (priv->on_datachannel_close) {
        g_closure_invalidate(priv->on_datachannel_close);
        g_closure_unref(priv->on_datachannel_close);
        priv->on_datachannel_close = NULL;
    }
}
예제 #26
0
static void
binding_entry_free (gpointer data)
{
  if (G_LIKELY (data))
    {
      ClutterBindingEntry *entry = data;

      g_closure_unref (entry->closure);

      g_slice_free (ClutterBindingEntry, entry);
    }
}
static void
matecomponent_listener_destroy (MateComponentObject *object)
{
	MateComponentListener *listener = (MateComponentListener *) object;

	if (listener->priv->event_callback) {
		g_closure_unref (listener->priv->event_callback);
		listener->priv->event_callback = NULL;
	}
	
	((MateComponentObjectClass *)matecomponent_listener_parent_class)->destroy (object);
}
예제 #28
0
static gboolean
verb_destroy (gpointer dummy, UIVerb *verb, gpointer dummy2)
{
	if (verb) {
		if (verb->closure)
			g_closure_unref (verb->closure);
		verb->closure = NULL;
		g_free (verb->cname);
		g_free (verb);
	}
	return TRUE;
}
예제 #29
0
static void
bonobo_listener_destroy (BonoboObject *object)
{
	BonoboListener *listener = (BonoboListener *) object;

	if (listener->priv->event_callback) {
		g_closure_unref (listener->priv->event_callback);
		listener->priv->event_callback = NULL;
	}
	
	((BonoboObjectClass *)bonobo_listener_parent_class)->destroy (object);
}
예제 #30
0
static gboolean
listener_destroy (gpointer dummy, UIListener *l, gpointer dummy2)
{
	if (l) {
		if (l->closure)
			g_closure_unref (l->closure);
		l->closure = NULL;
		g_free (l->id);
		g_free (l);
	}
	return TRUE;
}