Author: rpmcruz Date: Tue Oct 7 20:20:24 2008 New Revision: 51943 URL: http://svn.opensuse.org/viewcvs/yast?rev=51943&view=rev Log: * src/ygtkimage.h/c: add method to accept a pixbuf. * src/YGImage.cc: bug fix 428974: whatever the current theme, use GTK stock icons for warning, error, question and info icons. Modified: trunk/gtk/ChangeLog trunk/gtk/src/YGImage.cc trunk/gtk/src/ygtkimage.c trunk/gtk/src/ygtkimage.h Modified: trunk/gtk/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=51943&r1=51... ============================================================================== --- trunk/gtk/ChangeLog (original) +++ trunk/gtk/ChangeLog Tue Oct 7 20:20:24 2008 @@ -11,6 +11,11 @@ * src/ygtkwizard.c: set anchor background. + * src/ygtkimage.h/c: add method to accept a pixbuf. + + * src/YGImage.cc: bug fix 428974: whatever the current theme, use GTK + stock icons for warning, error, question and info icons. + 2008-10-06 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> * src/ygtkwizard.h/.c: collapse all button functions and accept button Modified: trunk/gtk/src/YGImage.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGImage.cc?rev=51943&... ============================================================================== --- trunk/gtk/src/YGImage.cc (original) +++ trunk/gtk/src/YGImage.cc Tue Oct 7 20:20:24 2008 @@ -8,6 +8,14 @@ #include "YGWidget.h" #include "YImage.h" #include "ygtkimage.h" +#include <string.h> + +static bool endsWith (const std::string &str1, const char *str2) +{ + size_t len = strlen (str2); + if (str1.size() < len) return false; + return str1.compare (str1.size()-len, len, str2, len); +} class YGImage : public YImage, public YGWidget { @@ -17,7 +25,22 @@ YGWidget (this, parent, true, YGTK_TYPE_IMAGE, NULL) { IMPL - ygtk_image_set_from_file (YGTK_IMAGE (getWidget()), filename.c_str(), animated); + YGtkImage *image = YGTK_IMAGE (getWidget()); + const char *stock = NULL; + if (endsWith (filename, "/msg_question.png")) + stock = GTK_STOCK_DIALOG_QUESTION; + else if (endsWith (filename, "/msg_info.png")) + stock = GTK_STOCK_DIALOG_INFO; + else if (endsWith (filename, "/msg_warning.png")) + stock = GTK_STOCK_DIALOG_WARNING; + else if (endsWith (filename, "/msg_error.png")) + stock = GTK_STOCK_DIALOG_ERROR; + if (stock && gtk_style_lookup_icon_set (m_widget->style, stock)) { + GdkPixbuf *pixbuf = gtk_widget_render_icon (m_widget, stock, GTK_ICON_SIZE_DIALOG, NULL); + ygtk_image_set_from_pixbuf (image, pixbuf); + } + else + ygtk_image_set_from_file (image, filename.c_str(), animated); } virtual void setAutoScale (bool scale) Modified: trunk/gtk/src/ygtkimage.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkimage.c?rev=51943&... ============================================================================== --- trunk/gtk/src/ygtkimage.c (original) +++ trunk/gtk/src/ygtkimage.c Tue Oct 7 20:20:24 2008 @@ -90,8 +90,8 @@ image->loaded = TRUE; ygtk_image_advance_frame_cb (image); } -/* else - g_warning ("Couldn't load image - %s", error_msg);*/ + else if (error_msg) + g_warning ("Couldn't load image - %s", error_msg); } void ygtk_image_set_from_file (YGtkImage *image, const char *filename, gboolean anim) @@ -111,6 +111,11 @@ } } +void ygtk_image_set_from_pixbuf (YGtkImage *image, GdkPixbuf *pixbuf) +{ + ygtk_image_set_pixbuf (image, pixbuf, NULL); +} + static void ygtk_image_loaded_cb (GdkPixbufLoader *loader, YGtkImage *image) { if (image->animated) { Modified: trunk/gtk/src/ygtkimage.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkimage.h?rev=51943&... ============================================================================== --- trunk/gtk/src/ygtkimage.h (original) +++ trunk/gtk/src/ygtkimage.h Tue Oct 7 20:20:24 2008 @@ -65,6 +65,7 @@ void ygtk_image_set_from_file (YGtkImage *image, const char *filename, gboolean anim); void ygtk_image_set_from_data (YGtkImage *image, const guint8 *data, long size, gboolean anim); +void ygtk_image_set_from_pixbuf (YGtkImage *image, GdkPixbuf *pixbuf); void ygtk_image_set_props (YGtkImage *image, YGtkImageAlign align, const gchar *alt_text); // as we don't have a window, -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org