[gnome-love] [Applet] Applet / Panel Interaction : Background color



Hello,

I would like to have an applet change its background color according to
the background color of its 'parent' panel. Below is a short description
of what I do based on the HelloWorld example of
http://developer.gnome.org/doc/API/panel/index.html (which BTW is a very
good start for applet programming).

The first step was to get the applet being notified that the background
of the panel had changed. That was easily done with a callback on the
panel event 'back_change': (I bind 'back_change' before I do
'applet_widget_add' as explained in the tutorial.)

----8<------
  gtk_signal_connect(GTK_OBJECT(applet),"back_change",
                     GTK_SIGNAL_FUNC(applet_back_change),
                     NULL);
---->8------

And it works: The callback function 'applet_back_change' is correctly
called. But now here is my problem: A call to
'gdk_window_set_background' within the callback has no effect. The
applet, which contains a label, remains desparately grey. I make the
call on the applet window (supposed to be the widget parameter passed to
the call back) . Below is the code of my call back (the new background
type is not checked in a first time):

----8<------
static void
applet_back_change(GtkWidget *widget, 
                   PanelBackType back_type,
                   GdkPixmap*    back_pixmap,
                   GdkColor      back_color,
                   gpointer data )
{
  g_print(_("Background was changed.\n"));
  gdk_window_set_background (  widget->window,
                               &back_color );
} // EndFunction applet_change_back
---->8------

Has anyone a clue of what I'm doing wrong. I've looked at the panel
code, and see that the place where the ButtonWidget's are drawn along
with the panel is really complicated (in function 'panel_widget_draw_all
(..)' in file 'panel-widget.c'). Am I supposed to code something similar
?

Thanks in advance

Francois

(I'm using gnome-libs 1.0.56, and gtk version 1.2.7)




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