Mercurial > dwindows
comparison gtk3/dw.c @ 1933:758f49e54566
Enable dw_windows_get_text() to return value of label under GTK.
Support for fullscreen display on GTK.
author | mhessling@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 11 Sep 2017 05:56:04 +0000 |
parents | 3a5571255ee6 |
children | eb488c379969 |
comparison
equal
deleted
inserted
replaced
1932:bf34d9f9dabe | 1933:758f49e54566 |
---|---|
404 GdkCursor *cursor; | 404 GdkCursor *cursor; |
405 GdkPixbuf *pixbuf; | 405 GdkPixbuf *pixbuf; |
406 | 406 |
407 child_box = gtk_event_box_new (); | 407 child_box = gtk_event_box_new (); |
408 child_widget_box = gtk_event_box_new (); | 408 child_widget_box = gtk_event_box_new (); |
409 #if GTK_CHECK_VERSION(3,12,0) | 409 #if GTK_CHECK_VERSION(3,12,0) |
410 gtk_widget_set_margin_start(child_widget_box, 2); | 410 gtk_widget_set_margin_start(child_widget_box, 2); |
411 #else | 411 #else |
412 gtk_widget_set_margin_left(child_widget_box, 2); | 412 gtk_widget_set_margin_left(child_widget_box, 2); |
413 #endif | 413 #endif |
414 top_event_box = gtk_event_box_new (); | 414 top_event_box = gtk_event_box_new (); |
415 bottom_event_box = gtk_event_box_new (); | 415 bottom_event_box = gtk_event_box_new (); |
416 grid = gtk_grid_new (); | 416 grid = gtk_grid_new (); |
417 gtk_grid_set_row_spacing(GTK_GRID(grid), 1); | 417 gtk_grid_set_row_spacing(GTK_GRID(grid), 1); |
418 gtk_grid_set_column_spacing(GTK_GRID(grid), 1); | 418 gtk_grid_set_column_spacing(GTK_GRID(grid), 1); |
419 | 419 |
420 for (i = 0; i < 3; i++) | 420 for (i = 0; i < 3; i++) |
421 { | 421 { |
422 button[i] = gtk_event_box_new (); | 422 button[i] = gtk_event_box_new (); |
423 gtk_widget_set_events (button[i], GDK_BUTTON_PRESS_MASK); | 423 gtk_widget_set_events (button[i], GDK_BUTTON_PRESS_MASK); |
424 } | 424 } |
432 { | 432 { |
433 _dw_override_color (button[j], "background-color", &color); | 433 _dw_override_color (button[j], "background-color", &color); |
434 } | 434 } |
435 gdk_rgba_parse (&color, GTK_MDI_LABEL_FOREGROUND); | 435 gdk_rgba_parse (&color, GTK_MDI_LABEL_FOREGROUND); |
436 _dw_override_color (label, "color", &color); | 436 _dw_override_color (label, "color", &color); |
437 #if GTK_CHECK_VERSION(3,16,0) | 437 #if GTK_CHECK_VERSION(3,16,0) |
438 gtk_label_set_xalign(GTK_LABEL(label), 0.0f); | 438 gtk_label_set_xalign(GTK_LABEL(label), 0.0f); |
439 gtk_label_set_yalign(GTK_LABEL(label), 0.5f); | 439 gtk_label_set_yalign(GTK_LABEL(label), 0.5f); |
440 #else | 440 #else |
441 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); | 441 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); |
442 #endif | 442 #endif |
464 gtk_widget_set_hexpand(top_event_box, TRUE); | 464 gtk_widget_set_hexpand(top_event_box, TRUE); |
465 gtk_grid_attach (GTK_GRID (grid), top_event_box, 0, 0, 1, 1); | 465 gtk_grid_attach (GTK_GRID (grid), top_event_box, 0, 0, 1, 1); |
466 gtk_grid_attach (GTK_GRID (grid), button[0], 1, 0, 1, 1); | 466 gtk_grid_attach (GTK_GRID (grid), button[0], 1, 0, 1, 1); |
467 gtk_grid_attach (GTK_GRID (grid), button[1], 2, 0, 1, 1); | 467 gtk_grid_attach (GTK_GRID (grid), button[1], 2, 0, 1, 1); |
468 gtk_grid_attach (GTK_GRID (grid), button[2], 3, 0, 1, 1); | 468 gtk_grid_attach (GTK_GRID (grid), button[2], 3, 0, 1, 1); |
469 | 469 |
470 /* Window contents */ | 470 /* Window contents */ |
471 gtk_widget_set_hexpand(child_widget_box, TRUE); | 471 gtk_widget_set_hexpand(child_widget_box, TRUE); |
472 gtk_widget_set_vexpand(child_widget_box, TRUE); | 472 gtk_widget_set_vexpand(child_widget_box, TRUE); |
473 gtk_grid_attach (GTK_GRID (grid), child_widget_box, 0, 1, 4, 1); | 473 gtk_grid_attach (GTK_GRID (grid), child_widget_box, 0, 1, 4, 1); |
474 | 474 |
475 /* Bottom border */ | 475 /* Bottom border */ |
476 gtk_grid_attach (GTK_GRID (grid), bottom_event_box, 4, 2, 1, 1); | 476 gtk_grid_attach (GTK_GRID (grid), bottom_event_box, 4, 2, 1, 1); |
477 | 477 |
478 gtk_container_add (GTK_CONTAINER (child_box), grid); | 478 gtk_container_add (GTK_CONTAINER (child_box), grid); |
479 | 479 |
608 attributes.visual = gtk_widget_get_visual (widget); | 608 attributes.visual = gtk_widget_get_visual (widget); |
609 | 609 |
610 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; | 610 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; |
611 thiswindow = gdk_window_new (gtk_widget_get_parent_window(widget), &attributes, attributes_mask); | 611 thiswindow = gdk_window_new (gtk_widget_get_parent_window(widget), &attributes, attributes_mask); |
612 gtk_widget_set_window(widget, thiswindow); | 612 gtk_widget_set_window(widget, thiswindow); |
613 | 613 |
614 gdk_window_set_user_data (gtk_widget_get_window(widget), widget); | 614 gdk_window_set_user_data (gtk_widget_get_window(widget), widget); |
615 } | 615 } |
616 | 616 |
617 static void gtk_mdi_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width) | 617 static void gtk_mdi_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width) |
618 { | 618 { |
861 FALSE, | 861 FALSE, |
862 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | | 862 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | |
863 GDK_BUTTON_RELEASE_MASK, | 863 GDK_BUTTON_RELEASE_MASK, |
864 NULL, | 864 NULL, |
865 event->button.time) != GDK_GRAB_SUCCESS) | 865 event->button.time) != GDK_GRAB_SUCCESS) |
866 #endif | 866 #endif |
867 return FALSE; | 867 return FALSE; |
868 | 868 |
869 mdi->drag_button = event->button.button; | 869 mdi->drag_button = event->button.button; |
870 | 870 |
871 mdi->drag_start.x = event->button.x; | 871 mdi->drag_start.x = event->button.x; |
948 FALSE, | 948 FALSE, |
949 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | | 949 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | |
950 GDK_BUTTON_RELEASE_MASK, | 950 GDK_BUTTON_RELEASE_MASK, |
951 NULL, | 951 NULL, |
952 event->button.time) != GDK_GRAB_SUCCESS) | 952 event->button.time) != GDK_GRAB_SUCCESS) |
953 #endif | 953 #endif |
954 return FALSE; | 954 return FALSE; |
955 | 955 |
956 mdi->drag_button = event->button.button; | 956 mdi->drag_button = event->button.button; |
957 if ((child->state == CHILD_MAXIMIZED) || (child->state == CHILD_ICONIFIED)) | 957 if ((child->state == CHILD_MAXIMIZED) || (child->state == CHILD_ICONIFIED)) |
958 { | 958 { |
1129 } | 1129 } |
1130 | 1130 |
1131 static SignalHandler _get_signal_handler(gpointer data) | 1131 static SignalHandler _get_signal_handler(gpointer data) |
1132 { | 1132 { |
1133 SignalHandler sh = {0}; | 1133 SignalHandler sh = {0}; |
1134 | 1134 |
1135 if(data) | 1135 if(data) |
1136 { | 1136 { |
1137 void **params = (void **)data; | 1137 void **params = (void **)data; |
1138 int counter = GPOINTER_TO_INT(params[0]); | 1138 int counter = GPOINTER_TO_INT(params[0]); |
1139 GtkWidget *widget = (GtkWidget *)params[2]; | 1139 GtkWidget *widget = (GtkWidget *)params[2]; |
1310 if(work.window) | 1310 if(work.window) |
1311 { | 1311 { |
1312 int (*keypressfunc)(HWND, char, int, int, void *, char *) = work.func; | 1312 int (*keypressfunc)(HWND, char, int, int, void *, char *) = work.func; |
1313 guint32 unichar = gdk_keyval_to_unicode(event->keyval); | 1313 guint32 unichar = gdk_keyval_to_unicode(event->keyval); |
1314 char utf8[7] = { 0 }; | 1314 char utf8[7] = { 0 }; |
1315 | 1315 |
1316 g_unichar_to_utf8(unichar, utf8); | 1316 g_unichar_to_utf8(unichar, utf8); |
1317 | 1317 |
1318 retval = keypressfunc(work.window, *event->string, event->keyval, | 1318 retval = keypressfunc(work.window, *event->string, event->keyval, |
1319 event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK), work.data, utf8); | 1319 event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK), work.data, utf8); |
1320 } | 1320 } |
1321 return retval; | 1321 return retval; |
1322 } | 1322 } |
1688 | 1688 |
1689 static gint _column_click_event(GtkWidget *widget, gpointer data) | 1689 static gint _column_click_event(GtkWidget *widget, gpointer data) |
1690 { | 1690 { |
1691 void **params = data; | 1691 void **params = data; |
1692 int retval = FALSE; | 1692 int retval = FALSE; |
1693 | 1693 |
1694 if(params && params[2]) | 1694 if(params && params[2]) |
1695 { | 1695 { |
1696 GtkWidget *tree = (GtkWidget *)params[2]; | 1696 GtkWidget *tree = (GtkWidget *)params[2]; |
1697 gint handlerdata = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tree), "_dw_column_click_id")); | 1697 gint handlerdata = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tree), "_dw_column_click_id")); |
1698 | 1698 |
1699 if(handlerdata) | 1699 if(handlerdata) |
1700 { | 1700 { |
1701 SignalHandler work; | 1701 SignalHandler work; |
1702 | 1702 |
1703 params[0] = GINT_TO_POINTER(handlerdata-1); | 1703 params[0] = GINT_TO_POINTER(handlerdata-1); |
1704 work = _get_signal_handler(params); | 1704 work = _get_signal_handler(params); |
1705 | 1705 |
1706 if(work.window) | 1706 if(work.window) |
1707 { | 1707 { |
1727 static gint _value_changed_event(GtkWidget *widget, gpointer data) | 1727 static gint _value_changed_event(GtkWidget *widget, gpointer data) |
1728 { | 1728 { |
1729 GtkWidget *slider, *spinbutton, *scrollbar; | 1729 GtkWidget *slider, *spinbutton, *scrollbar; |
1730 GtkAdjustment *adjustment = (GtkAdjustment *)widget; | 1730 GtkAdjustment *adjustment = (GtkAdjustment *)widget; |
1731 int max, val; | 1731 int max, val; |
1732 | 1732 |
1733 if(!GTK_IS_ADJUSTMENT(adjustment)) | 1733 if(!GTK_IS_ADJUSTMENT(adjustment)) |
1734 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(widget), "_dw_adjustment"); | 1734 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(widget), "_dw_adjustment"); |
1735 | 1735 |
1736 slider = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_slider"); | 1736 slider = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_slider"); |
1737 spinbutton = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_spinbutton"); | 1737 spinbutton = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_spinbutton"); |
1738 scrollbar = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_scrollbar"); | 1738 scrollbar = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_scrollbar"); |
1739 | 1739 |
1740 max = _round_value(gtk_adjustment_get_upper(adjustment)); | 1740 max = _round_value(gtk_adjustment_get_upper(adjustment)); |
1741 val = _round_value(gtk_adjustment_get_value(adjustment)); | 1741 val = _round_value(gtk_adjustment_get_value(adjustment)); |
1742 | 1742 |
1743 if(g_object_get_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event")) | 1743 if(g_object_get_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event")) |
1744 return FALSE; | 1744 return FALSE; |
1745 | 1745 |
1746 if (slider || spinbutton || scrollbar) | 1746 if (slider || spinbutton || scrollbar) |
1747 { | 1747 { |
1808 } | 1808 } |
1809 | 1809 |
1810 if(data) | 1810 if(data) |
1811 { | 1811 { |
1812 GdkPixbuf *icon_pixbuf; | 1812 GdkPixbuf *icon_pixbuf; |
1813 | 1813 |
1814 if(data[0] == 'G' && data[1] == 'd' && data[2] == 'k' && data[3] == 'P') | 1814 if(data[0] == 'G' && data[1] == 'd' && data[2] == 'k' && data[3] == 'P') |
1815 icon_pixbuf = gdk_pixbuf_new_from_inline(-1, (const guint8 *)data, FALSE, NULL); | 1815 icon_pixbuf = gdk_pixbuf_new_from_inline(-1, (const guint8 *)data, FALSE, NULL); |
1816 else | 1816 else |
1817 icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)data); | 1817 icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)data); |
1818 | 1818 |
1865 { | 1865 { |
1866 _resources.resource_max = res->resource_max; | 1866 _resources.resource_max = res->resource_max; |
1867 _resources.resource_id = res->resource_id; | 1867 _resources.resource_id = res->resource_id; |
1868 _resources.resource_data = res->resource_data; | 1868 _resources.resource_data = res->resource_data; |
1869 } | 1869 } |
1870 | 1870 |
1871 /* Setup the private data directory */ | 1871 /* Setup the private data directory */ |
1872 if(argc && argv && *argc > 0 && (*argv)[0]) | 1872 if(argc && argv && *argc > 0 && (*argv)[0]) |
1873 { | 1873 { |
1874 char *pathcopy = strdup((*argv)[0]); | 1874 char *pathcopy = strdup((*argv)[0]); |
1875 char *pos = strrchr(pathcopy, '/'); | 1875 char *pos = strrchr(pathcopy, '/'); |
1876 char *binname = pathcopy; | 1876 char *binname = pathcopy; |
1877 | 1877 |
1878 /* If we have a / then... | 1878 /* If we have a / then... |
1879 * the binary name should be at the end. | 1879 * the binary name should be at the end. |
1880 */ | 1880 */ |
1881 if(pos) | 1881 if(pos) |
1882 { | 1882 { |
1883 binname = pos + 1; | 1883 binname = pos + 1; |
1884 *pos = 0; | 1884 *pos = 0; |
1885 } | 1885 } |
1886 | 1886 |
1887 if(*binname) | 1887 if(*binname) |
1888 { | 1888 { |
1889 char *binpos = strstr(pathcopy, "/bin"); | 1889 char *binpos = strstr(pathcopy, "/bin"); |
1890 | 1890 |
1891 if(binpos) | 1891 if(binpos) |
1892 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); | 1892 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); |
1893 else | 1893 else |
1894 strcpy(_dw_share_path, "/usr/local"); | 1894 strcpy(_dw_share_path, "/usr/local"); |
1895 strcat(_dw_share_path, "/share/"); | 1895 strcat(_dw_share_path, "/share/"); |
1899 free(pathcopy); | 1899 free(pathcopy); |
1900 } | 1900 } |
1901 /* If that failed... just get the current directory */ | 1901 /* If that failed... just get the current directory */ |
1902 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) | 1902 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) |
1903 _dw_share_path[0] = '/'; | 1903 _dw_share_path[0] = '/'; |
1904 | 1904 |
1905 #if !GLIB_CHECK_VERSION(2,31,0) | 1905 #if !GLIB_CHECK_VERSION(2,31,0) |
1906 g_thread_init(NULL); | 1906 g_thread_init(NULL); |
1907 #endif | 1907 #endif |
1908 | 1908 |
1909 /* Load these functions via dlsym to avoid deprecation warnings */ | 1909 /* Load these functions via dlsym to avoid deprecation warnings */ |
1910 _dw_gdk_threads_init = dlsym(RTLD_DEFAULT, "gdk_threads_init"); | 1910 _dw_gdk_threads_init = dlsym(RTLD_DEFAULT, "gdk_threads_init"); |
1911 _dw_gdk_threads_enter = dlsym(RTLD_DEFAULT, "gdk_threads_enter"); | 1911 _dw_gdk_threads_enter = dlsym(RTLD_DEFAULT, "gdk_threads_enter"); |
1912 _dw_gdk_threads_leave = dlsym(RTLD_DEFAULT, "gdk_threads_leave"); | 1912 _dw_gdk_threads_leave = dlsym(RTLD_DEFAULT, "gdk_threads_leave"); |
1913 | 1913 |
1970 gettimeofday(&tv, NULL); | 1970 gettimeofday(&tv, NULL); |
1971 | 1971 |
1972 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds) | 1972 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds) |
1973 { | 1973 { |
1974 int _locked_by_me = FALSE; | 1974 int _locked_by_me = FALSE; |
1975 | 1975 |
1976 if(orig == (pthread_t)-1) | 1976 if(orig == (pthread_t)-1) |
1977 { | 1977 { |
1978 if(!pthread_getspecific(_dw_mutex_key)) | 1978 if(!pthread_getspecific(_dw_mutex_key)) |
1979 { | 1979 { |
1980 _dw_gdk_threads_enter(); | 1980 _dw_gdk_threads_enter(); |
2009 void API dw_main_iteration(void) | 2009 void API dw_main_iteration(void) |
2010 { | 2010 { |
2011 pthread_t orig = _dw_thread; | 2011 pthread_t orig = _dw_thread; |
2012 pthread_t curr = pthread_self(); | 2012 pthread_t curr = pthread_self(); |
2013 int _locked_by_me = FALSE; | 2013 int _locked_by_me = FALSE; |
2014 | 2014 |
2015 if(_dw_thread == (pthread_t)-1) | 2015 if(_dw_thread == (pthread_t)-1) |
2016 { | 2016 { |
2017 if(!pthread_getspecific(_dw_mutex_key)) | 2017 if(!pthread_getspecific(_dw_mutex_key)) |
2018 { | 2018 { |
2019 _dw_gdk_threads_enter(); | 2019 _dw_gdk_threads_enter(); |
2192 char outbuf[1025] = {0}; | 2192 char outbuf[1025] = {0}; |
2193 | 2193 |
2194 va_start(args, format); | 2194 va_start(args, format); |
2195 vsnprintf(outbuf, 1024, format, args); | 2195 vsnprintf(outbuf, 1024, format, args); |
2196 va_end(args); | 2196 va_end(args); |
2197 | 2197 |
2198 fprintf(stderr, "%s", outbuf); | 2198 fprintf(stderr, "%s", outbuf); |
2199 } | 2199 } |
2200 | 2200 |
2201 /* | 2201 /* |
2202 * Displays a Message Box with given text and title.. | 2202 * Displays a Message Box with given text and title.. |
2439 /* If we had a position request before shown */ | 2439 /* If we had a position request before shown */ |
2440 if (g_object_get_data(G_OBJECT(handle), "_dw_pos")) | 2440 if (g_object_get_data(G_OBJECT(handle), "_dw_pos")) |
2441 { | 2441 { |
2442 int x = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_x")); | 2442 int x = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_x")); |
2443 int y = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_y")); | 2443 int y = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_y")); |
2444 | 2444 |
2445 /* Call the position function again now that we are realized */ | 2445 /* Call the position function again now that we are realized */ |
2446 dw_window_set_pos(handle, x, y); | 2446 dw_window_set_pos(handle, x, y); |
2447 /* Clear out the data so we don't do it again */ | 2447 /* Clear out the data so we don't do it again */ |
2448 g_object_set_data(G_OBJECT(handle), "_dw_pos", NULL); | 2448 g_object_set_data(G_OBJECT(handle), "_dw_pos", NULL); |
2449 } | 2449 } |
2518 | 2518 |
2519 /* Handle the invisible event box if it exists */ | 2519 /* Handle the invisible event box if it exists */ |
2520 if(eventbox && GTK_IS_WIDGET(eventbox)) | 2520 if(eventbox && GTK_IS_WIDGET(eventbox)) |
2521 handle2 = eventbox; | 2521 handle2 = eventbox; |
2522 | 2522 |
2523 /* Check if we are removing a widget from a box */ | 2523 /* Check if we are removing a widget from a box */ |
2524 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) | 2524 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) |
2525 { | 2525 { |
2526 /* Get the number of items in the box... */ | 2526 /* Get the number of items in the box... */ |
2527 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); | 2527 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); |
2528 #if GTK_CHECK_VERSION(3,10,0) | 2528 #if GTK_CHECK_VERSION(3,10,0) |
2529 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); | 2529 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); |
2530 int z; | 2530 int z; |
2531 | 2531 |
2532 /* Figure out where in the grid this widget is and remove that row/column */ | 2532 /* Figure out where in the grid this widget is and remove that row/column */ |
2533 if(boxtype == DW_VERT) | 2533 if(boxtype == DW_VERT) |
2534 { | 2534 { |
2535 for(z=0;z<boxcount;z++) | 2535 for(z=0;z<boxcount;z++) |
2536 { | 2536 { |
2559 /* Decrease the count by 1 */ | 2559 /* Decrease the count by 1 */ |
2560 boxcount--; | 2560 boxcount--; |
2561 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); | 2561 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); |
2562 } | 2562 } |
2563 } | 2563 } |
2564 /* Finally destroy the widget */ | 2564 /* Finally destroy the widget */ |
2565 gtk_widget_destroy(handle2); | 2565 gtk_widget_destroy(handle2); |
2566 } | 2566 } |
2567 DW_MUTEX_UNLOCK; | 2567 DW_MUTEX_UNLOCK; |
2568 return 0; | 2568 return 0; |
2569 } | 2569 } |
2597 * fontname: Font name in Dynamic Windows format. | 2597 * fontname: Font name in Dynamic Windows format. |
2598 */ | 2598 */ |
2599 void API dw_font_set_default(char *fontname) | 2599 void API dw_font_set_default(char *fontname) |
2600 { | 2600 { |
2601 char *oldfont = _DWDefaultFont; | 2601 char *oldfont = _DWDefaultFont; |
2602 | 2602 |
2603 _DWDefaultFont = strdup(fontname); | 2603 _DWDefaultFont = strdup(fontname); |
2604 | 2604 |
2605 if(oldfont) | 2605 if(oldfont) |
2606 free(oldfont); | 2606 free(oldfont); |
2607 } | 2607 } |
2608 | 2608 |
2609 /* Convert DW style font to pango style */ | 2609 /* Convert DW style font to pango style */ |
2693 g_object_set_data(G_OBJECT(handle2), "_dw_fontname", (gpointer)font); | 2693 g_object_set_data(G_OBJECT(handle2), "_dw_fontname", (gpointer)font); |
2694 if(data) | 2694 if(data) |
2695 free(data); | 2695 free(data); |
2696 | 2696 |
2697 _dw_override_font(handle2, font); | 2697 _dw_override_font(handle2, font); |
2698 | 2698 |
2699 DW_MUTEX_UNLOCK; | 2699 DW_MUTEX_UNLOCK; |
2700 return TRUE; | 2700 return TRUE; |
2701 } | 2701 } |
2702 | 2702 |
2703 /* Allows the user to choose a font using the system's font chooser dialog. | 2703 /* Allows the user to choose a font using the system's font chooser dialog. |
2731 if(font) | 2731 if(font) |
2732 { | 2732 { |
2733 gtk_font_chooser_set_font(fd, font); | 2733 gtk_font_chooser_set_font(fd, font); |
2734 free(font); | 2734 free(font); |
2735 } | 2735 } |
2736 | 2736 |
2737 gtk_widget_show(GTK_WIDGET(fd)); | 2737 gtk_widget_show(GTK_WIDGET(fd)); |
2738 | 2738 |
2739 if(gtk_dialog_run(GTK_DIALOG(fd)) == GTK_RESPONSE_OK) | 2739 if(gtk_dialog_run(GTK_DIALOG(fd)) == GTK_RESPONSE_OK) |
2740 { | 2740 { |
2741 char *fontname = gtk_font_chooser_get_font(fd); | 2741 char *fontname = gtk_font_chooser_get_font(fd); |
2742 if(fontname && (retfont = strdup(fontname))) | 2742 if(fontname && (retfont = strdup(fontname))) |
2743 { | 2743 { |
2744 int len = strlen(fontname); | 2744 int len = strlen(fontname); |
2745 /* Convert to Dynamic Windows format if we can... */ | 2745 /* Convert to Dynamic Windows format if we can... */ |
2746 if(len > 0 && isdigit(fontname[len-1])) | 2746 if(len > 0 && isdigit(fontname[len-1])) |
2747 { | 2747 { |
2748 int size, x=len-1; | 2748 int size, x=len-1; |
2749 | 2749 |
2750 while(x > 0 && fontname[x] != ' ') | 2750 while(x > 0 && fontname[x] != ' ') |
2751 { | 2751 { |
2752 x--; | 2752 x--; |
2753 } | 2753 } |
2754 size = atoi(&fontname[x]); | 2754 size = atoi(&fontname[x]); |
2880 forecolor.green = (gdouble)DW_GREEN_VALUE(fore) / 255.0; | 2880 forecolor.green = (gdouble)DW_GREEN_VALUE(fore) / 255.0; |
2881 forecolor.blue = (gdouble)DW_BLUE_VALUE(fore) / 255.0; | 2881 forecolor.blue = (gdouble)DW_BLUE_VALUE(fore) / 255.0; |
2882 } | 2882 } |
2883 else if(fore != DW_CLR_DEFAULT) | 2883 else if(fore != DW_CLR_DEFAULT) |
2884 forecolor = _colors[fore]; | 2884 forecolor = _colors[fore]; |
2885 | 2885 |
2886 _dw_override_color(handle, "color", fore != DW_CLR_DEFAULT ? &forecolor : NULL); | 2886 _dw_override_color(handle, "color", fore != DW_CLR_DEFAULT ? &forecolor : NULL); |
2887 | 2887 |
2888 if(back & DW_RGB_COLOR) | 2888 if(back & DW_RGB_COLOR) |
2889 { | 2889 { |
2890 backcolor.alpha = 1.0; | 2890 backcolor.alpha = 1.0; |
2891 backcolor.red = (gdouble)DW_RED_VALUE(back) / 255.0; | 2891 backcolor.red = (gdouble)DW_RED_VALUE(back) / 255.0; |
2892 backcolor.green = (gdouble)DW_GREEN_VALUE(back) / 255.0; | 2892 backcolor.green = (gdouble)DW_GREEN_VALUE(back) / 255.0; |
2893 backcolor.blue = (gdouble)DW_BLUE_VALUE(back) / 255.0; | 2893 backcolor.blue = (gdouble)DW_BLUE_VALUE(back) / 255.0; |
2894 } | 2894 } |
2895 else if(back != DW_CLR_DEFAULT) | 2895 else if(back != DW_CLR_DEFAULT) |
2896 backcolor = _colors[back]; | 2896 backcolor = _colors[back]; |
2897 | 2897 |
2898 _dw_override_color(handle, "background-color", back != DW_CLR_DEFAULT ? &backcolor : NULL); | 2898 _dw_override_color(handle, "background-color", back != DW_CLR_DEFAULT ? &backcolor : NULL); |
2899 | 2899 |
2900 _save_gdk_colors(handle, forecolor, backcolor); | 2900 _save_gdk_colors(handle, forecolor, backcolor); |
2901 | 2901 |
2902 return TRUE; | 2902 return TRUE; |
2974 #else | 2974 #else |
2975 _dw_grab_manager = gdk_display_get_device_manager(gtk_widget_get_display(handle)); | 2975 _dw_grab_manager = gdk_display_get_device_manager(gtk_widget_get_display(handle)); |
2976 gdk_device_grab(gdk_device_manager_get_client_pointer(manager), | 2976 gdk_device_grab(gdk_device_manager_get_client_pointer(manager), |
2977 gtk_widget_get_window(handle), | 2977 gtk_widget_get_window(handle), |
2978 GDK_OWNERSHIP_WINDOW, | 2978 GDK_OWNERSHIP_WINDOW, |
2979 FALSE, | 2979 FALSE, |
2980 GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, | 2980 GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, |
2981 NULL, | 2981 NULL, |
2982 GDK_CURRENT_TIME); | 2982 GDK_CURRENT_TIME); |
2983 #endif | 2983 #endif |
2984 DW_MUTEX_UNLOCK; | 2984 DW_MUTEX_UNLOCK; |
2985 } | 2985 } |
2986 | 2986 |
3022 DW_MUTEX_LOCK; | 3022 DW_MUTEX_LOCK; |
3023 #if GTK_CHECK_VERSION(3,20,0) | 3023 #if GTK_CHECK_VERSION(3,20,0) |
3024 if(_dw_grab_seat) | 3024 if(_dw_grab_seat) |
3025 gdk_seat_ungrab(_dw_grab_seat); | 3025 gdk_seat_ungrab(_dw_grab_seat); |
3026 _dw_grab_seat = NULL; | 3026 _dw_grab_seat = NULL; |
3027 #else | 3027 #else |
3028 gdk_device_ungrab(gdk_device_manager_get_client_pointer(manager), GDK_CURRENT_TIME); | 3028 gdk_device_ungrab(gdk_device_manager_get_client_pointer(manager), GDK_CURRENT_TIME); |
3029 manager = NULL; | 3029 manager = NULL; |
3030 #endif | 3030 #endif |
3031 DW_MUTEX_UNLOCK; | 3031 DW_MUTEX_UNLOCK; |
3032 } | 3032 } |
3033 | 3033 |
3034 /* | 3034 /* |
3035 * Create a new Window Frame. | 3035 * Create a new Window Frame. |
3065 { | 3065 { |
3066 GtkWidget *box = dw_box_new(DW_VERT, 0); | 3066 GtkWidget *box = dw_box_new(DW_VERT, 0); |
3067 GtkWidget *grid = gtk_grid_new(); | 3067 GtkWidget *grid = gtk_grid_new(); |
3068 | 3068 |
3069 gtk_widget_show_all(grid); | 3069 gtk_widget_show_all(grid); |
3070 | 3070 |
3071 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 3071 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3072 | 3072 |
3073 gtk_window_set_title(GTK_WINDOW(tmp), title); | 3073 gtk_window_set_title(GTK_WINDOW(tmp), title); |
3074 gtk_window_set_resizable(GTK_WINDOW(tmp), (flStyle & DW_FCF_SIZEBORDER) ? TRUE : FALSE); | 3074 gtk_window_set_resizable(GTK_WINDOW(tmp), (flStyle & DW_FCF_SIZEBORDER) ? TRUE : FALSE); |
3075 | 3075 |
3085 flags |= GDK_DECOR_RESIZEH | GDK_DECOR_BORDER; | 3085 flags |= GDK_DECOR_RESIZEH | GDK_DECOR_BORDER; |
3086 | 3086 |
3087 if(flStyle & (DW_FCF_BORDER | DW_FCF_DLGBORDER)) | 3087 if(flStyle & (DW_FCF_BORDER | DW_FCF_DLGBORDER)) |
3088 flags |= GDK_DECOR_BORDER; | 3088 flags |= GDK_DECOR_BORDER; |
3089 | 3089 |
3090 if(flStyle & DW_FCF_MAXIMIZE) | 3090 if(flStyle & DW_FCF_FULLSCREEN) |
3091 gtk_window_maximize(GTK_WINDOW(tmp)); | 3091 gtk_window_fullscreen(GTK_WINDOW(tmp)); |
3092 | 3092 else |
3093 if(flStyle & DW_FCF_MINIMIZE) | 3093 { |
3094 gtk_window_iconify(GTK_WINDOW(tmp)); | 3094 if(flStyle & DW_FCF_MAXIMIZE) |
3095 | 3095 gtk_window_maximize(GTK_WINDOW(tmp)); |
3096 | |
3097 if(flStyle & DW_FCF_MINIMIZE) | |
3098 gtk_window_iconify(GTK_WINDOW(tmp)); | |
3099 } | |
3100 | |
3096 /* Either the CLOSEBUTTON or SYSMENU flags should make it deletable */ | 3101 /* Either the CLOSEBUTTON or SYSMENU flags should make it deletable */ |
3097 gtk_window_set_deletable(GTK_WINDOW(tmp), (flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU)) ? TRUE : FALSE); | 3102 gtk_window_set_deletable(GTK_WINDOW(tmp), (flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU)) ? TRUE : FALSE); |
3098 | 3103 |
3099 gdk_window_set_decorations(gtk_widget_get_window(tmp), flags); | 3104 gdk_window_set_decorations(gtk_widget_get_window(tmp), flags); |
3100 if(!flags) | 3105 if(!flags) |
3103 if(hwndOwner) | 3108 if(hwndOwner) |
3104 gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(tmp)), gtk_widget_get_window(GTK_WIDGET(hwndOwner)), 0, 0); | 3109 gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(tmp)), gtk_widget_get_window(GTK_WIDGET(hwndOwner)), 0, 0); |
3105 | 3110 |
3106 if(flStyle & DW_FCF_SIZEBORDER) | 3111 if(flStyle & DW_FCF_SIZEBORDER) |
3107 g_object_set_data(G_OBJECT(tmp), "_dw_size", GINT_TO_POINTER(1)); | 3112 g_object_set_data(G_OBJECT(tmp), "_dw_size", GINT_TO_POINTER(1)); |
3108 | 3113 |
3109 gtk_grid_attach(GTK_GRID(grid), box, 0, 1, 1, 1); | 3114 gtk_grid_attach(GTK_GRID(grid), box, 0, 1, 1, 1); |
3110 gtk_container_add(GTK_CONTAINER(tmp), grid); | 3115 gtk_container_add(GTK_CONTAINER(tmp), grid); |
3111 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box); | 3116 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box); |
3112 g_object_set_data(G_OBJECT(tmp), "_dw_grid", (gpointer)grid); | 3117 g_object_set_data(G_OBJECT(tmp), "_dw_grid", (gpointer)grid); |
3113 gtk_widget_add_events(GTK_WIDGET(tmp), GDK_PROPERTY_CHANGE_MASK); | 3118 gtk_widget_add_events(GTK_WIDGET(tmp), GDK_PROPERTY_CHANGE_MASK); |
3358 GtkAccelGroup *accel_group; | 3363 GtkAccelGroup *accel_group; |
3359 GtkWidget *box; | 3364 GtkWidget *box; |
3360 HMENUI tmp = 0; | 3365 HMENUI tmp = 0; |
3361 | 3366 |
3362 DW_MUTEX_LOCK; | 3367 DW_MUTEX_LOCK; |
3363 if(GTK_IS_WINDOW(location) && | 3368 if(GTK_IS_WINDOW(location) && |
3364 (box = (GtkWidget *)g_object_get_data(G_OBJECT(location), "_dw_grid"))) | 3369 (box = (GtkWidget *)g_object_get_data(G_OBJECT(location), "_dw_grid"))) |
3365 { | 3370 { |
3366 /* If there is an existing menu bar, remove it */ | 3371 /* If there is an existing menu bar, remove it */ |
3367 GtkWidget *oldmenu = (GtkWidget *)g_object_get_data(G_OBJECT(location), "_dw_menubar"); | 3372 GtkWidget *oldmenu = (GtkWidget *)g_object_get_data(G_OBJECT(location), "_dw_menubar"); |
3368 if(oldmenu) | 3373 if(oldmenu) |
3638 /* | 3643 /* |
3639 * Deletes the menu item specified. | 3644 * Deletes the menu item specified. |
3640 * Parameters: | 3645 * Parameters: |
3641 * menu: The handle to the menu in which the item was appended. | 3646 * menu: The handle to the menu in which the item was appended. |
3642 * id: Menuitem id. | 3647 * id: Menuitem id. |
3643 * Returns: | 3648 * Returns: |
3644 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. | 3649 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. |
3645 */ | 3650 */ |
3646 int API dw_menu_delete_item(HMENUI menu, unsigned long id) | 3651 int API dw_menu_delete_item(HMENUI menu, unsigned long id) |
3647 { | 3652 { |
3648 char numbuf[11]; | 3653 char numbuf[11]; |
3710 GdkDevice *device; | 3715 GdkDevice *device; |
3711 #if GTK_CHECK_VERSION(3,20,0) | 3716 #if GTK_CHECK_VERSION(3,20,0) |
3712 GdkSeat *seat; | 3717 GdkSeat *seat; |
3713 #else | 3718 #else |
3714 GdkDeviceManager *manager; | 3719 GdkDeviceManager *manager; |
3715 #endif | 3720 #endif |
3716 | 3721 |
3717 DW_MUTEX_LOCK; | 3722 DW_MUTEX_LOCK; |
3718 #ifdef GDK_WINDOWING_X11 | 3723 #ifdef GDK_WINDOWING_X11 |
3719 display = gdk_display_get_default(); | 3724 display = gdk_display_get_default(); |
3720 #if GTK_CHECK_VERSION(3,20,0) | 3725 #if GTK_CHECK_VERSION(3,20,0) |
3722 device = gdk_seat_get_pointer(seat); | 3727 device = gdk_seat_get_pointer(seat); |
3723 #else | 3728 #else |
3724 manager = gdk_display_get_device_manager(display); | 3729 manager = gdk_display_get_device_manager(display); |
3725 device = gdk_device_manager_get_client_pointer(manager); | 3730 device = gdk_device_manager_get_client_pointer(manager); |
3726 #endif | 3731 #endif |
3727 gdk_window_get_device_position(gdk_x11_window_lookup_for_display(display, GDK_ROOT_WINDOW()), | 3732 gdk_window_get_device_position(gdk_x11_window_lookup_for_display(display, GDK_ROOT_WINDOW()), |
3728 device, &gx, &gy, &state); | 3733 device, &gx, &gy, &state); |
3729 #endif | 3734 #endif |
3730 if(x) | 3735 if(x) |
3731 *x = gx; | 3736 *x = gx; |
3732 if(y) | 3737 if(y) |
3747 GdkDevice *device; | 3752 GdkDevice *device; |
3748 #if GTK_CHECK_VERSION(3,20,0) | 3753 #if GTK_CHECK_VERSION(3,20,0) |
3749 GdkSeat *seat; | 3754 GdkSeat *seat; |
3750 #else | 3755 #else |
3751 GdkDeviceManager *manager; | 3756 GdkDeviceManager *manager; |
3752 #endif | 3757 #endif |
3753 | 3758 |
3754 DW_MUTEX_LOCK; | 3759 DW_MUTEX_LOCK; |
3755 #ifdef GDK_WINDOWING_X11 | 3760 #ifdef GDK_WINDOWING_X11 |
3756 display = gdk_display_get_default(); | 3761 display = gdk_display_get_default(); |
3757 #if GTK_CHECK_VERSION(3,20,0) | 3762 #if GTK_CHECK_VERSION(3,20,0) |
3881 | 3886 |
3882 DW_MUTEX_LOCK; | 3887 DW_MUTEX_LOCK; |
3883 tmp = gtk_label_new(text); | 3888 tmp = gtk_label_new(text); |
3884 | 3889 |
3885 /* Left and centered */ | 3890 /* Left and centered */ |
3886 #if GTK_CHECK_VERSION(3,16,0) | 3891 #if GTK_CHECK_VERSION(3,16,0) |
3887 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f); | 3892 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f); |
3888 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f); | 3893 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f); |
3889 #else | 3894 #else |
3890 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); | 3895 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3891 #endif | 3896 #endif |
3915 gtk_container_add(GTK_CONTAINER(frame), tmp); | 3920 gtk_container_add(GTK_CONTAINER(frame), tmp); |
3916 gtk_widget_show(tmp); | 3921 gtk_widget_show(tmp); |
3917 gtk_widget_show(frame); | 3922 gtk_widget_show(frame); |
3918 | 3923 |
3919 /* Left and centered */ | 3924 /* Left and centered */ |
3920 #if GTK_CHECK_VERSION(3,16,0) | 3925 #if GTK_CHECK_VERSION(3,16,0) |
3921 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f); | 3926 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f); |
3922 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f); | 3927 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f); |
3923 #else | 3928 #else |
3924 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); | 3929 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3925 #endif | 3930 #endif |
4608 DW_MUTEX_LOCK; | 4613 DW_MUTEX_LOCK; |
4609 if(GTK_IS_ENTRY(handle)) | 4614 if(GTK_IS_ENTRY(handle)) |
4610 possible = gtk_entry_get_text(GTK_ENTRY(handle)); | 4615 possible = gtk_entry_get_text(GTK_ENTRY(handle)); |
4611 else if(GTK_IS_COMBO_BOX(handle)) | 4616 else if(GTK_IS_COMBO_BOX(handle)) |
4612 possible = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(handle)))); | 4617 possible = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(handle)))); |
4618 else if(GTK_IS_LABEL(handle)) | |
4619 possible = gtk_label_get_text(GTK_LABEL(handle)); | |
4613 | 4620 |
4614 DW_MUTEX_UNLOCK; | 4621 DW_MUTEX_UNLOCK; |
4615 return strdup(possible ? possible : ""); | 4622 return strdup(possible ? possible : ""); |
4616 } | 4623 } |
4617 | 4624 |
5018 void dw_mle_thaw(HWND handle) | 5025 void dw_mle_thaw(HWND handle) |
5019 { | 5026 { |
5020 } | 5027 } |
5021 | 5028 |
5022 /* Internal function to update the progress bar | 5029 /* Internal function to update the progress bar |
5023 * while in an indeterminate state. | 5030 * while in an indeterminate state. |
5024 */ | 5031 */ |
5025 gboolean _dw_update_progress_bar(gpointer data) | 5032 gboolean _dw_update_progress_bar(gpointer data) |
5026 { | 5033 { |
5027 if(g_object_get_data(G_OBJECT(data), "_dw_alive")) | 5034 if(g_object_get_data(G_OBJECT(data), "_dw_alive")) |
5028 { | 5035 { |
5485 (store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree)))) | 5492 (store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree)))) |
5486 { | 5493 { |
5487 GtkTreeIter iter; | 5494 GtkTreeIter iter; |
5488 | 5495 |
5489 if(gtk_tree_model_iter_parent(store, &iter, (GtkTreeIter *)item)) | 5496 if(gtk_tree_model_iter_parent(store, &iter, (GtkTreeIter *)item)) |
5490 gtk_tree_model_get(store, &iter, 3, &parent, -1); | 5497 gtk_tree_model_get(store, &iter, 3, &parent, -1); |
5491 } | 5498 } |
5492 DW_MUTEX_UNLOCK; | 5499 DW_MUTEX_UNLOCK; |
5493 return parent; | 5500 return parent; |
5494 } | 5501 } |
5495 | 5502 |
5904 { | 5911 { |
5905 if(ret) | 5912 if(ret) |
5906 { | 5913 { |
5907 int pwidth = gdk_pixbuf_get_width(ret); | 5914 int pwidth = gdk_pixbuf_get_width(ret); |
5908 int pheight = gdk_pixbuf_get_height(ret); | 5915 int pheight = gdk_pixbuf_get_height(ret); |
5909 | 5916 |
5910 if(pwidth > 24 || pheight > 24) | 5917 if(pwidth > 24 || pheight > 24) |
5911 { | 5918 { |
5912 GdkPixbuf *orig = ret; | 5919 GdkPixbuf *orig = ret; |
5913 ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR); | 5920 ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR); |
5914 g_object_unref(G_OBJECT(orig)); | 5921 g_object_unref(G_OBJECT(orig)); |
6289 * DW_RGB_TRANSPARENT will disable coloring rows. | 6296 * DW_RGB_TRANSPARENT will disable coloring rows. |
6290 * DW_CLR_DEFAULT will use the system default alternating row colors. | 6297 * DW_CLR_DEFAULT will use the system default alternating row colors. |
6291 */ | 6298 */ |
6292 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor) | 6299 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor) |
6293 { | 6300 { |
6294 #if !GTK_CHECK_VERSION(3,14,0) | 6301 #if !GTK_CHECK_VERSION(3,14,0) |
6295 GtkWidget *cont; | 6302 GtkWidget *cont; |
6296 int _locked_by_me = FALSE; | 6303 int _locked_by_me = FALSE; |
6297 DW_MUTEX_LOCK; | 6304 DW_MUTEX_LOCK; |
6298 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); | 6305 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); |
6299 | 6306 |
6300 /* Make sure it is the correct tree type */ | 6307 /* Make sure it is the correct tree type */ |
6301 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) | 6308 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) |
6302 { | 6309 { |
6303 if(oddcolor == DW_RGB_TRANSPARENT && evencolor == DW_RGB_TRANSPARENT) | 6310 if(oddcolor == DW_RGB_TRANSPARENT && evencolor == DW_RGB_TRANSPARENT) |
6304 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(cont), FALSE); | 6311 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(cont), FALSE); |
6305 else | 6312 else |
6306 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(cont), TRUE); | 6313 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(cont), TRUE); |
6307 } | 6314 } |
6308 DW_MUTEX_UNLOCK; | 6315 DW_MUTEX_UNLOCK; |
6309 #endif | 6316 #endif |
6310 } | 6317 } |
6311 | 6318 |
6312 /* | 6319 /* |
6313 * Sets the width of a column in the container. | 6320 * Sets the width of a column in the container. |
6314 * Parameters: | 6321 * Parameters: |
6321 GtkWidget *cont; | 6328 GtkWidget *cont; |
6322 int _locked_by_me = FALSE; | 6329 int _locked_by_me = FALSE; |
6323 | 6330 |
6324 DW_MUTEX_LOCK; | 6331 DW_MUTEX_LOCK; |
6325 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); | 6332 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); |
6326 | 6333 |
6327 /* Make sure it is the correct tree type */ | 6334 /* Make sure it is the correct tree type */ |
6328 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) | 6335 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) |
6329 { | 6336 { |
6330 GtkTreeViewColumn *col = gtk_tree_view_get_column(GTK_TREE_VIEW(cont), column); | 6337 GtkTreeViewColumn *col = gtk_tree_view_get_column(GTK_TREE_VIEW(cont), column); |
6331 | 6338 |
6901 static void _status_translate(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data) | 6908 static void _status_translate(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data) |
6902 { | 6909 { |
6903 GdkEventButton event = { 0 }; | 6910 GdkEventButton event = { 0 }; |
6904 long x, y; | 6911 long x, y; |
6905 gboolean retval; | 6912 gboolean retval; |
6906 | 6913 |
6907 dw_pointer_query_pos(&x, &y); | 6914 dw_pointer_query_pos(&x, &y); |
6908 | 6915 |
6909 event.button = button; | 6916 event.button = button; |
6910 event.x = x; | 6917 event.x = x; |
6911 event.y = y; | 6918 event.y = y; |
6912 | 6919 |
6913 g_signal_emit_by_name(G_OBJECT(user_data), "button_press_event", &event, &retval); | 6920 g_signal_emit_by_name(G_OBJECT(user_data), "button_press_event", &event, &retval); |
6914 } | 6921 } |
6915 | 6922 |
6916 /* | 6923 /* |
6917 * Inserts an icon into the taskbar. | 6924 * Inserts an icon into the taskbar. |
6931 status = gtk_status_icon_new_from_pixbuf(pixbuf); | 6938 status = gtk_status_icon_new_from_pixbuf(pixbuf); |
6932 if(bubbletext) | 6939 if(bubbletext) |
6933 gtk_status_icon_set_tooltip_text(status, bubbletext); | 6940 gtk_status_icon_set_tooltip_text(status, bubbletext); |
6934 g_object_set_data(G_OBJECT(handle), "_dw_taskbar", status); | 6941 g_object_set_data(G_OBJECT(handle), "_dw_taskbar", status); |
6935 g_signal_connect(G_OBJECT (status), "popup-menu", G_CALLBACK (_status_translate), handle); | 6942 g_signal_connect(G_OBJECT (status), "popup-menu", G_CALLBACK (_status_translate), handle); |
6936 gtk_status_icon_set_visible(status, TRUE); | 6943 gtk_status_icon_set_visible(status, TRUE); |
6937 DW_MUTEX_UNLOCK; | 6944 DW_MUTEX_UNLOCK; |
6938 } | 6945 } |
6939 | 6946 |
6940 /* | 6947 /* |
6941 * Deletes an icon from the taskbar. | 6948 * Deletes an icon from the taskbar. |
6942 * Parameters: | 6949 * Parameters: |
7040 } | 7047 } |
7041 *background = color; | 7048 *background = color; |
7042 } | 7049 } |
7043 } | 7050 } |
7044 | 7051 |
7045 #if GTK_CHECK_VERSION(3,3,11) | 7052 #if GTK_CHECK_VERSION(3,3,11) |
7046 /* Allows the user to choose a color using the system's color chooser dialog. | 7053 /* Allows the user to choose a color using the system's color chooser dialog. |
7047 * Parameters: | 7054 * Parameters: |
7048 * value: current color | 7055 * value: current color |
7049 * Returns: | 7056 * Returns: |
7050 * The selected color or the current color if cancelled. | 7057 * The selected color or the current color if cancelled. |
7058 | 7065 |
7059 DW_MUTEX_LOCK; | 7066 DW_MUTEX_LOCK; |
7060 cd = (GtkColorChooser *)gtk_color_chooser_dialog_new("Choose color", NULL); | 7067 cd = (GtkColorChooser *)gtk_color_chooser_dialog_new("Choose color", NULL); |
7061 gtk_color_chooser_set_use_alpha(cd, FALSE); | 7068 gtk_color_chooser_set_use_alpha(cd, FALSE); |
7062 gtk_color_chooser_set_rgba(cd, &color); | 7069 gtk_color_chooser_set_rgba(cd, &color); |
7063 | 7070 |
7064 gtk_widget_show(GTK_WIDGET(cd)); | 7071 gtk_widget_show(GTK_WIDGET(cd)); |
7065 | 7072 |
7066 if(gtk_dialog_run(GTK_DIALOG(cd)) == GTK_RESPONSE_OK) | 7073 if(gtk_dialog_run(GTK_DIALOG(cd)) == GTK_RESPONSE_OK) |
7067 { | 7074 { |
7068 gtk_color_chooser_get_rgba(cd, &color); | 7075 gtk_color_chooser_get_rgba(cd, &color); |
7069 retcolor = DW_RGB((int)(color.red * 255), (int)(color.green * 255), (int)(color.blue * 255)); | 7076 retcolor = DW_RGB((int)(color.red * 255), (int)(color.green * 255), (int)(color.blue * 255)); |
7070 } | 7077 } |
7071 gtk_widget_destroy(GTK_WIDGET(cd)); | 7078 gtk_widget_destroy(GTK_WIDGET(cd)); |
7072 DW_MUTEX_UNLOCK; | 7079 DW_MUTEX_UNLOCK; |
7073 return retcolor; | 7080 return retcolor; |
7074 } | 7081 } |
7075 #else | 7082 #else |
7076 static int _dw_color_active = 0; | 7083 static int _dw_color_active = 0; |
7077 | 7084 |
7078 /* Internal function to handle the color OK press */ | 7085 /* Internal function to handle the color OK press */ |
7079 static gint _gtk_color_ok(GtkWidget *widget, DWDialog *dwwait) | 7086 static gint _gtk_color_ok(GtkWidget *widget, DWDialog *dwwait) |
7080 { | 7087 { |
7185 } | 7192 } |
7186 #if GTK_CHECK_VERSION(3,22,0) | 7193 #if GTK_CHECK_VERSION(3,22,0) |
7187 clip = gdk_window_get_clip_region(window); | 7194 clip = gdk_window_get_clip_region(window); |
7188 dc = gdk_window_begin_draw_frame(window, clip); | 7195 dc = gdk_window_begin_draw_frame(window, clip); |
7189 cr = gdk_drawing_context_get_cairo_context(dc); | 7196 cr = gdk_drawing_context_get_cairo_context(dc); |
7190 #else | 7197 #else |
7191 cr = gdk_cairo_create(window); | 7198 cr = gdk_cairo_create(window); |
7192 #endif | 7199 #endif |
7193 } | 7200 } |
7194 else if(pixmap) | 7201 else if(pixmap) |
7195 cr = cairo_create(pixmap->image); | 7202 cr = cairo_create(pixmap->image); |
7196 if(cr) | 7203 if(cr) |
7197 { | 7204 { |
7207 /* If we are using a drawing context... | 7214 /* If we are using a drawing context... |
7208 * we don't own the cairo context so don't destroy it. | 7215 * we don't own the cairo context so don't destroy it. |
7209 */ | 7216 */ |
7210 if(dc) | 7217 if(dc) |
7211 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); | 7218 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); |
7212 else | 7219 else |
7213 #endif | 7220 #endif |
7214 cairo_destroy(cr); | 7221 cairo_destroy(cr); |
7215 } | 7222 } |
7216 DW_MUTEX_UNLOCK; | 7223 DW_MUTEX_UNLOCK; |
7217 } | 7224 } |
7218 | 7225 |
7246 } | 7253 } |
7247 #if GTK_CHECK_VERSION(3,22,0) | 7254 #if GTK_CHECK_VERSION(3,22,0) |
7248 clip = gdk_window_get_clip_region(window); | 7255 clip = gdk_window_get_clip_region(window); |
7249 dc = gdk_window_begin_draw_frame(window, clip); | 7256 dc = gdk_window_begin_draw_frame(window, clip); |
7250 cr = gdk_drawing_context_get_cairo_context(dc); | 7257 cr = gdk_drawing_context_get_cairo_context(dc); |
7251 #else | 7258 #else |
7252 cr = gdk_cairo_create(window); | 7259 cr = gdk_cairo_create(window); |
7253 #endif | 7260 #endif |
7254 } | 7261 } |
7255 else if(pixmap) | 7262 else if(pixmap) |
7256 cr = cairo_create(pixmap->image); | 7263 cr = cairo_create(pixmap->image); |
7257 if(cr) | 7264 if(cr) |
7258 { | 7265 { |
7269 /* If we are using a drawing context... | 7276 /* If we are using a drawing context... |
7270 * we don't own the cairo context so don't destroy it. | 7277 * we don't own the cairo context so don't destroy it. |
7271 */ | 7278 */ |
7272 if(dc) | 7279 if(dc) |
7273 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); | 7280 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); |
7274 else | 7281 else |
7275 #endif | 7282 #endif |
7276 cairo_destroy(cr); | 7283 cairo_destroy(cr); |
7277 } | 7284 } |
7278 DW_MUTEX_UNLOCK; | 7285 DW_MUTEX_UNLOCK; |
7279 } | 7286 } |
7280 | 7287 |
7309 } | 7316 } |
7310 #if GTK_CHECK_VERSION(3,22,0) | 7317 #if GTK_CHECK_VERSION(3,22,0) |
7311 clip = gdk_window_get_clip_region(window); | 7318 clip = gdk_window_get_clip_region(window); |
7312 dc = gdk_window_begin_draw_frame(window, clip); | 7319 dc = gdk_window_begin_draw_frame(window, clip); |
7313 cr = gdk_drawing_context_get_cairo_context(dc); | 7320 cr = gdk_drawing_context_get_cairo_context(dc); |
7314 #else | 7321 #else |
7315 cr = gdk_cairo_create(window); | 7322 cr = gdk_cairo_create(window); |
7316 #endif | 7323 #endif |
7317 } | 7324 } |
7318 else if(pixmap) | 7325 else if(pixmap) |
7319 cr = cairo_create(pixmap->image); | 7326 cr = cairo_create(pixmap->image); |
7320 if(cr) | 7327 if(cr) |
7321 { | 7328 { |
7322 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key); | 7329 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key); |
7323 | 7330 |
7324 if(flags & DW_DRAW_NOAA) | 7331 if(flags & DW_DRAW_NOAA) |
7325 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); | 7332 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); |
7326 | 7333 |
7327 gdk_cairo_set_source_rgba(cr, foreground); | 7334 gdk_cairo_set_source_rgba(cr, foreground); |
7328 cairo_set_line_width(cr, 1); | 7335 cairo_set_line_width(cr, 1); |
7329 cairo_move_to(cr, x[0], y[0]); | 7336 cairo_move_to(cr, x[0], y[0]); |
7330 for(z=1;z<npoints;z++) | 7337 for(z=1;z<npoints;z++) |
7331 { | 7338 { |
7340 /* If we are using a drawing context... | 7347 /* If we are using a drawing context... |
7341 * we don't own the cairo context so don't destroy it. | 7348 * we don't own the cairo context so don't destroy it. |
7342 */ | 7349 */ |
7343 if(dc) | 7350 if(dc) |
7344 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); | 7351 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); |
7345 else | 7352 else |
7346 #endif | 7353 #endif |
7347 cairo_destroy(cr); | 7354 cairo_destroy(cr); |
7348 } | 7355 } |
7349 DW_MUTEX_UNLOCK; | 7356 DW_MUTEX_UNLOCK; |
7350 } | 7357 } |
7351 | 7358 |
7380 } | 7387 } |
7381 #if GTK_CHECK_VERSION(3,22,0) | 7388 #if GTK_CHECK_VERSION(3,22,0) |
7382 clip = gdk_window_get_clip_region(window); | 7389 clip = gdk_window_get_clip_region(window); |
7383 dc = gdk_window_begin_draw_frame(window, clip); | 7390 dc = gdk_window_begin_draw_frame(window, clip); |
7384 cr = gdk_drawing_context_get_cairo_context(dc); | 7391 cr = gdk_drawing_context_get_cairo_context(dc); |
7385 #else | 7392 #else |
7386 cr = gdk_cairo_create(window); | 7393 cr = gdk_cairo_create(window); |
7387 #endif | 7394 #endif |
7388 } | 7395 } |
7389 else if(pixmap) | 7396 else if(pixmap) |
7390 cr = cairo_create(pixmap->image); | 7397 cr = cairo_create(pixmap->image); |
7391 if(cr) | 7398 if(cr) |
7392 { | 7399 { |
7393 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key); | 7400 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key); |
7394 | 7401 |
7395 if(flags & DW_DRAW_NOAA) | 7402 if(flags & DW_DRAW_NOAA) |
7396 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); | 7403 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); |
7397 | 7404 |
7398 gdk_cairo_set_source_rgba(cr, foreground); | 7405 gdk_cairo_set_source_rgba(cr, foreground); |
7399 cairo_set_line_width(cr, 1); | 7406 cairo_set_line_width(cr, 1); |
7400 cairo_move_to(cr, x, y); | 7407 cairo_move_to(cr, x, y); |
7401 cairo_line_to(cr, x, y + height); | 7408 cairo_line_to(cr, x, y + height); |
7402 cairo_line_to(cr, x + width, y + height); | 7409 cairo_line_to(cr, x + width, y + height); |
7410 /* If we are using a drawing context... | 7417 /* If we are using a drawing context... |
7411 * we don't own the cairo context so don't destroy it. | 7418 * we don't own the cairo context so don't destroy it. |
7412 */ | 7419 */ |
7413 if(dc) | 7420 if(dc) |
7414 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); | 7421 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); |
7415 else | 7422 else |
7416 #endif | 7423 #endif |
7417 cairo_destroy(cr); | 7424 cairo_destroy(cr); |
7418 } | 7425 } |
7419 DW_MUTEX_UNLOCK; | 7426 DW_MUTEX_UNLOCK; |
7420 } | 7427 } |
7421 | 7428 |
7453 } | 7460 } |
7454 #if GTK_CHECK_VERSION(3,22,0) | 7461 #if GTK_CHECK_VERSION(3,22,0) |
7455 clip = gdk_window_get_clip_region(window); | 7462 clip = gdk_window_get_clip_region(window); |
7456 dc = gdk_window_begin_draw_frame(window, clip); | 7463 dc = gdk_window_begin_draw_frame(window, clip); |
7457 cr = gdk_drawing_context_get_cairo_context(dc); | 7464 cr = gdk_drawing_context_get_cairo_context(dc); |
7458 #else | 7465 #else |
7459 cr = gdk_cairo_create(window); | 7466 cr = gdk_cairo_create(window); |
7460 #endif | 7467 #endif |
7461 } | 7468 } |
7462 else if(pixmap) | 7469 else if(pixmap) |
7463 cr = cairo_create(pixmap->image); | 7470 cr = cairo_create(pixmap->image); |
7464 if(cr) | 7471 if(cr) |
7465 { | 7472 { |
7466 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key); | 7473 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key); |
7467 int width = abs(x2-x1); | 7474 int width = abs(x2-x1); |
7468 float scale = fabs((float)(y2-y1))/(float)width; | 7475 float scale = fabs((float)(y2-y1))/(float)width; |
7469 | 7476 |
7470 if(flags & DW_DRAW_NOAA) | 7477 if(flags & DW_DRAW_NOAA) |
7471 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); | 7478 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); |
7472 | 7479 |
7473 gdk_cairo_set_source_rgba(cr, foreground); | 7480 gdk_cairo_set_source_rgba(cr, foreground); |
7474 cairo_set_line_width(cr, 1); | 7481 cairo_set_line_width(cr, 1); |
7475 if(scale != 1.0) | 7482 if(scale != 1.0) |
7476 cairo_scale(cr, 1.0, scale); | 7483 cairo_scale(cr, 1.0, scale); |
7477 if(flags & DW_DRAW_FULL) | 7484 if(flags & DW_DRAW_FULL) |
7495 /* If we are using a drawing context... | 7502 /* If we are using a drawing context... |
7496 * we don't own the cairo context so don't destroy it. | 7503 * we don't own the cairo context so don't destroy it. |
7497 */ | 7504 */ |
7498 if(dc) | 7505 if(dc) |
7499 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); | 7506 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); |
7500 else | 7507 else |
7501 #endif | 7508 #endif |
7502 cairo_destroy(cr); | 7509 cairo_destroy(cr); |
7503 } | 7510 } |
7504 DW_MUTEX_UNLOCK; | 7511 DW_MUTEX_UNLOCK; |
7505 } | 7512 } |
7506 | 7513 |
7538 } | 7545 } |
7539 #if GTK_CHECK_VERSION(3,22,0) | 7546 #if GTK_CHECK_VERSION(3,22,0) |
7540 clip = gdk_window_get_clip_region(window); | 7547 clip = gdk_window_get_clip_region(window); |
7541 dc = gdk_window_begin_draw_frame(window, clip); | 7548 dc = gdk_window_begin_draw_frame(window, clip); |
7542 cr = gdk_drawing_context_get_cairo_context(dc); | 7549 cr = gdk_drawing_context_get_cairo_context(dc); |
7543 #else | 7550 #else |
7544 cr = gdk_cairo_create(window); | 7551 cr = gdk_cairo_create(window); |
7545 #endif | 7552 #endif |
7546 if((tmpname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname"))) | 7553 if((tmpname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname"))) |
7547 fontname = tmpname; | 7554 fontname = tmpname; |
7548 } | 7555 } |
7549 else if(pixmap) | 7556 else if(pixmap) |
7550 { | 7557 { |
7604 /* If we are using a drawing context... | 7611 /* If we are using a drawing context... |
7605 * we don't own the cairo context so don't destroy it. | 7612 * we don't own the cairo context so don't destroy it. |
7606 */ | 7613 */ |
7607 if(dc) | 7614 if(dc) |
7608 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); | 7615 gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); |
7609 else | 7616 else |
7610 #endif | 7617 #endif |
7611 cairo_destroy(cr); | 7618 cairo_destroy(cr); |
7612 } | 7619 } |
7613 DW_MUTEX_UNLOCK; | 7620 DW_MUTEX_UNLOCK; |
7614 } | 7621 } |
7615 | 7622 |
7970 } | 7977 } |
7971 #if GTK_CHECK_VERSION(3,22,0) | 7978 #if GTK_CHECK_VERSION(3,22,0) |
7972 clip = gdk_window_get_clip_region(window); | 7979 clip = gdk_window_get_clip_region(window); |
7973 dc = gdk_window_begin_draw_frame(window, clip); | 7980 dc = gdk_window_begin_draw_frame(window, clip); |
7974 cr = gdk_drawing_context_get_cairo_context(dc); | 7981 cr = gdk_drawing_context_get_cairo_context(dc); |
7975 #else | 7982 #else |
7976 cr = gdk_cairo_create(window); | 7983 cr = gdk_cairo_create(window); |
7977 #endif | 7984 #endif |
7978 } | 7985 } |
7979 else if(destp) | 7986 else if(destp) |
7980 cr = cairo_create(destp->image); | 7987 cr = cairo_create(destp->image); |
7981 | 7988 |
7982 if(cr) | 7989 if(cr) |
7983 { | 7990 { |
7984 double xscale = 1, yscale = 1; | 7991 double xscale = 1, yscale = 1; |
7985 | 7992 |
7986 if(srcwidth != -1 && srcheight != -1) | 7993 if(srcwidth != -1 && srcheight != -1) |
7987 { | 7994 { |
7988 xscale = (double)width / (double)srcwidth; | 7995 xscale = (double)width / (double)srcwidth; |
7989 yscale = (double)height / (double)srcheight; | 7996 yscale = (double)height / (double)srcheight; |
7990 cairo_scale(cr, xscale, yscale); | 7997 cairo_scale(cr, xscale, yscale); |
7991 } | 7998 } |
7992 | 7999 |
7993 if(src) | 8000 if(src) |
7994 gdk_cairo_set_source_window (cr, gtk_widget_get_window(src), (xdest + xsrc) / xscale, (ydest + ysrc) / yscale); | 8001 gdk_cairo_set_source_window (cr, gtk_widget_get_window(src), (xdest + xsrc) / xscale, (ydest + ysrc) / yscale); |
7995 else if(srcp) | 8002 else if(srcp) |
7996 cairo_set_source_surface (cr, srcp->image, (xdest + xsrc) / xscale, (ydest + ysrc) / yscale); | 8003 cairo_set_source_surface (cr, srcp->image, (xdest + xsrc) / xscale, (ydest + ysrc) / yscale); |
7997 | 8004 |
7998 cairo_rectangle(cr, xdest / xscale, ydest / yscale, width, height); | 8005 cairo_rectangle(cr, xdest / xscale, ydest / yscale, width, height); |
7999 cairo_fill(cr); | 8006 cairo_fill(cr); |
8000 #if GTK_CHECK_VERSION(3,22,0) | 8007 #if GTK_CHECK_VERSION(3,22,0) |
8001 if(clip) | 8008 if(clip) |
8002 cairo_region_destroy(clip); | 8009 cairo_region_destroy(clip); |
8003 /* If we are using a drawing context... | 8010 /* If we are using a drawing context... |
8004 * we don't own the cairo context so don't destroy it. | 8011 * we don't own the cairo context so don't destroy it. |
8005 */ | 8012 */ |
8006 if(dc) | 8013 if(dc) |
8007 gdk_window_end_draw_frame(gtk_widget_get_window(dest), dc); | 8014 gdk_window_end_draw_frame(gtk_widget_get_window(dest), dc); |
8008 else | 8015 else |
8009 #endif | 8016 #endif |
8010 cairo_destroy(cr); | 8017 cairo_destroy(cr); |
8011 retval = DW_ERROR_NONE; | 8018 retval = DW_ERROR_NONE; |
8012 } | 8019 } |
8013 DW_MUTEX_UNLOCK; | 8020 DW_MUTEX_UNLOCK; |
8014 return retval; | 8021 return retval; |
8254 | 8261 |
8255 if(!eve) | 8262 if(!eve) |
8256 return DW_ERROR_NON_INIT; | 8263 return DW_ERROR_NON_INIT; |
8257 | 8264 |
8258 pthread_mutex_lock (&(eve->mutex)); | 8265 pthread_mutex_lock (&(eve->mutex)); |
8259 | 8266 |
8260 if(eve->posted) | 8267 if(eve->posted) |
8261 { | 8268 { |
8262 pthread_mutex_unlock (&(eve->mutex)); | 8269 pthread_mutex_unlock (&(eve->mutex)); |
8263 return DW_ERROR_NONE; | 8270 return DW_ERROR_NONE; |
8264 } | 8271 } |
8265 | 8272 |
8266 if(timeout != -1) | 8273 if(timeout != -1) |
8267 { | 8274 { |
8268 struct timeval now; | 8275 struct timeval now; |
8269 struct timespec timeo; | 8276 struct timespec timeo; |
8270 | 8277 |
8271 gettimeofday(&now, 0); | 8278 gettimeofday(&now, 0); |
8272 timeo.tv_sec = now.tv_sec + (timeout / 1000); | 8279 timeo.tv_sec = now.tv_sec + (timeout / 1000); |
8273 timeo.tv_nsec = now.tv_usec * 1000; | 8280 timeo.tv_nsec = now.tv_usec * 1000; |
8274 rc = pthread_cond_timedwait(&(eve->event), &(eve->mutex), &timeo); | 8281 rc = pthread_cond_timedwait(&(eve->event), &(eve->mutex), &timeo); |
8275 } | 8282 } |
8276 else | 8283 else |
8277 rc = pthread_cond_wait(&(eve->event), &(eve->mutex)); | 8284 rc = pthread_cond_wait(&(eve->event), &(eve->mutex)); |
8278 | 8285 |
8279 pthread_mutex_unlock (&(eve->mutex)); | 8286 pthread_mutex_unlock (&(eve->mutex)); |
8280 if(!rc) | 8287 if(!rc) |
8281 return DW_ERROR_NONE; | 8288 return DW_ERROR_NONE; |
8282 if(rc == ETIMEDOUT) | 8289 if(rc == ETIMEDOUT) |
8283 return DW_ERROR_TIMEOUT; | 8290 return DW_ERROR_TIMEOUT; |
8638 */ | 8645 */ |
8639 close(GPOINTER_TO_INT(eve)); | 8646 close(GPOINTER_TO_INT(eve)); |
8640 return DW_ERROR_NONE; | 8647 return DW_ERROR_NONE; |
8641 } | 8648 } |
8642 | 8649 |
8643 /* | 8650 /* |
8644 * Generally an internal function called from a newly created | 8651 * Generally an internal function called from a newly created |
8645 * thread to setup the Dynamic Windows environment for the thread. | 8652 * thread to setup the Dynamic Windows environment for the thread. |
8646 * However it is exported so language bindings can call it when | 8653 * However it is exported so language bindings can call it when |
8647 * they create threads that require access to Dynamic Windows. | 8654 * they create threads that require access to Dynamic Windows. |
8648 */ | 8655 */ |
8653 foreground->alpha = foreground->red = foreground->green = foreground->blue = 0.0; | 8660 foreground->alpha = foreground->red = foreground->green = foreground->blue = 0.0; |
8654 pthread_setspecific(_dw_fg_color_key, foreground); | 8661 pthread_setspecific(_dw_fg_color_key, foreground); |
8655 pthread_setspecific(_dw_bg_color_key, NULL); | 8662 pthread_setspecific(_dw_bg_color_key, NULL); |
8656 } | 8663 } |
8657 | 8664 |
8658 /* | 8665 /* |
8659 * Generally an internal function called from a terminating | 8666 * Generally an internal function called from a terminating |
8660 * thread to cleanup the Dynamic Windows environment for the thread. | 8667 * thread to cleanup the Dynamic Windows environment for the thread. |
8661 * However it is exported so language bindings can call it when | 8668 * However it is exported so language bindings can call it when |
8662 * they exit threads that require access to Dynamic Windows. | 8669 * they exit threads that require access to Dynamic Windows. |
8663 */ | 8670 */ |
8664 void API _dw_deinit_thread(void) | 8671 void API _dw_deinit_thread(void) |
8665 { | 8672 { |
8666 GdkRGBA *foreground, *background; | 8673 GdkRGBA *foreground, *background; |
8667 | 8674 |
8668 if((foreground = pthread_getspecific(_dw_fg_color_key))) | 8675 if((foreground = pthread_getspecific(_dw_fg_color_key))) |
8669 free(foreground); | 8676 free(foreground); |
8670 if((background = pthread_getspecific(_dw_bg_color_key))) | 8677 if((background = pthread_getspecific(_dw_bg_color_key))) |
8671 free(background); | 8678 free(background); |
8672 } | 8679 } |
8857 | 8864 |
8858 /* Internal function to get the recommended size of scrolled items */ | 8865 /* Internal function to get the recommended size of scrolled items */ |
8859 void _get_scrolled_size(GtkWidget *item, gint *thiswidth, gint *thisheight) | 8866 void _get_scrolled_size(GtkWidget *item, gint *thiswidth, gint *thisheight) |
8860 { | 8867 { |
8861 GtkWidget *widget = g_object_get_data(G_OBJECT(item), "_dw_user"); | 8868 GtkWidget *widget = g_object_get_data(G_OBJECT(item), "_dw_user"); |
8862 | 8869 |
8863 *thisheight = *thiswidth = 0; | 8870 *thisheight = *thiswidth = 0; |
8864 | 8871 |
8865 if(widget) | 8872 if(widget) |
8866 { | 8873 { |
8867 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE)) | 8874 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE)) |
8868 { | 8875 { |
8869 /* Set to half for tree */ | 8876 /* Set to half for tree */ |
8876 int height, width; | 8883 int height, width; |
8877 char *buf, *ptr; | 8884 char *buf, *ptr; |
8878 int wrap = (gtk_text_view_get_wrap_mode(GTK_TEXT_VIEW(widget)) == GTK_WRAP_WORD); | 8885 int wrap = (gtk_text_view_get_wrap_mode(GTK_TEXT_VIEW(widget)) == GTK_WRAP_WORD); |
8879 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | 8886 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
8880 int hscrolled = FALSE; | 8887 int hscrolled = FALSE; |
8881 | 8888 |
8882 *thiswidth = *thisheight = 0; | 8889 *thiswidth = *thisheight = 0; |
8883 | 8890 |
8884 dw_mle_get_size(item, &bytes, NULL); | 8891 dw_mle_get_size(item, &bytes, NULL); |
8885 | 8892 |
8886 ptr = buf = alloca(bytes + 2); | 8893 ptr = buf = alloca(bytes + 2); |
8887 dw_mle_export(item, buf, 0, (int)bytes); | 8894 dw_mle_export(item, buf, 0, (int)bytes); |
8888 buf[bytes] = 0; | 8895 buf[bytes] = 0; |
8889 strcat(buf, "\r"); | 8896 strcat(buf, "\r"); |
8890 | 8897 |
8891 /* MLE */ | 8898 /* MLE */ |
8892 while((ptr = strstr(buf, "\r"))) | 8899 while((ptr = strstr(buf, "\r"))) |
8893 { | 8900 { |
8894 ptr[0] = 0; | 8901 ptr[0] = 0; |
8895 width = 0; | 8902 width = 0; |
8896 if(strlen(buf)) | 8903 if(strlen(buf)) |
8897 dw_font_text_extents_get(item, NULL, buf, &width, &height); | 8904 dw_font_text_extents_get(item, NULL, buf, &width, &height); |
8898 else | 8905 else |
8899 dw_font_text_extents_get(item, NULL, testtext, NULL, &height); | 8906 dw_font_text_extents_get(item, NULL, testtext, NULL, &height); |
8900 | 8907 |
8901 if(wrap && width > _DW_SCROLLED_MAX_WIDTH) | 8908 if(wrap && width > _DW_SCROLLED_MAX_WIDTH) |
8902 { | 8909 { |
8903 *thiswidth = _DW_SCROLLED_MAX_WIDTH; | 8910 *thiswidth = _DW_SCROLLED_MAX_WIDTH; |
8904 *thisheight += height * (width / _DW_SCROLLED_MAX_WIDTH); | 8911 *thisheight += height * (width / _DW_SCROLLED_MAX_WIDTH); |
8905 } | 8912 } |
8927 } | 8934 } |
8928 else | 8935 else |
8929 { | 8936 { |
8930 gtk_widget_get_preferred_height(GTK_WIDGET(widget), NULL, thisheight); | 8937 gtk_widget_get_preferred_height(GTK_WIDGET(widget), NULL, thisheight); |
8931 gtk_widget_get_preferred_width(GTK_WIDGET(widget), NULL, thiswidth); | 8938 gtk_widget_get_preferred_width(GTK_WIDGET(widget), NULL, thiswidth); |
8932 | 8939 |
8933 *thisheight += 20; | 8940 *thisheight += 20; |
8934 *thiswidth += 20; | 8941 *thiswidth += 20; |
8935 } | 8942 } |
8936 } | 8943 } |
8937 if(*thiswidth < _DW_SCROLLED_MIN_WIDTH) | 8944 if(*thiswidth < _DW_SCROLLED_MIN_WIDTH) |
8987 | 8994 |
8988 if(pixbuf) | 8995 if(pixbuf) |
8989 { | 8996 { |
8990 int pwidth = gdk_pixbuf_get_width(pixbuf); | 8997 int pwidth = gdk_pixbuf_get_width(pixbuf); |
8991 int pheight = gdk_pixbuf_get_height(pixbuf); | 8998 int pheight = gdk_pixbuf_get_height(pixbuf); |
8992 | 8999 |
8993 if(width == -1) | 9000 if(width == -1) |
8994 width = pwidth; | 9001 width = pwidth; |
8995 if(height == -1) | 9002 if(height == -1) |
8996 height = pheight; | 9003 height = pheight; |
8997 | 9004 |
9041 /* Do some sanity bounds checking */ | 9048 /* Do some sanity bounds checking */ |
9042 if(index < 0) | 9049 if(index < 0) |
9043 index = 0; | 9050 index = 0; |
9044 if(index > boxcount) | 9051 if(index > boxcount) |
9045 index = boxcount; | 9052 index = boxcount; |
9046 | 9053 |
9047 #if !GTK_CHECK_VERSION(3,10,0) | 9054 #if !GTK_CHECK_VERSION(3,10,0) |
9048 /* Fix the index by taking into account empty cells */ | 9055 /* Fix the index by taking into account empty cells */ |
9049 if(boxtype == DW_VERT) | 9056 if(boxtype == DW_VERT) |
9050 { | 9057 { |
9051 int z; | 9058 int z; |
9052 | 9059 |
9074 gtk_widget_set_valign(item, vsize ? GTK_ALIGN_FILL : GTK_ALIGN_START); | 9081 gtk_widget_set_valign(item, vsize ? GTK_ALIGN_FILL : GTK_ALIGN_START); |
9075 gtk_widget_set_hexpand(item, hsize); | 9082 gtk_widget_set_hexpand(item, hsize); |
9076 gtk_widget_set_halign(item, hsize ? GTK_ALIGN_FILL : GTK_ALIGN_START); | 9083 gtk_widget_set_halign(item, hsize ? GTK_ALIGN_FILL : GTK_ALIGN_START); |
9077 /* Use the margin property as padding */ | 9084 /* Use the margin property as padding */ |
9078 g_object_set(G_OBJECT(item), "margin", pad, NULL); | 9085 g_object_set(G_OBJECT(item), "margin", pad, NULL); |
9079 /* Add to the grid using insert... | 9086 /* Add to the grid using insert... |
9080 * rows for vertical boxes and columns for horizontal. | 9087 * rows for vertical boxes and columns for horizontal. |
9081 */ | 9088 */ |
9082 if(boxtype == DW_VERT) | 9089 if(boxtype == DW_VERT) |
9083 { | 9090 { |
9084 gtk_grid_insert_row(GTK_GRID(box), index); | 9091 gtk_grid_insert_row(GTK_GRID(box), index); |
9092 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); | 9099 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); |
9093 /* Special case for scrolled windows */ | 9100 /* Special case for scrolled windows */ |
9094 if(GTK_IS_SCROLLED_WINDOW(item)) | 9101 if(GTK_IS_SCROLLED_WINDOW(item)) |
9095 { | 9102 { |
9096 gint scrolledwidth = 0, scrolledheight = 0; | 9103 gint scrolledwidth = 0, scrolledheight = 0; |
9097 | 9104 |
9098 /* Pre-run the calculation code for MLE/Container/Tree if needed */ | 9105 /* Pre-run the calculation code for MLE/Container/Tree if needed */ |
9099 if((width < 1 && !hsize) || (height < 1 && !vsize)) | 9106 if((width < 1 && !hsize) || (height < 1 && !vsize)) |
9100 _get_scrolled_size(item, &scrolledwidth, &scrolledheight); | 9107 _get_scrolled_size(item, &scrolledwidth, &scrolledheight); |
9101 | 9108 |
9102 if(width > 0) | 9109 if(width > 0) |
9103 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width); | 9110 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width); |
9104 else if(!hsize) | 9111 else if(!hsize) |
9105 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), scrolledwidth); | 9112 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), scrolledwidth); |
9106 if(height > 0) | 9113 if(height > 0) |
9113 /* Set the requested size of the widget */ | 9120 /* Set the requested size of the widget */ |
9114 if(width == -1 && (GTK_IS_COMBO_BOX(item) || GTK_IS_ENTRY(item))) | 9121 if(width == -1 && (GTK_IS_COMBO_BOX(item) || GTK_IS_ENTRY(item))) |
9115 gtk_widget_set_size_request(item, 150, height); | 9122 gtk_widget_set_size_request(item, 150, height); |
9116 else if(width == -1 && GTK_IS_SPIN_BUTTON(item)) | 9123 else if(width == -1 && GTK_IS_SPIN_BUTTON(item)) |
9117 gtk_widget_set_size_request(item, 50, height); | 9124 gtk_widget_set_size_request(item, 50, height); |
9118 else | 9125 else |
9119 gtk_widget_set_size_request(item, width, height); | 9126 gtk_widget_set_size_request(item, width, height); |
9120 } | 9127 } |
9121 if(GTK_IS_RADIO_BUTTON(item)) | 9128 if(GTK_IS_RADIO_BUTTON(item)) |
9122 { | 9129 { |
9123 GSList *group; | 9130 GSList *group; |
9157 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. | 9164 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. |
9158 */ | 9165 */ |
9159 int API dw_box_unpack(HWND handle) | 9166 int API dw_box_unpack(HWND handle) |
9160 { | 9167 { |
9161 int _locked_by_me = FALSE, retcode = DW_ERROR_GENERAL; | 9168 int _locked_by_me = FALSE, retcode = DW_ERROR_GENERAL; |
9162 | 9169 |
9163 DW_MUTEX_LOCK; | 9170 DW_MUTEX_LOCK; |
9164 if(GTK_IS_WIDGET(handle)) | 9171 if(GTK_IS_WIDGET(handle)) |
9165 { | 9172 { |
9166 GtkWidget *box, *handle2 = handle; | 9173 GtkWidget *box, *handle2 = handle; |
9167 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox"); | 9174 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox"); |
9168 | 9175 |
9169 /* Handle the invisible event box if it exists */ | 9176 /* Handle the invisible event box if it exists */ |
9170 if(eventbox && GTK_IS_WIDGET(eventbox)) | 9177 if(eventbox && GTK_IS_WIDGET(eventbox)) |
9171 handle2 = eventbox; | 9178 handle2 = eventbox; |
9172 | 9179 |
9173 /* Check if we are removing a widget from a box */ | 9180 /* Check if we are removing a widget from a box */ |
9174 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) | 9181 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) |
9175 { | 9182 { |
9176 /* Get the number of items in the box... */ | 9183 /* Get the number of items in the box... */ |
9177 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); | 9184 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); |
9178 #if GTK_CHECK_VERSION(3,10,0) | 9185 #if GTK_CHECK_VERSION(3,10,0) |
9179 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); | 9186 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); |
9180 #endif | 9187 #endif |
9181 | 9188 |
9182 if(boxcount > 0) | 9189 if(boxcount > 0) |
9183 { | 9190 { |
9189 if(!g_object_get_data(G_OBJECT(handle2), "_dw_refed")) | 9196 if(!g_object_get_data(G_OBJECT(handle2), "_dw_refed")) |
9190 { | 9197 { |
9191 g_object_ref(G_OBJECT(handle2)); | 9198 g_object_ref(G_OBJECT(handle2)); |
9192 g_object_set_data(G_OBJECT(handle2), "_dw_refed", GINT_TO_POINTER(1)); | 9199 g_object_set_data(G_OBJECT(handle2), "_dw_refed", GINT_TO_POINTER(1)); |
9193 } | 9200 } |
9194 /* Remove the widget from the box */ | 9201 /* Remove the widget from the box */ |
9195 #if GTK_CHECK_VERSION(3,10,0) | 9202 #if GTK_CHECK_VERSION(3,10,0) |
9196 /* Figure out where in the grid this widget is and remove that row/column */ | 9203 /* Figure out where in the grid this widget is and remove that row/column */ |
9197 if(boxtype == DW_VERT) | 9204 if(boxtype == DW_VERT) |
9198 { | 9205 { |
9199 int z; | 9206 int z; |
9200 | 9207 |
9240 */ | 9247 */ |
9241 HWND API dw_box_unpack_at_index(HWND box, int index) | 9248 HWND API dw_box_unpack_at_index(HWND box, int index) |
9242 { | 9249 { |
9243 int _locked_by_me = FALSE; | 9250 int _locked_by_me = FALSE; |
9244 HWND retval = 0; | 9251 HWND retval = 0; |
9245 | 9252 |
9246 DW_MUTEX_LOCK; | 9253 DW_MUTEX_LOCK; |
9247 /* Check if we are removing a widget from a box */ | 9254 /* Check if we are removing a widget from a box */ |
9248 if(GTK_IS_GRID(box)) | 9255 if(GTK_IS_GRID(box)) |
9249 { | 9256 { |
9250 /* Get the number of items in the box... */ | 9257 /* Get the number of items in the box... */ |
9251 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); | 9258 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); |
9252 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); | 9259 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); |
9253 #if GTK_CHECK_VERSION(3,10,0) | 9260 #if GTK_CHECK_VERSION(3,10,0) |
9254 GtkWidget *item = (boxtype == DW_VERT) ? gtk_grid_get_child_at(GTK_GRID(box), 0, index) : gtk_grid_get_child_at(GTK_GRID(box), index, 0); | 9261 GtkWidget *item = (boxtype == DW_VERT) ? gtk_grid_get_child_at(GTK_GRID(box), 0, index) : gtk_grid_get_child_at(GTK_GRID(box), index, 0); |
9255 #else | 9262 #else |
9256 GtkWidget *item; | 9263 GtkWidget *item; |
9257 | 9264 |
9258 /* Fix the index by taking into account empty cells */ | 9265 /* Fix the index by taking into account empty cells */ |
9294 if(!g_object_get_data(G_OBJECT(item), "_dw_refed")) | 9301 if(!g_object_get_data(G_OBJECT(item), "_dw_refed")) |
9295 { | 9302 { |
9296 g_object_ref(G_OBJECT(item)); | 9303 g_object_ref(G_OBJECT(item)); |
9297 g_object_set_data(G_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1)); | 9304 g_object_set_data(G_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1)); |
9298 } | 9305 } |
9299 /* Remove the widget from the box */ | 9306 /* Remove the widget from the box */ |
9300 gtk_container_remove(GTK_CONTAINER(box), item); | 9307 gtk_container_remove(GTK_CONTAINER(box), item); |
9301 #if GTK_CHECK_VERSION(3,10,0) | 9308 #if GTK_CHECK_VERSION(3,10,0) |
9302 if(boxtype == DW_VERT) | 9309 if(boxtype == DW_VERT) |
9303 gtk_grid_remove_row(GTK_GRID(box), index); | 9310 gtk_grid_remove_row(GTK_GRID(box), index); |
9304 else | 9311 else |
9305 gtk_grid_remove_column(GTK_GRID(box), index); | 9312 gtk_grid_remove_column(GTK_GRID(box), index); |
9306 #endif | 9313 #endif |
9307 retval = item; | 9314 retval = item; |
9308 } | 9315 } |
9309 } | 9316 } |
9310 DW_MUTEX_UNLOCK; | 9317 DW_MUTEX_UNLOCK; |
9311 return retval; | 9318 return retval; |
9418 (SubstructureRedirectMask | SubstructureNotifyMask), | 9425 (SubstructureRedirectMask | SubstructureNotifyMask), |
9419 &xevent); | 9426 &xevent); |
9420 | 9427 |
9421 /* Connect a signal to look for the property change */ | 9428 /* Connect a signal to look for the property change */ |
9422 connid = g_signal_connect(G_OBJECT(window), "property_notify_event", G_CALLBACK(_dw_property_notify), gdkwindow); | 9429 connid = g_signal_connect(G_OBJECT(window), "property_notify_event", G_CALLBACK(_dw_property_notify), gdkwindow); |
9423 | 9430 |
9424 /* Record the request time */ | 9431 /* Record the request time */ |
9425 time(&extents_time); | 9432 time(&extents_time); |
9426 | 9433 |
9427 /* Look for the property notify event */ | 9434 /* Look for the property notify event */ |
9428 do | 9435 do |
9429 { | 9436 { |
9430 dw_main_iteration(); | 9437 dw_main_iteration(); |
9431 time(&currtime); | 9438 time(&currtime); |
9432 } | 9439 } |
9433 while(currtime - extents_time < 2); | 9440 while(currtime - extents_time < 2); |
9434 | 9441 |
9435 /* Remove the signal handler now that we are done */ | 9442 /* Remove the signal handler now that we are done */ |
9436 g_signal_handler_disconnect(G_OBJECT(window), connid); | 9443 g_signal_handler_disconnect(G_OBJECT(window), connid); |
9437 } | 9444 } |
9438 | 9445 |
9439 /* Attempt to retrieve window's frame extents. */ | 9446 /* Attempt to retrieve window's frame extents. */ |
9440 eu.extents = &extents; | 9447 eu.extents = &extents; |
9441 if(gdk_property_get(gdkwindow, | 9448 if(gdk_property_get(gdkwindow, |
9442 extents_atom, | 9449 extents_atom, |
9443 gdk_atom_intern("CARDINAL", FALSE), | 9450 gdk_atom_intern("CARDINAL", FALSE), |
9479 gint gwidth, gheight; | 9486 gint gwidth, gheight; |
9480 | 9487 |
9481 /* Calculate the border size */ | 9488 /* Calculate the border size */ |
9482 gdk_window_get_frame_extents(window, &frame); | 9489 gdk_window_get_frame_extents(window, &frame); |
9483 gdk_window_get_geometry(window, NULL, NULL, &gwidth, &gheight); | 9490 gdk_window_get_geometry(window, NULL, NULL, &gwidth, &gheight); |
9484 | 9491 |
9485 cx = frame.width - gwidth; | 9492 cx = frame.width - gwidth; |
9486 if(cx < 0) | 9493 if(cx < 0) |
9487 cx = 0; | 9494 cx = 0; |
9488 cy = frame.height - gheight; | 9495 cy = frame.height - gheight; |
9489 if(cy < 0) | 9496 if(cy < 0) |
9532 | 9539 |
9533 DW_MUTEX_LOCK; | 9540 DW_MUTEX_LOCK; |
9534 if(GTK_IS_SCROLLED_WINDOW(handle)) | 9541 if(GTK_IS_SCROLLED_WINDOW(handle)) |
9535 { | 9542 { |
9536 gint scrolledwidth, scrolledheight; | 9543 gint scrolledwidth, scrolledheight; |
9537 | 9544 |
9538 _get_scrolled_size(handle, &scrolledwidth, &scrolledheight); | 9545 _get_scrolled_size(handle, &scrolledwidth, &scrolledheight); |
9539 | 9546 |
9540 if(width) | 9547 if(width) |
9541 *width = scrolledwidth; | 9548 *width = scrolledwidth; |
9542 if(height) | 9549 if(height) |
9543 *height = scrolledheight; | 9550 *height = scrolledheight; |
9544 } | 9551 } |
9556 int _dw_screen_width(void) | 9563 int _dw_screen_width(void) |
9557 { | 9564 { |
9558 #if GTK_CHECK_VERSION(3,22,0) | 9565 #if GTK_CHECK_VERSION(3,22,0) |
9559 { | 9566 { |
9560 GdkDisplay *display = gdk_display_get_default(); | 9567 GdkDisplay *display = gdk_display_get_default(); |
9561 | 9568 |
9562 if(display) | 9569 if(display) |
9563 { | 9570 { |
9564 GdkMonitor *monitor = gdk_display_get_primary_monitor(display); | 9571 GdkMonitor *monitor = gdk_display_get_primary_monitor(display); |
9565 | 9572 |
9566 if(monitor) | 9573 if(monitor) |
9567 { | 9574 { |
9568 GdkRectangle rc = { 0, 0, 0 ,0 }; | 9575 GdkRectangle rc = { 0, 0, 0 ,0 }; |
9569 gdk_monitor_get_geometry(monitor, &rc); | 9576 gdk_monitor_get_geometry(monitor, &rc); |
9570 return rc.width; | 9577 return rc.width; |
9571 } | 9578 } |
9572 } | 9579 } |
9573 } | 9580 } |
9574 return 0; | 9581 return 0; |
9575 #else | 9582 #else |
9576 return gdk_screen_width(); | 9583 return gdk_screen_width(); |
9577 #endif | 9584 #endif |
9578 } | 9585 } |
9579 | 9586 |
9580 /* | 9587 /* |
9581 * Returns the width of the screen. | 9588 * Returns the width of the screen. |
9582 */ | 9589 */ |
9595 int _dw_screen_height(void) | 9602 int _dw_screen_height(void) |
9596 { | 9603 { |
9597 #if GTK_CHECK_VERSION(3,22,0) | 9604 #if GTK_CHECK_VERSION(3,22,0) |
9598 { | 9605 { |
9599 GdkDisplay *display = gdk_display_get_default(); | 9606 GdkDisplay *display = gdk_display_get_default(); |
9600 | 9607 |
9601 if(display) | 9608 if(display) |
9602 { | 9609 { |
9603 GdkMonitor *monitor = gdk_display_get_primary_monitor(display); | 9610 GdkMonitor *monitor = gdk_display_get_primary_monitor(display); |
9604 | 9611 |
9605 if(monitor) | 9612 if(monitor) |
9606 { | 9613 { |
9607 GdkRectangle rc = { 0, 0, 0 ,0 }; | 9614 GdkRectangle rc = { 0, 0, 0 ,0 }; |
9608 gdk_monitor_get_geometry(monitor, &rc); | 9615 gdk_monitor_get_geometry(monitor, &rc); |
9609 return rc.height; | 9616 return rc.height; |
9610 } | 9617 } |
9611 } | 9618 } |
9612 } | 9619 } |
9613 return 0; | 9620 return 0; |
9614 #else | 9621 #else |
9615 return gdk_screen_height(); | 9622 return gdk_screen_height(); |
9616 #endif | 9623 #endif |
9617 } | 9624 } |
9618 | 9625 |
9619 /* | 9626 /* |
9620 * Returns the height of the screen. | 9627 * Returns the height of the screen. |
9621 */ | 9628 */ |
9640 DW_MUTEX_LOCK; | 9647 DW_MUTEX_LOCK; |
9641 #if GTK_CHECK_VERSION(3,22,0) | 9648 #if GTK_CHECK_VERSION(3,22,0) |
9642 vis = gdk_screen_get_system_visual(gdk_screen_get_default()); | 9649 vis = gdk_screen_get_system_visual(gdk_screen_get_default()); |
9643 #else | 9650 #else |
9644 vis = gdk_visual_get_system(); | 9651 vis = gdk_visual_get_system(); |
9645 #endif | 9652 #endif |
9646 retval = gdk_visual_get_depth(vis); | 9653 retval = gdk_visual_get_depth(vis); |
9647 DW_MUTEX_UNLOCK; | 9654 DW_MUTEX_UNLOCK; |
9648 return retval; | 9655 return retval; |
9649 } | 9656 } |
9650 | 9657 |
9676 GtkWidget *mdi; | 9683 GtkWidget *mdi; |
9677 #endif | 9684 #endif |
9678 | 9685 |
9679 if(!handle) | 9686 if(!handle) |
9680 return; | 9687 return; |
9681 | 9688 |
9682 DW_MUTEX_LOCK; | 9689 DW_MUTEX_LOCK; |
9683 #ifdef DW_INCLUDE_DEPRECATED | 9690 #ifdef DW_INCLUDE_DEPRECATED |
9684 if((mdi = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi)) | 9691 if((mdi = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi)) |
9685 { | 9692 { |
9686 gtk_mdi_move(GTK_MDI(mdi), handle, x, y); | 9693 gtk_mdi_move(GTK_MDI(mdi), handle, x, y); |
9687 } | 9694 } |
9688 else | 9695 else |
9689 #endif | 9696 #endif |
9690 { | 9697 { |
9691 GdkWindow *window = NULL; | 9698 GdkWindow *window = NULL; |
9692 | 9699 |
9693 if(GTK_IS_WINDOW(handle)) | 9700 if(GTK_IS_WINDOW(handle)) |
9694 { | 9701 { |
9695 GdkWindow *window = gtk_widget_get_window(handle); | 9702 GdkWindow *window = gtk_widget_get_window(handle); |
9696 int horz = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_horz")); | 9703 int horz = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_horz")); |
9697 int vert = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_vert")); | 9704 int vert = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_vert")); |
9698 int cx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_width")); | 9705 int cx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_width")); |
9699 int cy = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_height")); | 9706 int cy = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_height")); |
9700 int newx = x, newy = y, width = 0, height = 0; | 9707 int newx = x, newy = y, width = 0, height = 0; |
9701 | 9708 |
9702 /* If the window is mapped */ | 9709 /* If the window is mapped */ |
9703 if(window && gtk_widget_get_mapped(handle)) | 9710 if(window && gtk_widget_get_mapped(handle)) |
9704 { | 9711 { |
9705 /* If we need the width or height... */ | 9712 /* If we need the width or height... */ |
9706 if(horz || vert) | 9713 if(horz || vert) |
9708 GdkRectangle frame; | 9715 GdkRectangle frame; |
9709 int count = 0; | 9716 int count = 0; |
9710 | 9717 |
9711 /* Get the frame size */ | 9718 /* Get the frame size */ |
9712 gdk_window_get_frame_extents(window, &frame); | 9719 gdk_window_get_frame_extents(window, &frame); |
9713 | 9720 |
9714 /* FIXME: Sometimes we get returned an invalid 200x200 | 9721 /* FIXME: Sometimes we get returned an invalid 200x200 |
9715 * result... so if we get this... try the call a second | 9722 * result... so if we get this... try the call a second |
9716 * time and hope for a better result. | 9723 * time and hope for a better result. |
9717 */ | 9724 */ |
9718 while((frame.width == 200 || frame.width == (200 + cx)) && | 9725 while((frame.width == 200 || frame.width == (200 + cx)) && |
9719 (frame.height == 200 || frame.height == (200 + cy)) && count < 10) | 9726 (frame.height == 200 || frame.height == (200 + cy)) && count < 10) |
9720 { | 9727 { |
9721 _dw_msleep(1); | 9728 _dw_msleep(1); |
9722 count++; | 9729 count++; |
9723 gdk_window_get_frame_extents(window, &frame); | 9730 gdk_window_get_frame_extents(window, &frame); |
9768 if((vert & 0xf) == DW_GRAV_CENTER) | 9775 if((vert & 0xf) == DW_GRAV_CENTER) |
9769 newy += ((_dw_screen_height() / 2) - (height / 2)); | 9776 newy += ((_dw_screen_height() / 2) - (height / 2)); |
9770 else if((vert & 0xf) == DW_GRAV_BOTTOM) | 9777 else if((vert & 0xf) == DW_GRAV_BOTTOM) |
9771 newy = _dw_screen_height() - height - y; | 9778 newy = _dw_screen_height() - height - y; |
9772 | 9779 |
9773 #if GTK_CHECK_VERSION(3,3,8) | 9780 #if GTK_CHECK_VERSION(3,3,8) |
9774 /* Adjust the values to avoid Gnome bar if requested */ | 9781 /* Adjust the values to avoid Gnome bar if requested */ |
9775 if((horz | vert) & DW_GRAV_OBSTACLES) | 9782 if((horz | vert) & DW_GRAV_OBSTACLES) |
9776 { | 9783 { |
9777 GdkRectangle rect = { 0, 0, 0, 0 }; | 9784 GdkRectangle rect = { 0, 0, 0, 0 }; |
9778 #if GTK_CHECK_VERSION(3,22,0) | 9785 #if GTK_CHECK_VERSION(3,22,0) |
9779 GdkDisplay *display = gdk_display_get_default(); | 9786 GdkDisplay *display = gdk_display_get_default(); |
9780 | 9787 |
9781 if(display) | 9788 if(display) |
9782 { | 9789 { |
9783 GdkMonitor *monitor = gdk_display_get_primary_monitor(display); | 9790 GdkMonitor *monitor = gdk_display_get_primary_monitor(display); |
9784 | 9791 |
9785 if(monitor) | 9792 if(monitor) |
9786 gdk_monitor_get_workarea(monitor, &rect); | 9793 gdk_monitor_get_workarea(monitor, &rect); |
9787 } | 9794 } |
9788 #else | 9795 #else |
9789 GdkScreen *screen = gdk_screen_get_default(); | 9796 GdkScreen *screen = gdk_screen_get_default(); |
9790 | 9797 |
9791 gdk_screen_get_monitor_workarea(screen, 0, &rect); | 9798 gdk_screen_get_monitor_workarea(screen, 0, &rect); |
9792 #endif | 9799 #endif |
9793 if(horz & DW_GRAV_OBSTACLES) | 9800 if(horz & DW_GRAV_OBSTACLES) |
9794 { | 9801 { |
9795 if((horz & 0xf) == DW_GRAV_LEFT) | 9802 if((horz & 0xf) == DW_GRAV_LEFT) |
9796 newx += rect.x; | 9803 newx += rect.x; |
9797 else if((horz & 0xf) == DW_GRAV_RIGHT) | 9804 else if((horz & 0xf) == DW_GRAV_RIGHT) |
9803 newy += rect.y; | 9810 newy += rect.y; |
9804 else if((vert & 0xf) == DW_GRAV_BOTTOM) | 9811 else if((vert & 0xf) == DW_GRAV_BOTTOM) |
9805 newy -= _dw_screen_height() - (rect.y + rect.height); | 9812 newy -= _dw_screen_height() - (rect.y + rect.height); |
9806 } | 9813 } |
9807 } | 9814 } |
9808 #endif | 9815 #endif |
9809 } | 9816 } |
9810 /* Finally move the window into place */ | 9817 /* Finally move the window into place */ |
9811 gtk_window_move(GTK_WINDOW(handle), newx, newy); | 9818 gtk_window_move(GTK_WINDOW(handle), newx, newy); |
9812 } | 9819 } |
9813 else if((window = gtk_widget_get_window(handle))) | 9820 else if((window = gtk_widget_get_window(handle))) |
9814 gdk_window_move(window, x, y); | 9821 gdk_window_move(window, x, y); |
9857 } | 9864 } |
9858 else | 9865 else |
9859 #endif | 9866 #endif |
9860 { | 9867 { |
9861 GdkWindow *window; | 9868 GdkWindow *window; |
9862 | 9869 |
9863 /* Can only query if the window is realized */ | 9870 /* Can only query if the window is realized */ |
9864 if(handle && (window = gtk_widget_get_window(handle))) | 9871 if(handle && (window = gtk_widget_get_window(handle))) |
9865 { | 9872 { |
9866 /* If it is a toplevel window */ | 9873 /* If it is a toplevel window */ |
9867 if(GTK_IS_WINDOW(handle)) | 9874 if(GTK_IS_WINDOW(handle)) |
9952 y = DW_CENTER; | 9959 y = DW_CENTER; |
9953 if ( style & DW_DT_TOP ) | 9960 if ( style & DW_DT_TOP ) |
9954 y = DW_TOP; | 9961 y = DW_TOP; |
9955 if ( style & DW_DT_BOTTOM ) | 9962 if ( style & DW_DT_BOTTOM ) |
9956 y = DW_BOTTOM; | 9963 y = DW_BOTTOM; |
9957 #if GTK_CHECK_VERSION(3,16,0) | 9964 #if GTK_CHECK_VERSION(3,16,0) |
9958 gtk_label_set_xalign(GTK_LABEL(handle2), x); | 9965 gtk_label_set_xalign(GTK_LABEL(handle2), x); |
9959 gtk_label_set_yalign(GTK_LABEL(handle2), y); | 9966 gtk_label_set_yalign(GTK_LABEL(handle2), y); |
9960 #else | 9967 #else |
9961 gtk_misc_set_alignment(GTK_MISC(handle2), x, y); | 9968 gtk_misc_set_alignment(GTK_MISC(handle2), x, y); |
9962 #endif | 9969 #endif |
9964 gtk_label_set_line_wrap( GTK_LABEL(handle), TRUE ); | 9971 gtk_label_set_line_wrap( GTK_LABEL(handle), TRUE ); |
9965 } | 9972 } |
9966 if ( GTK_IS_CHECK_MENU_ITEM(handle2) && (mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED)) ) | 9973 if ( GTK_IS_CHECK_MENU_ITEM(handle2) && (mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED)) ) |
9967 { | 9974 { |
9968 int check = 0; | 9975 int check = 0; |
9969 | 9976 |
9970 if ( style & DW_MIS_CHECKED ) | 9977 if ( style & DW_MIS_CHECKED ) |
9971 check = 1; | 9978 check = 1; |
9972 | 9979 |
9973 _dw_ignore_click = 1; | 9980 _dw_ignore_click = 1; |
9974 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(handle2)) != check) | 9981 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(handle2)) != check) |
10432 gint rowcount = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); | 10439 gint rowcount = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); |
10433 gdouble pagesize = gtk_adjustment_get_page_size(adjust); | 10440 gdouble pagesize = gtk_adjustment_get_page_size(adjust); |
10434 gdouble upper = gtk_adjustment_get_upper(adjust) - pagesize; | 10441 gdouble upper = gtk_adjustment_get_upper(adjust) - pagesize; |
10435 gdouble lower = gtk_adjustment_get_lower(adjust); | 10442 gdouble lower = gtk_adjustment_get_lower(adjust); |
10436 gdouble change; | 10443 gdouble change; |
10437 | 10444 |
10438 /* Safety check */ | 10445 /* Safety check */ |
10439 if(rowcount < 2) | 10446 if(rowcount < 2) |
10440 { | 10447 { |
10441 DW_MUTEX_UNLOCK; | 10448 DW_MUTEX_UNLOCK; |
10442 return; | 10449 return; |
10443 } | 10450 } |
10444 | 10451 |
10445 /* Verify the range */ | 10452 /* Verify the range */ |
10446 rowcount--; | 10453 rowcount--; |
10447 if(top > rowcount) | 10454 if(top > rowcount) |
10448 top = rowcount; | 10455 top = rowcount; |
10449 | 10456 |
10788 float *percent = (float *)g_object_get_data(G_OBJECT(widget), "_dw_percent"); | 10795 float *percent = (float *)g_object_get_data(G_OBJECT(widget), "_dw_percent"); |
10789 | 10796 |
10790 if(percent) | 10797 if(percent) |
10791 { | 10798 { |
10792 GtkAllocation alloc; | 10799 GtkAllocation alloc; |
10793 | 10800 |
10794 gtk_widget_get_allocation(widget, &alloc); | 10801 gtk_widget_get_allocation(widget, &alloc); |
10795 | 10802 |
10796 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(widget)) == GTK_ORIENTATION_HORIZONTAL) | 10803 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(widget)) == GTK_ORIENTATION_HORIZONTAL) |
10797 gtk_paned_set_position(GTK_PANED(widget), (int)(alloc.width * (*percent / 100.0))); | 10804 gtk_paned_set_position(GTK_PANED(widget), (int)(alloc.width * (*percent / 100.0))); |
10798 else | 10805 else |
10799 gtk_paned_set_position(GTK_PANED(widget), (int)(alloc.height * (*percent / 100.0))); | 10806 gtk_paned_set_position(GTK_PANED(widget), (int)(alloc.height * (*percent / 100.0))); |
10800 g_object_set_data(G_OBJECT(widget), "_dw_percent", NULL); | 10807 g_object_set_data(G_OBJECT(widget), "_dw_percent", NULL); |
11123 } | 11130 } |
11124 | 11131 |
11125 if ( defpath ) | 11132 if ( defpath ) |
11126 { | 11133 { |
11127 struct stat buf; | 11134 struct stat buf; |
11128 | 11135 |
11129 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath)) | 11136 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath)) |
11130 { | 11137 { |
11131 strcpy( mypath, defpath ); | 11138 strcpy( mypath, defpath ); |
11132 } | 11139 } |
11133 | 11140 |
11134 /* See if the path exists */ | 11141 /* See if the path exists */ |
11135 if(stat(mypath, &buf) == 0) | 11142 if(stat(mypath, &buf) == 0) |
11136 { | 11143 { |
11137 /* If the path is a directory... set the current folder */ | 11144 /* If the path is a directory... set the current folder */ |
11138 if(buf.st_mode & S_IFDIR) | 11145 if(buf.st_mode & S_IFDIR) |
11139 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath ); | 11146 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath ); |
11145 else if(flags == DW_FILE_SAVE) | 11152 else if(flags == DW_FILE_SAVE) |
11146 { | 11153 { |
11147 if(strchr(mypath, '/')) | 11154 if(strchr(mypath, '/')) |
11148 { | 11155 { |
11149 unsigned long x = strlen(mypath) - 1; | 11156 unsigned long x = strlen(mypath) - 1; |
11150 | 11157 |
11151 /* Trim off the filename */ | 11158 /* Trim off the filename */ |
11152 while(x > 0 && mypath[x] != '/') | 11159 while(x > 0 && mypath[x] != '/') |
11153 { | 11160 { |
11154 x--; | 11161 x--; |
11155 } | 11162 } |
11156 if(mypath[x] == '/') | 11163 if(mypath[x] == '/') |
11157 { | 11164 { |
11158 char *file = NULL; | 11165 char *file = NULL; |
11159 char temp[PATH_MAX+1]; | 11166 char temp[PATH_MAX+1]; |
11160 | 11167 |
11161 /* Save the original path in temp */ | 11168 /* Save the original path in temp */ |
11162 strcpy(temp, mypath); | 11169 strcpy(temp, mypath); |
11163 mypath[x] = 0; | 11170 mypath[x] = 0; |
11164 | 11171 |
11165 /* Check to make sure the trimmed piece is a directory */ | 11172 /* Check to make sure the trimmed piece is a directory */ |
11166 if(realpath(mypath, temp) && stat(temp, &buf) == 0) | 11173 if(realpath(mypath, temp) && stat(temp, &buf) == 0) |
11167 { | 11174 { |
11168 if(buf.st_mode & S_IFDIR) | 11175 if(buf.st_mode & S_IFDIR) |
11169 { | 11176 { |
11170 /* We now have it split */ | 11177 /* We now have it split */ |
11171 file = &mypath[x+1]; | 11178 file = &mypath[x+1]; |
11172 } | 11179 } |
11173 } | 11180 } |
11174 | 11181 |
11175 /* Select folder... */ | 11182 /* Select folder... */ |
11176 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(filew), temp ); | 11183 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(filew), temp ); |
11177 /* ... and file separately */ | 11184 /* ... and file separately */ |
11178 if(file) | 11185 if(file) |
11179 gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER(filew), file ); | 11186 gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER(filew), file ); |
11537 */ | 11544 */ |
11538 HPRINT API dw_print_new(char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata) | 11545 HPRINT API dw_print_new(char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata) |
11539 { | 11546 { |
11540 GtkPrintOperation *op; | 11547 GtkPrintOperation *op; |
11541 int _locked_by_me = FALSE; | 11548 int _locked_by_me = FALSE; |
11542 | 11549 |
11543 if(!drawfunc) | 11550 if(!drawfunc) |
11544 return NULL; | 11551 return NULL; |
11545 | 11552 |
11546 DW_MUTEX_LOCK; | 11553 DW_MUTEX_LOCK; |
11547 if((op = gtk_print_operation_new())) | 11554 if((op = gtk_print_operation_new())) |
11548 { | 11555 { |
11549 gtk_print_operation_set_n_pages(op, pages); | 11556 gtk_print_operation_set_n_pages(op, pages); |
11550 gtk_print_operation_set_job_name(op, jobname ? jobname : "Dynamic Windows Print Job"); | 11557 gtk_print_operation_set_job_name(op, jobname ? jobname : "Dynamic Windows Print Job"); |
11551 g_object_set_data(G_OBJECT(op), "_dw_drawfunc", drawfunc); | 11558 g_object_set_data(G_OBJECT(op), "_dw_drawfunc", drawfunc); |
11567 int API dw_print_run(HPRINT print, unsigned long flags) | 11574 int API dw_print_run(HPRINT print, unsigned long flags) |
11568 { | 11575 { |
11569 GtkPrintOperationResult res; | 11576 GtkPrintOperationResult res; |
11570 GtkPrintOperation *op = (GtkPrintOperation *)print; | 11577 GtkPrintOperation *op = (GtkPrintOperation *)print; |
11571 int _locked_by_me = FALSE; | 11578 int _locked_by_me = FALSE; |
11572 | 11579 |
11573 DW_MUTEX_LOCK; | 11580 DW_MUTEX_LOCK; |
11574 res = gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); | 11581 res = gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); |
11575 DW_MUTEX_UNLOCK; | 11582 DW_MUTEX_UNLOCK; |
11576 return (res == GTK_PRINT_OPERATION_RESULT_ERROR ? DW_ERROR_UNKNOWN : DW_ERROR_NONE); | 11583 return (res == GTK_PRINT_OPERATION_RESULT_ERROR ? DW_ERROR_UNKNOWN : DW_ERROR_NONE); |
11577 } | 11584 } |
11583 */ | 11590 */ |
11584 void API dw_print_cancel(HPRINT print) | 11591 void API dw_print_cancel(HPRINT print) |
11585 { | 11592 { |
11586 int _locked_by_me = FALSE; | 11593 int _locked_by_me = FALSE; |
11587 GtkPrintOperation *op = (GtkPrintOperation *)print; | 11594 GtkPrintOperation *op = (GtkPrintOperation *)print; |
11588 | 11595 |
11589 DW_MUTEX_LOCK; | 11596 DW_MUTEX_LOCK; |
11590 gtk_print_operation_cancel(op); | 11597 gtk_print_operation_cancel(op); |
11591 DW_MUTEX_UNLOCK; | 11598 DW_MUTEX_UNLOCK; |
11592 } | 11599 } |
11593 | 11600 |
11612 return _user_dir; | 11619 return _user_dir; |
11613 } | 11620 } |
11614 | 11621 |
11615 /* | 11622 /* |
11616 * Returns a pointer to a static buffer which containes the | 11623 * Returns a pointer to a static buffer which containes the |
11617 * private application data directory. | 11624 * private application data directory. |
11618 */ | 11625 */ |
11619 char * API dw_app_dir(void) | 11626 char * API dw_app_dir(void) |
11620 { | 11627 { |
11621 return _dw_share_path; | 11628 return _dw_share_path; |
11622 } | 11629 } |
11783 * sigfunc: The pointer to the function to be used as the callback. | 11790 * sigfunc: The pointer to the function to be used as the callback. |
11784 * data: User data to be passed to the handler function. | 11791 * data: User data to be passed to the handler function. |
11785 */ | 11792 */ |
11786 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | 11793 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) |
11787 { | 11794 { |
11788 dw_signal_connect_data(window, signame, sigfunc, NULL, data); | 11795 dw_signal_connect_data(window, signame, sigfunc, NULL, data); |
11789 } | 11796 } |
11790 | 11797 |
11791 /* Internal function to free any allocated signal data.. | 11798 /* Internal function to free any allocated signal data.. |
11792 * and call any required function to free additional memory. | 11799 * and call any required function to free additional memory. |
11793 */ | 11800 */ |
11799 void (*discfunc)(HWND, void *) = params[1]; | 11806 void (*discfunc)(HWND, void *) = params[1]; |
11800 | 11807 |
11801 if(discfunc) | 11808 if(discfunc) |
11802 { | 11809 { |
11803 SignalHandler work = _get_signal_handler(data); | 11810 SignalHandler work = _get_signal_handler(data); |
11804 | 11811 |
11805 if(work.window) | 11812 if(work.window) |
11806 { | 11813 { |
11807 discfunc(work.window, work.data); | 11814 discfunc(work.window, work.data); |
11808 } | 11815 } |
11809 } | 11816 } |
11826 char *thisname = signame; | 11833 char *thisname = signame; |
11827 HWND thiswindow = window; | 11834 HWND thiswindow = window; |
11828 int sigid, _locked_by_me = FALSE; | 11835 int sigid, _locked_by_me = FALSE; |
11829 void **params = calloc(3, sizeof(void *)); | 11836 void **params = calloc(3, sizeof(void *)); |
11830 gint cid; | 11837 gint cid; |
11831 | 11838 |
11832 /* Save the disconnect function pointer */ | 11839 /* Save the disconnect function pointer */ |
11833 params[1] = discfunc; | 11840 params[1] = discfunc; |
11834 | 11841 |
11835 DW_MUTEX_LOCK; | 11842 DW_MUTEX_LOCK; |
11836 /* | 11843 /* |
11895 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _container_enter_event, discfunc); | 11902 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _container_enter_event, discfunc); |
11896 params[0] = GINT_TO_POINTER(sigid); | 11903 params[0] = GINT_TO_POINTER(sigid); |
11897 params[2] = (void *)thiswindow; | 11904 params[2] = (void *)thiswindow; |
11898 cid = g_signal_connect_data(G_OBJECT(thiswindow), "key_press_event", G_CALLBACK(_container_enter_event), params, _dw_signal_disconnect, 0); | 11905 cid = g_signal_connect_data(G_OBJECT(thiswindow), "key_press_event", G_CALLBACK(_container_enter_event), params, _dw_signal_disconnect, 0); |
11899 _set_signal_handler_id(thiswindow, sigid, cid); | 11906 _set_signal_handler_id(thiswindow, sigid, cid); |
11900 | 11907 |
11901 params = calloc(sizeof(void *), 3); | 11908 params = calloc(sizeof(void *), 3); |
11902 | 11909 |
11903 thisname = "button_press_event"; | 11910 thisname = "button_press_event"; |
11904 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_ENTER); | 11911 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_ENTER); |
11905 } | 11912 } |
11969 thisfunc = _findsigfunc(signame); | 11976 thisfunc = _findsigfunc(signame); |
11970 | 11977 |
11971 for(z=0;z<count;z++) | 11978 for(z=0;z<count;z++) |
11972 { | 11979 { |
11973 SignalHandler sh; | 11980 SignalHandler sh; |
11974 | 11981 |
11975 params[0] = GINT_TO_POINTER(z); | 11982 params[0] = GINT_TO_POINTER(z); |
11976 sh = _get_signal_handler(params); | 11983 sh = _get_signal_handler(params); |
11977 | 11984 |
11978 if(sh.intfunc == thisfunc) | 11985 if(sh.intfunc == thisfunc) |
11979 _remove_signal_handler((HWND)params[2], z); | 11986 _remove_signal_handler((HWND)params[2], z); |
12019 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(params[2]), "_dw_sigcounter")); | 12026 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(params[2]), "_dw_sigcounter")); |
12020 | 12027 |
12021 for(z=0;z<count;z++) | 12028 for(z=0;z<count;z++) |
12022 { | 12029 { |
12023 SignalHandler sh; | 12030 SignalHandler sh; |
12024 | 12031 |
12025 params[0] = GINT_TO_POINTER(z); | 12032 params[0] = GINT_TO_POINTER(z); |
12026 sh = _get_signal_handler(params); | 12033 sh = _get_signal_handler(params); |
12027 | 12034 |
12028 if(sh.data == data) | 12035 if(sh.data == data) |
12029 _remove_signal_handler((HWND)params[2], z); | 12036 _remove_signal_handler((HWND)params[2], z); |
12040 * or NULL on failure. | 12047 * or NULL on failure. |
12041 */ | 12048 */ |
12042 wchar_t * API dw_utf8_to_wchar(char *utf8string) | 12049 wchar_t * API dw_utf8_to_wchar(char *utf8string) |
12043 { | 12050 { |
12044 wchar_t *retval = NULL, *freeme; | 12051 wchar_t *retval = NULL, *freeme; |
12045 | 12052 |
12046 if(sizeof(wchar_t) == sizeof(gunichar)) | 12053 if(sizeof(wchar_t) == sizeof(gunichar)) |
12047 freeme = retval = (wchar_t *)g_utf8_to_ucs4(utf8string, -1, NULL, NULL, NULL); | 12054 freeme = retval = (wchar_t *)g_utf8_to_ucs4(utf8string, -1, NULL, NULL, NULL); |
12048 else if(sizeof(wchar_t) == sizeof(gunichar2)) | 12055 else if(sizeof(wchar_t) == sizeof(gunichar2)) |
12049 freeme = retval = (wchar_t *)g_utf8_to_utf16(utf8string, -1, NULL, NULL, NULL); | 12056 freeme = retval = (wchar_t *)g_utf8_to_utf16(utf8string, -1, NULL, NULL, NULL); |
12050 if(retval) | 12057 if(retval) |
12051 { | 12058 { |
12052 retval = wcsdup(retval); | 12059 retval = wcsdup(retval); |
12053 g_free(freeme); | 12060 g_free(freeme); |
12064 * or NULL on failure. | 12071 * or NULL on failure. |
12065 */ | 12072 */ |
12066 char * API dw_wchar_to_utf8(wchar_t *wstring) | 12073 char * API dw_wchar_to_utf8(wchar_t *wstring) |
12067 { | 12074 { |
12068 char *retval = NULL, *freeme; | 12075 char *retval = NULL, *freeme; |
12069 | 12076 |
12070 if(sizeof(wchar_t) == sizeof(gunichar)) | 12077 if(sizeof(wchar_t) == sizeof(gunichar)) |
12071 freeme = retval = g_ucs4_to_utf8((gunichar *)wstring, -1, NULL, NULL, NULL); | 12078 freeme = retval = g_ucs4_to_utf8((gunichar *)wstring, -1, NULL, NULL, NULL); |
12072 else if(sizeof(wchar_t) == sizeof(gunichar2)) | 12079 else if(sizeof(wchar_t) == sizeof(gunichar2)) |
12073 freeme = retval = g_utf16_to_utf8((gunichar2 *)wstring, -1, NULL, NULL, NULL); | 12080 freeme = retval = g_utf16_to_utf8((gunichar2 *)wstring, -1, NULL, NULL, NULL); |
12074 if(retval) | 12081 if(retval) |
12075 { | 12082 { |
12076 retval = strdup(retval); | 12083 retval = strdup(retval); |
12077 g_free(freeme); | 12084 g_free(freeme); |
12078 } | 12085 } |
12079 return retval; | 12086 return retval; |
12080 } | 12087 } |
12081 | 12088 |