rpms/gtk2/F-12 fresh-tooltips.patch,NONE,1.1 gtk2.spec,1.415,1.416
Matthias Clasen
mclasen at fedoraproject.org
Tue Oct 20 23:36:43 UTC 2009
Author: mclasen
Update of /cvs/pkgs/rpms/gtk2/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv6694
Modified Files:
gtk2.spec
Added Files:
fresh-tooltips.patch
Log Message:
Fresh tooltips look
fresh-tooltips.patch:
gtktooltip.c | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 179 insertions(+), 19 deletions(-)
--- NEW FILE fresh-tooltips.patch ---
diff -up gtk+-2.18.3/gtk/gtktooltip.c.fresh-tooltips gtk+-2.18.3/gtk/gtktooltip.c
--- gtk+-2.18.3/gtk/gtktooltip.c.fresh-tooltips 2009-10-16 10:35:45.000000000 -0400
+++ gtk+-2.18.3/gtk/gtktooltip.c 2009-10-20 15:14:00.479415361 -0400
@@ -95,6 +95,7 @@ static void gtk_tooltip_display_cl
GtkTooltip *tooltip);
static void gtk_tooltip_set_last_window (GtkTooltip *tooltip,
GdkWindow *window);
+static void update_shape (GtkTooltip *tooltip);
G_DEFINE_TYPE (GtkTooltip, gtk_tooltip, G_TYPE_OBJECT);
@@ -110,8 +111,18 @@ gtk_tooltip_class_init (GtkTooltipClass
}
static void
+on_composited_changed (GtkWidget *window,
+ GtkTooltip *tooltip)
+{
+ update_shape (tooltip);
+}
+
+static void
gtk_tooltip_init (GtkTooltip *tooltip)
{
+ GdkScreen *screen;
+ GdkColormap *rgba;
+
tooltip->timeout_id = 0;
tooltip->browse_mode_timeout_id = 0;
@@ -127,8 +138,15 @@ gtk_tooltip_init (GtkTooltip *tooltip)
tooltip->last_window = NULL;
tooltip->window = g_object_ref (gtk_window_new (GTK_WINDOW_POPUP));
+
+ screen = gtk_widget_get_screen (tooltip->window);
+ rgba = gdk_screen_get_rgba_colormap (screen);
+ if (rgba)
+ gtk_widget_set_colormap (tooltip->window, rgba);
+
gtk_window_set_type_hint (GTK_WINDOW (tooltip->window),
GDK_WINDOW_TYPE_HINT_TOOLTIP);
+
gtk_widget_set_app_paintable (tooltip->window, TRUE);
gtk_window_set_resizable (GTK_WINDOW (tooltip->window), FALSE);
gtk_widget_set_name (tooltip->window, "gtk-tooltip");
@@ -145,7 +163,7 @@ gtk_tooltip_init (GtkTooltip *tooltip)
gtk_widget_show (tooltip->alignment);
g_signal_connect_swapped (tooltip->window, "style-set",
- G_CALLBACK (gtk_tooltip_window_style_set), tooltip);
+ G_CALLBACK (gtk_tooltip_window_style_set), tooltip);
g_signal_connect_swapped (tooltip->window, "expose-event",
G_CALLBACK (gtk_tooltip_paint_window), tooltip);
@@ -162,6 +180,9 @@ gtk_tooltip_init (GtkTooltip *tooltip)
gtk_box_pack_start (GTK_BOX (tooltip->box), tooltip->label,
FALSE, FALSE, 0);
+ g_signal_connect (tooltip->window, "composited-changed",
+ G_CALLBACK (on_composited_changed), tooltip);
+
tooltip->custom_widget = NULL;
}
@@ -318,9 +339,9 @@ gtk_tooltip_set_icon_from_stock (GtkTool
* Since: 2.14
*/
void
-gtk_tooltip_set_icon_from_icon_name(GtkTooltip *tooltip,
- const gchar *icon_name,
- GtkIconSize size)
+gtk_tooltip_set_icon_from_icon_name (GtkTooltip *tooltip,
+ const gchar *icon_name,
+ GtkIconSize size)
{
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
@@ -471,27 +492,166 @@ static void
gtk_tooltip_window_style_set (GtkTooltip *tooltip)
{
gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment),
- tooltip->window->style->ythickness,
- tooltip->window->style->ythickness,
- tooltip->window->style->xthickness,
+ tooltip->window->style->ythickness,
+ tooltip->window->style->ythickness,
+ tooltip->window->style->xthickness,
tooltip->window->style->xthickness);
-
+ gtk_box_set_spacing (GTK_BOX (tooltip->box),
+ tooltip->window->style->xthickness);
gtk_widget_queue_draw (tooltip->window);
}
+static void
+draw_round_rect (cairo_t *cr,
+ gdouble aspect,
+ gdouble x,
+ gdouble y,
+ gdouble corner_radius,
+ gdouble width,
+ gdouble height)
+{
+ gdouble radius = corner_radius / aspect;
+
+ cairo_move_to (cr, x + radius, y);
+
+ /* top-right, left of the corner */
+ cairo_line_to (cr, x + width - radius, y);
+
+ /* top-right, below the corner */
+ cairo_arc (cr,
+ x + width - radius, y + radius, radius,
+ -90.0f * G_PI / 180.0f, 0.0f * G_PI / 180.0f);
+
+ /* bottom-right, above the corner */
+ cairo_line_to (cr, x + width, y + height - radius);
+
+ /* bottom-right, left of the corner */
+ cairo_arc (cr,
+ x + width - radius, y + height - radius, radius,
+ 0.0f * G_PI / 180.0f, 90.0f * G_PI / 180.0f);
+
+ /* bottom-left, right of the corner */
+ cairo_line_to (cr, x + radius, y + height);
+
+ /* bottom-left, above the corner */
+ cairo_arc (cr,
+ x + radius, y + height - radius, radius,
+ 90.0f * G_PI / 180.0f, 180.0f * G_PI / 180.0f);
+
+ /* top-left, below the corner */
+ cairo_line_to (cr, x, y + radius);
+
+ /* top-left, right of the corner */
+ cairo_arc (cr,
+ x + radius, y + radius, radius,
+ 180.0f * G_PI / 180.0f, 270.0f * G_PI / 180.0f);
+}
+
+static void
+fill_background (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GdkColor color;
+ gdouble r, g, b;
+ gint padding;
+ gint radius;
+ gdouble background_alpha;
+
+ if (gdk_screen_is_composited (gtk_widget_get_screen (widget)))
+ {
+ padding = 1;
+ background_alpha = 0.90;
+ }
+ else
+ {
+ padding = 0;
+ background_alpha = 1.0;
+ }
+
+ radius = MIN (widget->style->xthickness, widget->style->ythickness);
+ radius = MAX (radius, padding);
+
+ draw_round_rect (cr,
+ 1.0, padding, padding, radius,
+ widget->allocation.width - 2 * padding,
+ widget->allocation.height - 2 * padding);
+
+ color = widget->style->bg [GTK_STATE_NORMAL];
+ r = (float)color.red / 65535.0;
+ g = (float)color.green / 65535.0;
+ b = (float)color.blue / 65535.0;
+ cairo_set_source_rgba (cr, r, g, b, background_alpha);
+ cairo_fill_preserve (cr);
+
+#if 1
+ color = widget->style->text_aa [GTK_STATE_NORMAL];
+ r = (float) color.red / 65535.0;
+ g = (float) color.green / 65535.0;
+ b = (float) color.blue / 65535.0;
+#endif
+ cairo_set_source_rgba (cr, r, g, b, background_alpha / 2);
+ cairo_set_line_width (cr, 1);
+ cairo_stroke (cr);
+}
+
+static void
+update_shape (GtkTooltip *tooltip)
+{
+ GdkBitmap *mask;
+ cairo_t *cr;
+ gint width, height;
+
+ if (gdk_screen_is_composited (gtk_widget_get_screen (tooltip->window)))
+ {
+ gtk_widget_shape_combine_mask (tooltip->window, NULL, 0, 0);
+ return;
+ }
+
+ gtk_window_get_size (tooltip->window, &width, &height);
+ mask = (GdkBitmap *) gdk_pixmap_new (NULL, width, height, 1);
+ cr = gdk_cairo_create (mask);
+ if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
+ {
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_paint (cr);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ draw_round_rect (cr, 1.0, 0, 0, 4, width, height);
+ cairo_fill (cr);
+
+ gtk_widget_shape_combine_mask (tooltip->window, mask, 0, 0);
+ }
+ cairo_destroy (cr);
+
+ g_object_unref (mask);
+}
+
static gboolean
gtk_tooltip_paint_window (GtkTooltip *tooltip)
{
- gtk_paint_flat_box (tooltip->window->style,
- tooltip->window->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- NULL,
- tooltip->window,
- "tooltip",
- 0, 0,
- tooltip->window->allocation.width,
- tooltip->window->allocation.height);
+ cairo_t *context;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ context = gdk_cairo_create (tooltip->window->window);
+
+ cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
+ surface = cairo_surface_create_similar (cairo_get_target (context),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ tooltip->window->allocation.width,
+ tooltip->window->allocation.height);
+ cr = cairo_create (surface);
+
+ fill_background (tooltip->window, cr);
+
+ cairo_destroy (cr);
+ cairo_set_source_surface (context, surface, 0, 0);
+ cairo_paint (context);
+ cairo_surface_destroy (surface);
+ cairo_destroy (context);
+
+ update_shape (tooltip);
return FALSE;
}
@@ -631,7 +791,7 @@ find_widget_under_pointer (GdkWindow *wi
#ifdef DEBUG_TOOLTIP
g_print ("event window %p (belonging to %p (%s)) (%d, %d)\n",
- window, event_widget, gtk_widget_get_name (event_widget),
+ gindow, event_widget, gtk_widget_get_name (event_widget),
*x, *y);
#endif
Index: gtk2.spec
===================================================================
RCS file: /cvs/pkgs/rpms/gtk2/F-12/gtk2.spec,v
retrieving revision 1.415
retrieving revision 1.416
diff -u -p -r1.415 -r1.416
--- gtk2.spec 18 Oct 2009 05:43:09 -0000 1.415
+++ gtk2.spec 20 Oct 2009 23:36:42 -0000 1.416
@@ -17,7 +17,7 @@
Summary: The GIMP ToolKit (GTK+), a library for creating GUIs for X
Name: gtk2
Version: %{base_version}
-Release: 3%{?dist}
+Release: 4%{?dist}
License: LGPLv2+
Group: System Environment/Libraries
Source: http://download.gnome.org/sources/gtk+/2.18/gtk+-%{version}.tar.bz2
@@ -32,6 +32,8 @@ Patch1: system-python.patch
Patch2: icon-padding.patch
# from upstream
Patch3: image-size-alloc.patch
+#
+Patch4: fresh-tooltips.patch
BuildRequires: atk-devel >= %{atk_version}
BuildRequires: pango-devel >= %{pango_version}
@@ -146,6 +148,7 @@ This package contains developer document
%patch1 -p1 -b .system-python
%patch2 -p1 -b .icon-padding
%patch3 -p1 -b .image-size-alloc
+%patch4 -p1 -b .fresh-tooltips
%build
libtoolize --force --copy
@@ -382,6 +385,9 @@ fi
%changelog
+* Tue Oct 20 2009 Matthias Clasen <mclasen at redhat.com> - 2.18.3-4
+- Make tooltips look nicer
+
* Sun Oct 18 2009 Matthias Clasen <mclasen at redhat.com> - 2.18.3-3
- Fix a size allocation problem uncovered by the previous patch
More information about the fedora-extras-commits
mailing list