131
131
scroll.set_shadow_type(ShadowType.IN);
132
132
scroll.set_border_width(1);
133
133
this.pack_start(scroll);
138
private void fetch_data() {
139
string[] xdg_data_dirs = this.get_xdg_data_dirs();
140
var all_scopes = this.get_all_scopes(xdg_data_dirs);
143
private ScopeData get_scope_data(string scope_filename) {
147
private HashTable<string, GenericArray<string>> get_all_scopes(string[] xdg_data_dirs) {
148
var all_scopes = new HashTable<string, GenericArray<string>>(str_hash, str_equal);
150
foreach(string xdg_data in xdg_data_dirs) {
151
string dir_path = Path.build_filename(xdg_data, "unity", "scopes");
152
if(!FileUtils.test(dir_path, FileTest.EXISTS))
155
GenericArray<string> scopes = this.get_scope_files(dir_path);
156
all_scopes.insert(dir_path, scopes);
157
for(int i=0; i < scopes.length; i++) {
158
stdout.printf("%s\n", scopes[i]);
164
private GenericArray<string> get_scope_files(string dir_path) {
165
GenericArray<string> scopes = new GenericArray<string>();
166
var dir = Dir.open(dir_path);
168
while ((name = dir.read_name ()) != null) {
169
string path = Path.build_filename (dir_path, name);
170
if(FileUtils.test(path, FileTest.IS_REGULAR) && path.has_suffix(".scope")) {
173
if(FileUtils.test(path, FileTest.IS_DIR)) {
174
var sub_scopes = this.get_scope_files(path);
175
for(int i=0;i<sub_scopes.length;i++)
176
scopes.add(sub_scopes[i]);
182
private string[] get_xdg_data_dirs() {
183
string xdg_data = Environment.get_variable("XDG_DATA_DIRS");
184
if(xdg_data == null || xdg_data.strip().length == 0)
185
xdg_data = "/usr/share";
186
return xdg_data.split(":");
190
private class ScopeData {
191
public ScopeData(string scope_filepath) {