static gboolean animate_expander (gpointer data) { GtkLayout *layout; GdkWindow *window; animate_closure_t *closure = (animate_closure_t *) data; cairo_t *cr; if (g_source_is_destroyed (g_main_current_source ())) return FALSE; if (closure->finish) { e_tree_table_adapter_node_set_expanded (closure->etta, closure->node, !closure->expanded); closure->ectv->animate_timeout = 0; return FALSE; } layout = GTK_LAYOUT (closure->ectv->canvas); window = gtk_layout_get_bin_window (layout); cr = gdk_cairo_create (window); draw_expander ( closure->ectv, cr, closure->expanded ? GTK_EXPANDER_SEMI_COLLAPSED : GTK_EXPANDER_SEMI_EXPANDED, GTK_STATE_NORMAL, &closure->area); closure->finish = TRUE; cairo_destroy (cr); return TRUE; }
static gboolean priv_discovery_tick (gpointer pointer) { NiceAgent *agent = pointer; gboolean ret; agent_lock(); if (g_source_is_destroyed (g_main_current_source ())) { nice_debug ("Source was destroyed. " "Avoided race condition in priv_discovery_tick"); agent_unlock (); return FALSE; } ret = priv_discovery_tick_unlocked (pointer); if (ret == FALSE) { if (agent->discovery_timer_source != NULL) { g_source_destroy (agent->discovery_timer_source); g_source_unref (agent->discovery_timer_source); agent->discovery_timer_source = NULL; } } agent_unlock_and_emit (agent); return ret; }
static void complete_resolve_async (SoupAddressResolveAsyncData *res_data, guint status) { GSource *current_source; GMainContext *current_context; if (res_data->callback) { /* Awful hack; to make soup_socket_connect_async() * with an non-default async_context work correctly, * we need to ensure that the non-default context * (which we're now running in) is the thread-default * when the callbacks are run... */ current_source = g_main_current_source (); if (current_source && !g_source_is_destroyed (current_source)) current_context = g_source_get_context (current_source); else current_context = NULL; g_main_context_push_thread_default (current_context); res_data->callback (res_data->addr, status, res_data->callback_data); g_main_context_pop_thread_default (current_context); } g_object_unref (res_data->addr); g_slice_free (SoupAddressResolveAsyncData, res_data); }
/* {{{ proto void \Glib\Source->attach(Context $context) attaches a source to a main context */ PHP_METHOD(GlibSource, attach) { zval *context_zval = NULL; glib_main_context_object *context_object; glib_source_object *source_object; if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "O", &context_zval, glib_ce_main_context) == FAILURE) { return; } if(context_zval == NULL) { zend_throw_exception(spl_ce_InvalidArgumentException, "Invalid context sent", 0); return; } context_object = Z_GLIB_MAIN_CONTEXT_P(context_zval); source_object = Z_GLIB_SOURCE_P(getThis()); GLIB_CHECK_INITIALIZED(source_object->source, Glib\\Source) if(g_source_is_destroyed(source_object->source)) { zend_throw_exception(spl_ce_RuntimeException, "Source has been destroyed", 0); return; } RETURN_LONG(g_source_attach(source_object->source, context_object->main_context)); }
/** Callback invoked when a libusb FD should be removed from the poll set. */ static LIBUSB_CALL void usb_pollfd_removed(libusb_os_handle fd, void *user_data) { struct usb_source *usource; GPollFD *pollfd; unsigned int i; usource = user_data; if (G_UNLIKELY(g_source_is_destroyed(&usource->base))) return; /* It's likely that the removed poll FD is at the end. */ for (i = usource->pollfds->len; G_LIKELY(i > 0); i--) { pollfd = g_ptr_array_index(usource->pollfds, i - 1); if ((libusb_os_handle)pollfd->fd == fd) { g_source_remove_poll(&usource->base, pollfd); g_ptr_array_remove_index_fast(usource->pollfds, i - 1); return; } } sr_err("FD to be removed (%" G_GINTPTR_FORMAT ") not found in event source poll set.", (gintptr)fd); }
static gboolean update_display_timeout(gpointer user_data) { if (g_source_is_destroyed(g_main_current_source())) return FALSE; update_display(user_data); return TRUE; /* repeat later */ }
/** FD event source dispatch() method. * This is called if either prepare() or check() returned TRUE. */ static gboolean fd_source_dispatch(GSource *source, GSourceFunc callback, void *user_data) { struct fd_source *fsource; const char *name; unsigned int revents; gboolean keep; fsource = (struct fd_source *)source; name = g_source_get_name(source); revents = fsource->pollfd.revents; if (revents != 0) { sr_spew("%s: %s " G_POLLFD_FORMAT ", revents 0x%.2X", __func__, name, fsource->pollfd.fd, revents); } else { sr_spew("%s: %s " G_POLLFD_FORMAT ", timed out", __func__, name, fsource->pollfd.fd); } if (!callback) { sr_err("Callback not set, cannot dispatch event."); return G_SOURCE_REMOVE; } keep = (*(sr_receive_data_callback)callback) (fsource->pollfd.fd, revents, user_data); if (fsource->timeout_us >= 0 && G_LIKELY(keep) && G_LIKELY(!g_source_is_destroyed(source))) fsource->due_us = g_source_get_time(source) + fsource->timeout_us; return keep; }
static void gw_spellcheck_remove_signals (GwSpellcheck *spellcheck) { //Declarations GwSpellcheckPrivate *priv; LwPreferences *preferences; GtkEntry *entry; GSource *source; int i; priv = spellcheck->priv; preferences = gw_application_get_preferences (priv->application); entry = priv->entry; if (priv->signalid[GW_SPELLCHECK_SIGNALID_DICTIONARY] != 0) { lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalid[GW_SPELLCHECK_SIGNALID_DICTIONARY] ); priv->signalid[GW_SPELLCHECK_SIGNALID_DICTIONARY] = 0; } if (priv->signalid[GW_SPELLCHECK_SIGNALID_RK_CONV] != 0) { lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalid[GW_SPELLCHECK_SIGNALID_RK_CONV] ); priv->signalid[GW_SPELLCHECK_SIGNALID_RK_CONV] = 0; } for (i = 0; i < TOTAL_GW_SPELLCHECK_SIGNALIDS && entry != NULL; i++) { if (priv->signalid[i] > 0) { g_signal_handler_disconnect (G_OBJECT (entry), priv->signalid[i]); priv->signalid[i] = 0; } } for (i = 0; i < TOTAL_GW_SPELLCHECK_TIMEOUTIDS; i++) { if (g_main_current_source () != NULL && !g_source_is_destroyed (g_main_current_source ()) && priv->timeoutid[i] > 0 ) { source = g_main_context_find_source_by_id (NULL, priv->timeoutid[i]); if (source != NULL) { g_source_destroy (source); } } priv->timeoutid[i] = 0; } }
static void gw_kanjipadwindow_finalize (GObject *object) { GwKanjipadWindow *window; GwKanjipadWindowPrivate *priv; GSource *source; GError *error; GList *link; window = GW_KANJIPADWINDOW (object); priv = window->priv; error = NULL; for (link = priv->strokes; link != NULL; link = link->next) gw_kanjipadwindow_free_drawingarea_stroke (link->data); if (priv->strokes != NULL) g_list_free (priv->strokes); priv->strokes = NULL; if (priv->strokes != NULL) g_list_free (priv->curstroke); priv->curstroke = NULL; if (priv->ksurface != NULL) cairo_surface_destroy (priv->ksurface); priv->ksurface = NULL; if (priv->surface != NULL) cairo_surface_destroy (priv->surface); priv->surface = NULL; if (g_main_current_source () != NULL && !g_source_is_destroyed (g_main_current_source ()) && priv->iowatchid > 0 ) { source = g_main_context_find_source_by_id (NULL, priv->iowatchid); if (source != NULL) { g_source_destroy (source); } } priv->iowatchid = 0; if (error == NULL) { g_io_channel_shutdown (priv->from_engine, FALSE, &error); g_io_channel_unref (priv->from_engine); priv->from_engine = NULL; } if (error == NULL) { g_io_channel_shutdown (priv->to_engine, FALSE, &error); g_io_channel_unref (priv->to_engine); priv->to_engine = NULL; } g_spawn_close_pid (priv->engine_pid); if (error != NULL) { fprintf(stderr, "Errored: %s\n", error->message); exit(EXIT_FAILURE); } G_OBJECT_CLASS (gw_kanjipadwindow_parent_class)->finalize (object); }
static void cancellable_source_cancelled (GCancellable *cancellable, gpointer user_data) { GSource *source = user_data; if (!g_source_is_destroyed (source)) g_source_set_ready_time (source, 0); }
static gboolean _fm_modules_on_idle(gpointer user_data) { /* check if it is destroyed already */ if(g_source_is_destroyed(g_main_current_source())) return FALSE; G_LOCK(idle_handler); idle_handler = 0; G_UNLOCK(idle_handler); fm_modules_load(); return FALSE; }
static gboolean protobuf_source_dispatch (GSource *source, GSourceFunc callback, void *user_data) { ProtobufSource *protobuf_source = (ProtobufSource *) source; GPollFD *gpollfds = protobuf_source->pollfds; int i; int n_events; ProtobufC_FDNotify *events; void *to_free = NULL; n_events = 0; for (i = 0; i < protobuf_source->n_pollfds; i++) if (gpollfds[i].revents) n_events++; if (n_events < 128) events = alloca (sizeof (ProtobufC_FDNotify) * n_events); else to_free = events = g_new (ProtobufC_FDNotify, n_events); n_events = 0; for (i = 0; i < protobuf_source->n_pollfds; i++) if (gpollfds[i].revents) { events[n_events].fd = gpollfds[i].fd; events[n_events].events = gpollfd_events_to_protobuf_events (gpollfds[i].revents); /* note that we may actually wind up with fewer events after * calling gpollfd_events_to_protobuf_events() */ if (events[n_events].events != 0) n_events++; } rig_protobuf_c_dispatch_dispatch (protobuf_source->dispatch, n_events, events); /* XXX: PROTOBUF-C BUG? * * rig_protobuf_c_dispatch_dispatch can return with dispatch->n_changes * == 0 even though the list of notifies may have changed during the * dispatch itself which means we have to resort to explicitly comparing * the gpollfds with dispatch->notifies_desired which is obviously * not ideal! */ if (!g_source_is_destroyed (source)) sync_pollfds (protobuf_source); if (to_free) g_free (to_free); return TRUE; }
void TimeoutBase::Cancel() { LOG_TRACE("Entering function %s", __FUNCTION__); if (m_timeout) { if (!g_source_is_destroyed(m_timeout)) { g_source_destroy(m_timeout); } m_timeout = NULL; } }
/* {{{ proto bool \Glib\Source->isDestroyed() removes a source from a main context and marks it as destroyed */ PHP_METHOD(GlibSource, isDestroyed) { glib_source_object *source_object; if (zend_parse_parameters_none_throw() == FAILURE) { return; } source_object = Z_GLIB_SOURCE_P(getThis()); GLIB_CHECK_INITIALIZED(source_object->source, Glib\\Source) RETURN_BOOL(g_source_is_destroyed(source_object->source)); }
static gboolean async_timeout_cb (GstDiscoverer * dc) { if (!g_source_is_destroyed (g_main_current_source ())) { dc->priv->timeoutid = 0; GST_DEBUG ("Setting result to TIMEOUT"); dc->priv->current_info->result = GST_DISCOVERER_TIMEOUT; dc->priv->processing = FALSE; discoverer_collect (dc); discoverer_cleanup (dc); } return FALSE; }
static gboolean emit_found_files(gpointer user_data) { /* this callback is called from the main thread */ FmDirListJob* job = FM_DIR_LIST_JOB(user_data); /* g_print("emit_found_files: %d\n", g_slist_length(job->files_to_add)); */ if(g_source_is_destroyed(g_main_current_source())) return FALSE; g_signal_emit(job, signals[FILES_FOUND], 0, job->files_to_add); g_slist_free_full(job->files_to_add, (GDestroyNotify)fm_file_info_unref); job->files_to_add = NULL; job->delay_add_files_handler = 0; return FALSE; }
static void tls_source_sync (GTlsConnectionBaseSource *tls_source) { GTlsConnectionBase *tls = tls_source->tls; gboolean io_waiting, op_waiting; /* Was the source destroyed earlier in this main context iteration? */ if (g_source_is_destroyed ((GSource *) tls_source)) return; g_mutex_lock (&tls->op_mutex); if (((tls_source->condition & G_IO_IN) && tls->reading) || ((tls_source->condition & G_IO_OUT) && tls->writing) || (tls->handshaking && !tls->need_finish_handshake)) op_waiting = TRUE; else op_waiting = FALSE; if (!op_waiting && !tls->need_handshake && !tls->need_finish_handshake) io_waiting = TRUE; else io_waiting = FALSE; g_mutex_unlock (&tls->op_mutex); if (op_waiting == tls_source->op_waiting && io_waiting == tls_source->io_waiting) return; tls_source->op_waiting = op_waiting; tls_source->io_waiting = io_waiting; if (tls_source->child_source) { g_source_remove_child_source ((GSource *)tls_source, tls_source->child_source); g_source_unref (tls_source->child_source); } if (op_waiting) tls_source->child_source = g_cancellable_source_new (tls->waiting_for_op); else if (io_waiting && G_IS_POLLABLE_INPUT_STREAM (tls_source->stream)) tls_source->child_source = g_pollable_input_stream_create_source (tls->base_istream, NULL); else if (io_waiting && G_IS_POLLABLE_OUTPUT_STREAM (tls_source->stream)) tls_source->child_source = g_pollable_output_stream_create_source (tls->base_ostream, NULL); else tls_source->child_source = g_timeout_source_new (0); g_source_set_dummy_callback (tls_source->child_source); g_source_add_child_source ((GSource *)tls_source, tls_source->child_source); }
static gboolean gdk_threads_dispatch (gpointer data) { GdkThreadsDispatch *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; }
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; }
/** USB event source dispatch() method. */ static gboolean usb_source_dispatch(GSource *source, GSourceFunc callback, void *user_data) { struct usb_source *usource; GPollFD *pollfd; unsigned int revents; unsigned int i; gboolean keep; usource = (struct usb_source *)source; revents = 0; /* * This is somewhat arbitrary, but drivers use revents to distinguish * actual I/O from timeouts. When we remove the user timeout from the * driver API, this will no longer be needed. */ for (i = 0; i < usource->pollfds->len; i++) { pollfd = g_ptr_array_index(usource->pollfds, i); revents |= pollfd->revents; } if (revents != 0) sr_spew("%s: revents 0x%.2X", __func__, revents); else sr_spew("%s: timed out", __func__); if (!callback) { sr_err("Callback not set, cannot dispatch event."); return G_SOURCE_REMOVE; } keep = (*(sr_receive_data_callback)callback)(-1, revents, user_data); if (G_LIKELY(keep) && G_LIKELY(!g_source_is_destroyed(source))) { if (usource->timeout_us >= 0) usource->due_us = g_source_get_time(source) + usource->timeout_us; else usource->due_us = INT64_MAX; } return keep; }
/** Callback invoked when a new libusb FD should be added to the poll set. */ static LIBUSB_CALL void usb_pollfd_added(libusb_os_handle fd, short events, void *user_data) { struct usb_source *usource; GPollFD *pollfd; usource = user_data; if (G_UNLIKELY(g_source_is_destroyed(&usource->base))) return; pollfd = g_slice_new(GPollFD); #ifdef G_OS_WIN32 events = G_IO_IN; #endif pollfd->fd = (gintptr)fd; pollfd->events = events; pollfd->revents = 0; g_ptr_array_add(usource->pollfds, pollfd); g_source_add_poll(&usource->base, pollfd); }
static void complete_resolve_async (SoupAddress *addr, guint status) { SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr); SoupAddressResolveAsyncData *res_data; GSList *lookups, *l; GSource *current_source; GMainContext *current_context; lookups = priv->async_lookups; priv->async_lookups = NULL; /* Awful hack; to make soup_socket_connect_async() with an * non-default async_context work correctly, we need to ensure * that the non-default context (which we're now running in) * is the thread-default when the callbacks are run... */ current_source = g_main_current_source (); if (current_source && !g_source_is_destroyed (current_source)) current_context = g_source_get_context (current_source); else current_context = NULL; g_main_context_push_thread_default (current_context); for (l = lookups; l; l = l->next) { res_data = l->data; if (res_data->callback) { res_data->callback (addr, status, res_data->callback_data); } g_slice_free (SoupAddressResolveAsyncData, res_data); } g_slist_free (lookups); g_main_context_pop_thread_default (current_context); g_object_unref (addr); }
static gboolean _g_ssl_input_stream_read_ready(gpointer data) { GSSLInputStream *stream = (GSSLInputStream *)data; GSimpleAsyncResult *simple; GError *error = NULL; gssize result; g_assert(stream != NULL); g_assert(stream->priv->result != NULL); if(!g_source_is_destroyed(g_main_current_source())) { simple = stream->priv->result; stream->priv->result = NULL; if((result = openssl_read(stream->priv->ssl, stream->priv->buffer, stream->priv->count, stream->priv->cancellable, &error)) > 0) { g_simple_async_result_set_op_res_gssize(simple, result); } if(error) { g_simple_async_result_set_from_error(simple, error); g_error_free(error); } if(stream->priv->cancellable) { g_object_unref(stream->priv->cancellable); } g_simple_async_result_complete(simple); g_object_unref(simple); } return FALSE; }
/** FD event source dispatch() method. * This is called if either prepare() or check() returned TRUE. */ static gboolean fd_source_dispatch(GSource *source, GSourceFunc callback, void *user_data) { struct fd_source *fsource; unsigned int revents; gboolean keep; fsource = (struct fd_source *)source; revents = fsource->pollfd.revents; if (!callback) { sr_err("Callback not set, cannot dispatch event."); return G_SOURCE_REMOVE; } keep = (*(sr_receive_data_callback)callback) (fsource->pollfd.fd, revents, user_data); if (fsource->timeout_us >= 0 && G_LIKELY(keep) && G_LIKELY(!g_source_is_destroyed(source))) fsource->due_us = g_source_get_time(source) + fsource->timeout_us; return keep; }
static gboolean socket_send_more ( GSocket *gsocket, GIOCondition condition, gpointer data) { NiceSocket *sock = (NiceSocket *) data; TcpPriv *priv = sock->priv; agent_lock (NULL); if (g_source_is_destroyed (g_main_current_source ())) { nice_debug ("Source was destroyed. " "Avoided race condition in tcp-bsd.c:socket_send_more"); agent_unlock (NULL); return FALSE; } /* connection hangs up or queue was emptied */ if (condition & G_IO_HUP || nice_socket_flush_send_queue_to_socket (sock->fileno, &priv->send_queue)) { g_source_destroy (priv->io_source); g_source_unref (priv->io_source); priv->io_source = NULL; agent_unlock (NULL); if (priv->writable_cb) priv->writable_cb (sock, priv->writable_data); return FALSE; } agent_unlock (NULL); return TRUE; }
/* * This function is called every UPDATE_PERIOD seconds. It updates all * monitors. */ static gboolean monitors_update(gpointer data) { MonitorsPlugin *mp; int i; if (g_source_is_destroyed(g_main_current_source())) return FALSE; mp = (MonitorsPlugin *) data; if (!mp) RET(FALSE); for (i = 0; i < N_MONITORS; i++) { if (mp->monitors[i]) { mp->monitors[i]->update(mp->monitors[i]); if (mp->monitors[i]->update_tooltip) mp->monitors[i]->update_tooltip(mp->monitors[i]); } } return TRUE; }
static gboolean socket_send_more ( GSocket *gsocket, GIOCondition condition, gpointer data) { NiceSocket *sock = (NiceSocket *) data; TcpPriv *priv = sock->priv; struct to_be_sent *tbs = NULL; GError *gerr = NULL; agent_lock (); if (g_source_is_destroyed (g_main_current_source ())) { nice_debug ("Source was destroyed. " "Avoided race condition in tcp-bsd.c:socket_send_more"); agent_unlock (); return FALSE; } while ((tbs = g_queue_pop_head (&priv->send_queue)) != NULL) { int ret; if(condition & G_IO_HUP) { /* connection hangs up */ ret = -1; } else { GOutputVector local_bufs = { tbs->buf, tbs->length }; ret = g_socket_send_message (sock->fileno, NULL, &local_bufs, 1, NULL, 0, G_SOCKET_MSG_NONE, NULL, &gerr); } if (ret < 0) { if (g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) { GOutputVector local_buf = { tbs->buf, tbs->length }; NiceOutputMessage local_message = {&local_buf, 1}; add_to_be_sent (sock, &local_message, 0, local_buf.size, TRUE); free_to_be_sent (tbs); g_error_free (gerr); break; } g_clear_error (&gerr); } else if (ret < (int) tbs->length) { GOutputVector local_buf = { tbs->buf + ret, tbs->length - ret }; NiceOutputMessage local_message = {&local_buf, 1}; add_to_be_sent (sock, &local_message, 0, local_buf.size, TRUE); free_to_be_sent (tbs); break; } free_to_be_sent (tbs); } if (g_queue_is_empty (&priv->send_queue)) { g_source_destroy (priv->io_source); g_source_unref (priv->io_source); priv->io_source = NULL; agent_unlock (); return FALSE; } agent_unlock (); return TRUE; }
static gboolean on_show_dlg(gpointer user_data) { FmProgressDisplay* data = (FmProgressDisplay*)user_data; GtkBuilder* builder; GtkLabel* to; GtkWidget *to_label; FmPath* dest; const char* title = NULL; GtkTextTagTable* tag_table; GDK_THREADS_ENTER(); if(g_source_is_destroyed(g_main_current_source())) goto _end; builder = gtk_builder_new(); tag_table = gtk_text_tag_table_new(); gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); gtk_builder_add_from_file(builder, PACKAGE_UI_DIR "/progress.ui", NULL); data->dlg = GTK_DIALOG(gtk_builder_get_object(builder, "dlg")); g_object_weak_ref(G_OBJECT(data->dlg), on_progress_dialog_destroy, data); g_signal_connect(data->dlg, "response", G_CALLBACK(on_response), data); /* FIXME: connect to "close" signal */ to_label = (GtkWidget*)gtk_builder_get_object(builder, "to_label"); to = GTK_LABEL(gtk_builder_get_object(builder, "dest")); data->icon = GTK_IMAGE(gtk_builder_get_object(builder, "icon")); data->msg = GTK_LABEL(gtk_builder_get_object(builder, "msg")); data->act = GTK_LABEL(gtk_builder_get_object(builder, "action")); data->src = GTK_LABEL(gtk_builder_get_object(builder, "src")); data->dest = (GtkWidget*)gtk_builder_get_object(builder, "dest"); data->current = GTK_LABEL(gtk_builder_get_object(builder, "current")); data->progress = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progress")); data->error_pane = (GtkWidget*)gtk_builder_get_object(builder, "error_pane"); data->error_msg = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "error_msg")); data->remaining_time = GTK_LABEL(gtk_builder_get_object(builder, "remaining_time")); data->bold_tag = gtk_text_tag_new("bold"); g_object_set(data->bold_tag, "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_tag_table_add(tag_table, data->bold_tag); data->error_buf = gtk_text_buffer_new(tag_table); g_object_unref(tag_table); gtk_text_view_set_buffer(data->error_msg, data->error_buf); g_object_unref(builder); /* set the src label */ /* FIXME: direct access to job struct! */ if(data->job->srcs) { GList* l = fm_path_list_peek_head_link(data->job->srcs); int i; char* disp; FmPath* path; GString* str = g_string_sized_new(512); path = FM_PATH(l->data); disp = fm_path_display_basename(path); g_string_assign(str, disp); g_free(disp); for( i =1, l=l->next; i < 10 && l; l=l->next, ++i) { path = FM_PATH(l->data); g_string_append(str, _(", ")); disp = fm_path_display_basename(path); g_string_append(str, disp); g_free(disp); } if(l) g_string_append(str, "..."); gtk_label_set_text(data->src, str->str); g_string_free(str, TRUE); } /* FIXME: use accessor functions instead */ /* FIXME: direct access to job struct! */ switch(data->job->type) { case FM_FILE_OP_MOVE: title = _("Moving files"); break; case FM_FILE_OP_COPY: title = _("Copying files"); break; case FM_FILE_OP_TRASH: title = _("Trashing files"); break; case FM_FILE_OP_DELETE: title = _("Deleting files"); break; case FM_FILE_OP_LINK: title = _("Creating symlinks"); break; case FM_FILE_OP_CHANGE_ATTR: title = _("Changing file attributes"); break; case FM_FILE_OP_UNTRASH: break; case FM_FILE_OP_NONE: ; } if(title) { gtk_window_set_title(GTK_WINDOW(data->dlg), title); gtk_label_set_text(data->act, title); } dest = fm_file_ops_job_get_dest(data->job); if(dest) { char* dest_str = fm_path_display_name(dest, TRUE); gtk_label_set_text(to, dest_str); g_free(dest_str); } else { gtk_widget_destroy(data->dest); gtk_widget_destroy(to_label); } gtk_window_set_transient_for(GTK_WINDOW(data->dlg), data->parent); gtk_window_present(GTK_WINDOW(data->dlg)); data->update_timeout = g_timeout_add(500, on_update_dlg, data); data->delay_timeout = 0; _end: GDK_THREADS_LEAVE(); return FALSE; }
static gboolean idle_callback (gpointer data) { CajaProgressInfo *info = data; gboolean start_at_idle; gboolean finish_at_idle; gboolean changed_at_idle; gboolean progress_at_idle; GSource *source; source = g_main_current_source (); G_LOCK (progress_info); /* Protect agains races where the source has been destroyed on another thread while it was being dispatched. Similar to what gdk_threads_add_idle does. */ if (g_source_is_destroyed (source)) { G_UNLOCK (progress_info); return FALSE; } /* We hadn't destroyed the source, so take a ref. * This might ressurect the object from dispose, but * that should be ok. */ g_object_ref (info); g_assert (source == info->idle_source); g_source_unref (source); info->idle_source = NULL; start_at_idle = info->start_at_idle; finish_at_idle = info->finish_at_idle; changed_at_idle = info->changed_at_idle; progress_at_idle = info->progress_at_idle; info->start_at_idle = FALSE; info->finish_at_idle = FALSE; info->changed_at_idle = FALSE; info->progress_at_idle = FALSE; G_UNLOCK (progress_info); if (start_at_idle) { g_signal_emit (info, signals[STARTED], 0); } if (changed_at_idle) { g_signal_emit (info, signals[CHANGED], 0); } if (progress_at_idle) { g_signal_emit (info, signals[PROGRESS_CHANGED], 0); } if (finish_at_idle) { g_signal_emit (info, signals[FINISHED], 0); } g_object_unref (info); return FALSE; }