Patch for centered dialogs



Attached is a patch which changes the libanjuta-util methods
anjuta_dialog_question et al to take a GtkWidget* parent parameter.

If the pointer is NULL obviously nothing is done, otherwise 
transient_for() is called.

This patch will be much more usefull when the de-bonoboisation has been
completed and plugins can actually get a pointer to the top-level
window.

Ross
-- 
Ross Burton                     Software Engineer
OneEighty Software Ltd          Tel: +44 20 8680 8712
Cygnet House                    Fax: +44 20 8680 8453
12-14 Sydenham Road             r burton 180sw com
Croydon, Surrey CR9 2ET, UK     http://www.180sw.com./
====================================================================
Under the Regulation of Investigatory Powers (RIP) Act 2000 together
with any and all Regulations in force pursuant to the Act OneEighty
Software Ltd reserves the right to monitor any or all incoming or
outgoing communications as provided for under the Act
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/anjuta2/ChangeLog,v
retrieving revision 1.209
diff -u -r1.209 ChangeLog
--- ChangeLog	30 May 2002 22:15:23 -0000	1.209
+++ ChangeLog	31 May 2002 12:53:26 -0000
14
+2002-05-31  Ross Burton  <ross burtonini com>
+	* libanjuta/anjuta-utils.c
+	* libanjuta/anjuta-utils.h: Make the dialog methods take a
+	GtkWidget* which is a parent window.
+	* plugins/document-manager/anjuta-document-manager.c
+	* plugins/document-manager/anjuta-document.c
+	* plugins/document-manager/file-ops.c
+	* plugins/project-manager/project-tool.c
+	* plugins/symbol-browser/symbol-browser-tool.c
+	* src/window.c: Pass a valid GtkWindow, or NULL if one is not known.
+	
 2002-05-30  Ross Burton  <ross burtonini com>
 
 	* src/window.c: Tell the about dialog who its parent is so that it
Index: libanjuta/anjuta-utils.c
===================================================================
RCS file: /cvs/gnome/anjuta2/libanjuta/anjuta-utils.c,v
retrieving revision 1.19
diff -u -r1.19 anjuta-utils.c
--- libanjuta/anjuta-utils.c	17 Mar 2002 23:59:07 -0000	1.19
+++ libanjuta/anjuta-utils.c	31 May 2002 12:53:28 -0000
@@ -52,7 +53,7 @@
 }
 
 GtkResponseType
-anjuta_dialog_question (const char *msg)
+anjuta_dialog_question (const char *msg, GtkWindow *parent)
 {
 	GtkWidget *dialog;
 	GtkResponseType ret;
@@ -62,7 +63,7 @@
 					 GTK_MESSAGE_QUESTION,
 					 GTK_BUTTONS_YES_NO,
 					 msg);
-
+	if (parent) gtk_window_set_transient_for (GTK_WINDOW(dialog), parent);
 	ret = gtk_dialog_run (GTK_DIALOG (dialog));
 	gtk_widget_destroy (dialog);
 
@@ -70,7 +71,7 @@
 }
 
 void
-anjuta_dialog_error (const char *msg)
+anjuta_dialog_error (const char *msg, GtkWindow *parent)
 {
 	GtkWidget *dialog;
 
@@ -80,12 +81,13 @@
 					 GTK_BUTTONS_OK,
 					 msg);
 
+	if (parent) gtk_window_set_transient_for (GTK_WINDOW(dialog), parent);
 	gtk_dialog_run (GTK_DIALOG (dialog));
 	gtk_widget_destroy (dialog);
 }
 
 void 
-anjuta_dialog_info (const char *msg)
+anjuta_dialog_info (const char *msg, GtkWindow *parent)
 {
 	GtkWidget *dialog;
 
@@ -95,6 +97,7 @@
 					 GTK_BUTTONS_OK,
 					 msg);
 
+	if (parent) gtk_window_set_transient_for (GTK_WINDOW(dialog), parent);
 	gtk_dialog_run (GTK_DIALOG (dialog));
 	gtk_widget_destroy (dialog);
 }
@@ -155,7 +158,7 @@
 					 "exist!\nDo you want to "
 					 "create the file?"), filename);
 
-		if (anjuta_dialog_question (txt) == GTK_RESPONSE_YES) {
+		if (anjuta_dialog_question (txt, NULL) == GTK_RESPONSE_YES) {
 			GnomeVFSResult r;
 			GnomeVFSHandle *handle = NULL;
 
@@ -173,7 +176,7 @@
 					_("Error creating file '%s': %s'"), 
 					filename, 
 					gnome_vfs_result_to_string (r));
-				anjuta_dialog_error (txt);
+				anjuta_dialog_error (txt, NULL);
 			}
 		}
 		g_free (txt);
Index: libanjuta/anjuta-utils.h
===================================================================
RCS file: /cvs/gnome/anjuta2/libanjuta/anjuta-utils.h,v
retrieving revision 1.12
diff -u -r1.12 anjuta-utils.h
--- libanjuta/anjuta-utils.h	17 Mar 2002 23:59:07 -0000	1.12
+++ libanjuta/anjuta-utils.h	31 May 2002 12:53:28 -0000
@@ -20,12 +20,13 @@
 #define __ANJUTA_UTILS_H__
 
 #include <gtk/gtkdialog.h>
+#include <gtk/gtkwindow.h>
 
 G_BEGIN_DECLS
 
-GtkResponseType anjuta_dialog_question             (const char *msg);
-void            anjuta_dialog_error                (const char *msg);
-void            anjuta_dialog_info                 (const char *msg);
+GtkResponseType anjuta_dialog_question             (const char *msg, GtkWindow *parent);
+void            anjuta_dialog_error                (const char *msg, GtkWindow *parent);
+void            anjuta_dialog_info                 (const char *msg, GtkWindow *parent);
 
 gboolean        anjuta_is_empty_string             (const char *s);
 gulong          anjuta_get_file_size               (const char *filename);
Index: plugins/document-manager/anjuta-document-manager.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/document-manager/anjuta-document-manager.c,v
retrieving revision 1.20
diff -u -r1.20 anjuta-document-manager.c
--- plugins/document-manager/anjuta-document-manager.c	27 Apr 2002 17:40:29 -0000	1.20
+++ plugins/document-manager/anjuta-document-manager.c	31 May 2002 12:53:29 -0000
@@ -639,7 +639,7 @@
 			msg = g_strdup_printf (_("The file\n'%s'\nhas been changed from outside the editor!\nDo you want to reload it?"), anjuta_document_get_filename (document));
 		}
 		
-		if (anjuta_dialog_question (msg) == GTK_RESPONSE_YES) {
+		if (anjuta_dialog_question (msg, NULL) == GTK_RESPONSE_YES) {
 			file_reload (NULL, docman);
 		} else {
 			anjuta_document_set_changed_state( document, TRUE );
@@ -651,7 +651,7 @@
         case 2:
 		msg = g_strdup_printf (_("The file\n'%s'\nis not longer available.\nChoose YES to close it, or NO to keep it!"), anjuta_document_get_filename(document));
 		
-		if (anjuta_dialog_question (msg) == GTK_RESPONSE_YES) {
+		if (anjuta_dialog_question (msg, NULL) == GTK_RESPONSE_YES) {
 			file_close( NULL, docman );
 		} else {
 			anjuta_document_set_changed_state (document, TRUE);
Index: plugins/document-manager/anjuta-document.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/document-manager/anjuta-document.c,v
retrieving revision 1.48
diff -u -r1.48 anjuta-document.c
--- plugins/document-manager/anjuta-document.c	19 Apr 2002 16:25:28 -0000	1.48
+++ plugins/document-manager/anjuta-document.c	31 May 2002 12:53:29 -0000
@@ -256,7 +256,7 @@
 		char *msg = g_strdup_printf ("Document-Manager\nFailed to make "
 			"temp file - consider installing glimmer from CVS\nNo available"
 			" bonobo objects to open this file.\nMime Type: %s", mime_type);
-		anjuta_dialog_error (msg);
+		anjuta_dialog_error (msg, NULL);
 		g_free (msg);
 	}
 }
@@ -528,7 +528,7 @@
 		/* No Bonobo Control to view document, tell user */
 		char *msg = g_strdup_printf ("Document-Manager\nNo available bonobo"
 			" objects to open this file.\nMime Type: %s", mime_type);
-		anjuta_dialog_error (msg);
+		anjuta_dialog_error (msg, NULL);
 		g_free (msg);
 
 		return FALSE;
@@ -1320,6 +1320,6 @@
 	msg = g_strdup_printf (_("Set the default component for %s to %s"),
 			       document->mime_type,
 			       document->priv->current_component->name);
-	anjuta_dialog_info (msg);
+	anjuta_dialog_info (msg, NULL);
 	g_free (msg);
 }
Index: plugins/document-manager/file-ops.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/document-manager/file-ops.c,v
retrieving revision 1.33
diff -u -r1.33 file-ops.c
--- plugins/document-manager/file-ops.c	10 Apr 2002 18:18:18 -0000	1.33
+++ plugins/document-manager/file-ops.c	31 May 2002 12:53:29 -0000
@@ -90,7 +90,7 @@
 	if ( !anjuta_document_is_changed(current) )
 		return;
 		
-	if (anjuta_dialog_question (_("The file has been changed,\nDo You want to reload it?")) == GTK_RESPONSE_NO) {
+	if (anjuta_dialog_question (_("The file has been changed,\nDo You want to reload it?"), NULL) == GTK_RESPONSE_NO) {
 		return;
 	}
 
Index: plugins/project-manager/project-tool.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/project-manager/project-tool.c,v
retrieving revision 1.29
diff -u -r1.29 project-tool.c
--- plugins/project-manager/project-tool.c	10 Apr 2002 18:18:18 -0000	1.29
+++ plugins/project-manager/project-tool.c	31 May 2002 12:53:30 -0000
@@ -27,7 +28,7 @@
 
 	res = anjuta_show_file (tool, source);
 	if (!res) {
-		anjuta_dialog_error (_("Unable to open file."));
+		anjuta_dialog_error (_("Unable to open file."), NULL);
 		return;
 	}
 	
@@ -143,7 +144,7 @@
 
 		if (bail_out) {
 			anjuta_dialog_error (_("Could not activate the "
-					       "project component"));
+					       "project component"), NULL);
 			CORBA_exception_free (&ev);
 			return;
 		};
@@ -152,11 +153,11 @@
 		GNOME_Development_Project_load (project, path, &ev);
 		if (BONOBO_EX (&ev)) {
 			if (BONOBO_USER_EX (&ev, ex_GNOME_Development_Project_DoesntExist))
-				anjuta_dialog_error (_("Project does not exist!"));
+				anjuta_dialog_error (_("Project does not exist!"), NULL);
 			else if (BONOBO_USER_EX (&ev, ex_GNOME_Development_Project_Malformed))
-				anjuta_dialog_error (_("Not a proper project!"));
+				anjuta_dialog_error (_("Not a proper project!"), NULL);
 			else
-				anjuta_dialog_error (_("Unable to load project!"));
+				anjuta_dialog_error (_("Unable to load project!"), NULL);
 
 			CORBA_exception_free (&ev);
 			bonobo_object_release_unref (project, &ev);
@@ -180,7 +181,7 @@
 	bonobo_pbclient_set_value (pb, "project", arg, &ev);
 	if (BONOBO_EX (&ev)) {
 		anjuta_dialog_error (_("Unexpected error while binding the "
-				       "project to the tree control"));
+				       "project to the tree control"), NULL);
 		CORBA_exception_free (&ev);
 	}
 	
@@ -189,7 +190,7 @@
 	bonobo_pbclient_set_value (pb, "project", arg, &ev);
 	if (BONOBO_EX (&ev)) {
 		anjuta_dialog_error (_("Unexpected error while binding the "
-				       "project to the target control"));
+				       "project to the target control"), NULL);
 		CORBA_exception_free (&ev);
 	}
 
@@ -198,7 +199,7 @@
 	bonobo_pbclient_set_value (pb, "project", arg, &ev);
 	if (BONOBO_EX (&ev)) {
 		anjuta_dialog_error (_("Unexpected error while binding the "
-				       "project to the build info control"));
+				       "project to the build info control"), NULL);
 		CORBA_exception_free (&ev);
 	}
 
Index: plugins/symbol-browser/symbol-browser-tool.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/symbol-browser/symbol-browser-tool.c,v
retrieving revision 1.7
diff -u -r1.7 symbol-browser-tool.c
--- plugins/symbol-browser/symbol-browser-tool.c	27 Apr 2002 17:40:30 -0000	1.7
+++ plugins/symbol-browser/symbol-browser-tool.c	31 May 2002 12:53:30 -0000
@@ -55,7 +55,7 @@
 		g_free (ln);
 
 		if (!anjuta_show_file (tool, file)) {
-			anjuta_dialog_error (_("Unable to open file."));
+			anjuta_dialog_error (_("Unable to open file."), NULL);
 			g_free (file);
 			return;
 		}
Index: src/window.c
===================================================================
RCS file: /cvs/gnome/anjuta2/src/window.c,v
retrieving revision 1.59
diff -u -r1.59 window.c
--- src/window.c	30 May 2002 22:15:25 -0000	1.59
+++ src/window.c	31 May 2002 12:53:31 -0000
@@ -381,7 +373,7 @@
 	if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) {
 		mkdir (dir, 0755);
 		if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) {
-			anjuta_dialog_error ("Could not create .anjuta2 directory.");
+			anjuta_dialog_error ("Could not create .anjuta2 directory.", GTK_WINDOW(window));
 			return;
 		}
 	}
@@ -389,7 +381,7 @@
 
 	filename = gnome_util_prepend_user_home (".anjuta2/layout.xml");
 	if (!gdl_dock_layout_save_to_file (window->layout_manager, filename))
-		anjuta_dialog_error ("Could not save layout.");
+		anjuta_dialog_error ("Could not save layout.", GTK_WINDOW(window));
 }
 
 void


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