From: John Darrington Date: Thu, 25 Jan 2007 08:18:57 +0000 (+0000) Subject: Fixed buglet in file open action. X-Git-Tag: v0.6.0~579 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f159627d3b80706e58a54be2431c3edbc5333dc;p=pspp-builds.git Fixed buglet in file open action. --- diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index 9aa6501b..07588770 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -828,7 +828,7 @@ weight_cases_dialog (GObject *o, gpointer data) static void data_save_as_dialog (GtkAction *, struct data_editor *de); static void new_file (GtkAction *, struct editor_window *de); -static void open_data_dialog (GtkAction *, struct editor_window *de); +static void open_data_dialog (GtkAction *, struct data_editor *de); static void data_save (GtkAction *action, struct data_editor *e); @@ -1033,11 +1033,13 @@ new_file (GtkAction *action, struct editor_window *de) /* Callback for the data_open action. Prompts for a filename and opens it */ static void -open_data_dialog (GtkAction *action, struct editor_window *de) +open_data_dialog (GtkAction *action, struct data_editor *de) { + struct editor_window *e = (struct editor_window *) de; + GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Open"), - GTK_WINDOW (de->window), + GTK_WINDOW (e->window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, @@ -1065,16 +1067,15 @@ open_data_dialog (GtkAction *action, struct editor_window *de) case GTK_RESPONSE_ACCEPT: { struct getl_interface *sss; - gchar *file_name = + g_free (de->file_name); + de->file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - sss = create_syntax_string_source ("GET FILE='%s'.", file_name); + sss = create_syntax_string_source ("GET FILE='%s'.", de->file_name); execute_syntax (sss); - window_set_name_from_filename (de, file_name); - - g_free (file_name); + window_set_name_from_filename (e, de->file_name); } break; default: diff --git a/src/ui/gui/data-editor.h b/src/ui/gui/data-editor.h index 71bfd0e6..67302fa9 100644 --- a/src/ui/gui/data-editor.h +++ b/src/ui/gui/data-editor.h @@ -39,6 +39,10 @@ struct data_editor GladeXML *xml; gboolean save_as_portable; + + /* Name of the file this data is associated with (ie, was loaded from or + has been saved to), in "filename encoding", or NULL, if it's not + associated with any file */ gchar *file_name; }; diff --git a/src/ui/gui/window-manager.c b/src/ui/gui/window-manager.c index f25a97ab..2978d7ae 100644 --- a/src/ui/gui/window-manager.c +++ b/src/ui/gui/window-manager.c @@ -123,11 +123,12 @@ set_window_name (struct editor_window *e, gchar *title ; g_free (e->name); + e->name = NULL; if ( name ) { - e->name = g_strdup (name); - return ; + e->name = g_strdup (name); + return; } switch (e->type ) @@ -150,6 +151,8 @@ set_window_name (struct editor_window *e, } +/* Set the name of this window based on FILENAME. + FILENAME is in "filename encoding" */ void window_set_name_from_filename (struct editor_window *e, const gchar *filename) diff --git a/src/ui/gui/window-manager.h b/src/ui/gui/window-manager.h index 994cdbe2..ba0abced 100644 --- a/src/ui/gui/window-manager.h +++ b/src/ui/gui/window-manager.h @@ -13,7 +13,7 @@ enum window_type struct editor_window { GtkWindow *window; /* The top level window of the editor */ - gchar *name; /* The name of this editor */ + gchar *name; /* The name of this editor (UTF-8) */ enum window_type type; } ; @@ -22,6 +22,8 @@ struct editor_window * window_create (enum window_type type, const gchar * window_name (const struct editor_window *); +/* Set the name of this window based on FILENAME. + FILENAME is in "filename encoding" */ void window_set_name_from_filename (struct editor_window *e, const gchar *filename);