SF.net SVN: geany-plugins:[1700] trunk/geany-plugins/treebrowser

dimitrov-adrian at users.sourceforge.net dimitrov-adrian at xxxxx
Mon Nov 1 17:02:36 UTC 2010


Revision: 1700
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1700&view=rev
Author:   dimitrov-adrian
Date:     2010-11-01 17:02:36 +0000 (Mon, 01 Nov 2010)

Log Message:
-----------
Treebrowser: Added dialog question when creating/removing file, to prevent from losing target files if they exists.

Modified Paths:
--------------
    trunk/geany-plugins/treebrowser/ChangeLog
    trunk/geany-plugins/treebrowser/src/treebrowser.c

Modified: trunk/geany-plugins/treebrowser/ChangeLog
===================================================================
--- trunk/geany-plugins/treebrowser/ChangeLog	2010-11-01 15:18:52 UTC (rev 1699)
+++ trunk/geany-plugins/treebrowser/ChangeLog	2010-11-01 17:02:36 UTC (rev 1700)
@@ -36,6 +36,27 @@
 +-------------------------------+
 
 
+01-11-2010 	Adrian Dimitrov 		<dimitrov.adrian at gmail.com>
+
+	* src/treebrowser.c
+		Added dialog question when creating/removing file, to prevent from losing
+			target files if they exists.
+
+
+01-10-2010 	Adrian Dimitrov 		<dimitrov.adrian at gmail.com>
+
+	* ChangeLog
+		Revision 1688, Modified Thu Oct 28 21:02:33 2010 UTC by colombanw
+
+		Build system: don't force building the Treebrowser plugin
+
+		If the dependencies of the Treebrowser plugin are not met, simply
+		disable the plugin rather than abort the whole build.
+
+		Also add checks for creat(), sys/types.h, sys/stat.h and fcntl.h, and
+		fix the check for GIO to correctly handle the case it's not available.
+
+
 25-10-2010 	Adrian Dimitrov 		<dimitrov.adrian at gmail.com>
 
 	* src/treebrowser.c

Modified: trunk/geany-plugins/treebrowser/src/treebrowser.c
===================================================================
--- trunk/geany-plugins/treebrowser/src/treebrowser.c	2010-11-01 15:18:52 UTC (rev 1699)
+++ trunk/geany-plugins/treebrowser/src/treebrowser.c	2010-11-01 17:02:36 UTC (rev 1700)
@@ -881,21 +881,25 @@
 
 	if (uri_new)
 	{
-		gboolean creation_success = FALSE;
+		if (!(g_file_test(uri_new, G_FILE_TEST_EXISTS) &&
+			!dialogs_show_question(_("Target file '%s' exists\n, do you really want to replace it with empty file?"), uri_new)))
+		{
+			gboolean creation_success = FALSE;
 
-		while(g_file_test(uri_new, G_FILE_TEST_EXISTS))
-			setptr(uri_new, g_strconcat(uri_new, "_", NULL));
+			while(g_file_test(uri_new, G_FILE_TEST_EXISTS))
+				setptr(uri_new, g_strconcat(uri_new, "_", NULL));
 
-		if (utils_str_equal(type, "directory"))
-			creation_success = (g_mkdir(uri_new, 0755) == 0);
-		else
-			creation_success = (g_creat(uri_new, 0755) != -1);
+			if (utils_str_equal(type, "directory"))
+				creation_success = (g_mkdir(uri_new, 0755) == 0);
+			else
+				creation_success = (g_creat(uri_new, 0755) != -1);
 
-		if (creation_success)
-		{
-			treebrowser_browse(uri, refresh_root ? NULL : &iter);
-			if (treebrowser_search(uri_new, NULL))
-				treebrowser_rename_current();
+			if (creation_success)
+			{
+				treebrowser_browse(uri, refresh_root ? NULL : &iter);
+				if (treebrowser_search(uri_new, NULL))
+					treebrowser_rename_current();
+			}
 		}
 		g_free(uri_new);
 	}
@@ -1353,26 +1357,30 @@
 		if (uri)
 		{
 			uri_new = g_strconcat(g_path_get_dirname(uri), G_DIR_SEPARATOR_S, name_new, NULL);
-			if (g_rename(uri, uri_new) == 0)
+			if (!(g_file_test(uri_new, G_FILE_TEST_EXISTS) &&
+				!dialogs_show_question(_("Target file '%s' exists, do you really want to replace it?"), uri_new)))
 			{
-				gtk_tree_store_set(treestore, &iter,
-								TREEBROWSER_COLUMN_NAME, name_new,
-								TREEBROWSER_COLUMN_URI, uri_new,
-								-1);
-				path_parent = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), &iter);
-				if (gtk_tree_path_up(path_parent))
+				if (g_rename(uri, uri_new) == 0)
 				{
-					if (gtk_tree_model_get_iter(GTK_TREE_MODEL(treestore), &iter_parent, path_parent))
-						treebrowser_browse(g_path_get_dirname(uri_new), &iter_parent);
+					gtk_tree_store_set(treestore, &iter,
+									TREEBROWSER_COLUMN_NAME, name_new,
+									TREEBROWSER_COLUMN_URI, uri_new,
+									-1);
+					path_parent = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), &iter);
+					if (gtk_tree_path_up(path_parent))
+					{
+						if (gtk_tree_model_get_iter(GTK_TREE_MODEL(treestore), &iter_parent, path_parent))
+							treebrowser_browse(g_path_get_dirname(uri_new), &iter_parent);
+						else
+							treebrowser_browse(g_path_get_dirname(uri_new), NULL);
+					}
 					else
 						treebrowser_browse(g_path_get_dirname(uri_new), NULL);
+
+					if (!g_file_test(uri, G_FILE_TEST_IS_DIR))
+						if (document_close(document_find_by_filename(uri)))
+							document_open_file(uri_new, FALSE, NULL, NULL);
 				}
-				else
-					treebrowser_browse(g_path_get_dirname(uri_new), NULL);
-
-				if (!g_file_test(uri, G_FILE_TEST_IS_DIR))
-					if (document_close(document_find_by_filename(uri)))
-						document_open_file(uri_new, FALSE, NULL, NULL);
 			}
 			g_free(uri_new);
 			g_free(uri);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list