Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add editable, cursor-visible properties to TextView
Closes #8
  • Loading branch information
jonathanstowe committed May 19, 2016
1 parent 7df7b5b commit 0d097d0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/07_text.p6
@@ -0,0 +1,23 @@
#!/usr/bin/env perl6

use GTK::Simple;

my $app = GTK::Simple::App.new(title => 'Text');

my $editable = GTK::Simple::CheckButton.new(label => 'Editable');
$editable.status = True;
my $show-cursor = GTK::Simple::CheckButton.new(label => 'Show Cursor');
$show-cursor.status = True;
my $text-view = GTK::Simple::TextView.new;

$editable.toggled.tap(-> $w { $text-view.editable = $w.status });
$show-cursor.toggled.tap( -> $w { $text-view.cursor-visible = $w.status });

my $vbox = GTK::Simple::VBox.new($editable, $show-cursor, $text-view);

$app.set_content($vbox);


$app.run;

# vim: expandtab shiftwidth=4 ft=perl6
29 changes: 29 additions & 0 deletions lib/GTK/Simple.pm6
Expand Up @@ -701,6 +701,35 @@ class GTK::Simple::TextView does GTK::Simple::Widget {
$s.Supply;
}
}

sub gtk_text_view_set_editable(GtkWidget $widget, int32 $setting)
is native(&gtk-lib)
{ * }

sub gtk_text_view_get_editable(GtkWidget $widget)
is native(&gtk-lib)
returns int32
{ * }

method editable() returns Bool {
Proxy.new: FETCH => { Bool(gtk_text_view_get_editable($!gtk_widget)) },
STORE => -> $, Bool $setting { gtk_text_view_set_editable($!gtk_widget, $setting.value) };
}

sub gtk_text_view_set_cursor_visible(GtkWidget $widget, int32 $setting)
is native(&gtk-lib)
{ * }

sub gtk_text_view_get_cursor_visible(GtkWidget $widget)
is native(&gtk-lib)
returns int32
{ * }

method cursor-visible() returns Bool {
Proxy.new: FETCH => { Bool(gtk_text_view_get_cursor_visible($!gtk_widget)) },
STORE => -> $, Bool $setting { gtk_text_view_set_cursor_visible($!gtk_widget, $setting.value) };
}

}

class GTK::Simple::Button does GTK::Simple::Widget {
Expand Down

0 comments on commit 0d097d0

Please sign in to comment.