Oh dear,

#include <sys/utsname.h>

        struct utsname name;
        uname(&name);
        printf("%s\n", name.sysname);
        printf("%s\n", name.nodename);
        printf("%s\n", name.release);
        printf("%s\n", name.version);
        printf("%s\n", name.machine);

Thanks,

Michael


On 05/11/2007, Matteo Landi <[EMAIL PROTECTED]> wrote:
>
> On Mon, 2007-11-05 at 22:55 +1100, Michael Lamothe wrote:
> > Hi Matteo,
> >
> > I'm not following.  What box?  A GtkBox?  What "row"?
>
> they are just examples
>
> > Have you thought of using Glade to do your UI work?
>
> the fact is that i've started working with gtk two days ago because i
> was interested in make a gnome panel monitor, and in the tutorial i've
> found, i create a panel with the bonobo inititialization..
> i dont know if i can do this even with glade..
>
> Talking about the spawn, i think the problem is due to the command
> itself (uname) that at the end print a "\n"; So i gotta throw away that
> char from the string to obtaine a one line label, isn't it?
>
> M@
>
> > Thanks,
> >
> > Michael
> >
> > On 05/11/2007, Matteo Landi <[EMAIL PROTECTED]> wrote:
> > > ok ok that worked, but the output is the same as before...
> > >
> > > just try to create a box with two labels inside:
> > >
> > > one createt with label = gtk_label_new ("foo");
> > > and the other created with label = gtk_label_new (std_output);
> > >
> > > i got the foo one middle aligned and the second placed on the top of the
> > > row.. am i wrong?
> > >
> > > M@
> > >
> > > On Mon, 2007-11-05 at 22:06 +1100, Michael Lamothe wrote:
> > > > Your pseudo makes no sense, how can you pass a char * into parameter 2
> > > > of g_spawn_command_line_sync() when its a gchar**.  This worked for
> > > > me,
> > > >
> > > >
> > > >       gchar* std_output = NULL;
> > > >       g_spawn_command_line_sync("ls -al", &std_output, NULL, NULL, 
> > > > NULL);
> > > >       printf(std_output);
> > > >
> > > > Thanks,
> > > >
> > > > Michael
> > > >
> > > >
> > > > On 05/11/2007, Matteo Landi <[EMAIL PROTECTED]> wrote:
> > > > > Tnx i think that the first one is the function i'm in need of; by the
> > > > > way i cant' make it work, and my gnome panel crashs everytime i run 
> > > > > the
> > > > > applet, so i think there is some problems with memory:
> > > > > well, i've got:
> > > > > const char* data (as argoment of a function)
> > > > > char *std_out (created in the function)
> > > > >
> > > > > g_spawn_command_line_sync(data, std_out, NULL, NULL, NULL);
> > > > >
> > > > > is this call right? i think not...but why??
> > > > >
> > > > > tnx again
> > > > > M@
> > > > >
> > > > > On Mon, 2007-11-05 at 15:21 +1100, Michael Lamothe wrote:
> > > > > > Hi Matteo,
> > > > > >
> > > > > > There's a few ways to do this, two of which I'll tell you now.
> > > > > > Hopefully, you can change your application to use these functions
> > > > > > instead.
> > > > > >
> > > > > > Firstly, there's the g_spawn_ set of APIs designed for this.  I 
> > > > > > think
> > > > > > that something like g_spawn_command_line_sync() will do exactly what
> > > > > > you want.  Basically, GLib calculates and allocates the space
> > > > > > required.  The documentation mentions nothing about freeing the
> > > > > > allocated strings afterwards but I imagine you will have to free the
> > > > > > standard_output and standard_error parameters with g_free().
> > > > > >
> > > > > > Secondly, if the spawned program is meant to run asynchronously in 
> > > > > > the
> > > > > > background then you'll need to use something like
> > > > > > g_spawn_async_with_pipes().  I don't think that this is what you 
> > > > > > want
> > > > > > because you were talking about having to allocate the length of the
> > > > > > output.
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Michael
> > > > > >
> > > > > > On 05/11/2007, Matteo Landi <[EMAIL PROTECTED]> wrote:
> > > > > > > thank you very much, that solved one of my problems.
> > > > > > > here is the second:
> > > > > > > i'm using a pipe to catch the output of a specific command and 
> > > > > > > store it
> > > > > > > as a label in the panel; the problem is that if the array 
> > > > > > > containing the
> > > > > > > output is smaller than the output itself, the line is cut, and the
> > > > > > > applet is show all middle aligned; if the output is bigger, i get 
> > > > > > > the
> > > > > > > label splitted in two lines: the first one containing the entire 
> > > > > > > output,
> > > > > > > and the second one is empty.
> > > > > > > How could i solve this? maybe with dynamic allocation of memory, 
> > > > > > > but in
> > > > > > > order to know the output width size, i gotta insert a while that
> > > > > > > overload the applet isn't it?
> > > > > > > tnx in advance for the help
> > > > > > >
> > > > > > > M@
> > > > > > >
> > > > > > >
> > > > > > > On Sun, 2007-11-04 at 13:33 +1100, Michael Lamothe wrote:
> > > > > > > > Hi Matteo,
> > > > > > > >
> > > > > > > > Look at g_timeout_add() or the new gdk_threads_add_timeout().
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > >
> > > > > > > > Michael
> > > > > > > >
> > > > > > > >
> > > > > > > > On 04/11/2007, Matteo Landi <[EMAIL PROTECTED]> wrote:
> > > > > > > > > hi all
> > > > > > > > > i'm a complete newbie in developing with gtk, but yesterday i 
> > > > > > > > > had an
> > > > > > > > > idea about develope a gnome panel which could substitute 
> > > > > > > > > conky..
> > > > > > > > > In fact i'm in need of a panel that simply display the output 
> > > > > > > > > of a bash
> > > > > > > > > script..
> > > > > > > > > well, after have googled a bit, i found a guide for 
> > > > > > > > > implementing gnome
> > > > > > > > > applet and here is the result
> > > > > > > > >
> > > > > > > > > #include <string.h>
> > > > > > > > > #include <panel-applet.h>
> > > > > > > > > #include <gtk/gtklabel.h>
> > > > > > > > > #include <stdio.h>
> > > > > > > > >
> > > > > > > > > static gboolean on_button_press (GtkWidget *event_box, 
> > > > > > > > > GdkEventButton
> > > > > > > > > *event, GtkWidget* label){
> > > > > > > > >         if (event->button != 1)
> > > > > > > > >                 return FALSE;
> > > > > > > > >         else {
> > > > > > > > >                 FILE* fp;
> > > > > > > > >                 char line[160];
> > > > > > > > >                 fp = popen("~/scripts/allin1", "r");
> > > > > > > > >                 fgets( line, sizeof line, fp);
> > > > > > > > >                 pclose(fp);
> > > > > > > > >                 gtk_label_set_text (label,(const char*) line);
> > > > > > > > >         }
> > > > > > > > >         return TRUE;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > static gboolean my_applet_fill (PanelApplet *applet, const 
> > > > > > > > > gchar *iid,
> > > > > > > > > gpointer data){
> > > > > > > > >         FILE* fp;
> > > > > > > > >         int pid;
> > > > > > > > >         char line[160];
> > > > > > > > >         GtkWidget *label;
> > > > > > > > >
> > > > > > > > >         fp = popen("~/scripts/allin1", "r");
> > > > > > > > >         fgets( line, sizeof line, fp);
> > > > > > > > >         pclose(fp);
> > > > > > > > >
> > > > > > > > >         label = gtk_label_new (line);
> > > > > > > > >         gtk_container_add (GTK_CONTAINER (applet), label);
> > > > > > > > >
> > > > > > > > >         g_signal_connect (G_OBJECT(applet), 
> > > > > > > > > "button_press_event", G_CALLBACK
> > > > > > > > > (on_button_press), label);
> > > > > > > > >
> > > > > > > > >         gtk_widget_show_all (GTK_WIDGET (applet));
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >         return TRUE;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > PANEL_APPLET_BONOBO_FACTORY ("OAFIID:my_applet_Factory",
> > > > > > > > > PANEL_TYPE_APPLET, "Conky Porting", "0", my_applet_fill, 
> > > > > > > > > NULL);
> > > > > > > > >
> > > > > > > > > what i'm asking for is how could i refresh the label of the 
> > > > > > > > > applet after
> > > > > > > > > a fixed period of time... (now the applets refresh when 
> > > > > > > > > mouse-clicked)
> > > > > > > > > tnx in advance
> > > > > > > > >
> > > > > > > > > M@
> > > > > > > > >
> > > > > > > > > _______________________________________________
> > > > > > > > > gtk-list mailing list
> > > > > > > > > [EMAIL PROTECTED]
> > > > > > > > > http://mail.gnome.org/mailman/listinfo/gtk-list
> > > > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > > > >
> > >
> > >
>
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to