/** * Shutdown a IPC Server */ static void xmms_ipc_shutdown_server (xmms_ipc_t *ipc) { GList *c; xmms_ipc_client_t *co; if (!ipc) return; g_mutex_lock (ipc->mutex_lock); g_source_remove_by_user_data (ipc); g_io_channel_unref (ipc->chan); xmms_ipc_transport_destroy (ipc->transport); for (c = ipc->clients; c; c = g_list_next (c)) { co = c->data; if (!co) continue; co->ipc = NULL; } g_list_free (ipc->clients); g_mutex_unlock (ipc->mutex_lock); g_mutex_free (ipc->mutex_lock); g_free (ipc); }
// fifo_init_internal(path) // If path is NULL, reopen existing fifo, else open anew. static int fifo_init_internal(const char *fifo_path) { if (fifo_path) { fifo_deinit(); fifo_name = expand_filename(fifo_path); if (!check_fifo(fifo_name)) { scr_LogPrint(LPRINT_LOGNORM, "WARNING: Cannot create the FIFO. " "%s already exists and is not a pipe", fifo_name); g_free(fifo_name); fifo_name = NULL; return -1; } } else if (fifo_name) g_source_remove_by_user_data(fifo_channel); else return -1; if (!attach_fifo(fifo_name)) { scr_LogPrint(LPRINT_LOGNORM, "Error: Cannot open fifo"); return -1; } setenv(FIFO_ENV_NAME, fifo_name, 1); scr_LogPrint(LPRINT_LOGNORM, "FIFO initialized (%s)", fifo_path); return 1; }
/** * paxos_peer_destroy - Free up a peer. */ void paxos_peer_destroy(struct paxos_peer *peer) { GIOStatus status; GError *error = NULL; if (peer == NULL) { return; } // Clean up the msgpack read buffer / unpacker. msgpack_unpacker_destroy(&peer->pp_unpacker); // Get rid of our event listeners. while (g_source_remove_by_user_data(peer)); // Flush and destroy the GIOChannel. status = g_io_channel_shutdown(peer->pp_channel, TRUE, &error); if (status != G_IO_STATUS_NORMAL) { g_warning("paxos_peer_destroy: Trouble destroying peer."); } // Free the peer structure itself. g_free(peer); }
void idle_test() { int user_data = 0; gboolean retVal; GSource *s = g_idle_source_new(); idle_loop = g_main_loop_new(NULL, FALSE); g_source_attach(s,context); g_idle_add((GSourceFunc)function,&user_data); retVal = g_idle_remove_by_data(&user_data); //checks g_idle_remove_by_data g_assert(retVal == TRUE); retVal = FALSE; g_idle_add((GSourceFunc)function,&user_data); retVal = g_source_remove_by_user_data(&user_data); //checks g_source_remove_by_user_data g_assert(retVal == TRUE); g_idle_add((GSourceFunc)function,&user_data); g_main_loop_run(idle_loop); g_main_loop_unref(idle_loop); //checks whether the function was run or not g_assert(user_data == 1); }
/** * msgpack_conn_destroy - Free up a conn. */ void msgpack_conn_destroy(struct msgpack_conn *conn) { GIOStatus status; GError *error = NULL; if (conn == NULL) { return; } // Clean up the msgpack unpacker/read buffer. msgpack_unpacker_destroy(&conn->mc_unpacker); // Get rid of our event listeners. while (g_source_remove_by_user_data(conn)); // Flush and destroy the GIOChannel. status = g_io_channel_shutdown(conn->mc_channel, TRUE, &error); if (status != G_IO_STATUS_NORMAL) { g_warning("msgpack_conn_destroy: Trouble destroying conn."); } // Free the conn structure itself. g_free(conn); }
static void on_window_destroy_event (GtkWidget *widget, gpointer user_data) { g_object_unref (bookmark_list_store); g_object_unref (bookmark_empty_list_store); g_source_remove_by_user_data (widget); }
void MiracBroker::connection(MiracNetwork *connection) { while (g_source_remove_by_user_data(&connection_source_ptr_)) ; connection_.reset(connection); if (connection_) g_unix_fd_add(connection_->GetHandle(), G_IO_IN, receive_cb, &connection_source_ptr_); }
static void applet_destroy(MatePanelApplet *applet_widget, softupd_applet *applet) { g_assert(applet); // Remove all timers while (g_source_remove_by_user_data((gpointer) applet)) ; g_main_loop_quit(applet->loop); g_free(applet->pid_arr); g_free(applet); return; }
void DockLet::End() { while (g_source_remove_by_user_data(&docklet)) { } g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), (void *)(DestroyedCallback), this); gtk_widget_destroy(GTK_WIDGET(docklet)); g_object_unref(G_OBJECT(docklet)); if (menu) gtk_widget_destroy(menu); }
void DockLet::DestroyedCallback(GtkWidget *widget, DockLet *oDockLet) { oDockLet->embedded = false; oDockLet->image = NULL; /*if (!(GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window))) gtk_widget_show(gpAppFrame->oAppCore.window); // it is better not to use gtk_window_present(). */ while (g_source_remove_by_user_data(&(oDockLet->docklet))) { } g_object_unref(G_OBJECT(oDockLet->docklet)); g_idle_add(oDockLet->docklet_create, (gpointer)(oDockLet->current_icon)); //when user add Nofification area applet again,it will show icon again. }
/* * Close listening socket * Close all client sockets */ void dsmesock_shutdown(void) { if (as_chan) { // TODO: no strong guarantee that as_chan is unique g_source_remove_by_user_data(as_chan); g_io_channel_shutdown(as_chan, FALSE, 0); g_io_channel_unref(as_chan); as_chan = 0; } while (clients) { close_client(clients->data); } }
static void context_destroy(const char *ini_fn) { g_source_remove_by_user_data(ctx); if (ini_fn) save_profile(ini_fn); if (dac_tx_manager) { dac_data_manager_free(dac_tx_manager); dac_tx_manager = NULL; } iio_context_destroy(ctx); }
/** * msgpack_conn_write - Write data reliably to a connection. */ int msgpack_conn_write(GIOChannel *channel, GIOCondition condition, void *data) { struct msgpack_conn *conn; size_t bytes_written; GIOStatus status; GError *error = NULL; conn = (struct msgpack_conn *)data; // If there's nothing to write, do nothing. if (conn->mc_write_buffer->len == 0) { return TRUE; } // Write to the channel. status = g_io_channel_write_chars(channel, conn->mc_write_buffer->str, conn->mc_write_buffer->len, &bytes_written, &error); if (status == G_IO_STATUS_ERROR) { g_warning("msgpack_conn_write: Write to socket failed."); } g_string_erase(conn->mc_write_buffer, 0, bytes_written); if (conn->mc_write_buffer->len == 0) { // XXX: This is kind of hax. while (g_source_remove_by_user_data(conn)); g_io_add_watch(conn->mc_channel, G_IO_IN, msgpack_conn_read, conn); } // Flush the channel. error = NULL; if (g_io_channel_flush(conn->mc_channel, &error) == G_IO_STATUS_ERROR) { g_critical("msgpack_conn_write: Could not flush channel."); } if (status == G_IO_STATUS_EOF) { // Flush the read buffer. We will also detect the EOF in msgpack_conn_read, // which will destroy the conn for us. if (g_io_channel_get_buffer_condition(channel) & G_IO_IN) { msgpack_conn_read(channel, G_IO_IN, data); } return FALSE; } return TRUE; }
static void sig_disconnected(XMPP_SERVER_REC *server) { GSList *tmp; XMPP_QUERY_REC *query; if (!IS_XMPP_SERVER(server)) return; for (tmp = queries; tmp != NULL; tmp = tmp->next) { query = XMPP_QUERY(tmp->data); if (query == NULL) continue; if (query->server == server) g_source_remove_by_user_data(query); } }
void fifo_deinit(void) { unsetenv(FIFO_ENV_NAME); if (fifo_channel) g_source_remove_by_user_data(fifo_channel); /* channel itself should be destroyed by destruction callback */ /* destroy open fifo */ if (fifo_name) { /* well, that may create fifo, and then unlink, * but at least we will not destroy non-fifo data */ if (check_fifo(fifo_name)) unlink(fifo_name); g_free(fifo_name); fifo_name = NULL; } }
static void passwd_gui_on_response(GtkDialog* dlg, gint response, struct passwd_resp *pr) { char *cmdargs; //GtkEntry* entry = (GtkEntry*)user_data; if(G_LIKELY(response == GTK_RESPONSE_OK)) { cmdargs = lxnm_wireless_command_make(pr->aps->ifname, pr->aps->apinfo->essid, pr->aps->apinfo->apaddr, gtk_entry_get_text(pr->entry), pr->aps->apinfo->en_method, pr->aps->apinfo->key_mgmt, pr->aps->apinfo->group, pr->aps->apinfo->pairwise); lxnm_send_command(pr->aps->gio, LXNM_WIRELESS_CONNECT, cmdargs); g_free(cmdargs); } g_source_remove_by_user_data(pr->entry); /* remove timeout */ gtk_widget_destroy((GtkWidget*)dlg); }
static void screensaver_enable_x11 (ScreenSaver * screensaver) { #ifdef HAVE_XTEST if (screensaver->have_xtest) { g_source_remove_by_user_data (screensaver); return; } #endif XLockDisplay (screensaver->display); XSetScreenSaver (screensaver->display, screensaver->timeout, screensaver->interval, screensaver->prefer_blanking, screensaver->allow_exposures); XUnlockDisplay (screensaver->display); }
static void deleting_conv_cb(PurpleConversation *conv) { PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); twitter_debug("called\n"); g_return_if_fail(gtkconv != NULL); gint service = get_service_type(conv); GHashTable *hash = NULL; /* only attach to twitter conversation window */ switch(service) { case twitter_service: if(purple_prefs_get_bool(OPT_API_BASE_POST)) { g_source_remove_by_user_data((gpointer)conv); source.id = 0; source.conv = NULL; } hash = icon_hash[service]; break; case wassr_service: case identica_service: case jisko_service: case ffeed_service: hash = icon_hash[service]; break; default: twitter_debug("unknown service\n"); break; } if(hash) delete_requested_icon_marks(gtkconv, hash); }
// Destroy a figure void rtk_fig_destroy(rtk_fig_t *fig) { //printf( "destroying fig %p\n", fig ); rtk_canvas_lock(fig->canvas); // remove any glib sources that might access this figure (such as // a blink timer) - rtv while( g_source_remove_by_user_data( fig ) ) {} // empty loop - the call is repeated until it returns FALSE. // Remove from the list of canvas figures, or from the parent's list // of figures. if (fig->parent == NULL) { RTK_LIST_REMOVEX(fig->canvas->fig, sibling, fig); } else { RTK_LIST_REMOVEX(fig->parent->child, sibling, fig); } // Remove from the layer list. RTK_LIST_REMOVEX(fig->canvas->layer_fig, layer, fig); rtk_canvas_unlock(fig->canvas); // Free the strokes rtk_fig_clear(fig); free(fig->strokes); // Clear the dirty regions rtk_region_destroy(fig->region); free(fig); }
static void sn_event_func(SnMonitorEvent *ev, gpointer data) { SnStartupSequence *seq; gboolean change = FALSE; if (!(seq = sn_monitor_event_get_startup_sequence(ev))) return; switch (sn_monitor_event_get_type(ev)) { case SN_MONITOR_EVENT_INITIATED: sn_startup_sequence_ref(seq); sn_waits = g_slist_prepend(sn_waits, seq); /* 20 second timeout for apps to start if the launcher doesn't have a timeout */ g_timeout_add_full(G_PRIORITY_DEFAULT, 20 * 1000, sn_wait_timeout, seq, (GDestroyNotify)sn_startup_sequence_unref); change = TRUE; break; case SN_MONITOR_EVENT_CHANGED: /* XXX feedback changed? */ change = TRUE; break; case SN_MONITOR_EVENT_COMPLETED: case SN_MONITOR_EVENT_CANCELED: if ((seq = sequence_find(sn_startup_sequence_get_id(seq)))) { sn_waits = g_slist_remove(sn_waits, seq); g_source_remove_by_user_data(seq); change = TRUE; } break; }; if (change) screen_set_root_cursor(); }
static void context_destroy(struct osc_plugin *plugin, const char *ini_fn) { g_source_remove_by_user_data(ctx); osc_destroy_context(ctx); }
static void on_destroy(GtkWidget* w) { do{ }while( g_source_remove_by_user_data(w) ); }
static void screensaver_free_x11 (ScreenSaver * screensaver) { g_source_remove_by_user_data (screensaver); }
void vfs_dir_finalize( GObject *obj ) { VFSDir * dir = VFS_DIR( obj ); do{} while( g_source_remove_by_user_data( dir ) ); if( G_UNLIKELY( dir->task ) ) { g_signal_handlers_disconnect_by_func( dir->task, on_list_task_finished, dir ); /* FIXME: should we generate a "file-list" signal to indicate the dir loading was cancelled? */ //printf("spacefm: vfs_dir_finalize -> vfs_async_task_cancel\n"); vfs_async_task_cancel( dir->task ); g_object_unref( dir->task ); dir->task = NULL; } if ( dir->monitor ) { vfs_file_monitor_remove( dir->monitor, vfs_dir_monitor_callback, dir ); } if ( dir->path ) { if( G_LIKELY( dir_hash ) ) { g_hash_table_remove( dir_hash, dir->path ); /* There is no VFSDir instance */ if ( 0 == g_hash_table_size( dir_hash ) ) { g_hash_table_destroy( dir_hash ); dir_hash = NULL; vfs_mime_type_remove_reload_cb( mime_cb ); mime_cb = NULL; if( change_notify_timeout ) { g_source_remove( change_notify_timeout ); change_notify_timeout = 0; } g_signal_handler_disconnect( gtk_icon_theme_get_default(), theme_change_notify ); theme_change_notify = 0; } } g_free( dir->path ); g_free( dir->disp_path ); dir->path = dir->disp_path = NULL; } /* g_debug( "dir->thumbnail_loader: %p", dir->thumbnail_loader ); */ if( G_UNLIKELY( dir->thumbnail_loader ) ) { /* g_debug( "FREE THUMBNAIL LOADER IN VFSDIR" ); */ vfs_thumbnail_loader_free( dir->thumbnail_loader ); dir->thumbnail_loader = NULL; } if ( dir->file_list ) { g_list_foreach( dir->file_list, ( GFunc ) vfs_file_info_unref, NULL ); g_list_free( dir->file_list ); dir->file_list = NULL; dir->n_files = 0; } if( dir->changed_files ) { g_slist_foreach( dir->changed_files, (GFunc)vfs_file_info_unref, NULL ); g_slist_free( dir->changed_files ); dir->changed_files = NULL; } if( dir->created_files ) { g_slist_foreach( dir->created_files, (GFunc)g_free, NULL ); g_slist_free( dir->created_files ); dir->created_files = NULL; } g_mutex_free( dir->mutex ); G_OBJECT_CLASS( parent_class ) ->finalize( obj ); }
void MiracBroker::network(MiracNetwork *connection) { while (g_source_remove_by_user_data(&network_source_ptr_)) ; network_.reset(connection); }
static void context_destroy(const char *ini_fn) { g_source_remove_by_user_data(ctx); iio_context_destroy(ctx); }