blib/lib/UR/Object/View/Default/Gtk2.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 60 SCAR 30.0
CC
4
Cov
0%
_update_view_from_subject
20.0
_create_widget
2.0
_update_subject_from_view
2.0
CRAP 20.0
1 package UR::Object::View::Default::Gtk2;
2  
3 use strict;
4 use warnings;
5 require UR;
6 our $VERSION = "0.46"; # UR $VERSION;
7  
8 class UR::Object::View::Default::Gtk2 {
9 is => 'UR::Object::View',
10 has_constant => [
11 perspective => { value => 'default'},
12 toolkit => { value => 'gtk2'},
13 ],
14 };
15  
16 sub _create_widget {
17 my $self = shift;
18 my $label = Gtk2::Label->new("<new>");
19 return $label;
20 }
21  
22 sub _update_view_from_subject {
23 my $self = shift;
24 my $subject = $self->subject();
25 my @aspects = $self->aspects;
26 my $widget = $self->widget();
27
28 my $text = $self->subject_class_name;
29 $text .= " with id " . $subject->id if $subject;
30  
31 # Don't recurse back into something we're already in the process of showing
32 if ($self->_subject_is_used_in_an_encompassing_view()) {
33 $text .= " (REUSED ADDR)\n";
34 } else {
35 $text .= "\n";
36 my @sorted_aspects = map { $_->[1] }
37 sort { $a->[0] <=> $b->[0] }
38 map { [ $_->position, $_ ] }
39 @aspects;
40 for my $aspect (@sorted_aspects) {
41 my $label = $aspect->label;
42 $text .= "\n" . $label . ": ";
43 if ($subject) {
44 my @value = $subject->$label;
45 $text .= join(", ", @value);
46 }
47 else {
48 $text .= "-";
49 }
50 }
51 }
52 $widget->set_text($text);
53 return 1;
54 }
55  
56 sub _update_subject_from_view {
57 Carp::confess("This widget shouldn't be able to write to the object, it's a label? How did I get called?");
58 }
59  
60 sub _add_aspect {
61 shift->_update_view_from_subject;
62 }
63  
64 sub _remove_aspect {
65 shift->_update_view_from_subject;
66 }
67  
68 1;
69  
70 =pod
71  
72 =head1 NAME
73  
74 UR::Object::View::Default::Gtk2 - Gtk2 adaptor for object views
75  
76 =head1 DESCRIPTION
77  
78 This class provides code that implements a basic Gtk2 renderer for UR objects.
79  
80 =head1 SEE ALSO
81  
82 UR::Object::View, UR::Object
83  
84 =cut
85