comparison gtk3/dw.c @ 820:19a632499344

GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior. Also implemented dw_container_change_row_title() for GTK2/3.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 26 Mar 2011 12:52:35 +0000
parents c17634e2b303
children 43e6282463fa
comparison
equal deleted inserted replaced
819:2dd7638a7719 820:19a632499344
5842 { 5842 {
5843 GtkTreeView *tree = pointer; 5843 GtkTreeView *tree = pointer;
5844 5844
5845 if(GTK_IS_TREE_VIEW(tree)) 5845 if(GTK_IS_TREE_VIEW(tree))
5846 { 5846 {
5847 _dw_container_set_item(handle, NULL, column, row, data); 5847 _dw_container_set_item(handle, pointer, column, row, data);
5848 } 5848 }
5849 } 5849 }
5850 5850
5851 /* 5851 /*
5852 * Changes an existing item in specified row and column to the given data. 5852 * Changes an existing item in specified row and column to the given data.
5987 */ 5987 */
5988 void dw_container_set_column_width(HWND handle, int column, int width) 5988 void dw_container_set_column_width(HWND handle, int column, int width)
5989 { 5989 {
5990 } 5990 }
5991 5991
5992 /* Internal version for both */
5993 void _dw_container_set_row_title(HWND handle, void *pointer, int row, char *title)
5994 {
5995 GtkWidget *cont = handle;
5996 GtkListStore *store = NULL;
5997 int _locked_by_me = FALSE;
5998
5999 DW_MUTEX_LOCK;
6000 /* Make sure it is the correct tree type */
6001 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
6002 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
6003
6004 if(store)
6005 {
6006 GtkTreeIter iter;
6007
6008 if(pointer)
6009 {
6010 row += (int)g_object_get_data(G_OBJECT(cont), "_dw_insertpos");
6011 }
6012
6013 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, row))
6014 {
6015 gtk_list_store_set(store, &iter, 0, (gpointer)title, -1);
6016 }
6017 }
6018 DW_MUTEX_UNLOCK;
6019 }
6020
5992 /* 6021 /*
5993 * Sets the title of a row in the container. 6022 * Sets the title of a row in the container.
5994 * Parameters: 6023 * Parameters:
5995 * pointer: Pointer to the allocated memory in dw_container_alloc(). 6024 * pointer: Pointer to the allocated memory in dw_container_alloc().
5996 * row: Zero based row of data being set. 6025 * row: Zero based row of data being set.
5997 * title: String title of the item. 6026 * title: String title of the item.
5998 */ 6027 */
5999 void dw_container_set_row_title(void *pointer, int row, char *title) 6028 void dw_container_set_row_title(void *pointer, int row, char *title)
6000 { 6029 {
6001 GtkWidget *cont = pointer; 6030 _dw_container_set_row_title(pointer, pointer, row, title);
6002 GtkListStore *store = NULL; 6031 }
6003 int _locked_by_me = FALSE; 6032
6004 6033 /*
6005 DW_MUTEX_LOCK; 6034 * Changes the title of a row already inserted in the container.
6006 /* Make sure it is the correct tree type */ 6035 * Parameters:
6007 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) 6036 * handle: Handle to window (widget) of container.
6008 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont)); 6037 * row: Zero based row of data being set.
6009 6038 * title: String title of the item.
6010 if(store) 6039 */
6011 { 6040 void dw_container_change_row_title(HWND handle, int row, char *title)
6012 GtkTreeIter iter; 6041 {
6013 6042 _dw_container_set_row_title(handle, NULL, row, title);
6014 if(pointer)
6015 {
6016 row += (int)g_object_get_data(G_OBJECT(cont), "_dw_insertpos");
6017 }
6018
6019 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, row))
6020 {
6021 gtk_list_store_set(store, &iter, 0, (gpointer)title, -1);
6022 }
6023 }
6024 DW_MUTEX_UNLOCK;
6025 } 6043 }
6026 6044
6027 /* 6045 /*
6028 * Sets the title of a row in the container. 6046 * Sets the title of a row in the container.
6029 * Parameters: 6047 * Parameters: