gui: Fix icon names.
[pspp] / src / ui / gui / psppire-syntax-window.c
index 3c486848352dd12bd7ab1e0d5e3f12b3bd4c4807..393c2afb5a0d966f3c5d8824601e760a73b4a709 100644 (file)
@@ -197,9 +197,14 @@ editor_execute_syntax (const PsppireSyntaxWindow *sw, GtkTextIter start,
                       GtkTextIter stop)
 {
   PsppireWindow *win = PSPPIRE_WINDOW (sw);
-  struct lex_reader *reader = lex_reader_for_gtk_text_buffer (GTK_TEXT_BUFFER (sw->buffer), start, stop);
+  struct lex_reader *reader = lex_reader_for_gtk_text_buffer (
+    GTK_TEXT_BUFFER (sw->buffer), start, stop, sw->syntax_mode);
 
-  lex_reader_set_file_name (reader, psppire_window_get_filename (win));
+  const gchar *filename = psppire_window_get_filename (win);
+  /* TRANSLATORS: This is part of a filename.  Please avoid whitespace. */
+  gchar *untitled = xasprintf ("%s.sps", _("Untitled"));
+  lex_reader_set_file_name (reader, filename ? filename : untitled);
+  free (untitled);
 
   execute_syntax (psppire_default_data_window (), reader);
 }
@@ -514,6 +519,24 @@ on_run_current_line (PsppireSyntaxWindow *se)
 
 
 
+static void
+on_syntax (GAction *action, GVariant *param, PsppireSyntaxWindow *sw)
+{
+  g_action_change_state (action, param);
+  GVariant *new_state = g_action_get_state (action);
+
+  const gchar *what = g_variant_get_string (new_state, NULL);
+  if (0 == g_strcmp0 (what, "auto"))
+    sw->syntax_mode = SEG_MODE_AUTO;
+  else if (0 == g_strcmp0 (what, "interactive"))
+    sw->syntax_mode = SEG_MODE_INTERACTIVE;
+  else if (0 == g_strcmp0 (what, "batch"))
+    sw->syntax_mode = SEG_MODE_BATCH;
+  else
+    g_warn_if_reached ();
+}
+
+
 /* Append ".sps" to FILENAME if necessary.
    The returned result must be freed when no longer required.
  */
@@ -760,6 +783,7 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
                NULL);
 
   window->encoding = NULL;
+  window->syntax_mode = SEG_MODE_AUTO;
 
   window->cliptext = NULL;
   window->dispose_has_run = FALSE;
@@ -950,6 +974,13 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
     g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (run_to_end));
   }
 
+  {
+    GSimpleAction *act_syntax = g_simple_action_new_stateful ("syntax", G_VARIANT_TYPE_STRING,
+                                                                g_variant_new_string ("auto"));
+    g_signal_connect (act_syntax, "activate", G_CALLBACK (on_syntax), window);
+    g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (act_syntax));
+  }
+
   gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
                         create_windows_menu (GTK_WINDOW (window)));
 
@@ -992,7 +1023,7 @@ error_dialog (GtkWindow *w, const gchar *filename,  GError *err)
 
   g_free (fn);
 
-  g_object_set (dialog, "icon-name", "pspp", NULL);
+  g_object_set (dialog, "icon-name", "org.gnu.pspp", NULL);
 
   gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                            "%s", err->message);