comparison gtk/dw.c @ 328:e00aff2b899e

Tree item handles are now of the type HTREEITEM instead of HWND since they were rarely actually window handles.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 08 Apr 2003 17:47:31 +0000
parents 78be9770960c
children 9b1953ed0bff
comparison
equal deleted inserted replaced
327:3204b978e077 328:e00aff2b899e
481 SignalHandler *work = (SignalHandler *)data; 481 SignalHandler *work = (SignalHandler *)data;
482 int retval = FALSE; 482 int retval = FALSE;
483 483
484 if(work) 484 if(work)
485 { 485 {
486 int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func; 486 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work->func;
487 GtkTreeIter iter; 487 GtkTreeIter iter;
488 char *text = NULL; 488 char *text = NULL;
489 void *itemdata = NULL; 489 void *itemdata = NULL;
490 GtkWidget *item, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel); 490 GtkWidget *item, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel);
491 491
492 if(widget && gtk_tree_selection_get_selected(sel, NULL, &iter)) 492 if(widget && gtk_tree_selection_get_selected(sel, NULL, &iter))
493 { 493 {
494 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store"); 494 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store");
495 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, 3, &item, -1); 495 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, 3, &item, -1);
496 retval = treeselectfunc(work->window, item, text, work->data, itemdata); 496 retval = treeselectfunc(work->window, (HTREEITEM)item, text, work->data, itemdata);
497 } 497 }
498 } 498 }
499 return retval; 499 return retval;
500 } 500 }
501 #else 501 #else
513 gtk_object_set_data(GTK_OBJECT(treeroot), "lastselect", (gpointer)child); 513 gtk_object_set_data(GTK_OBJECT(treeroot), "lastselect", (gpointer)child);
514 } 514 }
515 515
516 if(work) 516 if(work)
517 { 517 {
518 int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func; 518 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work->func;
519 char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "text"); 519 char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "text");
520 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(child), "itemdata"); 520 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(child), "itemdata");
521 retval = treeselectfunc(work->window, child, text, work->data, itemdata); 521 retval = treeselectfunc(work->window, (HTREEITEM)child, text, work->data, itemdata);
522 } 522 }
523 return retval; 523 return retval;
524 } 524 }
525 #endif 525 #endif
526 526
3612 * title: The text title of the entry. 3612 * title: The text title of the entry.
3613 * icon: Handle to coresponding icon. 3613 * icon: Handle to coresponding icon.
3614 * parent: Parent handle or 0 if root. 3614 * parent: Parent handle or 0 if root.
3615 * itemdata: Item specific data. 3615 * itemdata: Item specific data.
3616 */ 3616 */
3617 HWND dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) 3617 HTREEITEM dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HWND parent, void *itemdata)
3618 { 3618 {
3619 #if GTK_MAJOR_VERSION > 1 3619 #if GTK_MAJOR_VERSION > 1
3620 GtkWidget *tree; 3620 GtkWidget *tree;
3621 GtkTreeIter *iter; 3621 GtkTreeIter *iter;
3622 GtkTreeStore *store; 3622 GtkTreeStore *store;
3623 GdkPixbuf *pixbuf; 3623 GdkPixbuf *pixbuf;
3624 HWND retval = 0; 3624 HTREEITEM retval = 0;
3625 int _locked_by_me = FALSE; 3625 int _locked_by_me = FALSE;
3626 3626
3627 if(!handle) 3627 if(!handle)
3628 return NULL; 3628 return NULL;
3629 3629
3638 3638
3639 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item); 3639 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item);
3640 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); 3640 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
3641 if(pixbuf) 3641 if(pixbuf)
3642 g_object_unref(pixbuf); 3642 g_object_unref(pixbuf);
3643 retval = (HWND)iter; 3643 retval = (HTREEITEM)iter;
3644 } 3644 }
3645 DW_MUTEX_UNLOCK; 3645 DW_MUTEX_UNLOCK;
3646 3646
3647 return retval; 3647 return retval;
3648 #else 3648 #else
3725 } 3725 }
3726 gtk_tree_item_expand(GTK_TREE_ITEM(newitem)); 3726 gtk_tree_item_expand(GTK_TREE_ITEM(newitem));
3727 gtk_tree_item_collapse(GTK_TREE_ITEM(newitem)); 3727 gtk_tree_item_collapse(GTK_TREE_ITEM(newitem));
3728 gtk_widget_show(newitem); 3728 gtk_widget_show(newitem);
3729 DW_MUTEX_UNLOCK; 3729 DW_MUTEX_UNLOCK;
3730 return newitem; 3730 return (HTREEITEM)newitem;
3731 #endif 3731 #endif
3732 } 3732 }
3733 3733
3734 /* 3734 /*
3735 * Inserts an item into a tree window (widget). 3735 * Inserts an item into a tree window (widget).
3738 * title: The text title of the entry. 3738 * title: The text title of the entry.
3739 * icon: Handle to coresponding icon. 3739 * icon: Handle to coresponding icon.
3740 * parent: Parent handle or 0 if root. 3740 * parent: Parent handle or 0 if root.
3741 * itemdata: Item specific data. 3741 * itemdata: Item specific data.
3742 */ 3742 */
3743 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) 3743 HTREEITEM dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
3744 { 3744 {
3745 #if GTK_MAJOR_VERSION > 1 3745 #if GTK_MAJOR_VERSION > 1
3746 GtkWidget *tree; 3746 GtkWidget *tree;
3747 GtkTreeIter *iter; 3747 GtkTreeIter *iter;
3748 GtkTreeStore *store; 3748 GtkTreeStore *store;
3749 GdkPixbuf *pixbuf; 3749 GdkPixbuf *pixbuf;
3750 HWND retval = 0; 3750 HTREEITEM retval = 0;
3751 int _locked_by_me = FALSE; 3751 int _locked_by_me = FALSE;
3752 3752
3753 if(!handle) 3753 if(!handle)
3754 return NULL; 3754 return NULL;
3755 3755
3764 3764
3765 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent); 3765 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent);
3766 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); 3766 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
3767 if(pixbuf) 3767 if(pixbuf)
3768 g_object_unref(pixbuf); 3768 g_object_unref(pixbuf);
3769 retval = (HWND)iter; 3769 retval = (HTREEITEM)iter;
3770 } 3770 }
3771 DW_MUTEX_UNLOCK; 3771 DW_MUTEX_UNLOCK;
3772 3772
3773 return retval; 3773 return retval;
3774 #else 3774 #else
3844 } 3844 }
3845 gtk_tree_item_expand(GTK_TREE_ITEM(item)); 3845 gtk_tree_item_expand(GTK_TREE_ITEM(item));
3846 gtk_tree_item_collapse(GTK_TREE_ITEM(item)); 3846 gtk_tree_item_collapse(GTK_TREE_ITEM(item));
3847 gtk_widget_show(item); 3847 gtk_widget_show(item);
3848 DW_MUTEX_UNLOCK; 3848 DW_MUTEX_UNLOCK;
3849 return item; 3849 return (HTREEITEM)item;
3850 #endif 3850 #endif
3851 } 3851 }
3852 3852
3853 /* 3853 /*
3854 * Sets the text and icon of an item in a tree window (widget). 3854 * Sets the text and icon of an item in a tree window (widget).
3856 * handle: Handle to the tree containing the item. 3856 * handle: Handle to the tree containing the item.
3857 * item: Handle of the item to be modified. 3857 * item: Handle of the item to be modified.
3858 * title: The text title of the entry. 3858 * title: The text title of the entry.
3859 * icon: Handle to coresponding icon. 3859 * icon: Handle to coresponding icon.
3860 */ 3860 */
3861 void dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) 3861 void dw_tree_set(HWND handle, HTREEITEM item, char *title, unsigned long icon)
3862 { 3862 {
3863 #if GTK_MAJOR_VERSION > 1 3863 #if GTK_MAJOR_VERSION > 1
3864 GtkWidget *tree; 3864 GtkWidget *tree;
3865 GtkTreeStore *store; 3865 GtkTreeStore *store;
3866 GdkPixbuf *pixbuf; 3866 GdkPixbuf *pixbuf;
3921 * Parameters: 3921 * Parameters:
3922 * handle: Handle to the tree containing the item. 3922 * handle: Handle to the tree containing the item.
3923 * item: Handle of the item to be modified. 3923 * item: Handle of the item to be modified.
3924 * itemdata: User defined data to be associated with item. 3924 * itemdata: User defined data to be associated with item.
3925 */ 3925 */
3926 void dw_tree_set_data(HWND handle, HWND item, void *itemdata) 3926 void dw_tree_set_data(HWND handle, HTREEITEM item, void *itemdata)
3927 { 3927 {
3928 #if GTK_MAJOR_VERSION > 1 3928 #if GTK_MAJOR_VERSION > 1
3929 GtkWidget *tree; 3929 GtkWidget *tree;
3930 GtkTreeStore *store; 3930 GtkTreeStore *store;
3931 int _locked_by_me = FALSE; 3931 int _locked_by_me = FALSE;
3955 * Gets the item data of a tree item. 3955 * Gets the item data of a tree item.
3956 * Parameters: 3956 * Parameters:
3957 * handle: Handle to the tree containing the item. 3957 * handle: Handle to the tree containing the item.
3958 * item: Handle of the item to be modified. 3958 * item: Handle of the item to be modified.
3959 */ 3959 */
3960 void *dw_tree_get_data(HWND handle, HWND item) 3960 void *dw_tree_get_data(HWND handle, HTREEITEM item)
3961 { 3961 {
3962 void *ret = NULL; 3962 void *ret = NULL;
3963 #if GTK_MAJOR_VERSION > 1 3963 #if GTK_MAJOR_VERSION > 1
3964 GtkWidget *tree; 3964 GtkWidget *tree;
3965 GtkTreeModel *store; 3965 GtkTreeModel *store;
3991 * Sets this item as the active selection. 3991 * Sets this item as the active selection.
3992 * Parameters: 3992 * Parameters:
3993 * handle: Handle to the tree window (widget) to be selected. 3993 * handle: Handle to the tree window (widget) to be selected.
3994 * item: Handle to the item to be selected. 3994 * item: Handle to the item to be selected.
3995 */ 3995 */
3996 void dw_tree_item_select(HWND handle, HWND item) 3996 void dw_tree_item_select(HWND handle, HTREEITEM item)
3997 { 3997 {
3998 #if GTK_MAJOR_VERSION > 1 3998 #if GTK_MAJOR_VERSION > 1
3999 GtkWidget *tree; 3999 GtkWidget *tree;
4000 GtkTreeStore *store; 4000 GtkTreeStore *store;
4001 int _locked_by_me = FALSE; 4001 int _locked_by_me = FALSE;
4109 * Expands a node on a tree. 4109 * Expands a node on a tree.
4110 * Parameters: 4110 * Parameters:
4111 * handle: Handle to the tree window (widget). 4111 * handle: Handle to the tree window (widget).
4112 * item: Handle to node to be expanded. 4112 * item: Handle to node to be expanded.
4113 */ 4113 */
4114 void dw_tree_expand(HWND handle, HWND item) 4114 void dw_tree_expand(HWND handle, HTREEITEM item)
4115 { 4115 {
4116 #if GTK_MAJOR_VERSION > 1 4116 #if GTK_MAJOR_VERSION > 1
4117 GtkWidget *tree; 4117 GtkWidget *tree;
4118 GtkTreeStore *store; 4118 GtkTreeStore *store;
4119 int _locked_by_me = FALSE; 4119 int _locked_by_me = FALSE;
4148 * Collapses a node on a tree. 4148 * Collapses a node on a tree.
4149 * Parameters: 4149 * Parameters:
4150 * handle: Handle to the tree window (widget). 4150 * handle: Handle to the tree window (widget).
4151 * item: Handle to node to be collapsed. 4151 * item: Handle to node to be collapsed.
4152 */ 4152 */
4153 void dw_tree_collapse(HWND handle, HWND item) 4153 void dw_tree_collapse(HWND handle, HTREEITEM item)
4154 { 4154 {
4155 #if GTK_MAJOR_VERSION > 1 4155 #if GTK_MAJOR_VERSION > 1
4156 GtkWidget *tree; 4156 GtkWidget *tree;
4157 GtkTreeStore *store; 4157 GtkTreeStore *store;
4158 int _locked_by_me = FALSE; 4158 int _locked_by_me = FALSE;
4187 * Removes a node from a tree. 4187 * Removes a node from a tree.
4188 * Parameters: 4188 * Parameters:
4189 * handle: Handle to the window (widget) to be cleared. 4189 * handle: Handle to the window (widget) to be cleared.
4190 * item: Handle to node to be deleted. 4190 * item: Handle to node to be deleted.
4191 */ 4191 */
4192 void dw_tree_delete(HWND handle, HWND item) 4192 void dw_tree_delete(HWND handle, HTREEITEM item)
4193 { 4193 {
4194 #if GTK_MAJOR_VERSION > 1 4194 #if GTK_MAJOR_VERSION > 1
4195 GtkWidget *tree; 4195 GtkWidget *tree;
4196 GtkTreeStore *store; 4196 GtkTreeStore *store;
4197 int _locked_by_me = FALSE; 4197 int _locked_by_me = FALSE;