Re: Creating Custom toolbars
- From: Havoc Pennington <hp Mcs Net>
- To: Dave Smith <dsmith gdev net>
- cc: gnome-list gnome org
- Subject: Re: Creating Custom toolbars
- Date: Tue, 2 Feb 1999 23:44:51 -0600 (CST)
On Wed, 3 Feb 1999, Dave Smith wrote:
>
> This may not be the correct list to ask this question on, if not please
> direct me to the right one.
>
Well it's the right list but it looks like your questions are questions
about C rather than Gnome, so perhaps a C list/newsgroup would be
better...
> I have tried:
>
> if (cfg->toolbar_custom)
> {
> glong i;
> GnomeUIInfo *toolbar[50];
>
This is an array of pointers (GnomeUIInfo*), you want an array of
GnomeUIInfo. Also "50" is bad; dynamically allocate the number of elements
you actually need.
> for (i = 0; i < cfg->toolbar_custom_items_no; i++)
> {
> if (!strcmp (cfg->toolbar_custom_items[i], "New"))
> {
> toolbar[i] = GNOMEUIINFO_ITEM_STOCK (N_("New"),
> N_("New File"),
> file_new, GNOME_STOCK_PIXMAP_NEW);
This is the wrong syntax since GNOMEUIINFO_ITEM_STOCK is giving you a
GnomeUIInfo, not a GnomeUIInfo*.
> };
>
> if (!strcmp (cfg->toolbar_custom_items[i], "Open"))
> printf("%s", item);
> *toolbar[i] = {GNOMEUIINFO_ITEM_STOCK (N_("Open"),
> N_("Open"),
> file_open, GNOME_STOCK_PIXMAP_OPEN)};
Now you're dereferencing the pointer to get an actual struct to assign to,
but the pointer is garbage so it probably segfaults. You need to make the
pointer point to something. (well, if you wanted an array of pointers to
begin with you would.)
> }
>
> }
> i = i++;
> toolbar[i] = "GNOMEUIINFO_END";
>
The quotation marks are wrong.
> gnome_app_create_toolbar_with_data (GNOME_APP (app), toolbar,
> vbox);
>
Again, "toolbar" should have type GnomeUIInfo[] (basically equivalent to
GnomeUInfo*), but you've given it type GnomeUIInfo*[] (or GnomeUIInfo**).
I'd suggest looking at gnome-app-helper.h for a long time, with K&R by
your side.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]