Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement monospace property on TextView
This partially addresses #7 however a more complete solution
(allowing setting of an arbitrary font on the widget,) requires
the implementation of gtk_widget_set_font_map and all the
attendant Pango bizness.
  • Loading branch information
jonathanstowe committed May 19, 2016
1 parent d5a943d commit 0f5fd75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/07_text.p6
Expand Up @@ -8,12 +8,17 @@ 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 $monospace = GTK::Simple::CheckButton.new(label => 'Monospaced');
$monospace.status = False;

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 });
$monospace.toggled.tap( -> $w { $text-view.monospace = $w.status });

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

$app.set_content($vbox);

Expand Down
15 changes: 15 additions & 0 deletions lib/GTK/Simple.pm6
Expand Up @@ -756,6 +756,21 @@ class GTK::Simple::TextView does GTK::Simple::Widget {
is gtk-property(&gtk_text_view_get_cursor_visible, &gtk_text_view_set_cursor_visible)
{ * }


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

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

method monospace()
returns Bool
is gtk-property(&gtk_text_view_get_monospace, &gtk_text_view_set_monospace)
{ * }

}

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

0 comments on commit 0f5fd75

Please sign in to comment.