xdot: [PATCH] Use theme background on DotWidget

35 views
Skip to first unread message

astian

unread,
Oct 2, 2018, 11:20:17 PM10/2/18
to xdo...@googlegroups.com, jose.r....@gmail.com
Hello,

I use a dark GTK+ theme and the stark white background on xdot's graph canvas
area sometimes hurts my eyes. I cobbled together the following patch which
makes the widget use the current theme's background colour instead.

Thanks.

--

--- a/xdot/ui/window.py 2018-10-01 20:06:48.309787120 +0000
+++ b/xdot/ui/window.py 2018-10-01 20:15:02.551392432 +0000
@@ -170,11 +170,11 @@ class DotWidget(Gtk.DrawingArea):
return True

def on_draw(self, widget, cr):
- cr.set_source_rgba(1.0, 1.0, 1.0, 1.0)
- cr.paint()
+ rect = self.get_allocation()
+ Gtk.render_background(self.get_style_context(), cr, 0, 0,
+ rect.width, rect.height)

cr.save()
- rect = self.get_allocation()
cr.translate(0.5*rect.width, 0.5*rect.height)
cr.scale(self.zoom_ratio, self.zoom_ratio)
cr.translate(-self.x, -self.y)

José Fonseca

unread,
Oct 11, 2018, 8:49:18 AM10/11/18
to ast...@e-nautia.com, xdo...@googlegroups.com
Fair enough.  The graph background colors default to white, but there's no guarantee they will be so.  I pushed thsi change.

Jose

Vladislav Ivanishin

unread,
Jul 18, 2019, 9:34:43 AM7/18/19
to xdot.py
This still gives white background for the rectangle area behind the graph itself, right?

Or am I not using the theme correctly? Here's what I get (attaching a pic):

scrot-1.png



Any graph would do, but FWIW here's the input:

$ cat test-theme.dot
digraph "/tmp/07-16/fold.026t.uninit" {
overlap=false;
        fn_0_basic_block_0 [shape=Mdiamond,label="ENTRY"];
        fn_0_basic_block_2 [shape=record,label="{\<bb\ 2\>: Hi}"];
        fn_0_basic_block_14 [shape=record,label="{\<bb\ 14\>:\l\ Yo}"];
        fn_0_basic_block_3 [shape=record,label="{\<bb\ 3\>:foo}"];
        fn_0_basic_block_4 [shape=record,label="{\<bb\ 4\>:\lbar}"];
        fn_0_basic_block_0:s -> fn_0_basic_block_2:n;
        fn_0_basic_block_2:s -> fn_0_basic_block_3:n;
        fn_0_basic_block_2:s -> fn_0_basic_block_14:n;
        fn_0_basic_block_14:s -> fn_0_basic_block_4:n;
        fn_0_basic_block_3:s -> fn_0_basic_block_4:n;
}

Thank you.
Vlad

astian

unread,
Jul 19, 2019, 5:46:56 AM7/19/19
to xdot.py, Vladislav Ivanishin
Vladislav Ivanishin:
> This still gives white background for the rectangle area behind the graph
> itself, right?

That is correct. As José Fonseca noted:

José Fonseca:
> Fair enough. The graph background colors default to white, but there's no
> guarantee they will be so. I pushed thsi change.

The graph colours can be changed using the graphviz language, see example below.

Cheers.

--

digraph "exg" {
graph [pad=0.8, bgcolor="#232323", color=white];
node [fontcolor="#fefefe", fontsize=12, fillcolor="#121212", style=filled, color="#666666", shape=box, fontname=Ubuntu];
edge [tailport=s, color=blue, headport=n];
header [color="#ff0000", penwidth=2, fillcolor="#660000", label="Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore\net dolore magna aliquyam erat, sed diam voluptua.", shape=note];
subgraph ets {
rank=same;
"e0" [penwidth=2, color="#00ff00", label="At vero eos et accusam et justo duo dolores et ea\nrebum. Stet clita kasd gubergren, no sea takimata\nsanctus est Lorem ipsum dolor sit amet."];
}
header -> "e0" [style=invis];
"#5" -> "#16";
"#86" -> "#87";
"#85.2" -> "#87";
"#119.1" -> "#120";
"#118.2" -> "#120";
"#119" -> "#120";
"#118.1" -> "#119";
"#25" -> "#25.1";
"#16" -> "#16.1";
"#83" -> "#84";
"#83.1" -> "#84";
"#60.1" -> "#60.2";
"#16.1" -> "#17";
"#81" -> "#83";
"#46.2" -> "#49";
"#47.1" -> "#49";
"#48" -> "#49";
"#99.1" -> "#100";
"#99.2" -> "#100";
"#66" -> "#66.1";
"#99.1" -> "#99.2";
}

Vladislav Ivanishin

unread,
Jul 19, 2019, 6:54:04 AM7/19/19
to astian, xdot.py
astian writes:

> Vladislav Ivanishin:
>> This still gives white background for the rectangle area behind the graph
>> itself, right?
>
> That is correct. As José Fonseca noted:
>
> José Fonseca:
>> Fair enough. The graph background colors default to white, but there's no
>> guarantee they will be so. I pushed thsi change.
>
> The graph colours can be changed using the graphviz language, see example below.
>
> Cheers.

Oh, great! The important bit here is

graph [bgcolor="#232323"];

Thanks a lot for the original patch and for the pointer.

--
Vlad
Reply all
Reply to author
Forward
0 new messages