test1.pl
author Peter Gervai <grin@grin.hu>
Thu, 16 Oct 2008 15:29:50 +0200
changeset 5 89516833532f
parent 3 689bf4b363c3
permissions -rwxr-xr-x
test1: remov unused stuff, implode long unnecessary thingz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     1
#!/usr/bin/perl -w
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     2
#$Id$
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     3
#
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     4
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     5
use strict;
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     6
use warnings;
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     7
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     8
use Gtk2 '-init';
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     9
use Gtk2::GladeXML;
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    10
use Gtk2::Gdk::Keysyms; # keyboard code constants
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    11
1
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    12
use Data::Dumper;
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    13
0
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    14
my $glade;
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    15
my $label;
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    16
my $field;
3
689bf4b363c3 test1: and coloring works too
Peter Gervai <grin@grin.hu>
parents: 2
diff changeset
    17
my $eventbox;
0
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    18
my $window_about;
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    19
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    20
# load UI
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    21
$glade = Gtk2::GladeXML->new("test1.glade");
1
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    22
#$glade = Gtk2::GladeXML->new("/tmp/glade/hello-world.glade");
0
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    23
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    24
# connect signals
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    25
$glade->signal_autoconnect_from_package('main');
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    26
1
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    27
$label = $glade->get_widget('main_text1');
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    28
$field = $glade->get_widget('entry');
3
689bf4b363c3 test1: and coloring works too
Peter Gervai <grin@grin.hu>
parents: 2
diff changeset
    29
$eventbox = $glade->get_widget('eventbox1');
0
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    30
$window_about = $glade->get_widget('aboutdialog1');
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    31
1
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    32
print "firing up\n";
0
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    33
Gtk2->main;
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    34
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    35
exit 0;
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    36
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    37
1
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    38
sub on_colour_button_color_set {
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    39
    my $button = shift;
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    40
    my $color = $button->get_color();
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    41
    my $alpha = $button->get_alpha();
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    42
    print "Color is: ", $color->to_string(), "\n";
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    43
    print "Alpha is: ", $alpha, "\n";
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    44
    
3
689bf4b363c3 test1: and coloring works too
Peter Gervai <grin@grin.hu>
parents: 2
diff changeset
    45
    # Gtk2::StateType?! (man gtk2::widget)
689bf4b363c3 test1: and coloring works too
Peter Gervai <grin@grin.hu>
parents: 2
diff changeset
    46
    
689bf4b363c3 test1: and coloring works too
Peter Gervai <grin@grin.hu>
parents: 2
diff changeset
    47
    $eventbox->modify_bg( 'normal', $color);
689bf4b363c3 test1: and coloring works too
Peter Gervai <grin@grin.hu>
parents: 2
diff changeset
    48
    #$glade->get_widget('frame1')->modify_bg( 'normal', $color);
1
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    49
}
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    50
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    51
5
89516833532f test1: remov unused stuff, implode long unnecessary thingz
Peter Gervai <grin@grin.hu>
parents: 3
diff changeset
    52
sub on_main_about_button_clicked { $window_about->show(); }
89516833532f test1: remov unused stuff, implode long unnecessary thingz
Peter Gervai <grin@grin.hu>
parents: 3
diff changeset
    53
sub on_aboutdialog1_response { $window_about->hide(); }
1
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    54
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    55
sub on_entry_key_release_event {
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    56
    my $widget = shift;
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    57
    my $event = shift;
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    58
    
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    59
    if( $event->keyval == $Gtk2::Gdk::Keysyms{KP_Enter} || 
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    60
              $event->keyval == $Gtk2::Gdk::Keysyms{Return} ) {
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    61
        on_main_ok_button_clicked();
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    62
        return 1;
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    63
    }
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    64
    return 0;
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    65
}
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    66
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    67
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    68
sub on_main_ok_button_clicked {
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    69
    my $txt = $field->get_text();
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    70
    $label->set_markup( "hello <b>$txt</b>!" );
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    71
}
0
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    72
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    73
# Handles window-manager-quit: shuts down gtk2 lib
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    74
sub on_main_delete_event {Gtk2->main_quit;}
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    75
43c199fb1993 glade perl test, first import
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    76
# Handles close-button quit
1
90185416e8ff test1 kind of working version
Peter Gervai <grin@grin.hu>
parents: 0
diff changeset
    77
sub on_main_nay_button_clicked {on_main_delete_event;}