[gtk-server] Re: Calendar Widget

  • From: "Bill Christiansen" <bill.christiansen@xxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Mon, 9 Apr 2007 08:25:49 +1200

Thanks Peter,
I'm really just starting to learn linux programming so I have a lot to
learn. I did have a play around with the prototype in the
gtk-server.cfgbefore reading your post. I was a bit confused whether
parameters reqired
by the function were the ones it used or the ones it returned (or both). I
noticed in some configurations the function would return an "ok" instead of
the "-1" and if I got it too wrong it would crash (not surprisingly).

I did try the same project with another program called Gins that's being
worked on by one of the Puppy Linux developers:

With Gins I could recieve data from the calendar widget but ran into a
similar problem with pointers when it came to using the textview widget. I
notice Gins uses the gdk_button_release signal instead of the calendars
day_selected event but not sure if that would make a difference. It also
only works using stdin and returns line data which can be read by BASH's
read function.

I will experiment a bit more and possibly look at a different scripting


On 4/8/07, Peter van Eerten <administrator@xxxxxxxxxxxxxx> wrote:

Hi there,

The reason for the '-1' returnvalue is, that you need to add the
prototype of the call 'gtk_calender_get_date' to the configfile of the

I would define it as follows:

FUNCTION_NAME = gtk_calender_get_date, NONE, NONE, 4, WIDGET, LONG, LONG,

However, the last three arguments are in fact pointers to memory, as
you also mention yourself. With BASH I do not see how the memory
pointed to can be read. There are some interpreted languages though,
which can 'read' memory assigned by C-pointers, like Perl, or newLisp.

In most situations, when a signal occurs on the widget, it is possible
to read the data which was sent with the signal. But with the calender
widget also no additional data is sent.

For BASH, as workaround you could write a small C program and compile
it as a binary. When this binary is invoked within a BASH script, it
reads the argument which in fact is the pointer to the address, and it
returns the value kept in this address. But this is probably not what
you want.


Quoting Bill Christiansen < bill.christiansen@xxxxxxxxx>:

> Hi,
> I'm not a very experienced programmer but just giving the Gtk-server,
> Glade combination a try.
> The GUI I made in Glade has a calendar widget and I can retrieve it's
> ID and access it's day_clicked event:
> # Get calendar widget ID and connect signal
> gtk "gtk_server_glade_widget calendar1"
> calendar1_ID=$RESULT
> gtk "gtk_server_connect $calendar1_ID day-selected calendar_clicked"
> But when I try to use get_date I am getting "-1" returned:
> # Initialize EVENT variable
> # Mainloop
> while [[ $EVENT != "main_window" && $EVENT != "button_exit" ]]
> do
>    gtk "gtk_server_callback WAIT"
>    if [[ $EVENT = "calendar_clicked" ]]
>    then
>        gtk "gtk_calendar_get_date $calendar1_ID"
>        text="'$RESULT'"
>        echo $text  # this is printing "-1" on console
>    fi
> done
> It may be that I need to process the $RESULT more as the GTK docs say it
> returns a tuplet of three integers for year month day, but may BASH
> is also limited at this stage, or is it because the calendar widget
needs to
> be setup in the gtk-server.cfg to be usable. Anyone else have experience
> with this widget?
> Regards
> Bill


Other related posts: