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
This commit is contained in:
Bertrand Lorentz 2011-07-02 19:06:48 +02:00
parent 23a0aa7af2
commit 75f9a8acb7
2 changed files with 23 additions and 24 deletions

View File

@ -46,31 +46,30 @@ public class CustomCellRenderer : CellRenderer
}
}
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);
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);
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);
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 ();
}
}
@ -78,9 +77,9 @@ 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 @@ public class Driver : Gtk.Window
void window_delete (object obj, DeleteEventArgs args)
{
Application.Quit ();
Gtk.Application.Quit ();
args.RetVal = true;
}
}

View File

@ -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))