topic.dat parsing in gnome-app-helper.c



Hi!

I was to include some html files into the help menu of my application
(gquest) using
GNOMEUIINFO_HELP ("gquest")

I created a topic.dat file includeing some html files and there appeared a
empty menu entry at the end of the help menu. Why? because I pressed enter
at the last line of the topic.dat file.

I did some investigation and:
create_help_entries() used by GNOMEUIINFO_HELP in gnome-app-helper.c
in gnome-libs/libgnomeui
does not skip empty lines.

The fix is quite easy:
skip creating a menu-entry when
 -  *buf != '\0'
    (buf contains the name of the help-file)
 -  *s != '\0'
    (s contains the label)

I donīt have cvs write acces but Iīm sure someone can fix it.
see a fixed version of the while-loop in create_help_entries():


        while (fgets (buf, sizeof (buf), file)) {
                /* Format of lines is "help_file_name whitespace*
menu_title" */

                for (s = buf; *s && !isspace (*s); s++)
                        ;

                *s++ = '\0';

                for (; *s && isspace (*s); s++)
                        ;

                if (s[strlen (s) - 1] == '\n')
                        s[strlen (s) - 1] = '\0';

                /* Create help menu entry */

                if( *buf != '\0' && *s != '\0') { /* skip empty lines */
                        entry = g_new (GnomeHelpMenuEntry, 1);
                        entry->name = g_strdup (uiinfo->moreinfo);
                        entry->path = g_strdup (buf);

                        item = gtk_menu_item_new ();
                        label = create_label (s, &keyval);
                        gtk_container_add(GTK_CONTAINER (item), label);
                        setup_underlined_accelerator(NULL,
menu_accel_group, item,
                                        keyval);

                        gtk_signal_connect (GTK_OBJECT (item), "activate",
                                            (GtkSignalFunc)
gnome_help_display, entry);
                        gtk_signal_connect (GTK_OBJECT (item), "destroy",
                                            (GtkSignalFunc)
free_help_menu_entry,
                                            entry);

                        gtk_menu_shell_insert (menu_shell, item, pos);
                        pos++;

                        gtk_widget_show (item);
                }
        }




Cheers, Martin.

+-------------------------------------------+
| Martin Hawlisch                           |
| http://freddy.rz.fh-mannheim.de/~hawlisch |
+-------------------------------------------+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]