50
57
* ------------------ */
52
59
static gchar *CONFIG_FILE = NULL;
53
61
static gchar *CONFIG_OPEN_EXTERNAL_CMD = "nautilus '%d'";
63
static gchar *CONFIG_OPEN_EXTERNAL_CMD = "explorer '%d'";
54
65
static gboolean CONFIG_REVERSE_FILTER = FALSE;
55
66
static gboolean CONFIG_ONE_CLICK_CHDOC = FALSE;
56
67
static gboolean CONFIG_SHOW_HIDDEN_FILES = FALSE;
230
/* result must be freed */
232
path_is_in_dir(gchar* src, gchar* find)
236
gchar *diffed_path = NULL, *tmp = NULL;
237
gchar **src_segments = NULL, **find_segments = NULL;
238
guint src_segments_n = 0, find_segments_n = 0, n = 0;
240
src_segments = g_strsplit(src, G_DIR_SEPARATOR_S, 0);
241
find_segments = g_strsplit(find, G_DIR_SEPARATOR_S, 0);
243
src_segments_n = g_strv_length(src_segments);
244
find_segments_n = g_strv_length(find_segments);
247
if (find_segments_n < n)
251
if (utils_str_equal(find_segments[i], src_segments[i]) != TRUE)
255
tmp = g_strconcat(diffed_path == NULL ? "" : diffed_path,
256
G_DIR_SEPARATOR_S, find_segments[i], NULL);
261
g_strfreev(src_segments);
262
g_strfreev(find_segments);
267
/* Return: FALSE - if file is filtered and not shown, and TRUE - if file isn`t filtered, and have to be shown */
220
269
check_filtered(const gchar *base_name)
224
273
gboolean temporary_reverse = FALSE;
225
const gchar *exts[] = {".o", ".obj", ".so", ".dll", ".a", ".lib"};
274
const gchar *exts[] = {".o", ".obj", ".so", ".dll", ".a", ".lib", ".la", ".lo", ".pyc"};
227
276
const gchar *ext;
228
277
gboolean filtered;
269
check_hidden(const gchar *uri)
271
gboolean is_visible = TRUE;
279
if (CONFIG_SHOW_HIDDEN_FILES)
281
g_object_unref(info);
282
g_object_unref(file);
287
if (uri[strlen(uri) - 1] == '~')
289
g_object_unref(info);
290
g_object_unref(file);
295
file = g_file_new_for_path(uri);
296
info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN, 0, NULL, NULL);
299
if (g_file_info_get_is_hidden(info))
301
g_object_unref(info);
303
g_object_unref(file);
304
# endif /* HAVE_GIO */
305
#else /* G_OS_WIN32 */
307
if (CONFIG_SHOW_HIDDEN_FILES)
313
if (uri[strlen(uri) - 1] == '~')
319
base_name = g_path_get_basename(uri);
319
win32_check_hidden(const gchar *filename)
322
static wchar_t w_filename[MAX_PATH];
323
MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename));
324
attrs = GetFileAttributesW(w_filename);
325
if (attrs != INVALID_FILE_ATTRIBUTES && attrs & FILE_ATTRIBUTE_HIDDEN)
331
/* Returns: whether name should be hidden. */
333
check_hidden(const gchar *filename)
335
const gchar *base_name = NULL;
336
base_name = g_path_get_basename(filename);
339
if (! NZV(base_name))
343
if (win32_check_hidden(filename))
320
346
if (base_name[0] == '.')
350
len = strlen(base_name);
351
if (base_name[len - 1] == '~')
400
432
treebrowser_chroot(gchar *directory)
402
if (g_str_has_suffix(directory, "/"))
434
if (g_str_has_suffix(directory, G_DIR_SEPARATOR_S))
403
435
g_strlcpy(directory, directory, strlen(directory));
405
437
gtk_entry_set_text(GTK_ENTRY(addressbar), directory);
407
439
if (!directory || strlen(directory) == 0)
440
directory = G_DIR_SEPARATOR_S;
410
442
if (! treebrowser_checkdir(directory))
784
treebrowser_expand_to_path(gchar* root, gchar* find)
787
gboolean founded = FALSE, global_founded = FALSE;
789
gchar **root_segments = NULL, **find_segments = NULL;
790
guint root_segments_n = 0, find_segments_n = 0;
792
root_segments = g_strsplit(root, G_DIR_SEPARATOR_S, 0);
793
find_segments = g_strsplit(find, G_DIR_SEPARATOR_S, 0);
795
root_segments_n = g_strv_length(root_segments)-1;
796
find_segments_n = g_strv_length(find_segments)-1;
799
for (i = 1; i<=find_segments_n; i++)
801
new = g_strconcat(new, G_DIR_SEPARATOR_S, find_segments[i], NULL);
805
if (treebrowser_search(new, NULL))
806
global_founded = TRUE;
809
if (utils_str_equal(root, new) == TRUE)
814
g_strfreev(root_segments);
815
g_strfreev(find_segments);
817
return global_founded;
752
821
treebrowser_track_current()
755
824
GeanyDocument *doc = document_get_current();
756
825
gchar *path_current;
757
gchar **path_segments;
826
gchar **path_segments = NULL;
759
829
if (doc != NULL && doc->file_name != NULL && g_path_is_absolute(doc->file_name))
761
831
path_current = utils_get_locale_from_utf8(doc->file_name);
763
path_segments = g_strsplit(path_current, G_DIR_SEPARATOR_S, 0);
765
treebrowser_search(path_current, NULL);
767
* NEED TO REWORK THE CONCEPT
834
* Checking if the document is in the expanded or collapsed files
836
if (! treebrowser_search(path_current, NULL))
839
* Else we have to chroting to the document`s nearles path
842
froot = path_is_in_dir(addressbar_last_address, g_path_get_dirname(path_current));
845
froot = g_strdup(G_DIR_SEPARATOR_S);
847
if (utils_str_equal(froot, addressbar_last_address) != TRUE)
848
treebrowser_chroot(froot);
850
treebrowser_expand_to_path(froot, path_current);
770
853
g_strfreev(path_segments);
771
855
g_free(path_current);
980
on_menu_find_in_files(GtkMenuItem *menuitem, gchar *uri)
982
search_show_find_in_files_dialog(uri);
896
986
on_menu_create_new_object(GtkMenuItem *menuitem, gchar *type)
898
988
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
1129
on_menu_close_children(GtkMenuItem *menuitem, gchar *uri)
1132
int uri_len = strlen(uri);
1133
for (i=0; i < GEANY(documents_array)->len; i++)
1135
if (documents[i]->is_valid)
1137
/* the docuemnt filename shoudl always be longer than the uri when closing children
1138
* Compare the beginingin of the filename string to see if it matchs the uri*/
1139
if (strlen(documents[i]->file_name) > uri_len )
1141
if (strncmp(uri,documents[i]->file_name, uri_len)==0)
1142
document_close(documents[i]);
1039
1149
on_menu_copy_uri(GtkMenuItem *menuitem, gchar *uri)
1041
1151
GtkClipboard *cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
1099
1209
gtk_container_add(GTK_CONTAINER(menu), item);
1100
1210
g_signal_connect(item, "activate", G_CALLBACK(on_menu_refresh), NULL);
1212
item = ui_image_menu_item_new(GTK_STOCK_FIND, _("Find in Files"));
1213
gtk_container_add(GTK_CONTAINER(menu), item);
1214
g_signal_connect(item, "activate", G_CALLBACK(on_menu_find_in_files), uri);
1215
gtk_widget_set_sensitive(item, is_dir);
1102
1217
item = gtk_separator_menu_item_new();
1103
1218
gtk_container_add(GTK_CONTAINER(menu), item);
1128
1243
g_signal_connect(item, "activate", G_CALLBACK(on_menu_close), uri);
1129
1244
gtk_widget_set_sensitive(item, is_document);
1246
item = ui_image_menu_item_new(GTK_STOCK_CLOSE, g_strdup_printf(_("Close Child Documents ")));
1247
gtk_container_add(GTK_CONTAINER(menu), item);
1248
g_signal_connect(item, "activate", G_CALLBACK(on_menu_close_children), uri);
1249
gtk_widget_set_sensitive(item, is_dir);
1131
1251
item = ui_image_menu_item_new(GTK_STOCK_COPY, _("Copy full path to clipboard"));
1132
1252
gtk_container_add(GTK_CONTAINER(menu), item);
1133
1253
g_signal_connect(item, "activate", G_CALLBACK(on_menu_copy_uri), uri);