Re: [evolution-patches] patch for bug 48759



On Tue, 2003-09-23 at 09:24, Charles Zhang wrote:
> Hi, everyone
> 
> When press the ok button on the dialog with no file selected, the file 
> select dialog return current work path as filename; such happened this bug.
> 
> I use a g_file_test function to see if a valid filename is inputted, and 
> stop the following process if not.
> 
> Tell me if this is ok, or some message should be prompted, or even we 
> should solve it with other method.
> 
> Best Regards
> Charles Zhang
> 
> ______________________________________________________________________
> Index: composer/e-msg-composer-select-file.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/e-msg-composer-select-file.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 e-msg-composer-select-file.c
> --- composer/e-msg-composer-select-file.c	2 Apr 2003 18:51:01 -0000	1.25
> +++ composer/e-msg-composer-select-file.c	23 Sep 2003 13:12:17 -0000
> @@ -38,6 +38,17 @@
>  
>  #include "e-msg-composer-select-file.h"
>  
> +static gboolean
> +ok_press_callback (GtkWidget        *okbutton, 
> +		   GdkEventButton   *event,
> +		   GtkFileSelection *selection)
> +{
> +	char *filename = gtk_file_selection_get_filename (selection);
> +	if (g_file_test (filename, G_FILE_TEST_IS_DIR))
> +		return TRUE;
> +	return FALSE;
> +}
> +

please rewrite this as the following:

{
	char *filename = gtk_file_selection_get_filename (selection);
	struct stat st;
	
	if (stat (filename, &st) == -1 || S_ISDIR (st.st_mode))
		return TRUE;
	
	return FALSE;
}

- there should always be 1 blank line after variable declarations.
- use stat() rather than g_file_text to be consistant with the rest of
the mailer code.

>  static GtkFileSelection *
>  run_selector(EMsgComposer *composer, const char *title, int multi, gboolean *showinline_p)
>  {
> @@ -52,6 +63,10 @@ run_selector(EMsgComposer *composer, con
>  	gnome_window_icon_set_from_file((GtkWindow *)selection, EVOLUTION_DATADIR "/images/evolution/compose-message.png");
>  	gtk_file_selection_set_select_multiple((GtkFileSelection *)selection, multi);
>  
> +	g_signal_connect (((GtkFileSelection *) selection)->ok_button,
> +			  "button_press_event", G_CALLBACK (ok_press_callback),
> +			  (gpointer) selection);
> +
>  	/* restore last path used */
>  	path = g_object_get_data((GObject *)composer, "attach_path");
>  	if (path == NULL) {
> @@ -99,6 +114,9 @@ e_msg_composer_select_file (EMsgComposer
>  	GtkFileSelection *selection;
>  	char *name = NULL;
>  
> +	/* FIXME: the next statement should be "run_selector(composer, title, FALSE, NULL)",
> +	   otherwise this dialog's title is wrong and more than one file can be selected. */
> +

uh... the whole point is that the user can select multiple files.

>  	selection = run_selector(composer, _("Attach file(s)"), TRUE, NULL);
>  	if (selection) {
>  		name = g_strdup(gtk_file_selection_get_filename(selection));
-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com




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