X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fhelper.c;h=6294e886f694983fb506572e03a2f422008ae402;hb=1b2a87ad88df1fcbf19efaff1476b48711278917;hp=8e616716835a76e6422ad1632614fde5d70f4dd0;hpb=db5b7f9dc9c86ae607f8bcbacaf49065b8cdcbae;p=pspp-builds.git diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 8e616716..6294e886 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -20,17 +20,21 @@ */ #include +#include "psppire-syntax-window.h" + #include #include #include "helper.h" #include "message-dialog.h" +#include #include #include #include #include #include +#include #include #include @@ -44,7 +48,7 @@ #include #include "psppire-data-store.h" #include -#include "output-viewer.h" +#include "psppire-output-window.h" #include "xalloc.h" @@ -99,19 +103,53 @@ text_to_value (const gchar *text, union value *v, } -GtkWidget * -get_widget_assert (GladeXML *xml, const gchar *name) +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, GType type) { - GtkWidget *w; - g_assert (xml); + GObject *o = NULL; g_assert (name); - w = glade_xml_get_widget (xml, name); + o = gtk_builder_get_object (builder, name); - if ( !w ) - g_critical ("Widget \"%s\" could not be found\n", name); + if ( !o ) + g_critical ("Object \"%s\" could not be found\n", name); - return w; + if ( ! g_type_is_a (G_OBJECT_TYPE (o), type)) + { + g_critical ("Object \"%s\" was expected to have type %s, but in fact has type %s", + name, g_type_name (type), G_OBJECT_TYPE_NAME (o)); + } + + return o; +} + + +GtkAction * +get_action_assert (GtkBuilder *builder, const gchar *name) +{ + return GTK_ACTION (get_object_assert (builder, name, GTK_TYPE_ACTION)); +} + +GtkWidget * +get_widget_assert (GtkBuilder *builder, const gchar *name) +{ + return GTK_WIDGET (get_object_assert (builder, name, GTK_TYPE_WIDGET)); } /* Converts a string in the pspp locale to utf-8. @@ -142,17 +180,34 @@ give_help (void) } void -connect_help (GladeXML *xml) +connect_help (GtkBuilder *xml) { - GList *helps = glade_xml_get_widget_prefix (xml, "help_button_"); + 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); - GList *i; - for ( i = g_list_first (helps); i ; i = g_list_next (i)) - g_signal_connect (GTK_WIDGET (i->data), "clicked", give_help, 0); + if ( name) + strncpy (s, name, 11); + s[11] = '\0'; - g_list_free (helps); -} + if ( 0 == strcmp ("help_button", s)) + { + g_signal_connect (o, "clicked", give_help, 0); + } + } + } + + g_slist_free (helps); +} void @@ -241,64 +296,17 @@ execute_syntax (struct getl_interface *sss) reader = proc_extract_active_file_data (the_dataset); if (!lazy_casereader_destroy (reader, lazy_serial)) - psppire_data_store_set_case_file (the_data_store, - psppire_case_file_new (reader)); + psppire_data_store_set_reader (the_data_store, reader); som_flush (); - reload_the_viewer (); + psppire_output_window_reload (); return retval; } -#ifdef G_ENABLE_DEBUG -# define g_marshal_value_peek_int(v) g_value_get_int (v) -#else -# define g_marshal_value_peek_int(v) (v)->data[0].v_int -#endif - - -/* VOID:INT,INT,INT */ -void -marshaller_VOID__INT_INT_INT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data) -{ - typedef void (*GMarshalFunc_VOID__INT_INT_INT) (gpointer data1, - gint arg_1, - gint arg_2, - gint arg_3, - gpointer data2); - register GMarshalFunc_VOID__INT_INT_INT callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - - g_return_if_fail (n_param_values == 4); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_VOID__INT_INT_INT) (marshal_data ? marshal_data : cc->callback); - - callback (data1, - g_marshal_value_peek_int (param_values + 1), - g_marshal_value_peek_int (param_values + 2), - g_marshal_value_peek_int (param_values + 3), - data2); -} - /* Create a deep copy of SRC */ GtkListStore * clone_list_store (const GtkListStore *src) @@ -343,3 +351,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); +}