Gnome panel applet question on callbacks

Gnome panel applet question on callbacks

Post by stone » Tue, 30 Nov 1999 04:00:00



Hello, all,

I'm a hobbyist in C, and new to Gnome and GUI programming.
I wrote a small app to operate my ATAPI CDROM changer, and
now I'm trying to convert the app to a panel applet.  

In the application version, this compiles without error:

gtk_signal_connect(GTK_OBJECT (button),"clicked",
                   GTK_SIGNAL_FUNC (cdchange),
                   (gpointer) "4");

But in the applet version, this call generates "passing arg 4
from incompatible pointer type":

applet_widget_register_callback(APPLET_WIDGET(applet),
                                "Slot select 4",
                                _("Slot 4"), cdchange,
                                (gpointer) "4");

Looking for inspiration, I went and looked at ALL the applet
code in CVS, but found that folks rarely use this call, preferring
to use the "stock callbacks".  When this function is used, the
"data" is generally NULL.

Here's a snippet from the applet tutorial, about
applet_widget_register_callback:

---
void applet_widget_register_callback(AppletWidget *applet,
                                     char *name,
                                     char *menutext,
                                     AppletCallbackFunc func,
                                     gpointer data);

Inserts a menu item into the panel menu. name is used to identify
the menu item. It is also the path of the menu item, this way you
can specify which submenu the new item should go in. menutext is
simply the label of the item. func is a pointer to a void function
(it is called with two arguments: an AppletWidget* and a gpointer).
The gpointer that is passed to *func is specified in data.
---

I'm getting all fuzzy-headed thinking about this, and it's
probably something simple, but how do I change this to avoid
the compiler error?

Thanks in advance,

Stoney

 
 
 

Gnome panel applet question on callbacks

Post by NF Steve » Tue, 30 Nov 1999 04:00:00



>Hello, all,

>I'm a hobbyist in C, and new to Gnome and GUI programming.
>I wrote a small app to operate my ATAPI CDROM changer, and
>now I'm trying to convert the app to a panel applet.  

>In the application version, this compiles without error:

>gtk_signal_connect(GTK_OBJECT (button),"clicked",
>                   GTK_SIGNAL_FUNC (cdchange),
>                   (gpointer) "4");

>But in the applet version, this call generates "passing arg 4
>from incompatible pointer type":

>applet_widget_register_callback(APPLET_WIDGET(applet),
>                                "Slot select 4",
>                                _("Slot 4"), cdchange,
>                                (gpointer) "4");

Have you changed the function cdchange so that it
matches the typedef for AppletCallbackFunc which is

typedef void (*AppletCallbackFunc) (AppletWidget *, gpointer);

i.e. cdchange needs to be

void change (AppletWidget *applet, gpointer data);

Norman

 
 
 

Gnome panel applet question on callbacks

Post by stone » Tue, 30 Nov 1999 04:00:00



>But in the applet version, this call generates "passing arg 4
>from incompatible pointer type":

>applet_widget_register_callback(APPLET_WIDGET(applet),
>                                "Slot select 4",
>                                _("Slot 4"), cdchange,
>                                (gpointer) "4");

> Have you changed the function cdchange so that it
> matches the typedef for AppletCallbackFunc which is

> typedef void (*AppletCallbackFunc) (AppletWidget *, gpointer);
> i.e. cdchange needs to be

> void cdchange (AppletWidget *applet, gpointer data);
> Norman

No, I have it as

int cdchange( GtkWidget *widget, gpointer data )

but it sounds like I need to. This function is sort of a Swiss-
Army knife, with lot's of things being served that I'd have to
break out.

I found out that putting GTK_SIGNAL_FUNC in the call makes it
compile without error messages, but the applet sometimes crashes the
panel.  (And the kernal is complaining about failed
"Start Stop Unit" packet commands).

applet_widget_register_callback(APPLET_WIDGET(applet),
                                "submenu/Slot 1",
                                _("Slot 1"),
                                GTK_SIGNAL_FUNC(cdchange),
                                (gpointer) "1");

This works.

Thanks for the advice, Norman.  That's probably what's making
my applet crash.

Stoney

 
 
 

1. gnome panel loses applets

Every now an then, my gnome panel will discard an applet, and from then
on it is nearly impossible to get it back.  I can add it for the sesion,
but no mater what it's gone next time I log on.

Any cluse?  I have RH6 and the gnome from there...

thanks

--
Rob

http://homepages.ihug.co.nz/~bayliss

2. Is 65k a reasonable salary for 3-5yrs exp Unix Admin?

3. gnome panel/applet crashes render desktop unusable!

4. linux for ibm rt-6150?

5. Tooltip trouble in bubbling GNOME panel applet

6. Network IP change?

7. gnome panel applet menus and drag and drop

8. Conner DDS2 drive under Solaris 2.3

9. Gnome Panel Applets

10. gnome and panel applets

11. GNOME Panel: workspace applet gone; how to get back?

12. RH8 Gnome panel modem applet

13. Problem writing Gnome panel applet