Revision: 1922 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1922&view=re... Author: dimitrov-adrian Date: 2011-02-11 22:39:15 +0000 (Fri, 11 Feb 2011)
Log Message: ----------- Added close children, Bugfix with file endings with ~ and check_hidden replacement
Modified Paths: -------------- trunk/geany-plugins/treebrowser/ChangeLog trunk/geany-plugins/treebrowser/README trunk/geany-plugins/treebrowser/src/treebrowser.c
Modified: trunk/geany-plugins/treebrowser/ChangeLog =================================================================== --- trunk/geany-plugins/treebrowser/ChangeLog 2011-02-11 20:28:34 UTC (rev 1921) +++ trunk/geany-plugins/treebrowser/ChangeLog 2011-02-11 22:39:15 UTC (rev 1922) @@ -35,11 +35,20 @@ +-------------------------------+
+10-02-2011 Adrian Dimitrov dimitrov.adrian@gmail.com + + * src/treebrowser.c + Added function to close directory childrens (patch by Oliver Marks (#3175562), thanks) + Replaced TreeBrowser`s hidden file check with the native filebrowser check (thanks to geany`s team), + this may be fixing the bug #3157070 (Treebrowser plugin crashes Geany with files ending in ~) + + 14-12-2010 Adrian Dimitrov dimitrov.adrian@gmail.com
* src/treebrowser.c Fixed nighty compilation error (reported by Enrico Tröger)
+ 10-12-2010 Adrian Dimitrov dimitrov.adrian@gmail.com
* ChangeLog
Modified: trunk/geany-plugins/treebrowser/README =================================================================== --- trunk/geany-plugins/treebrowser/README 2011-02-11 20:28:34 UTC (rev 1921) +++ trunk/geany-plugins/treebrowser/README 2011-02-11 22:39:15 UTC (rev 1922) @@ -1,6 +1,6 @@ .. |(version)| replace:: 0.20
-Treebrowser plugin +TreeBrowser plugin ==================
.. contents:: @@ -9,18 +9,17 @@ About =====
-The TreeBrowser plugin for Geany provides an alternate way to browse through -your files. It displays files and directories in a tree view and has more -features than the file browser plugin delivered with Geany itself. - - .. image:: http://img43.imageshack.us/img43/9053/screenshotsmallq.png :width: 400 :alt: treebrowser plugin :align: right :target: http://img828.imageshack.us/img828/1351/screenshot1fq.png
+The TreeBrowser plugin for Geany provides an alternate way to browse through +your files. It displays files and directories in a tree view and has more +features than the file browser plugin delivered with Geany itself.
+ Features ========
@@ -46,6 +45,14 @@ Tools->Plugin Manager and set checkbox at TreeBrowser plugin
+FAQ +=== + +* My base directory is not remember + Yes it isn`t saved, and I don`t think that it have to be saved while We have in Geany "Startup path", and "Load from the last session" + These settings are useful and the plugin take care about them, use them and the problem with the last directory remembering will be solved. + + Download Source ===============
@@ -57,13 +64,9 @@ Installation ============
- * Ubuntu/Debian - `sudo apt-get install geany-plugin-treebrowser` + The plugin is part from the geany-plugins projects, you can see the plugin`s install page at http://plugins.geany.org/install.html
- * Fedora - `yum install geany-plugins-treebrowser`
- License =======
Modified: trunk/geany-plugins/treebrowser/src/treebrowser.c =================================================================== --- trunk/geany-plugins/treebrowser/src/treebrowser.c 2011-02-11 20:28:34 UTC (rev 1921) +++ trunk/geany-plugins/treebrowser/src/treebrowser.c 2011-02-11 22:39:15 UTC (rev 1922) @@ -18,6 +18,9 @@ # include <gio/gio.h> #endif
+#ifdef G_OS_WIN32 +# include <windows.h> +#endif
/* These items are set by Geany before plugin_init() is called. */ GeanyPlugin *geany_plugin; @@ -216,13 +219,14 @@ #endif }
+/* Return: FALSE - if file is filtered and not shown, and TRUE - if file isn`t filtered, and have to be shown */ static gboolean check_filtered(const gchar *base_name) { gchar **filters; guint i; gboolean temporary_reverse = FALSE; - const gchar *exts[] = {".o", ".obj", ".so", ".dll", ".a", ".lib"}; + const gchar *exts[] = {".o", ".obj", ".so", ".dll", ".a", ".lib", ".la", ".lo", ".pyc"}; guint exts_len; const gchar *ext; gboolean filtered; @@ -265,66 +269,47 @@ return filtered; }
+#ifdef G_OS_WIN32 static gboolean -check_hidden(const gchar *uri) +win32_check_hidden(const gchar *filename) { - gboolean is_visible = TRUE; - gchar *base_name; + DWORD attrs; + static wchar_t w_filename[MAX_PATH]; + MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename)); + attrs = GetFileAttributesW(w_filename); + if (attrs != INVALID_FILE_ATTRIBUTES && attrs & FILE_ATTRIBUTE_HIDDEN) + return TRUE; + return FALSE; +} +#endif
-#ifdef G_OS_WIN32 -# ifdef HAVE_GIO - GFile *file; - GFileInfo *info; +/* Returns: whether name should be hidden. */ +static gboolean +check_hidden(const gchar *filename) +{ + const gchar *base_name = NULL; + base_name = g_path_get_basename(filename); + gsize len;
- if (CONFIG_SHOW_HIDDEN_FILES) - { - g_object_unref(info); - g_object_unref(file); - g_free(base_name); - return TRUE; - } - - if (uri[strlen(uri) - 1] == '~') - { - g_object_unref(info); - g_object_unref(file); - g_free(base_name); + if (! NZV(base_name)) return FALSE; - }
- file = g_file_new_for_path(uri); - info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN, 0, NULL, NULL); - if (info) - { - if (g_file_info_get_is_hidden(info)) - is_visible = FALSE; - g_object_unref(info); - } - g_object_unref(file); -# endif /* HAVE_GIO */ -#else /* G_OS_WIN32 */ - - if (CONFIG_SHOW_HIDDEN_FILES) - { - g_free(base_name); +#ifdef G_OS_WIN32 + if (win32_check_hidden(filename)) return TRUE; - } - - if (uri[strlen(uri) - 1] == '~') - { - g_free(base_name); - return FALSE; - } - - base_name = g_path_get_basename(uri); +#else if (base_name[0] == '.') - is_visible = FALSE; - g_free(base_name); + return TRUE; #endif
- return is_visible; + len = strlen(base_name); + if (base_name[len - 1] == '~') + return TRUE; + + return FALSE; }
+ static gchar* get_default_dir() { @@ -460,7 +445,7 @@ is_dir = g_file_test (uri, G_FILE_TEST_IS_DIR); utf8_name = utils_get_utf8_from_locale(fname);
- if (check_hidden(uri)) + if (!check_hidden(uri)) { GdkPixbuf *icon = NULL;
@@ -1036,6 +1021,27 @@ }
static void +on_menu_close_children(GtkMenuItem *menuitem, gchar *uri) +{ + guint nb_documents = geany->documents_array->len; + int i; + int uri_len=strlen(uri); + for(i=0; i<GEANY(documents_array)->len; i++) + { + if(documents[i]->is_valid) + { + /* the docuemnt filename shoudl always be longer than the uri when closing children + * Compare the beginingin of the filename string to see if it matchs the uri*/ + if(strlen(documents[i]->file_name)>uri_len) + { + if(strncmp(uri,documents[i]->file_name,uri_len)==0) + document_close(documents[i]); + } + } + } +} + +static void on_menu_copy_uri(GtkMenuItem *menuitem, gchar *uri) { GtkClipboard *cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); @@ -1128,6 +1134,11 @@ g_signal_connect(item, "activate", G_CALLBACK(on_menu_close), uri); gtk_widget_set_sensitive(item, is_document);
+ item = ui_image_menu_item_new(GTK_STOCK_CLOSE, g_strdup_printf(_("Close Child Documents "))); + gtk_container_add(GTK_CONTAINER(menu), item); + g_signal_connect(item, "activate", G_CALLBACK(on_menu_close_children), uri); + gtk_widget_set_sensitive(item, is_dir); + item = ui_image_menu_item_new(GTK_STOCK_COPY, _("Copy full path to clipboard")); gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_copy_uri), uri);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.