Mercurial > dwindows
diff gtk4/dw.c @ 2854:8a5131cbbe93
GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
Also similar to the other platforms, no longer install XPMs to gtk/.
GTK4 is currently untested, if it doesn't work, may be a follow-up.
Also fix a GCC fortify warning with strncpy().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 15 Nov 2022 02:29:56 +0000 |
parents | cd6a306800f5 |
children | 86286f528adf |
line wrap: on
line diff
--- a/gtk4/dw.c Tue Nov 15 01:07:55 2022 +0000 +++ b/gtk4/dw.c Tue Nov 15 02:29:56 2022 +0000 @@ -3925,13 +3925,18 @@ * filename: a path to a file (Bitmap on OS/2 or * Windows and a pixmap on Unix, pass * NULL if you use the id param) - */ -DW_FUNCTION_DEFINITION(dw_window_set_bitmap, void, HWND handle, unsigned long id, const char *filename) + * Returns: + * DW_ERROR_NONE on success. + * DW_ERROR_UNKNOWN if the parameters were invalid. + * DW_ERROR_GENERAL if the bitmap was unable to be loaded. + */ +DW_FUNCTION_DEFINITION(dw_window_set_bitmap, int, HWND handle, unsigned long id, const char *filename) DW_FUNCTION_ADD_PARAM3(handle, id, filename) -DW_FUNCTION_NO_RETURN(dw_window_set_bitmap) +DW_FUNCTION_RETURN(dw_window_set_bitmap, int) DW_FUNCTION_RESTORE_PARAM3(handle, HWND, id, ULONG, filename, const char *) { GdkPixbuf *tmp = NULL; + int retval = DW_ERROR_UNKNOWN; if(id) tmp = _dw_find_pixbuf((HICN)id, NULL, NULL); @@ -3966,12 +3971,20 @@ { GtkWidget *pixmap = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_bitmap"); if(pixmap) + { gtk_picture_set_pixbuf(GTK_PICTURE(pixmap), tmp); + retval = DW_ERROR_NONE; + } } else if(GTK_IS_PICTURE(handle)) + { gtk_picture_set_pixbuf(GTK_PICTURE(handle), tmp); - } - DW_FUNCTION_RETURN_NOTHING; + retval = DW_ERROR_NONE; + } + } + else + retval = DW_ERROR_GENERAL; + DW_FUNCTION_RETURN_THIS(retval); } /* @@ -3984,13 +3997,18 @@ * Bitmap on Windows and a pixmap on Unix, pass * NULL if you use the id param) * len: length of data - */ -DW_FUNCTION_DEFINITION(dw_window_set_bitmap_from_data, void, HWND handle, unsigned long id, const char *data, int len) + * Returns: + * DW_ERROR_NONE on success. + * DW_ERROR_UNKNOWN if the parameters were invalid. + * DW_ERROR_GENERAL if the bitmap was unable to be loaded. + */ +DW_FUNCTION_DEFINITION(dw_window_set_bitmap_from_data, int, HWND handle, unsigned long id, const char *data, int len) DW_FUNCTION_ADD_PARAM4(handle, id, data, len) -DW_FUNCTION_NO_RETURN(dw_window_set_bitmap_from_data) +DW_FUNCTION_RETURN(dw_window_set_bitmap_from_data, int) DW_FUNCTION_RESTORE_PARAM4(handle, HWND, id, ULONG, data, const char *, len, int) { GdkPixbuf *tmp = NULL; + int retval = DW_ERROR_UNKNOWN; if(data) { @@ -4014,7 +4032,7 @@ unlink(template); } } - else if (id) + else if(id) tmp = _dw_find_pixbuf((HICN)id, NULL, NULL); if(tmp) @@ -4024,12 +4042,20 @@ GtkWidget *pixmap = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_bitmap"); if(pixmap) + { gtk_picture_set_pixbuf(GTK_PICTURE(pixmap), tmp); + retval = DW_ERROR_NONE; + } } else if(GTK_IS_PICTURE(handle)) + { gtk_picture_set_pixbuf(GTK_PICTURE(handle), tmp); - } - DW_FUNCTION_RETURN_NOTHING; + retval = DW_ERROR_NONE; + } + } + else + retval = DW_ERROR_GENERAL; + DW_FUNCTION_RETURN_THIS(retval); } /*