static AtkObject * gtk_scrolled_window_accessible_ref_child (AtkObject *obj, gint child) { GtkWidget *widget; GtkScrolledWindow *scrolled_window; GtkWidget *hscrollbar, *vscrollbar; GList *children, *tmp_list; gint n_children; AtkObject *accessible = NULL; g_return_val_if_fail (child >= 0, NULL); widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); if (widget == NULL) return NULL; scrolled_window = GTK_SCROLLED_WINDOW (widget); hscrollbar = gtk_scrolled_window_get_hscrollbar (scrolled_window); vscrollbar = gtk_scrolled_window_get_vscrollbar (scrolled_window); children = gtk_container_get_children (GTK_CONTAINER (widget)); n_children = g_list_length (children); if (child == n_children) { if (gtk_scrolled_window_get_hscrollbar (scrolled_window)) accessible = gtk_widget_get_accessible (hscrollbar); else if (gtk_scrolled_window_get_vscrollbar (scrolled_window)) accessible = gtk_widget_get_accessible (vscrollbar); } else if (child == n_children + 1 && gtk_scrolled_window_get_hscrollbar (scrolled_window) && gtk_scrolled_window_get_vscrollbar (scrolled_window)) accessible = gtk_widget_get_accessible (vscrollbar); else if (child < n_children) { tmp_list = g_list_nth (children, child); if (tmp_list) accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data)); } g_list_free (children); if (accessible) g_object_ref (accessible); return accessible; }
void wxComboBox::Delete(unsigned int n) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) { wxCHECK_RET( IsValid(n), wxT("invalid index") ); GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); gtk_combo_box_remove_text( combobox, n ); } else #endif { GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list ); GList *child = g_list_nth( listbox->children, n ); if (!child) { wxFAIL_MSG(wxT("wrong index")); return; } DisableEvents(); GList *list = g_list_append( (GList*) NULL, child->data ); gtk_list_remove_items( listbox, list ); g_list_free( list ); EnableEvents(); } wxList::compatibility_iterator node = m_clientObjectList.Item( n ); if (node) { wxClientData *cd = (wxClientData*)node->GetData(); if (cd) delete cd; m_clientObjectList.Erase( node ); } node = m_clientDataList.Item( n ); if (node) m_clientDataList.Erase( node ); InvalidateBestSize(); }
MameExec * mame_exec_list_nth (MameExecList *list, guint index) { MameExec *exec; GList *list_ptr; g_return_val_if_fail (list != NULL, NULL); if (g_list_length (list->priv->list) == 0) return NULL; list_ptr = g_list_nth (list->priv->list, index); exec = (MameExec *) list_ptr->data; return exec; }
GList *list_truncate(GList *list, gint len) { GList *lp = g_list_nth(list, len); // 最初の element は 0。 if (lp == NULL) return list; // list がそんなに長くなかった。 if (lp->prev == NULL) { // len=0。 g_list_free_full(list, g_free); return NULL; } lp->prev->next = NULL; lp->prev = NULL; g_list_free_full(lp, g_free); return list; }
/** * Move the viewable part of the score up * */ void move_viewport_up (DenemoProject * gui) { if(Denemo.non_interactive) return; staffnode *staff_iterator; staff_iterator = g_list_nth (gui->movement->thescore, gui->movement->top_staff - 1); while (gui->movement->currentstaffnum < gui->movement->top_staff || !((DenemoStaff *) staff_iterator->data)->voicecontrol & DENEMO_PRIMARY) { gui->movement->top_staff--; staff_iterator = staff_iterator->prev; } set_bottom_staff (gui); update_vscrollbar (gui); }
void cd_do_select_nth_entry_in_listing (int iNumEntry) { myData.pListing->fPreviousOffset = myData.pListing->fCurrentOffset; int i = MIN (iNumEntry, myData.pListing->iNbEntries - 1); myData.pListing->pCurrentEntry = g_list_nth (myData.pListing->pEntries, i); myData.pListing->fAimedOffset = i * (myDialogs.dialogTextDescription.iSize + 2); myData.pListing->iCurrentEntryAnimationCount = NB_STEPS_FOR_CURRENT_ENTRY; myData.pListing->iScrollAnimationCount = NB_STEPS_FOR_SCROLL; myData.pListing->iTitleOffset = 0; myData.pListing->sens = 1; cairo_dock_launch_animation (CAIRO_CONTAINER (myData.pListing)); cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing)); }
gboolean playlist_select_invert(int num) { GList *list; gboolean retv = FALSE; PL_LOCK(); if ((list = g_list_nth(get_playlist(), num)) != NULL) { PlaylistEntry *entry = list->data; entry->selected = !entry->selected; retv = TRUE; } PL_UNLOCK(); return retv; }
static gint view_column_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n) { ViewColumnModel *view_model = (ViewColumnModel *)tree_model; if (parent) return FALSE; iter->stamp = view_model->stamp; iter->user_data = g_list_nth ((GList *)view_model->columns, n); return (iter->user_data != NULL); }
static void edit_window_list (const Dlg_head * h) { const size_t offset = 2; /* skip menu and buttonbar */ const size_t dlg_num = g_list_length (h->widgets) - offset; int lines, cols; Listbox *listbox; GList *w; int i = 0; int rv; lines = min ((size_t) (LINES * 2 / 3), dlg_num); cols = COLS * 2 / 3; listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]"); for (w = h->widgets; w != NULL; w = g_list_next (w)) if (edit_widget_is_editor ((Widget *) w->data)) { WEdit *e = (WEdit *) w->data; char *fname; if (e->filename_vpath == NULL) fname = g_strdup_printf ("%c [%s]", e->modified ? '*' : ' ', _("NoName")); else { char *fname2; fname2 = vfs_path_to_str (e->filename_vpath); fname = g_strdup_printf ("%c%s", e->modified ? '*' : ' ', fname2); g_free (fname2); } listbox_add_item (listbox->list, LISTBOX_APPEND_AT_END, get_hotkey (i++), str_term_trim (fname, listbox->list->widget.cols - 2), NULL); g_free (fname); } rv = g_list_position (h->widgets, h->current) - offset; listbox_select_entry (listbox->list, rv); rv = run_listbox (listbox); if (rv >= 0) { w = g_list_nth (h->widgets, rv + offset); dlg_set_top_widget (w->data); } }
static GkrellmStyle * get_style_from_list(GList *list, gint n) { GList *l; GkrellmStyle *style; l = g_list_nth(list, n); if (l == NULL || l->data == NULL) l = list; if (l->data == NULL) { g_warning("Warning: NULL style returned %d\n", n); abort(); } style = (GkrellmStyle *) l->data; return style; }
/** * \fn void config_probes_remove(ConfigProbes *w, int nProbesOld, int nProbes) * \brief Function to remove probes. * \param w * \brief Probes configuration structure. * \param nProbesOld * \brief Old probes number. * \param nProbes * \brief New probes number. */ void config_probes_remove (ConfigProbes * w, int nProbesOld, int nProbes) { int i, j; GList *element, *next; element = g_list_nth (w->list, 3 * nProbes); for (i = nProbes; i < nProbesOld; ++i) { for (j = 0; j < 3; ++j) { next = element->next; gtk_widget_destroy (GTK_WIDGET (element->data)); w->list = g_list_remove_link (w->list, element); element = next; } } }
static void add_to_history(ConboyNote *note) { AppData *app_data = app_data_get(); /* Consistency check */ if (app_data->current_element == NULL) { g_assert(app_data->note_history == NULL); } /* Consistency check */ if (app_data->note_history == NULL) { g_assert(app_data->current_element == NULL); } /* If we are currently not at the end of the history, we need to remove the 'future' before appending */ /* Remove everything from the current position to the end */ if (app_data->current_element != g_list_last(app_data->note_history)) { gint pos = g_list_position(app_data->note_history, app_data->current_element); gint len = g_list_length(app_data->note_history); GList *to_remove = NULL; for (; pos < len; pos++) { GList *element = g_list_nth(app_data->note_history, pos); to_remove = g_list_prepend(to_remove, element); } GList *iter = to_remove; while (iter) { GList *element = (GList*) iter->data; app_data->note_history = g_list_remove_link(app_data->note_history, element); g_list_free(element); iter = iter->next; } g_list_free(to_remove); } if (g_list_length(app_data->note_history) >= 20) { g_printerr("INFO: History is too long. Removing oldes element. \n"); app_data->note_history = g_list_delete_link(app_data->note_history, app_data->note_history); } app_data->note_history = g_list_append(app_data->note_history, note); app_data->current_element = g_list_last(app_data->note_history); }
static GtkTreeViewColumn* gt_tree_view_find_column(GtkTreeView *tree, int ind) { GtkTreeViewColumn *col=NULL; GList *cols; GList *iter; if (!tree) return NULL; cols=gtk_tree_view_get_columns(GTK_TREE_VIEW(tree)); if (!cols) return NULL; iter=g_list_nth(cols,(guint)ind + HIDDEN_COL); if (iter) { col=(GtkTreeViewColumn*)iter->data; } g_list_free(cols); return col; }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_delItem (JNIEnv *env, jobject obj, jint index) { void *ptr; GList *list; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); list = gtk_container_get_children (GTK_CONTAINER (ptr)); list = g_list_nth (list, index); gtk_container_remove (GTK_CONTAINER (ptr), GTK_WIDGET (list->data)); gdk_threads_leave (); }
void playlist_set_position(int pos) { GList *node; gboolean restart_playing = FALSE; PL_LOCK(); if (!playlist) { PL_UNLOCK(); return; } node = g_list_nth(playlist, pos); if (!node) { PL_UNLOCK(); return; } if (get_input_playing()) { /* We need to stop before changing playlist_position */ PL_UNLOCK(); input_stop(); PL_LOCK(); restart_playing = TRUE; } playlist_position = node->data; PL_UNLOCK(); playlist_check_pos_current(); if (restart_playing) playlist_play(); else { mainwin_set_info_text(); playlistwin_update_list(); } /* * Regenerate the shuffle list when the user set a position * manually */ playlist_generate_shuffle_list(); }
/* * call-seq: * [](index) -> Object or nil * * Given an integer +index+, return the item at that position in the collection. */ static VALUE rbpod_collection_get(VALUE self, VALUE key) { GList *current = NULL, *collection = TYPED_DATA_PTR(self, GList); VALUE klass = rb_funcall(self, rb_intern("type"), 0); if (FIXNUM_P(key) == FALSE) { return Qnil; } current = g_list_nth(collection, FIX2INT(key)); if (current == NULL) { return Qnil; } return rb_class_new_instance_with_data(0, NULL, klass, current->data); }
static GList *generate_random_list(SlideShowData *ss) { GList *src_list = NULL; GList *list = NULL; GList *work; src_list = generate_list(ss); while(src_list) { gint p = (double)rand() / ((double)RAND_MAX + 1.0) * g_list_length(src_list); work = g_list_nth(src_list, p); list = g_list_prepend(list, work->data); src_list = g_list_remove(src_list, work->data); } return list; }
void playlist_read_info(int pos) { GList *node; PL_LOCK(); if ((node = g_list_nth(get_playlist(), pos)) != NULL) { PlaylistEntry *entry = node->data; if (entry->title) g_free(entry->title); entry->title = NULL; entry->length = -1; playlist_get_info_entry(entry); } PL_UNLOCK(); playlistwin_update_list(); }
void gtk_text_region_get_iterator (GtkTextRegion *region, GtkTextRegionIterator *iter, guint start) { GtkTextRegionIteratorReal *real; g_return_if_fail (region != NULL); g_return_if_fail (iter != NULL); real = (GtkTextRegionIteratorReal *)iter; /* region->subregions may be NULL, -> end iter */ real->region = region; real->subregions = g_list_nth (region->subregions, start); real->region_time_stamp = region->time_stamp; }
static void row_removed_cb (ClutterModel *model, ClutterModelIter *iter, MxListView *list_view) { GList *children; GList *l; ClutterActor *child; if (list_view->priv->is_frozen) return; children = clutter_actor_get_children (CLUTTER_ACTOR (list_view)); l = g_list_nth (children, clutter_model_iter_get_row (iter)); child = (ClutterActor *) l->data; clutter_actor_remove_child (CLUTTER_ACTOR (list_view), child); g_list_free (children); }
void fr_process_set_arg_at (FrProcess *process, int n_comm, int n_arg, const char *arg_value) { FrCommandInfo *info; GList *arg; g_return_if_fail (process != NULL); info = g_ptr_array_index (process->priv->comm, n_comm); arg = g_list_nth (info->args, n_arg); g_return_if_fail (arg != NULL); g_free (arg->data); arg->data = g_strdup (arg_value); }
bool wxCheckListBox::IsChecked(unsigned int index) const { wxCHECK_MSG( m_list != NULL, false, wxT("invalid checklistbox") ); GList *child = g_list_nth( m_list->children, index ); if (child) { GtkBin *bin = GTK_BIN( child->data ); GtkLabel *label = GTK_LABEL( bin->child ); wxString str( wxGTK_CONV_BACK( label->label ) ); return str.GetChar(1) == wxCHECKLBOX_CHECKED; } wxFAIL_MSG(wxT("wrong checklistbox index")); return false; }
static void tny_gtk_attach_list_model_iterator_nth (TnyIterator *self, guint nth) { TnyGtkAttachListModelIterator *me = (TnyGtkAttachListModelIterator*) self; if (G_UNLIKELY (!me || !me->current || !me->model)) return; /* Move the iterator to the nth node. We'll count from zero, so we start with the first node of which we know the model stored a reference. */ g_mutex_lock (me->model->iterator_lock); me->current = g_list_nth (me->model->first, nth); g_mutex_unlock (me->model->iterator_lock); return; }
void playlist_fileinfo(int pos) { char *path = NULL; GList *node; PL_LOCK(); if ((node = g_list_nth(get_playlist(), pos)) != NULL) { PlaylistEntry *entry = node->data; path = g_strdup(entry->filename); } PL_UNLOCK(); if (path) { input_file_info_box(path); g_free(path); } }
void dt_dev_reload_history_items(dt_develop_t *dev) { dt_dev_pop_history_items(dev, 0); // remove unused history items: GList *history = g_list_nth(dev->history, dev->history_end); while(history) { GList *next = g_list_next(history); dt_dev_history_item_t *hist = (dt_dev_history_item_t *)(history->data); free(hist->params); free(hist->blend_params); free(history->data); dev->history = g_list_delete_link(dev->history, history); history = next; } dt_dev_read_history(dev); dt_dev_pop_history_items(dev, dev->history_end); }
void dialog_switch_list (void) { const size_t dlg_num = g_list_length (mc_dialogs); int lines, cols; Listbox *listbox; GList *h; int i = 0; int rv; if (mc_global.widget.midnight_shutdown || mc_current == NULL) return; lines = min ((size_t) (LINES * 2 / 3), dlg_num); cols = COLS * 2 / 3; listbox = create_listbox_window (lines, cols, _("Screens"), "[Screen selector]"); for (h = mc_dialogs; h != NULL; h = g_list_next (h)) { Dlg_head *dlg; char *title; dlg = (Dlg_head *) h->data; if ((dlg != NULL) && (dlg->get_title != NULL)) title = dlg->get_title (dlg, listbox->list->widget.cols - 2); /* FIXME! */ else title = g_strdup (""); listbox_add_item (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, NULL); g_free (title); } listbox_select_entry (listbox->list, dlg_num - 1 - g_list_position (mc_dialogs, mc_current)); rv = run_listbox (listbox); if (rv >= 0) { h = g_list_nth (mc_dialogs, dlg_num - 1 - rv); dialog_switch_goto (h); } }
/********************************************************************\ * gnc_query_list_set_query_sort * * sets the sorting order of entries in the list * * * * Args: list - list to change the sort order for * * new_column - is this a new column (so should we set the * * query sort order or just set the 'increasing' * * Returns: nothing * \********************************************************************/ static void gnc_query_list_set_query_sort (GNCQueryList *list, gboolean new_column) { gboolean sort_order = list->increasing; GList *node; GNCSearchParam *param; /* Find the column parameter definition */ node = g_list_nth(list->column_params, list->sort_column); param = node->data; /* If we're asked to invert numerics, and if this is a numeric or * debred column, then invert the sort order. */ if (list->numeric_inv_sort) { const char *type = gnc_search_param_get_param_type (param); if (!safe_strcmp(type, QOF_TYPE_NUMERIC) || !safe_strcmp(type, QOF_TYPE_DEBCRED)) sort_order = !sort_order; } /* Set the sort order for the engine, if the key changed */ if (new_column) { GSList *p1, *p2; p1 = gnc_search_param_get_param_path(param); p2 = g_slist_prepend(NULL, QUERY_DEFAULT_SORT); qof_query_set_sort_order (list->query, p1, p2, NULL); } qof_query_set_sort_increasing (list->query, sort_order, sort_order, sort_order); /* * Recompute the list. Is this really necessary? Why not just sort * the rows already in the clist? Answer: it would be an n-squared * algorithm to get the clist to match the resulting list. */ gnc_query_list_refresh(list); }
/* at this point we're in html.c and have the cur_pid */ void set_html_links(xmlNode *action, char * buf1) { char /**content,*/ *new_content; char id[256]; guint glist_index; int i; GList *glist; resource *element; new_content = xmlNodeGetContent(action); /* get boundary quotes out of string */ //new_content = set_contents(content); for(; *new_content != '\0'; new_content++) { switch (*new_content) { case '$': i = 0; new_content++; while (isalnum (*new_content) || *new_content == '_') { id[i] = *new_content; i++; new_content++; } id[i] = '\0'; glist_index = lookup_rsc_name(id); glist = g_list_nth(table[cur_pid].res, (guint) glist_index); if (glist) element = (resource *)glist->data; if (glist && strcmp (element->value, "$$") != 0) { set_href(buf1, glist); } else { if (glist) strcat (buf1, element->name); } strncat (buf1, new_content, 1); break; default : strncat (buf1, new_content, 1); } } }
GtkLabel *get_label_from_button( GtkButton *btn ) { if( btn == NULL ) return NULL; GList *ls = gtk_container_children( GTK_CONTAINER( btn ) ); if( ls == NULL ) return NULL; GList *p = g_list_nth( ls, 0 ); if( p == NULL ) return NULL; GtkLabel *label = GTK_LABEL( p->data ); if( label == NULL ) return NULL; return label; }
/* * JConfigStanza *j_config_get_stanza_nth(JConfig *cf, * const gchar *stanza_name, * guint n) * * Retreives the nth stanza with the given name, or NULL if * that does not exist */ JConfigStanza *j_config_get_stanza_nth(JConfig *cf, const gchar *stanza_name, guint n) { JConfigStanza *cfs; GList *elem; g_return_val_if_fail(cf != NULL, NULL); g_return_val_if_fail(stanza_name != NULL, NULL); elem = g_hash_table_lookup(cf->stanzas, stanza_name); if (elem == NULL) return(NULL); elem = g_list_nth(elem, n); cfs = elem != NULL ? (JConfigStanza *)elem->data : NULL; return(cfs); } /* j_config_get_stanza_nth() */