From b48a20de787a6374000174949dcd8f9666ecc51c Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 20 Feb 2009 14:28:16 +0900 Subject: [PATCH] Converted syntax-editor definition from libglade to gtkbuilder --- src/ui/gui/automake.mk | 3 ++- src/ui/gui/helper.c | 13 ++++++++++ src/ui/gui/helper.h | 1 + src/ui/gui/psppire-syntax-window.c | 39 ++++++++++++++++-------------- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 6440215a..b9246ccc 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -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) diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 1d4ae027..cd63c4a6 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -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) diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h index d388ccb4..aa52ded3 100644 --- a/src/ui/gui/helper.h +++ b/src/ui/gui/helper.h @@ -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 */ diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index 31f4966e..2b4c5b5e 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -18,7 +18,6 @@ #include #include -#include #include "helper.h" #include @@ -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); -- 2.30.2