Permalink
Browse files

sample: Update CustomCellRenderer and add it to the build

The progress bar rendered by the CustomCellRenderer might not be visible
because of a bug in the default theme in GNOME 3. Applying the following
patch fixes that :
http://git.gnome.org/browse/gnome-themes-standard/commit/?id=756f2ea3
  • Loading branch information...
1 parent 23a0aa7 commit 75f9a8acb756c13e397a50e76f8d6c56cbacd269 @bl8 bl8 committed Jul 2, 2011
Showing with 24 additions and 25 deletions.
  1. +23 −24 sample/CustomCellRenderer.cs
  2. +1 −1 sample/Makefile.am
@@ -46,41 +46,40 @@ protected override void OnGetSize (Widget widget, ref Rectangle cell_area, out i
}
}
- protected override void OnRender (Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags)
+ protected override void OnRender (Cairo.Context cr, Widget widget, Rectangle background_area, Rectangle cell_area, CellRendererState flags)
{
- int width = 0, height = 0, x_offset = 0, y_offset = 0;
- StateType state;
- OnGetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height);
-
- if (widget.HasFocus)
- state = StateType.Active;
- else
- state = StateType.Normal;
-
- width -= (int) this.Xpad * 2;
- height -= (int) this.Ypad * 2;
-
-
- //FIXME: Style.PaintBox needs some customization so that if you pass it
- //a Gdk.Rectangle.Zero it gives a clipping area big enough to draw
- //everything
- Gdk.Rectangle clipping_area = new Gdk.Rectangle ((int) (cell_area.X + x_offset + this.Xpad), (int) (cell_area.Y + y_offset + this.Ypad), width - 1, height - 1);
+ int x = (int) (cell_area.X + this.Xpad);
+ int y = (int) (cell_area.Y + this.Ypad);
+ int width = (int) (cell_area.Width - this.Xpad * 2);
+ int height = (int) (cell_area.Height - this.Ypad * 2);
+
+ widget.StyleContext.Save ();
+ widget.StyleContext.AddClass ("trough");
+ widget.StyleContext.RenderBackground (cr, x, y, width, height);
+ widget.StyleContext.RenderFrame (cr, x, y, width, height);
- Style.PaintBox (widget.Style, (Gdk.Window) window, StateType.Normal, ShadowType.In, clipping_area, widget, "trough", (int) (cell_area.X + x_offset + this.Xpad), (int) (cell_area.Y + y_offset + this.Ypad), width - 1, height - 1);
+ Border padding = widget.StyleContext.GetPadding (StateFlags.Normal);
+ x += padding.Left;
+ y += padding.Top;
+ width -= padding.Left + padding.Right;
+ height -= padding.Top + padding.Bottom;
- Gdk.Rectangle clipping_area2 = new Gdk.Rectangle ((int) (cell_area.X + x_offset + this.Xpad), (int) (cell_area.Y + y_offset + this.Ypad), (int) (width * Percentage), height - 1);
+ widget.StyleContext.Restore ();
- Style.PaintBox (widget.Style, (Gdk.Window) window, state, ShadowType.Out, clipping_area2, widget, "bar", (int) (cell_area.X + x_offset + this.Xpad), (int) (cell_area.Y + y_offset + this.Ypad), (int) (width * Percentage), height - 1);
+ widget.StyleContext.Save ();
+ widget.StyleContext.AddClass ("progressbar");
+ widget.StyleContext.RenderActivity (cr, x, y, (int) (width * Percentage), height);
+ widget.StyleContext.Restore ();
}
}
public class Driver : Gtk.Window
{
public static void Main ()
{
- Application.Init ();
+ Gtk.Application.Init ();
new Driver ();
- Application.Run ();
+ Gtk.Application.Run ();
}
ListStore liststore;
@@ -128,7 +127,7 @@ bool update_percent ()
void window_delete (object obj, DeleteEventArgs args)
{
- Application.Quit ();
+ Gtk.Application.Quit ();
args.RetVal = true;
}
}
View
@@ -8,7 +8,7 @@ DOTNET_TARGETS=
DOTNET_ASSEMBLY=
endif
-TARGETS = gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe treeviewdemo.exe managedtreeviewdemo.exe nodeviewdemo.exe treemodeldemo.exe actions.exe spawn.exe assistant.exe registerprop.exe gexceptiontest.exe native-instantiation.exe polarfixed.exe cairo-sample.exe scribble.exe testdnd.exe #custom-widget.exe custom-cellrenderer.exe scribble-xinput.exe $(DOTNET_TARGETS)
+TARGETS = gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe treeviewdemo.exe managedtreeviewdemo.exe nodeviewdemo.exe treemodeldemo.exe actions.exe spawn.exe assistant.exe registerprop.exe gexceptiontest.exe native-instantiation.exe polarfixed.exe cairo-sample.exe scribble.exe testdnd.exe custom-cellrenderer.exe #custom-widget.exescribble-xinput.exe $(DOTNET_TARGETS)
DEBUGS = $(addsuffix .mdb, $(TARGETS))

0 comments on commit 75f9a8a

Please sign in to comment.