Changeset 11116


Ignore:
Timestamp:
03/15/10 04:30:19 (2 years ago)
Author:
azawawi
Message:

Initial attempt at fixing Padre survey dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Wx/Dialog/WhereFrom.pm

    r11051 r11116  
    55use warnings; 
    66use Padre::Wx               (); 
    7 use Padre::Wx::Dialog       (); 
    87use Padre::Task::HTTPClient (); 
    98 
    109our $VERSION = '0.58'; 
    1110 
     11our @ISA     = qw{ 
     12    Padre::Wx::Role::MainChild 
     13    Wx::Dialog 
     14}; 
     15 
    1216sub new { 
    13     my ( $class, $window ) = @_; 
     17    my ( $class, $main ) = @_; 
    1418 
    1519    my $config = Padre->ide->config; 
    16     return if $config->feedback_done; 
     20    #return if $config->feedback_done; 
    1721 
    18     my @layout = ( 
    19         [   [ 'Wx::StaticText', undef, Wx::gettext('Where did you hear about Padre?') ], 
    20             [   'Wx::ComboBox', 
    21                 '_referer_', 
    22                 '', 
    23                 [   'Google', 
    24                     Wx::gettext('Other searchengine'), 
    25                     'FOSDEM', 
    26                     'CeBit', 
    27                     Wx::gettext('Other event'), 
    28                     Wx::gettext('Friend'), 
    29                     Wx::gettext('Reinstalling/Installing on other computer'), 
    30                     Wx::gettext('Other (Please fill in here)'), 
    31                 ] 
    32             ], 
    33         ], 
    34         [   [ 'Wx::Button', '_ok_', Wx::wxID_OK ], [], 
    35             [ 'Wx::Button', '_cancel_', Wx::gettext("Skip feedback") ], 
    36         ], 
     22    # Create the Wx dialog 
     23    my $dialog = $class->SUPER::new( 
     24        $main, 
     25        -1, 
     26        Wx::gettext('New installation survey'), 
     27        Wx::wxDefaultPosition, 
     28        Wx::wxDefaultSize, 
     29        Wx::wxDEFAULT_FRAME_STYLE, 
    3730    ); 
    3831 
    39     my $dialog = Padre::Wx::Dialog->new( 
    40         parent => $window, 
    41         title  => Wx::gettext("New installation survey"), 
    42         layout => \@layout, 
    43         width  => [ 200, 300 ], 
    44         bottom => 20, 
    45     ); 
    46     $dialog->{_widgets_}{_ok_}->SetDefault; 
    47     Wx::Event::EVT_BUTTON( $dialog, $dialog->{_widgets_}{_ok_},     \&WhereFrom_ok_clicked ); 
    48     Wx::Event::EVT_BUTTON( $dialog, $dialog->{_widgets_}{_cancel_}, \&WhereFrom_cancel_clicked ); 
     32    # Minimum dialog size 
     33    $dialog->SetMinSize( [ 200, 300 ] ); 
    4934 
    50     $dialog->{_widgets_}{_referer_}->SetFocus; 
     35    # Create sizer that will host all controls 
     36    my $sizer = Wx::BoxSizer->new(Wx::wxHORIZONTAL); 
     37 
     38    # Create the controls 
     39    $dialog->_create_controls($sizer); 
     40 
     41    # Bind the control events 
     42    $dialog->_bind_events; 
     43 
     44    # Wrap everything in a vbox to add some padding 
     45    $dialog->SetSizer($sizer); 
     46    $dialog->Fit; 
     47    $dialog->CentreOnParent; 
     48 
     49    $dialog->{combo}->SetFocus; 
    5150    $dialog->Show(1); 
    5251 
    53     return 1; 
     52    return $dialog; 
     53} 
     54 
     55sub _create_controls { 
     56    my $dialog = shift; 
     57 
     58    # "Where did you hear..." label 
     59    my $label = Wx::StaticText->new( $dialog, -1, Wx::gettext('Where did you hear about Padre?') ); 
     60 
     61    my $options = [    
     62        'Google', 
     63        Wx::gettext('Other searchengine'), 
     64        'FOSDEM', 
     65        'CeBit', 
     66        Wx::gettext('Other event'), 
     67        Wx::gettext('Friend'), 
     68        Wx::gettext('Reinstalling/Installing on other computer'), 
     69        Wx::gettext('Other (Please fill in here)'), 
     70    ]; 
     71     
     72    $dialog->{combo} = Wx::ComboBox->new( $dialog, -1, '' ); 
     73     
     74    # OK button 
     75    $dialog->{button_ok} = Wx::Button->new( 
     76        $dialog, Wx::wxID_OK, Wx::gettext("OK"), 
     77    ); 
     78    $dialog->{button_ok}->SetDefault; 
     79 
     80    # Cancel button 
     81    $dialog->{button_cancel} = Wx::Button->new( 
     82        $dialog, Wx::wxID_CANCEL,  
     83        Wx::gettext("Skip question without giving feedback"), 
     84    ); 
     85     
     86     
     87} 
     88 
     89 
     90sub _bind_events { 
     91    my $dialog = shift; 
     92    Wx::Event::EVT_BUTTON( $dialog, $dialog->{button_ok},     \&WhereFrom_ok_clicked ); 
     93    Wx::Event::EVT_BUTTON( $dialog, $dialog->{button_cancel}, \&WhereFrom_cancel_clicked ); 
    5494} 
    5595 
Note: See TracChangeset for help on using the changeset viewer.