Author: rpmcruz
Date: Thu Nov 6 02:58:02 2008
New Revision: 52961
URL: http://svn.opensuse.org/viewcvs/yast?rev=52961&view=rev
Log:
* src/YGUtils.h/cc: added touchAlpha flag to setOpacity() that makes
the pixbuf whiter by the alpha layer.
* src/YGPackageSelector.cc: set pattern and languages tooltip icon
transparent if not installed -- and use list icons if none provided.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/YGUtils.cc
trunk/gtk/src/YGUtils.h
trunk/gtk/src/ygtkfindentry.c
trunk/gtk/src/ygtkwizard.c
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=52961&r1=52960&r2=52961&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Thu Nov 6 02:58:02 2008
@@ -6,6 +6,12 @@
* src/YGLabel.cc: don't set selectable for labels that use just
one break line for padding purposes.
+ * src/YGUtils.h/cc: added touchAlpha flag to setOpacity() that makes
+ the pixbuf whiter by the alpha layer.
+
+ * src/YGPackageSelector.cc: set pattern and languages tooltip icon
+ transparent if not installed -- and use list icons if none provided.
+
2008-11-03 Ricardo Cruz
* src/yzyppwrapper.cc: bug fix 441143: use candidate object as the
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=52961&r1=52960&r2=52961&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Thu Nov 6 02:58:02 2008
@@ -589,13 +589,25 @@
std::string text ("<b>" + package->name() + "</b>\n");
text += package->description (true);
gtk_tooltip_set_markup (tooltip, text.c_str());
- const std::string &icon = package->icon();
- if (!icon.empty()) {
- GdkPixbuf *pixbuf = loadThemeIcon (icon.c_str(), 32);
- if (pixbuf) {
- gtk_tooltip_set_icon (tooltip, pixbuf);
- g_object_unref (G_OBJECT (pixbuf));
- }
+
+ std::string filename (package->icon());
+ GdkPixbuf *pixbuf = 0;
+ bool setTransparent = false;
+ if (!filename.empty()) {
+ pixbuf = loadThemeIcon (filename.c_str(), 32);
+ setTransparent = !package->isInstalled();
+ }
+ if (!pixbuf)
+ gtk_tree_model_get (model, &iter,
+ YGtkZyppModel::ICON_COLUMN, &pixbuf, -1);
+ if (pixbuf) {
+ GdkPixbuf *pixbuf2 = pixbuf;
+ if (setTransparent)
+ pixbuf2 = YGUtils::setOpacity (pixbuf, 40, true);
+ gtk_tooltip_set_icon (tooltip, pixbuf2);
+ if (setTransparent)
+ g_object_unref (G_OBJECT (pixbuf2));
+ g_object_unref (G_OBJECT (pixbuf));
}
return TRUE;
}
Modified: trunk/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=52961&r1=52960&r2=52961&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.cc (original)
+++ trunk/gtk/src/YGUtils.cc Thu Nov 6 02:58:02 2008
@@ -229,10 +229,15 @@
// Code from Banshee: shades a pixbuf a bit, used e.g. for hover effects
static inline guchar pixel_clamp (int val)
{ return MAX (0, MIN (255, val)); }
-GdkPixbuf *YGUtils::setOpacity (const GdkPixbuf *src, int opacity)
+GdkPixbuf *YGUtils::setOpacity (const GdkPixbuf *src, int opacity, bool touchAlpha)
{
if (!src) return NULL;
int shift = 255 - ((opacity * 255) / 100);
+ int rgb_shift = 0, alpha_shift = 0;
+ if (touchAlpha)
+ alpha_shift = shift;
+ else
+ rgb_shift = shift;
int width = gdk_pixbuf_get_width (src), height = gdk_pixbuf_get_height (src);
gboolean has_alpha = gdk_pixbuf_get_has_alpha (src);
@@ -250,18 +255,18 @@
guchar *src_pixels = src_pixels_orig + (i * src_rowstride);
guchar *dest_pixels = dest_pixels_orig + (i * dest_rowstride);
for (j = 0; j < width; j++) {
- *(dest_pixels++) = pixel_clamp (*(src_pixels++) + shift);
- *(dest_pixels++) = pixel_clamp (*(src_pixels++) + shift);
- *(dest_pixels++) = pixel_clamp (*(src_pixels++) + shift);
+ *(dest_pixels++) = pixel_clamp (*(src_pixels++) + rgb_shift);
+ *(dest_pixels++) = pixel_clamp (*(src_pixels++) + rgb_shift);
+ *(dest_pixels++) = pixel_clamp (*(src_pixels++) + rgb_shift);
if (has_alpha)
- *(dest_pixels++) = *(src_pixels++);
+ *(dest_pixels++) = pixel_clamp (*(src_pixels++) - alpha_shift);
}
}
return dest;
}
-GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity)
-{ return YGUtils::setOpacity (src, opacity); }
+GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity, gboolean useAlpha)
+{ return YGUtils::setOpacity (src, opacity, useAlpha); }
static std::string cutUnderline (const std::string &str)
{
Modified: trunk/gtk/src/YGUtils.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.h?rev=52961&r1=52960&r2=52961&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.h (original)
+++ trunk/gtk/src/YGUtils.h Thu Nov 6 02:58:02 2008
@@ -46,7 +46,7 @@
GdkPixbuf *loadPixbuf (const std::string &fileneme);
/* Shifts colors in a GdkPixbuf. */
- GdkPixbuf *setOpacity (const GdkPixbuf *src, int opacity);
+ GdkPixbuf *setOpacity (const GdkPixbuf *src, int opacity, bool touchAlpha);
/* Tries to make sense out of the string, applying some stock icon to the button. */
bool setStockIcon (GtkWidget *button, const std::string &label,
@@ -63,7 +63,7 @@
gboolean ygutils_setStockIcon (GtkWidget *button, const char *label,
const char *fallbackIcon);
- GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity);
+ GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity, gboolean useAlpha);
};
#endif // YGUTILS_H
Modified: trunk/gtk/src/ygtkfindentry.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkfindentry.c?rev=52961&r1=52960&r2=52961&view=diff
==============================================================================
--- trunk/gtk/src/ygtkfindentry.c (original)
+++ trunk/gtk/src/ygtkfindentry.c Thu Nov 6 02:58:02 2008
@@ -9,7 +9,7 @@
#include "ygtkfindentry.h"
#include
-extern GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity);
+extern GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity, gboolean alpha);
static guint menu_item_selected_signal = 0;
@@ -264,7 +264,7 @@
}
if (stock_icon) {
*normal_icon = gtk_widget_render_icon (widget, stock_icon, GTK_ICON_SIZE_MENU, NULL);
- *hover_icon = ygutils_setOpacity (*normal_icon, 88);
+ *hover_icon = ygutils_setOpacity (*normal_icon, 88, FALSE);
}
}
Modified: trunk/gtk/src/ygtkwizard.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=52961&r1=52960&r2=52961&view=diff
==============================================================================
--- trunk/gtk/src/ygtkwizard.c (original)
+++ trunk/gtk/src/ygtkwizard.c Thu Nov 6 02:58:02 2008
@@ -29,7 +29,7 @@
PangoWeight weight, double scale);
extern gboolean ygutils_setStockIcon (GtkWidget *button, const char *label,
const char *fallbackIcon);
-extern GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity);
+extern GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity, gboolean alpha);
//** YGtkHelpDialog
@@ -81,7 +81,7 @@
GdkPixbuf *pixbuf = gtk_icon_info_load_icon (info, NULL);
if (pixbuf) {
const gchar *filename = gtk_icon_info_get_filename (info);
- GdkPixbuf *transparent = ygutils_setOpacity (pixbuf, 60);
+ GdkPixbuf *transparent = ygutils_setOpacity (pixbuf, 60, FALSE);
ygtk_html_wrap_set_background (dialog->help_text, transparent, filename);
g_object_unref (pixbuf);
g_object_unref (transparent);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org