GNOME Bugzilla – Bug 591971
Translation Memories - gtranslator hangs when no directory is selected and add button is pressed
Last modified: 2012-03-24 10:09:09 UTC
Edit -> Preferences -> Translation Memories If "add to database" button is clicked leaving directory field empty gtranslator hangs. Also if non existing directory is entered gtranslator tries to process it instead of display a warning. I think that some king of test must be done on function "on_add_database_button_pulsed".
Created attachment 210404 [details] [review] Warning dialog if path is blank This patch adds a warning dialog if the user presses the button without selecting a folder. Maybe you could add an extra condition to verify that the folders exists
Review of attachment 210404 [details] [review]: Please update the patch in relation to the comments pointed inline. ::: plugins/translation-memory/gtr-translation-memory-dialog.c @@ +224,3 @@ + + /* + * If path is blank, show a warning message /* If path is empty, show a warning message */ @@ +227,3 @@ + */ + if (*path == '\0') + { declare here the GtkDialog *dialog; @@ +228,3 @@ + if (*path == '\0') + { + g_free (path); no need to free the path, it is owned by the entry @@ +234,3 @@ + GTK_BUTTONS_CLOSE, NULL); + + { Do not use set_markup, you are not using any markup in the message, use set_text @@ +236,3 @@ + gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), _("Please specify a valid path to build the translation memory")); + + g_free (path); Do not use dialog_run, it is getting deprecated. Use something like: gtk_widget_show (); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL)); @@ +237,3 @@ + + gtk_dialog_run (GTK_DIALOG (dialog)); + g_free (path); no need for this with the previous message @@ +238,3 @@ + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + dialog = gtk_message_dialog_new (data->parent, wrong indentation here? @@ +240,3 @@ + } + else + GTK_DIALOG_DESTROY_WITH_PARENT, wrong indentation? @@ +266,3 @@ g_object_unref (dir); + + }//Verify if path is blank or not no need for this comment
Created attachment 210461 [details] [review] Previous patch reviewed and fixed Right, sorry for the incovenience, but this is my first patch for source code. I hope now it is ok.
Review of attachment 210461 [details] [review]: Some more minor comments. ::: plugins/translation-memory/gtr-translation-memory-dialog.c @@ +232,3 @@ + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, + if (*path == '\0') the _() should be in one line @@ +264,3 @@ data, (GDestroyNotify) destroy_idle_data); g_object_unref (dir); this is wrongly indented
Created attachment 210468 [details] [review] Minor changes Again! ;-)
Review of attachment 210468 [details] [review]: more comments ::: plugins/translation-memory/gtr-translation-memory-dialog.c @@ +238,3 @@ + G_CALLBACK (gtk_widget_destroy), NULL); + } + dialog = gtk_message_dialog_new (data->parent, this else has too much indentation, it should be at the same level of the if @@ +239,3 @@ + } + else + GTK_DIALOG_DESTROY_WITH_PARENT, I mean what about all the code inside this block?
Created attachment 210471 [details] [review] More changes I've written it based in the previous code. I don't know the rules about indentationin GNOME's source code. Please, if indentation is still wrong, fix it yourself, and tell me about the changes. Thanks and sorry for the incovenience
One last request provide a format-patch, for this you have to commit the patch locally and create the patch with git format-patch, this way I can give you the credit for the patch.
Created attachment 210481 [details] [review] git diff patch Trying again...
It does not look like a format-patch. Just do like usual: git commit -a The message and instead of push you do: git format-patch origin
Created attachment 210483 [details] [review] Patch Ok, I didn't know how to do it. I hope this is the final chapter of this patch ;-)
See here the final patch: http://git.gnome.org/browse/gtranslator/commit/?id=7a0214bbfb9256fd1af1390de507037d69626f1b As you can see the message of the commit is more specific and after double checking I changed a few more things. Thanks for working on this.
Thanks for your help. Now, I know how to create a git-based patch :)