[geany/geany-plugins] 867809: Limit the display of diff output to 16 KB to not freeze the UI while rendering

Enrico Tröger git-noreply at xxxxx
Sat Jun 1 10:19:39 UTC 2013


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sat, 01 Jun 2013 10:19:39 UTC
Commit:      8678093e7b5d142c074a1d7fe6beeb03ce6b5f61
             https://github.com/geany/geany-plugins/commit/8678093e7b5d142c074a1d7fe6beeb03ce6b5f61

Log Message:
-----------
Limit the display of diff output to 16 KB to not freeze the UI while rendering

This should workaround the long-standing bug that the commit dialog freezes Geany
when the diff output is very large. Now, if the output exceeds 16 KB, a short message
is displayed instead suggesting to open the diff for review in Geany directly.


Modified Paths:
--------------
    geanyvc/src/geanyvc.c
    geanyvc/src/geanyvc.h

Modified: geanyvc/src/geanyvc.c
27 files changed, 20 insertions(+), 7 deletions(-)
===================================================================
@@ -1075,7 +1075,7 @@ enum
 }
 
 static void
-set_diff_buff(GtkTextBuffer * buffer, const gchar * txt)
+set_diff_buff(GtkWidget * textview, GtkTextBuffer * buffer, const gchar * txt)
 {
 	GtkTextIter start, end;
 	GtkTextMark *mark;
@@ -1083,6 +1083,19 @@ enum
 	const gchar *tagname = "";
 	const gchar *c, *p = txt;
 
+	if (strlen(txt) > COMMIT_DIFF_MAXLENGTH)
+	{
+		gtk_text_buffer_set_text(buffer,
+			_("The resulting differences cannot be displayed because "
+			  "the changes are too big to display here and would slow down the UI significantly."
+			  "\n\n"
+			  "To view the differences, cancel this dialog and open the differences "
+			  "in Geany directly by using the GeanyVC menu (Base Dirrectory -> Diff)."), -1);
+		gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);
+		return;
+	}
+	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_NONE);
+
 	gtk_text_buffer_set_text(buffer, txt, -1);
 
 	gtk_text_buffer_get_start_iter(buffer, &start);
@@ -1152,7 +1165,7 @@ enum
 	gchar *diff;
 	GtkWidget *diffView = ui_lookup_widget(GTK_WIDGET(treeview), "textDiff");
 	diff = get_commit_diff(GTK_TREE_VIEW(treeview));
-	set_diff_buff(gtk_text_view_get_buffer(GTK_TEXT_VIEW(diffView)), diff);
+	set_diff_buff(diffView, gtk_text_view_get_buffer(GTK_TEXT_VIEW(diffView)), diff);
 	g_free(diff);
 }
 
@@ -1523,7 +1536,7 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView
 	gtk_text_buffer_create_tag(diffbuf, "invisible", "invisible",
 				   TRUE, NULL);
 
-	set_diff_buff(diffbuf, diff);
+	set_diff_buff(diffView, diffbuf, diff);
 
 	if (set_maximize_commit_dialog)
 	{
@@ -1748,7 +1761,7 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView
 			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets.cb_confirm_add));
 		set_maximize_commit_dialog =
 			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets.cb_max_commit));
-		
+
 		set_external_diff =
 			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets.cb_external_diff));
 
@@ -1879,7 +1892,7 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView
 			       "inside tools menu or directly inside Geany's menubar."
 			       "Will take in account after next start of GeanyVC"));
 	gtk_button_set_focus_on_click(GTK_BUTTON(widgets.cb_attach_to_menubar), FALSE);
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets.cb_attach_to_menubar), 
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets.cb_attach_to_menubar),
 		set_menubar_entry);
 	gtk_box_pack_start(GTK_BOX(vbox), widgets.cb_attach_to_menubar, TRUE, FALSE, 2);
 
@@ -2241,7 +2254,7 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView
 	GtkWidget *menu_vc_file = NULL;
 	GtkWidget *menu_vc_dir = NULL;
 	GtkWidget *menu_vc_basedir = NULL;
-	
+
 	config_file =
 		g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
 			    "VC", G_DIR_SEPARATOR_S, "VC.conf", NULL);
@@ -2253,7 +2266,7 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView
 	if (set_menubar_entry == TRUE)
 	{
 		GtkMenuShell *menubar;
-		
+
 		menubar = GTK_MENU_SHELL(
 				ui_lookup_widget(geany->main_widgets->window, "menubar1"));
 


Modified: geanyvc/src/geanyvc.h
2 files changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -52,6 +52,8 @@ enum
 	VC_COMMAND_STARTDIR_FILE
 };
 
+#define COMMIT_DIFF_MAXLENGTH  16384
+
 #define FLAG_RELOAD         (1<<0)
 #define FLAG_FORCE_ASK      (1<<1)
 #define FLAG_FILE           (1<<2)



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list