It didn't do anything.
#include <gtk/gtk.h>
#include <stdlib.h>
-#include "data/any-reader.h"
#include "data/dataset.h"
#include "language/lexer/lexer.h"
#include "libpspp/message.h"
return ok;
}
-static GtkWidget *
-sysfile_chooser_dialog (PsppireWindow *toplevel)
-{
- GtkWidget *dialog =
- gtk_file_chooser_dialog_new (_("Open"),
- GTK_WINDOW (toplevel),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- GtkFileFilter *filter;
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Data and Syntax Files"));
- gtk_file_filter_add_pattern (filter, "*.sav");
- gtk_file_filter_add_pattern (filter, "*.SAV");
- gtk_file_filter_add_pattern (filter, "*.por");
- gtk_file_filter_add_pattern (filter, "*.POR");
- gtk_file_filter_add_pattern (filter, "*.sps");
- gtk_file_filter_add_pattern (filter, "*.SPS");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("System Files (*.sav)"));
- gtk_file_filter_add_pattern (filter, "*.sav");
- gtk_file_filter_add_pattern (filter, "*.SAV");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Portable Files (*.por) "));
- gtk_file_filter_add_pattern (filter, "*.por");
- gtk_file_filter_add_pattern (filter, "*.POR");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Syntax Files (*.sps) "));
- gtk_file_filter_add_pattern (filter, "*.sps");
- gtk_file_filter_add_pattern (filter, "*.SPS");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("All Files"));
- gtk_file_filter_add_pattern (filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- {
- gchar *dir_name;
- gchar *filename = NULL;
- g_object_get (toplevel, "filename", &filename, NULL);
-
- if ( ! g_path_is_absolute (filename))
- {
- gchar *path =
- g_build_filename (g_get_current_dir (), filename, NULL);
- dir_name = g_path_get_dirname (path);
- g_free (path);
- }
- else
- {
- dir_name = g_path_get_dirname (filename);
- }
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
- dir_name);
- free (dir_name);
- }
-
- return dialog;
-}
-
-/* Callback for the data_open action.
- Prompts for a filename and opens it */
-static void
-open_window (PsppireWindow *de)
-{
- GtkWidget *dialog = sysfile_chooser_dialog (de);
-
- switch (gtk_dialog_run (GTK_DIALOG (dialog)))
- {
- case GTK_RESPONSE_ACCEPT:
- {
- gchar *name =
- gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-
- gchar *sysname = convert_glib_filename_to_system_filename (name, NULL);
-
- if (any_reader_may_open (sysname))
- psppire_window_load (de, name);
- else
- open_syntax_window (name);
-
- g_free (sysname);
- g_free (name);
- }
- break;
- default:
- break;
- }
-
- gtk_widget_destroy (dialog);
-}
-
/* Returns true if NAME has a suffix which might denote a PSPP file */
static gboolean
name_has_suffix (const gchar *name)
static void
sysfile_info (PsppireDataWindow *de)
{
- GtkWidget *dialog = sysfile_chooser_dialog (PSPPIRE_WINDOW (de));
+ GtkWidget *dialog = psppire_window_file_chooser_dialog (PSPPIRE_WINDOW (de));
if ( GTK_RESPONSE_ACCEPT == gtk_dialog_run (GTK_DIALOG (dialog)))
{
connect_action (de, "file_save", G_CALLBACK (data_save));
- connect_action (de, "file_open", G_CALLBACK (open_window));
+ connect_action (de, "file_open", G_CALLBACK (psppire_window_open));
connect_action (de, "file_save_as", G_CALLBACK (data_save_as_dialog));
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009, 2010 Free Software Foundation
+ Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
window);
#endif
+ g_signal_connect_swapped (get_action_assert (xml, "file_open"),
+ "activate",
+ G_CALLBACK (psppire_window_open),
+ window);
+
g_signal_connect_swapped (get_action_assert (xml, "file_save"),
"activate",
G_CALLBACK (syntax_save),
#include <config.h>
+#include "psppire-window.h"
#include <gtk/gtk.h>
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-#include "psppire-window.h"
-#include "psppire-window-register.h"
+#include "data/any-reader.h"
+#include "data/dataset.h"
+
+#include "helper.h"
#include "psppire-conf.h"
+#include "psppire-data-window.h"
+#include "psppire-syntax-window.h"
+#include "psppire-window-register.h"
+#include "psppire.h"
static void psppire_window_base_finalize (PsppireWindowClass *, gpointer);
static void psppire_window_base_init (PsppireWindowClass *class);
g_signal_connect (window, "realize",
G_CALLBACK (on_realize), window);
-
}
/*
return ok;
}
+GtkWidget *
+psppire_window_file_chooser_dialog (PsppireWindow *toplevel)
+{
+ GtkWidget *dialog =
+ gtk_file_chooser_dialog_new (_("Open"),
+ GTK_WINDOW (toplevel),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ GtkFileFilter *filter;
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Data and Syntax Files"));
+ gtk_file_filter_add_pattern (filter, "*.sav");
+ gtk_file_filter_add_pattern (filter, "*.SAV");
+ gtk_file_filter_add_pattern (filter, "*.por");
+ gtk_file_filter_add_pattern (filter, "*.POR");
+ gtk_file_filter_add_pattern (filter, "*.sps");
+ gtk_file_filter_add_pattern (filter, "*.SPS");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("System Files (*.sav)"));
+ gtk_file_filter_add_pattern (filter, "*.sav");
+ gtk_file_filter_add_pattern (filter, "*.SAV");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Portable Files (*.por) "));
+ gtk_file_filter_add_pattern (filter, "*.por");
+ gtk_file_filter_add_pattern (filter, "*.POR");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Syntax Files (*.sps) "));
+ gtk_file_filter_add_pattern (filter, "*.sps");
+ gtk_file_filter_add_pattern (filter, "*.SPS");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All Files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ {
+ gchar *dir_name;
+ gchar *filename = NULL;
+ g_object_get (toplevel, "filename", &filename, NULL);
+
+ if ( ! g_path_is_absolute (filename))
+ {
+ gchar *path =
+ g_build_filename (g_get_current_dir (), filename, NULL);
+ dir_name = g_path_get_dirname (path);
+ g_free (path);
+ }
+ else
+ {
+ dir_name = g_path_get_dirname (filename);
+ }
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
+ dir_name);
+ free (dir_name);
+ }
+
+ return dialog;
+}
+
+/* Callback for the file_open action.
+ Prompts for a filename and opens it */
+void
+psppire_window_open (PsppireWindow *de)
+{
+ GtkWidget *dialog = psppire_window_file_chooser_dialog (de);
+
+ switch (gtk_dialog_run (GTK_DIALOG (dialog)))
+ {
+ case GTK_RESPONSE_ACCEPT:
+ {
+ gchar *name =
+ gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+
+ gchar *sysname = convert_glib_filename_to_system_filename (name, NULL);
+
+ if (any_reader_may_open (sysname))
+ {
+ PsppireWindow *window;
+
+#if 0
+ if (PSPPIRE_IS_DATA_WINDOW (de)
+ && psppire_data_window_is_empty (PSPPIRE_DATA_WINDOW (de)))
+ window = de;
+ else
+ window = PSPPIRE_WINDOW (psppire_data_window_new (NULL));
+#else
+ window = PSPPIRE_WINDOW (psppire_default_data_window ());
+#endif
+
+ psppire_window_load (window, name);
+ gtk_widget_show (GTK_WIDGET (window));
+ }
+ else
+ open_syntax_window (name);
+
+ g_free (sysname);
+ g_free (name);
+ }
+ break;
+ default:
+ break;
+ }
+
+ gtk_widget_destroy (dialog);
+}
+
/* Puts FILE_NAME into the recent list.
If it's already in the list, it moves it to the top
void psppire_window_save (PsppireWindow *w);
gboolean psppire_window_load (PsppireWindow *w, const gchar *file);
+void psppire_window_open (PsppireWindow *de);
+GtkWidget *psppire_window_file_chooser_dialog (PsppireWindow *toplevel);
G_END_DECLS
</object>
</child>
<child>
- <object class="GtkAction" id="open2">
+ <object class="GtkAction" id="file_open">
<property name="stock-id">gtk-open</property>
- <property name="name">open2</property>
- </object>
- </child>
- <child>
- <object class="GtkAction" id="file_open_syntax">
- <property name="name">file_open_syntax</property>
- <property name="label" translatable="yes">_Syntax</property>
- </object>
- </child>
- <child>
- <object class="GtkAction" id="file_open_data">
- <property name="name">file_open_data</property>
- <property name="label" translatable="yes">_Data</property>
+ <property name="name">file_open</property>
</object>
</child>
<child>
<menuitem action="file_new_syntax"/>
<menuitem action="file_new_data"/>
</menu>
- <menu action="open2">
- <menuitem action="file_open_syntax"/>
- <menuitem action="file_open_data"/>
- </menu>
+ <menuitem action="file_open"/>
<menuitem action="file_save"/>
<menuitem action="file_save_as"/>
<separator/>