New objects psppire-window and psppire-syntax-window.
[pspp] / src / ui / gui / data-editor.c
index f7df21c752e746bec52f647f672db0082e387fba..f540592db73bef50639cd87b64dabaa875ef903d 100644 (file)
@@ -59,7 +59,7 @@
 #define N_(msgid) msgid
 
 #include "data-editor.h"
-#include "syntax-editor.h"
+#include "psppire-syntax-window.h"
 #include <language/syntax-string-source.h>
 #include <language/command.h>
 #include <ui/syntax-gen.h>
@@ -74,6 +74,9 @@ static void on_edit_paste (GtkAction *a, gpointer data);
 
 
 static GtkWidget * create_data_sheet_variable_popup_menu (struct data_editor *);
+
+static GtkWidget * create_var_sheet_variable_popup_menu (struct data_editor *);
+
 static GtkWidget * create_data_sheet_cases_popup_menu (struct data_editor *);
 
 static void register_data_editor_actions (struct data_editor *de);
@@ -81,6 +84,8 @@ static void on_insert_variable (GtkAction *, gpointer data);
 static void insert_case (GtkAction *a, gpointer data);
 
 static void toggle_value_labels (GtkToggleAction *a, gpointer data);
+static void toggle_split_window (GtkToggleAction *ta, gpointer data);
+
 
 /* Callback for when the dictionary changes properties*/
 static void on_weight_change (GObject *, gint, gpointer);
@@ -203,7 +208,7 @@ on_recent_files_select (GtkMenuShell *menushell,   gpointer user_data)
 {
   gchar *file;
 
-  struct syntax_editor *se ;
+  GtkWidget *se ;
 
   gchar *uri =
     gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell));
@@ -212,10 +217,10 @@ on_recent_files_select (GtkMenuShell *menushell,   gpointer user_data)
 
   g_free (uri);
 
-  se = (struct syntax_editor *)
-    window_create (WINDOW_SYNTAX, file);
+  se = psppire_syntax_window_new ();
 
-  load_editor_from_file (se, file, NULL);
+  psppire_syntax_window_load_from_file (PSPPIRE_SYNTAX_WINDOW (se), file, NULL);
+  gtk_widget_show (se);
 
   g_free (file);
 }
@@ -695,8 +700,8 @@ new_data_editor (void)
 
   g_signal_connect (get_widget_assert (de->xml,"file_new_syntax"),
                    "activate",
-                   G_CALLBACK (new_syntax_window),
-                   e->window);
+                   G_CALLBACK (create_syntax_window),
+                   NULL);
 
   g_signal_connect (get_widget_assert (de->xml,"file_open_syntax"),
                    "activate",
@@ -914,21 +919,37 @@ new_data_editor (void)
                    "activate",
                    G_CALLBACK (minimise_all_windows), NULL);
 
+  de->toggle_split_window =
+    gtk_toggle_action_new ("toggle-split-window",
+                          _("_Split Window"),
+                          _("Split the window vertically and horizontally"),
+                          "pspp-split-window");
+
+  g_signal_connect (de->toggle_split_window, "toggled",
+                   G_CALLBACK (toggle_split_window),
+                   de);
+
+  gtk_action_connect_proxy (GTK_ACTION (de->toggle_split_window),
+                           get_widget_assert (de->xml,
+                                              "windows_split"));
 
   de->data_sheet_variable_popup_menu =
     GTK_MENU (create_data_sheet_variable_popup_menu (de));
 
+  de->var_sheet_variable_popup_menu =
+    GTK_MENU (create_var_sheet_variable_popup_menu (de));
+
   de->data_sheet_cases_popup_menu =
     GTK_MENU (create_data_sheet_cases_popup_menu (de));
 
 
   g_object_set (de->data_editor,
-               "column-menu", de->data_sheet_variable_popup_menu, NULL);
+               "datasheet-column-menu", de->data_sheet_variable_popup_menu,
+               "datasheet-row-menu", de->data_sheet_cases_popup_menu,
+               "varsheet-row-menu", de->var_sheet_variable_popup_menu,
+               NULL);
 
 
-  g_object_set (de->data_editor,
-               "row-menu", de->data_sheet_cases_popup_menu, NULL);
-
   return de;
 }
 
@@ -1023,9 +1044,19 @@ static void
 fonts_activate (GtkMenuItem *menuitem, gpointer data)
 {
   struct data_editor *de = data;
+  PangoFontDescription *current_font;
+  gchar *font_name;
   GtkWidget *dialog =
     gtk_font_selection_dialog_new (_("Font Selection"));
 
+
+  current_font = GTK_WIDGET(de->data_editor)->style->font_desc;
+  font_name = pango_font_description_to_string (current_font);
+
+  gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (dialog), font_name);
+
+  g_free (font_name);
+
   gtk_window_set_transient_for (GTK_WINDOW (dialog),
                                GTK_WINDOW (get_widget_assert (de->xml,
                                                               "data_editor")));
@@ -1056,6 +1087,18 @@ toggle_value_labels (GtkToggleAction *ta, gpointer data)
 
 
 
+static void
+toggle_split_window (GtkToggleAction *ta, gpointer data)
+{
+  struct data_editor *de = data;
+
+  psppire_data_editor_split_window (de->data_editor,
+                                   gtk_toggle_action_get_active (ta));
+}
+
+
+
+
 static void
 file_quit (GtkCheckMenuItem *menuitem, gpointer data)
 {
@@ -1590,6 +1633,43 @@ create_data_sheet_cases_popup_menu (struct data_editor *de)
 }
 
 
+static GtkWidget *
+create_var_sheet_variable_popup_menu (struct data_editor *de)
+{
+  GtkWidget *menu = gtk_menu_new ();
+
+  GtkWidget *insert_variable =
+    gtk_menu_item_new_with_label (_("Insert Variable"));
+
+  GtkWidget *delete_variable =
+    gtk_menu_item_new_with_label (_("Clear"));
+
+
+  gtk_action_connect_proxy (de->delete_variables,
+                           delete_variable);
+
+
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable);
+
+  g_signal_connect_swapped (G_OBJECT (insert_variable), "activate",
+                           G_CALLBACK (gtk_action_activate),
+                           de->insert_variable);
+
+
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+                        gtk_separator_menu_item_new ());
+
+
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), delete_variable);
+
+
+  gtk_widget_show_all (menu);
+
+  return menu;
+}
+
+
+
 \f
 
 static void