#!/usr/bin/perl -sw

use strict;
use Gtk;

BEGIN:
set_locale Gtk;
init Gtk;

my %langs;
$langs{'en_EN'} = {
	menu	=> [
		{ path		=> '/_File',
		  type		=> '<Branch>' },
		{ path		=> '/File/_Quit',
		  callback	=> \&CloseProgram },
		{ path		=> '/_Help',
		  type		=> '<Branch>' },
		{ path		=> '/Help/_About',
		  callback	=> \&MenuAbout }
	],
	sections		=> ['Search','Install','Configuration'],

	about_title		=> 'About Mi',
	about_sections		=> ['About','Authors','Thanks','License'],
	about_description	=> 'Graphical user interface for the poldek package manager.',
	about_authors		=> "Micha Chruszcz\n   michal\@chruszcz.one.pl\n   Author",
	about_thanks		=> "Micha Cielicki\n   yoshi\@aip.pl\n   Many fresh ideas, encourage, betatesting.
\ndepesz\n   depesz\@depesz.pl\n   Really huge help with perl.
\nLeszek Krupiski\n   leszek\@php.net\n   Betatesting, some new ideas.",
	about_license		=> 'This programs is distributed under the GPL v2 terms.',
	
	search_entry_frame	=> 'Search',
	search_label_name	=> 'Package name:',
	search_check_label	=> 'Search in:',
	search_check_conflicts	=> 'Conflicts',
	search_check_description => 'Description',
	search_check_files	=> 'Files',
	search_check_groups	=> 'Groups',
	search_check_obsolences	=> 'Obsolences',
	search_check_capabilities => 'Capabilities',
	search_check_requirements => 'Requirements',
	search_check_summary	=> 'Summary',
	search_check_perlre	=> 'Perl regular expression',
	search_submit		=> 'Submit search',
	search_result_list	=> ['Package name'],
	search_result_submit	=> 'Install selected',
	search_menu_description => 'Show description',
	search_menu_files	=> 'Show files',

	install_entry_frame	=> 'Install',
	install_label_name	=> 'Package name:',
	install_label_type	=> 'Installation type:',
	install_label_options	=> 'Options:',
	install_downgrade	=> 'Downgrade',
	install_fetch		=> 'Fetch',
	install_force		=> 'Force',
	install_fresh		=> 'Freshen',
	install_greedy		=> 'Greedy',
	install_install		=> 'Install',
	install_mercy		=> 'Mercy',
	install_nodeps		=> 'No dependecies',
	install_nofollow	=> 'No follow',
	install_reinstall	=> 'Reinstall',
	install_test		=> 'Test',
	install_uninstall	=> 'Uninstall',
	install_upgrade		=> 'Upgrade',
	install_submit		=> 'Submit install',

	conf_frame		=> 'Configuration',
	conf_lang_label		=> 'Program language:',
	conf_lang_select	=> 'Available languages',
	conf_srcname_label	=> 'Default packages source name:',
	conf_submit		=> 'Save settings',
	
	output_text_frame	=> 'Raw output',

	error_title		=> 'Error!',
	error_empty		=> 'Nothing is selected.',
	error_no_packages	=> 'No package matches.',
	error_unknown		=> 'Unknown error: ',

	info_title		=> 'Information',
	info_success		=> 'Operation successful',
	info_equal		=> 'Equal version installed, skipped',
	info_matches		=> ' package(s) matches',
};

my $LANG;
my $LANG_NAME;
my @CONFIG;
my $TMP;
my $HOME = $ENV{HOME};
my $LIBDIR = '/usr/share/mis';
my $LOCALE = $ENV{LANG};

if(!-d $HOME."/.mis"){
	mkdir($HOME."/.mis", 0755) or die("Cannot create program's home directory\n");;
}
if(!-e $HOME."/.mis/config"){
	open(TMP, ">$HOME/.mis/config") or die("Cannot create program's config file\n");
	print TMP "";
	close TMP;
}
open(CONFIG, "$HOME/.mis/config") or die("Cannot open config file: $!\n");
@CONFIG = <CONFIG>;
close CONFIG;
grep(!/^#/,@CONFIG);
my @language = grep(/^language\s=\s\w{5}$/, @CONFIG);
if(-e $LIBDIR.'/'.$LOCALE.'.lang' and @language == 0){
	open(TMP, "$LIBDIR/$LOCALE.lang") or die("Cannot open language file: $!\n");
	my @TMP = <TMP>;
	close TMP;
	my $language = join('',@TMP);
	eval $language; die("Language file has incorrect format\n") if $@;
	$LANG = $langs{$LOCALE};
	$LANG_NAME = $LOCALE;
}elsif(@language == 1){
	$language[0] =~ s/^language\s=\s//g;
	chop($language[0]);
	$LANG_NAME = $language[0];
	if($language[0] eq 'en_EN'){
		$LANG = $langs{'en_EN'};
	}elsif(-e "$LIBDIR/$language[0].lang"){
		open(TMP, "$LIBDIR/$language[0].lang") or die("Cannot open language file: $!\n");
		my @TMP = <TMP>;
		close TMP;
		my $language = join('',@TMP);
		eval $language; die("Language file has incorrect format\n") if $@;
		$LANG = $langs{$language[0]};
	}else{
		die("Language file does not exist\n");
	}
}else{
	$LANG = $langs{'en_EN'};
	$LANG_NAME = 'en_EN';
}
undef @language;
my @logo = ('64 56 123 2',
'  	c None',
'. 	c #1B2836',
'+ 	c #363636',
'@ 	c #5E5151',
'# 	c #6B5E5E',
'$ 	c #1B1B28',
'% 	c #283643',
'& 	c #0D1B28',
'* 	c #515151',
'= 	c #868686',
'- 	c #A1A1A1',
'; 	c #5E5E5E',
'> 	c #867979',
', 	c #6B6B6B',
'\' 	c #949494',
') 	c #BCBCBC',
'! 	c #948686',
'~ 	c #433643',
'{ 	c #434343',
'] 	c #797979',
'^ 	c #D7D7D7',
'/ 	c #C9C9BC',
'( 	c #282828',
'_ 	c #363651',
': 	c #363643',
'< 	c #C9C9C9',
'[ 	c #A19494',
'} 	c #0D0D28',
'| 	c #0D0D1B',
'1 	c #5E5E51',
'2 	c #AEA1A1',
'3 	c #E4E4E4',
'4 	c #0D1B1B',
'5 	c #C9BCBC',
'6 	c #0D0D0D',
'7 	c #1B2828',
'8 	c #79796B',
'9 	c #281B28',
'0 	c #36281B',
'a 	c #283628',
'b 	c #F2F2F2',
'c 	c #AEAEAE',
'd 	c #434351',
'e 	c #9494A1',
'f 	c #AEAEA1',
'g 	c #514343',
'h 	c #5E5E6B',
'i 	c #51515E',
'j 	c #5E515E',
'k 	c #796B6B',
'l 	c #6B6B5E',
'm 	c #434336',
'n 	c #868694',
'o 	c #94A1A1',
'p 	c #435151',
'q 	c #6B6B79',
'r 	c #D7C9D7',
's 	c #D7D7C9',
't 	c #797986',
'u 	c #5E6B6B',
'v 	c #363628',
'w 	c #FFFFFF',
'x 	c #6B7979',
'y 	c #283636',
'z 	c #1B1B1B',
'A 	c #F2F2E4',
'B 	c #362828',
'C 	c #798686',
'D 	c #515E5E',
'E 	c #868679',
'F 	c #A1A194',
'G 	c #949486',
'H 	c #BCBCAE',
'I 	c #5E5143',
'J 	c #281B1B',
'K 	c #364343',
'L 	c #433636',
'M 	c #A1A1AE',
'N 	c #C9C9D7',
'O 	c #C9D7D7',
'P 	c #1B1B0D',
'Q 	c #280D0D',
'R 	c #000000',
'S 	c #28281B',
'T 	c #D7C9C9',
'U 	c #515143',
'V 	c #282836',
'W 	c #AEBCBC',
'X 	c #1B0D0D',
'Y 	c #D7D7E4',
'Z 	c #BCAEAE',
'` 	c #1B1B36',
' .	c #D7E4E4',
'..	c #A1AEAE',
'+.	c #6B5E6B',
'@.	c #F2E4E4',
'#.	c #798694',
'$.	c #6B796B',
'%.	c #86796B',
'&.	c #796B79',
'*.	c #E4D7D7',
'=.	c #BCC9C9',
'-.	c #A194A1',
';.	c #AEAEBC',
'>.	c #514351',
',.	c #BCBCC9',
'\'.	c #1B0D1B',
').	c #361B0D',
'!.	c #281B0D',
'~.	c #E4E4D7',
'{.	c #8694A1',
'].	c #C9BCC9',
'^.	c #F2E4F2',
'/.	c #515E51',
'(.	c #948679',
'_.	c #362836',
':.	c #AEA1AE',
'<.	c #869494',
'[.	c #5E6B79',
'}.	c #8686A1',
'|.	c #515E6B',
'1.	c #5E5E79',
'2.	c #43361B',
'                                                                                      .                                         ',
'                                                                                  + @ # $ %                                     ',
'                                                                              & * = - - ; ; > * $                               ',
'                                                                            + , \' - - - \' , - ) ! ~ $                           ',
'                                                                        $ { \' - - - - - - = ] ) ^ / , (                         ',
'                        _ :                                             + ! - - - - - - - - , = ^ ^ < ,                         ',
'                    + , [ - > :                       } + + $         | ; - - - - - - - - - \' * < ^ ^ ) +                       ',
'                ( 1 2 < ^ 3 ^ ) +                   4 ; 5 5 2 ; |     6 ] - - - - - - - - - - ] ] ^ ^ ^ \' +                     ',
'              7 8 < < < < < ^ 3 ) (         9 0 a   ( { 3 3 3 b 1       ] - - - - - - - - - - - * c ^ ^ < \'                     ',
'              * 5 < ) ) ) ) < ^ ^ ;                 d = e - < 3 f $     g \' - - - - - - - - - - , ] < ^ ^ c ;                   ',
'            + - < ) e h * i \' < ^ ]         } { = j ( * k l = ^ < {     + , - - - - - - - - - - , m , n < < ,                   ',
'            1 ) < o p , = q d c r =     $ ( { < b < * - s c , < ^ h       * \' - - - - - - - - ] * c 2 # h < ]                   ',
'            t < ) u - ) < ) ; q < , v k / = c w < t = c ] x ] c ^ ;         ] - - - - - - \' ; * < ^ ^ ^ k ; t y                 ',
'            \' < - ; c ) < = z l < = f A ^ ] < w 5 \' - \' ^ ^ - q ] B         { = - - - - C D l ) ^ ^ ^ ^ < = : 7                 ',
'            \' ^ c E 2 c = ; 7 F ^ ^ 3 b < x 3 w w b ) \' w w - + B             { - - e , * G / ^ ^ ^ ^ ^ < e +                   ',
'            ] ) ) H c c 8 I E < 3 b b b < ] b w w w c - w w ] (               J K h d # ) < ^ ^ ^ ^ ^ ^ t L                     ',
'            K = M c c c < < 3 3 b b b N c ] < 3 3 O h c N n ( 4 | } }           0 P ; ) ^ ^ ^ ^ ^ < c j Q                       ',
'              L i q = - < ^ 3 b b b b = * * h q , ; { i $ R R R R R 6               S j c ^ ^ ^ < n g B                         ',
'                ( * k - < ^ 3 w w w w b T / < / / T / c z R R R R R 6                   U ] C t ; +                             ',
'              $ k \' - c \' n 3 w w b b w w w w w w w w w ] 6 R R R R 6                     B v v                                 ',
'            $ l \' - - c = * ^ b b b b b b b w w w w w w < v R R R R 6                                 % V y % y                 ',
'          ( ; \' \' - c ) \' z , W 3 b b b 3 3 b b b b b b 3 > 6 R R X (                             ~ j E - 2 [ ! ; i ~ V         ',
'          K = \' \' - c < c 6 6 V h M Y 3 3 3 3 3 3 3 3 b b < { R 6 # ,                         ( , - / ^ ^ ^ ^ ^ < Z F G , { `   ',
'        ( ; \' \' - c ) ^ < + R R R z u N 3 3 3 ^ ^ ^ 3 3 3 b ) { * < ,                     & $ , ) ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ < \' + | ',
'        V = \' \' c ) ^ b b ] L + R R 6 ;  .^ ^ ^ ^ ^ ^ 3 3 3 b o \' < ;                     @ > ; { D = c ) < ^ ^ ^ ^ ^ < \' D k ( ',
'        1 \' \' - c < 3 w w Z , \' ( R { L ..^ ^ ^ ^ < < 3 3 3 3 ; c e {                   V = - - - \' , j +.t n c < < M k ] c < + ',
'      ( = \' \' - ) ^ 3 w w @.] , , R ] - i \' < ^ ) ] q C o c - + = {                     + \' - - - - - - = k ; +.; h l \' T ^ < + ',
'      * \' \' - c < 3 b w w w ^ k ( R V #.\' * { i : , = > $.l { J z &                     * - - - - - - - - - - \' E 1 F < ^ ^ < ~ ',
'    ( > \' \' - c ] N w w w w w w 5 %.* L ; 3 f L ] - - - - - - - \' k ( z                 &.- - - - - - - - - - - - , - ^ ^ ^ T ~ ',
'    * = \' \' = M ] t ^ b w w w w w w w *.+ ) t ] - - - - - - - - - = { * 7             | = - - - - - - - - - - - - , \' ^ ^ ^ < + ',
'    , \' \' \' ] h ) = , < b w w w w w w b , ; ] \' i * t - - - - - \' * ] - ; $           | \' - - - - - - - - - - - - , \' ^ ^ ^ ) + ',
'  + ] \' \' - - k h =.G * =.b w w w w w b * ] - * > ! d \' - - - - ; , - - \' g         4 6 -.- - - - - - - - - - - - , - ^ ^ ^ = ( ',
'  * = \' \' \' - c > ; c Z { n 3 w w w b q ] - t 1 b w F ] - - - , * - - - - ] V     y = * q - - - - - - - - - - - - ] c ^ < - {   ',
'  i \' \' = \' - c ) = ; - ) , , ;.b w ) 1 - - h ] w w c ] - - ] { \' - - - - \' {     ; < ) >., = \' - - - - - - - - \' , ) ^ - {     ',
'  , \' = = \' - c c ) [ ; e O - , t < ] ] - - ; ] w w - ] - \' d ] - - - - - - ;     , 3 3 2 { + g * u #.- - - - - = , ) n L       ',
'+ ] \' = = \' - - c c ) c , x ^ ^ > ~ z u - - , \' w w = = - h @ - - - - - - e {     , ^ 3 ) +       B ( d C - - - h ; h B         ',
'y = \' = = = \' - - c c ) < = , ,.b T ! * { h { c w < ; \' ] * [ - \' - - - - , $     ;  .3 h X   7 V ( B z \'.V d d X P J           ',
'+ \' \' = = = \' - - - c ) ^ ^ - , M Y 3 *.c = = 3 w c * ] : ] n , * h e - \' * z $ V = b ^ z J g 1 ; , \' ] J     ).!.              ',
'+ \' \' = = = \' \' \' - c ) < ^ ^ c h t ,.3 3 b b b w ~.] + J { { , F * ] - ] ; * # \' T b 3 G ! t D , , ; ) z                       ',
'+ \' \' = = = \' \' \' \' - c < ^ 3 3 < \' i C 3 3 b b b w 3 < H H < @.b ] # -.{ 2 = - b b b ^ {.i ~ ] ].3 ] D z                       ',
'+ ] \' \' = = \' \' \' \' \' - ) ^ 3 3 3 3 < * < 3 3 3 b 3 ^ ^ b b b b < h +.* ! 3 = - ^.Y 3 < ; { B + d =.- B                         ',
'( ; \' \' = = = \' \' \' \' - ) < ^ 3 b 3 3 \' C ^ ^ ^ ^ < ] +.e ,.N W D + { 8 ^ Y q - r ] ] +./.k f < 8 q ] (                         ',
'  { n \' \' = = \' \' \' \' - c ) < ^ 3 3 3 < * ;.^ < ] ) H - k @ d + 6 + ] < ^ =.i M ^ - E (.H ^ 3 3 = _.L                           ',
'  ( , \' \' = = \' \' \' \' \' - c ) < ^ ^ ^ 3 E D W < k * e =.:.j ( G [ c < ^ ^ - ( : M ^ ^ ^ 3 3 3 N { !.                            ',
'    m = \' \' \' \' \' \' \' \' \' c c ) ) < ^ ^ ^ = >.x #.* z ( + , ) ^ ^ ^ ^ ^ ) i     \'.: q <.{.#.[.V ).                              ',
'    S D \' \' \' \' = = \' \' \' - c c ) < < ^ ^ ^ f > 1 1 ] Z ^ 3 3 ^ ^ ^ ^ < x $         ).!.z P S                                   ',
'      S ] \' \' \' , i = - - - - c ) < < < ^ 3 3 3 ^ ^ ~.3 3 3 3 ^ ^ ^ < t (                                                       ',
'        { \' = = = ; { t - - - - e W < < 3 3 3 ;.}.) 3 b b 3 3 3 ^ < C 7 \'.                                                      ',
'        ( = \' = = \' > { i i ~ + B : q , |.[.d L @ >.- b b b 3 ^ ..; + G (                                                       ',
'        + \' \' = = = \' \' * { ! f 2 ] ( * > * { f < - h c =.,.- , >.U * c l |                                                     ',
'        + = \' = = = = = i ] - - c c ] i ) - * = ) ) i : * * + d 2 - ; - E 6                                                     ',
'        ( ; \' \' = = = = ] = \' - c c c d ) c ; u c ) ; , 2 2 , , < \' ; - ] 6                                                     ',
'          B , n \' = = = = = \' \' c c o { ) c , , c c ; ] < ) , , ..* ] - y                                                       ',
'            ( d u q x = = = \' \' c c ; j ) \' { ] o , + \' ) = + # p ( ; K P                                                       ',
'                v + + { p ; q 1.q * z d ; L z { { S S >.* B z B J J J                                                           ',
'                        v 0 B B B     2.                                                                                        ');


# defining some scalars
my ($i, $body_vbox, $buffer, $label, $output, $search_value);
my $conf_value = '';
my $version = '0.0.1-alpha';
my $LOGFILE = 'lastlog';
open (LOG, ">$HOME/.mis/$LOGFILE") or warn("Cannot open logfile $!\n") if $!;

# window settings
my $window = new Gtk::Window('toplevel');
my $window_width = 630;
my $window_height = 520;
$window->set_default_size($window_width, $window_height);
$window->border_width(0);
$window->set_title('Mi');
$window->signal_connect('delete_event',\&CloseProgram);
my $output_text = new Gtk::Text(undef, undef);
my $fixed_font = Gtk::Gdk::Font->load('-misc-fixed-medium-r-normal-*-*-100-*-*-c-*-iso8859-2');

my $main_table = new Gtk::Table(4, 1, 0);
$main_table->show();

# menu
my $accel_group = new Gtk::AccelGroup();
my $item_factory = new Gtk::ItemFactory('Gtk::MenuBar', '<main>', $accel_group);
$item_factory->create_items(@{$LANG->{menu}});
$window->add_accel_group($accel_group);
my $menubar = $item_factory->get_widget('<main>');
$main_table->attach($menubar, 0, 1, 0, 1, ['fill', 'shrink'], ['fill', 'shrink'], 1, 1);
$menubar->show();

# notebook
my $notebook = new Gtk::Notebook();
$notebook->set_tab_pos('top');
$notebook->set_tab_border(4);
$notebook->set_homogeneous_tabs(1);
$notebook->show();
$main_table->attach($notebook, 0, 1, 1, 2, ['fill', 'expand'], ['fill', 'expand'], 1, 0);

my $install_entry = new Gtk::Entry(500);

# window body depending on section
for ($i = 0; $i < 3; $i++){
	$body_vbox = new Gtk::VBox(0,5);

	# specific parts of window default for each section
	# 0 - search, 1 - install, 2 - configuration
	if($i == 0){
		# Entry field
		my $search_entry = new Gtk::Entry(500);
		$search_entry->show();
		my $search_label_name = new Gtk::Label($LANG->{search_label_name});
		$search_label_name->show();
		my $search_entry_hbox = new Gtk::HBox(0, 5);
		$search_entry_hbox->pack_start($search_label_name, 0, 0, 5);
		$search_entry_hbox->pack_start($search_entry, 1, 1, 10);
		$search_entry_hbox->show();
		
		# Search flags
		my $search_check_label = new Gtk::Label($LANG->{search_check_label});
		$search_check_label->show();
		my $search_check_conflicts = new Gtk::CheckButton($LANG->{search_check_conflicts});
		$search_check_conflicts->show();
		my $search_check_description = new Gtk::CheckButton($LANG->{search_check_description});
		$search_check_description->set_active(1);
		$search_check_description->show();
		my $search_check_files = new Gtk::CheckButton($LANG->{search_check_files});
		$search_check_files->show();
		my $search_check_groups = new Gtk::CheckButton($LANG->{search_check_groups});
		$search_check_groups->show();
		my $search_check_obsolences = new Gtk::CheckButton($LANG->{search_check_obsolences});
		$search_check_obsolences->show();
		my $search_check_capabilities = new Gtk::CheckButton($LANG->{search_check_capabilities});
		$search_check_capabilities->show();
		my $search_check_requirements = new Gtk::CheckButton($LANG->{search_check_requirements});
		$search_check_requirements->show();
		my $search_check_summary = new Gtk::CheckButton($LANG->{search_check_summary});
		$search_check_summary->set_active(1);
		$search_check_summary->show();
		my $search_check_perlre = new Gtk::CheckButton($LANG->{search_check_perlre});
		$search_check_perlre->show();

		my $search_submit = new Gtk::Button($LANG->{search_submit});
		$search_submit->can_default(1);
		$search_submit->grab_default();
		$search_submit->show();
		
		my $search_table = new Gtk::Table(4, 6, 0);
		$search_table->show();
		$search_table->attach($search_entry_hbox, 0, 5, 0, 1, 'fill', 'fill', 5, 5);
		$search_table->attach_defaults($search_check_label, 0, 1, 2, 3);
		$search_table->attach_defaults($search_check_perlre, 3, 5, 1, 2);
		$search_table->attach_defaults($search_check_conflicts, 1, 2, 2, 3);
		$search_table->attach_defaults($search_check_description, 2, 3, 2, 3);
		$search_table->attach_defaults($search_check_files, 3, 4, 2, 3);
		$search_table->attach_defaults($search_check_groups, 4, 5, 2, 3);
		$search_table->attach_defaults($search_check_obsolences, 1, 2, 3, 4);
		$search_table->attach_defaults($search_check_capabilities, 2, 3, 3, 4);
		$search_table->attach_defaults($search_check_requirements, 3, 4, 3, 4);
		$search_table->attach_defaults($search_check_summary, 4, 5, 3, 4);
		$search_table->attach($search_submit, 3, 4, 4, 5, 'fill', 'fill', 0, 15);

		my $search_entry_frame = new Gtk::Frame($LANG->{search_entry_frame});
		$search_entry_frame->add($search_table);
		$search_entry_frame->show();
		$body_vbox->pack_start($search_entry_frame, 0, 1, 0);
		my $search_result_window = new Gtk::ScrolledWindow(undef, undef);
		$search_result_window->set_policy('automatic', 'always');
		$search_result_window->show();
		my $search_result_list = new_with_titles Gtk::CList(@{$LANG->{search_result_list}});
		$search_result_list->set_selection_mode('multiple');
		$search_result_list->set_shadow_type('etched_in');
		$search_result_list->column_titles_passive();
		$search_result_window->add($search_result_list);
		$search_result_list->show();
		$search_result_window->show();
		$body_vbox->pack_start($search_result_window, 1, 1, 0);
		my $search_result_submit = new Gtk::Button($LANG->{search_result_submit});
		$search_result_submit->show();
		$body_vbox->pack_start($search_result_submit, 0, 1, 3);
		
		my $search_menu = new Gtk::Menu();
		my $search_menu_description = new Gtk::MenuItem($LANG->{search_menu_description});
		$search_menu_description->show();
		$search_menu_description->signal_connect('activate',\&SearchResultDescription, $search_result_list);
		$search_menu->append($search_menu_description);
		my $search_menu_files = new Gtk::MenuItem($LANG->{search_menu_files});
		$search_menu_files->show();
		$search_menu_files->signal_connect('activate',\&SearchResultFiles, $search_result_list);
		$search_menu->append($search_menu_files);
		my $search_menu_install = new Gtk::MenuItem($LANG->{search_result_submit});
		$search_menu_install->show();
		$search_menu_install->signal_connect('activate',\&InstallSearchResults, $search_result_list);
		$search_menu->append($search_menu_install);
		
		# search's signals
		$search_submit->signal_connect('clicked',\&SubmitSearch, $search_entry);
		$search_result_list->signal_connect('select_row', \&SearchResultSelected);
		$search_result_list->signal_connect('unselect_row', \&SearchResultUnselected);
		$search_result_list->signal_connect('event', \&ShowSearchMenu, $search_menu);
		$search_result_submit->signal_connect('clicked', \&InstallSearchResults, $search_result_list);
		
		sub SubmitSearch
		{
			$search_value = '';
			$search_result_list->clear();
			my (undef, $search_pkgname) = @_;
			$search_pkgname = $search_pkgname->get_text();
			my $query = 'poldek';
			if(scalar(@CONFIG) != 0){
				my @srcname = grep(/^source_name\s+=\s+[\w\.-]+$/, @CONFIG);
				if(@srcname > 0){
					$srcname[0] =~ s/^source_name\s+=\s+//g;
					chop($srcname[0]);
					my @sources = split(/ /, $srcname[0]);
					foreach my $source(@sources){
						$query .= " --sn=$source";
					}
				}
			}
			$query .= ' --shcmd=\'search';
			if($search_check_conflicts->active){ $query .= ' --conflicts'; }
			if($search_check_description->active){ $query .= ' --description'; }
			if($search_check_files->active){ $query .= ' --files'; }
			if($search_check_groups->active){ $query .= ' --group'; }
			if($search_check_obsolences->active){ $query .= ' --obsoletes'; }
			if($search_check_capabilities->active){ $query .= ' --provides'; }
			if($search_check_requirements->active){ $query .= ' --requires'; }
			if($search_check_summary->active){ $query .= ' --summary'; }
			if($search_check_perlre->active){
				$query .= ' --perlre';
				$query .= " /$search_pkgname/'";
			}else{
				$query .= " $search_pkgname'";
			}
			if(!$search_check_conflicts == 1 || !$search_check_description == 1 || !$search_check_files == 1 || !$search_check_groups == 1 || !$search_check_obsolences == 1 || !$search_check_capabilities == 1 || !$search_check_requirements == 1 || !$search_check_summary == 1 || $search_pkgname eq ''){
				ErrorWindow($LANG->{error_empty});
			}else{
				#Przeszukiwanie pakietw..........................................zrobione.
				my $results;
				open(TMP, "$query 2>&1 |");
				while($output = <TMP>){
					$output_text->insert($fixed_font, undef, undef, $output);
					print LOG $output;
					chop($output);
					if($output =~ /^Przeszukiwanie pakietw.+zrobione\.$/){
						$results = 1;
					}else{
						if($output =~ /^No package matches/){
							ErrorWindow($LANG->{error_no_packages});
							last;
						}
						if($output =~ /^\d+ package\(s\) found.$/){
							$output =~ s/^(\d+).*/$1/;
							my $number_results = $output;
							InfoWindow($number_results.$LANG->{info_matches});
						}elsif($results){
							$output = [$output];
							$search_result_list->append(@{$output});
						}
					}
				}
				close TMP;
			}
			return;
		}
		sub ShowSearchMenu
		{
			my($clist , $menu, $event) = @_;
			if(defined($event->{'type'}) and ($event->{'type'} eq 'button_press') and ($event->{'button'} eq '3')){
				my @selection = $clist->selection;
				if(@selection > 0){
					$menu->popup(undef, undef, $event->{'time'}, $event->{'button'}, undef);
					return 1;
				}
			}
			return 0;
		}
		sub SearchResultDescription
		{
			my ($menu, $clist) = @_;
			my @search_list_show = $clist->selection;
			my $index = @search_list_show;
			if($index > 0){
				$index -= 1;
				my $pkgname = $clist->get_text($search_list_show[$index], 0);
				my $query = "poldek";
				if(scalar(@CONFIG) != 0){
					my @srcname = grep(/^source_name\s+=\s+[\w\.-]+$/, @CONFIG);
					if(@srcname > 0){
						$srcname[0] =~ s/^source_name\s+=\s+//g;
						chop($srcname[0]);
						my @sources = split(/ /, $srcname[0]);
						foreach my $source(@sources){
							$query .= " --sn=$source";
						}
					}
				}
				$query .= " --shcmd='desc $pkgname'";
				$output = `$query`;
				my @output = split(/^Summary/m, $output);
				InfoWindow("Summary$output[1]", 'left');
			}
			return;
		}
		sub SearchResultFiles
		{
			my ($menu, $clist) = @_;
			my @search_list_show = $clist->selection;
			my $index = @search_list_show;
			if($index > 0){
				$index -= 1;
				my $pkgname = $clist->get_text($search_list_show[$index], 0);
				my $query = "poldek";
				if(scalar(@CONFIG) != 0){
					my @srcname = grep(/^source_name\s+=\s+[\w\.-]+$/, @CONFIG);
					if(@srcname > 0){
						$srcname[0] =~ s/^source_name\s+=\s+//g;
						chop($srcname[0]);
						my @sources = split(/ /, $srcname[0]);
						foreach my $source(@sources){
							$query .= " --sn=$source";
						}
					}
				}
				$query .= " --shcmd='desc -f $pkgname'";
				$output = `$query`;
				my @output = split(/^Przeczytano \d+ pakietw$/m, $output);
				$i = scalar(@output) - 1;
				InfoWindow("$output[$i]", 'left');
			}
		}
		sub SearchResultSelected
		{
			my ($selected_list, $row, $column, undef, undef) = @_;
			$search_value .= $selected_list->get_text($row, $column)." ";
			return;
		}
		sub SearchResultUnselected
		{
			my ($selected_list, $row, $column, undef, undef) = @_;
			my $text = $selected_list->get_text($row, $column);
			$search_value =~ s/$text //g;
			return;
		}
		sub InstallSearchResults
		{
			if($search_value){
				$install_entry->set_text('');
				$notebook->set_page(1);
				$install_entry->append_text($search_value);
			}else{
				ErrorWindow($LANG->{error_empty});
			}
			return;
		}
	} # if($i == 0)
	if($i == 1){
		$install_entry->show();
		my $install_label_name = new Gtk::Label($LANG->{install_label_name});
		$install_label_name->show();
		my $install_label_type = new Gtk::Label($LANG->{install_label_type});
		$install_label_type->show();
		my $install_label_options = new Gtk::Label($LANG->{install_label_options});
		$install_label_options->show();
		my $install_downgrade = new Gtk::RadioButton($LANG->{install_downgrade});
		$install_downgrade->show();
		my $install_fetch = new Gtk::CheckButton($LANG->{install_fetch});
		$install_fetch->show();
		my $install_force = new Gtk::CheckButton($LANG->{install_force});
		$install_force->show();
		my $install_fresh = new Gtk::CheckButton($LANG->{install_fresh});
		$install_fresh->show();
		my $install_greedy = new Gtk::CheckButton($LANG->{install_greedy});
		$install_greedy->show();
		my $install_install = new Gtk::RadioButton($LANG->{install_install}, $install_downgrade);
		$install_install->set_active(1);
		$install_install->show();
		my $install_mercy = new Gtk::CheckButton($LANG->{install_mercy});
		$install_mercy->show();
		my $install_nodeps = new Gtk::CheckButton($LANG->{install_nodeps});
		$install_nodeps->show();
		my $install_nofollow = new Gtk::CheckButton($LANG->{install_nofollow});
		$install_nofollow->show();
		my $install_reinstall = new Gtk::RadioButton($LANG->{install_reinstall}, $install_install);
		$install_reinstall->show();
		my $install_uninstall = new Gtk::RadioButton($LANG->{install_uninstall}, $install_reinstall);
		$install_uninstall->show();
		my $install_upgrade = new Gtk::RadioButton($LANG->{install_upgrade}, $install_uninstall);
		$install_upgrade->show();
		my $install_test = new Gtk::CheckButton($LANG->{install_test});
		$install_test->show();

		my $install_entry_hbox = new Gtk::HBox(0, 5);
		$install_entry_hbox->pack_start($install_label_name, 0, 0, 5);
		$install_entry_hbox->pack_start($install_entry, 1, 1, 10);
		$install_entry_hbox->show();
		
		my $install_table = new Gtk::Table(5, 6, 0);
		$install_table->show();
		$install_table->attach($install_entry_hbox, 0, 5, 0, 1, 'fill', 'fill', 5, 5);
		$install_table->attach_defaults($install_label_type, 0, 1, 1, 2);
		$install_table->attach_defaults($install_downgrade, 1, 2, 1, 2);
		$install_table->attach_defaults($install_install, 2, 3, 1, 2);
		$install_table->attach_defaults($install_uninstall, 3, 4, 1, 2);
		$install_table->attach_defaults($install_upgrade, 4, 5, 1, 2);
		$install_table->attach_defaults($install_reinstall, 1, 2, 2, 3);
		$install_table->attach_defaults($install_label_options, 0, 1, 3, 4);
		$install_table->attach_defaults($install_fetch, 1, 2, 3, 4);
		$install_table->attach_defaults($install_force, 2, 3, 3, 4);
		$install_table->attach_defaults($install_fresh, 3, 4, 3, 4);
		$install_table->attach_defaults($install_greedy, 4, 5, 3, 4);
		$install_table->attach_defaults($install_mercy, 1, 2, 4, 5);
		$install_table->attach_defaults($install_nodeps, 2, 3, 4, 5);
		$install_table->attach_defaults($install_nofollow, 3, 4, 4, 5);
		$install_table->attach_defaults($install_test, 4, 5, 4, 5);
		my $install_submit = new Gtk::Button($LANG->{install_submit});
		$install_submit->can_default(1);
		$install_submit->grab_default();
		$install_submit->show();
		$install_table->attach($install_submit, 3, 4, 5, 6, 'fill', 'fill', 0, 15);

		my $install_entry_frame = new Gtk::Frame($LANG->{install_entry_frame});
		$install_entry_frame->add($install_table);
		$install_entry_frame->show();
		$body_vbox->pack_start($install_entry_frame, 0, 1, 0);
		
		$install_greedy->signal_connect('clicked', \&InstallGreedyNofollow);
		$install_nofollow->signal_connect('clicked', \&InstallGreedyNofollow);
		
		sub InstallGreedyNofollow
		{
			if($install_greedy->active){
				$install_nofollow->set_sensitive(0);
			}else{
				$install_nofollow->set_sensitive(1);
			}
			if($install_nofollow->active){
				$install_greedy->set_sensitive(0);
			}else{
				$install_greedy->set_sensitive(1);
			}
		}

		$install_downgrade->signal_connect('clicked', \&InstallOptionsDowngrade);
		$install_install->signal_connect('clicked', \&InstallOptionsInstall);
		$install_reinstall->signal_connect('clicked', \&InstallOptionsReinstall);
		$install_uninstall->signal_connect('clicked', \&InstallOptionsUninstall);
		$install_upgrade->signal_connect('clicked', \&InstallOptionsUpgrade);
		
		sub InstallOptionsDowngrade
		{
			$install_fresh->set_sensitive(0);
		}
		sub InstallOptionsInstall
		{
			$install_fresh->set_sensitive(1);
		}
		sub InstallOptionsReinstall
		{
			$install_fresh->set_sensitive(0);
		}
		sub InstallOptionsUninstall
		{
			$install_fresh->set_sensitive(0);
		}
		sub InstallOptionsUpgrade
		{
			$install_fresh->set_sensitive(1);
		}
		# catching signals
		$install_submit->signal_connect('clicked', \&InstallPackages, $install_entry, $install_downgrade, $install_fetch, $install_force, $install_fresh, $install_greedy, $install_install, $install_mercy, $install_nodeps, $install_nofollow, $install_reinstall, $install_test, $install_uninstall, $install_upgrade);
		
		sub InstallPackages
		{
			my (undef, $install_pkgname, $state_downgrade, $state_fetch, $state_force, $state_fresh, $state_greedy, $state_install, $state_mercy, $state_nodeps, $state_nofollow, $state_reinstall, $state_test, $state_uninstall, $state_upgrade) = @_;
			$install_pkgname = $install_pkgname->get_text();
			my $query = 'poldek';
			if(scalar(@CONFIG) != 0){
				my @srcname = grep(/^source_name\s+=\s+[\w\.-]+$/, @CONFIG);
				if(@srcname > 0){
					$srcname[0] =~ s/^source_name\s+=\s+//g;
					chop($srcname[0]);
					my @sources = split(/ /, $srcname[0]);
					foreach my $source(@sources){
						$query .= " --sn=$source";
					}
				}
			}
			if($state_downgrade->active){ 
				$query .= ' --downgrade';
				if($state_fetch->active){ $query .= ' --fetch'; }
				if($state_force->active){ $query .= ' --force'; }
				if($state_greedy->active){ $query .= ' --greedy'; }
				if($state_mercy->active){ $query .= ' --mercy'; }
				if($state_nodeps->active){ $query .= ' --nodeps'; }
				if($state_nofollow->active){ $query .= ' --nofollow'; }
				if($state_test->active){ $query .= ' --test'; }
				$query .= " $install_pkgname";
			}elsif($state_install->active){
				$query .= ' --shcmd=\'install';
				if($state_fetch->active){ $query .= ' --fetch'; }
				if($state_force->active){ $query .= ' --force'; }
				if($state_fresh->active){ $query .= ' --fresh'; }
				if($state_greedy->active){ $query .= ' --greedy'; }
				if($state_mercy->active){ $query .= ' --mercy'; }
				if($state_nodeps->active){ $query .= ' --nodeps'; }
				if($state_nofollow->active){ $query .= ' --nofollow'; }
				if($state_test->active){ $query .= ' --test'; }
				$query .= " $install_pkgname'";
			}elsif($state_reinstall->active){
				$query .= ' --reinstall';
				if($state_fetch->active){ $query .= ' --fetch'; }
				if($state_force->active){ $query .= ' --force'; }
				if($state_greedy->active){ $query .= ' --greedy'; }
				if($state_mercy->active){ $query .= ' --mercy'; }
				if($state_nodeps->active){ $query .= ' --nodeps'; }
				if($state_nofollow->active){ $query .= ' --nofollow'; }
				if($state_test->active){ $query .= ' --test'; }
				$query .= " $install_pkgname";
			}elsif($state_uninstall->active){
				$query .= ' --erase';
				if($state_fetch->active){ $query .= ' --fetch'; }
				if($state_force->active){ $query .= ' --force'; }
				if($state_greedy->active){ $query .= ' --greedy'; }
				if($state_mercy->active){ $query .= ' --mercy'; }
				if($state_nodeps->active){ $query .= ' --nodeps'; }
				if($state_nofollow->active){ $query .= ' --nofollow'; }
				if($state_test->active){ $query .= ' --test'; }
				$query .= " $install_pkgname";
			}elsif($state_upgrade->active){
				$query .= ' --upgrade';
				if($state_fetch->active){ $query .= ' --fetch'; }
				if($state_force->active){ $query .= ' --force'; }
				if($state_fresh->active){ $query .= ' --fresh'; }
				if($state_greedy->active){ $query .= ' --greedy'; }
				if($state_mercy->active){ $query .= ' --mercy'; }
				if($state_nodeps->active){ $query .= ' --nodeps'; }
				if($state_nofollow->active){ $query .= ' --nofollow'; }							
				if($state_test->active){ $query .= ' --test'; }
				$query .= " $install_pkgname";
			}else{
				ErrorWindow($LANG->{error_empty});
			}
			if($install_pkgname eq ''){
				ErrorWindow($LANG->{error_empty});
			}else{
				open(TMP, "$query 2>&1 |");
				my $error;
				while($output = <TMP>){
					$output_text->insert($fixed_font, undef, undef, $output);
					print LOG $output;
					chop($output);
					if($output =~ /^bd: mark: nie znaleziono/m){
						ErrorWindow($LANG->{error_no_packages});
						$error++;
					}elsif($output =~ /equal version installed, skipped$/){
						InfoWindow($LANG->{info_equal});
						$error++;
					}elsif($output =~ /^bd:/){
						my @error = split(/bd:/, $output);
						ErrorWindow($LANG->{error_unknown}.$error[1]);
						$error++;
					}
				}
				if(!$error){
					InfoWindow($LANG->{info_success});
				}
				close TMP;
			}
			return;
		}
	}# if($i == 1)
	if($i == 2){
		my $conf_table = new Gtk::Table(3, 5, 0);
		$conf_table->show();
		
		my $conf_label = new Gtk::Label($LANG->{conf_lang_label});
		$conf_label->show();
		my $conf_menu = new Gtk::Menu();
		my $conf_menu_item_label = 'UK English (en_EN)';
		my $conf_menu_item = new Gtk::MenuItem($conf_menu_item_label);
		$conf_menu->append($conf_menu_item);
		$conf_menu_item->signal_connect('activate', \&SelectLanguage, $conf_menu_item_label);
		$conf_menu_item->show();
		opendir(DIR, $LIBDIR) or die("Cannot read content of a language-packs directory\n");
		while(my $dir = readdir(DIR)){
			if($dir =~ /^\w{5}\.lang$/){
				open(TMP, $LIBDIR.'/'.$dir) or die("Language-pack '$dir' is broken\n");
				my @TMP = <TMP>;
				close TMP;
				$dir =~ s/\.lang$//g;
				$TMP[0] =~ s/^#//g;
				chop($TMP[0]);
				$conf_menu_item_label = $TMP[0].' ('.$dir.')';
				$conf_menu_item = new Gtk::MenuItem($conf_menu_item_label);
				if($dir eq $LANG_NAME){
					$conf_menu->prepend($conf_menu_item);
				}else{
					$conf_menu->append($conf_menu_item);
				}
				$conf_menu_item->signal_connect('activate', \&SelectLanguage, $conf_menu_item_label);
				$conf_menu_item->show();
			}
		}
		closedir DIR;
		my $conf_lang_select = new Gtk::OptionMenu();
		$conf_lang_select->set_menu($conf_menu);
		$conf_lang_select->set_usize(400, 0);
		$conf_lang_select->show();
		my $conf_hbox = new Gtk::HBox(0, 5);
		$conf_hbox->border_width(5);
		$conf_hbox->pack_start($conf_label, 1, 1, 5);
		$conf_hbox->pack_start($conf_lang_select, 0, 1, 10);
		$conf_hbox->show();
		$conf_table->attach_defaults($conf_hbox, 0, 5, 0, 1);

		$conf_label = new Gtk::Label($LANG->{conf_srcname_label});
		$conf_label->set_justify('left');
		$conf_label->show();
		my $conf_srcname_entry = new Gtk::Entry(100);
		$conf_srcname_entry->set_usize(400, 0);
		$conf_srcname_entry->show();
		if(scalar(@CONFIG) != 0){
			my @srcname = grep(/^source_name\s+=\s+[\w\s\.-]+$/, @CONFIG);
			if(@srcname > 0){
				$srcname[0] =~ s/^source_name\s+=\s+//g;
				chop($srcname[0]);
				$conf_srcname_entry->set_text($srcname[0]);
			}
		}
		$conf_hbox = new Gtk::HBox(0, 5);
		$conf_hbox->border_width(5);
		$conf_hbox->pack_start($conf_label, 1, 1, 5);
		$conf_hbox->pack_start($conf_srcname_entry, 0, 1, 10);
		$conf_hbox->show();
		$conf_table->attach_defaults($conf_hbox, 0, 5, 1, 2);

		my $conf_submit = new Gtk::Button($LANG->{conf_submit});
		$conf_submit->set_usize(125, 0);
		$conf_submit->signal_connect('clicked', \&SaveSettings);
		$conf_submit->can_default(1);
		$conf_submit->grab_default();
		$conf_submit->show();
		$conf_table->attach($conf_submit, 3, 4, 2, 3, 0, 0, 0, 15);
		my $conf_frame = new Gtk::Frame($LANG->{conf_frame});
		$conf_frame->show();
		$conf_frame->add($conf_table);
		$body_vbox->pack_start($conf_frame, 0, 1, 0);
		
		sub SelectLanguage
		{
			my (undef, $language_name) = @_;
			$language_name =~ s/.+\(//g;
			$language_name =~ s/\)//g;
			$conf_value = $language_name;
			return;
		}
		sub SaveSettings
		{
			my $source_name = $conf_srcname_entry->get_text();
			open(TMP, ">$HOME/.mis/config") or die("Cannot write to config file: $!");
			print TMP "language	= $conf_value\n";
			print TMP "source_name	= $source_name\n";
			close TMP;
			#Gtk->exit();
			#goto BEGIN;
			return;
		}
	}# if($i == 2)

	$body_vbox->show();
	
	$label = new Gtk::Label($LANG->{sections}->[$i]);
	$notebook->append_page($body_vbox, $label);
}

# textbox with output from poldek
$output_text->set_editable(0);
$output_text->set_line_wrap(256);
$output_text->set_usize(0, 110);
$output_text->show();
my $output_text_vscrollbar = new Gtk::VScrollbar($output_text->vadj);
$output_text_vscrollbar->show();
my $output_text_hbox = new Gtk::HBox(0, 1);
$output_text_hbox->pack_start($output_text, 1, 1, 0);
$output_text_hbox->pack_start($output_text_vscrollbar, 0, 1, 0);
$output_text_hbox->show();
my $output_text_frame = new Gtk::Frame($LANG->{output_text_frame});
$output_text_frame->show();
$output_text_frame->add($output_text_hbox);

$main_table->attach($output_text_frame, 0, 1, 3, 4, 'fill', 'fill', 1, 0);
$window->add($main_table);

$window->show();
main Gtk;
exit(0);

# signal subroutines
sub InfoWindow
{
	my ($info_text, $justify) = @_;
	unless($justify){
		$justify = 'center';
	}
	my $info_window = new Gtk::Window('dialog');
	$info_window->set_position('center');
	$info_window->set_title($LANG->{info_title});
	$info_window->border_width(5);
	my $info_vbox = new Gtk::VBox(0, 10);
	my $info_hbox = new Gtk::HBox(0, 10);
	$info_hbox->pack_start($info_vbox, 0, 1, 10);
	my $info_frame = new Gtk::Frame($LANG->{info_title});
	my $info_label = new Gtk::Label($info_text);
	$info_label->set_justify($justify);
	$info_vbox->pack_start($info_label, 0, 0, 3);
	my $info_button = new Gtk::Button('Ok');
	$info_button->can_default(1);
	$info_button->grab_default();
	$info_button->signal_connect('clicked', sub { $info_window->destroy(); });
	$info_vbox->pack_start($info_button, 0, 0, 5);
	$info_frame->add($info_hbox);
	$info_window->add($info_frame);
	$info_window->show_all();
	return;
}
sub ErrorWindow
{
	my ($error_text, $justify) = @_;
	unless($justify){
		$justify = 'center';
	}
	my $error_window = new Gtk::Window('dialog');
	$error_window->set_position('center');
	$error_window->set_title($LANG->{error_title});
	$error_window->border_width(5);
	my $error_vbox = new Gtk::VBox(0, 10);
	my $error_hbox = new Gtk::HBox(0, 10);
	$error_hbox->pack_start($error_vbox, 0, 1, 10);
	my $error_frame = new Gtk::Frame($LANG->{error_title});
	my $error_label = new Gtk::Label($error_text);
	$error_label->set_justify($justify);
	$error_vbox->pack_start($error_label, 0, 0, 3);
	my $error_button = new Gtk::Button('Ok');
	$error_button->can_default(1);
	$error_button->grab_default();
	$error_button->signal_connect('clicked', sub { $error_window->destroy(); });
	$error_vbox->pack_start($error_button, 0, 0, 5);
	$error_frame->add($error_hbox);
	$error_window->add($error_frame);
	$error_window->show_all();
	return;
}
sub MenuAbout
{
	my $window_about = new Gtk::Window('dialog');
	$window_about->set_position('center');
	$window_about->set_title($LANG->{about_title});
	$window_about->set_usize(450, 300);
	$window_about->border_width(10);
	$window_about->show();
	my $about_notebook = new Gtk::Notebook();
	$about_notebook->set_tab_pos('top');
	$about_notebook->set_homogeneous_tabs(1);
	$about_notebook->show();
	my $about_vbox = new Gtk::VBox(0, 5);
	$about_vbox->show();
	my $about_body_vbox;

	my $style = Gtk::Widget->get_default_style();
	my ($pixmap, $mask) = Gtk::Gdk::Pixmap->create_from_xpm_d($window_about->window, $style, @logo);
	my $logo = new Gtk::Pixmap($pixmap, $mask);
	$logo->show();
	my $about_logo_hbox = new Gtk::HBox(0, 0);
	$about_logo_hbox->show();
	$about_logo_hbox->pack_start($logo, 0, 0, 10);
	my $about_title_label = new Gtk::Label("Mi $version");
	$about_title_label->show();
	$about_logo_hbox->pack_start($about_title_label, 1, 1, 5);
	$about_vbox->pack_start($about_logo_hbox, 0, 0, 5);

	for $i (0..3){
		$about_body_vbox = new Gtk::VBox(1, 0);
		$about_body_vbox->show();
		if($i == 0){
			$label = new Gtk::Label($LANG->{about_description}."\n\n\n(c) 2003, Micha Chruszcz");
			$label->show();
			$about_body_vbox->pack_start($label, 1, 1, 0);
		}
		if($i == 1){
			my $about_window = new Gtk::ScrolledWindow(undef, undef);
			$about_window->show();
			$label = new Gtk::Label($LANG->{about_authors});
			$label->set_justify('left');
			$label->show();
			my $about_body_hbox = new Gtk::HBox(0, 0);
			$about_body_hbox->pack_start($label, 0, 1, 5);
			$about_body_hbox->show();
			$about_window->add_with_viewport($about_body_hbox);
			$about_body_vbox->pack_start($about_window, 0, 1, 1);
		}
		if($i == 2){
			my $about_window = new Gtk::ScrolledWindow(undef, undef);
			$about_window->show();
			$label = new Gtk::Label($LANG->{about_thanks});
			$label->set_justify('left');
			$label->show();
			my $about_body_hbox = new Gtk::HBox(0, 0);
			$about_body_hbox->pack_start($label, 0, 1, 5);
			$about_body_hbox->show();
			$about_window->add_with_viewport($about_body_hbox);
			$about_body_vbox->pack_start($about_window, 0, 1, 1);
		}
		if($i == 3){
			my $about_window = new Gtk::ScrolledWindow(undef, undef);
			$about_window->show();
			my $license = '';
			if(-e $LIBDIR.'/COPYING'){
				open(TMP, $LIBDIR.'/COPYING');
				my @license = <TMP>;
				close TMP;
				$license = join('',@license);
			}else{
				print("Cannot open license file\n");
			}
			$label = new Gtk::Label($LANG->{about_license}."\n".$license);
			$label->set_justify('left');
			$label->show();
			my $about_body_hbox = new Gtk::HBox(0, 0);
			$about_body_hbox->pack_start($label, 0, 1, 5);
			$about_body_hbox->show();
			$about_window->add_with_viewport($about_body_hbox);
			$about_body_vbox->pack_start($about_window, 0, 1, 1);
		}
		$label = new Gtk::Label($LANG->{about_sections}->[$i]);
		$about_notebook->append_page($about_body_vbox, $label);
	}
	$about_vbox->pack_start($about_notebook, 1, 1, 0);
	$window_about->add($about_vbox);
	return;
}
sub CloseProgram
{
	close LOG;
	Gtk->exit(0);
}
