static void gimp_text_style_editor_update (GimpTextStyleEditor *editor) { if (editor->update_idle_id) g_source_remove (editor->update_idle_id); editor->update_idle_id = gdk_threads_add_idle ((GSourceFunc) gimp_text_style_editor_update_idle, editor); }
JNIEXPORT void JNICALL Java_org_GNOME_Accessibility_AtkWrapper_windowStateChange(JNIEnv *jniEnv, jclass jClass, jobject jAccContext) { jobject global_ac = (*jniEnv)->NewGlobalRef(jniEnv, jAccContext); CallbackPara *para = alloc_callback_para(global_ac); gdk_threads_add_idle(window_state_change_handler, para); }
static void gail_combo_selection_changed_gtk (GtkWidget *widget, gpointer data) { GtkCombo *combo; GtkList *list; GList *slist; AtkObject *obj; GailCombo *gail_combo; combo = GTK_COMBO (data); list = GTK_LIST (combo->list); slist = list->selection; obj = gtk_widget_get_accessible (GTK_WIDGET (data)); gail_combo = GAIL_COMBO (obj); if (slist && slist->data) { if (slist->data != gail_combo->old_selection) { gail_combo->old_selection = slist->data; if (gail_combo->select_idle_handler == 0) gail_combo->select_idle_handler = gdk_threads_add_idle (notify_select, gail_combo); } if (gail_combo->deselect_idle_handler) { g_source_remove (gail_combo->deselect_idle_handler); gail_combo->deselect_idle_handler = 0; } } else { if (gail_combo->deselect_idle_handler == 0) gail_combo->deselect_idle_handler = gdk_threads_add_idle (notify_deselect, gail_combo); if (gail_combo->select_idle_handler) { g_source_remove (gail_combo->select_idle_handler); gail_combo->select_idle_handler = 0; } } }
static void refresh_list (GeditDocumentsPanel *panel) { /* refresh in an idle so that when adding/removing many tabs * the model is repopulated just once */ if (panel->priv->refresh_idle_id == 0) { panel->priv->refresh_idle_id = gdk_threads_add_idle ((GSourceFunc) refresh_list_idle, panel); } }
JNIEXPORT void JNICALL Java_org_GNOME_Accessibility_AtkWrapper_windowClose(JNIEnv *jniEnv, jclass jClass, jobject jAccContext, jboolean jIsToplevel) { jobject global_ac = (*jniEnv)->NewGlobalRef(jniEnv, jAccContext); CallbackPara *para = alloc_callback_para(global_ac); para->is_toplevel = (jIsToplevel == JNI_TRUE) ? TRUE : FALSE; gdk_threads_add_idle(window_close_handler, para); }
void uiQueueMain(void (*f)(void *data), void *data) { struct queued *q; // we have to use g_new0()/g_free() because uiAlloc() is only safe to call on the main thread // for some reason it didn't affect me, but it did affect krakjoe q = g_new0(struct queued, 1); q->f = f; q->data = data; gdk_threads_add_idle(doqueued, q); }
/** * glk_exit: * * If you want to shut down your program in the middle of your `glk_main()` * function, you can call glk_exit(). * * This function does not return. * * If you print some text to a window and then shut down your program, you can * assume that the player will be able to read it. Most likely the Glk library * will give a “`Hit any key to exit`” prompt. * (There are other possiblities, however. * A terminal-window version of Glk might simply exit and leave the last screen * state visible in the terminal window.) * * <note><para> * You should only shut down your program with glk_exit() or by returning from * your <function>glk_main()</function> function. If you call the ANSI * <function>exit()</function> function, bad things may happen. Some versions of * the Glk library may be designed for multiple sessions, for example, and you * would be cutting off all the sessions instead of just yours. You would * probably also prevent final text from being visible to the player. * </para></note> * * > # Chimara # * > If there are any windows open at the time glk_exit() is called, then * > Chimara will leave them open. * > This way, the final text remains visible. * > Note that bad things most definitely <emphasis>will</emphasis> happen if * > you use the ANSI `exit()`. */ void glk_exit(void) { ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); shutdown_glk_pre(); /* Find the biggest text buffer window */ winid_t win, largewin = NULL; glui32 largearea = 0; for(win = glk_window_iterate(NULL, NULL); win; win = glk_window_iterate(win, NULL)) { if(win->type == wintype_TextBuffer) { glui32 w, h; if(!largewin) { largewin = win; glk_window_get_size(largewin, &w, &h); largearea = w * h; } else { glk_window_get_size(win, &w, &h); if(w * h > largearea) { largewin = win; largearea = w * h; } } } } if(largewin) { glk_set_window(largewin); glk_set_style(style_Alert); glk_put_string("\n"); glk_put_string(glk_data->final_message); glk_put_string("\n"); flush_window_buffer(largewin); } /* Wait for a keypress if any text grid or buffer windows are open */ gboolean should_wait = FALSE; g_mutex_lock(&glk_data->shutdown_lock); for(win = glk_window_iterate(NULL, NULL); win; win = glk_window_iterate(win, NULL)) { if(win->type == wintype_TextGrid || win->type == wintype_TextBuffer) { g_signal_handler_unblock(win->widget, win->shutdown_keypress_handler); should_wait = TRUE; } } if (should_wait) g_cond_wait(&glk_data->shutdown_key_pressed, &glk_data->shutdown_lock); g_mutex_unlock(&glk_data->shutdown_lock); shutdown_glk_post(); gdk_threads_add_idle((GSourceFunc)emit_stopped_signal, glk_data->self); g_thread_exit(NULL); }
/* Send keyboard accelerators to the parent window, if necessary. * This code is heavily based on gtk_menu_key_press () */ static gboolean hildon_app_menu_key_press (GtkWidget *widget, GdkEventKey *event) { GtkWindow *parent_window; HildonAppMenuPrivate *priv; g_return_val_if_fail (HILDON_IS_APP_MENU (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); if (GTK_WIDGET_CLASS (hildon_app_menu_parent_class)->key_press_event (widget, event)) return TRUE; priv = HILDON_APP_MENU_GET_PRIVATE (widget); parent_window = priv->parent_window; if (parent_window) { guint accel_key, accel_mods; GdkModifierType consumed_modifiers; GdkDisplay *display; GSList *accel_groups; GSList *list; display = gtk_widget_get_display (widget); /* Figure out what modifiers went into determining the key symbol */ gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (display), event->hardware_keycode, event->state, event->group, NULL, NULL, NULL, &consumed_modifiers); accel_key = gdk_keyval_to_lower (event->keyval); accel_mods = event->state & gtk_accelerator_get_default_mod_mask () & ~consumed_modifiers; /* If lowercasing affects the keysym, then we need to include SHIFT in the modifiers, * We re-upper case when we match against the keyval, but display and save in caseless form. */ if (accel_key != event->keyval) accel_mods |= GDK_SHIFT_MASK; accel_groups = gtk_accel_groups_from_object (G_OBJECT (parent_window)); for (list = accel_groups; list; list = list->next) { GtkAccelGroup *accel_group = list->data; if (gtk_accel_group_query (accel_group, accel_key, accel_mods, NULL)) { gtk_window_activate_key (parent_window, event); priv->hide_idle_id = gdk_threads_add_idle (hildon_app_menu_hide_idle, widget); break; } } } return TRUE; }
guint gtr_idle_add( GSourceFunc function, gpointer data ) { #if GTK_CHECK_VERSION( 2,12,0 ) return gdk_threads_add_idle( function, data ); #else return g_idle_add_full( G_PRIORITY_DEFAULT, gtr_thread_func, gtr_func_data_new( function, data ), gtr_func_data_free ); #endif }
static void gth_media_viewer_page_real_view (GthViewerPage *base, GthFileData *file_data) { GthMediaViewerPage *self; char *uri; self = (GthMediaViewerPage*) base; g_return_if_fail (file_data != NULL); if (! gstreamer_init ()) return; gth_viewer_page_focus (GTH_VIEWER_PAGE (self)); if ((self->priv->file_data != NULL) && g_file_equal (file_data->file, self->priv->file_data->file) && (gth_file_data_get_mtime (file_data) == gth_file_data_get_mtime (self->priv->file_data))) { return; } /**/ _g_object_unref (self->priv->file_data); self->priv->file_data = gth_file_data_dup (file_data); self->priv->duration = 0; _g_object_unref (self->priv->icon); self->priv->icon = NULL; _gth_media_viewer_page_update_caption (self); /**/ gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), TRUE); g_signal_handlers_block_by_func(GET_WIDGET ("adjustment_position"), position_value_changed_cb, self); gtk_adjustment_set_value (GTK_ADJUSTMENT (GET_WIDGET ("adjustment_position")), 0.0); g_signal_handlers_unblock_by_func(GET_WIDGET ("adjustment_position"), position_value_changed_cb, self); reset_player_state (self); if (self->priv->playbin == NULL) return; gst_element_set_state (self->priv->playbin, GST_STATE_NULL); uri = g_file_get_uri (self->priv->file_data->file); g_object_set (G_OBJECT (self->priv->playbin), "uri", uri, NULL); gdk_threads_add_idle (set_to_paused, self); g_free (uri); }
/* Record the host after connection is established*/ static void host_added(int ihost, int sock){ htime[ihost]=myclockd(); proc_remove_all(ihost);/*remove all entries. */ LOCK(mhost); nhostup++; hsock[ihost]=sock; FD_SET(sock, &active_fd_set); UNLOCK(mhost); add_host_wrap(-1);//wakes up listen_host(). info("connected to %s\n", hosts[ihost]); gdk_threads_add_idle(host_up, GINT_TO_POINTER(ihost)); }
/** * Draw specified layer */ void vik_layer_emit_update ( VikLayer *vl ) { if ( vl->visible && vl->realized ) { vik_window_set_redraw_trigger(vl); // Only ever draw when there is time to do so if ( g_thread_self() != vik_window_get_thread (VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(vl))) ) // Drawing requested from another (background) thread, so handle via the gdk thread method gdk_threads_add_idle ( (GSourceFunc) idle_draw, vl ); else g_idle_add ( (GSourceFunc) idle_draw, vl ); } }
/*remove the host upon disconnection*/ static void host_removed(int sock){ int ihost=host_from_sock(sock); if(ihost==-1) return; close(sock); LOCK(mhost); nhostup--; hsock[ihost]=-1; FD_CLR(sock, &active_fd_set); UNLOCK(mhost); add_host_wrap(-1); gdk_threads_add_idle(host_down, GINT_TO_POINTER(ihost)); info("disconnected from %s\n", hosts[ihost]); }
AtkObject* gail_notebook_page_new (GtkNotebook *notebook, gint pagenum) { GObject *object; AtkObject *atk_object; GailNotebookPage *page; GtkWidget *child; GtkWidget *label; GList *list; g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL); child = gtk_notebook_get_nth_page (notebook, pagenum); if (!child) return NULL; object = g_object_new (GAIL_TYPE_NOTEBOOK_PAGE, NULL); g_return_val_if_fail (object != NULL, NULL); page = GAIL_NOTEBOOK_PAGE (object); page->notebook = notebook; g_object_add_weak_pointer (G_OBJECT (page->notebook), (gpointer *)&page->notebook); page->index = pagenum; list = g_list_nth (notebook->children, pagenum); page->page = list->data; page->textutil = NULL; atk_object = ATK_OBJECT (page); atk_object->role = ATK_ROLE_PAGE_TAB; atk_object->layer = ATK_LAYER_WIDGET; page->notify_child_added_id = gdk_threads_add_idle (notify_child_added, atk_object); /* * We get notified of changes to the label */ label = get_label_from_notebook_page (page); if (GTK_IS_LABEL (label)) { if (gtk_widget_get_mapped (label)) gail_notebook_page_init_textutil (page, label); else g_signal_connect (label, "map", G_CALLBACK (gail_notebook_page_label_map_gtk), page); } return atk_object; }
JNIEXPORT void JNICALL Java_org_GNOME_Accessibility_AtkWrapper_emitSignal(JNIEnv *jniEnv, jclass jClass, jobject jAccContext, jint id, jobjectArray args) { jobject global_ac = (*jniEnv)->NewGlobalRef(jniEnv, jAccContext); jobjectArray global_args = (jobjectArray)(*jniEnv)->NewGlobalRef(jniEnv, args); CallbackPara *para = alloc_callback_para(global_ac); para->signal_id = (gint)id; para->args = global_args; gdk_threads_add_idle(signal_emit_handler, para); }
static void gtk_model_menu_binding_items_changed (GMenuModel *model, gint position, gint removed, gint added, gpointer user_data) { GtkModelMenuBinding *binding = user_data; if (binding->update_idle == 0) { binding->update_idle = gdk_threads_add_idle (gtk_model_menu_binding_handle_changes, user_data); g_object_ref (binding->shell); } }
static PROC_T *proc_add(int id,int pid){ PROC_T *iproc; if((iproc=proc_get(id,pid))) return iproc; iproc=mycalloc(1,PROC_T); iproc->iseed_old=-1; iproc->pid=pid; iproc->hid=id; LOCK(mhost); iproc->next=pproc[id]; pproc[id]=iproc; nproc[id]++; gdk_threads_add_idle((GSourceFunc)update_title, GINT_TO_POINTER(id)); UNLOCK(mhost); return iproc; }
static gboolean OnFocusInFS(GtkWidget *widget, GdkEvent *event, gpointer user_data) { Application.Active = true; if (Application.FullScreenMode()) { fullscreen_needs_restore = true; gdk_threads_add_idle(fullscreen_restore, NULL); } C4Window *window = (C4Window*) user_data; if (window->mouse_was_grabbed) gdk_threads_add_timeout(50, grab_mouse_fn, widget); // Reset urgency hint (does nothing if unset) assert(widget == window->window && "OnFocusInFS callback used for something other than the main window."); gtk_window_set_urgency_hint(GTK_WINDOW(window->window), false); return false; }
static void hd_bookmark_widgets_bookmark_files_changed (GnomeVFSMonitorHandle *handle, const gchar *monitor_uri, const gchar *info_uri, GnomeVFSMonitorEventType event_type, gpointer user_data) { HDBookmarkWidgets *widgets = HD_BOOKMARK_WIDGETS (user_data); HDBookmarkWidgetsPrivate *priv = widgets->priv; g_debug ("%s. Type: %u", __FUNCTION__, event_type); if (!priv->parse_idle_id) priv->parse_idle_id = gdk_threads_add_idle ((GSourceFunc) hd_bookmark_widgets_parse_bookmark_files, user_data); }
guint cc_common_language_add_available_languages (GtkListStore *store, gboolean regions, GHashTable *user_langs) { AsyncLangData *data; data = g_new0 (AsyncLangData, 1); data->store = g_object_ref (store); data->user_langs = g_hash_table_ref (user_langs); data->languages = gdm_get_all_language_names (); data->regions = regions; data->position = 0; return gdk_threads_add_idle (add_one_language, data); }
JNIEXPORT void JNICALL Java_org_GNOME_Accessibility_AtkWrapper_objectStateChange(JNIEnv *jniEnv, jclass jClass, jobject jAccContext, jobject state, jboolean value) { jobject global_ac = (*jniEnv)->NewGlobalRef(jniEnv, jAccContext); CallbackPara *para = alloc_callback_para(global_ac); AtkStateType state_type = jaw_util_get_atk_state_type_from_java_state( jniEnv, state ); para->atk_state = state_type; if (value == JNI_TRUE) { para->state_value = TRUE; } else { para->state_value = FALSE; } gdk_threads_add_idle(object_state_change_handler, para); }
int main(int argc, char **argv) { gtk_test_init(&argc, &argv); hash_init(); resources_register_resource(); gui_init(); list_init(); // Ignore user input during testing gtk_widget_set_sensitive(GTK_WIDGET(gui.window), false); gdk_threads_add_idle((GSourceFunc)test_run, NULL); gui_run(); g_assert_not_reached(); return EXIT_FAILURE; }
static void send_batch (SearchThreadData *data) { SearchHits *hits; data->n_processed_files = 0; if (data->uri_hits) { hits = g_new (SearchHits, 1); hits->uris = data->uri_hits; hits->thread_data = data; gdk_threads_add_idle (search_thread_add_hits_idle, hits); } data->uri_hits = NULL; }
static gboolean gail_notebook_focus_cb (GtkWidget *widget, GtkDirectionType type) { AtkObject *atk_obj = gtk_widget_get_accessible (widget); GailNotebook *gail_notebook = GAIL_NOTEBOOK (atk_obj); switch (type) { case GTK_DIR_LEFT: case GTK_DIR_RIGHT: if (gail_notebook->idle_focus_id == 0) gail_notebook->idle_focus_id = gdk_threads_add_idle (gail_notebook_check_focus_tab, atk_obj); break; default: break; } return FALSE; }
static void latest_version_thread ( GtkWindow *window ) { // Need to allow a few redirects, as SF file is often served from different server DownloadMapOptions options = { FALSE, FALSE, NULL, 5, NULL, NULL, NULL }; gchar *filename = a_download_uri_to_tmp_file ( "http://sourceforge.net/projects/viking/files/VERSION", &options ); //gchar *filename = g_strdup ( "VERSION" ); if ( !filename ) { return; } GMappedFile *mf = g_mapped_file_new ( filename, FALSE, NULL ); if ( !mf ) return; gchar *text = g_mapped_file_get_contents ( mf ); gint latest_version = viking_version_to_number ( text ); gint my_version = viking_version_to_number ( VIKING_VERSION ); g_debug ( "The lastest version is: %s", text ); if ( my_version < latest_version ) { new_version_thread_data *nvtd = g_malloc ( sizeof(new_version_thread_data) ); nvtd->window = window; nvtd->version = g_strdup ( text ); gdk_threads_add_idle ( (GSourceFunc) new_version_available_message, nvtd ); } else g_debug ( "Running the lastest version: %s", VIKING_VERSION ); g_mapped_file_unref ( mf ); if ( filename ) { g_remove ( filename ); g_free ( filename ); } // Update last checked time GTimeVal time; g_get_current_time ( &time ); a_settings_set_string ( VIK_SETTINGS_VERSION_CHECKED_DATE, g_time_val_to_iso8601(&time) ); }
int viewport_update_panes(char *consumer, char *buffer, char *producer) { char namebuf[32]; int bufId; for (bufId = 0; bufId < 3; bufId++) { sprintf_s(namebuf, sizeof(namebuf), "textbuffer%d", (bufId + 1)); buffers[bufId] = (GtkTextBuffer *)gtk_builder_get_object(builder, namebuf); } data = g_new0(struct DispatchData, 1); data->output_str_c = consumer; data->output_str_b = buffer; data->output_str_p = producer; data->buffer0 = buffers[0]; data->buffer1 = buffers[1]; data->buffer2 = buffers[2]; printf("calling update\n"); gdk_threads_add_idle(display_status_textbuffer, data); return 0; }
/** * gtk_timeline_start: * @timeline: A #GtkTimeline * * Runs the timeline from the current frame. **/ void _gtk_timeline_start (GtkTimeline *timeline) { GtkTimelinePriv *priv; GtkSettings *settings; gboolean enable_animations = FALSE; g_return_if_fail (GTK_IS_TIMELINE (timeline)); priv = timeline->priv; if (!priv->source_id) { if (priv->timer) g_timer_continue (priv->timer); else priv->timer = g_timer_new (); /* sanity check */ g_assert (priv->fps > 0); if (priv->screen) { settings = gtk_settings_get_for_screen (priv->screen); g_object_get (settings, "gtk-enable-animations", &enable_animations, NULL); } priv->animations_enabled = enable_animations; g_signal_emit (timeline, signals [STARTED], 0); if (enable_animations) priv->source_id = gdk_threads_add_timeout (FRAME_INTERVAL (priv->fps), (GSourceFunc) gtk_timeline_run_frame, timeline); else priv->source_id = gdk_threads_add_idle ((GSourceFunc) gtk_timeline_run_frame, timeline); } }
static gboolean gtk_icon_view_item_accessible_do_action (AtkAction *action, gint i) { GtkIconViewItemAccessible *item; if (i != 0) return FALSE; item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (action); if (!GTK_IS_ICON_VIEW (item->widget)) return FALSE; if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) return FALSE; if (!item->action_idle_handler) item->action_idle_handler = gdk_threads_add_idle (idle_do_action, item); return TRUE; }
static void *url_worker(void *arg){ url_data *data = arg; buf_data *bdata = malloc(sizeof(buf_data)); bdata->offset = 0; bdata->size = 0; bdata->buf = NULL; bdata->postData = data->postData; data->data = bdata; if(data->httpType == CURL_HTTP_GET){ //printf("%s\n", data->url); data->npcode = get_url(data->url, bdata, g_hash_table_lookup(g_FRManager.hash_table, data->instance)); }else{ data->npcode = post_url(data->url, bdata, g_hash_table_lookup(g_FRManager.hash_table, data->instance)); } //TODO gdk_threads_add_idle(stream_write, arg); return NULL; }
static void process_dnd_source_mouse_release(GdkWindow *window, GdkEventButton *event) { glass_gdk_master_pointer_ungrab(); if (GLASS_GDK_DRAG_CONTEXT_GET_SELECTED_ACTION(get_drag_context())) { gdk_drag_drop(get_drag_context(), GDK_CURRENT_TIME); } else { gdk_drag_abort(get_drag_context(), GDK_CURRENT_TIME); /* let the gdk_drag_abort messages handled before finish */ gdk_threads_add_idle((GSourceFunc) dnd_finish_callback, NULL); } }