Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add LinkButton widget
- Loading branch information
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env perl6 | ||
|
|
||
| use v6; | ||
| use lib 'lib'; | ||
| use GTK::Simple::App; | ||
| use GTK::Simple::LinkButton; | ||
| use GTK::Simple::TextView; | ||
| use GTK::Simple::VBox; | ||
|
|
||
| my $app = GTK::Simple::App.new(title => 'Link Button Demo'); | ||
|
|
||
| my $link1-button = GTK::Simple::LinkButton.new(:label("Perl 6"), | ||
| :uri("http://perl6.org")); | ||
| my $link2-button = GTK::Simple::LinkButton.new(:label("Perl 6 Docs"), | ||
| :uri("http://doc.perl6.org")); | ||
| my $text-view = GTK::Simple::TextView.new; | ||
|
|
||
| $link1-button.activate-link.tap: { | ||
| $text-view.text ~= sprintf("activate-link %s triggerred, visited=%s\n", | ||
| $link1-button.uri, $link1-button.visited); | ||
| } | ||
|
|
||
| $link2-button.activate-link.tap: { | ||
| $text-view.text ~= sprintf("activate-link %s triggerred, visited=%s\n", | ||
| $link2-button.uri, $link2-button.visited); | ||
| } | ||
|
|
||
| $app.set-content( | ||
| GTK::Simple::VBox.new([ | ||
| { :widget($link1-button), :expand(False) }, | ||
| { :widget($link2-button), :expand(False) }, | ||
| $text-view, | ||
| ]) | ||
| ); | ||
|
|
||
| $app.border-width = 20; | ||
| $app.run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
|
|
||
| use v6; | ||
|
|
||
| use NativeCall; | ||
| use GTK::Simple::Raw :link-button, :DEFAULT; | ||
| use GTK::Simple::Common; | ||
| use GTK::Simple::Button; | ||
|
|
||
| unit class GTK::Simple::LinkButton is GTK::Simple::Button; | ||
|
|
||
| has $!activate-link-supply; | ||
|
|
||
| submethod BUILD(:$label!, :$uri!) { | ||
| self.WIDGET( gtk_link_button_new_with_label($uri, $label) ); | ||
| } | ||
|
|
||
| method uri() | ||
| returns Str | ||
| is gtk-property(>k_link_button_get_uri, >k_link_button_set_uri) | ||
| { * } | ||
|
|
||
| method visited() | ||
| returns Str | ||
| is gtk-property(>k_link_button_get_visited, >k_link_button_set_visited) | ||
| { * } | ||
|
|
||
| method activate-link() { | ||
| $!activate-link-supply //= do { | ||
| my $s = Supplier.new; | ||
| g_signal_connect_wd(self.WIDGET, "activate-link", | ||
| -> $, $ { | ||
| $s.emit(self); | ||
| CATCH { default { note $_; } } | ||
| }, | ||
| OpaquePointer, 0); | ||
| $s.Supply; | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters