anjuta r4795 - in trunk: . libanjuta plugins/file-wizard



Author: jhs
Date: Tue Feb 24 19:40:32 2009
New Revision: 4795
URL: http://svn.gnome.org/viewvc/anjuta?rev=4795&view=rev

Log:
2009-02-24  Johannes Schmid  <jhs gnome org>

	* libanjuta/anjuta-utils.c:
	Fix endless loop in g_file_convert_* and some warnings
	
	* plugins/file-wizard/file.c (on_add_to_project_toggled),
	(display_new_file), (on_new_file_okbutton_clicked):
	Fix add to repository for new file wizard

Modified:
   trunk/ChangeLog
   trunk/libanjuta/anjuta-utils.c
   trunk/plugins/file-wizard/file.c

Modified: trunk/libanjuta/anjuta-utils.c
==============================================================================
--- trunk/libanjuta/anjuta-utils.c	(original)
+++ trunk/libanjuta/anjuta-utils.c	Tue Feb 24 19:40:32 2009
@@ -82,20 +82,20 @@
 	
 	if (error)
 	{
-		g_warning (error->message);
+		g_warning ("%s", error->message);
 		g_error_free (error);
 		error = NULL;
 	}
 	
 	if (!g_output_stream_close (ostream, NULL, &error))
 	{
-		g_warning (error->message);
+		g_warning ("%s", error->message);
 		g_error_free (error);
 		error = NULL;
 	}
 	if (!g_input_stream_close (istream, NULL, &error))
 	{
-		g_warning (error->message);
+		g_warning ("%s", error->message);
 		g_error_free (error);
 	}
 }
@@ -1944,9 +1944,8 @@
 	gchar *path;
 	
 	path_list = NULL;
-	current_file = list;
 	
-	while (current_file)
+	for (current_file = list; current_file != NULL; current_file = g_list_next (current_file))
 	{
 		path = g_file_get_path (current_file->data);
 		
@@ -1971,10 +1970,8 @@
 	path_list = NULL;
 	
 	if (parent_file)
-	{
-		current_file = list;
-		
-		while (current_file)
+	{		
+		for (current_file = list; current_file != NULL; current_file = g_list_next (current_file))
 		{
 			path = g_file_get_relative_path (parent_file, current_file->data);
 			

Modified: trunk/plugins/file-wizard/file.c
==============================================================================
--- trunk/plugins/file-wizard/file.c	(original)
+++ trunk/plugins/file-wizard/file.c	Tue Feb 24 19:40:32 2009
@@ -37,6 +37,7 @@
 #include <libanjuta/interfaces/ianjuta-macro.h>
 #include <libanjuta/interfaces/ianjuta-file.h>
 #include <libanjuta/interfaces/ianjuta-project-manager.h>
+#include <libanjuta/interfaces/ianjuta-vcs.h>
 
 #include "plugin.h"
 #include "file.h"
@@ -108,6 +109,16 @@
 static void insert_notice(IAnjutaMacro* macro, const gchar* license_type, gint comment_type);
 static void insert_header(IAnjutaMacro* macro, gint source_type);
 
+static void
+on_add_to_project_toggled (GtkWidget* toggle_button, NewFileGUI *gui)
+{
+	gboolean status = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(toggle_button));
+	gtk_widget_set_sensitive (gui->add_to_repository, status);
+	if (!status)
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui->add_to_repository),
+		                              FALSE);
+}
+
 void
 display_new_file(AnjutaFileWizardPlugin *plugin,
 				 IAnjutaDocumentManager *docman)
@@ -129,6 +140,10 @@
        if (manager)
 			caps = ianjuta_project_manager_get_capabilities (manager, NULL);
 	}
+
+	g_signal_connect (nfg->add_to_project, "toggled", 
+	                  G_CALLBACK(on_add_to_project_toggled),
+	                  nfg);
 	
 	if ((caps & IANJUTA_PROJECT_MANAGER_CAN_ADD_SOURCE) == FALSE) {
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (nfg->add_to_project),
@@ -143,8 +158,6 @@
 	}
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (nfg->add_to_repository),
 								  FALSE);
-	/* FIXME: fix the problem with the repository add, then enable this check-button */
-	gtk_widget_set_sensitive (nfg->add_to_repository, FALSE);
 	
 	if (nfg && !(nfg->showing))
 	{
@@ -345,6 +358,26 @@
 				ianjuta_file_savable_save_as (IANJUTA_FILE_SAVABLE (teh), file, NULL);		
 				g_object_unref (file);
 			}		
+
+
+			/* Add to repository */
+			if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nfg->add_to_repository)))
+			{
+				IAnjutaVcs* ivcs = anjuta_shell_get_interface (ANJUTA_PLUGIN(docman)->shell, 
+										 IAnjutaVcs, NULL);
+				if (ivcs)
+				{					
+					GList* files = NULL;
+					GList* node;
+					AnjutaAsyncNotify* notify = anjuta_async_notify_new();
+					for (node = uri_list; node != NULL; node = g_list_next (node))
+					{
+						files = g_list_append (files, g_file_new_for_uri (node->data));
+					}
+					ianjuta_vcs_add (ivcs, files, notify, NULL);
+					g_list_foreach (files, (GFunc) g_object_unref, NULL);
+				}
+			}
 			g_list_foreach (uri_list, (GFunc)g_free, NULL);
 			g_list_free (uri_list);
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]