Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 13/08/2007, à 13:52

obiwankennedy

Applet gnome au comportement violent.

Voila j'ai codé mon premier applet gnome.
le but de cet applet est d'afficher une ligne d'un fichier texte dans la barre de menu. Le fichier contient 179 lignes. En gros, je veux que le 1er jour la premier ligne soit visible, le 179eme jours la 179eme ligne et le 180eme jours la 1ers lignes.

le problème réside dans le fait que lorsque j'ajoute l'applet à la barre de Gnome, les barres de menu disparaissent. (là est le comportement violent).

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <panel-applet.h>
#include <gtk/gtk.h>
#include <glib.h>



static gboolean
myexample_applet_fill (PanelApplet *applet,
   const gchar *iid,
   gpointer data)
{
        GtkWidget *label;
        GtkWidget *label1;
        GtkWidget *label2;
        GtkWidget *label3;
        GtkWidget *boite;
        GIOChannel* from;
        gsize *length;
        gsize *terminator_pos;
 gchar* str_return;


        if (strcmp (iid, "OAFIID:ExampleApplet") != 0)
                return FALSE;

         str_return = malloc(sizeof(gchar)*100);

        boite = gtk_hbox_new(FALSE, 2);

        from= g_io_channel_new_file("/home/obiwan/applet/data","r",NULL);
        g_io_channel_read_line(from,&str_return,length,terminator_pos,NULL);



        label = gtk_label_new (str_return);
        label1 = gtk_label_new("sp");
        label2 = gtk_label_new ("PP");
        label3 = gtk_label_new ("Tr");

        gtk_box_pack_start(GTK_BOX(boite), label, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(boite), label1, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(boite), label2, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(boite), label3, FALSE, FALSE, 0);

        struct tm *dtemps;
        time_t heure;

        time(&heure);
        dtemps = localtime(&heure);

        printf("%d",dtemps->tm_yday);

        gtk_container_add (GTK_CONTAINER (applet), boite);

        gtk_widget_show_all (GTK_WIDGET (applet));

        return TRUE;
}

PANEL_APPLET_BONOBO_FACTORY ("OAFIID:ExampleApplet_Factory",
                             PANEL_TYPE_APPLET,
                             "The Hello World Applet",
                             "0",
                             myexample_applet_fill,
                             NULL);

le .serveur

<oaf_info>
<oaf_server iid="OAFIID:ExampleApplet_Factory" type="exe"
            location="/usr/lib/gnome-applets/myexample">

        <oaf_attribute name="repo_ids" type="stringv">
                <item value="IDL:Bonobo/GenericFactory:1.0"/>
                <item value="IDL:Bonobo/Unknown:1.0"/>
        </oaf_attribute>
        <oaf_attribute name="name" type="string" value="Example Applet Factory"/>
        <oaf_attribute name="description" type="string" value="Factory to create the example applet"/>
</oaf_server>

<oaf_server iid="OAFIID:ExampleApplet" type="factory"
            location="OAFIID:ExampleApplet_Factory">

        <oaf_attribute name="repo_ids" type="stringv">
                <item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
                <item value="IDL:Bonobo/Control:1.0"/>
                <item value="IDL:Bonobo/Unknown:1.0"/>
        </oaf_attribute>
        <oaf_attribute name="name" type="string" value="Example Applet"/>
        <oaf_attribute name="description" type="string" value="An example applet"/>
        <oaf_attribute name="panel:category" type="string" value="Amusements"/>
        <oaf_attribute name="panel:icon" type="string" value="myicon.png"/>
</oaf_server>
</oaf_info>

Dans mes logiciels, j'écris ton nom.
SGNGD: SvgGd is Not GD
Rolisteam

Hors ligne