Make tree_is_expanded array static, add setter/getter function.
svn path=/trunk/; revision=50433
This commit is contained in:
parent
cd7712fd2f
commit
792f35a28c
16
epan/proto.c
16
epan/proto.c
|
@ -304,7 +304,7 @@ static void save_same_name_hfinfo(gpointer data)
|
|||
/* Points to the first element of an array of Booleans, indexed by
|
||||
a subtree item type; that array element is TRUE if subtrees of
|
||||
an item of that type are to be expanded. */
|
||||
gboolean *tree_is_expanded;
|
||||
static gboolean *tree_is_expanded;
|
||||
|
||||
/* Number of elements in that array. */
|
||||
int num_tree_types;
|
||||
|
@ -7404,6 +7404,20 @@ proto_check_field_name(const gchar *field_name)
|
|||
return wrs_check_charset(fld_abbrev_chars, field_name);
|
||||
}
|
||||
|
||||
gboolean
|
||||
tree_expanded(int tree_type)
|
||||
{
|
||||
g_assert(tree_type >= 0 && tree_type < num_tree_types);
|
||||
return tree_is_expanded[tree_type];
|
||||
}
|
||||
|
||||
void
|
||||
tree_expanded_set(int tree_type, gboolean value)
|
||||
{
|
||||
g_assert(tree_type >= 0 && tree_type < num_tree_types);
|
||||
tree_is_expanded[tree_type] = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
|
13
epan/proto.h
13
epan/proto.h
|
@ -1852,17 +1852,16 @@ WS_DLL_PUBLIC void proto_registrar_dump_fields(void);
|
|||
WS_DLL_PUBLIC void proto_registrar_dump_ftypes(void);
|
||||
|
||||
|
||||
|
||||
/** Points to the first element of an array of Booleans, indexed by
|
||||
a subtree item type. That array element is TRUE if subtrees of
|
||||
an item of that type are to be expanded. With MSVC and a
|
||||
libwireshark.dll, we need a special declaration. */
|
||||
WS_DLL_PUBLIC gboolean *tree_is_expanded;
|
||||
|
||||
/** Number of elements in the tree_is_expanded array. With MSVC and a
|
||||
* libwireshark.dll, we need a special declaration. */
|
||||
WS_DLL_PUBLIC int num_tree_types;
|
||||
|
||||
/** Returns TRUE if subtrees of that type are to be expanded. */
|
||||
WS_DLL_PUBLIC gboolean tree_expanded(int tree_type);
|
||||
|
||||
/** Sets if subtrees of that type are to be expanded. */
|
||||
WS_DLL_PUBLIC void tree_expanded_set(int tree_type, gboolean value);
|
||||
|
||||
/** glib doesn't have g_ptr_array_len of all things!*/
|
||||
#ifndef g_ptr_array_len
|
||||
#define g_ptr_array_len(a) ((a)?(a)->len:0)
|
||||
|
|
2
print.c
2
print.c
|
@ -238,7 +238,7 @@ void proto_tree_print_node(proto_node *node, gpointer data)
|
|||
g_assert((fi->tree_type >= -1) && (fi->tree_type < num_tree_types));
|
||||
if ((pdata->print_dissections == print_dissections_expanded) ||
|
||||
((pdata->print_dissections == print_dissections_as_displayed) &&
|
||||
(fi->tree_type >= 0) && tree_is_expanded[fi->tree_type])) {
|
||||
(fi->tree_type >= 0) && tree_expanded(fi->tree_type))) {
|
||||
if (node->first_child != NULL) {
|
||||
pdata->level++;
|
||||
proto_tree_children_foreach(node,
|
||||
|
|
|
@ -214,11 +214,8 @@ expand_tree(GtkTreeView *tree_view, GtkTreeIter *iter,
|
|||
* Nodes with "finfo->tree_type" of -1 have no ett_ value, and
|
||||
* are thus presumably leaf nodes and cannot be expanded.
|
||||
*/
|
||||
if (finfo->tree_type != -1) {
|
||||
g_assert(finfo->tree_type >= 0 &&
|
||||
finfo->tree_type < num_tree_types);
|
||||
tree_is_expanded[finfo->tree_type] = TRUE;
|
||||
}
|
||||
if (finfo->tree_type != -1)
|
||||
tree_expanded_set(finfo->tree_type, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -236,11 +233,8 @@ collapse_tree(GtkTreeView *tree_view, GtkTreeIter *iter,
|
|||
* Nodes with "finfo->tree_type" of -1 have no ett_ value, and
|
||||
* are thus presumably leaf nodes and cannot be collapsed.
|
||||
*/
|
||||
if (finfo->tree_type != -1) {
|
||||
g_assert(finfo->tree_type >= 0 &&
|
||||
finfo->tree_type < num_tree_types);
|
||||
tree_is_expanded[finfo->tree_type] = FALSE;
|
||||
}
|
||||
if (finfo->tree_type != -1)
|
||||
tree_expanded_set(finfo->tree_type, FALSE);
|
||||
}
|
||||
|
||||
struct field_lookup_info {
|
||||
|
@ -1288,9 +1282,10 @@ void
|
|||
expand_all_tree(proto_tree *protocol_tree _U_, GtkWidget *tree_view)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i < num_tree_types; i++) {
|
||||
tree_is_expanded[i] = TRUE;
|
||||
}
|
||||
|
||||
for(i=0; i < num_tree_types; i++)
|
||||
tree_expanded_set(i, TRUE);
|
||||
|
||||
gtk_tree_view_expand_all(GTK_TREE_VIEW(tree_view));
|
||||
}
|
||||
|
||||
|
@ -1298,9 +1293,10 @@ void
|
|||
collapse_all_tree(proto_tree *protocol_tree _U_, GtkWidget *tree_view)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i < num_tree_types; i++) {
|
||||
tree_is_expanded[i] = FALSE;
|
||||
}
|
||||
|
||||
for(i=0; i < num_tree_types; i++)
|
||||
tree_expanded_set(i, FALSE);
|
||||
|
||||
gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree_view));
|
||||
}
|
||||
|
||||
|
@ -1377,7 +1373,7 @@ expand_finfos(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointe
|
|||
|
||||
g_assert(fi->tree_type >= 0 && fi->tree_type < num_tree_types);
|
||||
|
||||
if (tree_is_expanded[fi->tree_type])
|
||||
if (tree_expanded(fi->tree_type))
|
||||
gtk_tree_view_expand_to_path(tree_view, path);
|
||||
else
|
||||
gtk_tree_view_collapse_row(tree_view, path);
|
||||
|
|
|
@ -140,7 +140,7 @@ proto_tree_draw_node(proto_node *node, gpointer data)
|
|||
}
|
||||
|
||||
if (is_branch) {
|
||||
if (tree_is_expanded[fi->tree_type]) {
|
||||
if (tree_expanded(fi->tree_type)) {
|
||||
item->setExpanded(true);
|
||||
} else {
|
||||
item->setExpanded(false);
|
||||
|
@ -334,7 +334,7 @@ void ProtoTree::expand(const QModelIndex & index) {
|
|||
if (fi->tree_type != -1) {
|
||||
g_assert(fi->tree_type >= 0 &&
|
||||
fi->tree_type < num_tree_types);
|
||||
tree_is_expanded[fi->tree_type] = TRUE;
|
||||
tree_expanded_set(fi->tree_type, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ void ProtoTree::collapse(const QModelIndex & index) {
|
|||
if (fi->tree_type != -1) {
|
||||
g_assert(fi->tree_type >= 0 &&
|
||||
fi->tree_type < num_tree_types);
|
||||
tree_is_expanded[fi->tree_type] = FALSE;
|
||||
tree_expanded_set(fi->tree_type, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ void ProtoTree::expandAll()
|
|||
{
|
||||
int i;
|
||||
for(i=0; i < num_tree_types; i++) {
|
||||
tree_is_expanded[i] = TRUE;
|
||||
tree_expanded_set(i, TRUE);
|
||||
}
|
||||
QTreeWidget::expandAll();
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ void ProtoTree::collapseAll()
|
|||
{
|
||||
int i;
|
||||
for(i=0; i < num_tree_types; i++) {
|
||||
tree_is_expanded[i] = FALSE;
|
||||
tree_expanded_set(i, FALSE);
|
||||
}
|
||||
QTreeWidget::collapseAll();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue