From: John Darrington Date: Wed, 27 Dec 2006 09:04:35 +0000 (+0000) Subject: Re-added the help button callbacks X-Git-Tag: v0.6.0~602 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=356c1209257f91eb08791e6b9ca72393fca6fcd0;p=pspp-builds.git Re-added the help button callbacks --- diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index 61b5aea0..df13affa 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -114,6 +114,8 @@ new_data_editor (void) de->xml = glade_xml_new (PKGDATADIR "/data-editor.glade", NULL, NULL); + connect_help (de->xml); + e->window = get_widget_assert (de->xml, "data_editor"); g_signal_connect (get_widget_assert (de->xml,"file_new_data"), diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index ae645a61..75b88f1d 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -82,3 +82,34 @@ pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err) return recode_string (CONV_PSPP_TO_UTF8, text, len); } +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + + +static void +give_help (void) +{ + static struct msg m = { + MSG_GENERAL, + MSG_NOTE, + {0, -1}, + 0, + }; + + if (! m.text) + m.text=g_strdup (_("Sorry. The help system hasn't yet been implemented.")); + + popup_message (&m); +} + +void +connect_help (GladeXML *xml) +{ + GList *helps = glade_xml_get_widget_prefix (xml, "help_button_"); + + 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); +} + + diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h index 3d8d6420..6ca188fc 100644 --- a/src/ui/gui/helper.h +++ b/src/ui/gui/helper.h @@ -41,4 +41,6 @@ GtkWidget * get_widget_assert (GladeXML *xml, const gchar *name); char * pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err); +void connect_help (GladeXML *xml); + #endif diff --git a/src/ui/gui/message-dialog.c b/src/ui/gui/message-dialog.c index 227d3528..297634af 100644 --- a/src/ui/gui/message-dialog.c +++ b/src/ui/gui/message-dialog.c @@ -98,6 +98,7 @@ void popup_message (const struct msg *m) { GtkWidget *dialog; + gchar *location = NULL; gint message_type; const char *msg; @@ -137,12 +138,22 @@ popup_message (const struct msg *m) message_type, GTK_BUTTONS_CLOSE, msg); + if ( m->where.line_number != -1) + { + location = g_strdup_printf (_("%s (line %d)"), + m->where.file_name ? m->where.file_name : "", + m->where.line_number); + } + else + { + location = g_strdup_printf (_("%s"), + m->where.file_name ? m->where.file_name : ""); } gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - _("%s (line %d) %s"), - m->where.file_name, - m->where.line_number, - m->text); + _("%s %s"), + location, + m->text); + free (location); gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); diff --git a/src/ui/gui/missing-val-dialog.c b/src/ui/gui/missing-val-dialog.c index f622d91f..58ff43da 100644 --- a/src/ui/gui/missing-val-dialog.c +++ b/src/ui/gui/missing-val-dialog.c @@ -213,6 +213,8 @@ missing_val_dialog_create (GladeXML *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.c b/src/ui/gui/psppire.c index cd2783c3..b0de6cfa 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -54,25 +54,6 @@ static bool parse_command_line (int *argc, char ***argv, gchar **filename, GError **err); -#define _(msgid) gettext (msgid) -#define N_(msgid) msgid - -static void -give_help (void) -{ - static struct msg m = { - MSG_GENERAL, - MSG_NOTE, - {0, -1}, - 0, - }; - - if (! m.text) - m.text=g_strdup (_("Sorry. The help system hasn't yet been implemented.")); - - popup_message (&m); -} - PsppireVarStore *the_var_store = 0; void create_icon_factory (void); @@ -144,36 +125,6 @@ main (int argc, char *argv[]) create_icon_factory (); -#if 0 - /* load the interface */ - data_editor_xml = glade_xml_new (PKGDATADIR "/data-editor.glade", NULL, NULL); - - if ( !data_editor_xml ) return 1; - - data_editor = get_widget_assert (data_editor_xml, "data_editor"); - - /* connect the signals in the interface */ - glade_xml_signal_autoconnect (data_editor_xml); - - var_sheet = GTK_SHEET (get_widget_assert (data_editor_xml, "variable_sheet")); - data_sheet = GTK_SHEET (get_widget_assert (data_editor_xml, "data_sheet")); - - gtk_sheet_set_model (var_sheet, G_SHEET_MODEL (the_var_store)); - - gtk_sheet_set_model (data_sheet, G_SHEET_MODEL (the_data_store)); - - var_data_selection_init (); - - { - GList *helps = glade_xml_get_widget_prefix (data_editor_xml, "help_button_"); - - 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); - } - -#endif - new_data_window (NULL, NULL); /* start the event loop */ @@ -280,3 +231,6 @@ create_icon_factory (void) gtk_icon_factory_add_default (factory); } + + + diff --git a/src/ui/gui/syntax-editor.c b/src/ui/gui/syntax-editor.c index 35fd7a5e..3341e5c0 100644 --- a/src/ui/gui/syntax-editor.c +++ b/src/ui/gui/syntax-editor.c @@ -325,6 +325,8 @@ new_syntax_editor (void) struct syntax_editor *se ; struct editor_window *e; + connect_help (xml); + se = g_malloc (sizeof (*se)); e = (struct editor_window *)se; diff --git a/src/ui/gui/val-labs-dialog.c b/src/ui/gui/val-labs-dialog.c index 3d7ccef1..22f0dcd7 100644 --- a/src/ui/gui/val-labs-dialog.c +++ b/src/ui/gui/val-labs-dialog.c @@ -371,6 +371,8 @@ val_labs_dialog_create (GladeXML *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");