diff -ru Zim-0.19/lib/Zim/GUI/PageView.pm Zim-0.19-bugfix/lib/Zim/GUI/PageView.pm --- Zim-0.19/lib/Zim/GUI/PageView.pm 2007-03-20 22:18:03.000000000 +0000 +++ Zim-0.19-bugfix/lib/Zim/GUI/PageView.pm 2008-03-27 19:42:38.000000000 +0000 @@ -328,26 +328,41 @@ =over 4 -=item C +=item C Applies the property FORMAT to any selected text or toggles the edit mode. +BOOLEAN is used to force format (TRUE) or un-format (FALSE). If BOOLEAN is +undefined the function acts as a toggle. + =cut -sub on_ApplyFormat { # catch all for format actions +sub on_ApplyFormat { + # Catches all for format actions + # + # This function passes on boolean values for toggles in order to + # make sure that the action is consistent with the displayed toggle. + # Without this it is possible to end up in a infinite loop when the + # two end up out of sync. my ($action, $self) = @_; return if $self->{_block_actions}; my $tag = lc $action->get_name; - $tag =~ s/^t// if $action->isa('Gtk2::ToggleAction'); + my $bool = undef; + if ($action->isa('Gtk2::ToggleAction')) { + $tag =~ s/^t//; + $bool = $action->get_active; + } + warn "## dispatch ACTION " . + (($tag eq 'link') ? "Link(undef, $bool)" : "ApplyFormat($tag, $bool)") . "\n"; ($tag eq 'link') - ? $self->Link() - : $self->ApplyFormat($tag) ; + ? $self->Link(undef, $bool) + : $self->ApplyFormat($tag, $bool) ; } sub ApplyFormat { - my ($self, $tag) = @_; + my ($self, $tag, $bool) = @_; die "Can't call ApplyFormat without a tag" unless length $tag; my $buffer = $self->{buffer}; my $has_tag = ($tag eq 'normal') ? 1 : 0; @@ -376,6 +391,9 @@ $select = 'auto' if defined $start; } + return 0 if defined $bool and $bool == $has_tag; + # do nothing if state is same + if ($select) { # there is a selection if ($tag eq 'verbatim' and !$has_tag) { $_Verbatim ||= $buffer->get_tag_table->lookup('Verbatim'); @@ -403,14 +421,12 @@ $buffer->select_range($end, $end) if $end; } } - else { - #warn "Toggle $tag\n"; + $buffer->set_edit_mode_tags($has_tag ? () : ($tag)); } -} -=item C +=item C This method is called by the "Link" button or by the ^L keybinding. It makes any selected text a link or toggles the link property. @@ -421,23 +437,28 @@ In readonly modus the selected text is regarded as a link and followed immediatly, but no actual link is made. +BOOLEAN is used to force link (TRUE) or unlink (FALSE). If BOOLEAN is +undefined the function acts as a toggle. + =cut sub Link { - my ($self, $link) = @_; + my ($self, $link, $bool) = @_; my $buffer = $self->{buffer}; my ($start, $end) = $buffer->get_selection_bounds; unless ($end and $start != $end) { # no selection if (grep {$_->{is_link}} $buffer->get_edit_mode_tags) { - $buffer->set_edit_mode_tags(); # reset - return; + $bool = 0 unless defined $bool; + $buffer->set_edit_mode_tags() unless $bool; # reset + return !$bool; } elsif ($self->{app}{settings}{use_autoselect}) { ($start, $end) = $buffer->auto_selection('link'); } unless ($end and $start != $end) { + return 0 if defined $bool and !$bool; my $tag = $buffer->create_link_tag; $buffer->set_edit_mode_tags($tag); return; @@ -452,6 +473,7 @@ $self->{app}{settings}{read_only} or $self->{app}{page}{properties}{read_only} ) { + return 0 if defined $bool and !$bool; my $bit = $link eq $text; $buffer->remove_all_tags($start, $end); $self->{htext}->apply_link(($bit ? undef : $link), $start, $end); @@ -947,9 +969,12 @@ my $copy_item = Gtk2::MenuItem->new( ($type eq 'mail') ? 'Copy Email Address' : 'Copy _Link' ); $copy_item->signal_connect(activate => sub { - my $clipboard = Gtk2::Clipboard->get( - Gtk2::Gdk::Atom->new('PRIMARY') ); - $clipboard->set_text($link); + # copy to both clipboard and selection + for (qw/CLIPBOARD PRIMARY/) { + my $c = Gtk2::Clipboard->get( + Gtk2::Gdk::Atom->new($_) ); + $c->set_text($link); + } } ); $copy_item->show; $menu->prepend($copy_item); Only in Zim-0.19-bugfix/lib/Zim/GUI: PageView.pm~ diff -ru Zim-0.19/lib/Zim/GUI/TrayIcon.pm Zim-0.19-bugfix/lib/Zim/GUI/TrayIcon.pm --- Zim-0.19/lib/Zim/GUI/TrayIcon.pm 2007-03-20 22:18:03.000000000 +0000 +++ Zim-0.19-bugfix/lib/Zim/GUI/TrayIcon.pm 2008-03-27 20:45:39.000000000 +0000 @@ -4,7 +4,7 @@ use Gtk2; use Zim::GUI::Component; -our $VERSION = '0.19'; +our $VERSION = '0.20'; our @ISA = qw/Zim::GUI::Component/; our $icon_class; @@ -198,9 +198,11 @@ sub on_popup_menu_activate { my ($app, $type, $page) = @{ pop(@_) }; + warn "app $app type $type page $page\n"; $app->present; - if ($type eq 'r') { $app->go_recent($page) } - else { $app->$page() } # GoHome or GoToday + return $app->$page() unless $type eq 'r'; # GoHome or GoToday + my $rec = $app->{history}->jump($page) || return; + $app->load_page($rec); } 1; diff -ru Zim-0.19/lib/Zim/Page.pm Zim-0.19-bugfix/lib/Zim/Page.pm --- Zim-0.19/lib/Zim/Page.pm 2007-03-20 22:18:03.000000000 +0000 +++ Zim-0.19-bugfix/lib/Zim/Page.pm 2008-03-27 20:32:25.000000000 +0000 @@ -578,6 +578,10 @@ # ergo, if "new_match" is there, this was not a link # to "match" in the first place my $new = $self->relative_name($links{$match}); + unless (length $new) { + warn "\tBUG: could not update link to $links{$match}\n"; + next; + } warn "\tUpdating $match => $new\n"; $$ref[1]{to} = $new; $$ref[2] = $new if @$ref == 3 and $$ref[2] eq $old; @@ -602,6 +606,10 @@ my $page = $self->{repository}->root->resolve_name($l, $from); #warn "resolved $l => $page\n"; my $new = $self->relative_name($page); + unless (length $new) { + warn "\tBUG: could not update link to $page\n"; + next; + } warn "\tUpdating $old => $new\n"; $$ref[1]{to} = $new; $$ref[2] = $new if @$ref == 3 and $$ref[2] eq $old; diff -ru Zim-0.19/t/41_export.t Zim-0.19-bugfix/t/41_export.t --- Zim-0.19/t/41_export.t 2007-03-20 22:18:03.000000000 +0000 +++ Zim-0.19-bugfix/t/41_export.t 2008-03-27 20:47:52.000000000 +0000 @@ -8,6 +8,7 @@ $SIG{__WARN__} = sub { print STDERR @_ unless $_[0] =~ /^#|Exporting|Indexing/; }; +$ENV{XDG_DATA_HOME} = './share/'; eval 'require Zim::Win32' if $^O eq 'MSWin32'; die $@ if $@;