comparison gtk3/dw.c @ 1742:cebf830e3da7

Minor GTK3 code cleanups from attempt at fixing combobox event order.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 03 Jun 2012 19:09:41 +0000
parents fae374a0055b
children 535e8c19a13d
comparison
equal deleted inserted replaced
1741:1b3b059a74b1 1742:cebf830e3da7
1327 } 1327 }
1328 1328
1329 static gint _combobox_select_event(GtkWidget *widget, gpointer data) 1329 static gint _combobox_select_event(GtkWidget *widget, gpointer data)
1330 { 1330 {
1331 SignalHandler work = _get_signal_handler(widget, data); 1331 SignalHandler work = _get_signal_handler(widget, data);
1332 static int _dw_recursing = 0;
1333 int retval = FALSE; 1332 int retval = FALSE;
1334 1333
1335 if(_dw_recursing) 1334 if(g_object_get_data(G_OBJECT(widget), "_dw_recursing"))
1336 return FALSE; 1335 return FALSE;
1337 1336
1338 if(work.window && GTK_IS_COMBO_BOX(widget)) 1337 if(work.window && GTK_IS_COMBO_BOX(widget))
1339 { 1338 {
1340 GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); 1339 GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
1342 if(store) 1341 if(store)
1343 { 1342 {
1344 GtkTreeIter iter; 1343 GtkTreeIter iter;
1345 GtkTreePath *path; 1344 GtkTreePath *path;
1346 1345
1347 _dw_recursing = 1; 1346 g_object_set_data(G_OBJECT(widget), "_dw_recursing", GINT_TO_POINTER(1));
1348 1347
1349 if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter)) 1348 if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter))
1350 { 1349 {
1351 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter); 1350 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
1352 1351
1362 } 1361 }
1363 gtk_tree_path_free(path); 1362 gtk_tree_path_free(path);
1364 } 1363 }
1365 } 1364 }
1366 1365
1367 _dw_recursing = 0; 1366 g_object_set_data(G_OBJECT(widget), "_dw_recursing", NULL);
1368 } 1367 }
1369 } 1368 }
1370 return retval; 1369 return retval;
1371 } 1370 }
1372 1371
4401 * Returns: 4400 * Returns:
4402 * text: The text associsated with a given window. 4401 * text: The text associsated with a given window.
4403 */ 4402 */
4404 char *dw_window_get_text(HWND handle) 4403 char *dw_window_get_text(HWND handle)
4405 { 4404 {
4406 const char *possible = ""; 4405 const char *possible = NULL;
4407 int _locked_by_me = FALSE; 4406 int _locked_by_me = FALSE;
4408 4407
4409 DW_MUTEX_LOCK; 4408 DW_MUTEX_LOCK;
4410 if(GTK_IS_ENTRY(handle)) 4409 if(GTK_IS_ENTRY(handle))
4411 possible = gtk_entry_get_text(GTK_ENTRY(handle)); 4410 possible = gtk_entry_get_text(GTK_ENTRY(handle));
4412 else if(GTK_IS_COMBO_BOX(handle)) 4411 else if(GTK_IS_COMBO_BOX(handle))
4413 possible = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(handle)))); 4412 possible = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(handle))));
4414 4413
4415 DW_MUTEX_UNLOCK; 4414 DW_MUTEX_UNLOCK;
4416 return strdup(possible); 4415 return strdup(possible ? possible : "");
4417 } 4416 }
4418 4417
4419 /* 4418 /*
4420 * Disables given window (widget). 4419 * Disables given window (widget).
4421 * Parameters: 4420 * Parameters: