Re: gnome applets with gtkmm



On Sun, 2006-18-06 at 01:28 +0200, Dodji Seketeli wrote:
> > Thanks for that. Yes it helped :)
> 
> Good to hear that :-)
> 
> > I got the GTK+ version working but I have no idea how to convert it to
> > GTKMM.
> Okay, cool.
> 
> [...]
> 
> okay, here is what I get after quickly changing the code:
> #include <iostream>
> #include <panel-applet.h>
> #include <gtkmm/label.h>
> 
> using namespace std ;
> using namespace Glib ;
> using namespace Gtk ;
> 
> =~=
> 
> static bool
> myexample_applet_fill (PanelApplet *applet, const gchar *iid, gpointer data)
> {
>     if (!iid) {
>         return false ;
>     }
> 
>     if (ustring (iid) != "OAFIID:ExampleApplet") {
>         cerr << "got a call for an other applet\n" ;
>         return false ;
>     }
> 
>     Label *label = manage( new Label ("Hello World"));
>     gtk_container_add (GTK_CONTAINER (applet),
>                                  GTK_WIDGET (label->gobj ()));
> 
>     gtk_widget_show_all (GTK_WIDGET (applet));
> 
>     return true;
> }
> 
> PANEL_APPLET_BONOBO_FACTORY ("OAFIID:ExampleApplet_Factory",
>                             PANEL_TYPE_APPLET,
>                             "The Hello World Applet",
>                             "0",
>                             (PanelAppletFactoryCallback) myexample_applet_fill,
>                             NULL);
> =~=
> 
> To compile it, I ran:
> g++ -o test-applet `pkg-config --libs --cflags libpanelapplet-2.0
> gtkmm-2.4` test-applet.cc
> 
> I don't know if it runs okay though :-) But you should get the idea .

Dodji, that works fine. 

However, instead of doing :
	gtk_container_add (GTK_CONTAINER (applet),
		GTK_WIDGET (label->gobj ()));

since PanelApplet is child of GtkEventBox (from gnome-panel docs) why
can't I do :

    Gtk::EventBox gtkmmApplet = static_cast<Gtk::EventBox> (*applet);
    gtkmmApplet.add (*panelLabel);

BTW, I get this error: no matching function for call to
'Gtk::EventBox::EventBox (_PanelApplet &)'


Thank,
-Gezim
#include <iostream>
#include <panel-applet.h>
#include <gtkmm/label.h>
#include <gtkmm/eventbox.h>

static bool
gPrayerTimesDashboard (PanelApplet *applet, const gchar *iid, gpointer data)
{
    if (!iid) {
        return false ;
    }

    if (Glib::ustring (iid) != "OAFIID:gPrayerTimesApplet") {
        std::cerr << "got a call for an other applet\n" ;
        return false ;
    }

    Gtk::Label *panelLabel = Gtk::manage (new Gtk::Label ("Hello World" ) );

    Gtk::EventBox gtkmmApplet = static_cast<Gtk::EventBox> (*applet);
    gtkmmApplet.add (*panelLabel);

    //gtk_container_add (GTK_CONTAINER (applet),
    //                             GTK_WIDGET (panelLabel->gobj ()));

    gtk_widget_show_all (GTK_WIDGET (applet));

    return true;
}

PANEL_APPLET_BONOBO_FACTORY ("OAFIID:gPrayerTimesApplet_Factory",
	PANEL_TYPE_APPLET, "The Prayer Times Applet",
	"0.1",
	(PanelAppletFactoryCallback) gPrayerTimesDashboard,
	NULL);


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