comparison gtk4/dw.c @ 2323:4b04943319c5

GTK4: Move a few more functions into thread safety. Add API to functions that were missing it. API is used for speficying calling convention, that isn't usually required on Unix, but should be there for future use. The thread safety macros will automatically add API, so just required to add it to ones not in the thread safety system.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 17 Feb 2021 06:21:27 +0000
parents ebcaedfa7ff4
children 610c66b17fbc
comparison
equal deleted inserted replaced
2322:ebcaedfa7ff4 2323:4b04943319c5
1349 * Initializes the Dynamic Windows engine. 1349 * Initializes the Dynamic Windows engine.
1350 * Parameters: 1350 * Parameters:
1351 * newthread: True if this is the only thread. 1351 * newthread: True if this is the only thread.
1352 * False if there is already a message loop running. 1352 * False if there is already a message loop running.
1353 */ 1353 */
1354 int dw_init(int newthread, int argc, char *argv[]) 1354 int API dw_init(int newthread, int argc, char *argv[])
1355 { 1355 {
1356 /* Setup the private data directory */ 1356 /* Setup the private data directory */
1357 if(argc > 0 && argv[0]) 1357 if(argc > 0 && argv[0])
1358 { 1358 {
1359 char *pathcopy = strdup(argv[0]); 1359 char *pathcopy = strdup(argv[0]);
1507 * Free's memory allocated by dynamic windows. 1507 * Free's memory allocated by dynamic windows.
1508 * Parameters: 1508 * Parameters:
1509 * ptr: Pointer to dynamic windows allocated 1509 * ptr: Pointer to dynamic windows allocated
1510 * memory to be free()'d. 1510 * memory to be free()'d.
1511 */ 1511 */
1512 void dw_free(void *ptr) 1512 void API dw_free(void *ptr)
1513 { 1513 {
1514 free(ptr); 1514 free(ptr);
1515 } 1515 }
1516 1516
1517 /* 1517 /*
1518 * Allocates and initializes a dialog struct. 1518 * Allocates and initializes a dialog struct.
1519 * Parameters: 1519 * Parameters:
1520 * data: User defined data to be passed to functions. 1520 * data: User defined data to be passed to functions.
1521 */ 1521 */
1522 DWDialog *dw_dialog_new(void *data) 1522 DWDialog * API dw_dialog_new(void *data)
1523 { 1523 {
1524 DWDialog *tmp = calloc(sizeof(DWDialog), 1); 1524 DWDialog *tmp = calloc(sizeof(DWDialog), 1);
1525 1525
1526 if(tmp) 1526 if(tmp)
1527 { 1527 {
1539 * initial called of dw_dialog_wait(). 1539 * initial called of dw_dialog_wait().
1540 * Parameters: 1540 * Parameters:
1541 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 1541 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
1542 * result: Data to be returned by dw_dialog_wait(). 1542 * result: Data to be returned by dw_dialog_wait().
1543 */ 1543 */
1544 int dw_dialog_dismiss(DWDialog *dialog, void *result) 1544 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
1545 { 1545 {
1546 dialog->result = result; 1546 dialog->result = result;
1547 if(dialog->method) 1547 if(dialog->method)
1548 g_main_loop_quit(dialog->mainloop); 1548 g_main_loop_quit(dialog->mainloop);
1549 else 1549 else
1556 * Accepts a dialog struct waits for dw_dialog_dismiss() to be 1556 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
1557 * called by a signal handler with the given dialog struct. 1557 * called by a signal handler with the given dialog struct.
1558 * Parameters: 1558 * Parameters:
1559 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 1559 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
1560 */ 1560 */
1561 void *dw_dialog_wait(DWDialog *dialog) 1561 void * API dw_dialog_wait(DWDialog *dialog)
1562 { 1562 {
1563 void *tmp; 1563 void *tmp;
1564 1564
1565 if(!dialog) 1565 if(!dialog)
1566 return NULL; 1566 return NULL;
1607 * title: The title of the message box. 1607 * title: The title of the message box.
1608 * flags: Defines buttons and icons to display 1608 * flags: Defines buttons and icons to display
1609 * format: printf style format string. 1609 * format: printf style format string.
1610 * ...: Additional variables for use in the format. 1610 * ...: Additional variables for use in the format.
1611 */ 1611 */
1612 int dw_messagebox(const char *title, int flags, const char *format, ...) 1612 int API dw_messagebox(const char *title, int flags, const char *format, ...)
1613 { 1613 {
1614 GtkMessageType gtkicon = GTK_MESSAGE_OTHER; 1614 GtkMessageType gtkicon = GTK_MESSAGE_OTHER;
1615 GtkButtonsType gtkbuttons = GTK_BUTTONS_OK; 1615 GtkButtonsType gtkbuttons = GTK_BUTTONS_OK;
1616 GtkWidget *dialog; 1616 GtkWidget *dialog;
1617 int response; 1617 int response;
1695 * Makes the window topmost. 1695 * Makes the window topmost.
1696 * Parameters: 1696 * Parameters:
1697 * handle: The window handle to make topmost. 1697 * handle: The window handle to make topmost.
1698 */ 1698 */
1699 #ifndef GDK_WINDOWING_X11 1699 #ifndef GDK_WINDOWING_X11
1700 int dw_window_raise(HWND handle) 1700 int API dw_window_raise(HWND handle)
1701 { 1701 {
1702 return DW_ERROR_UNKNOWN; 1702 return DW_ERROR_UNKNOWN;
1703 } 1703 }
1704 #else 1704 #else
1705 DW_FUNCTION_DEFINITION(dw_window_raise, int, HWND handle) 1705 DW_FUNCTION_DEFINITION(dw_window_raise, int, HWND handle)
1727 * Makes the window bottommost. 1727 * Makes the window bottommost.
1728 * Parameters: 1728 * Parameters:
1729 * handle: The window handle to make bottommost. 1729 * handle: The window handle to make bottommost.
1730 */ 1730 */
1731 #ifndef GDK_WINDOWING_X11 1731 #ifndef GDK_WINDOWING_X11
1732 int dw_window_lower(HWND handle) 1732 int API dw_window_lower(HWND handle)
1733 { 1733 {
1734 return DW_ERROR_UNKNOWN; 1734 return DW_ERROR_UNKNOWN;
1735 } 1735 }
1736 #else 1736 #else
1737 DW_FUNCTION_DEFINITION(dw_window_lower, int, HWND handle) 1737 DW_FUNCTION_DEFINITION(dw_window_lower, int, HWND handle)
1872 1872
1873 /* Causes entire window to be invalidated and redrawn. 1873 /* Causes entire window to be invalidated and redrawn.
1874 * Parameters: 1874 * Parameters:
1875 * handle: Toplevel window handle to be redrawn. 1875 * handle: Toplevel window handle to be redrawn.
1876 */ 1876 */
1877 void dw_window_redraw(HWND handle) 1877 void API dw_window_redraw(HWND handle)
1878 { 1878 {
1879 } 1879 }
1880 1880
1881 /* 1881 /*
1882 * Changes a window's parent to newparent. 1882 * Changes a window's parent to newparent.
2289 * Sets the font used by a specified window (widget) handle. 2289 * Sets the font used by a specified window (widget) handle.
2290 * Parameters: 2290 * Parameters:
2291 * handle: The window (widget) handle. 2291 * handle: The window (widget) handle.
2292 * border: Size of the window border in pixels. 2292 * border: Size of the window border in pixels.
2293 */ 2293 */
2294 int dw_window_set_border(HWND handle, int border) 2294 int API dw_window_set_border(HWND handle, int border)
2295 { 2295 {
2296 /* TODO */ 2296 /* TODO */
2297 return 0; 2297 return 0;
2298 } 2298 }
2299 2299
2330 * Captures the mouse input to this window. 2330 * Captures the mouse input to this window.
2331 * Parameters: 2331 * Parameters:
2332 * handle: Handle to receive mouse input. 2332 * handle: Handle to receive mouse input.
2333 */ 2333 */
2334 #ifndef GDK_WINDOWING_X11 2334 #ifndef GDK_WINDOWING_X11
2335 void dw_window_capture(HWND handle) 2335 void API dw_window_capture(HWND handle)
2336 { 2336 {
2337 } 2337 }
2338 #else 2338 #else
2339 static Display *_DWXGrabbedDisplay = NULL; 2339 static Display *_DWXGrabbedDisplay = NULL;
2340 2340
2362 2362
2363 /* 2363 /*
2364 * Releases previous mouse capture. 2364 * Releases previous mouse capture.
2365 */ 2365 */
2366 #ifndef GDK_WINDOWING_X11 2366 #ifndef GDK_WINDOWING_X11
2367 void dw_window_release(void) 2367 void API dw_window_release(void)
2368 { 2368 {
2369 } 2369 }
2370 #else 2370 #else
2371 DW_FUNCTION_DEFINITION(dw_window_release, void) 2371 DW_FUNCTION_DEFINITION(dw_window_release, void)
2372 DW_FUNCTION_ADD_PARAM 2372 DW_FUNCTION_ADD_PARAM
3106 * Parameters: 3106 * Parameters:
3107 * x: X coordinate. 3107 * x: X coordinate.
3108 * y: Y coordinate. 3108 * y: Y coordinate.
3109 */ 3109 */
3110 #ifndef GDK_WINDOWING_X11 3110 #ifndef GDK_WINDOWING_X11
3111 void dw_pointer_set_pos(long x, long y) 3111 void API dw_pointer_set_pos(long x, long y)
3112 { 3112 {
3113 } 3113 }
3114 #else 3114 #else
3115 DW_FUNCTION_DEFINITION(dw_pointer_set_pos, void, long x, long y) 3115 DW_FUNCTION_DEFINITION(dw_pointer_set_pos, void, long x, long y)
3116 DW_FUNCTION_ADD_PARAM2(x, y) 3116 DW_FUNCTION_ADD_PARAM2(x, y)
4220 * Sets the word auto complete state of an MLE box. 4220 * Sets the word auto complete state of an MLE box.
4221 * Parameters: 4221 * Parameters:
4222 * handle: Handle to the MLE. 4222 * handle: Handle to the MLE.
4223 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE 4223 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE
4224 */ 4224 */
4225 void dw_mle_set_auto_complete(HWND handle, int state) 4225 void API dw_mle_set_auto_complete(HWND handle, int state)
4226 { 4226 {
4227 } 4227 }
4228 4228
4229 /* 4229 /*
4230 * Sets the current cursor position of an MLE box. 4230 * Sets the current cursor position of an MLE box.
4300 /* 4300 /*
4301 * Stops redrawing of an MLE box. 4301 * Stops redrawing of an MLE box.
4302 * Parameters: 4302 * Parameters:
4303 * handle: Handle to the MLE to freeze. 4303 * handle: Handle to the MLE to freeze.
4304 */ 4304 */
4305 void dw_mle_freeze(HWND handle) 4305 void API dw_mle_freeze(HWND handle)
4306 { 4306 {
4307 } 4307 }
4308 4308
4309 /* 4309 /*
4310 * Resumes redrawing of an MLE box. 4310 * Resumes redrawing of an MLE box.
4311 * Parameters: 4311 * Parameters:
4312 * handle: Handle to the MLE to thaw. 4312 * handle: Handle to the MLE to thaw.
4313 */ 4313 */
4314 void dw_mle_thaw(HWND handle) 4314 void API dw_mle_thaw(HWND handle)
4315 { 4315 {
4316 } 4316 }
4317 4317
4318 /* Internal function to update the progress bar 4318 /* Internal function to update the progress bar
4319 * while in an indeterminate state. 4319 * while in an indeterminate state.
5120 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE); 5120 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE);
5121 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree), TRUE); 5121 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree), TRUE);
5122 gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tree), TRUE); 5122 gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tree), TRUE);
5123 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); 5123 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
5124 if(g_object_get_data(G_OBJECT(handle), "_dw_multi_sel")) 5124 if(g_object_get_data(G_OBJECT(handle), "_dw_multi_sel"))
5125 {
5126 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE); 5125 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
5127 }
5128 else 5126 else
5129 {
5130 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); 5127 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
5131 }
5132 gtk_widget_show(tree); 5128 gtk_widget_show(tree);
5133 free(array); 5129 free(array);
5134 if(_DWDefaultFont) 5130 if(_DWDefaultFont)
5135 dw_window_set_font(handle, _DWDefaultFont); 5131 dw_window_set_font(handle, _DWDefaultFont);
5136 return DW_ERROR_NONE; 5132 return DW_ERROR_NONE;
5212 * module: Handle to module (DLL) in OS/2 and Windows. 5208 * module: Handle to module (DLL) in OS/2 and Windows.
5213 * id: A unsigned long id int the resources on OS/2 and 5209 * id: A unsigned long id int the resources on OS/2 and
5214 * Windows, on GTK this is converted to a pointer 5210 * Windows, on GTK this is converted to a pointer
5215 * to an embedded XPM. 5211 * to an embedded XPM.
5216 */ 5212 */
5217 HICN dw_icon_load(unsigned long module, unsigned long id) 5213 HICN API dw_icon_load(unsigned long module, unsigned long id)
5218 { 5214 {
5219 return (HICN)id; 5215 return (HICN)id;
5220 } 5216 }
5221 5217
5222 /* Internal function to keep HICNs from getting too big */ 5218 /* Internal function to keep HICNs from getting too big */
5307 /* 5303 /*
5308 * Frees a loaded resource in OS/2 and Windows. 5304 * Frees a loaded resource in OS/2 and Windows.
5309 * Parameters: 5305 * Parameters:
5310 * handle: Handle to icon returned by dw_icon_load(). 5306 * handle: Handle to icon returned by dw_icon_load().
5311 */ 5307 */
5312 void dw_icon_free(HICN handle) 5308 void API dw_icon_free(HICN handle)
5313 { 5309 {
5314 int iicon = GPOINTER_TO_INT(handle); 5310 int iicon = GPOINTER_TO_INT(handle);
5315 5311
5316 if(iicon > 65535) 5312 if(iicon > 65535)
5317 { 5313 {
5735 * Parameters: 5731 * Parameters:
5736 * handle: Handle to the container window (widget). 5732 * handle: Handle to the container window (widget).
5737 * pointer: Pointer to the allocated memory in dw_container_alloc(). 5733 * pointer: Pointer to the allocated memory in dw_container_alloc().
5738 * rowcount: The number of rows to be inserted. 5734 * rowcount: The number of rows to be inserted.
5739 */ 5735 */
5740 void dw_container_insert(HWND handle, void *pointer, int rowcount) 5736 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
5741 { 5737 {
5742 /* Don't need to do anything here */ 5738 /* Don't need to do anything here */
5743 } 5739 }
5744 5740
5745 /* 5741 /*
6229 * Parameters: 6225 * Parameters:
6230 * handle: Window handle that will handle taskbar icon messages. 6226 * handle: Window handle that will handle taskbar icon messages.
6231 * icon: Icon handle to display in the taskbar. 6227 * icon: Icon handle to display in the taskbar.
6232 * bubbletext: Text to show when the mouse is above the icon. 6228 * bubbletext: Text to show when the mouse is above the icon.
6233 */ 6229 */
6234 void dw_taskbar_insert(HWND handle, HICN icon, const char *bubbletext) 6230 void API dw_taskbar_insert(HWND handle, HICN icon, const char *bubbletext)
6235 { 6231 {
6236 /* TODO: Removed in GTK4.... no replacement? */ 6232 /* TODO: Removed in GTK4.... no replacement? */
6237 } 6233 }
6238 6234
6239 /* 6235 /*
6240 * Deletes an icon from the taskbar. 6236 * Deletes an icon from the taskbar.
6241 * Parameters: 6237 * Parameters:
6242 * handle: Window handle that was used with dw_taskbar_insert(). 6238 * handle: Window handle that was used with dw_taskbar_insert().
6243 * icon: Icon handle that was used with dw_taskbar_insert(). 6239 * icon: Icon handle that was used with dw_taskbar_insert().
6244 */ 6240 */
6245 void dw_taskbar_delete(HWND handle, HICN icon) 6241 void API dw_taskbar_delete(HWND handle, HICN icon)
6246 { 6242 {
6247 /* TODO: Removed in GTK4.... no replacement? */ 6243 /* TODO: Removed in GTK4.... no replacement? */
6248 } 6244 }
6249 6245
6250 /* 6246 /*
6285 * Parameters: 6281 * Parameters:
6286 * red: red value. 6282 * red: red value.
6287 * green: green value. 6283 * green: green value.
6288 * blue: blue value. 6284 * blue: blue value.
6289 */ 6285 */
6290 void dw_color_foreground_set(unsigned long value) 6286 void API dw_color_foreground_set(unsigned long value)
6291 { 6287 {
6292 GdkRGBA color = _dw_internal_color(value); 6288 GdkRGBA color = _dw_internal_color(value);
6293 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key); 6289 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
6294 6290
6295 *foreground = color; 6291 *foreground = color;
6299 * Parameters: 6295 * Parameters:
6300 * red: red value. 6296 * red: red value.
6301 * green: green value. 6297 * green: green value.
6302 * blue: blue value. 6298 * blue: blue value.
6303 */ 6299 */
6304 void dw_color_background_set(unsigned long value) 6300 void API dw_color_background_set(unsigned long value)
6305 { 6301 {
6306 GdkRGBA *background = pthread_getspecific(_dw_bg_color_key); 6302 GdkRGBA *background = pthread_getspecific(_dw_bg_color_key);
6307 6303
6308 if(value == DW_CLR_DEFAULT) 6304 if(value == DW_CLR_DEFAULT)
6309 { 6305 {
7009 * dw_pixmap_new.. 7005 * dw_pixmap_new..
7010 * color: transparent color 7006 * color: transparent color
7011 * Note: This does nothing on GTK+ as transparency 7007 * Note: This does nothing on GTK+ as transparency
7012 * is handled automatically 7008 * is handled automatically
7013 */ 7009 */
7014 void dw_pixmap_set_transparent_color(HPIXMAP pixmap, unsigned long color) 7010 void API dw_pixmap_set_transparent_color(HPIXMAP pixmap, unsigned long color)
7015 { 7011 {
7016 } 7012 }
7017 7013
7018 /* 7014 /*
7019 * Creates a pixmap from internal resource graphic specified by id. 7015 * Creates a pixmap from internal resource graphic specified by id.
7039 } 7035 }
7040 7036
7041 /* Call this after drawing to the screen to make sure 7037 /* Call this after drawing to the screen to make sure
7042 * anything you have drawn is visible. 7038 * anything you have drawn is visible.
7043 */ 7039 */
7044 void dw_flush(void) 7040 void API dw_flush(void)
7045 { 7041 {
7046 } 7042 }
7047 7043
7048 /* 7044 /*
7049 * Sets the font used by a specified pixmap. 7045 * Sets the font used by a specified pixmap.
7170 cairo_scale(cr, xscale, yscale); 7166 cairo_scale(cr, xscale, yscale);
7171 } 7167 }
7172 7168
7173 if(src) 7169 if(src)
7174 ; 7170 ;
7175 #ifdef GTK3 7171 #ifdef GTK3 /* TODO: See how to do this in GTK4 */
7176 gdk_cairo_set_source_window (cr, gtk_widget_get_window(src), (xdest + xsrc) / xscale, (ydest + ysrc) / yscale); 7172 gdk_cairo_set_source_window (cr, gtk_widget_get_window(src), (xdest + xsrc) / xscale, (ydest + ysrc) / yscale);
7177 #endif 7173 #endif
7178 else if(srcp) 7174 else if(srcp)
7179 cairo_set_source_surface (cr, srcp->image, (xdest + xsrc) / xscale, (ydest + ysrc) / yscale); 7175 cairo_set_source_surface (cr, srcp->image, (xdest + xsrc) / xscale, (ydest + ysrc) / yscale);
7180 7176
7196 * Emits a beep. 7192 * Emits a beep.
7197 * Parameters: 7193 * Parameters:
7198 * freq: Frequency. 7194 * freq: Frequency.
7199 * dur: Duration. 7195 * dur: Duration.
7200 */ 7196 */
7201 void dw_beep(int freq, int dur) 7197 void API dw_beep(int freq, int dur)
7202 { 7198 {
7203 gdk_display_beep(gdk_display_get_default()); 7199 gdk_display_beep(gdk_display_get_default());
7204 } 7200 }
7205 7201
7206 void _dw_strlwr(char *buf) 7202 void _dw_strlwr(char *buf)
7218 * Parameters: 7214 * Parameters:
7219 * name: Base name of the shared library. 7215 * name: Base name of the shared library.
7220 * handle: Pointer to a module handle, 7216 * handle: Pointer to a module handle,
7221 * will be filled in with the handle. 7217 * will be filled in with the handle.
7222 */ 7218 */
7223 int dw_module_load(const char *name, HMOD *handle) 7219 int API dw_module_load(const char *name, HMOD *handle)
7224 { 7220 {
7225 int len; 7221 int len;
7226 char *newname; 7222 char *newname;
7227 char errorbuf[1025] = {0}; 7223 char errorbuf[1025] = {0};
7228 7224
7261 * handle: Module handle returned by dw_module_load() 7257 * handle: Module handle returned by dw_module_load()
7262 * name: Name of the symbol you want the address of. 7258 * name: Name of the symbol you want the address of.
7263 * func: A pointer to a function pointer, to obtain 7259 * func: A pointer to a function pointer, to obtain
7264 * the address. 7260 * the address.
7265 */ 7261 */
7266 int dw_module_symbol(HMOD handle, const char *name, void**func) 7262 int API dw_module_symbol(HMOD handle, const char *name, void**func)
7267 { 7263 {
7268 if(!func || !name) 7264 if(!func || !name)
7269 return -1; 7265 return -1;
7270 7266
7271 if(strlen(name) == 0) 7267 if(strlen(name) == 0)
7277 7273
7278 /* Frees the shared library previously opened. 7274 /* Frees the shared library previously opened.
7279 * Parameters: 7275 * Parameters:
7280 * handle: Module handle returned by dw_module_load() 7276 * handle: Module handle returned by dw_module_load()
7281 */ 7277 */
7282 int dw_module_close(HMOD handle) 7278 int API dw_module_close(HMOD handle)
7283 { 7279 {
7284 if(handle) 7280 if(handle)
7285 return dlclose(handle); 7281 return dlclose(handle);
7286 return 0; 7282 return 0;
7287 } 7283 }
7288 7284
7289 /* 7285 /*
7290 * Returns the handle to an unnamed mutex semaphore. 7286 * Returns the handle to an unnamed mutex semaphore.
7291 */ 7287 */
7292 HMTX dw_mutex_new(void) 7288 HMTX API dw_mutex_new(void)
7293 { 7289 {
7294 HMTX mutex = malloc(sizeof(pthread_mutex_t)); 7290 HMTX mutex = malloc(sizeof(pthread_mutex_t));
7295 7291
7296 pthread_mutex_init(mutex, NULL); 7292 pthread_mutex_init(mutex, NULL);
7297 return mutex; 7293 return mutex;
7300 /* 7296 /*
7301 * Closes a semaphore created by dw_mutex_new(). 7297 * Closes a semaphore created by dw_mutex_new().
7302 * Parameters: 7298 * Parameters:
7303 * mutex: The handle to the mutex returned by dw_mutex_new(). 7299 * mutex: The handle to the mutex returned by dw_mutex_new().
7304 */ 7300 */
7305 void dw_mutex_close(HMTX mutex) 7301 void API dw_mutex_close(HMTX mutex)
7306 { 7302 {
7307 if(mutex) 7303 if(mutex)
7308 { 7304 {
7309 pthread_mutex_destroy(mutex); 7305 pthread_mutex_destroy(mutex);
7310 free(mutex); 7306 free(mutex);
7314 /* 7310 /*
7315 * Tries to gain access to the semaphore, if it can't it blocks. 7311 * Tries to gain access to the semaphore, if it can't it blocks.
7316 * Parameters: 7312 * Parameters:
7317 * mutex: The handle to the mutex returned by dw_mutex_new(). 7313 * mutex: The handle to the mutex returned by dw_mutex_new().
7318 */ 7314 */
7319 void dw_mutex_lock(HMTX mutex) 7315 void API dw_mutex_lock(HMTX mutex)
7320 { 7316 {
7321 pthread_mutex_lock(mutex); 7317 pthread_mutex_lock(mutex);
7322 } 7318 }
7323 7319
7324 /* 7320 /*
7338 /* 7334 /*
7339 * Reliquishes the access to the semaphore. 7335 * Reliquishes the access to the semaphore.
7340 * Parameters: 7336 * Parameters:
7341 * mutex: The handle to the mutex returned by dw_mutex_new(). 7337 * mutex: The handle to the mutex returned by dw_mutex_new().
7342 */ 7338 */
7343 void dw_mutex_unlock(HMTX mutex) 7339 void API dw_mutex_unlock(HMTX mutex)
7344 { 7340 {
7345 pthread_mutex_unlock(mutex); 7341 pthread_mutex_unlock(mutex);
7346 } 7342 }
7347 7343
7348 /* 7344 /*
7349 * Returns the handle to an unnamed event semaphore. 7345 * Returns the handle to an unnamed event semaphore.
7350 */ 7346 */
7351 HEV dw_event_new(void) 7347 HEV API dw_event_new(void)
7352 { 7348 {
7353 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); 7349 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
7354 7350
7355 if(!eve) 7351 if(!eve)
7356 return NULL; 7352 return NULL;
7373 /* 7369 /*
7374 * Resets a semaphore created by dw_event_new(). 7370 * Resets a semaphore created by dw_event_new().
7375 * Parameters: 7371 * Parameters:
7376 * eve: The handle to the event returned by dw_event_new(). 7372 * eve: The handle to the event returned by dw_event_new().
7377 */ 7373 */
7378 int dw_event_reset (HEV eve) 7374 int API dw_event_reset (HEV eve)
7379 { 7375 {
7380 if(!eve) 7376 if(!eve)
7381 return DW_ERROR_NON_INIT; 7377 return DW_ERROR_NON_INIT;
7382 7378
7383 pthread_mutex_lock (&(eve->mutex)); 7379 pthread_mutex_lock (&(eve->mutex));
7392 * Posts a semaphore created by dw_event_new(). Causing all threads 7388 * Posts a semaphore created by dw_event_new(). Causing all threads
7393 * waiting on this event in dw_event_wait to continue. 7389 * waiting on this event in dw_event_wait to continue.
7394 * Parameters: 7390 * Parameters:
7395 * eve: The handle to the event returned by dw_event_new(). 7391 * eve: The handle to the event returned by dw_event_new().
7396 */ 7392 */
7397 int dw_event_post (HEV eve) 7393 int API dw_event_post (HEV eve)
7398 { 7394 {
7399 if(!eve) 7395 if(!eve)
7400 return DW_ERROR_NON_INIT; 7396 return DW_ERROR_NON_INIT;
7401 7397
7402 pthread_mutex_lock (&(eve->mutex)); 7398 pthread_mutex_lock (&(eve->mutex));
7410 * Waits on a semaphore created by dw_event_new(), until the 7406 * Waits on a semaphore created by dw_event_new(), until the
7411 * event gets posted or until the timeout expires. 7407 * event gets posted or until the timeout expires.
7412 * Parameters: 7408 * Parameters:
7413 * eve: The handle to the event returned by dw_event_new(). 7409 * eve: The handle to the event returned by dw_event_new().
7414 */ 7410 */
7415 int dw_event_wait(HEV eve, unsigned long timeout) 7411 int API dw_event_wait(HEV eve, unsigned long timeout)
7416 { 7412 {
7417 int rc; 7413 int rc;
7418 7414
7419 if(!eve) 7415 if(!eve)
7420 return DW_ERROR_NON_INIT; 7416 return DW_ERROR_NON_INIT;
7451 /* 7447 /*
7452 * Closes a semaphore created by dw_event_new(). 7448 * Closes a semaphore created by dw_event_new().
7453 * Parameters: 7449 * Parameters:
7454 * eve: The handle to the event returned by dw_event_new(). 7450 * eve: The handle to the event returned by dw_event_new().
7455 */ 7451 */
7456 int dw_event_close(HEV *eve) 7452 int API dw_event_close(HEV *eve)
7457 { 7453 {
7458 if(!eve || !(*eve)) 7454 if(!eve || !(*eve))
7459 return DW_ERROR_NON_INIT; 7455 return DW_ERROR_NON_INIT;
7460 7456
7461 pthread_mutex_lock (&((*eve)->mutex)); 7457 pthread_mutex_lock (&((*eve)->mutex));
7628 * Parameters: 7624 * Parameters:
7629 * eve: Pointer to an event handle to receive handle. 7625 * eve: Pointer to an event handle to receive handle.
7630 * name: Name given to semaphore which can be opened 7626 * name: Name given to semaphore which can be opened
7631 * by other processes. 7627 * by other processes.
7632 */ 7628 */
7633 HEV dw_named_event_new(const char *name) 7629 HEV API dw_named_event_new(const char *name)
7634 { 7630 {
7635 struct sockaddr_un un; 7631 struct sockaddr_un un;
7636 int ev, *tmpsock = (int *)malloc(sizeof(int)*2); 7632 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
7637 DWTID dwthread; 7633 DWTID dwthread;
7638 7634
7678 * Parameters: 7674 * Parameters:
7679 * eve: Pointer to an event handle to receive handle. 7675 * eve: Pointer to an event handle to receive handle.
7680 * name: Name given to semaphore which can be opened 7676 * name: Name given to semaphore which can be opened
7681 * by other processes. 7677 * by other processes.
7682 */ 7678 */
7683 HEV dw_named_event_get(const char *name) 7679 HEV API dw_named_event_get(const char *name)
7684 { 7680 {
7685 struct sockaddr_un un; 7681 struct sockaddr_un un;
7686 int ev = socket(AF_UNIX, SOCK_STREAM, 0); 7682 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
7687 if(ev < 0) 7683 if(ev < 0)
7688 return NULL; 7684 return NULL;
7699 * on this semaphore will block. 7695 * on this semaphore will block.
7700 * Parameters: 7696 * Parameters:
7701 * eve: Handle to the semaphore obtained by 7697 * eve: Handle to the semaphore obtained by
7702 * an open or create call. 7698 * an open or create call.
7703 */ 7699 */
7704 int dw_named_event_reset(HEV eve) 7700 int API dw_named_event_reset(HEV eve)
7705 { 7701 {
7706 /* signal reset */ 7702 /* signal reset */
7707 char tmp = (char)0; 7703 char tmp = (char)0;
7708 7704
7709 if(GPOINTER_TO_INT(eve) < 0) 7705 if(GPOINTER_TO_INT(eve) < 0)
7718 * waiting on the semaphore will no longer block. 7714 * waiting on the semaphore will no longer block.
7719 * Parameters: 7715 * Parameters:
7720 * eve: Handle to the semaphore obtained by 7716 * eve: Handle to the semaphore obtained by
7721 * an open or create call. 7717 * an open or create call.
7722 */ 7718 */
7723 int dw_named_event_post(HEV eve) 7719 int API dw_named_event_post(HEV eve)
7724 { 7720 {
7725 7721
7726 /* signal post */ 7722 /* signal post */
7727 char tmp = (char)1; 7723 char tmp = (char)1;
7728 7724
7740 * eve: Handle to the semaphore obtained by 7736 * eve: Handle to the semaphore obtained by
7741 * an open or create call. 7737 * an open or create call.
7742 * timeout: Number of milliseconds before timing out 7738 * timeout: Number of milliseconds before timing out
7743 * or -1 if indefinite. 7739 * or -1 if indefinite.
7744 */ 7740 */
7745 int dw_named_event_wait(HEV eve, unsigned long timeout) 7741 int API dw_named_event_wait(HEV eve, unsigned long timeout)
7746 { 7742 {
7747 fd_set rd; 7743 fd_set rd;
7748 struct timeval tv, *useme = NULL; 7744 struct timeval tv, *useme = NULL;
7749 int retval = 0; 7745 int retval = 0;
7750 char tmp; 7746 char tmp;
7793 * handles on this semaphore the semaphore will be destroyed. 7789 * handles on this semaphore the semaphore will be destroyed.
7794 * Parameters: 7790 * Parameters:
7795 * eve: Handle to the semaphore obtained by 7791 * eve: Handle to the semaphore obtained by
7796 * an open or create call. 7792 * an open or create call.
7797 */ 7793 */
7798 int dw_named_event_close(HEV eve) 7794 int API dw_named_event_close(HEV eve)
7799 { 7795 {
7800 /* Finally close the domain socket, 7796 /* Finally close the domain socket,
7801 * cleanup will continue in _dw_handle_sem. 7797 * cleanup will continue in _dw_handle_sem.
7802 */ 7798 */
7803 close(GPOINTER_TO_INT(eve)); 7799 close(GPOINTER_TO_INT(eve));
7866 * handle: A pointer to receive a SHM identifier. 7862 * handle: A pointer to receive a SHM identifier.
7867 * dest: A pointer to a pointer to receive the memory address. 7863 * dest: A pointer to a pointer to receive the memory address.
7868 * size: Size in bytes of the shared memory region to allocate. 7864 * size: Size in bytes of the shared memory region to allocate.
7869 * name: A string pointer to a unique memory name. 7865 * name: A string pointer to a unique memory name.
7870 */ 7866 */
7871 HSHM dw_named_memory_new(void **dest, int size, const char *name) 7867 HSHM API dw_named_memory_new(void **dest, int size, const char *name)
7872 { 7868 {
7873 char namebuf[1025]; 7869 char namebuf[1025];
7874 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); 7870 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
7875 7871
7876 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); 7872 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
7912 * Parameters: 7908 * Parameters:
7913 * dest: A pointer to a pointer to receive the memory address. 7909 * dest: A pointer to a pointer to receive the memory address.
7914 * size: Size in bytes of the shared memory region to requested. 7910 * size: Size in bytes of the shared memory region to requested.
7915 * name: A string pointer to a unique memory name. 7911 * name: A string pointer to a unique memory name.
7916 */ 7912 */
7917 HSHM dw_named_memory_get(void **dest, int size, const char *name) 7913 HSHM API dw_named_memory_get(void **dest, int size, const char *name)
7918 { 7914 {
7919 char namebuf[1025]; 7915 char namebuf[1025];
7920 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); 7916 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
7921 7917
7922 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); 7918 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
7950 * Frees a shared memory region previously allocated. 7946 * Frees a shared memory region previously allocated.
7951 * Parameters: 7947 * Parameters:
7952 * handle: Handle obtained from DB_named_memory_allocate. 7948 * handle: Handle obtained from DB_named_memory_allocate.
7953 * ptr: The memory address aquired with DB_named_memory_allocate. 7949 * ptr: The memory address aquired with DB_named_memory_allocate.
7954 */ 7950 */
7955 int dw_named_memory_free(HSHM handle, void *ptr) 7951 int API dw_named_memory_free(HSHM handle, void *ptr)
7956 { 7952 {
7957 struct _dw_unix_shm *h = handle; 7953 struct _dw_unix_shm *h = handle;
7958 int rc = munmap(ptr, h->size); 7954 int rc = munmap(ptr, h->size);
7959 7955
7960 close(h->fd); 7956 close(h->fd);
7974 * Parameters: 7970 * Parameters:
7975 * func: Function which will be run in the new thread. 7971 * func: Function which will be run in the new thread.
7976 * data: Parameter(s) passed to the function. 7972 * data: Parameter(s) passed to the function.
7977 * stack: Stack size of new thread (OS/2 and Windows only). 7973 * stack: Stack size of new thread (OS/2 and Windows only).
7978 */ 7974 */
7979 DWTID dw_thread_new(void *func, void *data, int stack) 7975 DWTID API dw_thread_new(void *func, void *data, int stack)
7980 { 7976 {
7981 DWTID gtkthread; 7977 DWTID gtkthread;
7982 void **tmp = malloc(sizeof(void *) * 2); 7978 void **tmp = malloc(sizeof(void *) * 2);
7983 int rc; 7979 int rc;
7984 7980
7992 } 7988 }
7993 7989
7994 /* 7990 /*
7995 * Ends execution of current thread immediately. 7991 * Ends execution of current thread immediately.
7996 */ 7992 */
7997 void dw_thread_end(void) 7993 void API dw_thread_end(void)
7998 { 7994 {
7999 pthread_exit(NULL); 7995 pthread_exit(NULL);
8000 } 7996 }
8001 7997
8002 /* 7998 /*
8003 * Returns the current thread's ID. 7999 * Returns the current thread's ID.
8004 */ 8000 */
8005 DWTID dw_thread_id(void) 8001 DWTID API dw_thread_id(void)
8006 { 8002 {
8007 return (DWTID)pthread_self(); 8003 return (DWTID)pthread_self();
8008 } 8004 }
8009 8005
8010 /* 8006 /*
8011 * Cleanly terminates a DW session, should be signal handler safe. 8007 * Cleanly terminates a DW session, should be signal handler safe.
8012 */ 8008 */
8013 void dw_shutdown(void) 8009 void API dw_shutdown(void)
8014 { 8010 {
8015 g_main_loop_unref(_DWMainLoop); 8011 g_main_loop_unref(_DWMainLoop);
8016 } 8012 }
8017 8013
8018 /* 8014 /*
8019 * Cleanly terminates a DW session, should be signal handler safe. 8015 * Cleanly terminates a DW session, should be signal handler safe.
8020 * Parameters: 8016 * Parameters:
8021 * exitcode: Exit code reported to the operating system. 8017 * exitcode: Exit code reported to the operating system.
8022 */ 8018 */
8023 void dw_exit(int exitcode) 8019 void API dw_exit(int exitcode)
8024 { 8020 {
8025 dw_shutdown(); 8021 dw_shutdown();
8026 exit(exitcode); 8022 exit(exitcode);
8027 } 8023 }
8028 8024
8506 } 8502 }
8507 DW_FUNCTION_RETURN_NOTHING; 8503 DW_FUNCTION_RETURN_NOTHING;
8508 } 8504 }
8509 8505
8510 /* Internal version to simplify the code with multiple versions of GTK */ 8506 /* Internal version to simplify the code with multiple versions of GTK */
8511 int _dw_screen_width(void) 8507 int _dw_get_screen_width(void)
8512 { 8508 {
8513 GdkDisplay *display = gdk_display_get_default(); 8509 GdkDisplay *display = gdk_display_get_default();
8514 8510
8515 if(display) 8511 if(display)
8516 { 8512 {
8528 } 8524 }
8529 8525
8530 /* 8526 /*
8531 * Returns the width of the screen. 8527 * Returns the width of the screen.
8532 */ 8528 */
8533 int dw_screen_width(void) 8529 DW_FUNCTION_DEFINITION(dw_screen_width, int)
8534 { 8530 DW_FUNCTION_ADD_PARAM
8535 return _dw_screen_width(); 8531 DW_FUNCTION_RETURN(dw_screen_width, int)
8532 {
8533 int retval = _dw_get_screen_width();
8534 DW_FUNCTION_RETURN_THIS(retval);
8536 } 8535 }
8537 8536
8538 /* Internal version to simplify the code with multiple versions of GTK */ 8537 /* Internal version to simplify the code with multiple versions of GTK */
8539 int _dw_screen_height(void) 8538 int _dw_get_screen_height(void)
8540 { 8539 {
8541 GdkDisplay *display = gdk_display_get_default(); 8540 GdkDisplay *display = gdk_display_get_default();
8542 8541
8543 if(display) 8542 if(display)
8544 { 8543 {
8556 } 8555 }
8557 8556
8558 /* 8557 /*
8559 * Returns the height of the screen. 8558 * Returns the height of the screen.
8560 */ 8559 */
8561 int dw_screen_height(void) 8560 DW_FUNCTION_DEFINITION(dw_screen_height, int)
8562 { 8561 DW_FUNCTION_ADD_PARAM
8563 return _dw_screen_height(); 8562 DW_FUNCTION_RETURN(dw_screen_height, int)
8563 {
8564 int retval = _dw_get_screen_height();
8565 DW_FUNCTION_RETURN_THIS(retval);
8564 } 8566 }
8565 8567
8566 /* This should return the current color depth */ 8568 /* This should return the current color depth */
8567 unsigned long dw_color_depth_get(void) 8569 unsigned long API dw_color_depth_get(void)
8568 { 8570 {
8569 /* TODO: Make this work on GTK4... with no GdkVisual */ 8571 /* TODO: Make this work on GTK4... with no GdkVisual */
8570 return 32; 8572 return 32;
8571 } 8573 }
8572 8574
8590 * handle: Window (widget) handle. 8592 * handle: Window (widget) handle.
8591 * x: X location from the bottom left. 8593 * x: X location from the bottom left.
8592 * y: Y location from the bottom left. 8594 * y: Y location from the bottom left.
8593 */ 8595 */
8594 #ifndef GDK_WINDOWING_X11 8596 #ifndef GDK_WINDOWING_X11
8595 void dw_window_set_pos(HWND handle, long x, long y) 8597 void API dw_window_set_pos(HWND handle, long x, long y)
8596 { 8598 {
8597 } 8599 }
8598 #else 8600 #else
8599 DW_FUNCTION_DEFINITION(dw_window_set_pos, void, HWND handle, long x, long y) 8601 DW_FUNCTION_DEFINITION(dw_window_set_pos, void, HWND handle, long x, long y)
8600 DW_FUNCTION_ADD_PARAM3(handle, x, y) 8602 DW_FUNCTION_ADD_PARAM3(handle, x, y)
8623 * x: X location from the bottom left. 8625 * x: X location from the bottom left.
8624 * y: Y location from the bottom left. 8626 * y: Y location from the bottom left.
8625 * width: Width of the widget. 8627 * width: Width of the widget.
8626 * height: Height of the widget. 8628 * height: Height of the widget.
8627 */ 8629 */
8628 void dw_window_set_pos_size(HWND handle, long x, long y, unsigned long width, unsigned long height) 8630 void API dw_window_set_pos_size(HWND handle, long x, long y, unsigned long width, unsigned long height)
8629 { 8631 {
8630 dw_window_set_size(handle, width, height); 8632 dw_window_set_size(handle, width, height);
8631 dw_window_set_pos(handle, x, y); 8633 dw_window_set_pos(handle, x, y);
8632 } 8634 }
8633 8635
8956 * Parameters: 8958 * Parameters:
8957 * handle: Notebook handle. 8959 * handle: Notebook handle.
8958 * pageid: Page ID of the tab to set. 8960 * pageid: Page ID of the tab to set.
8959 * text: Pointer to the text to set. 8961 * text: Pointer to the text to set.
8960 */ 8962 */
8961 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, const char *text) 8963 void API dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, const char *text)
8962 { 8964 {
8963 /* TODO (if possible) */ 8965 /* TODO (if possible) */
8964 } 8966 }
8965 8967
8966 /* 8968 /*
9023 * Appends the specified text to the listbox's (or combobox) entry list. 9025 * Appends the specified text to the listbox's (or combobox) entry list.
9024 * Parameters: 9026 * Parameters:
9025 * handle: Handle to the listbox to be appended to. 9027 * handle: Handle to the listbox to be appended to.
9026 * text: Text to append into listbox. 9028 * text: Text to append into listbox.
9027 */ 9029 */
9028 void dw_listbox_append(HWND handle, const char *text) 9030 void API dw_listbox_append(HWND handle, const char *text)
9029 { 9031 {
9030 dw_listbox_insert(handle, text, -1); 9032 dw_listbox_insert(handle, text, -1);
9031 } 9033 }
9032 9034
9033 /* 9035 /*
9799 * window: Toplevel window or dialog. 9801 * window: Toplevel window or dialog.
9800 * defaultitem: Handle to the dialog item to be default. 9802 * defaultitem: Handle to the dialog item to be default.
9801 * Remarks: 9803 * Remarks:
9802 * This is for use before showing the window/dialog. 9804 * This is for use before showing the window/dialog.
9803 */ 9805 */
9804 void dw_window_default(HWND window, HWND defaultitem) 9806 void API dw_window_default(HWND window, HWND defaultitem)
9805 { 9807 {
9806 if(window) 9808 if(window)
9807 g_object_set_data(G_OBJECT(window), "_dw_defaultitem", (gpointer)defaultitem); 9809 g_object_set_data(G_OBJECT(window), "_dw_defaultitem", (gpointer)defaultitem);
9808 } 9810 }
9809 9811
9840 * or NULL if it fails or notifications are not supported by the system. 9842 * or NULL if it fails or notifications are not supported by the system.
9841 * Remarks: 9843 * Remarks:
9842 * This will create a system notification that will show in the notifaction panel 9844 * This will create a system notification that will show in the notifaction panel
9843 * on supported systems, which may be clicked to perform another task. 9845 * on supported systems, which may be clicked to perform another task.
9844 */ 9846 */
9845 HWND dw_notification_new(const char *title, const char *imagepath, const char *description, ...) 9847 HWND API dw_notification_new(const char *title, const char *imagepath, const char *description, ...)
9846 { 9848 {
9847 GNotification *notification = g_notification_new(title); 9849 GNotification *notification = g_notification_new(title);
9848 9850
9849 if(notification) 9851 if(notification)
9850 { 9852 {
9883 * Parameters: 9885 * Parameters:
9884 * notification: The handle to the notification returned by dw_notification_new(). 9886 * notification: The handle to the notification returned by dw_notification_new().
9885 * Returns: 9887 * Returns:
9886 * DW_ERROR_NONE on success, DW_ERROR_UNKNOWN on error or not supported. 9888 * DW_ERROR_NONE on success, DW_ERROR_UNKNOWN on error or not supported.
9887 */ 9889 */
9888 int dw_notification_send(HWND notification) 9890 int API dw_notification_send(HWND notification)
9889 { 9891 {
9890 if(notification) 9892 if(notification)
9891 { 9893 {
9892 char id[101] = {0}; 9894 char id[101] = {0};
9893 9895
9904 /* 9906 /*
9905 * Returns some information about the current operating environment. 9907 * Returns some information about the current operating environment.
9906 * Parameters: 9908 * Parameters:
9907 * env: Pointer to a DWEnv struct. 9909 * env: Pointer to a DWEnv struct.
9908 */ 9910 */
9909 void dw_environment_query(DWEnv *env) 9911 void API dw_environment_query(DWEnv *env)
9910 { 9912 {
9911 struct utsname name; 9913 struct utsname name;
9912 char tempbuf[_DW_ENV_STRING_SIZE] = { 0 }, *dot; 9914 char tempbuf[_DW_ENV_STRING_SIZE] = { 0 }, *dot;
9913 9915
9914 uname(&name); 9916 uname(&name);
10049 * type: Either DW_EXEC_CON or DW_EXEC_GUI. 10051 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
10050 * params: An array of pointers to string arguements. 10052 * params: An array of pointers to string arguements.
10051 * Returns: 10053 * Returns:
10052 * -1 on error. 10054 * -1 on error.
10053 */ 10055 */
10054 int dw_exec(const char *program, int type, char **params) 10056 int API dw_exec(const char *program, int type, char **params)
10055 { 10057 {
10056 int ret = -1; 10058 int ret = -1;
10057 10059
10058 if((ret = fork()) == 0) 10060 if((ret = fork()) == 0)
10059 { 10061 {
10106 /* 10108 /*
10107 * Loads a web browser pointed at the given URL. 10109 * Loads a web browser pointed at the given URL.
10108 * Parameters: 10110 * Parameters:
10109 * url: Uniform resource locator. 10111 * url: Uniform resource locator.
10110 */ 10112 */
10111 int dw_browse(const char *url) 10113 int API dw_browse(const char *url)
10112 { 10114 {
10113 /* If possible load the URL/URI using gvfs... */ 10115 /* If possible load the URL/URI using gvfs... */
10114 gtk_show_uri(NULL, url, GDK_CURRENT_TIME); 10116 gtk_show_uri(NULL, url, GDK_CURRENT_TIME);
10115 return DW_ERROR_NONE; 10117 return DW_ERROR_NONE;
10116 } 10118 }
10137 * Causes the embedded HTML widget to take action. 10139 * Causes the embedded HTML widget to take action.
10138 * Parameters: 10140 * Parameters:
10139 * handle: Handle to the window. 10141 * handle: Handle to the window.
10140 * action: One of the DW_HTML_* constants. 10142 * action: One of the DW_HTML_* constants.
10141 */ 10143 */
10142 void dw_html_action(HWND handle, int action) 10144 void API dw_html_action(HWND handle, int action)
10143 { 10145 {
10144 #ifdef USE_WEBKIT 10146 #ifdef USE_WEBKIT
10145 WebKitWebView *web_view; 10147 WebKitWebView *web_view;
10146 10148
10147 if((web_view = _dw_html_web_view(handle))) 10149 if((web_view = _dw_html_web_view(handle)))
10182 * string: String buffer containt HTML code to 10184 * string: String buffer containt HTML code to
10183 * be rendered. 10185 * be rendered.
10184 * Returns: 10186 * Returns:
10185 * 0 on success. 10187 * 0 on success.
10186 */ 10188 */
10187 int dw_html_raw(HWND handle, const char *string) 10189 int API dw_html_raw(HWND handle, const char *string)
10188 { 10190 {
10189 #ifdef USE_WEBKIT 10191 #ifdef USE_WEBKIT
10190 WebKitWebView *web_view; 10192 WebKitWebView *web_view;
10191 10193
10192 if((web_view = _dw_html_web_view(handle))) 10194 if((web_view = _dw_html_web_view(handle)))
10207 * url: Universal Resource Locator of the web or 10209 * url: Universal Resource Locator of the web or
10208 * file object to be rendered. 10210 * file object to be rendered.
10209 * Returns: 10211 * Returns:
10210 * 0 on success. 10212 * 0 on success.
10211 */ 10213 */
10212 int dw_html_url(HWND handle, const char *url) 10214 int API dw_html_url(HWND handle, const char *url)
10213 { 10215 {
10214 #ifdef USE_WEBKIT 10216 #ifdef USE_WEBKIT
10215 WebKitWebView *web_view; 10217 WebKitWebView *web_view;
10216 10218
10217 if((web_view = _dw_html_web_view(handle))) 10219 if((web_view = _dw_html_web_view(handle)))
10233 * scriptdata: Data passed to the signal handler. 10235 * scriptdata: Data passed to the signal handler.
10234 * Notes: A DW_SIGNAL_HTML_RESULT event will be raised with scriptdata. 10236 * Notes: A DW_SIGNAL_HTML_RESULT event will be raised with scriptdata.
10235 * Returns: 10237 * Returns:
10236 * DW_ERROR_NONE (0) on success. 10238 * DW_ERROR_NONE (0) on success.
10237 */ 10239 */
10238 int dw_html_javascript_run(HWND handle, const char *script, void *scriptdata) 10240 int API dw_html_javascript_run(HWND handle, const char *script, void *scriptdata)
10239 { 10241 {
10240 #ifdef USE_WEBKIT 10242 #ifdef USE_WEBKIT
10241 WebKitWebView *web_view; 10243 WebKitWebView *web_view;
10242 10244
10243 if((web_view = _dw_html_web_view(handle))) 10245 if((web_view = _dw_html_web_view(handle)))
10295 * None. 10297 * None.
10296 * Returns: 10298 * Returns:
10297 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not 10299 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
10298 * be converted to text. 10300 * be converted to text.
10299 */ 10301 */
10300 char *dw_clipboard_get_text() 10302 char * API dw_clipboard_get_text(void)
10301 { 10303 {
10302 GdkDisplay *display = gdk_display_get_default(); 10304 GdkDisplay *display = gdk_display_get_default();
10303 GdkClipboard *clipboard; 10305 GdkClipboard *clipboard;
10304 char *ret = NULL; 10306 char *ret = NULL;
10305 10307
10317 /* 10319 /*
10318 * Sets the contents of the default clipboard to the supplied text. 10320 * Sets the contents of the default clipboard to the supplied text.
10319 * Parameters: 10321 * Parameters:
10320 * Text. 10322 * Text.
10321 */ 10323 */
10322 void dw_clipboard_set_text(const char *str, int len) 10324 void API dw_clipboard_set_text(const char *str, int len)
10323 { 10325 {
10324 GdkDisplay *display = gdk_display_get_default(); 10326 GdkDisplay *display = gdk_display_get_default();
10325 GdkClipboard *clipboard; 10327 GdkClipboard *clipboard;
10326 10328
10327 if((clipboard = gdk_display_get_clipboard(display))) 10329 if((clipboard = gdk_display_get_clipboard(display)))
10411 /* 10413 /*
10412 * Returns a pointer to a static buffer which contains the 10414 * Returns a pointer to a static buffer which contains the
10413 * current user directory. Or the root directory (C:\ on 10415 * current user directory. Or the root directory (C:\ on
10414 * OS/2 and Windows). 10416 * OS/2 and Windows).
10415 */ 10417 */
10416 char *dw_user_dir(void) 10418 char * API dw_user_dir(void)
10417 { 10419 {
10418 static char _user_dir[1024] = ""; 10420 static char _user_dir[1024] = "";
10419 10421
10420 if(!_user_dir[0]) 10422 if(!_user_dir[0])
10421 { 10423 {
10452 * it will create a unique ID in the form: org.dbsoft.dwindows.application 10454 * it will create a unique ID in the form: org.dbsoft.dwindows.application
10453 * or if the application name cannot be detected: org.dbsoft.dwindows.pid.# 10455 * or if the application name cannot be detected: org.dbsoft.dwindows.pid.#
10454 * The appname is only required on Windows. If NULL is passed the detected 10456 * The appname is only required on Windows. If NULL is passed the detected
10455 * application name will be used, but a prettier name may be desired. 10457 * application name will be used, but a prettier name may be desired.
10456 */ 10458 */
10457 int dw_app_id_set(const char *appid, const char *appname) 10459 int API dw_app_id_set(const char *appid, const char *appname)
10458 { 10460 {
10459 if(g_application_id_is_valid(appid)) 10461 if(g_application_id_is_valid(appid))
10460 { 10462 {
10461 strncpy(_dw_app_id, appid, _DW_APP_ID_SIZE); 10463 strncpy(_dw_app_id, appid, _DW_APP_ID_SIZE);
10462 return DW_ERROR_NONE; 10464 return DW_ERROR_NONE;
10469 * Parameters: 10471 * Parameters:
10470 * handle: Window handle of the widget. 10472 * handle: Window handle of the widget.
10471 * function: Function pointer to be called. 10473 * function: Function pointer to be called.
10472 * data: Pointer to the data to be passed to the function. 10474 * data: Pointer to the data to be passed to the function.
10473 */ 10475 */
10474 void dw_window_function(HWND handle, void *function, void *data) 10476 void API dw_window_function(HWND handle, void *function, void *data)
10475 { 10477 {
10476 void (* windowfunc)(void *); 10478 void (* windowfunc)(void *);
10477 10479
10478 windowfunc = function; 10480 windowfunc = function;
10479 10481
10486 * Parameters: 10488 * Parameters:
10487 * window: Window handle of signal to be called back. 10489 * window: Window handle of signal to be called back.
10488 * dataname: A string pointer identifying which signal to be hooked. 10490 * dataname: A string pointer identifying which signal to be hooked.
10489 * data: User data to be passed to the handler function. 10491 * data: User data to be passed to the handler function.
10490 */ 10492 */
10491 void dw_window_set_data(HWND window, const char *dataname, void *data) 10493 void API dw_window_set_data(HWND window, const char *dataname, void *data)
10492 { 10494 {
10493 HWND thiswindow = window; 10495 HWND thiswindow = window;
10494 10496
10495 if(!window) 10497 if(!window)
10496 return; 10498 return;
10508 * Parameters: 10510 * Parameters:
10509 * window: Window handle of signal to be called back. 10511 * window: Window handle of signal to be called back.
10510 * dataname: A string pointer identifying which signal to be hooked. 10512 * dataname: A string pointer identifying which signal to be hooked.
10511 * data: User data to be passed to the handler function. 10513 * data: User data to be passed to the handler function.
10512 */ 10514 */
10513 void *dw_window_get_data(HWND window, const char *dataname) 10515 void * API dw_window_get_data(HWND window, const char *dataname)
10514 { 10516 {
10515 HWND thiswindow = window; 10517 HWND thiswindow = window;
10516 void *ret = NULL; 10518 void *ret = NULL;
10517 10519
10518 if(!window) 10520 if(!window)
10613 * window: Window handle of signal to be called back. 10615 * window: Window handle of signal to be called back.
10614 * signame: A string pointer identifying which signal to be hooked. 10616 * signame: A string pointer identifying which signal to be hooked.
10615 * sigfunc: The pointer to the function to be used as the callback. 10617 * sigfunc: The pointer to the function to be used as the callback.
10616 * data: User data to be passed to the handler function. 10618 * data: User data to be passed to the handler function.
10617 */ 10619 */
10618 void dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data) 10620 void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data)
10619 { 10621 {
10620 dw_signal_connect_data(window, signame, sigfunc, NULL, data); 10622 dw_signal_connect_data(window, signame, sigfunc, NULL, data);
10621 } 10623 }
10622 10624
10623 /* Internal function to free any allocated signal data.. 10625 /* Internal function to free any allocated signal data..
10807 * signame: A string pointer identifying which signal to be hooked. 10809 * signame: A string pointer identifying which signal to be hooked.
10808 * sigfunc: The pointer to the function to be used as the callback. 10810 * sigfunc: The pointer to the function to be used as the callback.
10809 * discfunc: The pointer to the function called when this handler is removed. 10811 * discfunc: The pointer to the function called when this handler is removed.
10810 * data: User data to be passed to the handler function. 10812 * data: User data to be passed to the handler function.
10811 */ 10813 */
10812 void dw_signal_connect_data(HWND window, const char *signame, void *sigfunc, void *discfunc, void *data) 10814 void API dw_signal_connect_data(HWND window, const char *signame, void *sigfunc, void *discfunc, void *data)
10813 { 10815 {
10814 SignalList signal = _dw_findsignal(signame); 10816 SignalList signal = _dw_findsignal(signame);
10815 10817
10816 if(signal.func) 10818 if(signal.func)
10817 { 10819 {
10852 /* 10854 /*
10853 * Removes callbacks for a given window with given name. 10855 * Removes callbacks for a given window with given name.
10854 * Parameters: 10856 * Parameters:
10855 * window: Window handle of callback to be removed. 10857 * window: Window handle of callback to be removed.
10856 */ 10858 */
10857 void dw_signal_disconnect_by_name(HWND window, const char *signame) 10859 void API dw_signal_disconnect_by_name(HWND window, const char *signame)
10858 { 10860 {
10859 int z, count; 10861 int z, count;
10860 SignalList signal; 10862 SignalList signal;
10861 void **params = alloca(sizeof(void *) * 3); 10863 void **params = alloca(sizeof(void *) * 3);
10862 10864
10882 /* 10884 /*
10883 * Removes all callbacks for a given window. 10885 * Removes all callbacks for a given window.
10884 * Parameters: 10886 * Parameters:
10885 * window: Window handle of callback to be removed. 10887 * window: Window handle of callback to be removed.
10886 */ 10888 */
10887 void dw_signal_disconnect_by_window(HWND window) 10889 void API dw_signal_disconnect_by_window(HWND window)
10888 { 10890 {
10889 HWND thiswindow; 10891 HWND thiswindow;
10890 int z, count; 10892 int z, count;
10891 10893
10892 thiswindow = _dw_find_signal_window(window, NULL); 10894 thiswindow = _dw_find_signal_window(window, NULL);
10901 * Removes all callbacks for a given window with specified data. 10903 * Removes all callbacks for a given window with specified data.
10902 * Parameters: 10904 * Parameters:
10903 * window: Window handle of callback to be removed. 10905 * window: Window handle of callback to be removed.
10904 * data: Pointer to the data to be compared against. 10906 * data: Pointer to the data to be compared against.
10905 */ 10907 */
10906 void dw_signal_disconnect_by_data(HWND window, void *data) 10908 void API dw_signal_disconnect_by_data(HWND window, void *data)
10907 { 10909 {
10908 int z, count; 10910 int z, count;
10909 void **params = alloca(sizeof(void *) * 3); 10911 void **params = alloca(sizeof(void *) * 3);
10910 10912
10911 params[2] = _dw_find_signal_window(window, NULL); 10913 params[2] = _dw_find_signal_window(window, NULL);