Skip to content

Commit

Permalink
* gtk_columnview.c (columnview_remove_selected): added.
Browse files Browse the repository at this point in the history
  • Loading branch information
htrb committed Nov 26, 2023
1 parent 22d232b commit 299eac3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/gtk/gtk_columnview.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,25 @@ columnview_select(GtkWidget *columnview, int i)
gtk_selection_model_unselect_all (selection);
gtk_selection_model_select_item (selection, i, FALSE);
}

void
columnview_remove_selected(GtkWidget *columnview)
{
GtkSelectionModel *selection;
GListStore *list;
int i, n;

selection = gtk_column_view_get_model (GTK_COLUMN_VIEW (columnview));
list = columnview_get_list (columnview);
n = g_list_model_get_n_items (G_LIST_MODEL (list));
for (i = n - 1; i >= 0; i--) {
NgraphInst *ni;
guint idx;
if (! gtk_selection_model_is_selected (selection, i)) {
continue;
}
ni = g_list_model_get_item (G_LIST_MODEL (selection), i);
g_list_store_find (list, ni, &idx);
g_list_store_remove (list, idx);
}
}
1 change: 1 addition & 0 deletions src/gtk/gtk_columnview.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ NgraphInst *columnview_append_ngraph_inst(GtkWidget *columnview, const gchar *na
void columnview_select_all(GtkWidget *columnview);
void columnview_unselect_all(GtkWidget *columnview);
void columnview_select(GtkWidget *columnview, int i);
void columnview_remove_selected(GtkWidget *columnview);

#endif

0 comments on commit 299eac3

Please sign in to comment.