static void AttachToFrame( wxMenu *menu, wxWindow *win ) { wxWindow *top_frame = win; while (top_frame->GetParent() && !(top_frame->IsTopLevel())) top_frame = top_frame->GetParent(); // support for native hot keys ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget); if ( !g_slist_find( ACCEL_OBJECTS(menu->m_accel), obj ) ) gtk_accel_group_attach( menu->m_accel, obj ); wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *menuitem = node->GetData(); if (menuitem->IsSubMenu()) AttachToFrame( menuitem->GetSubMenu(), win ); node = node->GetNext(); } }
static void print_mode(MODE_REC *rec) { GSList *tmp; char *nicks; if (g_slist_find(channels, rec->channel) == NULL) { /* channel was destroyed while we were waiting.. */ return; } tmp = modes; modes = NULL; nicks = gslist_to_string(rec->nicks, ", "); printformat(rec->channel->server, rec->channel->name, MSGLEVEL_MODES, IRCTXT_CHANMODE_CHANGE, rec->channel->name, rec->mode, nicks); g_free(nicks); modes = tmp; }
static gboolean remove_interface(struct generic_data *data, const char *name) { struct interface_data *iface; iface = find_interface(data->interfaces, name); if (iface == NULL) return FALSE; process_properties_from_interface(data, iface); data->interfaces = g_slist_remove(data->interfaces, iface); if (iface->destroy) { iface->destroy(iface->user_data); iface->user_data = NULL; } /* * Interface being removed was just added, on the same mainloop * iteration? Don't send any signal */ if (g_slist_find(data->added, iface)) { data->added = g_slist_remove(data->added, iface); g_free(iface->name); g_free(iface); return TRUE; } if (data->parent == NULL) { g_free(iface->name); g_free(iface); return TRUE; } data->removed = g_slist_prepend(data->removed, iface->name); g_free(iface); add_pending(data); return TRUE; }
void panel_applet_save_position (AppletInfo *applet_info, const char *id, gboolean immediate) { const char *toplevel_id; AppletData *applet_data; g_return_if_fail (applet_info != NULL); g_return_if_fail (G_IS_OBJECT (applet_info->widget)); if (!immediate) { if (!queued_position_source) queued_position_source = g_timeout_add_seconds (1, (GSourceFunc) panel_applet_position_save_timeout, NULL); if (!g_slist_find (queued_position_saves, applet_info)) queued_position_saves = g_slist_prepend (queued_position_saves, applet_info); return; } if (!(toplevel_id = panel_applet_get_toplevel_id (applet_info))) return; applet_data = g_object_get_data (G_OBJECT (applet_info->widget), PANEL_APPLET_DATA); g_settings_set_string (applet_info->settings, PANEL_OBJECT_TOPLEVEL_ID_KEY, toplevel_id); g_settings_set_enum (applet_info->settings, PANEL_OBJECT_PACK_TYPE_KEY, applet_data->pack_type); g_settings_set_int (applet_info->settings, PANEL_OBJECT_PACK_INDEX_KEY, applet_data->pack_index); }
void set_task_state(Task *tsk, int state) { if (tsk == 0 || state < 0 || state >= TASK_STATE_COUNT) return; if (tsk->current_state != state || hide_task_diff_monitor) { GPtrArray* task_group = task_get_tasks(tsk->win); if (task_group) { for (size_t i=0; i<task_group->len; ++i) { Task* tsk1 = g_ptr_array_index(task_group, i); tsk1->current_state = state; tsk1->area.background = panel1[0].g_task.background[state]; tsk1->area.pixmap = tsk1->state_pix[state]; if (tsk1->state_pix[state] == 0) tsk1->area.redraw = 1; if (state == TASK_ACTIVE && g_slist_find(urgent_list, tsk1)) del_urgent(tsk1); // Show only the active task int hide = 0; if (hide_inactive_tasks) { if (state != TASK_ACTIVE) { hide = 1; } } if (window_get_monitor(tsk->win) != ((Panel*)tsk->area.panel)->monitor && (hide_task_diff_monitor || nb_panel > 1)) { hide = 1; } if (1 - hide != tsk1->area.visible) { tsk1->area.visible = 1 - hide; set_task_redraw(tsk1); Panel *p = (Panel*)tsk->area.panel; tsk->area.resize = 1; p->taskbar->area.resize = 1; p->area.resize = 1; } } panel_refresh = 1; } } }
void remove_task (Task *tsk) { if (!tsk) return; if (panel_mode == MULTI_DESKTOP) { Panel *panel = tsk->area.panel; panel->area.resize = 1; } Window win = tsk->win; // free title and icon just for the first task // even with task_on_all_desktop and with task_on_all_panel //printf("remove_task %s %d\n", tsk->title, tsk->desktop); if (tsk->title) free (tsk->title); int k; for (k=0; k<TASK_STATE_COUNT; ++k) { if (tsk->icon[k]) { imlib_context_set_image(tsk->icon[k]); imlib_free_image(); tsk->icon[k] = 0; if (tsk->state_pix[k]) XFreePixmap(server.dsp, tsk->state_pix[k]); } } Task *tsk2; Taskbar *tskbar; GPtrArray* task_group = g_hash_table_lookup(win_to_task_table, &win); for (size_t i = 0; i<task_group->len; ++i) { tsk2 = g_ptr_array_index(task_group, i); tskbar = tsk2->area.parent; tskbar->area.children = g_slist_remove(tskbar->area.children, tsk2); tskbar->area.resize = 1; if (tsk2 == task_active) task_active = 0; if (tsk2 == task_drag) task_drag = 0; if (g_slist_find(urgent_list, tsk2)) del_urgent(tsk2); free(tsk2); } g_hash_table_remove(win_to_task_table, &win); }
void scan (hp_rec_list_t *hp) { GSList *plist = NULL, *iterator = NULL; void *tmp; /* Step 1: * plist will contain all nodes currently in use somewhere. */ for (int i = 0; i < hp->nthreads; i++) { for (int j = 0; j < hp->K; j++) { tmp = hp->recs[i].node[j]; if (NULL != tmp) { plist = g_slist_prepend(plist, tmp); } } tmp = hp->recs[i].peek; if (NULL != tmp) { plist = g_slist_prepend(plist, tmp); } } /* Step 2: * Free all nodes in my retire list that is not in plist (i.e., not * in use anywhere). */ iterator = rlist; while(iterator) { tmp = iterator->data; iterator = iterator->next; if (!g_slist_find(plist, tmp)) { rlist = g_slist_remove(rlist, tmp); cnt--; hp->hp_node_destructor(tmp); __sync_fetch_and_add(&hp->cnt, 1); } } g_slist_free(plist); }
gboolean hal_device_store_remove (HalDeviceStore *store, HalDevice *device) { if (!g_slist_find (store->devices, device)) return FALSE; store->devices = g_slist_remove (store->devices, device); g_signal_handlers_disconnect_by_func (device, (gpointer)emit_device_property_changed, store); g_signal_handlers_disconnect_by_func (device, (gpointer)emit_device_capability_added, store); g_signal_emit (store, signals[STORE_CHANGED], 0, device, FALSE); g_object_unref (device); return TRUE; }
static void clutter_master_clock_default_add_timeline (ClutterMasterClock *clock, ClutterTimeline *timeline) { ClutterMasterClockDefault *master_clock = (ClutterMasterClockDefault *) clock; gboolean is_first; if (g_slist_find (master_clock->timelines, timeline)) return; is_first = master_clock->timelines == NULL; master_clock->timelines = g_slist_prepend (master_clock->timelines, timeline); if (is_first) { master_clock_schedule_stage_updates (master_clock); _clutter_master_clock_start_running (clock); } }
RESULT test_slist_find () { GSList *list = g_slist_prepend (NULL, "three"); GSList *found; char *data; list = g_slist_prepend (list, "two"); list = g_slist_prepend (list, "one"); data = "four"; list = g_slist_append (list, data); found = g_slist_find (list, data); if (found->data != data) return FAILED ("Find failed"); g_slist_free (list); return OK; }
static void _adg_remove_dependency(AdgModel *model, AdgEntity *entity) { AdgModelPrivate *data; GSList *node; data = model->data; node = g_slist_find(data->dependencies, entity); if (node == NULL) { g_warning(_("%s: attempting to remove the nonexistent dependency " "on the entity with type %s from a model of type %s"), G_STRLOC, g_type_name(G_OBJECT_TYPE(entity)), g_type_name(G_OBJECT_TYPE(model))); return; } data->dependencies = g_slist_delete_link(data->dependencies, node); g_object_unref(entity); }
void* xchat_unhook(xchat_plugin *ph, xchat_hook *hook) { // perl.c trips this if (!g_slist_find(hook_list, hook) || hook->type == HOOK_DELETED) return nullptr; if (hook->type == HOOK_TIMER && hook->tag != 0) fe_timeout_remove(hook->tag); if (hook->type == HOOK_FD && hook->tag != 0) fe_input_remove(hook->tag); hook->type = HOOK_DELETED; // expunge later if (hook->name) free(hook->name); // nullptr for timers & fds if (hook->help_text) free(hook->help_text); // nullptr for non-commands return hook->userdata; }
static const char *get_nicks(Server **server, Channel **channel, void *user_data) { NickMenuData *data = user_data; if (server == NULL) { /* destroy */ server_unref(data->server); g_free(data->nick); g_free(data); return NULL; } if (data->server->disconnected) return NULL; *server = data->server; *channel = g_slist_find(data->server->channels, data->channel) != NULL ? data->channel : NULL; return data->nick; }
void wxMenuBar::Attach( wxFrame *win ) { wxMenuBarBase::Attach(win); wxWindow *top_frame = win; while (top_frame->GetParent() && !(top_frame->IsTopLevel())) top_frame = top_frame->GetParent(); // support for native key accelerators indicated by underscroes ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget); if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) ) gtk_accel_group_attach( m_accel, obj ); wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) { wxMenu *menu = node->GetData(); AttachToFrame( menu, win ); node = node->GetNext(); } }
void _clutter_stage_manager_remove_stage (ClutterStageManager *stage_manager, ClutterStage *stage) { /* this might be called multiple times from a ::dispose, so it * needs to just return without warning */ if (!g_slist_find (stage_manager->stages, stage)) return; stage_manager->stages = g_slist_remove (stage_manager->stages, stage); /* if it's the default stage, get the first available from the list */ if (default_stage == stage) default_stage = stage_manager->stages ? stage_manager->stages->data : NULL; g_signal_emit (stage_manager, manager_signals[STAGE_REMOVED], 0, stage); g_object_unref (stage); }
static gboolean auth_call_complete (AuthCall *call) { NMAuthChain *self; g_return_val_if_fail (call, G_SOURCE_REMOVE); self = call->chain; g_return_val_if_fail (self, G_SOURCE_REMOVE); g_return_val_if_fail (g_slist_find (self->calls, call), G_SOURCE_REMOVE); self->calls = g_slist_remove (self->calls, call); if (!self->calls) { g_assert (!self->idle_id && !self->done); self->idle_id = g_idle_add (auth_chain_finish, self); } auth_call_free (call); return FALSE; }
static void _do_cancel_secrets (NMActRequest *self, GetSecretsInfo *info, gboolean is_disposing) { NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); nm_assert (info && info->self == self); nm_assert (g_slist_find (priv->secrets_calls, info)); priv->secrets_calls = g_slist_remove (priv->secrets_calls, info); nm_settings_connection_cancel_secrets (nm_act_request_get_settings_connection (self), info->call_id); if (info->callback) { gs_free_error GError *error = NULL; nm_utils_error_set_cancelled (&error, is_disposing, "NMActRequest"); info->callback (self, info, NULL, error, info->callback_data); } _get_secrets_info_free (info); }
static int sig_check_linecache(void) { GSList *tmp, *caches; time_t now; now = time(NULL); caches = NULL; for (tmp = views; tmp != NULL; tmp = tmp->next) { TEXT_BUFFER_VIEW_REC *rec = tmp->data; if (g_slist_find(caches, rec->cache) != NULL) continue; caches = g_slist_append(caches, rec->cache); g_hash_table_foreach_remove(rec->cache->line_cache, (GHRFunc) line_cache_check_remove, &now); } g_slist_free(caches); return 1; }
/* * main * * program begins here. */ int main (int argc, char *argv[]) { int nIndex; GSList *list, *node; char buffer[88]; /* --- Must be set to NULL --- */ list = NULL; /* --- Insert the names --- */ list = g_slist_insert_sorted (list, "Fred", CompareNames); list = g_slist_insert_sorted (list, "Joe", CompareNames); list = g_slist_insert_sorted (list, "Susie", CompareNames); list = g_slist_insert_sorted (list, "Frank", CompareNames); list = g_slist_insert_sorted (list, "Wilma", CompareNames); list = g_slist_insert_sorted (list, "Mary", CompareNames); strcpy (buffer, "Wilma"); node = g_slist_find (list, buffer); if (node) { g_print ("found..\n"); } else { g_print ("not found..\n"); } /* --- Loop through the list --- */ for (nIndex = 0; node = g_slist_nth (list, nIndex); nIndex++) { /* --- Dump out the contents and look up the index --- */ g_print ("%s position %d\n", (char *) node->data, g_slist_index (list, node->data)); } g_print ("-----\n"); /* --- Another way to print each of the data elements. --- */ g_slist_foreach (list, (GFunc) PrintNames, list); }
static void client_disconnected (GsmClient *client, gpointer data) { GsmSession *session = data; gboolean is_condition_client = FALSE; session->clients = g_slist_remove (session->clients, client); session->shutdown_clients = g_slist_remove (session->shutdown_clients, client); session->interact_clients = g_slist_remove (session->interact_clients, client); session->phase2_clients = g_slist_remove (session->phase2_clients, client); if (g_slist_find (session->condition_clients, client)) { session->condition_clients = g_slist_remove (session->condition_clients, client); is_condition_client = TRUE; } if (session->phase != GSM_SESSION_PHASE_SHUTDOWN && gsm_client_get_autorestart (client) && !is_condition_client) { GError *error = NULL; gsm_client_restart (client, &error); if (error) { g_warning ("Error on restarting session client: %s", error->message); g_clear_error (&error); } } g_object_unref (client); }
void * hexchat_unhook (hexchat_plugin *ph, hexchat_hook *hook) { /* perl.c trips this */ if (!g_slist_find (hook_list, hook) || hook->type == HOOK_DELETED) return NULL; if (hook->type == HOOK_TIMER && hook->tag != 0) fe_timeout_remove (hook->tag); if (hook->type == HOOK_FD && hook->tag != 0) fe_input_remove (hook->tag); hook->type = HOOK_DELETED; /* expunge later */ if (hook->name) free (hook->name); /* NULL for timers & fds */ if (hook->help_text) free (hook->help_text); /* NULL for non-commands */ return hook->userdata; }
void module_file_unload(MODULE_FILE_REC *file) { MODULE_REC *root; root = file->root; root->files = g_slist_remove(root->files, file); if (file->initialized) signal_emit("module unloaded", 2, file->root, file); #ifdef HAVE_GMODULE if (file->gmodule != NULL) module_file_deinit_gmodule(file); #endif g_free(file->name); g_free(file->defined_module_name); g_free(file); if (root->files == NULL && g_slist_find(modules, root) != NULL) module_unload(root); }
gboolean mcap_delete_mdl(struct mcap_mdl *mdl, mcap_mdl_notify_cb delete_cb, gpointer user_data, GDestroyNotify destroy, GError **err) { struct mcap_mcl *mcl= mdl->mcl; struct mcap_mdl_op_cb *con; GSList *l; l = g_slist_find(mcl->mdls, mdl); if (!l) { g_set_error(err, MCAP_ERROR, MCAP_ERROR_INVALID_MDL, "%s" , error2str(MCAP_INVALID_MDEP)); return FALSE; } if (mdl->state == MDL_WAITING) { g_set_error(err, MCAP_ERROR, MCAP_ERROR_FAILED, "Mdl is not created"); return FALSE; } mdl->state = MDL_DELETING; con = g_new0(struct mcap_mdl_op_cb, 1); con->mdl = mcap_mdl_ref(mdl); con->cb.notify = delete_cb; con->destroy = destroy; con->user_data = user_data; if (!send_delete_req(mcl, con, mdl->mdlid, err)) { mcap_mdl_unref(con->mdl); g_free(con); return FALSE; } return TRUE; }
static void ipc_master_takeover_fail( struct bitlbee_child *child, gboolean both ) { if( child == NULL || g_slist_find( child_list, child ) == NULL ) return; if( both && child->to_child != NULL ) ipc_master_takeover_fail( child->to_child, FALSE ); if( child->to_fd > -1 ) { /* Send this error only to the new connection, which can be recognised by to_fd being set. */ if( write( child->ipc_fd, "TAKEOVER FAIL\r\n", 15 ) != 15 ) { ipc_master_free_one( child ); return; } close( child->to_fd ); child->to_fd = -1; } child->to_child = NULL; }
wifi_profile_t *get_next_profile(wifi_profile_t *curr_profile) { // Return first profile (if present), if NULL argument is passed if(NULL == curr_profile) { if(NULL != wifi_profile_list) { return (wifi_profile_t *)(wifi_profile_list->data); } else return NULL; } GSList *node = g_slist_find(wifi_profile_list, curr_profile); if(node->next != NULL) { wifi_profile_t *profile = (wifi_profile_t *)(node->next->data); return profile; } return NULL; }
static gboolean plugins_before_load_cb(WebKitDOMDOMWindow *win, WebKitDOMEvent *event, GList *gl) { WebKitDOMElement *element = (void*)webkit_dom_event_get_src_element(event); char *tagname = webkit_dom_element_get_tag_name(element); char *type = webkit_dom_element_get_attribute(element, "type"); if ( (!g_strcmp0(type, "application/x-shockwave-flash") && (! g_ascii_strcasecmp(tagname, "object") || ! g_ascii_strcasecmp(tagname, "embed")) ) && ! g_slist_find(ALLOWED(gl), element) ) { VIEW(gl)->plugins->status |= PLUGIN_STATUS_HAS_PLUGIN; webkit_dom_event_prevent_default(event); webkit_dom_event_stop_propagation(event); plugins_create_click_element(element, gl); } g_object_unref(element); g_free(tagname); g_free(type); return true; }
static void auth_cb(DBusError *derr, void *user_data) { struct avctp *session = user_data; if (!g_slist_find(sessions, session)) { error("avctp auth_cb: session no longer exists"); return; } if (derr && dbus_error_is_set(derr)) { error("Access denied: %s", derr->message); if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) { debug("Canceling authorization request"); service_cancel_auth(&session->src, &session->dst); } avctp_unref(session); return; } avctp_connect_session(session); }
void vfs_dir_emit_file_deleted( VFSDir* dir, const char* file_name, VFSFileInfo* file ) { GList* l; VFSFileInfo* file_found; if( G_UNLIKELY( 0 == strcmp(file_name, dir->path) ) ) { /* Special Case: The directory itself was deleted... */ file = NULL; /* clear the whole list */ g_mutex_lock( dir->mutex ); g_list_foreach( dir->file_list, (GFunc)vfs_file_info_unref, NULL ); g_list_free( dir->file_list ); dir->file_list = NULL; g_mutex_unlock( dir->mutex ); g_signal_emit( dir, signals[ FILE_DELETED_SIGNAL ], 0, file ); return; } l = vfs_dir_find_file( dir, file_name, file ); if ( G_LIKELY( l ) ) { file_found = vfs_file_info_ref( ( VFSFileInfo* ) l->data ); if( !g_slist_find( dir->changed_files, file_found ) ) { dir->changed_files = g_slist_prepend( dir->changed_files, file_found ); if ( 0 == change_notify_timeout ) { change_notify_timeout = g_timeout_add_full( G_PRIORITY_LOW, 200, notify_file_change, NULL, NULL ); } } else vfs_file_info_unref( file_found ); } }
/** * empathy_irc_network_set_server_position: * @network: an #EmpathyIrcNetwork * @server: the #EmpathyIrcServer to move * @pos: the position to move the server. If this is negative, or is larger than * the number of servers in the list, the server is moved to the end of the * list. * * Move an #EmpathyIrcServer in the servers list of the given * #EmpathyIrcNetwork. * */ void empathy_irc_network_set_server_position (EmpathyIrcNetwork *self, EmpathyIrcServer *server, gint pos) { EmpathyIrcNetworkPriv *priv; GSList *l; g_return_if_fail (EMPATHY_IS_IRC_NETWORK (self)); g_return_if_fail (server != NULL && EMPATHY_IS_IRC_SERVER (server)); priv = GET_PRIV (self); l = g_slist_find (priv->servers, server); if (l == NULL) return; priv->servers = g_slist_delete_link (priv->servers, l); priv->servers = g_slist_insert (priv->servers, server, pos); g_signal_emit (self, signals[MODIFIED], 0); }
void obex_object_set_io_flags(void *object, int flags, int err) { GSList *l; for (l = watches; l;) { struct io_watch *watch = l->data; l = l->next; if (watch->object != object) continue; if (watch->func(object, flags, err, watch->user_data) == TRUE) continue; if (g_slist_find(watches, watch) == NULL) continue; watches = g_slist_remove(watches, watch); g_free(watch); } }