aboutsummaryrefslogtreecommitdiffstats
path: root/template/en/default/attachment/diff-header.html.tmpl
blob: e3ca1ac416ee8ed2aec4b492adc4c173ac91f4f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
[%# 1.0@bugzilla.org %]
[%# The contents of this file are subject to the Mozilla Public
  # License Version 1.1 (the "License"); you may not use this file
  # except in compliance with the License. You may obtain a copy of
  # the License at http://www.mozilla.org/MPL/
  #
  # Software distributed under the License is distributed on an "AS
  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  # implied. See the License for the specific language governing
  # rights and limitations under the License.
  #
  # The Original Code is the Bugzilla Bug Tracking System.
  #
  # The Initial Developer of the Original Code is Netscape Communications
  # Corporation. Portions created by Netscape are
  # Copyright (C) 1998 Netscape Communications Corporation. All
  # Rights Reserved.
  #
  # Contributor(s): John Keiser <jkeiser@netscape.com>
  #%]

[%# Define strings that will serve as the title and header of this page %]

[% PROCESS global/variables.none.tmpl %]

[% title = BLOCK %]
  [% IF attachid %]
Attachment #[% attachid %] for [% terms.bug %] #[% bugid %]
  [% ELSE %]
Interdiff of #[% oldid %] and #[% newid %] for #[% terms.bug %] #[% bugid %]
  [% END %]
[% END %]

[% style = BLOCK %]
.file_head {
  font-weight: bold;
  font-size: 1em;
  background-color: #c3c3c3;
  border: 1px solid black;
  width: 100%;
}

.file_head a {
  text-decoration: none; 
  font-family: monospace; 
  font-size: 1.1em;
}

.file_collapse {
  display: none;
}

.section_head {
  width: 100%;
  background-color: #f0f0f0;
  border: 1px solid black;
  text-align: left;
}

table.file_table {
  table-layout: fixed;
  width: 100%;
  empty-cells: show;
  border-spacing: 0px;
  border-collapse: collapse;
  /* draw border below last open context section in listing */
  border-bottom: 1px solid black;
}

tbody.file td {
  border-left: 1px dashed black;
  border-right: 1px dashed black;
  width: 50%;
}

tbody.file pre {
  display: inline;
  white-space: -moz-pre-wrap;
  font-size: 0.9em;
}

tbody.file pre:empty {
  display: block;
  height: 1em;
}

.changed {
  background-color: lightblue;
}

.added {
  background-color: lightgreen;
}

.removed {
  background-color: #FFCC99;
}

.warning {
  color: red
}
[% END %]

[%# SCRIPT FUNCTIONS %]
[% javascript = BLOCK %]
  function collapse_all() {
    var elem = document.checkboxform.firstChild;
    while (elem != null) {
      if (elem.firstChild != null) {
        var tbody = elem.firstChild.nextSibling;
        if (tbody.className == 'file') {
          tbody.className = 'file_collapse';
          twisty = get_twisty_from_tbody(tbody);
          twisty.firstChild.nodeValue = '(+)';
          twisty.nextSibling.checked = false;
        }
      }
      elem = elem.nextSibling;
    }
    return false;
  }

  function expand_all() {
    var elem = document.checkboxform.firstChild;
    while (elem != null) {
      if (elem.firstChild != null) {
        var tbody = elem.firstChild.nextSibling;
        if (tbody.className == 'file_collapse') {
          tbody.className = 'file';
          twisty = get_twisty_from_tbody(tbody);
          twisty.firstChild.nodeValue = '(-)';
          twisty.nextSibling.checked = true;
        }
      }
      elem = elem.nextSibling;
    }
    return false;
  }

  var current_restore_elem;

  function restore_all() {
    current_restore_elem = null;
    incremental_restore();
  }

  function incremental_restore() {
    if (!document.checkboxform.restore_indicator.checked) {
      return;
    }
    var next_restore_elem;
    if (current_restore_elem) {
      next_restore_elem = current_restore_elem.nextSibling;
    } else {
      next_restore_elem = document.checkboxform.firstChild;
    }
    while (next_restore_elem != null) {
      current_restore_elem = next_restore_elem;
      if (current_restore_elem.firstChild != null) {
        restore_elem(current_restore_elem.firstChild.nextSibling);
      }
      next_restore_elem = current_restore_elem.nextSibling;
    }
  }

  function restore_elem(elem, alertme) {
    if (elem.className == 'file_collapse') {
      twisty = get_twisty_from_tbody(elem);
      if (twisty.nextSibling.checked) {
        elem.className = 'file';
        twisty.firstChild.nodeValue = '(-)';
      }
    } else if (elem.className == 'file') {
      twisty = get_twisty_from_tbody(elem);
      if (!twisty.nextSibling.checked) {
        elem.className = 'file_collapse';
        twisty.firstChild.nodeValue = '(+)';
      }
    }
  }

  function twisty_click(twisty) {
    tbody = get_tbody_from_twisty(twisty);
    if (tbody.className == 'file') {
      tbody.className = 'file_collapse';
      twisty.firstChild.nodeValue = '(+)';
      twisty.nextSibling.checked = false;
    } else {
      tbody.className = 'file';
      twisty.firstChild.nodeValue = '(-)';
      twisty.nextSibling.checked = true;
    }
    return false;
  }

  function get_tbody_from_twisty(twisty) {
    return twisty.parentNode.parentNode.parentNode.nextSibling;
  }
  function get_twisty_from_tbody(tbody) {
    return tbody.previousSibling.firstChild.firstChild.firstChild;
  }
[% END %]

[% onload = 'restore_all(); document.checkboxform.restore_indicator.checked = true' %]

[% BLOCK viewurl %]attachment.cgi?id=[% id %][% END %]
[% BLOCK editurl %][% PROCESS viewurl %]&amp;action=edit[% END %]
[% BLOCK diffurl %][% PROCESS viewurl %]&amp;action=diff[% END %]

[% IF headers %]
  [% h1 = BLOCK %]
    [% IF attachid %]
      Attachment #[% attachid %]: [% description FILTER html %]
    [% ELSE %]
      Diff Between 
       #[% oldid %]: <a href="[% PROCESS diffurl id=oldid %]">[% old_desc FILTER html %]</a>
      and 
       #[% newid %]: <a href="[% PROCESS diffurl id=newid %]">[% new_desc FILTER html %]</a>
    [% END %]
    for <a href="show_bug.cgi?id=[% bugid %]">[% terms.bug %] #[% bugid %]</a>
  [% END %]
  [% h2 = BLOCK %]
    [% bugsummary FILTER html %]
  [% END %]
  [% PROCESS global/header.html.tmpl %]
[% ELSE %]
  <html>
  <head>
  <style type="text/css">
  [% style %]
  </style>
  <script type="text/javascript" language="JavaScript">
  <!--
  [% javascript %]
  -->
  </script>
  </head>
  <body onload="[% onload FILTER html %]">
[% END %]
  
[%# If we have attachid, we are in diff, otherwise we're in interdiff %]
[% IF attachid %]
  [%# HEADER %]
  [% IF headers %]
    <a href="[% PROCESS viewurl id=attachid %]">View</a>
    | <a href="[% PROCESS editurl id=attachid %]">Edit</a>
    | <a href="[% PROCESS diffurl id=attachid %]&amp;context=[% context FILTER html %]&amp;collapsed=[% collapsed FILTER html %]&amp;headers=[% headers FILTER html %]&amp;format=raw">Raw&nbsp;Unified</a>
  [% END %]
  [% IF other_patches %]
    [% IF headers %] |[%END%]
    Differences between
    <form style="display: inline" action="">
      <select name="oldid">
      [% FOREACH patch = other_patches %]
        <option value="[% patch.id %]"
        [% IF patch.selected %] selected[% END %]
        >[% patch.desc FILTER html %]</option>
      [% END %]
      </select>
      and this patch
      <input type="submit" value="Diff">
      <input type="hidden" name="action" value="interdiff">
      <input type="hidden" name="newid" value="[% attachid %]">
      <input type="hidden" name="headers" value="[% headers FILTER html %]">
    </form>
  [% END %]
  <br>
[% ELSE %]
  [% IF headers %]
    <a href="attachment.cgi?oldid=[% oldid %]&amp;newid=[% newid %]&amp;action=interdiff&amp;format=raw">Raw Unified</a>
    |
  [% END %]
[% END %]
  
[%# Collapse / Expand %]
<a href="#"
   onmouseover="lastStatus = window.status; window.status='Collapse All'; return true"
   onmouseout="window.status = lastStatus; return true"
   onclick="return collapse_all()">Collapse All</a> | 
<a href="#"
   onmouseover="lastStatus = window.status; window.status='Expand All'; return true"
   onmouseout="window.status = lastStatus; return true"
   onclick="return expand_all()">Expand All</a>

[% IF do_context %]
  [%# only happens for normal viewing, not interdiff %]
  | <span style='font-weight: bold'>Context:</span>
  [% IF context == "patch" %]
    (<strong>Patch</strong> / 
  [% ELSE %]
    (<a href="[% PROCESS diffurl id=attachid %]&amp;headers=[% headers FILTER html %]">Patch</a> / 
  [% END %]
  [% IF context == "file" %]
    <strong>File</strong> /
  [% ELSE %]
    <a href="[% PROCESS diffurl id=attachid %]&amp;headers=[% headers FILTER html %]&amp;context=file">File</a> / 
  [% END %]

  [% IF context == "patch" || context == "file" %]
    [% context = 3 %]
  [% END %]
  [%# textbox for context %]
  <form style="display: inline" action=""><input type="hidden" name="action" value="diff"><input type="hidden" name="id" value="[% attachid %]"><input type="hidden" name="collapsed" value="[% collapsed FILTER html %]"><input type="hidden" name="headers" value="[% headers FILTER html %]"><input type="text" name="context" value="[% context FILTER html %]" size="3"></form>)
[% END %]

[% IF warning %]
<h2 class="warning">Warning: 
  [% IF warning == "interdiff1" %]
  this difference between two patches may show things in the wrong places due
  to a limitation in [% terms.Bugzilla %] when comparing patches with different
  sets of files.
  [% END %]
  [% IF warning == "interdiff2" %]
  this difference between two patches may be inaccurate due to a limitation in
  [%+ terms.Bugzilla %] when comparing patches made against different revisions.
  [% END %]
</h2>
[% ELSE %]
    <br><br>
[% END %]
 
[%# Restore Stuff %]
<form name="checkboxform" action="">
<input type="checkbox" name="restore_indicator" style="display: none">


id='n585' href='#n585'>585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894
package ugtk;

# DO NOT USE THIS MODULE ANYMORE; IT'S DEPRECATED
# BETTER USE ugtk2 (gtk+2, fontconfig, ... and the like support)
#
# ONLY standalone/net_monitor STILL USES IT

use diagnostics;
use strict;
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $border $use_pixbuf $use_imlib);

@ISA = qw(Exporter);
%EXPORT_TAGS = (
    helpers => [ qw(createScrolledWindow create_menu create_notebook create_packtable create_hbox create_vbox create_adjustment create_box_with_title create_treeitem create_dialog destroy_window) ],
    wrappers => [ qw(gtksignal_connect gtkradio gtkpack gtkpack_ gtkpack__ gtkpack2 gtkpack2_ gtkpack2__ gtkpowerpack gtkcombo_setpopdown_strings gtkset_editable gtksetstyle gtkset_text gtkset_tip gtkappenditems gtkappend gtkset_shadow_type gtkset_layout gtkset_relief gtkadd gtkexpand gtkput gtktext_insert gtkset_usize gtksize gtkset_justify gtkset_active gtkset_sensitive gtkset_visibility gtkset_modal gtkset_border_width gtkmove gtkresize gtkshow gtkhide gtkdestroy gtkflush gtkcolor gtkset_mousecursor gtkset_mousecursor_normal gtkset_mousecursor_wait gtkset_background gtkset_default_fontset gtkctree_children gtkxpm gtkpng create_pix_text get_text_coord fill_tiled gtkicons_labels_widget write_on_pixmap gtkcreate_xpm gtkcreate_png gtkcreate_png_pixbuf gtkbuttonset create_pixbutton gtkroot gtkentry compose_with_back compose_pixbufs) ],
    various => [ qw(add2notebook add_icon_path n_line_size) ],
);
$EXPORT_TAGS{all} = [ map { @$_ } values %EXPORT_TAGS ];
@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;

use Gtk;

if (!$::no_ugtk_init) {
    !check_for_xserver() and die "Cannot be run in console mode.\n";
    Gtk->init;
    eval { require Gtk::Gdk::Pixbuf; Gtk::Gdk::Pixbuf->init };
    $use_pixbuf = $@ ? 0 : 1;
}
eval { require Gtk::Gdk::ImlibImage; Gtk::Gdk::ImlibImage->init };
$use_imlib = $@ ? 0 : 1;

use c;
use log;
use common;

my @icon_paths;
sub add_icon_path { push @icon_paths, @_ }
sub icon_paths() {
   (@icon_paths, $ENV{SHARE_PATH}, "$ENV{SHARE_PATH}/icons", "$ENV{SHARE_PATH}/libDrakX/pixmaps", "/usr/lib/libDrakX/icons", "pixmaps", 'standalone/icons');
}  

#-#######################
# gtk widgets wrappers
#-#######################

sub gtkdestroy                { $_[0] and $_[0]->destroy }
sub gtkflush()                  { Gtk->main_iteration while Gtk->events_pending }
sub gtkhide                   { $_[0]->hide; $_[0] }
sub gtkmove                   { $_[0]->window->move($_[1], $_[2]); $_[0] }
sub gtkpack                   { gtkpowerpack(1, 1, @_) }
sub gtkpack_                  { gtkpowerpack('arg', 1, @_) }
sub gtkpack__                 { gtkpowerpack(0, 1, @_) }
sub gtkpack2                  { gtkpowerpack(1, 0, @_) }
sub gtkpack2_                 { gtkpowerpack('arg', 0, @_) }
sub gtkpack2__                { gtkpowerpack(0, 0, @_) }
sub gtkput                    { $_[0]->put(gtkshow($_[1]), $_[2], $_[3]); $_[0] }
sub gtkpixmap                 { new Gtk::Pixmap(gdkpixmap(@_)) }
sub gtkresize                 { $_[0]->window->resize($_[1], $_[2]); $_[0] }
sub gtkset_active             { $_[0]->set_active($_[1]); $_[0] }
sub gtkset_border_width       { $_[0]->set_border_width($_[1]); $_[0] }
sub gtkset_editable           { $_[0]->set_editable($_[1]); $_[0] }
sub gtkset_justify            { $_[0]->set_justify($_[1]); $_[0] }
sub gtkset_layout             { $_[0]->set_layout($_[1]); $_[0] }
sub gtkset_modal              { $_[0]->set_modal($_[1]); $_[0] }
sub gtkset_mousecursor_normal { gtkset_mousecursor(68, @_) }
sub gtkset_mousecursor_wait   { gtkset_mousecursor(150, @_) }
sub gtkset_relief             { $_[0]->set_relief($_[1]); $_[0] }
sub gtkset_sensitive          { $_[0]->set_sensitive($_[1]); $_[0] }
sub gtkset_visibility         { $_[0]->set_visibility($_[1]); $_[0] }
sub gtkset_tip                { $_[0]->set_tip($_[1], $_[2]) if $_[2]; $_[1] }
sub gtkset_shadow_type        { $_[0]->set_shadow_type($_[1]); $_[0] }
sub gtkset_style              { $_[0]->set_style($_[1]); $_[0] }
sub gtkset_usize              { $_[0]->set_usize($_[1], $_[2]); $_[0] }
sub gtkshow                   { $_[0]->show; $_[0] }
sub gtksize                   { $_[0]->size($_[1], $_[2]); $_[0] }
sub gtkexpand                 { $_[0]->expand; $_[0] }

sub gdkpixmap {
    my ($f, $w) = @_;
    $f =~ m|.png$| and return gtkcreate_png($f);
    $f =~ m|.xpm$| and return gtkcreate_xpm($w, $f);
}

sub gtkadd {
    my $w = shift;
    foreach (@_) {
	my $l = $_;
	ref $l or $l = new Gtk::Label($l);
	$w->add($l);
	$l->show;
    }
    $w
}

sub gtkappend {
    my $w = shift;
    foreach (@_) {
	my $l = $_;
	ref $l or $l = new Gtk::Label($l);
	$w->append($l);
	$l->show;
    }
    $w
}

sub gtkappenditems {
    my $w = shift;
    $_->show() foreach @_;
    $w->append_items(@_);
    $w
}

sub gtkbuttonset {
    gtkdestroy($_[0]->child);
    gtkadd($_[0], gtkshow($_[1]))
}

sub create_pixbutton {
    my ($label, $pix, $reverse_order) = @_;
    gtkadd(new Gtk::Button(), gtkpack_(new Gtk::HBox(0, 3), 1, "", $reverse_order ? (0, $label, if_($pix, 0, $pix)) : (if_($pix, 0, $pix), 0, $label), 1, ""));
}

sub gtkentry {
    my ($text) = @_;
    my $e = new Gtk::Entry;
    $e->set_text($text);
    $e;
}

sub gtksetstyle { 
    my ($w, $s) = @_;
    $w->set_style($s);
    $w;
}

sub gtkcolor {
    my ($r, $g, $b) = @_;
    my $color = bless { red => $r, green => $g, blue => $b }, 'Gtk::Gdk::Color';
    gtkroot()->get_colormap->color_alloc($color);
}

sub gtkradio {
    my $def = shift;
    my $radio;
    map { $radio = new Gtk::RadioButton($_, if_($radio, $radio));
	  $radio->set_active($_ eq $def); $radio } @_;
}

sub gtkroot {
    Gtk->init;
    Gtk->set_locale;
    Gtk::Gdk::Window->new_foreign(Gtk::Gdk->ROOT_WINDOW);
}

sub gtkset_background {
    my ($r, $g, $b) = @_;
    my $root = gtkroot();
    my $gc = Gtk::Gdk::GC->new($root);
    my $color = gtkcolor($r, $g, $b);
    $gc->set_foreground($color);
    $root->set_background($color);
    my ($h, $w) = $root->get_size;
    $root->draw_rectangle($gc, 1, 0, 0, $w, $h);
}

sub gtktext_insert {
    my ($w, $t) = @_;
    $w->freeze;
    $w->backward_delete($w->get_length);
    if (ref($t) eq 'ARRAY') {
	$w->insert($_->[0], $_->[1], $_->[2], $_->[3]) foreach @$t;
    } else {
	$w->insert(undef, undef, undef, $t); 
    }
    #- DEPRECATED? needs \n otherwise in case of one line text the beginning is not shown (even with the vadj->set_value)
    $w->set_word_wrap(1);
#-    $w->vadj->set_value(0);
    $w->thaw;
    $w;
}

sub gtkset_text {
    my ($w, $s) = @_;
    $w->set_text($s);
    $w;
}

sub gtkcombo_setpopdown_strings {
    my $w = shift;
    $w->set_popdown_strings(@_);
    $w;
}

sub gtkappend_text {
    my ($w, $s) = @_;
    $w->append_text($s);
    $w;
}

sub gtkprepend_text {
    my ($w, $s) = @_;
    $w->prepend_text($s);
    $w;
}

sub gtkset_mousecursor {
    my ($type, $w) = @_;
    ($w || gtkroot())->set_cursor(Gtk::Gdk::Cursor->new($type));
}

sub gtksignal_connect {
    my $w = shift;
    $w->signal_connect(@_);
    $w;
}

#-#######################
# create widgets wrappers
#-#######################

sub create_adjustment {
    my ($val, $min, $max) = @_;
    new Gtk::Adjustment($val, $min, $max + 1, 1, ($max - $min + 1) / 10, 1);
}

sub create_box_with_title {
    my $o = shift;

    my $nbline = sum(map { round(length($_) / 60 + 1/2) } map { split "\n" } @_);
    my $box = new Gtk::VBox(0,0);
    return $box if $nbline == 0;

    $o->{box_size} = n_line_size($nbline, 'text', $box);
    if (@_ <= 2 && $nbline > 4) {
	$o->{icon} && !$::isWizard and 
	  eval { gtkpack__($box, gtkset_border_width(gtkpack_(new Gtk::HBox(0,0), 1, gtkpng($o->{icon})),5)) };
	my $wanted = $o->{box_size};
	$o->{box_size} = min(200, $o->{box_size});
	my $has_scroll = $o->{box_size} < $wanted;

	my $wtext = new Gtk::Text;
	$wtext->can_focus($has_scroll);
	chomp(my $text = join("\n", @_));
	my $scroll = createScrolledWindow(gtktext_insert($wtext, $text));
	$scroll->set_usize(400, $o->{box_size});
	gtkpack($box, $scroll);
    } else {
	my $a = !$::no_separator;
	undef $::no_separator;
	if ($o->{icon} && !$::isWizard) {
	    gtkpack__($box,
		      gtkpack_(new Gtk::HBox(0,0),
			       0, gtkset_usize(new Gtk::VBox(0,0), 15, 0),
			       0, eval { gtkpng($o->{icon}) },
			       0, gtkset_usize(new Gtk::VBox(0,0), 15, 0),
			       1, gtkpack_($o->{box_title} = new Gtk::VBox(0,0),
					   1, new Gtk::HBox(0,0),
					   (map {
					       my $w = ref $_ ? $_ : new Gtk::Label($_);
					       $::isWizard and $w->set_justify("left");
					       $w->set_name("Title");
					       (0, $w);
					   } map { ref $_ ? $_ : warp_text($_) } @_),
					   1, new Gtk::HBox(0,0),
					  )
			      ),
		      if_($a, new Gtk::HSeparator)
		     )
	} else {
	    gtkpack__($box,
		      (map {
			  my $w = ref $_ ? $_ : new Gtk::Label($_);
			  $::isWizard and $w->set_justify("left");
			  $w->set_name("Title");
			  $w;
		      } map { ref $_ ? $_ : warp_text($_) } @_),
		      if_($a, new Gtk::HSeparator)
		     )
	}
    }
}

# drakfloppy / logdrake
sub create_dialog {
    my ($label, $c) = @_;
    my $ret = 0;
    my $dialog = new Gtk::Dialog;
    $dialog->signal_connect(delete_event => sub { Gtk->main_quit() });
    $dialog->set_title(N("logdrake"));
    $dialog->border_width(10);
    $dialog->vbox->pack_start(new Gtk::Label($label),1,1,0);

    my $button = new Gtk::Button(N("OK"));
    $button->can_default(1);
    $button->signal_connect(clicked => sub { $ret = 1; $dialog->destroy(); Gtk->main_quit() });
    $dialog->action_area->pack_start($button, 1, 1, 0);
    $button->grab_default;

    if ($c) {
	my $button2 = new Gtk::Button(N("Cancel"));
	$button2->signal_connect(clicked => sub { $ret = 0; $dialog->destroy(); Gtk->main_quit() });
	$button2->can_default(1);
	$dialog->action_area->pack_start($button2, 1, 1, 0);
    }

    $dialog->show_all;
    Gtk->main();
    $ret;
}

# drakfloppy / logdrake
sub destroy_window {
	my ($_widget, $windowref, $w2) = @_;
	$$windowref = undef;
	$w2 = undef if defined $w2;
	0;
}

sub create_hbox { gtkset_layout(gtkset_border_width(new Gtk::HButtonBox, 3), $_[0] || 'spread') }

sub create_factory_menu_ {
    my ($type, $name, $window, @menu_items) = @_;
    my $widget = new Gtk::ItemFactory($type, $name, my $accel_group = new Gtk::AccelGroup);
    $widget->create_items(@menu_items);
    $window->add_accel_group($accel_group); #$accel_group->attach($main_win);
    my $menu = $widget->get_widget($name);
    $menu->{factory} = $widget;
    $menu; # return menu bar
}

sub create_factory_menu { create_factory_menu_('Gtk::MenuBar', '<main>', @_) }

sub create_menu {
    my $title = shift;
    my $w = new Gtk::MenuItem($title);
    $w->set_submenu(gtkshow(gtkappend(new Gtk::Menu, @_)));
    $w
}

sub create_notebook {
    my $n = new Gtk::Notebook;
    add2notebook($n, splice(@_, 0, 2)) while @_;
    $n
}

sub create_packtable {
    my ($options, @l) = @_;
    my $w = new Gtk::Table(0, 0, $options->{homogeneous} || 0);
    each_index {
	my ($i, $l) = ($_[0], $_);
	each_index {
	    my ($j) = @_;
	    if ($_) {
		ref $_ or $_ = new Gtk::Label($_);
		$j != $#$l ?
		  $w->attach($_, $j, $j + 1, $i, $i + 1, 'fill', 'fill', 5, 0) :
		  $w->attach($_, $j, $j + 1, $i, $i + 1, 1|4, ref($_) eq 'Gtk::ScrolledWindow' ? 1|4 : 0, 0, 0);
		$_->show;
	    }
	} @$l;
    } @l;
    $w->set_col_spacings($options->{col_spacings} || 0);
    $w->set_row_spacings($options->{row_spacings} || 0);
    $w
}

sub createScrolledWindow {
    my ($W, $policy, $viewport_shadow) = @_;
    my $w = new Gtk::ScrolledWindow(undef, undef);
    $policy ||= [ 'automatic', 'automatic' ];
    $w->set_policy(@$policy);
    if (member(ref $W, qw(Gtk::CList Gtk::CTree Gtk::Text))) {
       $w->add($W)
    } else {
       $w->add_with_viewport($W);
       $viewport_shadow and gtkset_shadow_type($w->child, $viewport_shadow);
    }
    $W->can("set_focus_vadjustment") and $W->set_focus_vadjustment($w->get_vadjustment);
    $W->show;
    $w
}

sub create_treeitem {
    my ($name) = @_;
    
    my ($next_child, $left, $right, $up, $down);
    $next_child = sub {
	my ($c, $dir) = @_;
	my @childs = $c->parent->children;
	my $i; for ($i = 0; $i < @childs; $i++) { last if $childs[$i] == $c || $childs[$i]->subtree == $c }
	$i += $dir;
	0 <= $i && $i < @childs ? $childs[$i] : undef;
    };
    $left = sub { &$next_child($_[0]->parent, 0) };