gerbv  2.10.1-dev~93f1b5
selection.c
Go to the documentation of this file.
1 /*
2  * gEDA - GNU Electronic Design Automation
3  *
4  * selection.c -- this file is a part of gerbv.
5  *
6  * Copyright (C) 2014 Sergey Alyoshin <alyoshin.s@gmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the Free
10  * Software Foundation; either version 2 of the License, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * this program; if not, write to the Free Software Foundation, Inc., 51
20  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
28 #include "gerbv.h"
29 
30 GArray*
31 selection_new_array(void) {
32  return g_array_new(FALSE, FALSE, sizeof(gerbv_selection_item_t));
33 }
34 
35 gchar*
36 selection_free_array(gerbv_selection_info_t* sel_info) {
37  return g_array_free(sel_info->selectedNodeArray, FALSE);
38 }
39 
40 guint
41 selection_length(gerbv_selection_info_t* sel_info) {
42  return sel_info->selectedNodeArray->len;
43 }
44 
45 gerbv_selection_item_t
46 selection_get_item_by_index(gerbv_selection_info_t* sel_info, guint idx) {
47  return g_array_index(sel_info->selectedNodeArray, gerbv_selection_item_t, idx);
48 }
49 
50 void
51 selection_clear_item_by_index(gerbv_selection_info_t* sel_info, guint idx) {
52  g_array_remove_index(sel_info->selectedNodeArray, idx);
53 }
54 
55 void
56 selection_clear(gerbv_selection_info_t* sel_info) {
57  if (selection_length(sel_info))
58  g_array_remove_range(sel_info->selectedNodeArray, 0, sel_info->selectedNodeArray->len);
59 }
60 
61 void
62 selection_add_item(gerbv_selection_info_t* sel_info, gerbv_selection_item_t* item) {
63  g_array_append_val(sel_info->selectedNodeArray, *item);
64 }
The main header file for the libgerbv library.