~ubuntu-branches/ubuntu/karmic/zim/karmic

« back to all changes in this revision

Viewing changes to lib/Zim/GUI/TreeView.pm

  • Committer: Bazaar Package Importer
  • Author(s): Emfox Zhou
  • Date: 2007-08-25 13:04:42 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20070825130442-q7xffffj9usah8b4
Tags: 0.20-1
* New upstream release
* Fix the bug which cause wrong internal links (Closes: #438612)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
use Gtk2::Gdk::Keysyms;
7
7
use Zim::GUI::Component;
8
8
 
9
 
our $VERSION = '0.18';
 
9
our $VERSION = '0.20';
10
10
our @ISA = qw/Zim::GUI::Component/;
11
11
 
12
12
=head1 NAME
85
85
 
86
86
        # drag-n-drop stuff
87
87
        $tree_view->enable_model_drag_source(
88
 
                'button1-mask', ['link', 'copy', 'move'],
 
88
                'button1-mask', ['link', 'move', 'copy'],
89
89
                ['text/x-zim-page-list', [], 0] );
90
90
        $tree_view->signal_connect_swapped(
91
91
                drag_data_get => \&on_drag_data_get, $self);
92
92
        $tree_view->enable_model_drag_dest(
93
 
                ['link', 'copy', 'move'],
 
93
                ['link', 'move', 'copy'],
94
94
                ['text/x-zim-page-list', [], 0] );
95
95
        $tree_view->signal_connect_swapped(
96
96
                drag_data_received => \&on_drag_data_received, $self);
116
116
 
117
117
sub on_drag_data_received { # we are drag target
118
118
        my ($self, $context, $x, $y, $selection_data, $info, $time) = @_;
 
119
        #warn "!! drag_action:".$context->action.' ('.join(', ', $context->actions).")\n";
119
120
        return unless $info == 0; # text/x-zim-page-list
120
121
 
121
122
        my $data = $selection_data->data;
303
304
 
304
305
=item C<list_pages(NAMESPACE)>
305
306
 
306
 
Wrapper around C<< Zim::Repository->list_pages() >> to fill the tree.
 
307
Wrapper around C<< Zim::Store->list_pages() >> to fill the tree.
307
308
 
308
309
=cut
309
310
 
324
325
                }
325
326
                my ($ns, $node) = @{ shift @queue };
326
327
                #warn "list_pages: $ns\n";
 
328
                my $child;
327
329
                for my $p ($repository->list_pages($ns)) {
328
330
                        #warn "\t$p\n";
329
331
                        my $is_dir = ($p =~ s/:+$//);
330
332
                        my $name = $p;
331
333
                        $name =~ s/_/ /g;
332
 
                        my $child = $model->append($node);
 
334
                        $child = $model->append($node);
333
335
                        $model->set($child, 0 => $name, 1 => $ns.':'.$p);
334
336
                                # base_name, name
335
337
                        push @queue, [$ns.':'.$p, $child] if $is_dir; # recurse
336
338
                }
 
339
 
 
340
                # expand tree into this namespace (child is last child)
 
341
                $self->{tree_view}->expand_to_path($model->get_path($child))
 
342
                        if $child and $self->{app}{settings}{expand_tree};
 
343
                
337
344
                return 1;
338
345
        } ;
339
346
        warn "# Start scanning tree\n";