Re: GtkList and GList......please...anybody???



On 17 Feb 2003, Syed Imranullah Azeezullah wrote:

Hello,

Read about GtkList here:
http://developer.gnome.org/doc/API/2.0/gtk/GtkList.html

You can also read about GList here:
http://developer.gnome.org/doc/API/2.0/glib/glib-Doubly-Linked-Lists.html

You might also want to know that GtkList is deprecated. There are some
very good tutorials / examples about data structures like linkedlists
around on the internet. I suggest you just glance at them.

Regards,
Imran

On Mon, 2003-02-17 at 09:03, Uni wrote:
Hi,

I'm using Anjuta an IDE for Glade and using makefiles etc...What this does it allows you to build your 
GUI (visually) using Glade and all you have to do is write the callback functions behind the objects. The 
files that are automatically generated are:

callbacks.c
callbacks.h
interface.c
interface.h
main.c
support.c
support.h

All I'm wanting to do is have a list box where strings are simply put into it...Since Anjuta creates the 
code to generate your chosen GUI it generated the following for the List object:

(in the interface.c, but only relevant code is shown)

GtkWidget*
create_window_main (void)
{
    ...
    ...

    GtkWidget *list_shopping_list;        <- As I called the item "list_shopping_list" minus quotes, from 
inside the GUI editor

    ...
    ...
    
    list_shopping_list = gtk_list_new();
    gtk_widget_ref (list_shopping_list);
    gtk_object_set_data_full (GTK_OBJECT (window_main), "list_shopping_list", list_shopping_list, 
(GtkDestroyNotify) gtk_widget_unref);
    gk_widget_show (list_shopping_list);
    gtk_box_pack_start (GTK_BOX (hbox3), list_shopping_list, TRUE, TRUE, 0);    
}


And that's it as far as anything to do with the list box is concerned. Right...That was in the 
interface.c. I have then created my own file called "list_handler.c". In "list_handler.c" (minus quotes) 
I'm wanting a function that simply adds items to this list box that was set up in the interface.c file. 
If I can get that I'd be ecstatic. Please if you could help I'd be very grateful...


Thanks for your time,
Uni

Hello,

  to add an item to the list : 

GtkWidget *item;
GList *list=NULL;

item = gtk_list_item_new_with_label("toto");
list = g_list_append (list, item);
item = gtk_list_item_new_with_label("tata");
list = g_list_append (list, item);
gtk_list_prepend_items(GTK_LIST(list_shopping_list), list);

You can use gtk_list_append_items, or gtk_list_insert_items instead of 
gtk_list_prepend_items (look at 
http://developer.gnome.org/doc/API/gtk/gtklist.html).
In addition, you can put other widgets than label in the item.

Hope this helps

Vincent TORRI


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


-- 
TORRI Vincent
Mathematiques Appliquees Bordeaux                                                
Institut de Mathematiques                                                       
Universite Bordeaux 1                                                           
351 cours de la liberation                                                      
33 405 Talence cedex - France                                                   
                                                                                
Tel : 33 (0)5 57 96 21 42                                                       
Fax : 33 (0)5 56 84 26 26                                                       
--




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