comparison gtk/dw.c @ 120:7d2108cbcd3e

Porting DW to GTK 2.0... and changed the percent value from into to a float so there won't be any rounding.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 19 Oct 2002 11:46:54 +0000
parents 1cad81b7cc4c
children d8af32b1b1cd
comparison
equal deleted inserted replaced
119:1cad81b7cc4c 120:7d2108cbcd3e
17 #include <sys/time.h> 17 #include <sys/time.h>
18 #include "config.h" 18 #include "config.h"
19 #include <gdk/gdkkeysyms.h> 19 #include <gdk/gdkkeysyms.h>
20 #ifdef USE_IMLIB 20 #ifdef USE_IMLIB
21 #include <gdk_imlib.h> 21 #include <gdk_imlib.h>
22 #elif defined(USE_PIXBUF) 22 #endif
23 #if GTK_MAJOR_VERSION > 1
23 #include <gdk-pixbuf/gdk-pixbuf.h> 24 #include <gdk-pixbuf/gdk-pixbuf.h>
24 #include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h>
25 #include <gdk-pixbuf/gdk-pixbuf-xlib.h>
26 #endif 25 #endif
27 26
28 /* These are used for resource management */ 27 /* These are used for resource management */
29 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) 28 #if defined(DW_RESOURCES) && !defined(BUILD_DLL)
30 extern DWResources _resources; 29 extern DWResources _resources;
554 } 553 }
555 554
556 if(data) 555 if(data)
557 { 556 {
558 GdkPixmap *icon_pixmap = NULL; 557 GdkPixmap *icon_pixmap = NULL;
559 #ifdef USE_IMLIB 558 #if GTK_MAJOR_VERSION > 1
559 icon_pixmap = (GdkPixmap *)gdk_pixbuf_new_from_xpm_data((const char **)data);
560 #elif defined(USE_IMLIB)
560 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); 561 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap);
561 #elif defined(USE_PIXBUF)
562 icon_pixmap = (GdkPixmap *)gdk_pixbuf_new_from_xpm_data((const char **)data);
563 #else 562 #else
564 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], &data); 563 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], &data);
565 #endif 564 #endif
566 return icon_pixmap; 565 return icon_pixmap;
567 } 566 }
1104 DW_MUTEX_UNLOCK; 1103 DW_MUTEX_UNLOCK;
1105 } 1104 }
1106 1105
1107 int _set_font(HWND handle, char *fontname) 1106 int _set_font(HWND handle, char *fontname)
1108 { 1107 {
1108 int retval = FALSE;
1109 #if GTK_MAJOR_VERSION < 2
1109 GtkStyle *style; 1110 GtkStyle *style;
1110 GdkFont *font = NULL; 1111 GdkFont *font = NULL;
1111 int retval = FALSE;
1112 1112
1113 font = gdk_font_load(fontname); 1113 font = gdk_font_load(fontname);
1114 1114
1115 if(font) 1115 if(font)
1116 { 1116 {
1117 style = gtk_widget_get_style(handle); 1117 style = gtk_widget_get_style(handle);
1118 style->font = font; 1118 style->font = font;
1119 gtk_widget_set_style(handle, style); 1119 gtk_widget_set_style(handle, style);
1120 retval = TRUE; 1120 retval = TRUE;
1121 } 1121 }
1122 #else
1123 PangoFontDescription *font = pango_font_description_from_string(fontname);
1124
1125 if(font)
1126 gtk_widget_modify_font(handle, font);
1127 pango_font_description_free(font);
1128 #endif
1122 return retval; 1129 return retval;
1123 } 1130 }
1124 1131
1125 /* 1132 /*
1126 * Sets the font used by a specified window (widget) handle. 1133 * Sets the font used by a specified window (widget) handle.
1210 1217
1211 style = gtk_style_copy(gtk_widget_get_style(handle)); 1218 style = gtk_style_copy(gtk_widget_get_style(handle));
1212 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor; 1219 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor;
1213 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; 1220 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor;
1214 gtk_widget_set_style(handle, style); 1221 gtk_widget_set_style(handle, style);
1215 1222
1216 _save_gdk_colors(handle, forecolor, backcolor); 1223 _save_gdk_colors(handle, forecolor, backcolor);
1217 1224
1218 if(GTK_IS_CLIST(handle)) 1225 if(GTK_IS_CLIST(handle))
1219 { 1226 {
1220 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount"); 1227 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount");
1461 * Parameters: 1468 * Parameters:
1462 * id: An ID to be used with WinWindowFromID() or 0L. 1469 * id: An ID to be used with WinWindowFromID() or 0L.
1463 */ 1470 */
1464 HWND dw_bitmap_new(unsigned long id) 1471 HWND dw_bitmap_new(unsigned long id)
1465 { 1472 {
1466 GdkPixmap *pixmap= NULL; 1473 GdkPixmap *pixmap = NULL;
1467 GdkBitmap *bitmap; 1474 GdkBitmap *bitmap = NULL;
1468 GtkWidget *tmp; 1475 GtkWidget *tmp;
1469 static char * test_xpm[] = { 1476 static char * test_xpm[] = {
1470 "1 1 2 1", 1477 "1 1 2 1",
1471 " c None", 1478 " c None",
1472 ". c #FFFFFF", 1479 ". c #FFFFFF",
1473 "."}; 1480 "."};
1474 int _locked_by_me = FALSE; 1481 int _locked_by_me = FALSE;
1475 1482
1476 DW_MUTEX_LOCK; 1483 DW_MUTEX_LOCK;
1477 #ifdef USE_IMLIB 1484 #if GTK_MAJOR_VERSION > 1
1485 pixmap = (GdkPixmap *)gdk_pixbuf_new_from_xpm_data((const char **)test_xpm);
1486 tmp = gtk_image_new_from_pixbuf((GdkPixbuf *)pixmap);
1487 #elif defined(USE_IMLIB)
1478 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap); 1488 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap);
1479 #elif defined(USE_PIXBUF)
1480 pixmap = (GdkPixmap *)gdk_pixbuf_new_from_xpm_data((const char **)test_xpm);
1481 #else 1489 #else
1482 gtk_widget_realize(last_window); 1490 gtk_widget_realize(last_window);
1483 1491
1484 if(last_window) 1492 if(last_window)
1485 pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &bitmap, &_colors[DW_CLR_PALEGRAY], test_xpm); 1493 pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &bitmap, &_colors[DW_CLR_PALEGRAY], test_xpm);
1486 #endif 1494 #endif
1495 #if GTK_MAJOR_VERSION < 2
1487 tmp = gtk_pixmap_new(pixmap, bitmap); 1496 tmp = gtk_pixmap_new(pixmap, bitmap);
1497 #endif
1488 gtk_widget_show(tmp); 1498 gtk_widget_show(tmp);
1489 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); 1499 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
1490 DW_MUTEX_UNLOCK; 1500 DW_MUTEX_UNLOCK;
1491 return tmp; 1501 return tmp;
1492 } 1502 }
1655 char numbuf[10]; 1665 char numbuf[10];
1656 if(accel && accel_group) 1666 if(accel && accel_group)
1657 { 1667 {
1658 tmphandle=gtk_check_menu_item_new_with_label(""); 1668 tmphandle=gtk_check_menu_item_new_with_label("");
1659 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); 1669 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
1660 gtk_widget_add_accelerator(tmphandle, "activate_item", accel_group, tmp_key, GDK_MOD1_MASK, 0); 1670 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
1661 } 1671 }
1662 else 1672 else
1663 tmphandle=gtk_check_menu_item_new_with_label(tempbuf); 1673 tmphandle=gtk_check_menu_item_new_with_label(tempbuf);
1664 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); 1674 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE);
1665 sprintf(numbuf, "%lu", id); 1675 sprintf(numbuf, "%lu", id);
1669 { 1679 {
1670 if(accel && accel_group) 1680 if(accel && accel_group)
1671 { 1681 {
1672 tmphandle=gtk_menu_item_new_with_label(""); 1682 tmphandle=gtk_menu_item_new_with_label("");
1673 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); 1683 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
1674 gtk_widget_add_accelerator(tmphandle, "activate_item", accel_group, tmp_key, GDK_MOD1_MASK, 0); 1684 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
1675 } 1685 }
1676 else 1686 else
1677 tmphandle=gtk_menu_item_new_with_label(tempbuf); 1687 tmphandle=gtk_menu_item_new_with_label(tempbuf);
1678 } 1688 }
1679 } 1689 }
1936 { 1946 {
1937 GtkWidget *tmp, *tmpbox, *scroller; 1947 GtkWidget *tmp, *tmpbox, *scroller;
1938 int _locked_by_me = FALSE; 1948 int _locked_by_me = FALSE;
1939 1949
1940 DW_MUTEX_LOCK; 1950 DW_MUTEX_LOCK;
1951 #if GTK_MAJOR_VERSION > 1
1952 tmpbox = gtk_scrolled_window_new (NULL, NULL);
1953 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmpbox),
1954 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1955 tmp = gtk_text_view_new();
1956 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmpbox), tmp);
1957 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE);
1958 #else
1941 tmpbox = gtk_hbox_new(FALSE, 0); 1959 tmpbox = gtk_hbox_new(FALSE, 0);
1942 tmp = gtk_text_new(NULL, NULL); 1960 tmp = gtk_text_new(NULL, NULL);
1943 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); 1961 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE);
1944 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); 1962 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE);
1945 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj); 1963 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj);
1946 GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS); 1964 GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS);
1965 gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0);
1966 gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0);
1967 gtk_widget_show(scroller);
1968 #endif
1947 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); 1969 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
1948 gtk_object_set_data(GTK_OBJECT(tmpbox), "mle", (gpointer)tmp); 1970 gtk_object_set_data(GTK_OBJECT(tmpbox), "mle", (gpointer)tmp);
1949 gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0);
1950 gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0);
1951 gtk_widget_show(tmp); 1971 gtk_widget_show(tmp);
1952 gtk_widget_show(scroller);
1953 gtk_widget_show(tmpbox); 1972 gtk_widget_show(tmpbox);
1954 DW_MUTEX_UNLOCK; 1973 DW_MUTEX_UNLOCK;
1955 return tmpbox; 1974 return tmpbox;
1956 } 1975 }
1957 1976
2238 2257
2239 DW_MUTEX_LOCK; 2258 DW_MUTEX_LOCK;
2240 icon_pixmap = _find_pixmap(&bitmap, id, handle); 2259 icon_pixmap = _find_pixmap(&bitmap, id, handle);
2241 2260
2242 if(handle->window && icon_pixmap) 2261 if(handle->window && icon_pixmap)
2262 #if GTK_MAJOR_VERSION > 1
2263 gtk_window_set_icon(GTK_WINDOW(handle), (GdkPixbuf *)icon_pixmap);
2264 #else
2243 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap); 2265 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap);
2266 #endif
2244 2267
2245 DW_MUTEX_UNLOCK; 2268 DW_MUTEX_UNLOCK;
2246 } 2269 }
2247 2270
2248 /* 2271 /*
2258 int _locked_by_me = FALSE; 2281 int _locked_by_me = FALSE;
2259 2282
2260 DW_MUTEX_LOCK; 2283 DW_MUTEX_LOCK;
2261 tmp = _find_pixmap(&bitmap, id, handle); 2284 tmp = _find_pixmap(&bitmap, id, handle);
2262 if(tmp) 2285 if(tmp)
2286 #if GTK_MAJOR_VERSION > 1
2287 gtk_image_set_from_pixbuf(GTK_IMAGE(handle), (GdkPixbuf *)tmp);
2288 #else
2263 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap); 2289 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap);
2290 #endif
2264 DW_MUTEX_UNLOCK; 2291 DW_MUTEX_UNLOCK;
2265 } 2292 }
2266 2293
2267 /* 2294 /*
2268 * Sets the text used for a given window. 2295 * Sets the text used for a given window.
2297 * Returns: 2324 * Returns:
2298 * text: The text associsated with a given window. 2325 * text: The text associsated with a given window.
2299 */ 2326 */
2300 char *dw_window_get_text(HWND handle) 2327 char *dw_window_get_text(HWND handle)
2301 { 2328 {
2329 #if GTK_MAJOR_VERSION > 1
2330 const char *possible = "";
2331 #else
2302 char *possible = ""; 2332 char *possible = "";
2333 #endif
2303 int _locked_by_me = FALSE; 2334 int _locked_by_me = FALSE;
2304 2335
2305 DW_MUTEX_LOCK; 2336 DW_MUTEX_LOCK;
2306 if(GTK_IS_ENTRY(handle)) 2337 if(GTK_IS_ENTRY(handle))
2307 possible = gtk_entry_get_text(GTK_ENTRY(handle)); 2338 possible = gtk_entry_get_text(GTK_ENTRY(handle));
2366 { 2397 {
2367 unsigned int tmppoint = startpoint; 2398 unsigned int tmppoint = startpoint;
2368 int _locked_by_me = FALSE; 2399 int _locked_by_me = FALSE;
2369 2400
2370 DW_MUTEX_LOCK; 2401 DW_MUTEX_LOCK;
2402 #if GTK_MAJOR_VERSION > 1
2403 if(GTK_IS_SCROLLED_WINDOW(handle))
2404 #else
2371 if(GTK_IS_BOX(handle)) 2405 if(GTK_IS_BOX(handle))
2406 #endif
2372 { 2407 {
2373 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2408 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2374 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont"); 2409 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont");
2375 2410
2411 #if GTK_MAJOR_VERSION > 1
2412 if(tmp && GTK_IS_TEXT_VIEW(tmp))
2413 {
2414 char *impbuf = malloc(strlen(buffer)+1);
2415 GtkTextBuffer *tbuffer;
2416 GtkTextIter iter;
2417
2418 _strip_cr(impbuf, buffer);
2419
2420 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
2421 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint);
2422 gtk_text_buffer_place_cursor(tbuffer, &iter);
2423 gtk_text_buffer_insert_at_cursor(tbuffer, impbuf, -1);
2424 free(impbuf);
2425 }
2426 #else
2376 if(tmp && GTK_IS_TEXT(tmp)) 2427 if(tmp && GTK_IS_TEXT(tmp))
2377 { 2428 {
2378 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "foregdk"); 2429 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "foregdk");
2379 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "backgdk"); 2430 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "backgdk");
2380 char *impbuf = malloc(strlen(buffer)+1); 2431 char *impbuf = malloc(strlen(buffer)+1);
2384 gtk_text_set_point(GTK_TEXT(tmp), startpoint < 0 ? 0 : startpoint); 2435 gtk_text_set_point(GTK_TEXT(tmp), startpoint < 0 ? 0 : startpoint);
2385 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1); 2436 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1);
2386 tmppoint = gtk_text_get_point(GTK_TEXT(tmp)); 2437 tmppoint = gtk_text_get_point(GTK_TEXT(tmp));
2387 free(impbuf); 2438 free(impbuf);
2388 } 2439 }
2440 #endif
2389 } 2441 }
2390 DW_MUTEX_UNLOCK; 2442 DW_MUTEX_UNLOCK;
2391 return tmppoint; 2443 return tmppoint;
2392 } 2444 }
2393 2445
2399 * startpoint: Point to start grabbing text. 2451 * startpoint: Point to start grabbing text.
2400 * length: Amount of text to be grabbed. 2452 * length: Amount of text to be grabbed.
2401 */ 2453 */
2402 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) 2454 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
2403 { 2455 {
2456 #if GTK_MAJOR_VERSION > 1
2457 #else
2404 int _locked_by_me = FALSE; 2458 int _locked_by_me = FALSE;
2405 gchar *text; 2459 gchar *text;
2406 2460
2407 DW_MUTEX_LOCK; 2461 DW_MUTEX_LOCK;
2408 if(GTK_IS_BOX(handle)) 2462 if(GTK_IS_BOX(handle))
2418 g_free(text); 2472 g_free(text);
2419 } 2473 }
2420 } 2474 }
2421 } 2475 }
2422 DW_MUTEX_UNLOCK; 2476 DW_MUTEX_UNLOCK;
2477 #endif
2423 } 2478 }
2424 2479
2425 /* 2480 /*
2426 * Obtains information about an MLE box. 2481 * Obtains information about an MLE box.
2427 * Parameters: 2482 * Parameters:
2437 *bytes = 0; 2492 *bytes = 0;
2438 if(lines) 2493 if(lines)
2439 *lines = 0; 2494 *lines = 0;
2440 2495
2441 DW_MUTEX_LOCK; 2496 DW_MUTEX_LOCK;
2497 #if GTK_MAJOR_VERSION > 1
2498 if(GTK_IS_SCROLLED_WINDOW(handle))
2499 {
2500 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2501
2502 if(tmp && GTK_IS_TEXT_VIEW(tmp))
2503 {
2504 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
2505
2506 if(bytes)
2507 *bytes = gtk_text_buffer_get_char_count(buffer) + 1;
2508 if(lines)
2509 *lines = gtk_text_buffer_get_line_count(buffer) + 1;
2510 }
2511 }
2512 #else
2442 if(GTK_IS_BOX(handle)) 2513 if(GTK_IS_BOX(handle))
2443 { 2514 {
2444 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2515 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2445 2516
2446 if(tmp && GTK_IS_TEXT(tmp)) 2517 if(tmp && GTK_IS_TEXT(tmp))
2466 g_free(text); 2537 g_free(text);
2467 } 2538 }
2468 } 2539 }
2469 } 2540 }
2470 } 2541 }
2542 #endif
2471 DW_MUTEX_UNLOCK; 2543 DW_MUTEX_UNLOCK;
2472 } 2544 }
2473 2545
2474 /* 2546 /*
2475 * Deletes text from an MLE box. 2547 * Deletes text from an MLE box.
2481 void dw_mle_delete(HWND handle, int startpoint, int length) 2553 void dw_mle_delete(HWND handle, int startpoint, int length)
2482 { 2554 {
2483 int _locked_by_me = FALSE; 2555 int _locked_by_me = FALSE;
2484 2556
2485 DW_MUTEX_LOCK; 2557 DW_MUTEX_LOCK;
2558 #if GTK_MAJOR_VERSION > 1
2559 #else
2486 if(GTK_IS_BOX(handle)) 2560 if(GTK_IS_BOX(handle))
2487 { 2561 {
2488 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2562 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2489 2563
2490 if(tmp && GTK_IS_TEXT(tmp)) 2564 if(tmp && GTK_IS_TEXT(tmp))
2491 { 2565 {
2492 gtk_text_set_point(GTK_TEXT(tmp), startpoint); 2566 gtk_text_set_point(GTK_TEXT(tmp), startpoint);
2493 gtk_text_forward_delete(GTK_TEXT(tmp), length); 2567 gtk_text_forward_delete(GTK_TEXT(tmp), length);
2494 } 2568 }
2495 } 2569 }
2570 #endif
2496 DW_MUTEX_UNLOCK; 2571 DW_MUTEX_UNLOCK;
2497 } 2572 }
2498 2573
2499 /* 2574 /*
2500 * Clears all text from an MLE box. 2575 * Clears all text from an MLE box.
2504 void dw_mle_clear(HWND handle) 2579 void dw_mle_clear(HWND handle)
2505 { 2580 {
2506 int length, _locked_by_me = FALSE; 2581 int length, _locked_by_me = FALSE;
2507 2582
2508 DW_MUTEX_LOCK; 2583 DW_MUTEX_LOCK;
2584 #if GTK_MAJOR_VERSION > 1
2585 #else
2509 if(GTK_IS_BOX(handle)) 2586 if(GTK_IS_BOX(handle))
2510 { 2587 {
2511 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2588 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2512 2589
2513 if(tmp && GTK_IS_TEXT(tmp)) 2590 if(tmp && GTK_IS_TEXT(tmp))
2515 length = gtk_text_get_length(GTK_TEXT(tmp)); 2592 length = gtk_text_get_length(GTK_TEXT(tmp));
2516 gtk_text_set_point(GTK_TEXT(tmp), 0); 2593 gtk_text_set_point(GTK_TEXT(tmp), 0);
2517 gtk_text_forward_delete(GTK_TEXT(tmp), length); 2594 gtk_text_forward_delete(GTK_TEXT(tmp), length);
2518 } 2595 }
2519 } 2596 }
2597 #endif
2520 DW_MUTEX_UNLOCK; 2598 DW_MUTEX_UNLOCK;
2521 } 2599 }
2522 2600
2523 /* 2601 /*
2524 * Sets the visible line of an MLE box. 2602 * Sets the visible line of an MLE box.
2529 void dw_mle_set_visible(HWND handle, int line) 2607 void dw_mle_set_visible(HWND handle, int line)
2530 { 2608 {
2531 int _locked_by_me = FALSE; 2609 int _locked_by_me = FALSE;
2532 2610
2533 DW_MUTEX_LOCK; 2611 DW_MUTEX_LOCK;
2612 #if GTK_MAJOR_VERSION > 1
2613 #else
2534 if(GTK_IS_BOX(handle)) 2614 if(GTK_IS_BOX(handle))
2535 { 2615 {
2536 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2616 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2537 2617
2538 if(tmp && GTK_IS_TEXT(tmp)) 2618 if(tmp && GTK_IS_TEXT(tmp))
2550 2630
2551 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); 2631 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos);
2552 } 2632 }
2553 } 2633 }
2554 } 2634 }
2635 #endif
2555 DW_MUTEX_UNLOCK; 2636 DW_MUTEX_UNLOCK;
2556 } 2637 }
2557 2638
2558 /* 2639 /*
2559 * Sets the editablity of an MLE box. 2640 * Sets the editablity of an MLE box.
2564 void dw_mle_set_editable(HWND handle, int state) 2645 void dw_mle_set_editable(HWND handle, int state)
2565 { 2646 {
2566 int _locked_by_me = FALSE; 2647 int _locked_by_me = FALSE;
2567 2648
2568 DW_MUTEX_LOCK; 2649 DW_MUTEX_LOCK;
2650 #if GTK_MAJOR_VERSION > 1
2651 if(GTK_IS_SCROLLED_WINDOW(handle))
2652 {
2653 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2654
2655 if(tmp && GTK_IS_TEXT_VIEW(tmp))
2656 gtk_text_view_set_editable(GTK_TEXT_VIEW(tmp), state);
2657 }
2658 #else
2569 if(GTK_IS_BOX(handle)) 2659 if(GTK_IS_BOX(handle))
2570 { 2660 {
2571 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2661 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2572 2662
2573 if(tmp && GTK_IS_TEXT(tmp)) 2663 if(tmp && GTK_IS_TEXT(tmp))
2574 {
2575 gtk_text_set_editable(GTK_TEXT(tmp), state); 2664 gtk_text_set_editable(GTK_TEXT(tmp), state);
2576 } 2665 }
2577 } 2666 #endif
2578 DW_MUTEX_UNLOCK; 2667 DW_MUTEX_UNLOCK;
2579 } 2668 }
2580 2669
2581 /* 2670 /*
2582 * Sets the word wrap state of an MLE box. 2671 * Sets the word wrap state of an MLE box.
2587 void dw_mle_set_word_wrap(HWND handle, int state) 2676 void dw_mle_set_word_wrap(HWND handle, int state)
2588 { 2677 {
2589 int _locked_by_me = FALSE; 2678 int _locked_by_me = FALSE;
2590 2679
2591 DW_MUTEX_LOCK; 2680 DW_MUTEX_LOCK;
2681 #if GTK_MAJOR_VERSION > 1
2682 if(GTK_IS_SCROLLED_WINDOW(handle))
2683 {
2684 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2685
2686 if(tmp && GTK_IS_TEXT_VIEW(tmp))
2687 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_WORD);
2688 }
2689 #else
2592 if(GTK_IS_BOX(handle)) 2690 if(GTK_IS_BOX(handle))
2593 { 2691 {
2594 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2692 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2595 2693
2596 if(tmp && GTK_IS_TEXT(tmp)) 2694 if(tmp && GTK_IS_TEXT(tmp))
2597 { 2695 {
2598 gtk_text_set_word_wrap(GTK_TEXT(tmp), state); 2696 gtk_text_set_word_wrap(GTK_TEXT(tmp), state);
2599 gtk_text_set_line_wrap(GTK_TEXT(tmp), state); 2697 gtk_text_set_line_wrap(GTK_TEXT(tmp), state);
2600 } 2698 }
2601 } 2699 }
2700 #endif
2602 DW_MUTEX_UNLOCK; 2701 DW_MUTEX_UNLOCK;
2603 } 2702 }
2604 2703
2605 /* 2704 /*
2606 * Sets the current cursor position of an MLE box. 2705 * Sets the current cursor position of an MLE box.
2611 void dw_mle_set(HWND handle, int point) 2710 void dw_mle_set(HWND handle, int point)
2612 { 2711 {
2613 int _locked_by_me = FALSE; 2712 int _locked_by_me = FALSE;
2614 2713
2615 DW_MUTEX_LOCK; 2714 DW_MUTEX_LOCK;
2715 #if GTK_MAJOR_VERSION > 1
2716 #else
2616 if(GTK_IS_BOX(handle)) 2717 if(GTK_IS_BOX(handle))
2617 { 2718 {
2618 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2719 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2619 2720
2620 if(tmp && GTK_IS_TEXT(tmp)) 2721 if(tmp && GTK_IS_TEXT(tmp))
2633 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); 2734 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos);
2634 } 2735 }
2635 gtk_text_set_point(GTK_TEXT(tmp), point); 2736 gtk_text_set_point(GTK_TEXT(tmp), point);
2636 } 2737 }
2637 } 2738 }
2739 #endif
2638 DW_MUTEX_UNLOCK; 2740 DW_MUTEX_UNLOCK;
2639 } 2741 }
2640 2742
2641 /* 2743 /*
2642 * Finds text in an MLE box. 2744 * Finds text in an MLE box.
2649 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) 2751 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
2650 { 2752 {
2651 int _locked_by_me = FALSE, retval = 0; 2753 int _locked_by_me = FALSE, retval = 0;
2652 2754
2653 DW_MUTEX_LOCK; 2755 DW_MUTEX_LOCK;
2756 #if GTK_MAJOR_VERSION > 1
2757 #else
2654 if(GTK_IS_BOX(handle)) 2758 if(GTK_IS_BOX(handle))
2655 { 2759 {
2656 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2760 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2657 2761
2658 if(tmp && GTK_IS_TEXT(tmp)) 2762 if(tmp && GTK_IS_TEXT(tmp))
2692 2796
2693 g_free(tmpbuf); 2797 g_free(tmpbuf);
2694 } 2798 }
2695 } 2799 }
2696 } 2800 }
2697 2801 #endif
2698 DW_MUTEX_UNLOCK; 2802 DW_MUTEX_UNLOCK;
2699 return retval; 2803 return retval;
2700 } 2804 }
2701 2805
2702 /* 2806 /*
2707 void dw_mle_freeze(HWND handle) 2811 void dw_mle_freeze(HWND handle)
2708 { 2812 {
2709 int _locked_by_me = FALSE; 2813 int _locked_by_me = FALSE;
2710 2814
2711 DW_MUTEX_LOCK; 2815 DW_MUTEX_LOCK;
2816 #if GTK_MAJOR_VERSION > 1
2817 #else
2712 if(GTK_IS_BOX(handle)) 2818 if(GTK_IS_BOX(handle))
2713 { 2819 {
2714 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2820 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2715 2821
2716 if(tmp && GTK_IS_TEXT(tmp)) 2822 if(tmp && GTK_IS_TEXT(tmp))
2717 { 2823 {
2718 gtk_text_freeze(GTK_TEXT(tmp)); 2824 gtk_text_freeze(GTK_TEXT(tmp));
2719 } 2825 }
2720 } 2826 }
2827 #endif
2721 DW_MUTEX_UNLOCK; 2828 DW_MUTEX_UNLOCK;
2722 } 2829 }
2723 2830
2724 /* 2831 /*
2725 * Resumes redrawing of an MLE box. 2832 * Resumes redrawing of an MLE box.
2729 void dw_mle_thaw(HWND handle) 2836 void dw_mle_thaw(HWND handle)
2730 { 2837 {
2731 int _locked_by_me = FALSE; 2838 int _locked_by_me = FALSE;
2732 2839
2733 DW_MUTEX_LOCK; 2840 DW_MUTEX_LOCK;
2841 #if GTK_MAJOR_VERSION > 1
2842 #else
2734 if(GTK_IS_BOX(handle)) 2843 if(GTK_IS_BOX(handle))
2735 { 2844 {
2736 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); 2845 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
2737 2846
2738 if(tmp && GTK_IS_TEXT(tmp)) 2847 if(tmp && GTK_IS_TEXT(tmp))
2739 { 2848 {
2740 gtk_text_thaw(GTK_TEXT(tmp)); 2849 gtk_text_thaw(GTK_TEXT(tmp));
2741 } 2850 }
2742 } 2851 }
2852 #endif
2743 DW_MUTEX_UNLOCK; 2853 DW_MUTEX_UNLOCK;
2744 } 2854 }
2745 2855
2746 /* 2856 /*
2747 * Returns the range of the percent bar. 2857 * Returns the range of the percent bar.
2959 gtk_object_set_data(GTK_OBJECT(newitem), "itemdata", (gpointer)itemdata); 3069 gtk_object_set_data(GTK_OBJECT(newitem), "itemdata", (gpointer)itemdata);
2960 gtk_object_set_data(GTK_OBJECT(newitem), "tree", (gpointer)tree); 3070 gtk_object_set_data(GTK_OBJECT(newitem), "tree", (gpointer)tree);
2961 hbox = gtk_hbox_new(FALSE, 2); 3071 hbox = gtk_hbox_new(FALSE, 2);
2962 gtk_object_set_data(GTK_OBJECT(newitem), "hbox", (gpointer)hbox); 3072 gtk_object_set_data(GTK_OBJECT(newitem), "hbox", (gpointer)hbox);
2963 gdkpix = _find_pixmap(&gdkbmp, icon, hbox); 3073 gdkpix = _find_pixmap(&gdkbmp, icon, hbox);
3074 #if GTK_MAJOR_VERSION > 1
3075 pixmap = gtk_image_new_from_pixbuf((GdkPixbuf *)gdkbmp);
3076 #else
2964 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); 3077 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
3078 #endif
2965 gtk_container_add(GTK_CONTAINER(newitem), hbox); 3079 gtk_container_add(GTK_CONTAINER(newitem), hbox);
2966 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); 3080 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
2967 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); 3081 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
2968 gtk_widget_show(label); 3082 gtk_widget_show(label);
2969 gtk_widget_show(pixmap); 3083 gtk_widget_show(pixmap);
3044 gtk_object_set_data(GTK_OBJECT(item), "itemdata", (gpointer)itemdata); 3158 gtk_object_set_data(GTK_OBJECT(item), "itemdata", (gpointer)itemdata);
3045 gtk_object_set_data(GTK_OBJECT(item), "tree", (gpointer)tree); 3159 gtk_object_set_data(GTK_OBJECT(item), "tree", (gpointer)tree);
3046 hbox = gtk_hbox_new(FALSE, 2); 3160 hbox = gtk_hbox_new(FALSE, 2);
3047 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox); 3161 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox);
3048 gdkpix = _find_pixmap(&gdkbmp, icon, hbox); 3162 gdkpix = _find_pixmap(&gdkbmp, icon, hbox);
3163 #if GTK_MAJOR_VERSION > 1
3164 pixmap = gtk_image_new_from_pixbuf((GdkPixbuf *)gdkbmp);
3165 #else
3049 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); 3166 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
3167 #endif
3050 gtk_container_add(GTK_CONTAINER(item), hbox); 3168 gtk_container_add(GTK_CONTAINER(item), hbox);
3051 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); 3169 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
3052 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); 3170 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
3053 gtk_widget_show(label); 3171 gtk_widget_show(label);
3054 gtk_widget_show(pixmap); 3172 gtk_widget_show(pixmap);
3125 hbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "hbox"); 3243 hbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "hbox");
3126 gtk_widget_destroy(hbox); 3244 gtk_widget_destroy(hbox);
3127 hbox = gtk_hbox_new(FALSE, 2); 3245 hbox = gtk_hbox_new(FALSE, 2);
3128 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox); 3246 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox);
3129 gdkpix = _find_pixmap(&gdkbmp, icon, hbox); 3247 gdkpix = _find_pixmap(&gdkbmp, icon, hbox);
3248 #if GTK_MAJOR_VERSION > 1
3249 pixmap = gtk_image_new_from_pixbuf((GdkPixbuf *)gdkbmp);
3250 #else
3130 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); 3251 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
3252 #endif
3131 gtk_container_add(GTK_CONTAINER(item), hbox); 3253 gtk_container_add(GTK_CONTAINER(item), hbox);
3132 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); 3254 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
3133 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); 3255 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
3134 gtk_widget_show(label); 3256 gtk_widget_show(label);
3135 gtk_widget_show(pixmap); 3257 gtk_widget_show(pixmap);
3483 { 3605 {
3484 long hicon = *((long *)data); 3606 long hicon = *((long *)data);
3485 GdkBitmap *bitmap = NULL; 3607 GdkBitmap *bitmap = NULL;
3486 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist); 3608 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist);
3487 3609
3610 #if GTK_MAJOR_VERSION < 2
3488 if(pixmap) 3611 if(pixmap)
3489 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); 3612 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap);
3613 #endif
3490 } 3614 }
3491 else if(flag & DW_CFA_STRING) 3615 else if(flag & DW_CFA_STRING)
3492 { 3616 {
3493 char *tmp = *((char **)data); 3617 char *tmp = *((char **)data);
3494 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); 3618 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp);
4161 pixmap->width = width; pixmap->height = height; 4285 pixmap->width = width; pixmap->height = height;
4162 4286
4163 4287
4164 DW_MUTEX_LOCK; 4288 DW_MUTEX_LOCK;
4165 pixmap->handle = handle; 4289 pixmap->handle = handle;
4166 #ifdef USE_PIXBUF 4290 #if GTK_MAJOR_VERSION > 1
4167 pixmap->pixmap = (GdkPixmap *)gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, depth, width, height); 4291 pixmap->pixmap = (GdkPixmap *)gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, depth, width, height);
4168 #else 4292 #else
4169 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth); 4293 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth);
4170 #endif 4294 #endif
4171 DW_MUTEX_UNLOCK; 4295 DW_MUTEX_UNLOCK;
4192 4316
4193 DW_MUTEX_LOCK; 4317 DW_MUTEX_LOCK;
4194 pixmap->pixmap = _find_pixmap(&bitmap, id, handle); 4318 pixmap->pixmap = _find_pixmap(&bitmap, id, handle);
4195 if(pixmap->pixmap) 4319 if(pixmap->pixmap)
4196 { 4320 {
4321 #if GTK_MAJOR_VERSION < 2
4197 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; 4322 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap;
4198 pixmap->width = pvt->width; pixmap->height = pvt->height; 4323 pixmap->width = pvt->width; pixmap->height = pvt->height;
4324 #else
4325 pixmap->width = gdk_pixbuf_get_width((GdkPixbuf *)pixmap->pixmap);
4326 pixmap->height = gdk_pixbuf_get_height((GdkPixbuf *)pixmap->pixmap);
4327 #endif
4199 } 4328 }
4200 DW_MUTEX_UNLOCK; 4329 DW_MUTEX_UNLOCK;
4201 return pixmap; 4330 return pixmap;
4202 } 4331 }
4203 4332
4222 void dw_pixmap_destroy(HPIXMAP pixmap) 4351 void dw_pixmap_destroy(HPIXMAP pixmap)
4223 { 4352 {
4224 int _locked_by_me = FALSE; 4353 int _locked_by_me = FALSE;
4225 4354
4226 DW_MUTEX_LOCK; 4355 DW_MUTEX_LOCK;
4227 #ifdef USE_PIXBUF 4356 #if GTK_MAJOR_VERSION > 1
4228 gdk_pixbuf_unref((GdkPixbuf *)pixmap->pixmap); 4357 gdk_pixbuf_unref((GdkPixbuf *)pixmap->pixmap);
4229 #else 4358 #else
4230 gdk_pixmap_unref(pixmap->pixmap); 4359 gdk_pixmap_unref(pixmap->pixmap);
4231 #endif 4360 #endif
4232 free(pixmap); 4361 free(pixmap);
4263 DW_MUTEX_LOCK; 4392 DW_MUTEX_LOCK;
4264 if(dest) 4393 if(dest)
4265 gc = _set_colors(dest->window); 4394 gc = _set_colors(dest->window);
4266 else if(src) 4395 else if(src)
4267 gc = _set_colors(src->window); 4396 gc = _set_colors(src->window);
4268 #ifndef USE_PIXBUF 4397 #if GTK_MAJOR_VERSION < 1
4269 else if(destp) 4398 else if(destp)
4270 gc = gdk_gc_new(destp->pixmap); 4399 gc = gdk_gc_new(destp->pixmap);
4271 else if(srcp) 4400 else if(srcp)
4272 gc = gdk_gc_new(srcp->pixmap); 4401 gc = gdk_gc_new(srcp->pixmap);
4273 #endif 4402 #endif
4274 4403
4275 if(gc 4404 if(gc
4276 #ifdef USE_PIXBUF 4405 #if GTK_MAJOR_VERSION > 2
4277 || (!dest && !src) 4406 || (!dest && !src)
4278 #endif 4407 #endif
4279 ) 4408 )
4280 { 4409 {
4281 #ifndef USE_PIXBUF 4410 #if GTK_MAJOR_VERSION < 1
4282 gdk_draw_pixmap(dest ? dest->window : destp->pixmap, gc, src ? src->window : srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height); 4411 gdk_draw_pixmap(dest ? dest->window : destp->pixmap, gc, src ? src->window : srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height);
4283 #else 4412 #else
4284 if(dest && srcp) 4413 if(dest && srcp)
4285 gdk_pixbuf_xlib_render_to_drawable(dest->window, gc, (GdkPixbuf *)srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height, XLIB_RGB_DITHER_NONE, 0, 0); 4414 gdk_pixbuf_render_to_drawable((GdkPixbuf *)srcp->pixmap, dest->window, gc, xsrc, ysrc, xdest, ydest, width, height, GDK_RGB_DITHER_NONE, 0, 0);
4286 4415
4287 if(gc) 4416 if(gc)
4288 #endif 4417 #endif
4289 gdk_gc_unref(gc); 4418 gdk_gc_unref(gc);
4290 } 4419 }
4291 DW_MUTEX_UNLOCK; 4420 DW_MUTEX_UNLOCK;
4292 } 4421 }
5525 } 5654 }
5526 5655
5527 /* Reposition the bar according to the percentage */ 5656 /* Reposition the bar according to the percentage */
5528 gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data) 5657 gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data)
5529 { 5658 {
5530 int percent = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); 5659 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent");
5531 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth"); 5660 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth");
5532 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight"); 5661 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight");
5533 float ratio = ((float)percent/100.0);
5534 5662
5535 /* Prevent infinite recursion ;) */ 5663 /* Prevent infinite recursion ;) */
5536 if(lastwidth == event->width && lastheight == event->height) 5664 if(!percent || (lastwidth == event->width && lastheight == event->height))
5537 return TRUE; 5665 return TRUE;
5538 5666
5539 lastwidth = event->width; lastheight = event->height; 5667 lastwidth = event->width; lastheight = event->height;
5540 5668
5541 gtk_object_set_data(GTK_OBJECT(widget), "_dw_splitbar_sizing", (gpointer)1);
5542 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth); 5669 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth);
5543 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight); 5670 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight);
5544 5671
5545 if(GTK_IS_HPANED(widget)) 5672 if(GTK_IS_HPANED(widget))
5546 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * ratio)); 5673 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0)));
5547 if(GTK_IS_VPANED(widget)) 5674 if(GTK_IS_VPANED(widget))
5548 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * ratio)); 5675 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*percent / 100.0)));
5549 return TRUE; 5676 return TRUE;
5550 } 5677 }
5551 5678
5679 #if GTK_MAJOR_VERSION == 2
5552 /* Figure out the new percentage */ 5680 /* Figure out the new percentage */
5553 gint _splitbar_child_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data) 5681 gint _splitbar_accept_position(GtkWidget *widget, gpointer data)
5554 { 5682 {
5555 GtkWidget *splitbar = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_splitbar"); 5683 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent");
5556 int percent; 5684 int size = 0, position = gtk_paned_get_position(GTK_PANED(widget));
5557 5685
5558 if(!splitbar) 5686 if(!percent)
5559 return TRUE;
5560
5561 if(gtk_object_get_data(GTK_OBJECT(splitbar), "_dw_splitbar_sizing"))
5562 {
5563 gtk_object_set_data(GTK_OBJECT(splitbar), "_dw_splitbar_sizing", (gpointer)0);
5564 return TRUE; 5687 return TRUE;
5565 } 5688
5566 5689 if(GTK_IS_VPANED(widget))
5567 if(GTK_IS_VPANED(splitbar)) 5690 size = widget->allocation.height;
5568 percent = (int)((event->height * 100) / (splitbar->allocation.height - 3)); 5691 else if(GTK_IS_HPANED(widget))
5569 else if(GTK_IS_HPANED(splitbar)) 5692 size = widget->allocation.width;
5570 percent = (int)((event->width * 100) / (splitbar->allocation.width - 3)); 5693
5571 else 5694 if(size > 0)
5572 return TRUE; 5695 *percent = ((float)(position * 100) / (float)size);
5573
5574 gtk_object_set_data(GTK_OBJECT(splitbar), "_dw_percent", (gpointer)percent);
5575
5576 return TRUE; 5696 return TRUE;
5577 } 5697 }
5698 #endif
5578 5699
5579 /* 5700 /*
5580 * Creates a splitbar window (widget) with given parameters. 5701 * Creates a splitbar window (widget) with given parameters.
5581 * Parameters: 5702 * Parameters:
5582 * type: Value can be BOXVERT or BOXHORZ. 5703 * type: Value can be BOXVERT or BOXHORZ.
5587 */ 5708 */
5588 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) 5709 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
5589 { 5710 {
5590 GtkWidget *tmp = NULL; 5711 GtkWidget *tmp = NULL;
5591 int _locked_by_me = FALSE; 5712 int _locked_by_me = FALSE;
5592 5713 float *percent = malloc(sizeof(float));
5714
5593 DW_MUTEX_LOCK; 5715 DW_MUTEX_LOCK;
5594 if(type == BOXHORZ) 5716 if(type == BOXHORZ)
5595 tmp = gtk_hpaned_new(); 5717 tmp = gtk_hpaned_new();
5596 else 5718 else
5597 tmp = gtk_vpaned_new(); 5719 tmp = gtk_vpaned_new();
5598 gtk_paned_add1(GTK_PANED(tmp), topleft); 5720 gtk_paned_add1(GTK_PANED(tmp), topleft);
5599 gtk_paned_add2(GTK_PANED(tmp), bottomright); 5721 gtk_paned_add2(GTK_PANED(tmp), bottomright);
5600 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); 5722 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
5601 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_percent", (gpointer)50); 5723 *percent = 50.0;
5724 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_percent", (gpointer)percent);
5725 gtk_object_set_data(GTK_OBJECT(topleft), "_dw_splitbar", (gpointer)tmp);
5602 gtk_signal_connect(GTK_OBJECT(tmp), "size-allocate", GTK_SIGNAL_FUNC(_splitbar_size_allocate), NULL); 5726 gtk_signal_connect(GTK_OBJECT(tmp), "size-allocate", GTK_SIGNAL_FUNC(_splitbar_size_allocate), NULL);
5603 gtk_object_set_data(GTK_OBJECT(topleft), "_dw_splitbar", (gpointer)tmp); 5727 #if GTK_MAJOR_VERSION > 1
5604 #if 0 5728 gtk_signal_connect(GTK_OBJECT(tmp), "accept-position", GTK_SIGNAL_FUNC(_splitbar_accept_position), NULL);
5605 gtk_signal_connect(GTK_OBJECT(topleft), "size-allocate", GTK_SIGNAL_FUNC(_splitbar_child_size_allocate), NULL); 5729 #else
5730 gtk_paned_set_handle_size(GTK_PANED(tmp), 3);
5606 #endif 5731 #endif
5607 gtk_paned_set_handle_size(GTK_PANED(tmp), 3);
5608 gtk_widget_show(tmp); 5732 gtk_widget_show(tmp);
5609 DW_MUTEX_UNLOCK; 5733 DW_MUTEX_UNLOCK;
5610 return tmp; 5734 return tmp;
5611 } 5735 }
5612 5736
5613 /* 5737 /*
5614 * Sets the position of a splitbar (pecentage). 5738 * Sets the position of a splitbar (pecentage).
5615 * Parameters: 5739 * Parameters:
5616 * handle: The handle to the splitbar returned by dw_splitbar_new(). 5740 * handle: The handle to the splitbar returned by dw_splitbar_new().
5617 */ 5741 */
5618 void dw_splitbar_set(HWND handle, int percent) 5742 void dw_splitbar_set(HWND handle, float percent)
5619 { 5743 {
5620 /* We probably need to force a redraw here */ 5744 /* We probably need to force a redraw here */
5621 dw_window_set_data(handle, "_dw_percent", (void *)percent); 5745 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
5746
5747 if(mypercent)
5748 *mypercent = percent;
5622 } 5749 }
5623 5750
5624 /* 5751 /*
5625 * Gets the position of a splitbar (pecentage). 5752 * Gets the position of a splitbar (pecentage).
5626 * Parameters: 5753 * Parameters:
5627 * handle: The handle to the splitbar returned by dw_splitbar_new(). 5754 * handle: The handle to the splitbar returned by dw_splitbar_new().
5628 */ 5755 */
5629 int dw_splitbar_get(HWND handle) 5756 float dw_splitbar_get(HWND handle)
5630 { 5757 {
5631 return (int)dw_window_get_data(handle, "_dw_percent"); 5758 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
5759
5760 if(percent)
5761 return *percent;
5762 return 0.0;
5632 } 5763 }
5633 5764
5634 /* 5765 /*
5635 * Pack windows (widgets) into a box from the start (or top). 5766 * Pack windows (widgets) into a box from the start (or top).
5636 * Parameters: 5767 * Parameters:
5817 } 5948 }
5818 5949
5819 /* Internal function to handle the file OK press */ 5950 /* Internal function to handle the file OK press */
5820 void _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) 5951 void _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait)
5821 { 5952 {
5953 #if GTK_MAJOR_VERSION > 1
5954 const char *tmp;
5955 #else
5822 char *tmp; 5956 char *tmp;
5957 #endif
5823 5958
5824 if(!dwwait) 5959 if(!dwwait)
5825 return; 5960 return;
5826 5961
5827 tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data)); 5962 tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data));