Converted syntax-editor definition from libglade to gtkbuilder
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 20 Feb 2009 05:28:16 +0000 (14:28 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 20 Feb 2009 05:28:16 +0000 (14:28 +0900)
src/ui/gui/automake.mk
src/ui/gui/helper.c
src/ui/gui/helper.h
src/ui/gui/psppire-syntax-window.c

index 6440215a7667f684edceb3f647314b136d0efb1f..b9246ccc49c06384c5a3d038724769a9870f5a2b 100644 (file)
@@ -76,6 +76,7 @@ nodist_src_ui_gui_psppire_DATA = \
        $(top_builddir)/src/ui/gui/rank.ui \
        $(top_builddir)/src/ui/gui/recode.ui \
        $(top_builddir)/src/ui/gui/regression.ui \
+       $(top_builddir)/src/ui/gui/syntax-editor.ui
        $(top_builddir)/src/ui/gui/t-test.ui
 
 EXTRA_DIST += \
@@ -252,4 +253,4 @@ EXTRA_DIST += src/ui/gui/OChangeLog\
 
 BUILT_SOURCES += src/ui/gui/psppire-marshal.c src/ui/gui/psppire-marshal.h
 CLEANFILES += src/ui/gui/psppire-marshal.c src/ui/gui/psppire-marshal.h \
-       $(nodist_src_ui_gui_psppire_DATA)
\ No newline at end of file
+       $(nodist_src_ui_gui_psppire_DATA)
index 1d4ae02729348d495ed79a3ac9938cd44f3939de..cd63c4a68a6ffef42ef6e60782922c02963c06f4 100644 (file)
@@ -119,6 +119,19 @@ builder_new_real (const gchar *name)
 }
 
 
+GObject *
+get_object_assert (GtkBuilder *builder, const gchar *name)
+{
+  GObject *o = NULL;
+  g_assert (name);
+
+  o = gtk_builder_get_object (builder, name);
+
+  if ( !o )
+    g_critical ("Object \"%s\" could not be found\n", name);
+
+  return o;
+}
 
 GtkWidget *
 get_widget_assert (gpointer x, const gchar *name)
index d388ccb41821b132afaf5670647ea3dd961a0cd4..aa52ded37466e3d87ca75059e2d6c00e855e4b1d 100644 (file)
@@ -47,6 +47,7 @@ gchar * value_to_text (union value v, struct fmt_spec format);
 gboolean text_to_value (const gchar *text, union value *v,
                       struct fmt_spec format);
 
+GObject * get_object_assert (GtkBuilder *builder, const gchar *name);
 GtkWidget * get_widget_assert (gpointer x, const gchar *name);
 
 /* Converts a string in the pspp locale to utf-8 */
index 31f4966ef33948495e7d65898059776c7314bf79..2b4c5b5e4ae871384bd6beb625e336b8c3411c8a 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <gtk/gtksignal.h>
 #include <gtk/gtkbox.h>
-#include <glade/glade.h>
 #include "helper.h"
 
 #include <libpspp/message.h>
@@ -485,9 +484,9 @@ extern struct source_stream *the_source_stream ;
 static void
 psppire_syntax_window_init (PsppireSyntaxWindow *window)
 {
-  GladeXML *xml = XML_NEW ("syntax-editor.glade");
+  GtkBuilder *xml = builder_new ("syntax-editor.ui");
   GtkWidget *box = gtk_vbox_new (FALSE, 0);
-  
+
   GtkWidget *menubar = get_widget_assert (xml, "menubar2");
   GtkWidget *sw = get_widget_assert (xml, "scrolledwindow8");
 
@@ -501,7 +500,7 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
 
   g_signal_connect (window->buffer, "changed", G_CALLBACK (on_text_changed), window);
 
-  connect_help (xml);
+  //  connect_help (xml);
 
   gtk_container_add (GTK_CONTAINER (window), box);
 
@@ -518,74 +517,78 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
 
   gtk_widget_show_all (box);
 
-  g_signal_connect (get_widget_assert (xml,"file_new_syntax"),
+  g_signal_connect (get_object_assert (xml,"file_new_syntax"),
                    "activate",
                    G_CALLBACK (create_syntax_window),
                    NULL);
 
-  g_signal_connect (get_widget_assert (xml,"file_open_syntax"),
+  g_signal_connect (get_object_assert (xml,"file_open_syntax"),
                    "activate",
                    G_CALLBACK (open_syntax_window),
                    window);
 
 #if 0
-  g_signal_connect (get_widget_assert (xml,"file_new_data"),
+  g_signal_connect (get_object_assert (xml,"file_new_data"),
                    "activate",
                    G_CALLBACK (create_data_window),
                    window);
 #endif
 
-  g_signal_connect (get_widget_assert (xml,"help_about"),
+  g_signal_connect (get_object_assert (xml,"help_about"),
                    "activate",
                    G_CALLBACK (about_new),
                    window);
 
-  g_signal_connect (get_widget_assert (xml,"help_reference"),
+  g_signal_connect (get_object_assert (xml,"help_reference"),
                    "activate",
                    G_CALLBACK (reference_manual),
                    NULL);
 
-  g_signal_connect (get_widget_assert (xml, "file_save"),
+  g_signal_connect (get_object_assert (xml, "file_save"),
                    "activate",
                    G_CALLBACK (on_syntax_save),
                    window);
 
-  g_signal_connect (get_widget_assert (xml, "file_save_as"),
+  g_signal_connect (get_object_assert (xml, "file_save_as"),
                    "activate",
                    G_CALLBACK (on_syntax_save_as),
                    window);
 
-  g_signal_connect (get_widget_assert (xml,"file_quit"),
+  g_signal_connect (get_object_assert (xml,"file_quit"),
                    "activate",
                    G_CALLBACK (on_quit),
                    window);
 
-  g_signal_connect (get_widget_assert (xml,"run_all"),
+  g_signal_connect (get_object_assert (xml,"run_all"),
                    "activate",
                    G_CALLBACK (on_run_all),
                    window);
 
 
-  g_signal_connect (get_widget_assert (xml,"run_selection"),
+  g_signal_connect (get_object_assert (xml,"run_selection"),
                    "activate",
                    G_CALLBACK (on_run_selection),
                    window);
 
-  g_signal_connect (get_widget_assert (xml,"run_current_line"),
+  g_signal_connect (get_object_assert (xml,"run_current_line"),
                    "activate",
                    G_CALLBACK (on_run_current_line),
                    window);
 
-  g_signal_connect (get_widget_assert (xml,"run_to_end"),
+  g_signal_connect (get_object_assert (xml,"run_to_end"),
                    "activate",
                    G_CALLBACK (on_run_to_end),
                    window);
 
-  g_signal_connect (get_widget_assert (xml,"windows_minimise_all"),
+  g_signal_connect (get_object_assert (xml,"windows_minimise_all"),
                    "activate",
                    G_CALLBACK (psppire_window_minimise_all), NULL);
 
-  PSPPIRE_WINDOW (window)->menu = GTK_MENU_SHELL (get_widget_assert (xml,"windows_menu"));
+  GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (xml, "uimanager1"));
+
+  PSPPIRE_WINDOW (window)->menu =
+    GTK_MENU_SHELL (GTK_WIDGET (gtk_ui_manager_get_widget (uim,"/ui/menubar2/windows/windows_minimise_all"))->parent);
+
 
   g_object_unref (xml);