#define N_(msgid) msgid
#include "data/any-reader.h"
-#include "data/file-name.h"
+#include "data/file-handle-def.h"
#include "data/dataset.h"
#include "libpspp/version.h"
#include "psppire-encoding-selector.h"
#include "psppire-syntax-window.h"
#include "psppire-window-register.h"
-#include "psppire.h"
static void psppire_window_base_init (PsppireWindowClass *class);
static void psppire_window_class_init (PsppireWindowClass *class);
g_string_append_printf (title, "PSPPIRE %s", window->description);
+ int minor = 1;
+ sscanf (bare_version, "%*d.%d.%*d", &minor);
+ if (minor % 2)
+ g_string_append_printf (title, " - Test version! Please report bugs to %s", PACKAGE_BUGREPORT);
+
gtk_window_set_title (GTK_WINDOW (window), title->str);
g_string_free (title, TRUE);
: NULL);
psppire_window_name_changed (window);
break;
- break;
case PROP_ID:
g_free (window->id);
window->id = g_value_dup_string (value);
-static void
-menu_toggled (GtkCheckMenuItem *mi, gpointer data)
-{
-#if GTK3_TRANSITION
- /* Prohibit changes to the state */
- mi->active = !mi->active;
-#endif
-}
-
-
-/* Look up the window associated with this menuitem and present it to the user */
-static void
-menu_activate (GtkMenuItem *mi, gpointer data)
-{
- const gchar *key = data;
-
- PsppireWindowRegister *reg = psppire_window_register_new ();
-
- PsppireWindow *window = psppire_window_register_lookup (reg, key);
-
- gtk_window_present (GTK_WINDOW (window));
-}
-
static void
insert_menuitem_into_menu (PsppireWindow *window, gpointer key)
{
gchar *filename;
GtkWidget *item;
-
- /* Add a separator before adding the first real item. If we add a separator
- at any other time, sometimes GtkUIManager removes it. */
- if (!window->added_separator)
- {
- GtkWidget *separator = gtk_separator_menu_item_new ();
- gtk_widget_show (separator);
- gtk_menu_shell_append (window->menu, separator);
- window->added_separator = TRUE;
- }
-
filename = g_filename_display_name (key);
item = gtk_check_menu_item_new_with_label (filename);
g_free (filename);
- g_signal_connect (item, "toggled", G_CALLBACK (menu_toggled), NULL);
- g_signal_connect (item, "activate", G_CALLBACK (menu_activate), key);
-
- gtk_widget_show (item);
-
- gtk_menu_shell_append (window->menu, item);
-
-#if GTK3_TRANSITION
- /* Set the state without emitting a signal */
- GTK_CHECK_MENU_ITEM (item)->active =
- (psppire_window_register_lookup (psppire_window_register_new (), key) == window);
-#endif
-
g_hash_table_insert (window->menuitem_table, key, item);
}
insert_menuitem (GObject *reg, const gchar *key, gpointer data)
{
PsppireWindow *window = PSPPIRE_WINDOW (data);
-
+
insert_menuitem_into_menu (window, (gpointer) key);
}
remove_menuitem (PsppireWindowRegister *reg, const gchar *key, gpointer data)
{
PsppireWindow *window = PSPPIRE_WINDOW (data);
- GtkWidget *item ;
-
- item = g_hash_table_lookup (window->menuitem_table, key);
-
g_hash_table_remove (window->menuitem_table, key);
-
- if (GTK_IS_CONTAINER (window->menu))
- gtk_container_remove (GTK_CONTAINER (window->menu), item);
}
static void
static void
psppire_window_init (PsppireWindow *window)
{
- window->menu = NULL;
window->filename = NULL;
window->basename = NULL;
window->id = NULL;
GTK_RESPONSE_REJECT);
cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL,
+ _("Cancel"),
GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_SAVE,
+ _("Save"),
GTK_RESPONSE_APPLY);
gtk_widget_grab_focus (cancel_button);
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,
+ _("Cancel"), GTK_RESPONSE_CANCEL,
+ _("Open"), GTK_RESPONSE_ACCEPT,
NULL);
g_object_set (dialog, "local-only", FALSE, NULL);
gchar *name =
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- gchar *sysname = convert_glib_filename_to_system_filename (name, NULL);
+ const gchar **cs = NULL;
+ g_get_filename_charsets (&cs);
gchar *encoding = psppire_encoding_selector_get_encoding (
gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog)));
- int retval = any_reader_detect (sysname, NULL);
+ struct file_handle *fh = fh_create_file (NULL, name, cs[0], fh_default_properties ());
+
+ int retval = any_reader_detect (fh, NULL);
if (retval == 1)
open_data_window (de, name, encoding, NULL);
else if (retval == 0)
open_syntax_window (name, encoding);
g_free (encoding);
- g_free (sysname);
+ fh_unref (fh);
g_free (name);
}
break;