Internationalisation.
[pspp-builds.git] / src / ui / gui / menu-actions.c
index d1165f38b6ae8117f8d7efea4c7816dd5ff8b489..f031ea7030e5a1b75f2898c752a9db36678c1a14 100644 (file)
 
 #include <config.h>
 #include <stdlib.h>
+#include <gettext.h>
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
 
 #include <data/file-handle-def.h>
 #include <data/sys-file-reader.h>
@@ -40,8 +44,6 @@
 #include "psppire-var-store.h"
 #include "psppire-data-store.h"
 
-#define _(A) A
-#define N_(A) A
 
 
 extern GladeXML *xml;
@@ -55,26 +57,25 @@ static struct file_handle *psppire_handle = 0;
 
 static const gchar handle_name[] = "psppire_handle";
 
-static const gchar untitled[] = _("Untitled");
+static const gchar untitled[] = N_("Untitled");
 
-static const gchar window_title[]=_("PSPP Data Editor");
+static const gchar window_title[] = N_("PSPP Data Editor");
 
 
+/* Sets the title bar to TEXT */
 static void
 psppire_set_window_title(const gchar *text)
 {
   GtkWidget *data_editor = get_widget_assert(xml, "data_editor");
   
-  gchar *title = g_strdup_printf("%s --- %s", text, window_title);
+  gchar *title = g_strdup_printf("%s --- %s", text, gettext(window_title));
 
   gtk_window_set_title(GTK_WINDOW(data_editor), title);
-
-  g_free(title);
 }
 
-void
-on_new1_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+
+gboolean
+clear_file(void)
 {
   GtkWidget *data_sheet = get_widget_assert(xml, "data_sheet");
   GtkWidget *var_sheet = get_widget_assert(xml, "variable_sheet");
@@ -86,13 +87,23 @@ on_new1_activate                       (GtkMenuItem     *menuitem,
   psppire_dict_clear(the_dictionary);
   psppire_case_array_clear(the_cases);
   
-  psppire_set_window_title(untitled);
+  psppire_set_window_title(gettext(untitled));
 
   if (psppire_handle)
     fh_free(psppire_handle);
   psppire_handle = 0 ;
+
+  return TRUE;
 }
 
+void
+on_new1_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  clear_file();
+}
+
+
 
 static gboolean
 populate_case_from_reader(struct ccase *c, gpointer aux)
@@ -591,8 +602,10 @@ data_var_select(GtkNotebook *notebook,
   switch_menus(page_num);
 }
 
-static void
-var_data_selection_init()
+
+/* Initialised things on the variable sheet */
+void
+var_data_selection_init(void)
 {
   notebook = GTK_NOTEBOOK(get_widget_assert(xml, "notebook1"));
   menuitems[PAGE_DATA_SHEET] = get_widget_assert(xml, "data1");
@@ -624,14 +637,3 @@ on_variables1_activate(GtkMenuItem     *menuitem,
   select_sheet(PAGE_VAR_SHEET);
 }
 
-
-/* Callback which occurs when gtk_main is entered */
-gboolean
-callbacks_on_init(gpointer data)
-{
-  psppire_set_window_title(untitled);
-
-  var_data_selection_init();
-
-  return FALSE;
-}