1 /*
2  * Nautilus-Actions
3  * A Nautilus extension which offers configurable context menu actions.
4  *
5  * Copyright (C) 2005 The GNOME Foundation
6  * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7  * Copyright (C) 2009-2014 Pierre Wieser and others (see AUTHORS)
8  *
9  * Nautilus-Actions is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * Nautilus-Actions is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Nautilus-Actions; see the file COPYING. If not, see
21  * <http://www.gnu.org/licenses/>.
22  *
23  * Authors:
24  *   Frederic Ruaudel <grumz@grumz.net>
25  *   Rodrigo Moya <rodrigo@gnome-db.org>
26  *   Pierre Wieser <pwieser@trychlos.org>
27  *   ... and many others (see AUTHORS)
28  */
29 
30 #ifndef __NACT_TREE_VIEW_H__
31 #define __NACT_TREE_VIEW_H__
32 
33 /*
34  * SECTION: nact-tree-view
35  * @title: NactTreeView
36  * @short_description: The Tree View Base Class Definition
37  * @include: nact-tree-view.h
38  *
39  * This is a convenience class to manage a read-only items tree view.
40  *
41  * The NactTreeView encapsulates the GtkTreeView which displays the items
42  * list on the left of the main pane.
43  *
44  * It is instanciated from NactMainWindow::on_initialize_gtk().
45  *
46  * A pointer to this NactTreeView is attached to the NactMainWindow at
47  * construction time.
48  */
49 
50 #include <api/na-object-item.h>
51 
52 #include "base-window.h"
53 
54 G_BEGIN_DECLS
55 
56 #define NACT_TYPE_TREE_VIEW                ( nact_tree_view_get_type())
57 #define NACT_TREE_VIEW( object )           ( G_TYPE_CHECK_INSTANCE_CAST( object, NACT_TYPE_TREE_VIEW, NactTreeView ))
58 #define NACT_TREE_VIEW_CLASS( klass )      ( G_TYPE_CHECK_CLASS_CAST( klass, NACT_TYPE_TREE_VIEW, NactTreeViewClass ))
59 #define NACT_IS_TREE_VIEW( object )        ( G_TYPE_CHECK_INSTANCE_TYPE( object, NACT_TYPE_TREE_VIEW ))
60 #define NACT_IS_TREE_VIEW_CLASS( klass )   ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NACT_TYPE_TREE_VIEW ))
61 #define NACT_TREE_VIEW_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NACT_TYPE_TREE_VIEW, NactTreeViewClass ))
62 
63 typedef struct _NactTreeViewPrivate        NactTreeViewPrivate;
64 
65 typedef struct {
66 	/*< private >*/
67 	GObject              parent;
68 	NactTreeViewPrivate *private;
69 }
70 	NactTreeView;
71 
72 typedef struct _NactTreeViewClassPrivate   NactTreeViewClassPrivate;
73 
74 typedef struct {
75 	/*< private >*/
76 	GObjectClass              parent;
77 	NactTreeViewClassPrivate *private;
78 }
79 	NactTreeViewClass;
80 
81 /**
82  * Properties defined by the NactTreeView class.
83  * They should be provided at object instantiation time.
84  *
85  * @TREE_PROP_WINDOW:         the BaseWindow.
86  * @TREE_PROP_PARENT:         the widget which is parent of this tree view.
87  * @TREE_PROP_WIDGET_NAME:    the tree view widget name.
88  * @TREE_PROP_MODE:           management mode.
89  * @TREE_PROP_NOTIFY_ALLOWED: whether notifications are allowed.
90  */
91 #define TREE_PROP_WINDOW						"tree-prop-window"
92 #define TREE_PROP_PARENT						"tree-prop-parent"
93 #define TREE_PROP_WIDGET_NAME					"tree-prop-widget-name"
94 #define TREE_PROP_MODE							"tree-prop-mode"
95 #define TREE_PROP_NOTIFY_ALLOWED				"tree-prop-notify-allowed"
96 
97 /**
98  * Signals emitted by the NactTreeView instance.
99  */
100 #define TREE_SIGNAL_COUNT_CHANGED				"tree-signal-count-changed"
101 #define TREE_SIGNAL_FOCUS_IN					"tree-signal-focus-in"
102 #define TREE_SIGNAL_FOCUS_OUT					"tree-signal-focus-out"
103 #define TREE_SIGNAL_LEVEL_ZERO_CHANGED			"tree-signal-level-zero-changed"
104 #define TREE_SIGNAL_MODIFIED_STATUS_CHANGED		"tree-signal-modified-status-changed"
105 
106 typedef enum {
107 	TREE_MODE_EDITION = 0,
108 	TREE_MODE_SELECTION,
109 	/*< private >*/
110 	TREE_MODE_N_MODES
111 }
112 	NactTreeMode;
113 
114 /**
115  * When getting a list of items; these indcators may be OR-ed.
116  */
117 enum {
118 	TREE_LIST_SELECTED = 1<<0,
119 	TREE_LIST_MODIFIED = 1<<1,
120 	TREE_LIST_ALL      = 1<<7,
121 	TREE_LIST_DELETED  = 1<<8,
122 };
123 
124 /**
125  * The NactTreeView is attached to the parent BaseWindow via a GObject data.
126  * Only NactTreeView itself and NactTreeIEditable interface should use it.
127  */
128 #define WINDOW_DATA_TREE_VIEW					"window-data-tree-view"
129 
130 GType         nact_tree_view_get_type( void );
131 
132 NactTreeView *nact_tree_view_new( BaseWindow *window, GtkContainer *parent, const gchar *treeview_name, NactTreeMode mode );
133 
134 void          nact_tree_view_fill     ( NactTreeView *view, GList *items );
135 
136 gboolean      nact_tree_view_are_notify_allowed( const NactTreeView *view );
137 void          nact_tree_view_set_notify_allowed( NactTreeView *view, gboolean allow );
138 
139 void          nact_tree_view_collapse_all      ( const NactTreeView *view );
140 void          nact_tree_view_expand_all        ( const NactTreeView *view );
141 NAObjectItem *nact_tree_view_get_item_by_id    ( const NactTreeView *view, const gchar *id );
142 GList        *nact_tree_view_get_items         ( const NactTreeView *view );
143 GList        *nact_tree_view_get_items_ex      ( const NactTreeView *view, guint mode );
144 
145 void          nact_tree_view_select_row_at_path( NactTreeView *view, GtkTreePath *path );
146 
147 G_END_DECLS
148 
149 #endif /* __NACT_TREE_VIEW_H__ */
150