[anjuta] git: Show error messages in a scrollable text view



commit 076453e20236b091d841fdbd9f6a7704cd27a431
Author: James Liggett <jrliggett cox net>
Date:   Sun Aug 9 20:02:18 2009 -0700

    git: Show error messages in a scrollable text view
    
    This should avoid having the dialog balloon to very large sizes when there are
    a lot of errors. It also gives the user the opportunity to scroll through the
    errors so that they can all be seen.

 plugins/git/git-ui-utils.c |   75 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 73 insertions(+), 2 deletions(-)
---
diff --git a/plugins/git/git-ui-utils.c b/plugins/git/git-ui-utils.c
index 6215891..2fef97a 100644
--- a/plugins/git/git-ui-utils.c
+++ b/plugins/git/git-ui-utils.c
@@ -259,6 +259,77 @@ git_clear_status_bar_progress_pulse (guint timer_id)
 	g_source_remove (timer_id);
 }
 
+static void
+message_dialog (GtkMessageType message_type, const gchar *message)
+{
+	GtkWidget *dialog;
+	GtkWidget *close_button;
+	GtkWidget *content_area;
+	GtkWidget *hbox;
+	GtkWidget *image;
+	GtkWidget *scrolled_window;
+	GtkWidget *text_view;
+	GtkTextBuffer *text_buffer;
+
+	dialog = gtk_dialog_new_with_buttons (NULL,
+	                                      NULL,
+	                                      GTK_DIALOG_DESTROY_WITH_PARENT,
+	                                      NULL);
+
+	close_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE,
+	                                      GTK_RESPONSE_CLOSE);
+	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+	hbox = gtk_hbox_new (FALSE, 2);
+	image = gtk_image_new ();
+	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+	text_view = gtk_text_view_new ();
+	text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
+
+	switch (message_type)
+	{
+		case GTK_MESSAGE_ERROR:
+			gtk_image_set_from_icon_name (GTK_IMAGE (image), 
+			                              GTK_STOCK_DIALOG_ERROR, 
+			                              GTK_ICON_SIZE_DIALOG);
+			break;
+		case GTK_MESSAGE_WARNING:
+			gtk_image_set_from_icon_name (GTK_IMAGE (image), 
+			                              GTK_STOCK_DIALOG_WARNING,
+			                              GTK_ICON_SIZE_DIALOG);
+			break;
+		default:
+			break;
+	}
+
+	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+	gtk_widget_set_size_request (text_view, 500, 150);
+	
+	gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+	                                     GTK_SHADOW_IN);
+
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+	                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+	gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
+	gtk_text_buffer_set_text (text_buffer, message, strlen (message));
+
+	gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, TRUE, TRUE, 0);
+
+	gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
+
+	gtk_widget_grab_default (close_button);
+	gtk_widget_grab_focus (close_button);
+
+	g_signal_connect (G_OBJECT (dialog), "response",
+	                  G_CALLBACK (gtk_widget_destroy),
+	                  NULL);
+
+	gtk_widget_show_all (dialog);
+	
+}
+
 void
 git_report_errors (AnjutaCommand *command, guint return_code)
 {
@@ -272,9 +343,9 @@ git_report_errors (AnjutaCommand *command, guint return_code)
 	if (message)
 	{
 		if (return_code != 0)
-			anjuta_util_dialog_error (NULL, message);
+			message_dialog (GTK_MESSAGE_ERROR, message);
 		else
-			anjuta_util_dialog_warning (NULL, message);
+			message_dialog (GTK_MESSAGE_WARNING, message);
 		
 		g_free (message);
 	}



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