static void tree_selection_changed(GtkTreeSelection* selection, gpointer user_data) { GList *_list; GtkTreeIter iter; GtkTreeModel *model; GtkTreeSelection *sel; // destroy selection tilp_local_selection_destroy(); sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(ctree_wnd)); // create local selection for(_list = gtk_tree_selection_get_selected_rows(selection, &model); _list; _list = g_list_next(_list)) { GtkTreePath *path = _list->data; FileEntry *fe; gtk_tree_model_get_iter(model, &iter, path); gtk_tree_model_get(model, &iter, COLUMN_DATA, &fe, -1); tilp_local_selection_add(fe->name); } g_list_foreach(_list, (GFunc)gtk_tree_path_free, NULL); g_list_free(_list); // create file selection _list = gtk_tree_selection_get_selected_rows(selection, &model); if(_list) { tilp_file_selection_destroy(); for(; _list; _list = g_list_next(_list)) { GtkTreePath *path = _list->data; FileEntry *fe; gchar *full_path; gtk_tree_model_get_iter(model, &iter, path); gtk_tree_model_get(model, &iter, COLUMN_DATA, &fe, -1); full_path = g_strconcat(local.cwdir, G_DIR_SEPARATOR_S, fe->name, NULL); tilp_file_selection_add(full_path); } g_list_foreach(_list, (GFunc)gtk_tree_path_free, NULL); g_list_free(_list); } }
static int do_chmod_thread (gftpui_callback_data * cdata) { GList * filelist, * templist; gftp_window_data * wdata; gftp_file * tempfle; int error; GtkTreeSelection *select; GtkTreeIter iter; GtkTreeModel * model; wdata = cdata->uidata; error = 0; select = gtk_tree_view_get_selection (GTK_TREE_VIEW (wdata->listbox)); templist = gtk_tree_selection_get_selected_rows(select, &model); for (filelist = templist ; filelist != NULL; filelist = g_list_next(filelist)) { gtk_tree_model_get_iter(model, &iter, (GtkTreePath*)filelist->data); gtk_tree_model_get(model, &iter, 0, &tempfle, -1); if (gftp_chmod (wdata->request, tempfle->file, mode) != 0) error = 1; if (!GFTP_IS_CONNECTED (wdata->request)) break; } g_list_foreach (templist, (GFunc) gtk_tree_path_free, NULL); g_list_free (templist); return (error); }
gchar * xfburn_directory_browser_get_selection (XfburnDirectoryBrowser * browser) { GtkTreeSelection *selection; GtkTreeModel *model; GList *selected_rows; gchar *full_paths = NULL; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser)); selected_rows = gtk_tree_selection_get_selected_rows (selection, &model); selected_rows = g_list_last (selected_rows); while (selected_rows) { GtkTreeIter iter; gchar *current_path = NULL; gchar *temp = NULL; gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data); gtk_tree_model_get (model, &iter, DIRECTORY_BROWSER_COLUMN_PATH, ¤t_path, -1); temp = g_strdup_printf ("file://%s\n%s", current_path, full_paths ? full_paths : ""); g_free (current_path); g_free (full_paths); full_paths = temp; selected_rows = g_list_previous (selected_rows); } selected_rows = g_list_first (selected_rows); g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL); g_list_free (selected_rows); return full_paths; }
GList *ex_tree_view_get_rows(GtkTreeView *treeview) { GList *iter_list = NULL; GtkTreeSelection *sel = gtk_tree_view_get_selection(treeview); if (gtk_tree_selection_count_selected_rows(sel) == 0) return NULL; GList *path_list = gtk_tree_selection_get_selected_rows(sel, NULL); while(path_list) { GtkTreeIter iter; GtkTreeIter *it; gtk_tree_model_get_iter(gtk_tree_view_get_model (treeview), &iter, path_list -> data); it = gtk_tree_iter_copy (&iter); iter_list = g_list_append(iter_list, it); path_list = path_list -> next; } g_list_foreach (path_list, (GFunc) gtk_tree_path_free, NULL); g_list_free(path_list); return iter_list; }
static int pragha_filter_dialog_key_press (GtkWidget *fliter_view, GdkEventKey *event, PraghaFilterDialog *fdialog) { GtkTreeSelection *selection; GList *list; if (event->state != 0 && ((event->state & GDK_CONTROL_MASK) || (event->state & GDK_MOD1_MASK) || (event->state & GDK_MOD3_MASK) || (event->state & GDK_MOD4_MASK) || (event->state & GDK_MOD5_MASK))) { return FALSE; } else if(event->keyval == GDK_KEY_q || event->keyval == GDK_KEY_Q) { selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fliter_view)); list = gtk_tree_selection_get_selected_rows (selection, NULL); if (list) { pragha_filter_dialog_select_row_on_current_playlist (GTK_TREE_VIEW (fliter_view), list->data, fdialog); gtk_tree_path_free (list->data); g_list_free (list); toggle_queue_selected_current_playlist (fdialog->cplaylist); } return TRUE; } return FALSE; }
static void node_tree_selection_changed_cb ( LibreImpuestoWindow *libre_impuesto_window, GtkTreeSelection *selection) { GtkTreeModel *model; GtkTreeIter iter; GList *list; gchar *form; LibreImpuestoCommand *impuesto_command; list = gtk_tree_selection_get_selected_rows (selection, &model); if (list == NULL) goto exit; gtk_tree_model_get_iter (model, &iter, list->data); if (!gtk_tree_model_iter_has_child (model, &iter)) { gtk_tree_model_get (model, &iter, 2, &form, -1); impuesto_command = libre_impuesto_get_command(libre_impuesto_window_get_impuesto(libre_impuesto_window)); libre_impuesto_queue_command (impuesto_command, IMPUESTO_COMMAND_OPEN_FORM, form, FALSE); g_free (form); } exit: g_list_free (list); }
/** * trace_view_get_selected_row - return the selected row * @treeview: The tree view * * Returns the selected row number (or -1 if none is selected) */ gint trace_view_get_selected_row(GtkWidget *treeview) { GtkTreeView *tree = GTK_TREE_VIEW(treeview); GtkTreeSelection *selection; GtkTreeModel *model; GtkTreePath *path; gchar *spath; GList *glist; gint row; model = gtk_tree_view_get_model(tree); if (!model) return -1; selection = gtk_tree_view_get_selection(tree); glist = gtk_tree_selection_get_selected_rows(selection, &model); if (!glist) return -1; /* Only one row may be selected */ path = glist->data; spath = gtk_tree_path_to_string(path); row = atoi(spath); g_free(spath); gtk_tree_path_free(path); g_list_free(glist); return row; }
/* notes_note_edit */ void notes_note_edit(Notes * notes) { GtkTreeSelection * treesel; GList * selected; GtkTreeModel * model = GTK_TREE_MODEL(notes->store); GList * s; GtkTreePath * path; GtkTreeIter iter; Note * note; if((treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(notes->view))) == NULL) return; if((selected = gtk_tree_selection_get_selected_rows(treesel, NULL)) == NULL) return; for(s = g_list_first(selected); s != NULL; s = g_list_next(s)) { if((path = s->data) == NULL) continue; if(_notes_get_iter(notes, &iter, path) != TRUE) continue; gtk_tree_model_get(model, &iter, ND_COL_NOTE, ¬e, -1); if(note != NULL) noteedit_new(notes, note); } g_list_free(selected); }
static void uri_opener_open_cb(GtkWidget *widget, gpointer data) { ClickableText *uri; GtkTreeIter sel; GtkTreeModel *model; GtkTreeSelection *selection; GList *selected, *cur; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(opener.urilist)); selected = gtk_tree_selection_get_selected_rows(selection, &model); cm_return_if_fail(selected); for(cur = selected; cur != NULL; cur = g_list_next(cur)) { if(!gtk_tree_model_get_iter(model, &sel, (GtkTreePath *)cur->data)) continue; gtk_tree_model_get(model, &sel, URI_OPENER_DATA, &uri, -1); if (!uri) continue; if (textview_uri_security_check(opener.msgview->mimeview->textview, uri) == TRUE) open_uri(uri->uri, prefs_common_get_uri_cmd()); } g_list_foreach(selected, (GFunc)gtk_tree_path_free, NULL); g_list_free(selected); }
static void on_remove_autorun_choice_clicked(GtkButton *button, GtkTreeView *view) { GtkTreeSelection *tree_sel = gtk_tree_view_get_selection(view); GtkTreeModel *model; GList *rows = gtk_tree_selection_get_selected_rows(tree_sel, &model), *l; GtkTreeIter it; /* convert paths to references */ for (l = rows; l; l = l->next) { GtkTreePath *tp = l->data; l->data = gtk_tree_row_reference_new(model, tp); gtk_tree_path_free(tp); } /* remove rows from model */ for (l = rows; l; l = l->next) { if (gtk_tree_model_get_iter(model, &it, gtk_tree_row_reference_get_path(l->data))) { char *type; gtk_tree_model_get(model, &it, 2, &type, -1); if (type) g_hash_table_remove(app_config->autorun_choices, type); g_free(type); gtk_list_store_remove(GTK_LIST_STORE(model), &it); } else g_critical("autorun_choice not found in model"); gtk_tree_row_reference_free(l->data); } g_list_free(rows); }
void notes_note_delete_selected(Notes * notes) { GtkTreeSelection * treesel; GList * selected; GtkTreeModel * model = GTK_TREE_MODEL(notes->store); GtkTreeRowReference * reference; GList * s; GtkTreePath * path; if((treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(notes->view))) == NULL) return; if((selected = gtk_tree_selection_get_selected_rows(treesel, NULL)) == NULL) return; if(_notes_confirm(notes->window, _("Are you sure you want to delete the" " selected note(s)?")) != 0) return; for(s = g_list_first(selected); s != NULL; s = g_list_next(s)) { if((path = s->data) == NULL) continue; reference = gtk_tree_row_reference_new(model, path); s->data = reference; gtk_tree_path_free(path); } g_list_foreach(selected, (GFunc)_note_delete_selected_foreach, notes); g_list_free(selected); }
gchar * xkb_layout_chooser_get_selected_id (GtkDialog * dialog) { GtkTreeModel *filtered_list_model; GtkWidget *xkb_filtered_layouts_list = g_object_get_data (G_OBJECT (dialog), "xkb_filtered_layouts_list"); GtkTreeIter viter; gchar *v_id; GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (xkb_filtered_layouts_list)); GList *selected_layouts = gtk_tree_selection_get_selected_rows (selection, &filtered_list_model); if (g_list_length (selected_layouts) != 1) return NULL; gtk_tree_model_get_iter (filtered_list_model, &viter, (GtkTreePath *) (selected_layouts->data)); g_list_foreach (selected_layouts, (GFunc) gtk_tree_path_free, NULL); g_list_free (selected_layouts); gtk_tree_model_get (filtered_list_model, &viter, COMBO_BOX_MODEL_COL_XKB_ID, &v_id, -1); return v_id; }
static void on_menu_item_copy_url (GtkWidget *menu_item, GtkTreeView *treeview) { GtkTreeSelection *selection; GtkTreeModel *treemodel; GtkTreeIter iter; GList *selected_rows, *i; GString *urls_buf; urls_buf = g_string_sized_new(500); selection = gtk_tree_view_get_selection (treeview); selected_rows = gtk_tree_selection_get_selected_rows (selection, &treemodel); i = g_list_first (selected_rows); while (i) { gchar *track_url; gtk_tree_model_get_iter (treemodel, &iter, (GtkTreePath *) i->data); gtk_tree_model_get (treemodel, &iter, URL_COLUMN, &track_url, -1); g_string_append (urls_buf, track_url); g_string_append (urls_buf, "\n"); g_free (track_url); i = g_list_next (i); } gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), urls_buf->str, urls_buf->len); g_list_free (selected_rows); g_string_free(urls_buf, TRUE); }
/** * Cette fonction retourne TRUE si tous les items sont sélectionnés * * \param le tree_view considéré * * \return TRUE si tous sélectionnés FALSE autrement. */ gboolean utils_tree_view_all_rows_are_selected ( GtkTreeView *tree_view ) { GtkTreeModel *model; GtkTreeIter iter; GtkTreeSelection *selection; GList *rows_list; gint index; model = gtk_tree_view_get_model ( tree_view ); selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) ); rows_list = gtk_tree_selection_get_selected_rows ( selection, &model ); index = g_list_length ( rows_list ); if ( gtk_tree_model_get_iter_first ( model, &iter ) ) { do { index--; if ( index < 0 ) break; } while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) ); } g_list_foreach ( rows_list, ( GFunc ) gtk_tree_path_free, NULL ); g_list_free ( rows_list ); if ( index == 0 ) return TRUE; else return FALSE; }
static void nsgtk_download_sensitivity_evaluate(GtkTreeSelection *selection) { GtkTreeIter iter; GList *rows; gboolean selected = gtk_tree_selection_count_selected_rows(selection); GtkTreeModel *model = GTK_TREE_MODEL(nsgtk_download_store); nsgtk_download_actions sensitivity = 0; struct gui_download_window *dl; if (selected) { rows = gtk_tree_selection_get_selected_rows(selection, &model); while (rows != NULL) { gtk_tree_model_get_iter(model, &iter, (GtkTreePath*)rows->data); gtk_tree_model_get(model, &iter, NSGTK_DOWNLOAD, &dl, -1); sensitivity |= dl->sensitivity; rows = rows->next; } } else { rows = nsgtk_downloads_list; while (rows != NULL) { dl = rows->data; sensitivity |= (dl->sensitivity & NSGTK_DOWNLOAD_CLEAR); rows = rows->next; } } nsgtk_download_sensitivity_update_buttons(sensitivity); }
static void selection_cb(GtkTreeSelection *selection, GtkTreeModel *model) { GtkTreeIter iter; GValue value = {0, }; GtkTreePath *path; int nr_selected = gtk_tree_selection_count_selected_rows(selection); if (selected_dives) { g_list_foreach (selected_dives, (GFunc) gtk_tree_path_free, NULL); g_list_free (selected_dives); } selected_dives = gtk_tree_selection_get_selected_rows(selection, NULL); switch (nr_selected) { case 0: /* keep showing the last selected dive */ return; case 1: /* just pick that dive as selected */ path = g_list_nth_data(selected_dives, 0); if (gtk_tree_model_get_iter(model, &iter, path)) { gtk_tree_model_get_value(model, &iter, DIVE_INDEX, &value); selected_dive = g_value_get_int(&value); repaint_dive(); } return; default: /* multiple selections - what now? At this point I * don't want to change the selected dive unless * there is exactly one dive selected; not sure this * is the most intuitive solution. * I do however want to keep around which dives have * been selected */ return; } }
static void nsgtk_download_do(nsgtk_download_selection_action action) { GList *rows, *dls = NULL; GtkTreeModel *model = GTK_TREE_MODEL(nsgtk_download_store); gboolean selection_exists = gtk_tree_selection_count_selected_rows( nsgtk_download_selection); if (selection_exists) { rows = gtk_tree_selection_get_selected_rows( nsgtk_download_selection, &model); while (rows != NULL) { struct gui_download_window *dl; gtk_tree_model_get_iter(GTK_TREE_MODEL( nsgtk_download_store), &nsgtk_download_iter, (GtkTreePath*)rows->data); gtk_tree_model_get(GTK_TREE_MODEL(nsgtk_download_store), &nsgtk_download_iter, NSGTK_DOWNLOAD, &dl, -1); dls = g_list_prepend(dls, dl); rows = rows->next; } g_list_foreach(rows, (GFunc)gtk_tree_path_free, NULL); g_list_foreach(rows, (GFunc)g_free, NULL); g_list_free(rows); } else dls = g_list_copy(nsgtk_downloads_list); g_list_foreach(dls, (GFunc)action, NULL); g_list_free(dls); }
static void submit() { GtkTreeModel *model; GtkTreeSelection *selected = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); GList *list = gtk_tree_selection_get_selected_rows(selected, &model); GSList *files = NULL; GList *item; GtkTreeIter iter; for(item = list; item != NULL; item = g_list_next(item)) { GtkTreePath *treepath = item->data; gtk_tree_model_get_iter(model, &iter, treepath); gchar *path, *name; gtk_tree_model_get(model, &iter, 0, &path, 1, &name, -1); gchar *file = g_build_path(G_DIR_SEPARATOR_S, base_directory, path, name, NULL); files = g_slist_append(files, file); g_free(path); g_free(name); } document_open_files(files, FALSE, NULL, NULL); g_slist_foreach(files, (GFunc)g_free, NULL); //free filenames g_slist_free(files); }
static void remove_button_clicked(GtkButton *button, XmiMsimGuiLayerDialog *dialog) { GtkTreeModel *model; GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->compositionTreeView)); GList *selected_rows = gtk_tree_selection_get_selected_rows(selection, &model); gint n_selected_rows = gtk_tree_selection_count_selected_rows(selection); GtkTreeRowReference **refs = (GtkTreeRowReference**) g_malloc(sizeof(GtkTreeRowReference*)*n_selected_rows); int i; // the following really needs two for loops!!! // paths change while rows are being added or removed, while references never change for (i = 0 ; i < n_selected_rows ; i++) { refs[i] = gtk_tree_row_reference_new(model, (GtkTreePath *) g_list_nth_data(selected_rows, i)); } for (i = 0 ; i < n_selected_rows ; i++) { GtkTreePath *path = gtk_tree_row_reference_get_path(refs[i]); GtkTreeIter iter; gtk_tree_model_get_iter(model, &iter, path); //delete row happens here gtk_list_store_remove(GTK_LIST_STORE(model), &iter); gtk_tree_path_free(path); gtk_tree_row_reference_free(refs[i]); } g_list_free_full(selected_rows, (GDestroyNotify) gtk_tree_path_free); g_free(refs); //the sum needs to be updated update_sum(dialog); return; }
/* * Tree view selection changed callback */ void on_selection_changed(GtkTreeSelection *treeselection, gpointer user_data) { if (handle_selection) { GList *rows = gtk_tree_selection_get_selected_rows(treeselection, &model); GtkTreePath *path = (GtkTreePath*)rows->data; GtkTreeIter iter; gtk_tree_model_get_iter ( gtk_tree_view_get_model(GTK_TREE_VIEW(tree)), &iter, path); gchar *file; int line; gtk_tree_model_get ( gtk_tree_view_get_model(GTK_TREE_VIEW(tree)), &iter, S_FILEPATH, &file, S_LINE, &line, -1); /* check if file name is not empty and we have source files for the frame */ if (strlen(file) && GPOINTER_TO_INT(g_hash_table_lookup(frames, (gpointer)file))) callback(file, line); g_free(file); gtk_tree_path_free(path); g_list_free(rows); } }
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); } }
void JIDList::Remove(GtkButton *button, JIDList *c) { GtkTreeIter iter; GtkTreeModel *model; model = gtk_tree_view_get_model(GTK_TREE_VIEW(glade_xml_get_widget(c->gxml, "list"))); for(;;) { GtkTreeSelection* select = gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(c->gxml, "list"))); GList *list = gtk_tree_selection_get_selected_rows(select, &model); if ( list ) { gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, (GtkTreePath *) list->data); gtk_list_store_remove(GTK_LIST_STORE(model), &iter); } else break; g_list_foreach (list, ( void(*)(void*, void*)) gtk_tree_path_free, NULL); g_list_free (list); } }
void on_tabu_playlist_row_activated_event ( GtkTreeView *view ) { GList *selected; GtkTreeModel *store; GtkTreeIter iter; gchar *uri; GtkTreeSelection *selection = gtk_tree_view_get_selection ( view ); selected = gtk_tree_selection_get_selected_rows ( selection, &store ); if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, selected->data)) { gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 2, &uri, -1); tabu_playlist_set_song (tabu_get_playlist(), FALSE); TABU_PLAYLIST (tabu_get_playlist())->reference = gtk_tree_row_reference_new (store, selected->data); tabu_playlist_set_song (tabu_get_playlist(), TRUE); tabu_backend_play_uri (uri); } g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL); g_list_free (selected); }
G_MODULE_EXPORT void gw_settingswindow_drag_begin_cb (GtkWidget *widget, GdkDragContext *context, gpointer data) { cairo_surface_t *surface; GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; GtkTreePath *path; GList *selectedlist; view = GTK_TREE_VIEW (widget); model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); selectedlist = gtk_tree_selection_get_selected_rows (selection, &model); path = (GtkTreePath*) selectedlist->data; surface = gtk_tree_view_create_row_drag_icon (view, path); gtk_drag_set_icon_surface (context, surface); cairo_surface_destroy (surface); g_list_foreach (selectedlist, (GFunc) gtk_tree_path_free, NULL); g_list_free (selectedlist); }
static void sum_selected_rows(GtkTreeSelection *selection, gpointer user_data) { GtkLabel *label; GtkTreeModel *model; GList *list; GList *cur; gchar *row_string; GtkTreeIter iter; label = g_object_get_data(G_OBJECT(selection), "label"); list = gtk_tree_selection_get_selected_rows(selection, &model); if (list == NULL) { gtk_label_set_text(label, ""); return; } for (cur = g_list_first(list); cur != NULL; cur = g_list_next(cur)) { if (gtk_tree_model_get_iter(model, &iter, (GtkTreePath *)cur->data) == TRUE) { gtk_tree_model_get(model, &iter, COLUMN_FIELD_NAME, &row_string, -1); } gtk_tree_path_free((GtkTreePath *)cur->data); } g_list_free(list); gtk_label_set_text(label, row_string); }
static void remmina_ftp_client_action_download(GObject *object, RemminaFTPClient *client) { RemminaFTPClientPriv *priv = (RemminaFTPClientPriv*) client->priv; GtkTreeSelection *selection; gchar *localdir; GList *list, *list_iter; GtkTreeIter iter; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->file_list_view)); if (!selection) return; list = gtk_tree_selection_get_selected_rows(selection, NULL); if (!list) return; localdir = remmina_ftp_client_get_download_dir(client); if (!localdir) { g_list_free(list); return; } list_iter = g_list_first(list); while (list_iter) { gtk_tree_model_get_iter(priv->file_list_sort, &iter, (GtkTreePath*) list_iter->data); remmina_ftp_client_download(client, &iter, localdir); list_iter = g_list_next(list_iter); } g_list_free(list); g_free(localdir); }
static GList * gnac_profiles_mgr_get_selected_rows(void) { GtkTreeModel *model = GTK_TREE_MODEL( gnac_profiles_mgr_get_object("liststore")); GtkTreeView *view = GTK_TREE_VIEW( gnac_profiles_mgr_get_widget("profile_treeview")); GtkTreeSelection *selection = gtk_tree_view_get_selection(view); /* Convert path to GtkTreeRowReference */ GList *next = gtk_tree_selection_get_selected_rows(selection, &model); GList *next_temp = next; GList *row_references = NULL; while (next) { row_references = g_list_prepend(row_references, gtk_tree_row_reference_new(model, next->data)); next = g_list_next(next); } row_references = g_list_reverse(row_references); g_list_free_full(next_temp, (GDestroyNotify) gtk_tree_path_free); return row_references; }
/* true if exactly one item is selected */ bool list_get_selected(GtkWidget *list, GtkTreeModel **model, GtkTreeIter *iter) { GtkTreeSelection *sel = list_get_selection(list); #if 1 // this copes with multiple selections ... bool retval = false; GList *slist = gtk_tree_selection_get_selected_rows(sel, model); if(g_list_length(slist) == 1) retval = gtk_tree_model_get_iter(*model, iter, static_cast<GtkTreePath *>(slist->data)) == TRUE; #if GLIB_CHECK_VERSION(2,28,0) g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free)); #else g_list_foreach(slist, reinterpret_cast<GFunc>(gtk_tree_path_free), nullptr); g_list_free(slist); #endif return retval; #else // ... this doesn't return gtk_tree_selection_get_selected(sel, model, iter) == TRUE; #endif }
/** * ephy_node_view_edit: * @view: an #EphyNodeView * @remove_if_cancelled: whether the edited node should be removed if editing is cancelled * * Edits the currently selected node in @view, the @remove_if_cancelled parameter * controls if the node should be removed if editing is cancelled. **/ void ephy_node_view_edit (EphyNodeView *view, gboolean remove_if_cancelled) { GtkTreePath *path; GtkTreeSelection *selection; GList *rows; GtkTreeModel *model; g_return_if_fail (view->priv->editable_renderer != NULL); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); rows = gtk_tree_selection_get_selected_rows (selection, &model); if (rows == NULL) return; path = rows->data; g_object_set (G_OBJECT (view->priv->editable_renderer), "editable", TRUE, NULL); gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, view->priv->editable_column, TRUE); view->priv->edited_node = get_node_from_path (view, path); view->priv->remove_if_cancelled = remove_if_cancelled; g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); g_list_free (rows); }
void rc_gui_list2_delete_lists() { static GList *path_list = NULL; GList *list_foreach; GtkTreeIter iter; if(path_list!=NULL) { g_list_foreach(path_list, (GFunc)gtk_tree_path_free, NULL); g_list_free(path_list); path_list = NULL; } path_list = gtk_tree_selection_get_selected_rows( rc_ui->list2_selection, NULL); if(path_list==NULL) return; path_list = g_list_sort(path_list, (GCompareFunc)gtk_tree_path_compare); for(list_foreach=g_list_last(path_list);list_foreach!=NULL; list_foreach=g_list_previous(list_foreach)) { gtk_tree_model_get_iter(rc_ui->list2_tree_model, &iter, list_foreach->data); gtk_list_store_remove(GTK_LIST_STORE(rc_ui->list2_tree_model), &iter); } if(path_list!=NULL) { g_list_foreach(path_list, (GFunc)gtk_tree_path_free, NULL); g_list_free(path_list); path_list = NULL; } }