comparison gtk3/dw.c @ 778:99ce0ea1f271

Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 20 Mar 2011 18:27:59 +0000
parents c0e7200dad31
children d67d2f626c33
comparison
equal deleted inserted replaced
777:c0e7200dad31 778:99ce0ea1f271
3565 return 0; 3565 return 0;
3566 } 3566 }
3567 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", (gpointer)_DW_TREE_TYPE_CONTAINER); 3567 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", (gpointer)_DW_TREE_TYPE_CONTAINER);
3568 g_object_set_data(G_OBJECT(tmp), "_dw_multi_sel", GINT_TO_POINTER(multi)); 3568 g_object_set_data(G_OBJECT(tmp), "_dw_multi_sel", GINT_TO_POINTER(multi));
3569 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3569 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
3570 gtk_widget_show(tmp);
3571 DW_MUTEX_UNLOCK; 3570 DW_MUTEX_UNLOCK;
3572 return tmp; 3571 return tmp;
3573 } 3572 }
3574 3573
3575 /* 3574 /*
4096 } 4095 }
4097 else 4096 else
4098 { 4097 {
4099 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); 4098 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
4100 } 4099 }
4101 gtk_widget_show(tmp); 4100 gtk_widget_show(tree);
4102 DW_MUTEX_UNLOCK; 4101 DW_MUTEX_UNLOCK;
4103 return tmp; 4102 return tmp;
4104 } 4103 }
4105 4104
4106 /* 4105 /*
5451 } 5450 }
5452 else 5451 else
5453 { 5452 {
5454 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); 5453 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
5455 } 5454 }
5456 gtk_widget_show(handle); 5455 gtk_widget_show(tree);
5457 free(array); 5456 free(array);
5458 DW_MUTEX_UNLOCK; 5457 DW_MUTEX_UNLOCK;
5459 return TRUE; 5458 return TRUE;
5460 } 5459 }
5461 5460
8218 * handle: Handle to the listbox to be appended to. 8217 * handle: Handle to the listbox to be appended to.
8219 * text: Text to append into listbox. 8218 * text: Text to append into listbox.
8220 */ 8219 */
8221 void dw_listbox_append(HWND handle, char *text) 8220 void dw_listbox_append(HWND handle, char *text)
8222 { 8221 {
8222 dw_listbox_insert(handle, text, -1);
8223 }
8224
8225 /*
8226 * Inserts the specified text int the listbox's (or combobox) entry list at the
8227 * position indicated.
8228 * Parameters:
8229 * handle: Handle to the listbox to be appended to.
8230 * text: Text to insert into listbox.
8231 * pos: 0-based index into listbox. -1 will append
8232 */
8233 void dw_listbox_insert(HWND handle, char *text, int pos)
8234 {
8223 GtkWidget *handle2 = handle; 8235 GtkWidget *handle2 = handle;
8224 int _locked_by_me = FALSE; 8236 GtkListStore *store = NULL;
8225 8237 int _locked_by_me = FALSE;
8226 DW_MUTEX_LOCK; 8238
8239 DW_MUTEX_LOCK;
8240 /* Get the inner handle for scrolled controls */
8227 if(GTK_IS_SCROLLED_WINDOW(handle)) 8241 if(GTK_IS_SCROLLED_WINDOW(handle))
8228 { 8242 {
8229 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 8243 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8230 if(tmp) 8244 if(tmp)
8231 handle2 = tmp; 8245 handle2 = tmp;
8232 } 8246 }
8233 #if 0
8234 g_object_set_data(G_OBJECT(handle), "_dw_appending", GINT_TO_POINTER(1));
8235 if(GTK_IS_LIST(handle2))
8236 {
8237 GtkWidget *list_item;
8238 GList *tmp;
8239 char *font = (char *)g_object_get_data(G_OBJECT(handle), "_dw_font");
8240 GdkColor *fore = (GdkColor *)g_object_get_data(G_OBJECT(handle2), "_dw_foregdk");
8241 GdkColor *back = (GdkColor *)g_object_get_data(G_OBJECT(handle2), "_dw_backgdk");
8242
8243 list_item=gtk_list_item_new_with_label(text);
8244
8245 if(font)
8246 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
8247 if(fore && back)
8248 _set_color(GTK_LIST_ITEM(list_item)->item.bin.child,
8249 DW_RGB(fore->red, fore->green, fore->blue),
8250 DW_RGB(back->red, back->green, back->blue));
8251
8252 tmp = g_list_append(NULL, list_item);
8253 gtk_widget_show(list_item);
8254 gtk_list_append_items(GTK_LIST(handle2),tmp);
8255 }
8256 else if(GTK_IS_COMBO_BOX(handle2))
8257 {
8258 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
8259 char *addtext = strdup(text);
8260
8261 if(addtext)
8262 {
8263 char *defstr = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO_BOX(handle2)->entry));
8264 tmp = g_list_append(tmp, addtext);
8265 g_object_set_data(G_OBJECT(handle2), "_dw_user", tmp);
8266 gtk_combo_set_popdown_strings(GTK_COMBO_BOX(handle2), tmp);
8267 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO_BOX(handle2)->entry), defstr);
8268 }
8269 }
8270 g_object_set_data(G_OBJECT(handle), "_dw_appending", NULL);
8271 #endif
8272 DW_MUTEX_UNLOCK;
8273 }
8274
8275 /*
8276 * Inserts the specified text int the listbox's (or combobox) entry list at the
8277 * position indicated.
8278 * Parameters:
8279 * handle: Handle to the listbox to be appended to.
8280 * text: Text to insert into listbox.
8281 * pos: 0-based index into listbox. -1 will append
8282 */
8283 void dw_listbox_insert(HWND handle, char *text, int pos)
8284 {
8285 GtkWidget *handle2 = handle;
8286 GtkTreeIter *iter;
8287 GtkListStore *store = NULL;
8288 int _locked_by_me = FALSE;
8289
8290 DW_MUTEX_LOCK;
8291 /* Get the inner handle for scrolled controls */
8292 if(GTK_IS_SCROLLED_WINDOW(handle))
8293 {
8294 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8295 if(tmp)
8296 handle2 = tmp;
8297 }
8298 if(handle2) 8247 if(handle2)
8299 { 8248 {
8300 /* Make sure it is the correct tree type */ 8249 GtkTreeIter iter;
8301 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX)
8302 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
8303 else if(GTK_IS_COMBO_BOX(handle2))
8304 store = (GtkTreeStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
8305
8306 if(!store)
8307 {
8308 DW_MUTEX_UNLOCK;
8309 return;
8310 }
8311
8312 /* Insert an entry at the end */
8313 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
8314
8315 gtk_list_store_append(store, iter);
8316 gtk_list_store_set (store, iter, 0, text, -1);
8317 }
8318 DW_MUTEX_UNLOCK;
8319 }
8320
8321 /*
8322 * Appends the specified text items to the listbox's (or combobox) entry list.
8323 * Parameters:
8324 * handle: Handle to the listbox to be appended to.
8325 * text: Text strings to append into listbox.
8326 * count: Number of text strings to append
8327 */
8328 void dw_listbox_list_append(HWND handle, char **text, int count)
8329 {
8330 GtkWidget *handle2 = handle;
8331 GtkTreeIter *iter;
8332 GtkListStore *store = NULL;
8333 int _locked_by_me = FALSE;
8334
8335 DW_MUTEX_LOCK;
8336 /* Get the inner handle for scrolled controls */
8337 if(GTK_IS_SCROLLED_WINDOW(handle))
8338 {
8339 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8340 if(tmp)
8341 handle2 = tmp;
8342 }
8343 if(handle2)
8344 {
8345 int z;
8346 8250
8347 /* Make sure it is the correct tree type */ 8251 /* Make sure it is the correct tree type */
8348 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX) 8252 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX)
8349 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2)); 8253 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
8350 else if(GTK_IS_COMBO_BOX(handle2)) 8254 else if(GTK_IS_COMBO_BOX(handle2))
8354 { 8258 {
8355 DW_MUTEX_UNLOCK; 8259 DW_MUTEX_UNLOCK;
8356 return; 8260 return;
8357 } 8261 }
8358 8262
8359 /* Insert entries at the end */ 8263 if(pos < 0)
8360 for(z=0;z<count;z++) 8264 {
8361 { 8265 /* Insert an entry at the end */
8362 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); 8266 gtk_list_store_append(store, &iter);
8363 8267 }
8364 gtk_list_store_append(store, iter); 8268 else
8365 gtk_list_store_set (store, iter, 0, text[z], -1); 8269 {
8366 } 8270 /* Insert at position */
8367 } 8271 gtk_list_store_insert(store, &iter, pos);
8368 DW_MUTEX_UNLOCK; 8272 }
8369 } 8273 gtk_list_store_set (store, &iter, 0, text, -1);
8370 8274 }
8371 /* 8275 DW_MUTEX_UNLOCK;
8372 * Clears the listbox's (or combobox) list of all entries. 8276 }
8373 * Parameters: 8277
8374 * handle: Handle to the listbox to be cleared. 8278 /*
8375 */ 8279 * Appends the specified text items to the listbox's (or combobox) entry list.
8376 void dw_listbox_clear(HWND handle) 8280 * Parameters:
8281 * handle: Handle to the listbox to be appended to.
8282 * text: Text strings to append into listbox.
8283 * count: Number of text strings to append
8284 */
8285 void dw_listbox_list_append(HWND handle, char **text, int count)
8377 { 8286 {
8378 GtkWidget *handle2 = handle; 8287 GtkWidget *handle2 = handle;
8379 int _locked_by_me = FALSE; 8288 GtkListStore *store = NULL;
8380 8289 int _locked_by_me = FALSE;
8381 DW_MUTEX_LOCK; 8290
8291 DW_MUTEX_LOCK;
8292 /* Get the inner handle for scrolled controls */
8382 if(GTK_IS_SCROLLED_WINDOW(handle)) 8293 if(GTK_IS_SCROLLED_WINDOW(handle))
8383 { 8294 {
8384 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 8295 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8385 if(tmp) 8296 if(tmp)
8386 handle2 = tmp; 8297 handle2 = tmp;
8387 } 8298 }
8388 #if 0 8299 if(handle2)
8389 if(GTK_IS_COMBO_BOX(handle2)) 8300 {
8390 { 8301 int z;
8391 GList *list, *tmp = (GList *)g_object_get_data(G_OBJECT(handle2)); 8302 GtkTreeIter iter;
8392 8303
8393 if(tmp) 8304 /* Make sure it is the correct tree type */
8394 { 8305 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX)
8395 list = tmp; 8306 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
8396 while(list) 8307 else if(GTK_IS_COMBO_BOX(handle2))
8397 { 8308 store = (GtkTreeStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
8398 if(list->data) 8309
8399 free(list->data); 8310 if(!store)
8400 list=list->next; 8311 {
8401 } 8312 DW_MUTEX_UNLOCK;
8402 g_list_free(tmp); 8313 return;
8403 } 8314 }
8404 g_object_set_data(G_OBJECT(handle2), "_dw_user", NULL); 8315
8405 } 8316 /* Insert entries at the end */
8406 else if(GTK_IS_LIST(handle2)) 8317 for(z=0;z<count;z++)
8407 { 8318 {
8408 int count = dw_listbox_count(handle); 8319 gtk_list_store_append(store, &iter);
8409 8320 gtk_list_store_set (store, &iter, 0, text[z], -1);
8410 gtk_list_clear_items(GTK_LIST(handle2), 0, count); 8321 }
8411 } 8322 }
8412 #endif 8323 DW_MUTEX_UNLOCK;
8413 DW_MUTEX_UNLOCK; 8324 }
8414 } 8325
8415 8326 /*
8416 /* 8327 * Clears the listbox's (or combobox) list of all entries.
8417 * Returns the listbox's item count. 8328 * Parameters:
8418 * Parameters: 8329 * handle: Handle to the listbox to be cleared.
8419 * handle: Handle to the listbox to be counted 8330 */
8420 */ 8331 void dw_listbox_clear(HWND handle)
8421 int dw_listbox_count(HWND handle)
8422 { 8332 {
8423 GtkWidget *handle2 = handle; 8333 GtkWidget *handle2 = handle;
8424 int retval = 0; 8334 GtkListStore *store = NULL;
8425 int _locked_by_me = FALSE; 8335 int _locked_by_me = FALSE;
8426 8336
8427 DW_MUTEX_LOCK; 8337 DW_MUTEX_LOCK;
8338 /* Get the inner handle for scrolled controls */
8428 if(GTK_IS_SCROLLED_WINDOW(handle)) 8339 if(GTK_IS_SCROLLED_WINDOW(handle))
8429 { 8340 {
8430 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 8341 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8431 if(tmp) 8342 if(tmp)
8432 handle2 = tmp; 8343 handle2 = tmp;
8433 } 8344 }
8434 #if 0 8345 if(handle2)
8435 else if(GTK_IS_COMBO_BOX(handle)) 8346 {
8436 { 8347 /* Make sure it is the correct tree type */
8437 handle2 = GTK_COMBO_BOX(handle)->list; 8348 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX)
8438 } 8349 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
8439 if(GTK_IS_LIST(handle2)) 8350 else if(GTK_IS_COMBO_BOX(handle2))
8440 { 8351 store = (GtkTreeStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
8441 GList *list = GTK_LIST(handle2)->children; 8352
8442 while(list) 8353 if(!store)
8443 { 8354 {
8444 list = list->next; 8355 DW_MUTEX_UNLOCK;
8445 retval++; 8356 return;
8446 } 8357 }
8447 } 8358 /* Clear the list */
8448 #endif 8359 gtk_list_store_clear(store);
8360 }
8361 DW_MUTEX_UNLOCK;
8362 }
8363
8364 /*
8365 * Returns the listbox's item count.
8366 * Parameters:
8367 * handle: Handle to the listbox to be counted
8368 */
8369 int dw_listbox_count(HWND handle)
8370 {
8371 GtkWidget *handle2 = handle;
8372 GtkListStore *store = NULL;
8373 int _locked_by_me = FALSE;
8374 int retval = 0;
8375
8376 DW_MUTEX_LOCK;
8377 /* Get the inner handle for scrolled controls */
8378 if(GTK_IS_SCROLLED_WINDOW(handle))
8379 {
8380 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8381 if(tmp)
8382 handle2 = tmp;
8383 }
8384 if(handle2)
8385 {
8386 /* Make sure it is the correct tree type */
8387 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX)
8388 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
8389 else if(GTK_IS_COMBO_BOX(handle2))
8390 store = (GtkTreeStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
8391
8392 if(store)
8393 {
8394 /* Get the number of children at the top level */
8395 retval = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
8396 }
8397 }
8449 DW_MUTEX_UNLOCK; 8398 DW_MUTEX_UNLOCK;
8450 return retval; 8399 return retval;
8451 } 8400 }
8452 8401
8453 /* 8402 /*
8497 * length: Length of the buffer (including NULL). 8446 * length: Length of the buffer (including NULL).
8498 */ 8447 */
8499 void dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) 8448 void dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
8500 { 8449 {
8501 GtkWidget *handle2 = handle; 8450 GtkWidget *handle2 = handle;
8502 int _locked_by_me = FALSE; 8451 GtkListStore *store = NULL;
8503 8452 int _locked_by_me = FALSE;
8504 DW_MUTEX_LOCK; 8453
8454 DW_MUTEX_LOCK;
8455 /* Get the inner handle for scrolled controls */
8505 if(GTK_IS_SCROLLED_WINDOW(handle)) 8456 if(GTK_IS_SCROLLED_WINDOW(handle))
8506 { 8457 {
8507 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 8458 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8508 if(tmp) 8459 if(tmp)
8509 handle2 = tmp; 8460 handle2 = tmp;
8510 } 8461 }
8511 #if 0 8462 if(handle2)
8512 else if(GTK_IS_COMBO_BOX(handle)) 8463 {
8513 { 8464 /* Make sure it is the correct tree type */
8514 handle2 = GTK_COMBO_BOX(handle)->list; 8465 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX)
8515 } 8466 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
8516 if(GTK_IS_LIST(handle2)) 8467 else if(GTK_IS_COMBO_BOX(handle2))
8517 { 8468 store = (GtkTreeStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
8518 int counter = 0; 8469
8519 GList *list = GTK_LIST(handle2)->children; 8470 if(store)
8520 8471 {
8521 while(list) 8472 GtkTreePath *path = gtk_tree_path_new_from_indices(index);
8522 { 8473 GtkTreeIter iter;
8523 if(counter == index) 8474 GValue value;
8524 { 8475 char *out;
8525 gchar *text = ""; 8476
8526 8477 /* Get the number of children at the top level */
8527 if(GTK_IS_LIST_ITEM(list->data)) 8478 gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path);
8528 { 8479 gtk_tree_model_get_value(GTK_TREE_MODEL(store), &iter, 0, &value);
8529 GtkListItem *li = GTK_LIST_ITEM(list->data); 8480 out = g_value_get_string(&value);
8530 8481 strncpy(buffer, out, length);
8531 if(GTK_IS_ITEM(&(li->item))) 8482 g_object_unref(G_OBJECT(path));
8532 { 8483 }
8533 GtkItem *i = &(li->item); 8484 }
8534
8535 if(GTK_IS_BIN(&(i->bin)))
8536 {
8537 GtkBin *b = &(i->bin);
8538
8539 if(GTK_IS_LABEL(b->child))
8540 gtk_label_get(GTK_LABEL(b->child), &text);
8541 }
8542 }
8543 }
8544 else if(GTK_IS_COMBO_BOX(handle) && list->data)
8545 text = (gchar *)list->data;
8546
8547 strncpy(buffer, (char *)text, length);
8548 break;
8549 }
8550 list = list->next;
8551 counter++;
8552 }
8553 }
8554 #endif
8555 DW_MUTEX_UNLOCK; 8485 DW_MUTEX_UNLOCK;
8556 } 8486 }
8557 8487
8558 /* 8488 /*
8559 * Sets the text of a given listbox entry. 8489 * Sets the text of a given listbox entry.
8563 * buffer: Buffer where text will be copied. 8493 * buffer: Buffer where text will be copied.
8564 */ 8494 */
8565 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) 8495 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
8566 { 8496 {
8567 GtkWidget *handle2 = handle; 8497 GtkWidget *handle2 = handle;
8568 int _locked_by_me = FALSE; 8498 GtkListStore *store = NULL;
8569 8499 int _locked_by_me = FALSE;
8570 DW_MUTEX_LOCK; 8500
8501 DW_MUTEX_LOCK;
8502 /* Get the inner handle for scrolled controls */
8571 if(GTK_IS_SCROLLED_WINDOW(handle)) 8503 if(GTK_IS_SCROLLED_WINDOW(handle))
8572 { 8504 {
8573 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 8505 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8574 if(tmp) 8506 if(tmp)
8575 handle2 = tmp; 8507 handle2 = tmp;
8576 } 8508 }
8577 #if 0 8509 if(handle2)
8578 else if(GTK_IS_COMBO_BOX(handle)) 8510 {
8579 { 8511 /* Make sure it is the correct tree type */
8580 handle2 = GTK_COMBO_BOX(handle)->list; 8512 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX)
8581 } 8513 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
8582 if(GTK_IS_LIST(handle2)) 8514 else if(GTK_IS_COMBO_BOX(handle2))
8583 { 8515 store = (GtkTreeStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
8584 int counter = 0; 8516
8585 GList *list = GTK_LIST(handle2)->children; 8517 if(store)
8586 8518 {
8587 while(list) 8519 GtkTreePath *path = gtk_tree_path_new_from_indices(index);
8588 { 8520 GtkTreeIter iter;
8589 if(counter == index) 8521 GValue value;
8590 { 8522 char *out;
8591 8523
8592 if(GTK_IS_LIST_ITEM(list->data)) 8524 /* Get the number of children at the top level */
8593 { 8525 gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path);
8594 GtkListItem *li = GTK_LIST_ITEM(list->data); 8526 gtk_list_store_set(store, &iter, buffer);
8595 8527 g_object_unref(G_OBJECT(path));
8596 if(GTK_IS_ITEM(&(li->item))) 8528 }
8597 { 8529 }
8598 GtkItem *i = &(li->item);
8599
8600 if(GTK_IS_BIN(&(i->bin)))
8601 {
8602 GtkBin *b = &(i->bin);
8603
8604 if(GTK_IS_LABEL(b->child))
8605 gtk_label_set_text(GTK_LABEL(b->child), buffer);
8606 }
8607 }
8608 }
8609 else if(GTK_IS_COMBO_BOX(handle))
8610 {
8611 if(list->data)
8612 g_free(list->data);
8613 list->data = g_strdup(buffer);
8614 }
8615 break;
8616 }
8617 list = list->next;
8618 counter++;
8619 }
8620 }
8621 #endif
8622 DW_MUTEX_UNLOCK; 8530 DW_MUTEX_UNLOCK;
8623 } 8531 }
8624 8532
8625 /* 8533 /*
8626 * Returns the index to the current selected item or -1 when done. 8534 * Returns the index to the current selected item or -1 when done.
8760 * index: Item index. 8668 * index: Item index.
8761 */ 8669 */
8762 void dw_listbox_delete(HWND handle, int index) 8670 void dw_listbox_delete(HWND handle, int index)
8763 { 8671 {
8764 GtkWidget *handle2 = handle; 8672 GtkWidget *handle2 = handle;
8765 int _locked_by_me = FALSE; 8673 GtkListStore *store = NULL;
8766 8674 int _locked_by_me = FALSE;
8767 DW_MUTEX_LOCK; 8675
8676 DW_MUTEX_LOCK;
8677 /* Get the inner handle for scrolled controls */
8768 if(GTK_IS_SCROLLED_WINDOW(handle)) 8678 if(GTK_IS_SCROLLED_WINDOW(handle))
8769 { 8679 {
8770 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 8680 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
8771 if(tmp) 8681 if(tmp)
8772 handle2 = tmp; 8682 handle2 = tmp;
8773 } 8683 }
8774 #if 0 8684 if(handle2)
8775 else if(GTK_IS_COMBO_BOX(handle)) 8685 {
8776 { 8686 /* Make sure it is the correct tree type */
8777 handle2 = GTK_COMBO_BOX(handle)->list; 8687 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == _DW_TREE_TYPE_LISTBOX)
8778 } 8688 store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
8779 if(GTK_IS_LIST(handle2)) 8689 else if(GTK_IS_COMBO_BOX(handle2))
8780 { 8690 store = (GtkTreeStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
8781 gtk_list_clear_items(GTK_LIST(handle2), index, index+1); 8691
8782 } 8692 if(store)
8783 #endif 8693 {
8694 GtkTreePath *path = gtk_tree_path_new_from_indices(index);
8695 GtkTreeIter iter;
8696 GValue value;
8697 char *out;
8698
8699 /* Get the number of children at the top level */
8700 gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path);
8701 gtk_list_store_remove(store, &iter);
8702 g_object_unref(G_OBJECT(path));
8703 }
8704 }
8784 DW_MUTEX_UNLOCK; 8705 DW_MUTEX_UNLOCK;
8785 } 8706 }
8786 8707
8787 /* Reposition the bar according to the percentage */ 8708 /* Reposition the bar according to the percentage */
8788 static gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data) 8709 static gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data)