void CChooseApertureSimpleDlg::UpdateApertures(void) { char txt[256]; int selectedIndex = -1; gtk_tree_view_set_model(GTK_TREE_VIEW(m_AperView), NULL); gtk_list_store_clear(m_Apertures); for (int i=0; i<m_Aper.Count(); i++) { const CAperture *aper = m_Aper.Get(i); sprintf(txt, "#%d (%.2f)", aper->Id(), aper->Radius()); GtkTreeIter iter; gtk_list_store_append(m_Apertures, &iter); gtk_list_store_set(m_Apertures, &iter, 0, i, 1, txt, -1); if (i==m_ApertureIndex) selectedIndex = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_Apertures), NULL)-1; } gtk_tree_view_set_model(GTK_TREE_VIEW(m_AperView), GTK_TREE_MODEL(m_Apertures)); GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_AperView)); if (selectedIndex>=0) { GtkTreeIter iter; if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_Apertures), &iter, NULL, selectedIndex)) gtk_tree_selection_select_iter(sel, &iter); } else { GtkTreeIter iter; if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(m_Apertures), &iter)) { gtk_tree_model_get(GTK_TREE_MODEL(m_Apertures), &iter, 0, &m_ApertureIndex, -1); gtk_tree_selection_select_iter(sel, &iter); } else m_ApertureIndex = -1; } gtk_widget_set_sensitive(m_AperView, gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_Apertures), NULL)>1); }
void CChooseApertureDlg::UpdateChannels(void) { int i; GtkTreeIter iter; CChannels *cy = m_Table->ChannelsY(); // Update list of dependent channels gtk_tree_view_set_model(GTK_TREE_VIEW(m_DataView), NULL); gtk_list_store_clear(m_Channels); for (i=0; i<cy->Count(); i++) { gtk_list_store_append(m_Channels, &iter); gtk_list_store_set(m_Channels, &iter, 0, i, 1, cy->GetName(i), -1); } gtk_tree_view_set_model(GTK_TREE_VIEW(m_DataView), GTK_TREE_MODEL(m_Channels)); int count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_Channels), NULL); if (m_Column<0 || m_Column>=count) m_Column = (count>0 ? 0 : -1); if (m_Column>=0) { if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_Channels), &iter, NULL, m_Column)) { GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_DataView)); gtk_tree_selection_select_iter(sel, &iter); } } gtk_widget_set_sensitive(m_DataView, gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_Channels), NULL)>1); }
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; }
void cdda_remove_from_playlist_foreach(gpointer data, gpointer user_data) { int i = 0; GtkTreeIter iter; unsigned long hash; playlist_t * pl = (playlist_t *)data; cdda_drive_t * drive = (cdda_drive_t *)user_data; playlist_data_t * pldata = NULL; if (drive->disc.hash == 0) { hash = drive->disc.hash_prev; } else { hash = drive->disc.hash; } while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pl->store), &iter, NULL, i++)) { if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(pl->store), &iter) > 0) { int j = 0; GtkTreeIter child; while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pl->store), &child, &iter, j++)) { gtk_tree_model_get(GTK_TREE_MODEL(pl->store), &child, PL_COL_DATA, &pldata, -1); if (cdda_hash_matches(pldata->file, hash)) { gtk_tree_store_remove(pl->store, &child); --j; } } if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(pl->store), &iter) == 0) { gtk_tree_store_remove(pl->store, &iter); --i; } else { recalc_album_node(pl, &iter); } } else { gtk_tree_model_get(GTK_TREE_MODEL(pl->store), &iter, PL_COL_DATA, &pldata, -1); if (cdda_hash_matches(pldata->file, hash)) { gtk_tree_store_remove(pl->store, &iter); --i; } } } playlist_content_changed(pl); }
static gboolean hildon_find_toolbar_filter (GtkTreeModel *model, GtkTreeIter *iter, gpointer self) { GtkTreePath *path; const gint *indices; gint n; gint limit; gint total; total = gtk_tree_model_iter_n_children (model, NULL); g_object_get (self, "history_limit", &limit, NULL); path = gtk_tree_model_get_path (model, iter); indices = gtk_tree_path_get_indices (path); /* set the row's index, list store has only one level */ n = indices [0]; gtk_tree_path_free (path); /*if the row is among the latest "history_limit" additions of the * model, then we show it */ if( (total - limit <= n) && (n < total) ) return TRUE; else return FALSE; }
/* is the user looking at the latest messages? */ static gboolean is_pinned_to_new (struct MsgData * data) { gboolean pinned_to_new = FALSE; if (data->view == NULL) { pinned_to_new = TRUE; } else { GtkTreePath * last_visible; if (gtk_tree_view_get_visible_range (data->view, NULL, &last_visible)) { GtkTreeIter iter; const int row_count = gtk_tree_model_iter_n_children (data->sort, NULL); if (gtk_tree_model_iter_nth_child (data->sort, &iter, NULL, row_count-1)) { GtkTreePath * last_row = gtk_tree_model_get_path (data->sort, &iter); pinned_to_new = !gtk_tree_path_compare (last_visible, last_row); gtk_tree_path_free (last_row); } gtk_tree_path_free (last_visible); } } return pinned_to_new; }
/******************************************************* * csv_import_hrows_cb * * call back for the start row / number of header rows *******************************************************/ void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data ) { CsvImportInfo *info = user_data; GtkTreeIter iter; gboolean valid; int num_rows; /* Get number of rows for header */ info->header_rows = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spin)); /* Get number of rows displayed */ num_rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(info->store), NULL); /* Modify background color for header rows */ if (info->header_rows == 0) { valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, 0 ); if (valid) gtk_list_store_set (info->store, &iter, ROW_COLOR, NULL, -1); } else { if (info->header_rows - 1 < num_rows) { valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, info->header_rows - 1 ); if (valid) gtk_list_store_set (info->store, &iter, ROW_COLOR, "pink", -1); valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(info->store), &iter); if (valid) gtk_list_store_set (info->store, &iter, ROW_COLOR, NULL, -1); } } }
static VALUE rg_n_children(VALUE self) { GtkTreeIter* iter = _SELF(self); GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; return INT2NUM(gtk_tree_model_iter_n_children(model, iter)); }
/* 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); }
static void bookmarks_delete_bookmark (void) { GtkTreeIter iter; GtkTreePath *path; gint *indices, row, rows; g_assert (GTK_IS_TREE_VIEW (bookmark_list_widget)); if (!gtk_tree_selection_get_selected (bookmark_selection, NULL, &iter)) return; /* Remove the selected item from the list store. on_row_deleted() will remove it from the bookmark list. */ path = gtk_tree_model_get_path (GTK_TREE_MODEL (bookmark_list_store), &iter); indices = gtk_tree_path_get_indices (path); row = indices[0]; gtk_tree_path_free (path); gtk_list_store_remove (bookmark_list_store, &iter); /* Try to select the same row, or the last one in the list. */ rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (bookmark_list_store), NULL); if (row >= rows) row = rows - 1; if (row < 0) { bookmarks_set_empty (TRUE); } else { gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (bookmark_list_store), &iter, NULL, row); gtk_tree_selection_select_iter (bookmark_selection, &iter); } }
void remove_row(GtkToolButton *toolbutton, gpointer user_data) { GtkListStore* restrictions = GTK_LIST_STORE(gtk_tree_view_get_model(restrictions_view)); int rows = gtk_tree_model_iter_n_children( GTK_TREE_MODEL(restrictions), NULL); GtkTreeSelection* selection = gtk_tree_view_get_selection(restrictions_view); GtkTreeIter iter; if(gtk_tree_selection_get_selected(selection, NULL, &iter)) { bool valid = gtk_list_store_remove(restrictions, &iter); if(!valid) { valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(restrictions), &iter, NULL, rows - 1); } if(valid) { GtkTreePath* model_path = gtk_tree_model_get_path( GTK_TREE_MODEL(restrictions), &iter); gtk_tree_view_set_cursor(restrictions_view, model_path, NULL, false); gtk_tree_path_free(model_path); } } }
void FormAccount_SetCursorOnLast(FormAccount* fa) { GtkTreeModel* model; GtkTreeIter iter; uint nlast; GtkTreePath* path; model = gtk_tree_view_get_model(GTK_TREE_VIEW(fa->ListViewAccount)); nlast = gtk_tree_model_iter_n_children(model, NULL); if (nlast == 0) { return ; } --nlast; if (gtk_tree_model_iter_nth_child(model, &iter, NULL, nlast) == FALSE) { return ; } path = gtk_tree_model_get_path(model, &iter); gtk_tree_view_set_cursor_on_cell(GTK_TREE_VIEW(fa->ListViewAccount), path, NULL, NULL, FALSE); gtk_tree_path_free(path); }
/** * eog_list_store_length: * @store: An #EogListStore. * * Returns the number of images in the store. * * Returns: The number of images in @store. **/ gint eog_list_store_length (EogListStore *store) { g_return_val_if_fail (EOG_IS_LIST_STORE (store), -1); return gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL); }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeRemoveAll (JNIEnv *env, jobject obj) { void *ptr; GtkTreeModel *model; GtkWidget *bin; gint count, i; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); bin = choice_get_widget (GTK_WIDGET (ptr)); model = gtk_combo_box_get_model (GTK_COMBO_BOX (bin)); count = gtk_tree_model_iter_n_children (model, NULL); /* First, unselect everything, to avoid problems when removing items. */ gtk_combo_box_set_active (GTK_COMBO_BOX (bin), -1); for (i = count - 1; i >= 0; i--) { gtk_combo_box_remove_text (GTK_COMBO_BOX (bin), i); } gdk_threads_leave (); }
void refresh_cdda_drive_node(char * device_path) { GtkTreeIter iter_cdda; GtkTreeIter iter_drive; GtkTreeIter iter_tmp; cdda_drive_t * drive; char str_title[MAXLEN]; int i, found; gtk_tree_model_get_iter_first(GTK_TREE_MODEL(music_store), &iter_cdda); i = found = 0; while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(music_store), &iter_drive, &iter_cdda, i++)) { gtk_tree_model_get(GTK_TREE_MODEL(music_store), &iter_drive, MS_COL_DATA, &drive, -1); if (strcmp(drive->device_path, device_path) == 0) { found = 1; break; } } if (!found) { return; } if (drive->disc.n_tracks > 0) { snprintf(str_title, MAXLEN-1, "%s [%s]", _("Unknown disc"), cdda_displayed_device_path(device_path)); } else { snprintf(str_title, MAXLEN-1, "%s [%s]", _("No disc"), cdda_displayed_device_path(device_path)); } gtk_tree_store_set(music_store, &iter_drive, MS_COL_NAME, str_title, -1); if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(music_store), &iter_drive) > 0) { if (options.cdda_remove_from_playlist) { cdda_remove_from_playlist(drive); } while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(music_store), &iter_tmp, &iter_drive, 0)) { store_cdda_remove_track(&iter_tmp); } } if (options.enable_ms_tree_icons) { if (drive->disc.n_tracks > 0) { gtk_tree_store_set(music_store, &iter_drive, MS_COL_ICON, icon_cdda_disc, -1); } else { gtk_tree_store_set(music_store, &iter_drive, MS_COL_ICON, icon_cdda_nodisc, -1); } } if (drive->disc.n_tracks > 0) { update_track_data(drive, iter_drive); } music_store_selection_changed(STORE_TYPE_CDDA); }
static void remove_button_clicked (GtkButton *button, CcBackgroundPanel *panel) { CcBackgroundItem *item; GtkListStore *store; GtkTreePath *path; CcBackgroundPanelPrivate *priv; priv = panel->priv; item = get_selected_item (panel); if (item == NULL) g_assert_not_reached (); bg_pictures_source_remove (panel->priv->pictures_source, item); g_object_unref (item); /* Are there any items left in the pictures tree store? */ store = bg_source_get_liststore (BG_SOURCE (panel->priv->pictures_source)); if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 0) gtk_combo_box_set_active (GTK_COMBO_BOX (WID ("sources-combobox")), SOURCE_WALLPAPERS); path = gtk_tree_path_new_from_string ("0"); gtk_icon_view_select_path (GTK_ICON_VIEW (WID ("backgrounds-iconview")), path); gtk_tree_path_free (path); }
static void feed_list_node_check_if_folder_is_empty (const gchar *nodeId) { GtkTreeIter *iter; int count; debug1 (DEBUG_GUI, "folder empty check for node id \"%s\"", nodeId); /* this function does two things: 1. add "(empty)" entry to an empty folder 2. remove an "(empty)" entry from a non empty folder (this state is possible after a drag&drop action) */ iter = feed_list_node_to_iter (nodeId); if (!iter) return; count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (feedstore), iter); /* case 1 */ if (0 == count) { feed_list_node_add_empty_node (iter); return; } if (1 == count) return; /* else we could have case 2 */ feed_list_node_remove_empty_node (iter); }
void _fcitx_im_widget_im_selection_changed(GtkTreeSelection *selection, gpointer data) { FcitxImWidget* self = data; GtkTreeView *treeView = gtk_tree_selection_get_tree_view(selection); GtkTreeModel *model = gtk_tree_view_get_model(treeView); GtkTreeIter iter; if (gtk_tree_selection_get_selected(selection, &model, &iter)) { gtk_widget_set_sensitive(GTK_WIDGET(self->delimbutton), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(self->configurebutton), TRUE); GtkTreePath* path = gtk_tree_model_get_path(model, &iter); gint* ind = gtk_tree_path_get_indices(path); gint n = gtk_tree_model_iter_n_children(model, NULL); if (ind) { gtk_widget_set_sensitive(GTK_WIDGET(self->moveupbutton), (*ind != 0)); gtk_widget_set_sensitive(GTK_WIDGET(self->movedownbutton), (*ind != n - 1)); } gtk_tree_path_free(path); } else { gtk_widget_set_sensitive(GTK_WIDGET(self->delimbutton), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(self->configurebutton), FALSE); } }
static gboolean dialog_state_valid (gpointer data) { struct variable *v = NULL; struct paired_samples_dialog *tt_d = data; GtkTreeIter dest_iter; gint n_rows = gtk_tree_model_iter_n_children (tt_d->list_store, NULL); if ( n_rows == 0 ) return FALSE; /* Get the last row */ gtk_tree_model_iter_nth_child (tt_d->list_store, &dest_iter, NULL, n_rows - 1); /* Get the last (2nd) column */ gtk_tree_model_get (tt_d->list_store, &dest_iter, 1, &v, -1); if (v == NULL) return FALSE; if ( NULL == tt_d->valid) return TRUE; return tt_d->valid (tt_d->aux); }
static gboolean gtkam_list_get_iter (GtkamList *list, GtkTreeIter *iter, GtkamCamera *camera, const gchar *folder, const gchar *name) { gint n, i; gchar *f, *na; n = gtk_tree_model_iter_n_children ( GTK_TREE_MODEL (list->priv->store), NULL); for (i = 0; i < n; i++) { gtk_tree_model_iter_nth_child ( GTK_TREE_MODEL (list->priv->store), iter, NULL, i); if (camera != gtkam_list_get_camera_from_iter (list, iter)) continue; f = gtkam_list_get_folder_from_iter (list, iter); if (strcmp (folder, f)) { g_free (f); continue; } if (name) { na = gtkam_list_get_name_from_iter (list, iter); if (strcmp (name, na)) { g_free (na); continue; } } break; } return (i != n); }
static void subtitle_refresh_list_ui_from_settings(signal_user_data_t *ud, GValue *settings) { GValue *subtitle_list; GValue *subsettings; gint ii, count, tm_count; GtkTreeView *tv; GtkTreeModel *tm; GtkTreeIter ti; tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list")); tm = gtk_tree_view_get_model(tv); tm_count = gtk_tree_model_iter_n_children(tm, NULL); subtitle_list = ghb_settings_get_value(settings, "subtitle_list"); count = ghb_array_len(subtitle_list); if (count != tm_count) { ghb_clear_subtitle_list_ui(ud->builder); for (ii = 0; ii < count; ii++) { gtk_tree_store_append(GTK_TREE_STORE(tm), &ti, NULL); } } for (ii = 0; ii < count; ii++) { g_return_if_fail(tv != NULL); gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii); subsettings = ghb_array_get_nth(subtitle_list, ii); subtitle_refresh_list_row_ui(tm, &ti, subsettings); } }
gboolean gtk_tree_model_iter_next_dfs (GtkTreeModel *model, GtkTreeIter *itr) { GtkTreeIter itrTree ; if (gtk_tree_model_iter_n_children (model, itr) > 0) { if (!gtk_tree_model_iter_children (model, &itrTree, itr)) return gtk_tree_model_iter_next (model, itr) ; else { memcpy (itr, &itrTree, sizeof (GtkTreeIter)) ; return TRUE ; } } else if (gtk_tree_model_iter_next (model, itr)) return TRUE ; else { if (!gtk_tree_model_iter_parent (model, &itrTree, itr)) return FALSE ; else if (!gtk_tree_model_iter_next (model, &itrTree)) return FALSE ; else memcpy (itr, &itrTree, sizeof (GtkTreeIter)) ; } return TRUE ; }
/* --------------------------------------------------------------------- * 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_idle (RBImportDialog *dialog) { int count; const char *fmt; char *text; if (rb_entry_view_have_selection (dialog->priv->entry_view)) { GList *sel; sel = rb_entry_view_get_selected_entries (dialog->priv->entry_view); count = g_list_length (sel); g_list_free_full (sel, (GDestroyNotify) rhythmdb_entry_unref); fmt = ngettext ("Import %d selected track", "Import %d selected tracks", count); } else { count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (dialog->priv->query_model), NULL); fmt = ngettext ("Import %d listed track", "Import %d listed tracks", count); } text = g_strdup_printf (fmt, count); gtk_button_set_label (GTK_BUTTON (dialog->priv->import_button), text); g_free (text); dialog->priv->update_status_id = 0; return FALSE; }
static void _gtk_tree_move_iter(GtkTreeStore *store, GtkTreeIter *source, GtkTreeIter *dest) { /* create copy of iter and insert into destinatation */ GtkTreeIter ni; GValue value; memset(&value,0,sizeof(GValue)); gtk_tree_model_get_value(GTK_TREE_MODEL(store), source, 0, &value); gtk_tree_store_insert(store, &ni, dest,0); gtk_tree_store_set(store, &ni, 0, g_strdup(g_value_get_string(&value)), -1); /* for each children recurse into */ int children = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), source); for (int k=0; k<children; k++) { GtkTreeIter child; if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &child, source, k)) _gtk_tree_move_iter(store, &child, &ni); } /* iter copied lets remove source */ gtk_tree_store_remove(store, source); }
/* 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; }
void gtk_assert_dialog_append_stack_frame(GtkAssertDialog *dlg, const gchar *function, const gchar *arguments, const gchar *sourcefile, guint line_number) { GtkTreeModel *model; GtkTreeIter iter; GString *linenum; gint count; g_return_if_fail (GTK_IS_ASSERT_DIALOG (dlg)); model = gtk_tree_view_get_model (GTK_TREE_VIEW(dlg->treeview)); /* how many items are in the list up to now ? */ count = gtk_tree_model_iter_n_children (model, NULL); linenum = g_string_new(""); if ( line_number != 0 ) g_string_printf (linenum, "%u", line_number); /* add data to the list store */ gtk_list_store_append (GTK_LIST_STORE(model), &iter); gtk_list_store_set (GTK_LIST_STORE(model), &iter, STACKFRAME_LEVEL_COLIDX, count+1, /* start from 1 and not from 0 */ FUNCTION_NAME_COLIDX, function, FUNCTION_ARGS_COLIDX, arguments, SOURCE_FILE_COLIDX, sourcefile, LINE_NUMBER_COLIDX, linenum->str, -1); g_string_free (linenum, TRUE); }
static void addr_delete_clicked (GtkButton *button, gpointer user_data) { GtkTreeView *treeview = GTK_TREE_VIEW (user_data); GtkTreeSelection *selection; GList *selected_rows; GtkTreeModel *model = NULL; GtkTreeIter iter; int num_rows; selection = gtk_tree_view_get_selection (treeview); if (gtk_tree_selection_count_selected_rows (selection) != 1) return; selected_rows = gtk_tree_selection_get_selected_rows (selection, &model); if (!selected_rows) return; if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data)) gtk_list_store_remove (GTK_LIST_STORE (model), &iter); g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL); g_list_free (selected_rows); num_rows = gtk_tree_model_iter_n_children (model, NULL); if (num_rows && gtk_tree_model_iter_nth_child (model, &iter, NULL, num_rows - 1)) { selection = gtk_tree_view_get_selection (treeview); gtk_tree_selection_select_iter (selection, &iter); } }
static void entry_activated (GtkWidget *entry, dt_lib_collect_rule_t *d) { changed_callback(NULL, d); dt_lib_collect_t *c = get_collect(d); GtkTreeView *view = c->view; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(view)); gint rows = gtk_tree_model_iter_n_children(model, NULL); if(rows == 1) { GtkTreeIter iter; if(gtk_tree_model_get_iter_first(model, &iter)) { gchar *text; const int item = gtk_combo_box_get_active(GTK_COMBO_BOX(d->combo)); if(item == 0) // get full path for film rolls: gtk_tree_model_get (model, &iter, DT_LIB_COLLECT_COL_PATH, &text, -1); else gtk_tree_model_get (model, &iter, DT_LIB_COLLECT_COL_TEXT, &text, -1); gtk_entry_set_text(GTK_ENTRY(d->text), text); g_free(text); changed_callback(NULL, d); } } dt_collection_update_query(darktable.collection); }
static void bookmarks_delete_bookmark (NautilusBookmarksWindow *self) { GtkTreeIter iter; GtkTreePath *path; gint *indices, row, rows; if (!gtk_tree_selection_get_selected (self->priv->selection, NULL, &iter)) { return; } /* Remove the selected item from the list store. on_row_deleted() will remove it from the bookmark list. */ path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->priv->model), &iter); indices = gtk_tree_path_get_indices (path); row = indices[0]; gtk_tree_path_free (path); gtk_list_store_remove (self->priv->model, &iter); /* Try to select the same row, or the last one in the list. */ rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (self->priv->model), NULL); if (row >= rows) { row = rows - 1; } if (row < 0) { bookmarks_set_empty (self, TRUE); } else { gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->priv->model), &iter, NULL, row); gtk_tree_selection_select_iter (self->priv->selection, &iter); } }