1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  * plugin.h
4  * Copyright (C) Massimo Cora' 2007-2008 <maxcvs@email.it>
5  *
6  * plugin.h is free software.
7  *
8  * You may redistribute it and/or modify it under the terms of the
9  * GNU General Public License, as published by the Free Software
10  * Foundation; either version 2 of the License, or (at your option)
11  * any later version.
12  *
13  * plugin.h is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with plugin.h.  If not, write to:
20  * 	The Free Software Foundation, Inc.,
21  * 	51 Franklin Street, Fifth Floor
22  * 	Boston, MA  02110-1301, USA.
23  */
24 
25 #ifndef _SYMBOL_DB_H_
26 #define _SYMBOL_DB_H_
27 
28 #include <libanjuta/anjuta-plugin.h>
29 #include <libanjuta/anjuta-launcher.h>
30 #include "symbol-db-engine.h"
31 
32 
33 G_BEGIN_DECLS
34 
35 extern GType symbol_db_get_type (GTypeModule *module);
36 #define ANJUTA_TYPE_PLUGIN_SYMBOL_DB         (symbol_db_get_type (NULL))
37 #define ANJUTA_PLUGIN_SYMBOL_DB(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_PLUGIN_SYMBOL_DB, SymbolDBPlugin))
38 #define ANJUTA_PLUGIN_SYMBOL_DB_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), ANJUTA_TYPE_PLUGIN_SYMBOL_DB, SymbolDBPluginClass))
39 #define ANJUTA_IS_PLUGIN_SYMBOL_DB(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_PLUGIN_SYMBOL_DB))
40 #define ANJUTA_IS_PLUGIN_SYMBOL_DB_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_PLUGIN_SYMBOL_DB))
41 #define ANJUTA_PLUGIN_SYMBOL_DB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ANJUTA_TYPE_PLUGIN_SYMBOL_DB, SymbolDBPluginClass))
42 
43 
44 typedef struct _SymbolDBPlugin SymbolDBPlugin;
45 typedef struct _SymbolDBPluginClass SymbolDBPluginClass;
46 
47 
48 #include "symbol-db-system.h"
49 #include "symbol-db-query.h"
50 
51 /* default value for ctags executable. User must have it installed. This is a
52  * personalized version of ctags for Anjuta.
53  */
54 #define CTAGS_PATH	PACKAGE_BIN_DIR"/anjuta-tags"
55 
56 
57 typedef struct _PackageScanData {
58 	gchar *package_name;
59 	gchar *package_version;
60 	gint proc_id;
61 	gint files_length;
62 	gint files_done;
63 
64 } PackageScanData;
65 
66 struct _SymbolDBPlugin {
67 	AnjutaPlugin parent;
68 	AnjutaUI *ui;
69 	GSettings* settings;
70 
71 	/* project monitor */
72 	guint root_watch_id;
73 
74 	/* ui merge */
75 	GtkActionGroup *popup_action_group;
76 	GtkActionGroup *menu_action_group;
77 	gint merge_id;
78 
79 	/* preferences */
80 	GtkBuilder *prefs_bxml;
81 
82 	/* editor monitor */
83 	guint buf_update_timeout_id;
84 	gboolean need_symbols_update;
85 	GTimer *update_timer;
86 	GPtrArray *buffer_update_files;
87 	GPtrArray *buffer_update_ids;
88 	gboolean buffer_update_semaphore;		/* it monitors the update status of the
89 	 										 * buffer _and_ the editor switching.
90 	 										 * A new page cannot be updated with the
91 	 										 * new view-locals symbols if a scanning
92 	 										 * is in progress
93 	 										 */
94 	guint editor_watch_id;
95 	gchar *project_root_uri;
96 	gchar *project_root_dir;
97 	gchar *project_opened;
98 	gboolean needs_sources_scan;
99 
100 	/* Symbol's engine connection to database. Instance for local project */
101 	SymbolDBEngine *sdbe_project;
102 
103 	/* global's one */
104 	SymbolDBEngine *sdbe_globals;
105 	GAsyncQueue *global_scan_aqueue;
106 	PackageScanData *current_pkg_scanned;
107 
108 
109 	/* system's population object */
110 	SymbolDBSystem *sdbs;
111 
112 	GtkWidget *dbv_main;					/* symbol main window [gtk_box] */
113 	GtkWidget *dbv_notebook;          		/* main notebook */
114 	GtkWidget *dbv_hbox;					/* hbox for notebook buttons */
115 	/*
116 	 GtkWidget *scrolled_global; */			/* symbol view scrolledwindow for global
117 										   	symbols */
118 
119 	GtkWidget *tabber;
120 
121 	/* GtkWidget *scrolled_locals; */
122 	GtkWidget *scrolled_search;
123 	GtkWidget *progress_bar_project;		/* symbol db progress bar - project */
124 	GtkWidget *progress_bar_system;			/* symbol db progress bar - system (globals) */
125 
126 	GtkTreeModel *file_model;               /* File symbols model */
127 	GtkWidget *search_entry;                /* The search entry box */
128 	GtkWidget *pref_tree_view; 				/* Preferences treeview */
129 
130 	/* current editor */
131 	GObject *current_editor;
132 	GHashTable *editor_connected;
133 	GHashTable *editors;
134 
135 	/* In session loading? */
136 	gboolean session_loading;
137 
138 	gint files_count_project;
139 	gint files_count_project_done;
140 
141 	gint files_count_system;
142 	gint files_count_system_done;
143 	gchar *current_scanned_package;
144 
145 	IAnjutaSymbolQuery *search_query;
146 
147 	GTree *proc_id_tree;				/* the scan processes'll receive an id from
148 	 									 * the symbol engine when scan-end happens.
149 	 									 * Track them here */
150 
151 	gboolean is_project_importing;		/* refreshes or resumes after abort */
152 	gboolean is_project_updating;		/* makes up to date symbols of the project's files */
153 	gboolean is_offline_scanning;		/* detects offline changes to makefile.am */
154 	gboolean is_adding_element;			/* we're adding an element */
155 };
156 
157 struct _SymbolDBPluginClass {
158 	AnjutaPluginClass parent_class;
159 
160 	/* signals */
161 	void (* project_import_end) 	(void);
162 	void (* globals_import_end) 	(void);
163 
164 };
165 
166 
167 
168 G_END_DECLS
169 
170 #endif
171