static gboolean close_fftscope_window(GtkWidget * widget, GdkEvent * event, gpointer data) { GDK_THREADS_LEAVE(); stop_fftscope(); GDK_THREADS_ENTER(); return TRUE; }
static void nsp_app_feeds_search(void* user_data) { NspApp *app = nsp_app_get(); NspFeed *feed = nsp_feed_new(); GtkTreeIter iter; GRegex *regex; char *new_feed_title = "Search results"; char *search_exp; char *tmp; feed->title = malloc(sizeof(char)*(strlen(new_feed_title) + 1)); memcpy(feed->title, new_feed_title, sizeof(char)*(strlen(new_feed_title)+1)); /* Build search term and load results */ regex = g_regex_new ("(%|_)", 0, 0, NULL); tmp = g_regex_replace(regex, (char*)user_data, -1, 0, "\\\\\\0", 0, NULL); g_regex_unref(regex); regex = g_regex_new ("[ \t]+", 0, 0, NULL); search_exp = g_regex_replace(regex, tmp, -1, 0, "%", 0, NULL); g_regex_unref(regex); g_free(tmp); feed->items = nsp_feed_items_search(search_exp); /* Update front-end */ GDK_THREADS_ENTER(); nsp_feed_update_model(feed); gtk_tree_view_set_model(GTK_TREE_VIEW(app->window->feed_item_list), nsp_feed_get_items_model(feed)); GDK_THREADS_LEAVE(); GDK_THREADS_ENTER(); iter = nsp_feed_list_add(app->window->feed_list, feed, true); gtk_tree_store_set (GTK_TREE_STORE(app->window->feed_list->list_model), &iter, LIST_COL_ICON, app->window->feed_list->icon_search, -1); app->feeds = g_list_append(app->feeds, feed); gtk_tree_view_set_cursor(GTK_TREE_VIEW(app->window->feed_list->list_view), gtk_tree_model_get_path(app->window->feed_list->list_model, &iter), NULL, FALSE); GDK_THREADS_LEAVE(); }
static void on_stop_search( GtkWidget* btn, FindFile* data ) { if( data->task && ! vfs_async_task_is_finished( data->task ) ) { // see note in vfs-async-task.c: vfs_async_task_real_cancel() GDK_THREADS_LEAVE(); vfs_async_task_cancel( data->task ); GDK_THREADS_ENTER(); } }
static gboolean brasero_gio_operation_wait_for_operation_end (BraseroGioOperation *operation, GError **error) { BRASERO_MEDIA_LOG ("Waiting for end of async operation"); g_object_ref (operation->cancel); g_cancellable_reset (operation->cancel); g_signal_connect (operation->cancel, "cancelled", G_CALLBACK (brasero_gio_operation_cancelled), operation); /* put a timeout (30 sec) */ operation->timeout_id = g_timeout_add_seconds (20, brasero_gio_operation_timeout, operation); operation->loop = g_main_loop_new (NULL, FALSE); GDK_THREADS_LEAVE (); g_main_loop_run (operation->loop); GDK_THREADS_ENTER (); g_main_loop_unref (operation->loop); operation->loop = NULL; if (operation->timeout_id) { g_source_remove (operation->timeout_id); operation->timeout_id = 0; } if (operation->error) { BRASERO_MEDIA_LOG ("Medium operation finished with an error %s", operation->error->message); if (operation->error->code == G_IO_ERROR_FAILED_HANDLED) { BRASERO_MEDIA_LOG ("Error already handled and displayed by GIO"); /* means we shouldn't display any error message since * that was already done */ g_error_free (operation->error); operation->error = NULL; } else if (error && (*error) == NULL) g_propagate_error (error, operation->error); else g_error_free (operation->error); operation->error = NULL; } g_object_unref (operation->cancel); return operation->result; }
static void process_found_files( FindFile* data, GQueue* queue, const char* path ) { char *name; gsize len, term; GtkTreeIter it; VFSFileInfo* fi; GdkPixbuf* icon; FoundFile* ff; if( path ) { name = g_filename_display_basename( path ); fi = vfs_file_info_new(); if( vfs_file_info_get( fi, path, name ) ) { ff = g_slice_new0( FoundFile ); ff->fi = fi; ff->dir_path = g_path_get_dirname( path ); g_queue_push_tail( queue, ff ); } else { vfs_file_info_unref( fi ); } g_free( name ); /* we queue the found files, and not add them to the tree view direclty. * when we queued more than 10 files, we add them at once. I think * this can prevent locking gtk+ too frequently and improve responsiveness. * FIXME: This could blocked the last queued files and delay their display * to the end of the whole search. A better method is needed. */ //MOD disabled this - causes last queued files to not display // if( g_queue_get_length( queue ) < 10 ) // return; } while( ff = (FoundFile*)g_queue_pop_head(queue) ) { GDK_THREADS_ENTER(); gtk_list_store_append( data->result_list, &it ); icon = vfs_file_info_get_small_icon( ff->fi ); gtk_list_store_set( data->result_list, &it, COL_ICON, icon, COL_NAME, vfs_file_info_get_disp_name(ff->fi), COL_DIR, ff->dir_path, /* FIXME: non-UTF8? */ COL_TYPE, vfs_file_info_get_mime_type_desc( ff->fi ), COL_SIZE, vfs_file_info_get_disp_size( ff->fi ), COL_MTIME, vfs_file_info_get_disp_mtime( ff->fi ), COL_INFO, ff->fi, -1 ); g_object_unref( icon ); GDK_THREADS_LEAVE(); g_slice_free( FoundFile, ff ); } }
static void nsp_app_feed_add (void* user_data) { NspApp *app = nsp_app_get(); char *url = g_strdup((const char*) user_data); NspFeed *feed; GtkTreeIter iter; char *new_feed_title = "New Subscription"; /* Create the new feed, populate it and add it to the list */ feed = nsp_feed_new(); feed->url = url; feed->title = malloc(sizeof(char)*(strlen(new_feed_title) + 1)); memcpy(feed->title, new_feed_title, sizeof(char)*(strlen(new_feed_title)+1)); GDK_THREADS_ENTER(); iter = nsp_feed_list_add(app->window->feed_list, feed, false); gtk_tree_store_set (GTK_TREE_STORE(app->window->feed_list->list_model), &iter, LIST_COL_ICON, app->window->feed_list->icon_load, -1); GDK_THREADS_LEAVE(); /* Fetch and save the items */ if ( nsp_feed_update_items(feed) || nsp_feed_save_to_db(feed) ) { nsp_feed_list_remove(app->window->feed_list, feed); nsp_feed_free(feed); return; } app->feeds = g_list_append(app->feeds, feed); GDK_THREADS_ENTER(); nsp_feed_update_model(feed); nsp_feed_update_unread_count(feed); nsp_feed_list_update_entry(app->window->feed_list, feed); GDK_THREADS_LEAVE(); if ( !nsp_feed_update_icon(feed) ) { GDK_THREADS_ENTER(); nsp_feed_list_update_entry(app->window->feed_list, feed); GDK_THREADS_LEAVE(); } }
/* Scroll function taken/adapted from gtktreeview.c */ static gint scroll_row_timeout (gpointer data) { GtkTreeView *tree_view = data; GdkRectangle visible_rect; gint y, x; gint offset; gfloat value; GtkAdjustment* vadj; RbTreeDndData *priv_data; GDK_THREADS_ENTER (); priv_data = g_object_get_data (G_OBJECT (tree_view), RB_TREE_DND_STRING); g_return_val_if_fail(priv_data != NULL, TRUE); gdk_window_get_pointer (gtk_tree_view_get_bin_window (tree_view), &x, &y, NULL); gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &x, &y); gtk_tree_view_convert_bin_window_to_tree_coords (tree_view, x, y, &x, &y); gtk_tree_view_get_visible_rect (tree_view, &visible_rect); /* see if we are near the edge. */ if (x < visible_rect.x && x > visible_rect.x + visible_rect.width) { GDK_THREADS_LEAVE (); priv_data->scroll_timeout = 0; return FALSE; } offset = y - (visible_rect.y + 2 * SCROLL_EDGE_SIZE); if (offset > 0) { offset = y - (visible_rect.y + visible_rect.height - 2 * SCROLL_EDGE_SIZE); if (offset < 0) { GDK_THREADS_LEAVE (); priv_data->scroll_timeout = 0; return FALSE; } } vadj = gtk_tree_view_get_vadjustment (tree_view); value = CLAMP (vadj->value + offset, vadj->lower, vadj->upper - vadj->page_size); gtk_adjustment_set_value (vadj, value); /* don't remove it if we're on the edge and not scrolling */ if (ABS (vadj->value - value) > 0.0001) remove_select_on_drag_timeout(tree_view); GDK_THREADS_LEAVE (); return TRUE; }
static gint gtk_combo_focus_idle (GtkCombo * combo) { if (combo) { GDK_THREADS_ENTER (); gtk_widget_grab_focus (combo->entry); GDK_THREADS_LEAVE (); } return FALSE; }
static gboolean button_activate_timeout (gpointer data) { GDK_THREADS_ENTER (); gtk_button_finish_activate (data, TRUE); GDK_THREADS_LEAVE (); return FALSE; }
int interface_gtk_stop() { global_update = -1; GDK_THREADS_ENTER(); gdk_flush(); gtk_exit(0); // This is *NOT* clean :-( GDK_THREADS_LEAVE(); return 1; }
static void ensure_dlg(FmProgressDisplay* data) { if(data->delay_timeout) { g_source_remove(data->delay_timeout); data->delay_timeout = 0; } GDK_THREADS_ENTER(); if(!data->dlg) _on_show_dlg(data); GDK_THREADS_LEAVE(); }
static gboolean xt_event_prepare (GSource* source_data, gint *timeout) { int mask; GDK_THREADS_ENTER(); mask = XPending(xtdisplay); GDK_THREADS_LEAVE(); return (gboolean)mask; }
gboolean populate_files (gpointer data) //TODO:: show an spinner while loading { FilebrowserBackend *filebackend= FILEBROWSER_BACKEND(data); FilebrowserBackendDetails *directory = FILEBROWSER_BACKEND_GET_PRIVATE(filebackend); GDK_THREADS_ENTER(); if (g_cancellable_is_cancelled (directory->cancellable)){ GDK_THREADS_LEAVE(); return FALSE; /* remove source */ } GError *error=NULL; GFileInfo *info = g_file_enumerator_next_file (directory->enumerator, directory->cancellable, &error); if (info){ const gchar *mime= g_file_info_get_content_type (info); if (!g_file_info_get_is_hidden (info) && !g_file_info_get_is_backup (info)){ if (MIME_ISDIR(mime)){ //if has dot in name pos 0 don't process const gchar *folder=g_file_info_get_display_name(info); if(folder[0]!='.'){ FOLDERFILE *current; current=new_folderfile(); current->mime=g_strdup(mime); GIcon *icon =g_file_info_get_icon(info); current->icon= g_icon_to_string (icon); current->display_name=g_strdup(folder); /* add to list */ directory->filesinfolder = g_slist_append(directory->filesinfolder, current); } } else { if (IS_TEXT(mime) && !IS_APPLICATION(mime)){ //files FOLDERFILE *current; current=new_folderfile(); current->mime=g_strdup(mime); GIcon *icon =g_file_info_get_icon(info); current->icon= g_icon_to_string (icon); current->display_name=g_strdup(g_file_info_get_display_name(info)); /* add to list */ directory->filesinfolder = g_slist_append(directory->filesinfolder, current); } } } g_object_unref(info); } else { if (error){ g_print(_("Error::%s"),error->message); g_error_free (error); } GDK_THREADS_LEAVE(); return FALSE; /* remove source */ } GDK_THREADS_LEAVE(); return TRUE; }
static gint remove_message_timeout (MessageInfo * mi) { GDK_THREADS_ENTER (); mate_appbar_refresh(MATE_APPBAR(mi->app->statusbar)); g_signal_handler_disconnect(mi->app, mi->handlerid); g_free ( mi ); GDK_THREADS_LEAVE (); return FALSE; /* removes the timeout */ }
static gboolean animation_timeout (gpointer data) { gboolean retval; GDK_THREADS_ENTER (); retval = do_animation (data); GDK_THREADS_LEAVE (); return retval; }
/* Works for statusbar and dialog both. */ static gint progress_timeout_cb (ProgressKeyReal * key) { gdouble percent; GDK_THREADS_ENTER (); percent = (* key->percentage_cb)(key->data); mate_app_set_progress (key, percent); GDK_THREADS_LEAVE (); return TRUE; }
/** * gimp_dialog_run: * @dialog: a #GimpDialog * * This function does exactly the same as gtk_dialog_run() except it * does not make the dialog modal while the #GMainLoop is running. * * Return value: response ID **/ gint gimp_dialog_run (GimpDialog *dialog) { RunInfo ri = { NULL, GTK_RESPONSE_NONE, NULL }; gulong response_handler; gulong unmap_handler; gulong destroy_handler; gulong delete_handler; g_return_val_if_fail (GIMP_IS_DIALOG (dialog), -1); g_object_ref (dialog); gtk_window_present (GTK_WINDOW (dialog)); response_handler = g_signal_connect (dialog, "response", G_CALLBACK (run_response_handler), &ri); unmap_handler = g_signal_connect (dialog, "unmap", G_CALLBACK (run_unmap_handler), &ri); delete_handler = g_signal_connect (dialog, "delete-event", G_CALLBACK (run_delete_handler), &ri); destroy_handler = g_signal_connect (dialog, "destroy", G_CALLBACK (run_destroy_handler), &ri); ri.loop = g_main_loop_new (NULL, FALSE); GDK_THREADS_LEAVE (); g_main_loop_run (ri.loop); GDK_THREADS_ENTER (); g_main_loop_unref (ri.loop); ri.loop = NULL; ri.destroyed = FALSE; if (!ri.destroyed) { g_signal_handler_disconnect (dialog, response_handler); g_signal_handler_disconnect (dialog, unmap_handler); g_signal_handler_disconnect (dialog, delete_handler); g_signal_handler_disconnect (dialog, destroy_handler); } g_object_unref (dialog); return ri.response_id; }
static gboolean update_visibility_idle (RBSource *source) { gint count; GDK_THREADS_ENTER (); count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (source->priv->query_model), NULL); g_object_set (source, "visibility", (count > 0), NULL); source->priv->update_visibility_id = 0; GDK_THREADS_LEAVE (); return FALSE; }
/* The actual FFTscope renderer function. */ static void the_fftscope() { guint8 *loc; guint8 bits[256 * 129]; int i, h; running = 1; while (running) { int w; guint val; memset(bits, 128, 256 * SCOPE_HEIGHT); for (i = 0; i < 256; i++) { val = (act_fft[i] + act_fft[i + 256]) / (64 * (128 / SCOPE_HEIGHT)); if (val > (SCOPE_HEIGHT-1)) { val = (SCOPE_HEIGHT-1); } loc = bits + i + 256 * (SCOPE_HEIGHT-1); for (h = val; h > 0; h--) { *loc = h; loc -= 256; } } GDK_THREADS_ENTER(); gdk_draw_indexed_image(area->window, area->style->white_gc, 0, 0, 256, SCOPE_HEIGHT, GDK_RGB_DITHER_NONE, bits, 256, color_map); gdk_flush(); GDK_THREADS_LEAVE(); dosleep(SCOPE_SLEEP); } GDK_THREADS_ENTER(); fftscope_hide(); GDK_THREADS_LEAVE(); }
static gboolean thunar_text_renderer_entry_menu_popdown_timer (gpointer user_data) { ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (user_data); GDK_THREADS_ENTER (); /* check if we still have the keyboard focus */ if (G_UNLIKELY (!GTK_WIDGET_HAS_FOCUS (text_renderer->entry))) thunar_text_renderer_editing_done (GTK_CELL_EDITABLE (text_renderer->entry), text_renderer); GDK_THREADS_LEAVE (); return FALSE; }
static gint queue_draw_timeout (gpointer data) { GtkHexEntry *hex_entry; GDK_THREADS_ENTER (); hex_entry = GTK_HEX_ENTRY (data); hex_entry->timer = 0; gtk_hex_entry_paint (GTK_WIDGET(hex_entry),NULL); GDK_THREADS_LEAVE (); return FALSE; }
static gboolean marlin_text_renderer_entry_menu_popdown_timer (gpointer user_data) { MarlinTextRenderer *text_renderer = MARLIN_TEXT_RENDERER (user_data); GDK_THREADS_ENTER (); /* check if we still have the keyboard focus */ if (G_UNLIKELY (!gtk_widget_has_focus (text_renderer->entry))) marlin_text_renderer_editing_done (GTK_CELL_EDITABLE (text_renderer->entry), text_renderer); GDK_THREADS_LEAVE (); return FALSE; }
void show_dialog(const gchar* message) { GDK_THREADS_ENTER(); GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", message); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_show(dialog); /* gtk_widget_destroy(dialog); */ GDK_THREADS_LEAVE(); }
static gboolean pcm_timer (gpointer data) { BstPlayBackHandle *handle = data; GDK_THREADS_ENTER (); if (!handle->waiting_for_notify) { bse_wave_osc_request_pcm_position (handle->wosc1); handle->waiting_for_notify = TRUE; } GDK_THREADS_LEAVE (); return TRUE; }
static gboolean xt_event_check (GSource* source_data) { GDK_THREADS_ENTER (); if (xt_event_poll_fd.revents & G_IO_IN) { int mask; mask = XPending(xtdisplay); GDK_THREADS_LEAVE (); return (gboolean)mask; } GDK_THREADS_LEAVE (); return FALSE; }
static gboolean hd_incoming_event_window_timeout (HDIncomingEventWindow *window) { HDIncomingEventWindowPrivate *priv = window->priv; GDK_THREADS_ENTER (); priv->timeout_id = 0; g_signal_emit (window, signals[RESPONSE], 0, GTK_RESPONSE_DELETE_EVENT); GDK_THREADS_LEAVE (); return FALSE; }
static gboolean gdk_event_source_prepare (GSource *source, gint *timeout) { GdkDisplay *display = ((GdkEventSource*) source)->display; gboolean retval; GDK_THREADS_ENTER (); *timeout = -1; retval = (_gdk_event_queue_find_first (display) != NULL); GDK_THREADS_LEAVE (); return retval; }
static gboolean on_update_dlg(gpointer user_data) { FmProgressDisplay* data = (FmProgressDisplay*)user_data; /* the g_strdup very probably returns the same pointer that was g_free'd so we cannot just compare data->old_cur_file with data->cur_file */ GDK_THREADS_ENTER(); if(!g_source_is_destroyed(g_main_current_source()) && data->cur_file) { gtk_label_set_text(data->current, data->cur_file); g_free(data->old_cur_file); data->old_cur_file = data->cur_file; data->cur_file = NULL; } GDK_THREADS_LEAVE(); return TRUE; }
static gboolean threads_dispatch(gpointer data) { threads_dispatch_t * dispatch = data; gboolean ret = FALSE; GDK_THREADS_ENTER(); if (!g_source_is_destroyed(g_main_current_source())) { ret = dispatch->func(dispatch->data); } GDK_THREADS_LEAVE(); return ret; }
/* --- functions --- */ static gboolean change_beam_value (gpointer data) { if (!GTK_WIDGET_DRAWABLE (data)) { g_object_unref (data); return FALSE; } GDK_THREADS_ENTER (); BstDBBeam *self = BST_DB_BEAM (data); double v = rand() / ((double) RAND_MAX) * (self->dbsetup->maxdb - self->dbsetup->mindb) + self->dbsetup->mindb; if (v > self->dbsetup->maxdb) v = self->dbsetup->mindb; bst_db_beam_set_value (self, v); GDK_THREADS_LEAVE (); return TRUE; }