[glabels/vala] Removed use of deprecated Gtk.Style.
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels/vala] Removed use of deprecated Gtk.Style.
- Date: Sat, 24 May 2014 18:40:05 +0000 (UTC)
commit e6b4046d87a01b4e3a86e1e5aa6b69a40e020937
Author: Jim Evins <evins snaught com>
Date: Sat May 24 14:38:49 2014 -0400
Removed use of deprecated Gtk.Style.
glabels/color_swatch.vala | 17 +++++++--------
glabels/font_sample.vala | 47 +++++++++++++++++++++-----------------------
glabels/mini_preview.vala | 27 ++++++++++++++++---------
3 files changed, 47 insertions(+), 44 deletions(-)
---
diff --git a/glabels/color_swatch.vala b/glabels/color_swatch.vala
index f53de14..fc7e43a 100644
--- a/glabels/color_swatch.vala
+++ b/glabels/color_swatch.vala
@@ -42,23 +42,22 @@ namespace glabels
public override bool draw( Cairo.Context cr )
{
- Color fill_color, line_color;
-
cr.set_antialias( Cairo.Antialias.NONE );
double w = get_allocated_width();
double h = get_allocated_height();
- Gtk.Style style = this.get_style();
+ Gtk.StyleContext style_context = this.get_style_context();
+ Color fill_color, border_color;
if ( this.is_sensitive() )
{
- fill_color = color;
- line_color = Color.from_gdk_color( style.fg[Gtk.StateType.NORMAL] );
+ fill_color = color;
+ border_color = Color.from_gdk_rgba(
style_context.get_border_color(Gtk.StateFlags.NORMAL) );
}
else
{
- fill_color = Color.none();
- line_color = Color.from_gdk_color( style.fg[Gtk.StateType.INSENSITIVE] );
+ fill_color = Color.none();
+ border_color = Color.from_gdk_rgba(
style_context.get_border_color(Gtk.StateFlags.INSENSITIVE) );
}
cr.rectangle( 1, 1, w-2, h-2 );
@@ -69,7 +68,7 @@ namespace glabels
cr.fill_preserve();
}
- cr.set_source_rgb( line_color.r, line_color.g, line_color.b );
+ cr.set_source_rgb( border_color.r, border_color.g, border_color.b );
cr.set_line_width( 1.0 );
cr.stroke();
@@ -77,7 +76,7 @@ namespace glabels
}
- public override void style_set( Gtk.Style? style )
+ public override void style_updated()
{
redraw_canvas();
}
diff --git a/glabels/font_sample.vala b/glabels/font_sample.vala
index e989c91..bdf7864 100644
--- a/glabels/font_sample.vala
+++ b/glabels/font_sample.vala
@@ -44,27 +44,22 @@ namespace glabels
public override bool draw( Cairo.Context cr )
{
- Gtk.Style style;
- double w, h;
- Color fill_color, line_color;
- Pango.Layout layout;
- Pango.FontDescription desc;
- Pango.Rectangle ink_rect, logical_rect;
- double layout_x, layout_y, layout_width, layout_height;
-
- w = get_allocated_width();
- h = get_allocated_height();
-
- style = this.get_style();
+ double w = get_allocated_width();
+ double h = get_allocated_height();
+
+ Gtk.StyleContext style_context = this.get_style_context();
+ Color text_color, fill_color, border_color;
if ( this.is_sensitive() )
{
- fill_color = Color.from_gdk_color( style.light[Gtk.StateType.NORMAL] );
- line_color = Color.from_gdk_color( style.fg[Gtk.StateType.NORMAL] );
+ text_color = Color.black();
+ fill_color = Color.white();
+ border_color = Color.from_gdk_rgba(
style_context.get_border_color(Gtk.StateFlags.NORMAL) );
}
else
{
- fill_color = Color.none();
- line_color = Color.from_gdk_color( style.fg[Gtk.StateType.INSENSITIVE] );
+ text_color = Color( 0.75, 0.75, 0.75, 1.0 );
+ fill_color = Color.none();
+ border_color = Color.from_gdk_rgba(
style_context.get_border_color(Gtk.StateFlags.INSENSITIVE) );
}
cr.set_antialias( Cairo.Antialias.NONE );
@@ -74,15 +69,15 @@ namespace glabels
cr.set_source_rgba( fill_color.r, fill_color.g, fill_color.b, fill_color.a );
cr.fill_preserve();
- cr.set_source_rgb( line_color.r, line_color.g, line_color.b );
+ cr.set_source_rgb( border_color.r, border_color.g, border_color.b );
cr.set_line_width( 1.0 );
cr.stroke();
cr.set_antialias( Cairo.Antialias.DEFAULT );
- layout = Pango.cairo_create_layout( cr );
+ Pango.Layout layout = Pango.cairo_create_layout( cr );
- desc = new Pango.FontDescription();
+ Pango.FontDescription desc = new Pango.FontDescription();
desc.set_family( font_family );
desc.set_weight( Pango.Weight.NORMAL );
desc.set_style( Pango.Style.NORMAL );
@@ -91,12 +86,14 @@ namespace glabels
layout.set_font_description( desc );
layout.set_text( sample_text, -1 );
layout.set_width( -1 );
+
+ Pango.Rectangle ink_rect, logical_rect;
layout.get_pixel_extents( out ink_rect, out logical_rect );
- layout_width = double.max( logical_rect.width, ink_rect.width );
- layout_height = double.max( logical_rect.height, ink_rect.height );
+ double layout_width = double.max( logical_rect.width, ink_rect.width );
+ double layout_height = double.max( logical_rect.height, ink_rect.height );
- layout_x = (w - layout_width) / 2.0;
- layout_y = (h - layout_height) / 2.0;
+ double layout_x = (w - layout_width) / 2.0;
+ double layout_y = (h - layout_height) / 2.0;
if (ink_rect.x < logical_rect.x)
{
@@ -108,14 +105,14 @@ namespace glabels
layout_y += logical_rect.y - ink_rect.y;
}
- cr.set_source_rgb( line_color.r, line_color.g, line_color.b );
+ cr.set_source_rgb( text_color.r, text_color.g, text_color.b );
cr.move_to( layout_x, layout_y );
Pango.cairo_show_layout( cr, layout );
return false;
}
- public override void style_set( Gtk.Style? style )
+ public override void style_updated()
{
redraw_canvas();
}
diff --git a/glabels/mini_preview.vala b/glabels/mini_preview.vala
index 3c863cf..d56db93 100644
--- a/glabels/mini_preview.vala
+++ b/glabels/mini_preview.vala
@@ -77,7 +77,7 @@ namespace glabels
canvas.set_size_request( width, height );
canvas.draw.connect( on_draw );
- canvas.style_set.connect( on_style_set );
+ canvas.style_updated.connect( on_style_updated );
}
@@ -209,7 +209,7 @@ namespace glabels
}
- private void on_style_set( Gtk.Style? previous_style )
+ private void on_style_updated()
{
redraw_canvas();
}
@@ -329,9 +329,8 @@ namespace glabels
cr.rectangle( x, y, template.page_width, template.page_height );
- Gtk.Style style = get_style();
- Color shadow_color = Color.from_gdk_color( style.dark[Gtk.StateType.NORMAL] );
- cr.set_source_rgb( shadow_color.r, shadow_color.g, shadow_color.b );
+ Color shadow_color = Color( 0, 0, 0, 0.75 );
+ cr.set_source_rgba( shadow_color.r, shadow_color.g, shadow_color.b, shadow_color.a );
cr.fill();
@@ -346,9 +345,9 @@ namespace glabels
cr.rectangle( 0, 0, template.page_width, template.page_height );
- Gtk.Style style = get_style();
- Color paper_color = Color.from_gdk_color( style.light[Gtk.StateType.NORMAL] );
- Color outline_color = Color.from_gdk_color( style.fg[Gtk.StateType.NORMAL] );
+ Gtk.StyleContext style_context = get_style_context();
+ Color paper_color = Color.white();
+ Color outline_color = Color.from_gdk_rgba(
style_context.get_border_color(Gtk.StateFlags.NORMAL) );
cr.set_source_rgb( paper_color.r, paper_color.g, paper_color.b );
cr.fill_preserve();
@@ -368,8 +367,16 @@ namespace glabels
int n_labels = frame.get_n_labels();
- Gtk.Style style = get_style();
- Color base_color = Color.from_gdk_color( style.base[Gtk.StateType.SELECTED] );
+ Gtk.StyleContext style_context = get_style_context();
+ Gdk.RGBA base_rgba;
+ if ( !style_context.lookup_color( "selected_bg_color", out base_rgba ) )
+ {
+ base_rgba.red = 0.0;
+ base_rgba.green = 0.6;
+ base_rgba.blue = 1.0;
+ base_rgba.alpha = 1.0;
+ }
+ Color base_color = Color.from_gdk_rgba( base_rgba );
Color highlight_color = Color.from_color_and_opacity( base_color, 0.10 );
Color outline_color;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]