X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-window.c;h=6fb0b87c47209d6992d43db005dc0ecc9621cc29;hb=c502669e3fbc97a792a6c0064a72cfb9690d7d23;hp=fadc70c85f9c3625dad2e22127a47ded194830ce;hpb=d40618a338795cacd2bc8ec92482bf21227f75a2;p=pspp diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index fadc70c85f..6fb0b87c47 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -30,7 +30,7 @@ #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" @@ -39,7 +39,6 @@ #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); @@ -109,6 +108,11 @@ psppire_window_set_title (PsppireWindow *window) 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 (title, " - UNRELEASED TEST SOFTWARE! NOT FOR PRODUCTION USE."); + gtk_window_set_title (GTK_WINDOW (window), title->str); g_string_free (title, TRUE); @@ -309,62 +313,15 @@ psppire_window_base_init (PsppireWindowClass *class) -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); } @@ -393,14 +350,7 @@ static void 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 @@ -448,7 +398,6 @@ on_delete (PsppireWindow *w, GdkEvent *event, gpointer user_data) static void psppire_window_init (PsppireWindow *window) { - window->menu = NULL; window->filename = NULL; window->basename = NULL; window->id = NULL; @@ -615,7 +564,7 @@ psppire_window_model_get_type (void) window_model_type = g_type_register_static (G_TYPE_INTERFACE, "PsppireWindowModel", &window_model_info, 0); - + g_type_interface_add_prerequisite (window_model_type, G_TYPE_OBJECT); } @@ -780,19 +729,22 @@ psppire_window_open (PsppireWindow *de) 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;