|
Thank you, Jeffrey. I've modified the patch and test again, please see if it works. Best Regards Charles Zhang Jeffrey Stedfast wrote: On Thu, 2003-09-25 at 03:07, Charles Zhang wrote: [snip] |
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 26 Sep 2003 15:08:06 -0000
@@ -38,6 +38,27 @@
#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);
+ char *pathname = g_path_get_dirname (filename);
+ gboolean ret = FALSE;
+ struct stat st;
+
+ if (stat (pathname, &st) == -1 || !S_ISDIR (st.st_mode)) {
+ /* pathdir doesn't exist or isn't a valid dir */
+ ret = TRUE;
+ } else if (stat (filename, &st) == 0 && !S_ISREG (st.st_mode)) {
+ /* file exists but isn't a regular file */
+ ret = TRUE;
+ }
+
+ g_free (pathname);
+ return ret;
+}
+
static GtkFileSelection *
run_selector(EMsgComposer *composer, const char *title, int multi, gboolean *showinline_p)
{
@@ -52,6 +73,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) {
@@ -98,6 +123,9 @@ e_msg_composer_select_file (EMsgComposer
{
GtkFileSelection *selection;
char *name = NULL;
+
+ /* FIXME: the next instrument should be "run_selector(composer, title, FALSE, NULL)",
+ otherwise this dialog's title is wrong and more than one file can be selected. */
selection = run_selector(composer, _("Attach file(s)"), TRUE, NULL);
if (selection) {
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.544.2.13
diff -u -p -r1.544.2.13 ChangeLog
--- composer/ChangeLog 29 Aug 2003 05:57:25 -0000 1.544.2.13
+++ composer/ChangeLog 26 Sep 2003 15:08:06 -0000
@@ -0,0 +0,7 @@
+2003-09-25 Charles Zhang <charles zhang sun com>
+
+ * e-msg-composer-select-file.c (ok_press_callback): Check if
+ valid file name inputted.
+ * e-msg-composer-select-file.c (run_selector): Connect ok but-
+ ton-press event to ok_press_callback. [#48759]
+