Aw: Re: Writing a class from type Gtk3::SourceView::CompletionProvider



Dear Jeremy,
You are great!!!! Thanks a lot for your help. With the following code I got the custom Completion Provider:
package Provider;
use Glib ("TRUE","FALSE");
use Gtk3::SourceView;
use Glib::Object::Subclass
    'Glib::Object',
    interfaces => [ 'Gtk3::SourceView::CompletionProvider' ];
sub GET_NAME {
    return 'Custom'
}
sub GET_ICON {
}
sub POPULATE {
    my ($self, $context) = @_;
    my $proposal = Gtk3::SourceView::CompletionItem->new('Hello','Hello');
    my @proposals = ($proposal);
    $context->add_proposals($self, \@proposals, TRUE);
}
sub MATCH {
    return TRUE;
}
sub GET_ACTIVATION {
    return 'interactive';
}
sub GET_INFO_WIDGET {
    
}
sub GET_START_ITER {
    return FALSE;
}
sub ACTIVATE_PROPOSAL {
    return FALSE;
}
sub GET_INTERACTIVE_DELAY {
    return '-1';
}
sub GET_PRIORITY {
    return 0;
}
In the main program, one just has to add the custom Completion function with the following lines:
my $completion = $textview->get_completion();
my $custom_provider = Provider->new();
$completion->add_provider($custom_provider);
 
I am very happy! I have not any more guessed, that I can solve this problem! Thank you very very much!
 
I will also implement your improvement suggestions for the Module. Yes, adding to CPAN will be the next adventure. But I have a very good instruction in the german perl-community, so that I hope to getting it. But with regard to your hints it will probably take some times more...
Best wishes, 
Max
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]