| 1 | # parent => $widget ? | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright 2007, 2008, 2009, 2010 Kevin Ryde | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # This file is part of Chart. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Chart is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # it under the terms of the GNU General Public License as published by the | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # Free Software Foundation; either version 3, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # version. | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # Chart is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # You should have received a copy of the GNU General Public License along | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # with Chart. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | package App::Chart::Gtk2::Ex::ToplevelBits; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use List::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use App::Chart::Gtk2::Ex::ToplevelSingleton; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # uncomment this to run the ### lines | ||||||||||||||||||||||||||||||||||||||||||
| 29 | #use Smart::Comments; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # screen | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # parent | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # with_properties | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # init_properties | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # modal | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # hide_on_delete | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub popup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
popup: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my ($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | ### ToplevelBits popup(): $class | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $properties = $options{'properties'} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{'properties'} || {}
MC/DC0%0/1
$options{'properties'} || {}
$options{'properties'}
Truth table0%0/2
A
A= $options{'properties'}
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | my $screen = _screen | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | ($options{'transient_for'} || $options{'parent'} || $options{'screen'}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$options{'transient_for'} || $options{'parent'} || $options{'screen'}
$options{"transient_for"} or $options{"parent"}
MC/DC0%0/3
$options{'transient_for'} || $options{'parent'} || $options{'screen'}
$options{"transient_for"}
$options{"parent"}
$options{'screen'}
Truth table0%0/4
A or B || C
A= $options{"transient_for"}B= $options{"parent"}C= $options{'screen'}
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | my $dialog = List::Util::first | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | {$_->isa($class) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
Condition0%0/6
$_->isa($class) and !defined($screen) || $_->get_screen == $screen
not defined $screen or $_->get_screen == $screen
MC/DC0%0/3
$_->isa($class) and !defined($screen) || $_->get_screen == $screen
$_->isa($class)
not defined $screen
$_->get_screen == $screen
Truth table0%0/4
A and not(B) or C
A= $_->isa($class)B= not defined $screenC= $_->get_screen == $screen
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | && (! defined $screen || $_->get_screen == $screen) | ||||||||||||||||||||||||||||||||||||||||||
| 49 | && _object_properties_equal($_,$properties)} | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | Gtk2::Window->list_toplevels; | |||||||||||||||||||||||||||||||||||||||||
| 51 | ### ToplevelBits found: $dialog | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($dialog) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if (exists $options{'modal'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $dialog->set_modal ($options{'modal'}); | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (exists $options{'transient_for'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $dialog->set_transient_for ($options{'transient_for'}); | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ### new dialog $class | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if (eval { require Gtk2::Ex::WidgetCursor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | Gtk2::Ex::WidgetCursor->busy; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | require Module::Load; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | Module::Load::load ($class); | |||||||||||||||||||||||||||||||||||||||||
| 69 | $dialog = $class->Glib::Object::new | ||||||||||||||||||||||||||||||||||||||||||
| 70 | ((defined $screen ? (screen => $screen) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 71 | (exists $options{'modal'} ? (modal => $options{'modal'}) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | (exists $options{'transient_for'} ? (transient_for => $options{'transient_for'}) : ()), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | %$properties); | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($options{'hide_on_delete'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $dialog->signal_connect (delete_event => \&Gtk2::Widget::hide_on_delete); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # if (! $dialog->visible) { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | # if (my $func = $options{'newly_visible_func'}) { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | # $func->($dialog); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $dialog->present; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return $dialog; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub _screen { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_screen: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my ($obj) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if (! defined $obj) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return Gtk2::Gdk::Screen->get_default; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # don't want $display->get_screen($screennum) | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ($obj->isa('Gtk2::Gdk::Display')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return $obj->get_default_screen; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if (my $func = $obj->can('get_screen')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | return $obj->$func || croak "No screen for target $obj"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$obj->$func || croak("No screen for target $obj")
MC/DC0%0/1
$obj->$func || croak("No screen for target $obj")
$obj->$func
Truth table0%0/2
A
A= $obj->$func
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if (my $func = $obj->can('get_default_screen')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return $obj->$func || croak "No default screen for target $obj"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$obj->$func || croak("No default screen for target $obj")
MC/DC0%0/1
$obj->$func || croak("No default screen for target $obj")
$obj->$func
Truth table0%0/2
A
A= $obj->$func
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return $obj; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub _object_properties_equal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_object_properties_equal: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my ($obj, $properties) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | while (my ($pname, $value) = each %$properties) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $pspec = $obj->find_property ($pname) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$obj->find_property($pname) || croak(q[No such property '], $pname, q['])
MC/DC0%0/1
$obj->find_property($pname) || croak(q[No such property '], $pname, q['])
$obj->find_property($pname)
Truth table0%0/2
A
A= $obj->find_property($pname)
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | || croak "No such property '",$pname,"'"; | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($pspec->values_cmp ($value, $obj->get($pname)) != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 119 | __END__ | ||||||||||||||||||||||||||||||||||||||||||