X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fhelper.c;h=aec2e3d408a5411f86406e80c5d2635e0e946417;hb=c38762e6de6a20119033f6405f05472372ec7c5a;hp=bae608afa7ab060aeae46ad5782fc914548efabc;hpb=38c2638eed90f33225870563c4be183097e4155a;p=pspp-builds.git diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index bae608af..aec2e3d4 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -20,6 +20,8 @@ */ #include +#include "psppire-syntax-window.h" + #include #include @@ -32,6 +34,7 @@ #include #include +#include #include #include @@ -45,7 +48,7 @@ #include #include "psppire-data-store.h" #include -#include "output-viewer.h" +#include "psppire-output-window.h" #include "xalloc.h" @@ -100,14 +103,48 @@ text_to_value (const gchar *text, union value *v, } +GtkBuilder * +builder_new_real (const gchar *name) +{ + GtkBuilder *builder = gtk_builder_new (); + + GError *err = NULL; + if ( ! gtk_builder_add_from_file (builder, name, &err)) + { + g_critical ("Couldnt open user interface file %s: %s", name, err->message); + g_clear_error (&err); + } + + return builder; +} + + +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 (GladeXML *xml, const gchar *name) +get_widget_assert (gpointer x, const gchar *name) { - GtkWidget *w; - g_assert (xml); + GObject *obj = G_OBJECT (x); + GtkWidget *w = NULL; g_assert (name); - w = glade_xml_get_widget (xml, name); + if (GTK_IS_BUILDER (obj)) + w = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (obj), name)); + + if (GLADE_IS_XML (obj)) + w = glade_xml_get_widget (GLADE_XML (obj), name); if ( !w ) g_critical ("Widget \"%s\" could not be found\n", name); @@ -142,8 +179,38 @@ give_help (void) gtk_widget_destroy (dialog); } -void -connect_help (GladeXML *xml) +static void +connect_help_builder (GtkBuilder *xml) +{ + GSList *helps = gtk_builder_get_objects (xml); + + GSList *i; + for ( i = helps; i ; i = g_slist_next (i)) + { + GObject *o = i->data; + if ( GTK_IS_WIDGET (o) ) + { + gchar *name = NULL; + gchar s[12] = {0}; + g_object_get (o, "name", &name, NULL); + + if ( name) + strncpy (s, name, 11); + s[11] = '\0'; + + + if ( 0 == strcmp ("help_button", s)) + { + g_signal_connect (GTK_WIDGET (o), "clicked", give_help, 0); + } + } + } + + g_slist_free (helps); +} + +static void +connect_help_glade (GladeXML *xml) { GList *helps = glade_xml_get_widget_prefix (xml, "help_button_"); @@ -155,6 +222,22 @@ connect_help (GladeXML *xml) } +void +connect_help (gpointer *xml) +{ + if (GTK_IS_BUILDER (xml)) + connect_help_builder (GTK_BUILDER (xml)); + + else if (GLADE_IS_XML (xml)) + connect_help_glade (GLADE_XML (xml)); + + else + { + g_error ("XML of type %s", G_OBJECT_TYPE_NAME (xml)); + } +} + + void reference_manual (GtkMenuItem *menu, gpointer data) @@ -246,7 +329,7 @@ execute_syntax (struct getl_interface *sss) som_flush (); - reload_the_viewer (); + psppire_output_window_reload (); return retval; } @@ -297,3 +380,12 @@ clone_list_store (const GtkListStore *src) } +void +paste_syntax_in_new_window (const gchar *syntax) +{ + GtkWidget *se = psppire_syntax_window_new (); + + gtk_text_buffer_insert_at_cursor (PSPPIRE_SYNTAX_WINDOW (se)->buffer, syntax, -1); + + gtk_widget_show (se); +}