void fm_folder_model_file_deleted(FmFolderModel* model, FmFileInfo* file) { GSequenceIter *seq_it; /* not required for hidden files */ gboolean update_view; #if 0 /* If there is no file info, that means the dir itself was deleted. */ if( G_UNLIKELY(!file) ) { /* Clear the whole list */ GSequenceIter *items_it = g_sequence_get_begin_iter(model->items); path = gtk_tree_path_new_from_indices(0, -1); while( !g_sequence_iter_is_end(items_it) ) { gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), path); file = (VFSFileInfo*)g_sequence_get(items_it); items_it = g_sequence_iter_next(it); vfs_file_info_unref(file); } for( l = model->items; l; l = model->items ) { gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), path); file = (VFSFileInfo*)l->data; model->items = g_list_delete_link(model->items, l); vfs_file_info_unref(file); } g_sequence_remove_range( g_sequence_get_begin_iter(model->items), g_sequence_get_end_iter(model->items) ); gtk_tree_path_free(path); return; } #endif if( !model->show_hidden && fm_file_info_is_hidden(file) ) /* if this is a hidden file */ { update_view = FALSE; seq_it = g_sequence_get_begin_iter(model->hidden); } else { update_view = TRUE; seq_it = g_sequence_get_begin_iter(model->items); } while( !g_sequence_iter_is_end(seq_it) ) { FmFolderItem* item = (FmFolderItem*)g_sequence_get(seq_it); if( item->inf == file ) break; seq_it = g_sequence_iter_next(seq_it); } if( update_view ) { GtkTreePath* path = gtk_tree_path_new_from_indices(g_sequence_iter_get_position(seq_it), -1); gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), path); gtk_tree_path_free(path); } model->iter_age++; g_sequence_remove(seq_it); }
static gboolean acwin_move_selection(BluefishTextView * btv, gint keyval) { GtkTreeSelection *selection; GtkTreeIter it; GtkTreeModel *model; GtkTreePath *path; selection = gtk_tree_view_get_selection(ACWIN(btv->autocomp)->tree); if (gtk_tree_selection_get_selected(selection, &model, &it)) { gboolean retval = TRUE; gint i, rows = 12, *indices = NULL; path = gtk_tree_model_get_path(model, &it); indices = gtk_tree_path_get_indices(path); switch (keyval) { case GDK_Up: /* move the selection one up */ retval = gtk_tree_path_prev(path); break; case GDK_Down: gtk_tree_path_next(path); break; case GDK_Page_Down: i = MIN(gtk_tree_model_iter_n_children(model, NULL) - 1, indices[0] + rows); gtk_tree_path_free(path); path = gtk_tree_path_new_from_indices(i, -1); break; case GDK_Page_Up: i = MAX(indices[0] - rows, 0); gtk_tree_path_free(path); path = gtk_tree_path_new_from_indices(i, -1); break; case GDK_Home: gtk_tree_path_free(path); path = gtk_tree_path_new_first(); break; case GDK_End: gtk_tree_path_free(path); i = gtk_tree_model_iter_n_children(model, NULL); path = gtk_tree_path_new_from_indices(i - 1, -1); break; default: return FALSE; break; } if (gtk_tree_model_get_iter(model, &it, path)) { gtk_tree_selection_select_iter(selection, &it); gtk_tree_view_scroll_to_cell(ACWIN(btv->autocomp)->tree, path, NULL, FALSE, 0, 0); } else retval = FALSE; gtk_tree_path_free(path); return retval; } else { /* set selection */ } return FALSE; }
/* Test for GNOME bugzilla bug 163214. Invalidate a couple of rows, * then scroll to one of these. */ static void test_bug163214 (ScrollFixture *fixture, gconstpointer test_data) { int i; GtkListStore *store; GtkTreePath *path; g_test_bug ("163214"); gtk_widget_show_all (fixture->window); /* Make sure all events have been processed and the window * is visible. */ while (gtk_events_pending ()) gtk_main_iteration (); store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fixture->tree_view))); /* Invalidate a page of rows */ for (i = 100; i < 110; i++) { GtkTreeIter iter; gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter, NULL, i); gtk_list_store_set (store, &iter, 0, "Row", -1); } /* Then scroll to that page. */ path = gtk_tree_path_new_from_indices (105, -1); scroll (fixture, path, TRUE, 0.5); gtk_tree_path_free (path); /* Make sure all events have been processed and the window * is visible. */ while (gtk_events_pending ()) gtk_main_iteration (); store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fixture->tree_view))); /* Invalidate a page of rows */ for (i = 300; i < 310; i++) { GtkTreeIter iter; gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter, NULL, i); gtk_list_store_set (store, &iter, 0, "Row", -1); } /* Then scroll to the first row */ path = gtk_tree_path_new_from_indices (0, -1); scroll (fixture, path, TRUE, 0.5); gtk_tree_path_free (path); }
void fm_folder_model_set_show_hidden(FmFolderModel* model, gboolean show_hidden) { FmFolderItem* item; GList *l, *next; GSequenceIter *items_it; g_return_if_fail(model != NULL); if( model->show_hidden == show_hidden ) return; model->show_hidden = show_hidden; if( show_hidden ) /* add previously hidden items back to the list */ { GSequenceIter *hidden_it = g_sequence_get_begin_iter(model->hidden); while( !g_sequence_iter_is_end(hidden_it) ) { GtkTreeIter it; GSequenceIter *next_hidden_it; GSequenceIter *insert_item_it = g_sequence_search(model->items, g_sequence_get(hidden_it), fm_folder_model_compare, model); next_hidden_it = g_sequence_iter_next(hidden_it); item = (FmFolderItem*)g_sequence_get(hidden_it); it.stamp = model->stamp; it.user_data = hidden_it; g_sequence_move(hidden_it, insert_item_it); GtkTreePath *path = gtk_tree_path_new_from_indices(g_sequence_iter_get_position(hidden_it), -1); gtk_tree_model_row_inserted(GTK_TREE_MODEL(model), path, &it); gtk_tree_path_free(path); hidden_it = next_hidden_it; } } else /* move invisible items to hidden list */ { GSequenceIter *items_it = g_sequence_get_begin_iter(model->items); while( !g_sequence_iter_is_end(items_it) ) { GtkTreePath* tp; GSequenceIter *next_item_it = g_sequence_iter_next(items_it); item = (FmFolderItem*)g_sequence_get(items_it); if( fm_file_info_is_hidden(item->inf) ) { gint delete_pos = g_sequence_iter_get_position(items_it); g_sequence_move( items_it, g_sequence_get_begin_iter(model->hidden) ); tp = gtk_tree_path_new_from_indices(delete_pos, -1); /* tell everybody that we removed an item */ gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), tp); gtk_tree_path_free(tp); } items_it = next_item_it; } } }
static void scroll_both_realize (ScrollFixture *fixture, GtkTreePath *path, gboolean use_align, gdouble row_align) { GtkTreePath *end; gtk_widget_show_all (fixture->window); /* Scroll to end */ end = gtk_tree_path_new_from_indices (999, -1); gtk_tree_view_set_cursor (GTK_TREE_VIEW (fixture->tree_view), end, NULL, FALSE); gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (fixture->tree_view), end, NULL, use_align, row_align, 0.0); gtk_tree_path_free (end); while (gtk_events_pending ()) gtk_main_iteration (); /* Scroll to final position */ gtk_tree_view_set_cursor (GTK_TREE_VIEW (fixture->tree_view), path, NULL, FALSE); gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (fixture->tree_view), path, NULL, use_align, row_align, 0.0); ensure_layout (); test_position (GTK_TREE_VIEW (fixture->tree_view), path, use_align, row_align); }
static void thunar_column_model_notify_visible_columns (ThunarPreferences *preferences, GParamSpec *pspec, ThunarColumnModel *column_model) { GtkTreePath *path; GtkTreeIter iter; gint n; _thunar_return_if_fail (THUNAR_IS_COLUMN_MODEL (column_model)); _thunar_return_if_fail (THUNAR_IS_PREFERENCES (preferences)); /* load the new list of visible columns */ thunar_column_model_load_visible_columns (column_model); /* emit "row-changed" for all rows */ for (n = 0; n < THUNAR_N_VISIBLE_COLUMNS; ++n) { path = gtk_tree_path_new_from_indices (n, -1); if (gtk_tree_model_get_iter (GTK_TREE_MODEL (column_model), &iter, path)) gtk_tree_model_row_changed (GTK_TREE_MODEL (column_model), path, &iter); gtk_tree_path_free (path); } /* emit "columns-changed" */ g_signal_emit (G_OBJECT (column_model), column_model_signals[COLUMNS_CHANGED], 0); }
static void LoadCheatListItems(int index) { GtkListStore *store = gtk_list_store_new(2, G_TYPE_BOOLEAN, G_TYPE_STRING); GtkTreeIter iter; GtkWidget *widget; int i; widget = gtk_builder_get_object(builder, "GtkCList_Cheat"); for (i = 0; i < NumCheats; i++) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, Cheats[i].Enabled, 1, Cheats[i].Descr, -1); } gtk_tree_view_set_model(GTK_TREE_VIEW(widget), GTK_TREE_MODEL(store)); g_object_unref(G_OBJECT(store)); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE); gtk_tree_view_set_search_column(GTK_TREE_VIEW(widget), 1); gtk_widget_show(widget); if (index >= NumCheats) { index = NumCheats - 1; } if (index >= 0) { GtkTreePath *path; GtkTreeSelection *sel; path = gtk_tree_path_new_from_indices(index, -1); sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); gtk_tree_selection_select_path(sel, path); gtk_tree_path_free(path); } }
void ptk_file_list_file_changed( VFSDir* dir, VFSFileInfo* file, PtkFileList* list ) { GList* l; GtkTreeIter it; GtkTreePath* path; if( ! list->show_hidden && vfs_file_info_get_name(file)[0] == '.' ) return; l = g_list_find( list->files, file ); if( ! l ) return; it.stamp = list->stamp; it.user_data = l; it.user_data2 = l->data; path = gtk_tree_path_new_from_indices( g_list_index(list->files, l->data), -1 ); gtk_tree_model_row_changed( GTK_TREE_MODEL(list), path, &it ); gtk_tree_path_free( path ); }
static void on_control_name_edited (GtkCellRendererText * cellrenderertext, gchar * path_string, gchar * new_text, gpointer user_data) { BtSettingsPageInteractionController *self = BT_SETTINGS_PAGE_INTERACTION_CONTROLLER (user_data); GtkTreeModel *store; if ((store = gtk_tree_view_get_model (self->priv->controller_list))) { GtkTreeIter iter; if (gtk_tree_model_get_iter_from_string (store, &iter, path_string)) { GObject *control; if ((control = bt_object_list_model_get_object ((BtObjectListModel *) store, &iter))) { GtkTreePath *path; gint pos; g_object_set (control, "name", new_text, NULL); // resort the list on_device_menu_changed (self->priv->device_menu, self); // select control again pos = get_control_pos (self->priv->device, (BtIcControl *) control); path = gtk_tree_path_new_from_indices (pos, -1); gtk_widget_grab_focus (GTK_WIDGET (self->priv->controller_list)); gtk_tree_view_set_cursor (self->priv->controller_list, path, gtk_tree_view_get_column (self->priv->controller_list, CONTROLLER_LIST_LABEL), TRUE); gtk_tree_path_free (path); } } } }
/* Given a drop path retrieved by gtk_tree_view_get_dest_row_at_pos, this function * determines whether dropping a bookmark item at the specified path is allow. * If dropping is not allowed, this function tries to choose an alternative position * for the bookmark item and modified the tree path @tp passed into this function. */ static gboolean get_bookmark_drag_dest(FmPlacesView* view, GtkTreePath** tp, GtkTreeViewDropPosition* pos) { gboolean ret = TRUE; if(*tp) { /* if the drop site is below the separator (in the bookmark area) */ if(fm_places_model_path_is_bookmark(FM_PLACES_MODEL(model), *tp)) { /* we cannot drop into a item */ if(*pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE || *pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER) ret = FALSE; else ret = TRUE; } else /* the drop site is above the separator (in the places area containing volumes) */ { const GtkTreePath* sep = fm_places_model_get_separator_path(FM_PLACES_MODEL(model)); /* set drop site at the first bookmark item */ gtk_tree_path_get_indices(*tp)[0] = gtk_tree_path_get_indices(sep)[0] + 1; *pos = GTK_TREE_VIEW_DROP_BEFORE; ret = TRUE; } } else { /* drop at end of the bookmarks list instead */ *tp = gtk_tree_path_new_from_indices(gtk_tree_model_iter_n_children(GTK_TREE_MODEL(model), NULL) - 1, -1); *pos = GTK_TREE_VIEW_DROP_AFTER; ret = TRUE; } g_debug("path: %s", gtk_tree_path_to_string(*tp)); return ret; }
static void select_nonexisting (GtkWidget *button, GtkIconView *icon_list) { GtkTreePath *path = gtk_tree_path_new_from_indices (999999, -1); gtk_icon_view_select_path (icon_list, path); gtk_tree_path_free (path); }
/* TODO - when ready - will replace the old gui_pulldown_new() function */ gpointer gui_pd_new(GSList *list, gint active, gpointer callback, gpointer argument) { GSList *item; GtkTreeModel *treemodel; GtkTreePath *treepath; GtkTreeIter iter; GtkWidget *w = NULL; #if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION >= 4 /* build the widget and associated drop down list */ w = gtk_combo_box_new_text(); for (item=list ; item ; item=g_slist_next(item)) gtk_combo_box_append_text(GTK_COMBO_BOX(w), item->data); /* set the currently active item */ treemodel = gtk_combo_box_get_model(GTK_COMBO_BOX(w)); treepath = gtk_tree_path_new_from_indices(active, -1); gtk_tree_model_get_iter(treemodel, &iter, treepath); gtk_combo_box_set_active_iter(GTK_COMBO_BOX(w), &iter); /* attach callback (if any) */ if (callback) g_signal_connect(GTK_OBJECT(w), "changed", GTK_SIGNAL_FUNC(callback), argument); #endif return(w); }
/* Test for GNOME bugzilla bug 93584. We add 150 rows to an existing * small model, and scroll to one of these with alignment. */ static void test_bug93584 (ScrollFixture *fixture, gconstpointer test_data) { int row, i; GtkTreeStore *store; GtkTreePath *path; g_test_bug ("93584"); /* Mimic state as in original test case */ g_signal_connect (G_OBJECT (fixture->tree_view), "realize", G_CALLBACK (gtk_tree_view_expand_all), NULL); gtk_widget_show_all (fixture->window); store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fixture->tree_view))); /* Add 150 rows */ for (i = 0; i < 150; i++) { GtkTreeIter iter; gtk_tree_store_append (store, &iter, NULL); gtk_tree_store_set (store, &iter, 0, "Row", -1); } row = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL); row -= 20; path = gtk_tree_path_new_from_indices (row, -1); scroll (fixture, path, TRUE, 0.5); gtk_tree_path_free (path); }
/* --------------------------------------------------------------------- * Callback for adding a language in the configuration dialog * --------------------------------------------------------------------- */ static void on_configure_add_language(GtkWidget* widget, gpointer data) { GtkWidget* tree_view = (GtkWidget*)data; GtkListStore *list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view))); GtkTreeIter tree_iter; GtkTreePath *path; GtkTreeViewColumn* column = NULL; gint nb_lines; /* Add a line */ gtk_list_store_append(list_store, &tree_iter); /* and give the focus to it */ nb_lines = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(list_store), NULL); path = gtk_tree_path_new_from_indices(nb_lines-1, -1); column = gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view), 0); /* TODO : why isn't the cell being edited, although we say "TRUE" as last parameter ?? */ gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view), path, column, TRUE); gtk_widget_grab_focus(tree_view); gtk_tree_path_free(path); }
static gboolean update_status(gpointer data) { GtkTreeSelection *selection; GtkTreeIter iter; GtkTreePath *path; GtkTreeModel *model; struct test_status *ts = (struct test_status *)data; gchar *stock_id; model = gtk_tree_view_get_model(GTK_TREE_VIEW(test_item_view)); path = gtk_tree_path_new_from_indices(ts->number, -1); gtk_tree_model_get_iter(model, &iter, path); gtk_tree_path_free(path); if (ts->type == UPDATE_HIGHLIGHT) { selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(test_item_view)); gtk_tree_selection_select_iter(selection, &iter); } else { stock_id = ts->success ? GTK_STOCK_OK : GTK_STOCK_STOP; gtk_list_store_set(GTK_LIST_STORE(model), &iter, RESULT, stock_id, -1); } g_mutex_lock(&ts->update_mutex); ts->update = 0; g_cond_signal(&ts->update_cond); g_mutex_unlock(&ts->update_mutex); return FALSE; }
void uim_cand_win_vertical_gtk_set_index(UIMCandWinVerticalGtk *vertical_cwin, gint index) { UIMCandWinGtk *cwin; UIMCandWinVerticalGtkClass *vertical_cwin_class; UIMCandWinGtkClass *cwin_class; g_return_if_fail(UIM_IS_CAND_WIN_VERTICAL_GTK(vertical_cwin)); cwin = UIM_CAND_WIN_GTK(vertical_cwin); /* call parent method */ vertical_cwin_class = UIM_CAND_WIN_VERTICAL_GTK_GET_CLASS(vertical_cwin); cwin_class = g_type_class_peek_parent(vertical_cwin_class); cwin_class->set_index(cwin, index); if (cwin->candidate_index >= 0) { GtkTreePath *path; gint pos = index; if (cwin->display_limit) pos = cwin->candidate_index % cwin->display_limit; path = gtk_tree_path_new_from_indices(pos, -1); gtk_tree_view_set_cursor(GTK_TREE_VIEW(cwin->view), path, NULL, FALSE); gtk_tree_path_free(path); } else { GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cwin->view)); gtk_tree_selection_unselect_all(selection); uim_cand_win_gtk_update_label(cwin); } }
static void notify_device_controlchange (BtIcLearn * learn, GParamSpec * arg, gpointer user_data) { BtSettingsPageInteractionController *self = BT_SETTINGS_PAGE_INTERACTION_CONTROLLER (user_data); gchar *id; BtIcControl *control; g_object_get (learn, "device-controlchange", &id, NULL); control = btic_learn_register_learned_control (learn, id); g_free (id); if (control) { gint pos = get_control_pos (self->priv->device, control); GtkTreePath *path = gtk_tree_path_new_from_indices (pos, -1); // add the new control to the list bt_object_list_model_insert (BT_OBJECT_LIST_MODEL (gtk_tree_view_get_model (self->priv->controller_list)), (GObject *) control, pos); // select the control gtk_widget_grab_focus (GTK_WIDGET (self->priv->controller_list)); gtk_tree_view_set_cursor (self->priv->controller_list, path, gtk_tree_view_get_column (self->priv->controller_list, CONTROLLER_LIST_LABEL), TRUE); gtk_tree_path_free (path); g_signal_connect_object (control, "notify::value", G_CALLBACK (notify_controlchange), (gpointer) self, 0); } }
/** * Try to select the bookmark before the current one. * If none is selected the last in the list is picked. * Wraps around. */ void AP_UnixDialog_Goto::_selectPrevBookmark () { UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::_selectPrevBookmark ()\n")); GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (m_lvBookmarks)); UT_return_if_fail (model != NULL); GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvBookmarks)); GtkTreeIter iter; // try to select prev gboolean haveSelected = gtk_tree_selection_get_selected (selection, &model, &iter); if (haveSelected) { GtkTreePath *path = gtk_tree_model_get_path (model, &iter); gtk_tree_path_prev (path); gboolean havePrev = gtk_tree_model_get_iter (model, &iter, path); if (havePrev) { gtk_tree_selection_select_path (selection, path); gtk_tree_path_free (path); return; } gtk_tree_path_free (path); } // select last UT_uint32 idx = getExistingBookmarksCount () - 1; GtkTreePath *path = gtk_tree_path_new_from_indices (idx); gtk_tree_selection_select_path (selection, path); UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::_selectPrevBookmark () select last '%d'\n", gtk_tree_model_get_iter (model, &iter, path))); gtk_tree_path_free (path); }
void moose_list_model_append_record(MooseListModel *self, const gchar *name, guint year_born) { GtkTreeIter iter; GtkTreePath *path; gulong newsize; guint pos; MooseListModelRecord *newrecord; g_return_if_fail(MOOSE_IS_LIST_MODEL(self)); g_return_if_fail(name != NULL); pos = self->priv->num_rows++; newsize = self->priv->num_rows * sizeof(MooseListModelRecord *); self->priv->rows = g_realloc(self->priv->rows, newsize); newrecord = g_new0(MooseListModelRecord, 1); newrecord->name = g_strdup(name); newrecord->year_born = year_born; self->priv->rows[pos] = newrecord; newrecord->pos = pos; /* inform the tree view and other interested objects * (e.g. tree row references) that we have inserted * a new row, and where it was inserted */ path = gtk_tree_path_new_from_indices(newrecord->pos, -1); moose_list_model_get_iter(GTK_TREE_MODEL(self), &iter, path); gtk_tree_model_row_inserted(GTK_TREE_MODEL(self), path, &iter); gtk_tree_path_free(path); }
/** * xfae_model_remove: * @model : a #XfaeModel. * @iter : the #GtkTreeIter referring to the item that should be removed. * @error : return location for errors or %NULL. * * Tries to remove the item referred to by @iter from @model. * * Return value: %TRUE if the removal was successful. **/ gboolean xfae_model_remove (XfaeModel *model, GtkTreeIter *iter, GError **error) { GtkTreePath *path; XfaeItem *item; GList *lp; gint index_; g_return_val_if_fail (XFAE_IS_MODEL (model), FALSE); g_return_val_if_fail (iter->stamp == model->stamp, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); lp = iter->user_data; item = lp->data; /* try to unlink the item from disk */ if (!xfae_item_remove (item, error)) return FALSE; /* unlink the item from the list */ index_ = g_list_position (model->items, lp); model->items = g_list_delete_link (model->items, lp); xfae_item_free (item); /* tell the view that we have just removed one item */ path = gtk_tree_path_new_from_indices (index_, -1); gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path); gtk_tree_path_free (path); return TRUE; }
void select_row(gint row) { if (row < 0) return; GtkTreePath *p = gtk_tree_path_new_from_indices(row, -1); gtk_tree_selection_select_path(tree_selection, p); gtk_tree_path_free(p); }
void remove_button_clicked_cb(GtkWidget *widget, gpointer data) { struct add_data *ad = (struct add_data *) data; GtkTreeIter iter,temp_iter; GtkTreeModel *model; gboolean valid; int index,nindices; int i; char buffer[512]; if (gtk_tree_selection_get_selected(ad->select, &model, &iter)) { valid = gtk_tree_model_get_iter_first(model, &temp_iter); index = 0; nindices = 0; while(valid) { if (gtk_tree_selection_iter_is_selected(ad->select, &temp_iter)) { #if DEBUG == 1 fprintf(stdout,"Index: %i\n",nindices); #endif index = nindices; } nindices++; valid = gtk_tree_model_iter_next(model, &temp_iter); } for (i = index ; i < nindices ; i++) { (*(ad->cw->lw->my_layer))->weight[i] =(*(ad->cw->lw->my_layer))->weight[i+1]; (*(ad->cw->lw->my_layer))->Z[i] =(*(ad->cw->lw->my_layer))->Z[i+1]; } (*(ad->cw->lw->my_layer))->weight = (double *) realloc((*(ad->cw->lw->my_layer))->weight, sizeof(double)*((*(ad->cw->lw->my_layer))->n_elements-1)); (*(ad->cw->lw->my_layer))->Z = (int *) realloc((*(ad->cw->lw->my_layer))->Z, sizeof(int)*((*(ad->cw->lw->my_layer))->n_elements-1)); (*(ad->cw->lw->my_layer))->n_elements--; gtk_list_store_remove(ad->store, &iter); sprintf(buffer,"%g", xmi_sum_double((*(ad->cw->lw->my_layer))->weight,(*(ad->cw->lw->my_layer))->n_elements )*100.0); gtk_entry_set_text(GTK_ENTRY(ad->cw->lw->sumEntry), buffer); if ((*(ad->cw->lw->my_layer))->n_elements == 0) gtk_widget_set_sensitive(ad->cw->lw->okButton, FALSE); else{ //select next line if available if (index == nindices -1) gtk_tree_selection_select_path(ad->select,gtk_tree_path_new_from_indices(nindices-2,-1)); else gtk_tree_selection_select_path(ad->select,gtk_tree_path_new_from_indices(index,-1)); } } }
void ugtk_setting_dialog_set_page (UgtkSettingDialog* sdialog, int nth) { GtkTreePath* path; path = gtk_tree_path_new_from_indices (nth, -1); gtk_tree_view_set_cursor (sdialog->tree_view, path, NULL, FALSE); gtk_tree_path_free (path); gtk_notebook_set_current_page (sdialog->notebook, nth); }
void rc_gui_list2_scroll_to_index(gint list_index) { GtkTreePath *path; if(list_index<0) return; path = gtk_tree_path_new_from_indices(list_index, -1); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(rc_ui->list2_tree_view), path, NULL, FALSE, 0.0, 0.0); gtk_tree_path_free(path); }
void rc_gui_select_list2(gint list_index) { GtkTreePath *path; if(list_index<0) return; path = gtk_tree_path_new_from_indices(list_index, -1); gtk_tree_view_set_cursor(GTK_TREE_VIEW(rc_ui->list2_tree_view), path, NULL, FALSE); gtk_tree_path_free(path); }
static GtkTreePath *moose_list_model_get_path(GtkTreeModel *tree_model, GtkTreeIter *iter) { g_return_val_if_fail(MOOSE_IS_LIST_MODEL(tree_model), NULL); g_return_val_if_fail(iter != NULL, NULL); g_return_val_if_fail(iter->user_data != NULL, NULL); MooseListModelRecord *record = (MooseListModelRecord *)iter->user_data; return gtk_tree_path_new_from_indices(record->pos, -1); }
void saa_tree_view_select_wing(SaaTreeView * treeview, SaaAile * ai) { GtkTreeSelection * sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); int i = saa_solide_index_aile(treeview->visuel->solide, ai); GtkTreePath * path = gtk_tree_path_new_from_indices(2, i, -1); gtk_tree_view_expand_to_path (GTK_TREE_VIEW(treeview), path); gtk_tree_selection_select_path(sel, path); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview), path, NULL, TRUE, 0.5, 0); gtk_tree_path_free (path); }
/** * Print the selected item in a combo box. * @param combo_box combo box to print information about */ void mk_print_GtkComboBox_info(GtkComboBox* combo_box) { gint active = gtk_combo_box_get_active(combo_box); GtkTreeModel* model = gtk_combo_box_get_model(combo_box); GtkTreePath* path = gtk_tree_path_new_from_indices(active, -1); GtkTreeIter iter; if (gtk_combo_box_get_active_iter(combo_box, &iter)) { print_tree_selection(model, path, &iter, NULL); } }
static GtkTreePath* thunar_column_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter) { _thunar_return_val_if_fail (THUNAR_IS_COLUMN_MODEL (tree_model), NULL); _thunar_return_val_if_fail (iter->stamp == THUNAR_COLUMN_MODEL (tree_model)->stamp, NULL); /* generate the path for the iterator */ return gtk_tree_path_new_from_indices (GPOINTER_TO_INT (iter->user_data), -1); }
static void test_bug111500_mixed (ScrollFixture *fixture, gconstpointer test_data) { int i, len; GtkTreeStore *store; GtkTreeIter parent; GtkTreePath *path; g_test_bug ("111500"); gtk_widget_show_all (fixture->window); /* Make sure all events have been processed and the window * is visible. */ while (gtk_events_pending ()) gtk_main_iteration (); /* Further prepare model */ store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fixture->tree_view))); for (i = 0; i < 15; i++) { GtkTreeIter iter; gtk_tree_store_append (store, &iter, NULL); if (i % 2 == 0) gtk_tree_store_set (store, &iter, 0, "Other node", -1); else gtk_tree_store_set (store, &iter, 0, "Other\nnode", -1); } len = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL); gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &parent, NULL, len - 1); for (i = 0; i < 5; i++) { GtkTreeIter iter; gtk_tree_store_append (store, &iter, &parent); if (i % 2 != 0) gtk_tree_store_set (store, &iter, 0, "Row", -1); else gtk_tree_store_set (store, &iter, 0, "Row\nRow", -1); } path = gtk_tree_path_new_from_indices (len - 1, -1); gtk_tree_view_expand_row (GTK_TREE_VIEW (fixture->tree_view), path, FALSE); gtk_tree_path_down (path); scroll (fixture, path, FALSE, 0.5); gtk_tree_path_free (path); }