X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire.c;h=7344b9816146f867b7804eee824ebe169601fe61;hb=7f0d18e1c856e42ef8fc910d785baace2900f7e6;hp=20f5130e81895d00bff35c5208ef781a8ea1d697;hpb=caea04e274261b575c7a3c5d3742c2a9672a5c54;p=pspp diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 20f5130e81..7344b98161 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -1,5 +1,6 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011, 2012, 2013, 2014, 2016 Free Software Foundation + Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011, 2012, 2013, 2014, + 2016 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 @@ -17,7 +18,6 @@ #include -#include #include #include #include @@ -38,7 +38,8 @@ #include "output/driver.h" #include "output/journal.h" -#include "output/message-item.h" +#include "output/output-item.h" +#include "output/spv/spv.h" #include "ui/gui/dict-display.h" #include "ui/gui/executor.h" @@ -105,7 +106,7 @@ initialize (const struct init_source *is) bind_textdomain_codeset (PACKAGE, "UTF-8"); break; case 8: - if ( ! gtk_parse_args (is->argc, is->argv) ) + if (! gtk_parse_args (is->argc, is->argv)) { perror ("Error parsing arguments"); exit (1); @@ -139,53 +140,26 @@ psppire_quit (GApplication *app) g_application_quit (app); } -struct icon_size -{ - int resolution; /* The dimension of the images which will be used */ - size_t n_sizes; /* The number of items in the array below. */ - const GtkIconSize *usage; /* An array determining for what the icon set is used */ -}; - -static const GtkIconSize menus[] = {GTK_ICON_SIZE_MENU}; -static const GtkIconSize large_toolbar[] = {GTK_ICON_SIZE_LARGE_TOOLBAR}; -static const GtkIconSize small_toolbar[] = {GTK_ICON_SIZE_SMALL_TOOLBAR}; - - -/* We currently have three icon sets viz: 16x16, 24x24 and 32x32 - We use the 16x16 for menus, the 32x32 for the large_toolbars and - the 24x24 for small_toolbars. - - The order of this array is pertinent. The icons in the sets occuring - earlier in the array will be used a the wildcard (default) icon size, - if such an icon exists. -*/ -static const struct icon_size sizemap[] = - { - {24, sizeof (small_toolbar) / sizeof (GtkIconSize), small_toolbar}, - {16, sizeof (menus) / sizeof (GtkIconSize), menus}, - {32, sizeof (large_toolbar) / sizeof (GtkIconSize), large_toolbar} - }; - - - - static void handle_msg (const struct msg *m_, void *lexer_) { struct lexer *lexer = lexer_; - struct msg m = *m_; + struct msg m = { + .category = m_->category, + .severity = m_->severity, + .location = (m_->location ? m_->location + : lexer ? lex_get_location (lexer, 0, 0) + : NULL), + .command_name = output_get_uppercase_command_name (), + .text = m_->text, + }; - if (lexer != NULL && m.file_name == NULL) - { - m.file_name = CONST_CAST (char *, lex_get_file_name (lexer)); - m.first_line = lex_get_first_line_number (lexer, 0); - m.last_line = lex_get_last_line_number (lexer, 0); - m.first_column = lex_get_first_column (lexer, 0); - m.last_column = lex_get_last_column (lexer, 0); - } + output_item_submit (message_item_create (&m)); - message_item_submit (message_item_create (&m)); + free (m.command_name); + if (m.location != m_->location) + msg_location_destroy (m.location); } void @@ -196,27 +170,34 @@ psppire_set_lexer (struct lexer *lexer) GtkWindow * -psppire_preload_file (const gchar *file) +psppire_preload_file (const gchar *file, GtkWindow *victim) { const gchar *local_encoding = "UTF-8"; - + struct file_handle *fh = fh_create_file (NULL, file, local_encoding, fh_default_properties ()); const char *filename = fh_get_file_name (fh); - + int retval = any_reader_detect (fh, NULL); GtkWindow *w = NULL; /* Check to see if the file is a .sav or a .por file. If not assume that it is a syntax file */ if (retval == 1) - w = open_data_window (NULL, filename, NULL, NULL); + w = open_data_window (PSPPIRE_WINDOW (victim), filename, NULL, NULL); else if (retval == 0) { - create_data_window (); - w = open_syntax_window (filename, NULL); + char *error = spv_detect (filename); + if (!error) + read_spv_file (filename); + else + { + free (error); + create_data_window (); + open_syntax_window (filename, NULL); + } } fh_unref (fh);