gchar * germinal_terminal_get_url (GerminalTerminal *self, GdkEventButton *button_event) { GerminalTerminalPrivate *priv = germinal_terminal_get_instance_private (self); if (button_event) /* only access to cached url if no button_event available */ { g_clear_pointer (&priv->url, g_free); /* free previous url */ gint tag; /* avoid stupid vte segv (said to be optional) */ priv->url = vte_terminal_match_check_event (VTE_TERMINAL (self), (GdkEvent *) button_event, &tag); } return priv->url; }
static void gtk_source_map_destroy (GtkWidget *widget) { GtkSourceMap *map = GTK_SOURCE_MAP (widget); GtkSourceMapPrivate *priv; priv = gtk_source_map_get_instance_private (map); disconnect_buffer (map); disconnect_view (map); g_clear_object (&priv->css_provider); g_clear_pointer (&priv->font_desc, pango_font_description_free); GTK_WIDGET_CLASS (gtk_source_map_parent_class)->destroy (widget); }
static GtkTreeIter * photos_organize_collection_model_find_collection_iter (PhotosOrganizeCollectionModel *self, PhotosBaseItem *collection) { gtk_tree_model_foreach (GTK_TREE_MODEL (self), photos_organize_collection_model_foreach, collection); if (self->coll_path != NULL) { GtkTreeIter iter; gtk_tree_model_get_iter (GTK_TREE_MODEL (self), &iter, self->coll_path); g_clear_pointer (&self->coll_path, (GDestroyNotify) gtk_tree_path_free); return gtk_tree_iter_copy (&iter); } return NULL; }
/** * gsk_renderer_unrealize: * @renderer: a #GskRenderer * * Releases all the resources created by gsk_renderer_realize(). */ void gsk_renderer_unrealize (GskRenderer *renderer) { GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer); g_return_if_fail (GSK_IS_RENDERER (renderer)); if (!priv->is_realized) return; GSK_RENDERER_GET_CLASS (renderer)->unrealize (renderer); g_clear_pointer (&priv->prev_node, gsk_render_node_unref); priv->is_realized = FALSE; }
void gcal_time_selector_set_time (GcalTimeSelector *selector, GDateTime *time) { g_return_if_fail (GCAL_IS_TIME_SELECTOR (selector)); if (selector->time != time) { gint hour, minute; g_clear_pointer (&selector->time, g_date_time_unref); selector->time = g_date_time_new_local (g_date_time_get_year (time), g_date_time_get_month (time), g_date_time_get_day_of_month (time), g_date_time_get_hour (time), g_date_time_get_minute (time), 0); /* Update the spinners */ g_signal_handlers_block_by_func (selector->hour_adjustment, update_time, selector); g_signal_handlers_block_by_func (selector->minute_adjustment, update_time, selector); hour = g_date_time_get_hour (time); minute = g_date_time_get_minute (time); if (!selector->format_24h) { g_signal_handlers_block_by_func (selector->period_combo, update_time, selector); gtk_combo_box_set_active (GTK_COMBO_BOX (selector->period_combo), hour >= 12); hour = hour % 12; hour = (hour == 0)? 12 : hour; g_signal_handlers_unblock_by_func (selector->period_combo, update_time, selector); } gtk_adjustment_set_value (selector->hour_adjustment, hour); gtk_adjustment_set_value (selector->minute_adjustment, minute); update_label (selector); g_signal_handlers_unblock_by_func (selector->hour_adjustment, update_time, selector); g_signal_handlers_unblock_by_func (selector->minute_adjustment, update_time, selector); g_object_notify (G_OBJECT (selector), "time"); } }
bool ImGui_ImplGtk3Cogl_CreateFontsTexture() { // Build texture atlas ImGuiIO& io = ImGui::GetIO(); unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. g_clear_pointer(&io.Fonts->TexID, cogl_object_unref); io.Fonts->TexID = cogl_texture_2d_new_from_data(g_Context, width, height, COGL_PIXEL_FORMAT_RGBA_8888, width * 4, pixels, NULL); return true; }
static void tear_down_mock_xdg_runtime_dir (void) { GError *error = NULL; g_socket_close (mock_bus, &error); g_assert_no_error (error); if (g_unlink (mock_bus_path) < 0) g_error ("g_unlink(\"%s\"): %s", mock_bus_path, g_strerror (errno)); if (g_rmdir (tmpdir) < 0) g_error ("g_rmdir(\"%s\"): %s", tmpdir, g_strerror (errno)); g_clear_object (&mock_bus); g_clear_pointer (&mock_bus_path, g_free); }
static void filter_changed (GtkEntry *entry, CcLanguageChooser *chooser) { CcLanguageChooserPrivate *priv = chooser->priv; gchar *filter_contents = NULL; g_clear_pointer (&priv->filter_words, g_strfreev); filter_contents = cc_util_normalize_casefold_and_unaccent (gtk_entry_get_text (GTK_ENTRY (priv->filter_entry))); if (!filter_contents) return; priv->filter_words = g_strsplit_set (g_strstrip (filter_contents), " ", 0); g_free (filter_contents); gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->language_list)); }
void meta_cursor_sprite_set_texture (MetaCursorSprite *sprite, CoglTexture *texture, int hot_x, int hot_y) { MetaCursorSpritePrivate *priv = meta_cursor_sprite_get_instance_private (sprite); g_clear_pointer (&priv->texture, cogl_object_unref); if (texture) priv->texture = cogl_object_ref (texture); priv->hot_x = hot_x; priv->hot_y = hot_y; g_signal_emit (sprite, signals[TEXTURE_CHANGED], 0); }
static gboolean io_unpause_internal (gpointer msg) { SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); SoupMessageIOData *io = priv->io_data; g_return_val_if_fail (io != NULL, FALSE); g_clear_pointer (&io->unpause_source, g_source_unref); io->paused = FALSE; if (io->io_source) return FALSE; io_run (msg, FALSE); return FALSE; }
static void gssdp_resource_browser_finalize (GObject *object) { GSSDPResourceBrowser *resource_browser; GSSDPResourceBrowserPrivate *priv; resource_browser = GSSDP_RESOURCE_BROWSER (object); priv = gssdp_resource_browser_get_instance_private (resource_browser); g_clear_pointer (&priv->target_regex, g_regex_unref); g_free (priv->target); g_hash_table_destroy (priv->resources); G_OBJECT_CLASS (gssdp_resource_browser_parent_class)->finalize (object); }
static gboolean query_completed_cb (GcalShellSearchProvider *search_provider, GcalManager *manager) { GcalShellSearchProviderPrivate *priv = search_provider->priv; GList *events, *l; GVariantBuilder builder; time_t current_time_t; g_hash_table_remove_all (priv->events); events = gcal_manager_get_shell_search_events (priv->manager); if (events == NULL) { g_dbus_method_invocation_return_value (priv->pending_search->invocation, g_variant_new ("(as)", NULL)); goto out; } g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); current_time_t = time (NULL); events = g_list_sort_with_data (events, (GCompareDataFunc) sort_event_data, ¤t_time_t); for (l = events; l != NULL; l = g_list_next (l)) { const gchar *uid; uid = gcal_event_get_uid (l->data); if (g_hash_table_contains (priv->events, uid)) continue; g_variant_builder_add (&builder, "s", uid); g_hash_table_insert (priv->events, g_strdup (uid), l->data); } g_list_free (events); g_dbus_method_invocation_return_value (priv->pending_search->invocation, g_variant_new ("(as)", &builder)); out: g_object_unref (priv->pending_search->invocation); g_strfreev (priv->pending_search->terms); g_clear_pointer (&(priv->pending_search), g_free); g_application_release (g_application_get_default ()); return FALSE; }
static void dispose (GObject *object) { CEPageIP4 *self = CE_PAGE_IP4 (object); CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self); int i; g_clear_object (&priv->window_group); /* Mark CEPageIP4 object as invalid; store this indication to cells to be usable in callbacks */ for (i = 0; i <= COL_LAST; i++) g_object_set_data (G_OBJECT (priv->addr_cells[i]), "ce-page-not-valid", GUINT_TO_POINTER (1)); g_clear_pointer (&priv->connection_id, g_free); G_OBJECT_CLASS (ce_page_ip4_parent_class)->dispose (object); }
void csd_ldsm_clean (void) { if (ldsm_timeout_id) { g_source_remove (ldsm_timeout_id); ldsm_timeout_id = 0; } g_clear_pointer (&ldsm_notified_hash, g_hash_table_destroy); g_clear_object (&ldsm_monitor); g_clear_object (&settings); g_clear_object (&dialog); if (notification != NULL) notify_notification_close (notification, NULL); g_slist_free_full (ignore_paths, g_free); ignore_paths = NULL; }
static void _egg_counter_arena_destroy (EggCounterArena *arena) { g_assert (arena != NULL); if (arena->data_is_mmapped) munmap (arena->cells, arena->data_length); else g_free (arena->cells); g_clear_pointer (&arena->counters, g_list_free); arena->cells = NULL; if (arena->arena_is_malloced) g_free (arena); }
static gboolean dispatch_close (OstreeRepo *repo, StaticDeltaExecutionState *state, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; if (state->content_out) { if (!g_output_stream_flush (state->content_out, cancellable, error)) goto out; if (state->trusted) { if (!_ostree_repo_commit_trusted_content_bare (repo, state->checksum, &state->barecommitstate, state->uid, state->gid, state->mode, state->xattrs, cancellable, error)) goto out; } else { if (!_ostree_repo_commit_untrusted_content_bare (repo, state->checksum, &state->barecommitstate, state->uid, state->gid, state->mode, state->xattrs, cancellable, error)) goto out; } } if (!dispatch_unset_read_source (repo, state, cancellable, error)) goto out; g_clear_pointer (&state->xattrs, g_variant_unref); g_clear_object (&state->content_out); state->checksum_index++; state->output_target = NULL; ret = TRUE; out: if (!ret) g_prefix_error (error, "opcode open-splice-and-close: "); return ret; }
static void ide_doap_finalize (GObject *object) { IdeDoap *self = (IdeDoap *)object; g_clear_pointer (&self->bug_database, g_free); g_clear_pointer (&self->category, g_free); g_clear_pointer (&self->description, g_free); g_clear_pointer (&self->download_page, g_free); g_clear_pointer (&self->homepage, g_free); g_clear_pointer (&self->languages, g_ptr_array_unref); g_clear_pointer (&self->name, g_free); g_clear_pointer (&self->shortdesc, g_free); g_list_free_full (self->maintainers, g_object_unref); self->maintainers = NULL; G_OBJECT_CLASS (ide_doap_parent_class)->finalize (object); }
char * gnome_settings_get_chassis_type (void) { char *ret = NULL; GError *error = NULL; GVariant *inner; GVariant *variant = NULL; GDBusConnection *connection; connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (connection == NULL) { g_warning ("system bus not available: %s", error->message); g_error_free (error); goto out; } variant = g_dbus_connection_call_sync (connection, "org.freedesktop.hostname1", "/org/freedesktop/hostname1", "org.freedesktop.DBus.Properties", "Get", g_variant_new ("(ss)", "org.freedesktop.hostname1", "Chassis"), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (variant == NULL) { g_debug ("Failed to get property '%s': %s", "Chassis", error->message); g_error_free (error); goto out; } g_variant_get (variant, "(v)", &inner); ret = g_variant_dup_string (inner, NULL); g_variant_unref (inner); out: g_clear_object (&connection); g_clear_pointer (&variant, g_variant_unref); return ret; }
static void ide_line_change_gutter_renderer_begin (GtkSourceGutterRenderer *renderer, cairo_t *cr, GdkRectangle *bg_area, GdkRectangle *cell_area, GtkTextIter *begin, GtkTextIter *end) { IdeLineChangeGutterRenderer *self = (IdeLineChangeGutterRenderer *)renderer; IdeBufferChangeMonitor *monitor; GtkTextBuffer *buffer; GtkTextView *view; struct { GArray *lines; guint begin_line; guint end_line; } state; g_assert (IDE_IS_LINE_CHANGE_GUTTER_RENDERER (self)); g_assert (cr != NULL); g_assert (bg_area != NULL); g_assert (cell_area != NULL); g_assert (begin != NULL); g_assert (end != NULL); if (!(view = gtk_source_gutter_renderer_get_view (renderer)) || !(buffer = gtk_text_view_get_buffer (view)) || !IDE_IS_BUFFER (buffer) || !(monitor = ide_buffer_get_change_monitor (IDE_BUFFER (buffer)))) return; self->begin_line = state.begin_line = gtk_text_iter_get_line (begin); state.end_line = gtk_text_iter_get_line (end); state.lines = g_array_new (FALSE, TRUE, sizeof (LineInfo)); g_array_set_size (state.lines, state.end_line - state.begin_line + 1); ide_buffer_change_monitor_foreach_change (monitor, state.begin_line, state.end_line, populate_changes_cb, &state); g_clear_pointer (&self->lines, g_array_unref); self->lines = g_steal_pointer (&state.lines); }
/** * gsk_renderer_render_texture: * @renderer: a realized #GdkRenderer * @root: a #GskRenderNode * @viewport: (allow-none): the section to draw or %NULL to use @root's bounds * * Renders the scene graph, described by a tree of #GskRenderNode instances, * to a #GdkTexture. * * The @renderer will acquire a reference on the #GskRenderNode tree while * the rendering is in progress. * * If you want to apply any transformations to @root, you should put it into a * transform node and pass that node instead. * * Returns: (transfer full): a #GdkTexture with the rendered contents of @root. */ GdkTexture * gsk_renderer_render_texture (GskRenderer *renderer, GskRenderNode *root, const graphene_rect_t *viewport) { GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer); graphene_rect_t real_viewport; GdkTexture *texture; g_return_val_if_fail (GSK_IS_RENDERER (renderer), NULL); g_return_val_if_fail (priv->is_realized, NULL); g_return_val_if_fail (GSK_IS_RENDER_NODE (root), NULL); g_return_val_if_fail (priv->root_node == NULL, NULL); priv->root_node = gsk_render_node_ref (root); if (viewport == NULL) { gsk_render_node_get_bounds (root, &real_viewport); viewport = &real_viewport; } texture = GSK_RENDERER_GET_CLASS (renderer)->render_texture (renderer, root, viewport); #ifdef G_ENABLE_DEBUG if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER)) { GString *buf = g_string_new ("*** Texture stats ***\n\n"); gsk_profiler_append_counters (priv->profiler, buf); g_string_append_c (buf, '\n'); gsk_profiler_append_timers (priv->profiler, buf); g_string_append_c (buf, '\n'); g_print ("%s\n***\n\n", buf->str); g_string_free (buf, TRUE); } #endif g_clear_pointer (&priv->root_node, gsk_render_node_unref); return texture; }
static void rg_graph_size_allocate (GtkWidget *widget, GtkAllocation *alloc) { RgGraph *self = (RgGraph *)widget; RgGraphPrivate *priv = rg_graph_get_instance_private (self); GtkAllocation old_alloc; g_assert (RG_IS_GRAPH (self)); g_assert (alloc != NULL); gtk_widget_get_allocation (widget, &old_alloc); if ((old_alloc.width != alloc->width) || (old_alloc.height != alloc->height)) g_clear_pointer (&priv->surface, cairo_surface_destroy); GTK_WIDGET_CLASS (rg_graph_parent_class)->size_allocate (widget, alloc); }
static void gtd_object_real_set_uid (GtdObject *object, const gchar *uid) { GtdObjectPrivate *priv; g_assert (GTD_IS_OBJECT (object)); priv = gtd_object_get_instance_private (object); if (g_strcmp0 (priv->uid, uid) == 0) return; g_clear_pointer (&priv->uid, g_free); priv->uid = g_strdup (uid); g_object_notify_by_pspec (G_OBJECT (object), properties[PROP_UID]); }
void free_config(RaucConfig *config) { g_return_if_fail(config); g_free(config->system_compatible); g_free(config->system_bootloader); g_free(config->mount_prefix); g_free(config->store_path); g_free(config->grubenv_path); g_free(config->statusfile_path); g_free(config->keyring_path); g_free(config->autoinstall_path); g_free(config->systeminfo_handler); g_free(config->preinstall_handler); g_free(config->postinstall_handler); g_clear_pointer(&config->slots, g_hash_table_destroy); g_free(config); }
gboolean meta_cursor_tracker_handle_xevent (MetaCursorTracker *tracker, XEvent *xevent) { XFixesCursorNotifyEvent *notify_event; if (xevent->xany.type != tracker->screen->display->xfixes_event_base + XFixesCursorNotify) return FALSE; notify_event = (XFixesCursorNotifyEvent *)xevent; if (notify_event->subtype != XFixesDisplayCursorNotify) return FALSE; g_clear_pointer (&tracker->sprite, cogl_object_unref); g_signal_emit (tracker, signals[CURSOR_CHANGED], 0); return TRUE; }
static void photos_item_manager_dispose (GObject *object) { PhotosItemManager *self = PHOTOS_ITEM_MANAGER (object); if (self->collection_path != NULL) { photos_item_manager_collection_path_free (self); self->collection_path = NULL; } g_clear_pointer (&self->collections, (GDestroyNotify) g_hash_table_unref); g_clear_object (&self->loader_cancellable); g_clear_object (&self->active_collection); g_clear_object (&self->monitor); G_OBJECT_CLASS (photos_item_manager_parent_class)->dispose (object); }
static void _device_cleanup (NMActiveConnection *self) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); if (priv->device) { g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_state_changed), self); g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_master_changed), self); g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_metered_changed), self); } if (priv->pending_activation_id) { nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE); g_clear_pointer (&priv->pending_activation_id, g_free); } g_clear_object (&priv->device); }
static void decorator_commit_cb (GObject *object, GAsyncResult *result, gpointer user_data) { TrackerSparqlConnection *conn; TrackerDecoratorPrivate *priv; TrackerDecorator *decorator; GError *error = NULL; GPtrArray *errors; guint i; decorator = user_data; priv = decorator->priv; conn = TRACKER_SPARQL_CONNECTION (object); errors = tracker_sparql_connection_update_array_finish (conn, result, &error); if (error) { g_warning ("There was an error pushing metadata: %s\n", error->message); } if (errors) { for (i = 0; i < errors->len; i++) { SparqlUpdate *update; GError *child_error; child_error = g_ptr_array_index (errors, i); update = &g_array_index (priv->commit_buffer, SparqlUpdate, i); if (!child_error) continue; decorator_blacklist_add (decorator, update->id); item_warn (conn, update->id, update->sparql, child_error); } g_ptr_array_unref (errors); } g_clear_pointer (&priv->commit_buffer, (GDestroyNotify) g_array_unref); if (!decorator_check_commit (decorator)) decorator_cache_next_items (decorator); }
static void on_create_and_connect (GtkButton *button, HotSshTab *self) { HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self); GError *local_error = NULL; GError **error = &local_error; GtkTreeIter iter; gs_unref_object GNetworkAddress *address = NULL; const char *hostname; gs_free char *stripped_hostname = NULL; const char *username; gs_free char *stripped_username = NULL; hostname = gtk_entry_get_text (GTK_ENTRY (priv->host_entry)); stripped_hostname = g_strstrip (g_strdup (hostname)); username = gtk_entry_get_text (GTK_ENTRY (priv->username_entry)); stripped_username = g_strstrip (g_strdup (username)); g_clear_object (&priv->cancellable); priv->cancellable = g_cancellable_new (); g_clear_object (&priv->address); address = (GNetworkAddress*)g_network_address_parse (stripped_hostname, 22, error); if (!address) { page_transition_take_error (self, local_error); return; } g_clear_pointer (&priv->connection_id, g_free); hotssh_hostdb_add_entry (hotssh_hostdb_get_instance (), stripped_username, (GNetworkAddress*)address, &priv->connection_id); hotssh_hostdb_lookup_by_id (hotssh_hostdb_get_instance (), priv->connection_id, &iter); /* gtk_tree_selection_select_iter (gtk_tree_view_get_selection ((GtkTreeView*)priv->connections_treeview), &iter); */ page_transition (self, HOTSSH_TAB_PAGE_LIST_CONNECTIONS); }
static void current_msg_got_body (SoupMessage *msg, gpointer user_data) { SoupConnection *conn = user_data; SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn); priv->unused_timeout = 0; if (priv->proxy_uri && msg->method == SOUP_METHOD_CONNECT && SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { soup_connection_event (conn, G_SOCKET_CLIENT_PROXY_NEGOTIATED, NULL); /* We're now effectively no longer proxying */ g_clear_pointer (&priv->proxy_uri, soup_uri_free); } priv->reusable = soup_message_is_keepalive (msg); }
void gt_twitch_chat_view_connect(GtTwitchChatView* self, const gchar* chan) { GtTwitchChatViewPrivate* priv = gt_twitch_chat_view_get_instance_private(self); priv->joined_channel = TRUE; g_clear_pointer(&priv->cur_chan, (GDestroyNotify) g_free); priv->cur_chan = g_strdup(chan); if (priv->chat_badges_cancel) g_cancellable_cancel(priv->chat_badges_cancel); g_clear_object(&priv->chat_badges_cancel); priv->chat_badges_cancel = g_cancellable_new(); gt_twitch_chat_badges_async(main_app->twitch, chan, priv->chat_badges_cancel, (GAsyncReadyCallback) chat_badges_cb, self); }