*)
let opened = ref None in
+ (* If we are moused-over a particular package, then this is != None. *)
+ let current = ref None in
+ let set_current new_current =
+ let old_current = !current in
+ current := new_current;
+ (* Because this structure contains loops, we can't use
+ * structural comparisons like: = <> compare.
+ *)
+ let do_repaint =
+ match old_current, new_current with
+ | None, Some _ -> true
+ | Some _, None -> true
+ | Some { pkg = { nevra = n1 } }, Some { pkg = { nevra = n2 } } ->
+ n1 <> n2
+ | _ -> false in
+ if do_repaint then drawing_area_repaint ()
+ in
+
(* Called from the "Open package" menu entry and other places. *)
let open_package pkgstr =
debug "open_package %s\n%!" pkgstr;
opened :=
Some (root, pkgs, depsmap, totalsmap, tree, depth, top_total);
+ set_current None;
(* Update the window title. *)
window#set_title (pkgstr ^ " - " ^ base_title);
let tooltips = ref None in
- (* If we are moused-over a particular package, then this is != None. *)
- let current = ref None in
- let set_current new_current =
- let old_current = !current in
- current := new_current;
- (* Because this structure contains loops, we can't use
- * structural comparisons like: = <> compare.
- *)
- let do_repaint =
- match old_current, new_current with
- | None, Some _ -> true
- | Some _, None -> true
- | Some { pkg = { nevra = n1 } }, Some { pkg = { nevra = n2 } } ->
- n1 <> n2
- | _ -> false in
- if do_repaint then drawing_area_repaint ()
- in
-
(* To track tooltips, the 'repaint' function records the location of
* each box (ie. package) in the drawing area in this private data
* structure, and the 'motion' function looks them up in order to
let height = int_of_float height in
if width > 8 then (
- draw_pkg_outline x y width pkgsizewidth height colour;
+ draw_pkg_outline x y width pkgsizewidth height colour pkg;
draw_pkg_label x y width height colour pkg total increm
)
else if width >= 4 then
- draw_pkg_narrow x y width height colour
+ draw_pkg_narrow x y width height colour pkg
(* else
XXX This doesn't work. We need to coalesce small packages
in the tree.
draw_pkg_narrow x y 1 height colour *)
- and draw_pkg_outline x y width pkgsizewidth height colour =
- draw#set_foreground colour;
+ and draw_pkg_outline x y width pkgsizewidth height colour pkg =
+ let body_colour = choose_colour colour pkg in
+ draw#set_foreground body_colour;
draw#rectangle ~x:(x+2) ~y:(y+2)
~width:(width-4) ~height:(height-4)
~filled:true ();
if pkgsizewidth > 2 then (
- draw#set_foreground (darken colour);
+ draw#set_foreground (darken body_colour);
draw#rectangle ~x:(x+2) ~y:(y+2)
~width:(pkgsizewidth-2) ~height:(height-4)
~filled:true ();
- draw#set_foreground (choose_contrasting_colour colour);
+ draw#set_foreground (choose_contrasting_colour body_colour);
draw#set_line_attributes ~style:`ON_OFF_DASH ();
draw#line (x+pkgsizewidth) (y+2) (x+pkgsizewidth) (y+height-2);
draw#set_line_attributes ~style:`SOLID ()
);
- draw#set_foreground (`BLACK);
+ draw#set_foreground `BLACK;
draw#rectangle ~x:(x+2) ~y:(y+2)
~width:(width-4) ~height:(height-4)
~filled:false ()
in
loop txts
- and draw_pkg_narrow x y width height colour =
- draw#set_foreground colour;
+ and draw_pkg_narrow x y width height colour pkg =
+ draw#set_foreground (choose_colour colour pkg);
draw#rectangle ~x:(x+2) ~y:(y+2)
~width:(width-4) ~height:(height-4) ~filled:true ()
if r + g + b > 98304 then `BLACK else `WHITE
| _ -> `WHITE
+ and choose_colour colour pkg =
+ match !current with
+ | None -> colour
+ | Some current ->
+ let nevra = pkg.nevra in
+ let is_parent =
+ List.exists
+ (fun { pkg = { nevra = n } } -> n = nevra) current.parents in
+ let is_child =
+ List.exists
+ (fun { pkg = { nevra = n } } -> n = nevra) current.children in
+ if is_parent && is_child then `RGB (63000, 63000, 0) (* yellow *)
+ else if is_parent then `RGB (0, 63000, 63000) (* cyan *)
+ else if is_child then `RGB (0, 63000, 0) (* green *)
+ else colour
+
and darken = function
| `RGB (r, g, b) ->
`RGB (r * 9 / 10, g * 9 / 10, b * 9 / 10)
(display_percent increm top_total) (display_size increm) increm
(display_percent total top_total) (display_size total) total in
let text = if dep.parents = [] then text else text ^ sprintf "
-Required by:
+Required by (blue):
%s"
(deps_of_string dep.parents) in
let text = if dep.children = [] then text else text ^ sprintf "
-Requires:
+Requires (green):
%s"
(deps_of_string dep.children) in
tt#set_tip ~text (da :> GObj.widget);