Gtk3 custom theme parsing
- From: zentara <zzmiloschxx gmail com>
- To: gtk-perl-list gnome org
- Subject: Gtk3 custom theme parsing
- Date: Thu, 2 Aug 2012 09:56:05 -0400
Hi,
I'm trying to convert a few Gtk2 scripts to Gtk3.
I found a simple theme that works with the default internal
theme engine, it's called Albatross.
I'm on a non-Gnome desktop.
Anyways, Gtk2 had a parse_string method which worked,
but on Gtk3 it's hard to find.
The lack of Perl docs says "No documentation found for "Gtk::CssProvider".
So would anyone know how to do this? The c docs say to now
use GtkCssProvider instead of parse_string, but I'm clueless
as how to get it to work.
Thanks,
zentara
#!/usr/bin/perl
use warnings;
use strict;
use Glib qw/TRUE FALSE/;
use Gtk3 '-init';
#not found
#use Gtk3::CssProvider;
# this worked for Gtk2
=head1
Gtk2::Rc->parse_string(<<__);
style "my_text" {
font_name ="sans 24"
text[NORMAL] = "#FFAA00"
base[NORMAL] = "#000000"
GtkTextView::cursor-color = "red"
}
style "my_cursor"{
fg[NORMAL] = "#FF0000"
}
widget "*Text*" style "my_text"
__
=cut
# what is the right method here?
#gtk_css_provider_load_from_data
Gtk::CssProvider->provider_load_from_data(<<__);
style "my_text" {
font_name ="sans 24"
text[NORMAL] = "#FFAA00"
base[NORMAL] = "#000000"
GtkTextView::cursor-color = "red"
}
style "my_cursor"{
fg[NORMAL] = "#FF0000"
}
widget "*Text*" style "my_text"
__
my $window = Gtk3::Window->new('toplevel');
$window->set_title('Z');
$window ->signal_connect( 'destroy' => \&delete_event );
$window->set_border_width(10);
$window->set_size_request(400,400);
my $vbox = Gtk3::VBox->new( FALSE, 6 );
$window->add($vbox);
$vbox->set_border_width(2);
my $hbox= Gtk3::HBox->new( FALSE, 6 );
$vbox->pack_end($hbox,FALSE,FALSE,0);
my $ebutton = Gtk3::Button->new_from_stock('gtk-quit');
$hbox->pack_end( $ebutton, FALSE, FALSE, 0 );
$ebutton->signal_connect( clicked => \&delete_event );
# Create a textbuffer to contain that string
my $textbuffer = Gtk3::TextBuffer->new();
$textbuffer->set_text('yadda yadda yadda', 17); # needs length
# Create a textview using that textbuffer
my $textview = Gtk3::TextView->new_with_buffer($textbuffer);
# Add the textview to a scrolledwindow
my $scrolledwindow = Gtk3::ScrolledWindow->new( undef, undef );
$scrolledwindow->add($textview);
$vbox->pack_start($scrolledwindow, 1, 1, 0 );
$window->show_all();
#get all text
#my $iter = $textbuffer->get_iter_at_offset(0);
# my $iter1 = $buffer->get_end_iter;
#my $iter1 = $textbuffer->get_iter_at_offset(20);
my $num =
$textbuffer->get_text($textbuffer->get_start_iter, $textbuffer->get_end_iter, 1);
print "$num\n";
Gtk3->main;
#####################################
sub delete_event {
Gtk3->main_quit;
return FALSE;
}
#######################################
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]