static void ide_fancy_tree_view_size_allocate (GtkWidget *widget, GtkAllocation *alloc) { IdeFancyTreeView *self = (IdeFancyTreeView *)widget; IdeFancyTreeViewPrivate *priv = ide_fancy_tree_view_get_instance_private (self); g_assert (IDE_IS_FANCY_TREE_VIEW (self)); GTK_WIDGET_CLASS (ide_fancy_tree_view_parent_class)->size_allocate (widget, alloc); if (priv->last_width != alloc->width) { /* * We must perform our queued relayout from an idle callback * so that we don't affect this draw cycle. If we do that, we * will get empty content flashes for the current frame. This * allows us to draw the current frame slightly incorrect but * fixup on the next frame (which looks much nicer from a user * point of view). */ if (priv->relayout_source == 0) priv->relayout_source = gdk_threads_add_idle_full (G_PRIORITY_HIGH, queue_relayout_in_idle, g_object_ref (self), g_object_unref); } }
/** * gdk_threads_add_idle: (skip) * @function: function to call * @data: data to pass to @function * * A wrapper for the common usage of gdk_threads_add_idle_full() * assigning the default priority, #G_PRIORITY_DEFAULT_IDLE. * * See gdk_threads_add_idle_full(). * * Returns: the ID (greater than 0) of the event source. * * Since: 2.12 */ guint gdk_threads_add_idle (GSourceFunc function, gpointer data) { return gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE, function, data, NULL); }
static gboolean gail_menu_item_do_action (AtkAction *action, gint i) { if (i == 0) { GtkWidget *item; GailMenuItem *gail_menu_item; item = GTK_ACCESSIBLE (action)->widget; if (item == NULL) /* State is defunct */ return FALSE; if (!gtk_widget_get_sensitive (item) || !gtk_widget_get_visible (item)) return FALSE; gail_menu_item = GAIL_MENU_ITEM (action); if (gail_menu_item->action_idle_handler) return FALSE; else { gail_menu_item->action_idle_handler = gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE, idle_do_action, g_object_ref (gail_menu_item), (GDestroyNotify) g_object_unref); } return TRUE; } else return FALSE; }
static void xfce_panel_image_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv; gtk_widget_set_allocation (widget, allocation); /* check if the available size changed */ if ((priv->pixbuf != NULL || priv->source != NULL) && allocation->width > 0 && allocation->height > 0 && (allocation->width != priv->width || allocation->height != priv->height)) { /* store the new size */ priv->width = allocation->width; priv->height = allocation->height; /* free cache */ xfce_panel_image_unref_null (priv->cache); if (priv->pixbuf == NULL) { /* delay icon loading */ priv->idle_load_id = gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE, xfce_panel_image_load, widget, xfce_panel_image_load_destroy); } else { /* directly render pixbufs */ xfce_panel_image_load (widget); } } }
static void ide_terminal_page_spawn_cb (GObject *object, GAsyncResult *result, gpointer user_data) { IdeTerminalLauncher *launcher = (IdeTerminalLauncher *)object; g_autoptr(IdeTerminalPage) self = user_data; g_autoptr(GError) error = NULL; gint64 now; g_assert (IDE_IS_TERMINAL_LAUNCHER (launcher)); g_assert (G_IS_ASYNC_RESULT (result)); g_assert (IDE_IS_TERMINAL_PAGE (self)); if (!ide_terminal_launcher_spawn_finish (launcher, result, &error)) { g_autofree gchar *format = NULL; format = g_strdup_printf ("%s: %s", _("Subprocess launcher failed"), error->message); ide_terminal_page_feed (self, format); } if (gtk_widget_in_destruction (GTK_WIDGET (self))) return; now = g_get_monotonic_time (); if (ABS (now - self->last_respawn) < FLAPPING_DURATION_USEC) { ide_terminal_page_feed (self, _("Subprocess launcher failed too quickly, will not respawn.")); return; } if (!self->respawn_on_exit) { if (self->close_on_exit) gdk_threads_add_idle_full (G_PRIORITY_LOW + 1000, (GSourceFunc) destroy_widget_in_idle, g_object_ref (self), g_object_unref); return; } g_clear_object (&self->pty); vte_terminal_reset (VTE_TERMINAL (self->terminal_top), TRUE, TRUE); self->pty = vte_pty_new_sync (VTE_PTY_DEFAULT, NULL, NULL); vte_terminal_set_pty (VTE_TERMINAL (self->terminal_top), self->pty); /* Spawn our terminal and wait for it to exit */ self->last_respawn = now; ide_terminal_launcher_spawn_async (self->launcher, self->pty, NULL, ide_terminal_page_spawn_cb, g_object_ref (self)); }
void byzanz_recorder_queue_snapshot (ByzanzRecorder *recorder) { g_return_if_fail (BYZANZ_IS_RECORDER (recorder)); if (recorder->next_image_source == 0) { recorder->next_image_source = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE, byzanz_recorder_next_image, recorder, NULL); } }
static void gtk_menu_section_box_schedule_separator_sync (GtkMenuSectionBox *box) { box = box->toplevel; if (!box->separator_sync_idle) box->separator_sync_idle = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE, /* before resize... */ gtk_menu_section_box_handle_sync_separators, box, NULL); }
static void ide_highlight_engine_queue_work (IdeHighlightEngine *self) { g_assert (IDE_IS_HIGHLIGHT_ENGINE (self)); if ((self->highlighter == NULL) || (self->buffer == NULL) || (self->work_timeout != 0)) return; self->work_timeout = gdk_threads_add_idle_full (G_PRIORITY_LOW, ide_highlight_engine_work_timeout_handler, self, NULL); }
void init_enumeration( FilebrowserBackend *filebackend) { FilebrowserBackendDetails *directory = FILEBROWSER_BACKEND_GET_PRIVATE(filebackend); if (g_cancellable_is_cancelled (directory->cancellable)) return ; /* remove source */ GFile *file = g_file_new_for_commandline_arg (directory->current_folder); GError *error=NULL; directory->enumerator = g_file_enumerate_children (file,FOLDER_INFOFLAGS,G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, directory->cancellable,&error); if (!directory->enumerator){ g_print(_("Error getting file browser files. GIO Error:%s\t"),error->message); g_error_free (error); filebrowser_backend_restore(filebackend); return ; } directory->idle_id = gdk_threads_add_idle_full (G_PRIORITY_DEFAULT, populate_files, filebackend, clean_enumerate); }
/** * gb_color_picker_document_monitor_queue_colorize: * @self: a #GbColorPickerDocumentMonitor * * This queues a region to be recolorized but does so after returning * to the main loop. This can be useful for situations where you do not * know if you are in a path that must retain a valid GtkTextIter. * * Since: 3.26 */ static void gb_color_picker_document_monitor_queue_oper (GbColorPickerDocumentMonitor *self, const GtkTextIter *begin, const GtkTextIter *end, gboolean uncolorize) { QueuedColorize queued = { 0 }; GtkTextBuffer *buffer; GtkTextIter real_begin; GtkTextIter real_end; g_return_if_fail (GB_IS_COLOR_PICKER_DOCUMENT_MONITOR (self)); g_return_if_fail (self->buffer != NULL); g_return_if_fail (begin == NULL || GTK_TEXT_BUFFER (self->buffer) == gtk_text_iter_get_buffer (begin)); g_return_if_fail (end == NULL || GTK_TEXT_BUFFER (self->buffer) == gtk_text_iter_get_buffer (end)); buffer = GTK_TEXT_BUFFER (self->buffer); gtk_text_buffer_get_bounds (buffer, &real_begin, &real_end); if (begin) real_begin = *begin; if (end) real_end = *end; queued.self = g_object_ref (self); queued.buffer = g_object_ref (buffer); queued.begin = g_object_ref (gtk_text_buffer_create_mark (buffer, NULL, &real_begin, TRUE)); queued.end = g_object_ref (gtk_text_buffer_create_mark (buffer, NULL, &real_end, FALSE)); queued.uncolorize = !!uncolorize; gdk_threads_add_idle_full (G_PRIORITY_LOW, gb_color_picker_document_monitor_queue_oper_cb, g_slice_dup (QueuedColorize, &queued), queued_colorize_free); }