static void nice_output_stream_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NiceOutputStream *self = NICE_OUTPUT_STREAM (object); switch (prop_id) { case PROP_AGENT: { /* Construct only. */ NiceAgent *agent = g_value_dup_object (value); g_weak_ref_set (&self->priv->agent_ref, agent); /* agent may be NULL if the stream is being constructed by * nice_io_stream_get_output_stream() after the NiceIOStream’s agent has * already been finalised. */ if (agent != NULL) { g_signal_connect (agent, "streams-removed", (GCallback) streams_removed_cb, self); g_object_unref (agent); } break; } case PROP_STREAM_ID: /* Construct only. */ self->priv->stream_id = g_value_get_uint (value); break; case PROP_COMPONENT_ID: /* Construct only. */ self->priv->component_id = g_value_get_uint (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } }
/** * gda_pstmt_set_gda_statement: * @pstmt: a #GdaPStmt object * @stmt: (allow-none): a #GdaStatement object, or %NULL * * Informs @pstmt that it corresponds to the preparation of the @stmt statement */ void gda_pstmt_set_gda_statement (GdaPStmt *pstmt, GdaStatement *stmt) { g_return_if_fail (GDA_IS_PSTMT (pstmt)); g_return_if_fail (!stmt || GDA_IS_STATEMENT (stmt)); g_rec_mutex_lock (& pstmt->priv->mutex); GdaStatement *estmt; estmt = g_weak_ref_get (& pstmt->priv->gda_stmt_ref); if (estmt == stmt) { if (estmt) g_object_unref (estmt); g_rec_mutex_unlock (& pstmt->priv->mutex); return; } gda_stmt_reset_cb (NULL, pstmt); if (stmt) { g_object_ref (stmt); g_weak_ref_set (& pstmt->priv->gda_stmt_ref, stmt); g_signal_connect (G_OBJECT (stmt), "reset", G_CALLBACK (gda_stmt_reset_cb), pstmt); } g_rec_mutex_unlock (& pstmt->priv->mutex); }
/** * gst_gl_context_create: * @context: a #GstGLContext: * @other_context: (allow-none): a #GstGLContext to share OpenGL objects with * @error: (allow-none): a #GError * * Creates an OpenGL context in the current thread with the specified * @other_context as a context to share shareable OpenGL objects with. See the * OpenGL specification for what is shared between contexts. * * If an error occurs, and @error is not %NULL, then error will contain details * of the error and %FALSE will be returned. * * Should only be called once. * * Returns: whether the context could successfully be created * * Since: 1.4 */ gboolean gst_gl_context_create (GstGLContext * context, GstGLContext * other_context, GError ** error) { gboolean alive = FALSE; g_return_val_if_fail (GST_GL_IS_CONTEXT (context), FALSE); g_return_val_if_fail (!GST_GL_IS_WRAPPED_CONTEXT (context), FALSE); GST_DEBUG_OBJECT (context, " other_context:%" GST_PTR_FORMAT, other_context); _ensure_window (context); g_mutex_lock (&context->priv->render_lock); if (!context->priv->created) { g_weak_ref_set (&context->priv->other_context_ref, other_context); context->priv->error = error; context->priv->gl_thread = g_thread_new ("gstglcontext", (GThreadFunc) gst_gl_context_create_thread, context); g_cond_wait (&context->priv->create_cond, &context->priv->render_lock); context->priv->created = TRUE; GST_INFO_OBJECT (context, "gl thread created"); } alive = context->priv->alive; g_mutex_unlock (&context->priv->render_lock); return alive; }
/** * gst_gl_context_set_window: * @context: a #GstGLContext * @window: (transfer full): a #GstGLWindow * * Set's the current window on @context to @window. The window can only be * changed before gst_gl_context_create() has been called and the @window is not * already running. * * Returns: Whether the window was successfully updated * * Since: 1.4 */ gboolean gst_gl_context_set_window (GstGLContext * context, GstGLWindow * window) { g_return_val_if_fail (!GST_IS_GL_WRAPPED_CONTEXT (context), FALSE); GST_DEBUG_OBJECT (context, "window:%" GST_PTR_FORMAT, window); /* we can't change the window while we are running */ if (context->priv->alive) return FALSE; if (window) { if (gst_gl_window_is_running (window)) return FALSE; g_weak_ref_set (&window->context_ref, context); } if (context->window) gst_object_unref (context->window); context->window = window ? gst_object_ref (window) : NULL; return TRUE; }
static void stdout_closure_free (StdoutClosure *closure) { g_weak_ref_set (&closure->sysroot, NULL); g_clear_object (&closure->real_stdout); g_clear_object (&closure->data_stream); g_slice_free (StdoutClosure, closure); }
static gboolean sysroot_setup_stdout_redirect (RpmostreedSysroot *self, GError **error) { g_autoptr(GInputStream) stream = NULL; g_autoptr(GSource) source = NULL; StdoutClosure *closure; gint pipefd[2]; gboolean ret = FALSE; /* XXX libostree logs messages to systemd's journal and also to stdout. * Redirect our own stdout back to ourselves so we can capture those * messages and pass them on to clients. Admittedly hokey but avoids * hacking libostree directly (for now). */ closure = g_slice_new0 (StdoutClosure); g_weak_ref_set (&closure->sysroot, self); /* Save the real stdout before overwriting its file descriptor. */ closure->real_stdout = g_unix_output_stream_new (dup (STDOUT_FILENO), FALSE); if (pipe (pipefd) < 0) { glnx_set_prefix_error_from_errno (error, "%s", "pipe() failed"); goto out; } if (dup2 (pipefd[1], STDOUT_FILENO) < 0) { glnx_set_prefix_error_from_errno (error, "%s", "dup2() failed"); goto out; } stream = g_memory_input_stream_new (); closure->data_stream = g_data_input_stream_new (stream); g_clear_object (&stream); stream = g_unix_input_stream_new (pipefd[0], FALSE); source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (stream), NULL); /* Transfer ownership of the StdoutClosure. */ g_source_set_callback (source, (GSourceFunc) sysroot_stdout_ready_cb, closure, (GDestroyNotify) stdout_closure_free); closure = NULL; self->stdout_source_id = g_source_attach (source, NULL); ret = TRUE; out: if (closure != NULL) stdout_closure_free (closure); return ret; }
static void gimp_operation_tool_create_gui (GimpOperationTool *op_tool) { GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (op_tool); GtkWidget *options_gui; gint off_x, off_y; GeglRectangle area; gint aux; gimp_filter_tool_get_drawable_area (filter_tool, &off_x, &off_y, &area); options_gui = gimp_prop_gui_new (G_OBJECT (filter_tool->config), G_TYPE_FROM_INSTANCE (filter_tool->config), 0, &area, GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (op_tool)), (GimpCreatePickerFunc) gimp_filter_tool_add_color_picker, (GimpCreateControllerFunc) gimp_filter_tool_add_controller, filter_tool); g_weak_ref_set (&op_tool->options_gui_ref, options_gui); for (aux = 1; ; aux++) { gchar pad[32]; gchar label[32]; if (aux == 1) { g_snprintf (pad, sizeof (pad), "aux"); /* don't translate "Aux" */ g_snprintf (label, sizeof (label), _("Aux Input")); } else { g_snprintf (pad, sizeof (pad), "aux%d", aux); /* don't translate "Aux" */ g_snprintf (label, sizeof (label), _("Aux%d Input"), aux); } if (gegl_node_has_pad (filter_tool->operation, pad)) { AuxInput *input; input = gimp_operation_tool_aux_input_new (op_tool, filter_tool->operation, pad, label); op_tool->aux_inputs = g_list_append (op_tool->aux_inputs, input); } else { break; } } }
GdaWebPStmt * gda_web_pstmt_new (GdaConnection *cnc, const gchar *pstmt_hash) { GdaWebPStmt *pstmt; g_return_val_if_fail (pstmt_hash && *pstmt_hash, NULL); pstmt = (GdaWebPStmt *) g_object_new (GDA_TYPE_WEB_PSTMT, NULL); GdaWebPStmtPrivate *priv = gda_web_pstmt_get_instance_private (pstmt); g_weak_ref_set (&priv->cnc, cnc); priv->pstmt_hash = g_strdup (pstmt_hash); return pstmt; }
GdaPostgresPStmt * gda_postgres_pstmt_new (GdaConnection *cnc, PGconn *pconn, const gchar *prep_name) { GdaPostgresPStmt *pstmt; pstmt = (GdaPostgresPStmt *) g_object_new (GDA_TYPE_POSTGRES_PSTMT, NULL); GdaPostgresPStmtPrivate *priv = gda_postgres_pstmt_get_instance_private (pstmt); priv->prep_name = g_strdup (prep_name); g_weak_ref_set (&priv->cnc, cnc); // FIXME: PGconn should be get from the GdaConnection priv->pconn = pconn; return pstmt; }
static void gimp_operation_tool_dialog (GimpFilterTool *filter_tool) { GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (filter_tool); GtkWidget *main_vbox; GtkWidget *options_sw; GtkWidget *options_gui; GtkWidget *options_box; main_vbox = gimp_filter_tool_dialog_get_vbox (filter_tool); /* The options scrolled window */ options_sw = gtk_scrolled_window_new (NULL, NULL); g_weak_ref_set (&op_tool->options_sw_ref, options_sw); gtk_scrolled_window_set_overlay_scrolling (GTK_SCROLLED_WINDOW (options_sw), FALSE); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (options_sw), GTK_SHADOW_NONE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (options_sw), GTK_POLICY_NEVER, GTK_POLICY_NEVER); gtk_box_pack_start (GTK_BOX (main_vbox), options_sw, TRUE, TRUE, 0); gtk_widget_show (options_sw); /* The options vbox */ options_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); g_weak_ref_set (&op_tool->options_box_ref, options_box); gtk_container_add (GTK_CONTAINER (options_sw), options_box); gtk_widget_show (options_box); options_gui = g_weak_ref_get (&op_tool->options_gui_ref); if (options_gui) { gimp_operation_tool_add_gui (op_tool); g_object_unref (options_gui); } }
static void mega_filesystem_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { MegaFilesystem* filesystem = MEGA_FILESYSTEM(object); MegaFilesystemPrivate* priv = filesystem->priv; switch (property_id) { case PROP_SESSION: g_weak_ref_set(&priv->session, g_value_get_object(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } }
/* * @stmt may be %NULL */ static void gda_stmt_reset_cb (GdaStatement *stmt, GdaPStmt *pstmt) { GdaPStmtPrivate *priv = gda_pstmt_get_instance_private (pstmt); g_rec_mutex_lock (& priv->mutex); if (stmt) { g_object_ref (stmt); g_signal_handlers_disconnect_by_func (G_OBJECT (stmt), G_CALLBACK (gda_stmt_reset_cb), pstmt); g_object_unref (stmt); } else { GdaStatement *stm = g_weak_ref_get (& priv->gda_stmt_ref); if (stm) { g_signal_handlers_disconnect_by_func (G_OBJECT (stm), G_CALLBACK (gda_stmt_reset_cb), pstmt); g_object_unref (stm); } } g_weak_ref_set (& priv->gda_stmt_ref, NULL); g_rec_mutex_unlock (& priv->mutex); }
/* * Do clean-up and notifications in the main thread */ static bool worker_post(gpointer _wj) { WorkerJob* wj = _wj; QueueItem* job = wj->job; WfWorker* w = wj->worker; if(!job->cancelled){ Waveform* waveform = g_weak_ref_get(&job->ref); call(job->done, waveform, NULL, job->user_data); if(waveform) g_object_unref(waveform); } if(job->free && job->user_data){ job->free(job->user_data); job->user_data = NULL; } w->jobs = g_list_remove(w->jobs, job); g_weak_ref_set(&job->ref, NULL); g_free(job); g_free(wj); return G_SOURCE_REMOVE; }
static void yahoo_backend_child_added (ECollectionBackend *backend, ESource *child_source) { EYahooBackend *yahoo_backend; ESource *collection_source; const gchar *extension_name; gboolean is_mail = FALSE; /* Chain up to parent's child_added() method. */ E_COLLECTION_BACKEND_CLASS (e_yahoo_backend_parent_class)-> child_added (backend, child_source); yahoo_backend = E_YAHOO_BACKEND (backend); collection_source = e_backend_get_source (E_BACKEND (backend)); extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT; is_mail |= e_source_has_extension (child_source, extension_name); /* Take special note of the mail identity source. * We need it to build the calendar CalDAV path. */ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY; if (e_source_has_extension (child_source, extension_name)) { GWeakRef *weak_ref; weak_ref = &yahoo_backend->mail_identity_source; g_weak_ref_set (weak_ref, child_source); is_mail = TRUE; } extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT; is_mail |= e_source_has_extension (child_source, extension_name); /* Synchronize mail-related user with the collection identity. */ extension_name = E_SOURCE_EXTENSION_AUTHENTICATION; if (is_mail && e_source_has_extension (child_source, extension_name)) { ESourceAuthentication *auth_child_extension; ESourceCollection *collection_extension; const gchar *collection_identity; const gchar *auth_child_user; extension_name = E_SOURCE_EXTENSION_COLLECTION; collection_extension = e_source_get_extension ( collection_source, extension_name); collection_identity = e_source_collection_get_identity ( collection_extension); extension_name = E_SOURCE_EXTENSION_AUTHENTICATION; auth_child_extension = e_source_get_extension ( child_source, extension_name); auth_child_user = e_source_authentication_get_user ( auth_child_extension); /* XXX Do not override an existing user name setting. * The IMAP or (especially) SMTP configuration may * have been modified to use a non-Yahoo! server. */ if (auth_child_user == NULL) e_source_authentication_set_user ( auth_child_extension, collection_identity); } }
GdaBlobOp * _gda_sqlite_blob_op_new (GdaConnection *cnc, const gchar *db_name, const gchar *table_name, const gchar *column_name, sqlite3_int64 rowid) { GdaSqliteBlobOp *bop = NULL; int rc; sqlite3_blob *sblob; gchar *db, *table; gboolean free_strings = TRUE; gboolean transaction_started = FALSE; g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL); g_return_val_if_fail (table_name, NULL); g_return_val_if_fail (column_name, NULL); g_return_val_if_fail (GDA_IS_SQLITE_PROVIDER (gda_connection_get_provider (cnc)), NULL); GdaSqliteBlobOpPrivate *priv = gda_sqlite_blob_op_get_instance_private (bop); if (db_name) { db = (gchar *) db_name; table = (gchar *) table_name; free_strings = FALSE; } else if (! _split_identifier_string (g_strdup (table_name), &db, &table)) return NULL; SqliteConnectionData *cdata; cdata = (SqliteConnectionData*) gda_connection_internal_get_provider_data_error (cnc, NULL); if (!cdata || ! _gda_sqlite_check_transaction_started (cnc, &transaction_started, NULL)) return NULL; GdaSqliteProvider *prov = GDA_SQLITE_PROVIDER (gda_connection_get_provider (cnc)); rc = SQLITE3_CALL (prov, sqlite3_blob_open) (cdata->connection, db ? db : "main", table, column_name, rowid, 1, /* Read & Write */ &(sblob)); if (rc != SQLITE_OK) { #ifdef GDA_DEBUG_NO g_print ("ERROR: %s\n", SQLITE3_CALL (prov, sqlite3_errmsg) (cdata->connection)); #endif if (transaction_started) gda_connection_rollback_transaction (cnc, NULL, NULL); goto out; } bop = g_object_new (GDA_TYPE_SQLITE_BLOB_OP, "connection", cnc, NULL); priv->sblob = sblob; g_weak_ref_set (&priv->provider, prov); #ifdef GDA_DEBUG_NO g_print ("OPENED blob %p\n", bop); #endif out: if (free_strings) { g_free (db); g_free (table); } return (GdaBlobOp*) bop; }
void gtk_gst_base_widget_set_element (GtkGstBaseWidget * widget, GstElement * element) { g_weak_ref_set (&widget->element, element); }