package App::Gtk2Demo; use strict; use warnings; our $VERSION = '0.05'; use App::Gtk2Demo::GUI; sub run { my $entries = entries(); collect_widgets($entries); App::Gtk2Demo::GUI::set_entries($entries); App::Gtk2Demo::GUI::build_gui(get_widgets()); } #use Gtk2::GladeXML; # #my $gladexml; #sub run { # require App::Gtk2Demo::Glade; # $gladexml = Gtk2::GladeXML->new_from_buffer(App::Gtk2Demo::Glade::get_xml()); # $gladexml->signal_autoconnect_from_package("App::Gtk2Demo"); # Gtk2->main; #} #sub on_main_destroy { # _close_app(); #} #sub on_quit_clicked { # _close_app(); #} # #AUTOLOAD { # our $AUTOLOAD; # print $AUTOLOAD . " <-\n"; #} #sub DESTROY { #} sub check_entries { check_files(entries()); print "All the files are readable\n"; } # check if we can read all the files listed here sub check_files { my ($entries) = @_; foreach my $entry (@$entries) { open my $fh, $entry->{name} or die "Could not open $entry->{name} $!"; check_files($entry->{more}) if $entry->{more}; } } { my %widgets; sub collect_widgets { my ($entries) = @_; foreach my $entry (@$entries) { if ($entry->{type} eq "file") { analyze_file($entry->{name}, $entry->{title}); } collect_widgets($entry->{more}) if $entry->{more}; } return; } sub analyze_file { my ($file, $title) = @_; open my $fh, $file or return; while (my $line = <$fh>) { if ($line =~ /(Gtk2::\w+(:?::\w+)*)/) { $widgets{$1}{$file} = $title; } } } sub get_widgets { return \%widgets; } } sub entries { return [ { title => "Welcome", type => "text", name => "welcome.txt", }, { title => "Tutorial", type => "text", name => "tutorial/overview.txt", more => [ { title => "Simple", type => "file", name => "tutorial/simple.pl", }, { title => "Hello World", type => "file", name => "tutorial/hello_world.pl", }, { title => "Signal handlers", type => "text", name => "tutorial/signals.txt", }, { title => "Exit button", type => "file", name => "tutorial/button.pl", }, { title => "Exit button, printing to console", type => "file", name => "tutorial/button_print.pl", }, { title => "Two widgets on one window", type => "file", name => "tutorial/vbox.pl", }, { title => "Horizontal Layout", type => "file", name => "tutorial/hbox.pl", }, { title => "Data Entry and Label Change", type => "file", name => "tutorial/box_and_button.pl", }, #- Text box, just as we have in this application filled by text typed in an entry box #- Open a file #- Popup windows for confirmation (do you really want to exit ?) #- Save a file (ask for confirmation if file already exists) #- Table layout { title => "Pop-up Window for Right-click", type => "file", name => "tutorial/rightclick.pl", }, { title => "Resizable Windows", type => "file", name => "tutorial/vpaned.pl", }, { title => "Notebook", type => "file", name => "tutorial/notebook.pl", }, { title => "Keyboard", type => "file", name => "tutorial/keyboard.pl", }, { title => "Password entry", type => "file", name => "tutorial/password.pl", }, ], }, # { # title => "GTK Perl Demo (this code)", # type => "file", # name => "gtk-perl-demo.pl", # }, { title => "Examples", type => "text", name => "examples.txt", more => [ { title => "Accel groups", type => "file", name => "examples/accel_groups.pl", }, { title => "Simple list", type => "file", name => "examples/simplelist.pl", }, { title => "Simple Menu", type => "file", name => "examples/simple_menu.pl", }, { title => "Multi Sel", type => "file", name => "examples/multisel.pl", }, { title => "File chooser", type => "file", name => "examples/file_chooser.pl", }, { title => "Dialog", type => "file", name => "examples/dialog.pl", }, { title => "Plug", type => "file", name => "examples/plug.pl", }, { title => "Calendar date", type => "file", name => "examples/cellrenderer_date.pl", }, { title => "Calendar", type => "file", name => "examples/calendar.pl", }, ], }, { title => "Examples", type => "text", name => "examples.txt", more => [ { title => "Adding stock icons", type => "file", name => "examples/adding_stock_icons.pl", }, { title => "Button box", type => "file", name => "examples/buttonbox.pl", }, { title => "Cellrender popup", type => "file", name => "examples/cellrenderer_popup.pl", }, { title => "Cellrender progress", type => "file", name => "examples/cellrenderer_progress.pl", }, { title => "Cellrender spinbuttons", type => "file", name => "examples/cellrenderer_spinbutton.pl", }, { title => "Color list", type => "file", name => "examples/color_list.pl", }, { title => "Color snooper", type => "file", name => "examples/color_snooper.pl", }, { title => "Combo box", type => "file", name => "examples/combo_box.pl", }, { title => "Custom list", type => "file", name => "examples/customlist.pl", }, { title => "Custome renerer", type => "file", name => "examples/customrenderer.pl", }, ], }, { title => "Examples", type => "text", name => "examples.txt", more => [ { title => "Fileselect Multiselect", type => "file", name => "examples/filesel_multisel.pl", }, { title => "Histogramplot", type => "file", name => "examples/histogramplot.pl", }, { title => "Inline images", type => "file", name => "examples/inline-images.pl", }, { title => "Insert text", type => "file", name => "examples/insert-text-test.pl", }, { title => "Item Factory", type => "file", name => "examples/item_factory_demo.pl", }, { title => "Layout", type => "file", name => "examples/layout.pl", }, { title => "Rulers", type => "file", name => "examples/rulers.pl", }, { title => "Scribble", type => "file", name => "examples/scribble.pl", }, { title => "Socket", type => "file", name => "examples/socket.pl", }, { title => "Test DND", type => "file", name => "examples/testdnd.pl", }, { title => "Thread usage", type => "file", name => "examples/thread_usage.pl", }, { title => "Timeout test", type => "file", name => "examples/timeouttest.pl", }, { title => "Image map", type => "file", name => "examples/imagemap.pl", }, { title => "Source View", type => "file", name => "examples/source_view.pl", }, ], }, { title => "Cookbook", type => "text", name => "cookbook.txt", more => [ { title => "Buttons", type => "file", name => "cookbook/buttons.txt", more => [ { title => "Image Custom Stock ID", type => "file", name => "cookbook/buttons/button-image-custom-stock_id", }, { title => "button-manually-add-image", type => "file", name => "cookbook/buttons/button-manually-add-image", }, { title => "check-buttons", type => "file", name => "cookbook/buttons/check-buttons", }, { title => "image-button", type => "file", name => "cookbook/buttons/image-button", }, { title => "packing-example-simple2-seperator", type => "file", name => "cookbook/buttons/packing-example-simple2-seperator", }, { title => "packing-using-tables1", type => "file", name => "cookbook/buttons/packing-using-tables1", }, { title => "radio-buttons", type => "file", name => "cookbook/buttons/radio-buttons", }, { title => "radio-buttons1", type => "file", name => "cookbook/buttons/radio-buttons1", }, { title => "toggle-button", type => "file", name => "cookbook/buttons/toggle-button", }, { title => "toggle-button1", type => "file", name => "cookbook/buttons/toggle-button1", }, ], }, { title => "Color", type => "file", name => "cookbook.txt", more => [ { title => "button-color1", type => "file", name => "cookbook/color/button-color1", }, { title => "button-color-w-label", type => "file", name => "cookbook/color/button-color-w-label", }, { title => "color_list", type => "file", name => "cookbook/color/color_list", }, { title => "color-selecter-button", type => "file", name => "cookbook/color/color-selecter-button", }, { title => "color_snooper", type => "file", name => "cookbook/color/color_snooper", }, { title => "window-bg-color", type => "file", name => "cookbook/color/window-bg-color", }, ], }, ], }, { title => "About", type => "text", name => "about.txt", }, ]; } 1;