Remove deprecated objects GtkAction and GtkUIManager
[pspp] / src / ui / gui / psppire-data-editor.c
index 5ae78dd886d503d7a04936c3632f0a775b90cf62..1c6143aaf4df167310b2d517915f09b4e43bd247 100644 (file)
@@ -31,7 +31,7 @@
 #include "ui/gui/psppire-data-store.h"
 #include "ui/gui/psppire-value-entry.h"
 #include "ui/gui/psppire-var-sheet.h"
-#include "ui/gui/psppire.h"
+#include "ui/gui/psppire-conf.h"
 
 #include <gettext.h>
 #define _(msgid) gettext (msgid)
@@ -48,7 +48,6 @@ static void psppire_data_editor_init                (PsppireDataEditor      *de)
 
 static void disconnect_data_sheets (PsppireDataEditor *);
 static void refresh_entry (PsppireDataEditor *);
-static void psppire_data_editor_update_ui_manager (PsppireDataEditor *);
 
 GType
 psppire_data_editor_get_type (void)
@@ -104,12 +103,6 @@ psppire_data_editor_dispose (GObject *obj)
       de->font = NULL;
     }
 
-  if (de->ui_manager)
-    {
-      g_object_unref (de->ui_manager);
-      de->ui_manager = NULL;
-    }
-
   /* Chain up to the parent class */
   G_OBJECT_CLASS (parent_class)->dispose (obj);
 }
@@ -120,8 +113,7 @@ enum
     PROP_DATA_STORE,
     PROP_DICTIONARY,
     PROP_VALUE_LABELS,
-    PROP_SPLIT_WINDOW,
-    PROP_UI_MANAGER
+    PROP_SPLIT_WINDOW
   };
 
 static void
@@ -182,7 +174,7 @@ psppire_data_editor_set_property (GObject         *object,
         psppire_data_sheet_set_value_labels (data_sheet,
                                           g_value_get_boolean (value));
       break;
-    case PROP_UI_MANAGER:
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -213,9 +205,6 @@ psppire_data_editor_get_property (GObject         *object,
                            psppire_data_sheet_get_value_labels (
                              PSPPIRE_DATA_SHEET (de->data_sheets[0])));
       break;
-    case PROP_UI_MANAGER:
-      g_value_set_object (value, psppire_data_editor_get_ui_manager (de));
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -228,7 +217,7 @@ psppire_data_editor_switch_page (GtkNotebook     *notebook,
                                  guint            page_num)
 {
   GTK_NOTEBOOK_CLASS (parent_class)->switch_page (notebook, w, page_num);
-  psppire_data_editor_update_ui_manager (PSPPIRE_DATA_EDITOR (notebook));
+
 }
 
 static void
@@ -236,7 +225,7 @@ psppire_data_editor_set_focus_child (GtkContainer *container,
                                      GtkWidget    *widget)
 {
   GTK_CONTAINER_CLASS (parent_class)->set_focus_child (container, widget);
-  psppire_data_editor_update_ui_manager (PSPPIRE_DATA_EDITOR (container));
+
 }
 
 static void
@@ -246,7 +235,7 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass)
   GParamSpec *dict_spec ;
   GParamSpec *value_labels_spec;
   GParamSpec *split_window_spec;
-  GParamSpec *ui_manager_spec;
+
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
   GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
@@ -304,15 +293,6 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass)
                                    PROP_SPLIT_WINDOW,
                                    split_window_spec);
 
-  ui_manager_spec =
-    g_param_spec_object ("ui-manager",
-                         "UI Manager",
-                         "UI manager for the active notebook tab.  The client should merge this UI manager with the active UI manager to obtain menu items and tool bar items specific to the active notebook tab.",
-                         GTK_TYPE_UI_MANAGER,
-                         G_PARAM_READABLE);
-  g_object_class_install_property (object_class,
-                                   PROP_UI_MANAGER,
-                                   ui_manager_spec);
 }
 
 static gboolean
@@ -693,27 +673,29 @@ make_split_datasheet (PsppireDataEditor *de, GtkTreeViewGridLines grid_lines,
   return GTK_WIDGET (xpaned);
 }
 
+static void set_font_recursively (GtkWidget *w, gpointer data);
+
 static void
 psppire_data_editor_init (PsppireDataEditor *de)
 {
   GtkWidget *var_sheet_scroller;
   GtkWidget *hbox;
+  gchar *fontname = NULL;
 
   de->font = NULL;
-  de->ui_manager = NULL;
   de->old_vbox_widget = NULL;
 
   g_object_set (de, "tab-pos", GTK_POS_BOTTOM, NULL);
 
   de->cell_ref_label = gtk_label_new ("");
   gtk_label_set_width_chars (GTK_LABEL (de->cell_ref_label), 25);
-  gtk_misc_set_alignment (GTK_MISC (de->cell_ref_label), 0.0, 0.5);
+  gtk_widget_set_valign (de->cell_ref_label, GTK_ALIGN_CENTER);
 
   de->datum_entry = psppire_value_entry_new ();
   g_signal_connect (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (de->datum_entry))),
                     "activate", G_CALLBACK (on_datum_entry_activate), de);
 
-  hbox = gtk_hbox_new (FALSE, 0);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_box_pack_start (GTK_BOX (hbox), de->cell_ref_label, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (hbox), de->datum_entry, TRUE, TRUE, 0);
 
@@ -721,7 +703,7 @@ psppire_data_editor_init (PsppireDataEditor *de)
   de->datasheet_vbox_widget
     = make_single_datasheet (de, GTK_TREE_VIEW_GRID_LINES_BOTH, FALSE);
 
-  de->vbox = gtk_vbox_new (FALSE, 0);
+  de->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   gtk_box_pack_start (GTK_BOX (de->vbox), hbox, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (de->vbox), de->datasheet_vbox_widget,
                       TRUE, TRUE, 0);
@@ -747,7 +729,15 @@ psppire_data_editor_init (PsppireDataEditor *de)
 
   g_object_set (de, "can-focus", FALSE, NULL);
 
-  psppire_data_editor_update_ui_manager (de);
+  if (psppire_conf_get_string (psppire_conf_new (),
+                          "Data Editor", "font",
+                               &fontname) )
+    {
+      de->font = pango_font_description_from_string (fontname);
+      g_free (fontname);
+      set_font_recursively (GTK_WIDGET (de), de->font);
+    }
+
 }
 
 GtkWidget*
@@ -783,12 +773,8 @@ static void
 set_font_recursively (GtkWidget *w, gpointer data)
 {
   PangoFontDescription *font_desc = data;
-  GtkRcStyle *style = gtk_widget_get_modifier_style (w);
-
-  pango_font_description_free (style->font_desc);
-  style->font_desc = pango_font_description_copy (font_desc);
 
-  gtk_widget_modify_style (w, style);
+  gtk_widget_override_font (w, font_desc);
 
   if ( GTK_IS_CONTAINER (w))
     gtk_container_foreach (GTK_CONTAINER (w), set_font_recursively, font_desc);
@@ -798,11 +784,18 @@ set_font_recursively (GtkWidget *w, gpointer data)
 void
 psppire_data_editor_set_font (PsppireDataEditor *de, PangoFontDescription *font_desc)
 {
+  gchar *font_name;
   set_font_recursively (GTK_WIDGET (de), font_desc);
 
   if (de->font)
     pango_font_description_free (de->font);
   de->font = pango_font_description_copy (font_desc);
+  font_name = pango_font_description_to_string (de->font);
+
+  psppire_conf_set_string (psppire_conf_new (),
+                          "Data Editor", "font",
+                          font_name);
+
 }
 
 /* If SPLIT is TRUE, splits DE's data sheet into four panes.
@@ -848,7 +841,6 @@ psppire_data_editor_split_window (PsppireDataEditor *de, gboolean split)
 
   de->split = split;
   g_object_notify (G_OBJECT (de), "split");
-  psppire_data_editor_update_ui_manager (de);
 }
 
 /* Makes the variable with dictionary index DICT_INDEX in DE's dictionary
@@ -907,58 +899,3 @@ psppire_data_editor_get_active_data_sheet (PsppireDataEditor *de)
 
   return PSPPIRE_DATA_SHEET (de->data_sheets[0]);
 }
-
-/* Returns the UI manager that should be merged into DE's toplevel widget's UI
-   manager to display menu items and toolbar items specific to DE's current
-   page and data sheet.
-
-   DE's toplevel widget can watch for changes by connecting to DE's
-   notify::ui-manager signal. */
-GtkUIManager *
-psppire_data_editor_get_ui_manager (PsppireDataEditor *de)
-{
-  psppire_data_editor_update_ui_manager (de);
-  return de->ui_manager;
-}
-
-static void
-psppire_data_editor_update_ui_manager (PsppireDataEditor *de)
-{
-  PsppireDataSheet *data_sheet;
-  GtkUIManager *ui_manager;
-
-  ui_manager = NULL;
-
-  switch (gtk_notebook_get_current_page (GTK_NOTEBOOK (de)))
-    {
-    case PSPPIRE_DATA_EDITOR_DATA_VIEW:
-      data_sheet = psppire_data_editor_get_active_data_sheet (de);
-      if (data_sheet != NULL)
-        ui_manager = psppire_data_sheet_get_ui_manager (data_sheet);
-      else
-        {
-          /* This happens transiently in psppire_data_editor_split_window(). */
-        }
-      break;
-
-    case PSPPIRE_DATA_EDITOR_VARIABLE_VIEW:
-      ui_manager = psppire_var_sheet_get_ui_manager (
-        PSPPIRE_VAR_SHEET (de->var_sheet));
-      break;
-
-    default:
-      /* This happens transiently in psppire_data_editor_init(). */
-      break;
-    }
-
-  if (ui_manager != de->ui_manager)
-    {
-      if (de->ui_manager)
-        g_object_unref (de->ui_manager);
-      if (ui_manager)
-        g_object_ref (ui_manager);
-      de->ui_manager = ui_manager;
-
-      g_object_notify (G_OBJECT (de), "ui-manager");
-    }
-}