? src/glade-3.pc
Index: src/glade-app.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-app.c,v
retrieving revision 1.38
diff -u -p -r1.38 glade-app.c
--- src/glade-app.c	30 Apr 2006 06:27:36 -0000	1.38
+++ src/glade-app.c	27 May 2006 13:37:20 -0000
@@ -776,6 +776,32 @@ glade_app_is_project_loaded (const gchar
 	return loaded;
 }
 
+/**
+ * glade_app_get_loaded_project:
+ * @project_path: The path of an open project
+ *
+ * Finds an open project with @path
+ */
+GladeProject*
+glade_app_get_loaded_project (const gchar *project_path)
+{
+	GladeApp *app;
+	GList    *l;
+
+	if (project_path == NULL) return FALSE;
+
+	app = glade_app_get ();
+
+	for (l = app->priv->projects; l; l = l->next)
+	{
+		GladeProject *project = GLADE_PROJECT (l->data);
+
+		if (project->path && strcmp (project_path, project->path) == 0)
+			return project;
+	}
+
+	return NULL;
+}
 
 void
 glade_app_show_properties (gboolean raise)
Index: src/glade-app.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-app.h,v
retrieving revision 1.17
diff -u -p -r1.17 glade-app.h
--- src/glade-app.h	24 Apr 2006 15:36:44 -0000	1.17
+++ src/glade-app.h	27 May 2006 13:37:21 -0000
@@ -102,6 +102,8 @@ GKeyFile*          glade_app_get_config 
 LIBGLADEUI_API 
 gboolean           glade_app_is_project_loaded (const gchar *project_path);
 LIBGLADEUI_API 
+GladeProject*      glade_app_get_loaded_project (const gchar *project_path);
+LIBGLADEUI_API 
 void               glade_app_show_properties (gboolean raise);
 LIBGLADEUI_API 
 void               glade_app_hide_properties (void);
Index: src/glade-editor-property.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-editor-property.c,v
retrieving revision 1.31
diff -u -p -r1.31 glade-editor-property.c
--- src/glade-editor-property.c	18 May 2006 05:19:29 -0000	1.31
+++ src/glade-editor-property.c	27 May 2006 13:37:34 -0000
@@ -932,8 +932,9 @@ glade_eprop_flags_load (GladeEditorPrope
 		g_type_class_unref(class);	
 	}
 
-	gtk_entry_set_text (GTK_ENTRY (eprop_flags->entry), 
-			    g_string_free (string, FALSE));
+	gtk_entry_set_text (GTK_ENTRY (eprop_flags->entry), string->str);
+
+	g_string_free (string, TRUE);
 }
 
 
Index: src/glade-project-window.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-project-window.c,v
retrieving revision 1.149
diff -u -p -r1.149 glade-project-window.c
--- src/glade-project-window.c	27 May 2006 01:22:27 -0000	1.149
+++ src/glade-project-window.c	27 May 2006 13:37:41 -0000
@@ -552,9 +552,10 @@ gpw_save (GladeProjectWindow *gpw, Glade
 static void
 gpw_save_as (GladeProjectWindow *gpw, const gchar *dialog_title)
 {
- 	GladeProject *project;
+ 	GladeProject *project, *open_project_with_same_name;
  	GtkWidget *filechooser;
 	gchar *path = NULL;
+	gchar *primary_msg, *secondary_msg;
 	gchar *real_path, *ch;
 	
 	if ((project = glade_app_get_project ()) == NULL)
@@ -601,12 +602,46 @@ gpw_save_as (GladeProjectWindow *gpw, co
 	
 	g_free (path);
 
-	if (glade_app_is_project_loaded (real_path))
+
+	if (glade_util_file_is_writeable (real_path) == FALSE)
 	{
-		glade_util_ui_message (gpw->priv->window, GLADE_UI_WARN,
-				       _("%s is already open"), real_path);
+		primary_msg = g_strdup_printf ("Could not save the file %s", real_path);
+
+		glade_util_ui_alert (gpw->priv->window, GLADE_UI_ERROR,
+				     primary_msg, 
+				     "You do not have the permissions necessary to save the file. " 
+				     "Please, check that you typed the location correctly "
+				     "and try again.");
+
+		g_free (primary_msg);
+		g_free (real_path);
+
+
 		return;
 	}
+
+	if ((open_project_with_same_name = glade_app_get_loaded_project (real_path)) != NULL)
+	{
+
+		if (open_project_with_same_name != project) {
+
+			primary_msg = g_strdup_printf ("Could not save project to file %s", real_path);
+			secondary_msg = g_strdup_printf ("Another project with that path is already open");
+
+			glade_util_ui_alert (gpw->priv->window,
+				             GLADE_UI_ERROR,
+		     		             primary_msg,
+			                     secondary_msg);	
+		
+			g_free (primary_msg);
+			g_free (secondary_msg);
+			g_free (real_path);
+
+			return;
+		}
+
+	}
+
 	gpw_save (gpw, project, real_path);
 
 	g_free (real_path);
Index: src/glade-utils.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-utils.c,v
retrieving revision 1.85
diff -u -p -r1.85 glade-utils.c
--- src/glade-utils.c	27 May 2006 01:22:27 -0000	1.85
+++ src/glade-utils.c	27 May 2006 13:37:48 -0000
@@ -267,6 +267,89 @@ glade_util_ui_message (GtkWidget        
 	return (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_YES);
 }
 
+/**
+ * glade_util_ui_alert:
+ * @parent: a #GtkWindow cast as a #GtkWidget
+ * @primary_msg: The primary message for this alert
+ * @secondary_msg: The secondary message for this alert
+ *
+ * Creates a new alert dialog window as a child of @parent containing
+ * a primary message @primary_msg and secondary message @secondary_msg, 
+ * runs it, then destroys it on close. Depending on @type, a cancel button 
+ * may apear or the icon may change. This dialog is GNOME HIG compliant.
+ *
+ * Returns: True if the @type was GLADE_UI_ARE_YOU_SURE and the user
+ *          selected "OK", True if the @type was GLADE_UI_YES_OR_NO and
+ *          the user selected "YES"; False otherwise.
+ */
+gboolean
+glade_util_ui_alert    (GtkWidget          *parent, 
+		       GladeUIMessageType   type,
+		       const gchar         *primary_msg,
+		       const gchar         *secondary_msg)
+{
+	GtkWidget      *dialog;
+	GtkMessageType  message_type = GTK_MESSAGE_INFO;
+	GtkButtonsType  buttons_type = GTK_BUTTONS_OK;
+	gchar          *markup;
+	gint            response;
+
+
+	/* Get message_type */
+	switch (type)
+	{
+	case GLADE_UI_INFO: message_type = GTK_MESSAGE_INFO; break;
+	case GLADE_UI_WARN:
+	case GLADE_UI_ARE_YOU_SURE:
+		message_type = GTK_MESSAGE_WARNING;
+		break;
+	case GLADE_UI_ERROR:      message_type = GTK_MESSAGE_ERROR;    break;
+	case GLADE_UI_YES_OR_NO:  message_type = GTK_MESSAGE_QUESTION; break;
+		break;
+	default: 
+		g_critical ("Bad arg for glade_util_ui_message");
+		break;
+	}
+
+
+	/* Get buttons_type */
+	switch (type)
+	{
+	case GLADE_UI_INFO:
+	case GLADE_UI_WARN:
+	case GLADE_UI_ERROR:
+		buttons_type = GTK_BUTTONS_OK;
+		break;
+	case GLADE_UI_ARE_YOU_SURE: buttons_type = GTK_BUTTONS_OK_CANCEL; break;
+	case GLADE_UI_YES_OR_NO:    buttons_type = GTK_BUTTONS_YES_NO; break;
+		break;
+	default: 
+		g_critical ("Bad arg for glade_util_ui_message");
+		break;
+	}
+
+	dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (parent),
+					 GTK_DIALOG_DESTROY_WITH_PARENT,
+					 message_type,
+					 buttons_type,
+					 "<span weight=\"bold\" size=\"larger\">%s</span>", primary_msg);
+
+
+	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+						  secondary_msg,
+						  NULL);
+
+	/* No title according to HIG */
+	gtk_window_set_title (GTK_WINDOW (dialog), "");
+
+
+	response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+	gtk_widget_destroy (dialog);
+
+	return (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_YES);
+}
+
 
 
 
Index: src/glade-utils.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-utils.h,v
retrieving revision 1.51
diff -u -p -r1.51 glade-utils.h
--- src/glade-utils.h	27 May 2006 01:22:27 -0000	1.51
+++ src/glade-utils.h	27 May 2006 13:37:49 -0000
@@ -35,6 +35,11 @@ gboolean         glade_util_ui_message  
 						  GladeUIMessageType type,
 						  const gchar *format, ...);
 LIBGLADEUI_API
+gboolean         glade_util_ui_alert             (GtkWidget *parent, 
+						  GladeUIMessageType type,
+						  const gchar *primary_msg,
+                                                  const gchar *secondary_msg);
+LIBGLADEUI_API
 void		glade_util_flash_message	(GtkWidget *statusbar, 
 						 guint context_id,
 						 gchar *format, ...);
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/glade3/src/main.c,v
retrieving revision 1.47
diff -u -p -r1.47 main.c
--- src/main.c	30 Apr 2006 07:48:21 -0000	1.47
+++ src/main.c	27 May 2006 13:37:50 -0000
@@ -106,7 +106,10 @@ main (int argc, char *argv[])
 		g_error_free (error);
 		return -1;
 	}
-	
+
+	g_option_context_free (option_context);
+	option_context = NULL;
+
 
 	if (version == TRUE)
 	{
