From: John Darrington Date: Sat, 21 Feb 2009 04:04:05 +0000 (+0900) Subject: Re enable the connect_help function X-Git-Tag: v0.7.3~296^2~3 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c38762e6de6a20119033f6405f05472372ec7c5a;p=pspp-builds.git Re enable the connect_help function --- diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index cd63c4a6..aec2e3d4 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -179,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_"); @@ -192,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) diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h index aa52ded3..3e1cb067 100644 --- a/src/ui/gui/helper.h +++ b/src/ui/gui/helper.h @@ -54,7 +54,7 @@ GtkWidget * get_widget_assert (gpointer x, const gchar *name); char * pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err); -void connect_help (GladeXML *); +void connect_help (gpointer *); void reference_manual (GtkMenuItem *, gpointer); diff --git a/src/ui/gui/missing-val-dialog.c b/src/ui/gui/missing-val-dialog.c index e8027bf8..52e7a037 100644 --- a/src/ui/gui/missing-val-dialog.c +++ b/src/ui/gui/missing-val-dialog.c @@ -224,8 +224,6 @@ missing_val_dialog_create (GtkBuilder *xml) { struct missing_val_dialog *dialog = g_malloc (sizeof (*dialog)); - // connect_help (xml); - dialog->window = get_widget_assert (xml, "missing_values_dialog"); gtk_window_set_transient_for diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index d5e5044a..3671e098 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -208,7 +208,7 @@ psppire_output_window_init (PsppireOutputWindow *window) gtk_widget_show_all (box); - // connect_help (xml); + connect_help (xml); window->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (window->textview)); diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index a786db80..898d8a75 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -500,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); diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index a36bf6f9..ed9a4268 100644 --- a/src/ui/gui/psppire-var-sheet.c +++ b/src/ui/gui/psppire-var-sheet.c @@ -491,6 +491,8 @@ psppire_var_sheet_init (PsppireVarSheet *vs) vs->missing_val_dialog = missing_val_dialog_create (builder); vs->var_type_dialog = var_type_dialog_create (builder); + connect_help (builder); + g_object_unref (builder); vs->dispose_has_run = FALSE; diff --git a/src/ui/gui/val-labs-dialog.c b/src/ui/gui/val-labs-dialog.c index 6cddeb3e..3b56efad 100644 --- a/src/ui/gui/val-labs-dialog.c +++ b/src/ui/gui/val-labs-dialog.c @@ -372,8 +372,6 @@ val_labs_dialog_create (GtkBuilder *xml) struct val_labs_dialog *dialog = g_malloc (sizeof (*dialog)); - // connect_help (xml); - dialog->window = get_widget_assert (xml,"val_labs_dialog"); dialog->value_entry = get_widget_assert (xml,"value_entry"); dialog->label_entry = get_widget_assert (xml,"label_entry");