From 9451b864939291653ee4441a45cf27b5c74d4a99 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 22 Jul 2017 00:32:53 +1000 Subject: [PATCH] Wrap gtkutil/image --- libs/gtkutil/image.cpp | 22 +++++++++------------- libs/gtkutil/image.h | 11 ++++++----- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/libs/gtkutil/image.cpp b/libs/gtkutil/image.cpp index 961d2e73..4164f031 100644 --- a/libs/gtkutil/image.cpp +++ b/libs/gtkutil/image.cpp @@ -50,35 +50,31 @@ GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ){ } } -GtkImage* image_new_from_file_with_mask( const char* filename ){ +ui::Image image_new_from_file_with_mask( const char* filename ){ GdkPixbuf* rgba = pixbuf_new_from_file_with_mask( filename ); if ( rgba == 0 ) { - return 0; + return ui::Image(0); } else { - GtkImage* image = GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) ); + auto image = ui::Image(GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) )); g_object_unref( rgba ); return image; } } -GtkImage* image_new_missing(){ - return GTK_IMAGE( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); +ui::Image image_new_missing(){ + return ui::Image(GTK_IMAGE( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) )); } -GtkImage* new_image( const char* filename ){ - { - GtkImage* image = image_new_from_file_with_mask( filename ); - if ( image != 0 ) { - return image; - } +ui::Image new_image( const char* filename ){ + if ( auto image = image_new_from_file_with_mask( filename ) ) { + return image; } - return image_new_missing(); } -GtkImage* new_local_image( const char* filename ){ +ui::Image new_local_image( const char* filename ){ StringOutputStream fullPath( 256 ); fullPath << g_bitmapsPath.c_str() << filename; return new_image( fullPath.c_str() ); diff --git a/libs/gtkutil/image.h b/libs/gtkutil/image.h index cf452559..6a8d419b 100644 --- a/libs/gtkutil/image.h +++ b/libs/gtkutil/image.h @@ -19,18 +19,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_IMAGE_H ) #define INCLUDED_GTKUTIL_IMAGE_H void BitmapsPath_set( const char* path ); -typedef struct _GtkImage GtkImage; typedef struct _GdkPixbuf GdkPixbuf; GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ); -GtkImage* image_new_from_file_with_mask( const char* filename ); -GtkImage* image_new_missing(); -GtkImage* new_image( const char* filename ); // filename is full path to image file -GtkImage* new_local_image( const char* filename ); // filename is relative to local bitmaps path +ui::Image image_new_from_file_with_mask( const char* filename ); +ui::Image image_new_missing(); +ui::Image new_image( const char* filename ); // filename is full path to image file +ui::Image new_local_image( const char* filename ); // filename is relative to local bitmaps path #endif -- 2.39.2