static void move_row (chan *ch, int delta, GtkTreeIter *parent) { GtkTreeStore *store = ch->cv->store; GtkTreeIter *src = &ch->iter; GtkTreeIter dest = ch->iter; GtkTreePath *dest_path; if (delta < 0) /* down */ { if (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &dest)) gtk_tree_store_swap (store, src, &dest); else /* move to top */ gtk_tree_store_move_after (store, src, NULL); } else { dest_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &dest); if (gtk_tree_path_prev (dest_path)) { gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &dest, dest_path); gtk_tree_store_swap (store, src, &dest); } else { /* move to bottom */ gtk_tree_store_move_before (store, src, NULL); } gtk_tree_path_free (dest_path); } }
void move_down (GtkButton *button, gpointer user_data) { GtkTreeIter first_iter, *second_iter; GtkTreeSelection *selected; Widgets *widgets = (Widgets*)user_data; selected = gtk_tree_view_get_selection (widgets->tree); if(selected == NULL) { return 0; } gtk_tree_selection_get_selected (selected, NULL, &first_iter); //gtk_tree_store_remove (store, &first_iter); second_iter = gtk_tree_iter_copy (&first_iter); if(gtk_tree_model_iter_next (widgets->store, second_iter)) { gtk_tree_store_swap (widgets->store, &first_iter, second_iter); } }
int clip_GTK_TREESTORESWAP(ClipMachine * ClipMachineMemory) { C_object *cstree = _fetch_co_arg(ClipMachineMemory); C_object *citer1 = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); C_object *citer2 = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3)); CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType); CHECKCOBJ(cstree, GTK_IS_TREE_STORE(cstree->object)); CHECKCOBJ(citer1, GTK_IS_TREE_ITER(citer1->object)); CHECKCOBJ(citer2, GTK_IS_TREE_ITER(citer2->object)); gtk_tree_store_swap(GTK_TREE_STORE(cstree->object), GTK_TREE_ITER(citer1->object), GTK_TREE_ITER(citer2->object)); return 0; err: return 1; }
static VALUE rg_swap(VALUE self, VALUE iter1, VALUE iter2) { gtk_tree_store_swap(_SELF(self), RVAL2GTKTREEITER(iter1), RVAL2GTKTREEITER(iter2)); return self; }