summaryrefslogtreecommitdiffstats
path: root/cest_ton_boot
blob: a43b4e012c9261ba620203703e25d32b800128ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/usr/bin/perl -w

# Control-center

# Copyright (C) 2001 MandrakeSoft
# Yves Duret <yduret at mandrakesoft.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


use Gtk;
use Config;
init Gtk;
use POSIX;
use Locale::GetText;

setlocale (LC_ALL, "");
Locale::GetText::textdomain ("c'est ton boot !");
#Locale::GetText::bindtextdomain ("drakfloppy", "/usr/share/locale");

import Locale::GetText I_;

$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\S*) (\S*)/;
if ($::isEmbedded) {
  print "EMBED\n";
  print "XID : $::XID\n";
  print "CCPID :  $::CCPID\n";
}

local $_ = join '', @ARGV;

/-h/ and die I_("usage: drakfloppy\n");

$x_mode = 0;
$a_mode = (-e "/etc/aurora/Monitor");

my @xpm_data = ( "16 16 4 1",
		 "       c None s None",
		 ".      c black",
		 "X      c #808080",
		 "o      c white",
		 "                ",
		 "  ..            ",
		 " .Xo.    ...    ",
		 " .Xoo. ..oo.    ",
		 " .Xooo.Xooo...  ",
		 " .Xooo.oooo.X.  ",
		 " .Xooo.Xooo.X.  ",
		 " .Xooo.oooo.X.  ",
		 " .Xooo.Xooo.X.  ",
		 " .Xooo.oooo.X.  ",
		 "  .Xoo.Xoo..X.  ",
		 "   .Xo.o..ooX.  ",
		 "    .X..XXXXX.  ",
		 "    ..X.......  ",
		 "     ..         ",
		 "                ");

my $window = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window ("toplevel");
$window->signal_connect( 'delete_event', sub { $::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0) });
$window->set_title( I_("ce soir tu choisis ton boot") );
#$window->set_policy('automatic', 'automatic');
$window->set_policy(0, 0, 0);
$window->border_width (10);
$window->realize;


### menus definition
# the menus are not shown
# but they provides shiny shortcut like C-q
my @menu_items = ( { path        => I_("/_File"),
		     type        => '<Branch>' },
		   { path        => I_("/File/_New"),
		     accelerator => I_("<control>N"),
		     callback    => \&print_hello },
		   { path        => I_("/File/_Open"),
		     accelerator => I_("<control>O"),
		     callback    => \&print_hello },
		   { path        => I_("/File/_Save"),
		     accelerator => I_("<control>S"),
		     callback    => \&print_hello },
		   { path        => I_("/File/Save _As") },
		   { path        => I_("/File/-"),
		     type        => '<Separator>' },
		   { path        => I_("/File/_Quit"),
		     accelerator => I_("<control>Q"),
		     callback    => sub { $::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0) } },

		   { path        => I_("/_Options"),
		     type        => '<Branch>' },
		   { path        => I_("/Options/Test") },

		   { path        => I_("/_Help"),
		     type        => '<LastBranch>' },
		   { path        => I_("/Help/_About...") } );

my $menubar = get_main_menu( $window );

######### menus end

my $global_vbox = new Gtk::VBox();

$global_vbox->pack_start (new Gtk::Label(I_("special c'est ton choix")), 0, 0, 0);

######## aurora part
my $aurora_frame = new Gtk::Frame( I_("Boot mode") );
my $a_main_hbox = new Gtk::HBox;

my $a_dedans = new Gtk::VBox( 0, 10 );
$a_dedans->border_width (5);
my $a_box = new Gtk::VBox(0, 0 );

my $a_button = new Gtk::CheckButton( I_("Launch Aurora at boot time") );
$a_button->signal_connect( "clicked", sub {
			     ($a_mode) ? $a_box->set_sensitive(0) : $a_box->set_sensitive(1);
			     $a_mode = !$a_mode;
			   });
$a_dedans->pack_start ($a_button, 0, 0, 0);

my $a_h_button = new Gtk::RadioButton I_("horizontal nice looking aurora");
$a_h_button->set_active(1);
$a_box->pack_start($a_h_button, 1, 1, 0);

my $a_v_button = new Gtk::RadioButton I_("vertical traditionnal aurora"), $a_h_button;
$a_box->pack_start($a_v_button, 1, 1, 0);

my $a_g_button = new Gtk::RadioButton I_("gMonitor (choose this only if you have a non FrameBuffer kernel"), $a_h_button;
$a_box->pack_start($a_g_button, 1, 1, 0);

$a_box->set_sensitive (0);
$a_dedans->pack_start ($a_box, 0, 0, 0);

# now for the pixmap from gdk
my ( $pixmap, $mask ) = Gtk::Gdk::Pixmap->create_from_xpm( $window->window, $window->get_style()->bg( 'normal' ), "./c.xpm" );

# a pixmap widget to contain the pixmap
my $pixmapwid = new Gtk::Pixmap( $pixmap, $mask );
$pixmapwid->show();

$a_main_hbox->pack_start ($a_dedans, 0, 0, 0);
$a_main_hbox->pack_start ($pixmapwid, 0, 0, 0);
$aurora_frame->add($a_main_hbox);
$global_vbox->pack_start ($aurora_frame, 1, 1, 0);

### X mode
my $x_main_frame = new Gtk::Frame( I_("System mode") );
my $x_dedans = new Gtk::VBox( 0, 10 );
$x_dedans->border_width (5);
my $x_box = new Gtk::VBox(0, 0 );

my $x_button = new Gtk::CheckButton( I_("Launch the X-Window system at start") );
$x_button->signal_connect( "clicked", sub {
			       ($x_mode) ? $x_box->set_sensitive(0) : $x_box->set_sensitive(1);
			       $x_mode = !$x_mode;
			   });
$x_dedans->pack_start ($x_button, 0, 0, 0);


my $x_no_button = new Gtk::RadioButton I_("no, I do not want autologin");
#$x_no_button->set_active(1);
$x_box->pack_start($x_no_button, 1, 1, 0);

my $x_yes_button = new Gtk::RadioButton I_("yes, I want autologin with this user"), $x_no_button;
$x_box->pack_start($x_yes_button, 1, 1, 0);

my $user_dedans = new Gtk::VBox( 0, 10 );
$user_dedans->border_width (0);

my $user_combo = new Gtk::Combo;
$user_combo->set_popdown_strings( "you", "me", "rms", "linus");
$user_dedans->pack_start($user_combo, 0, 0, 0);
$x_box->pack_start ($user_dedans, 0, 0, 0);
$x_box->set_sensitive (0);
$x_dedans->pack_start ($x_box, 0, 0, 0);
$x_main_frame->add($x_dedans);
$global_vbox->pack_start ($x_main_frame, 1, 1, 0);

### final buttons
my $build_button = new Gtk::Button( I_("OK") );
my $cancel_button = new Gtk::Button( I_("Cancel") );
my $fin_hbox = new Gtk::HBox( 0, 0 );
$cancel_button->signal_connect( 'clicked', sub {$::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0)});
$build_button->signal_connect('clicked', \&print_hello);
$fin_hbox->pack_end($cancel_button, 0, 0, 0);
$fin_hbox->pack_end($build_button,  0, 0, 10);
$global_vbox->pack_start ($fin_hbox, 0, 0, 0);

### back to window
$window->add( $global_vbox );

$window->show_all();

main Gtk;

#-------------------------------------------------------------
# menu callback functions
#-------------------------------------------------------------

sub print_hello {
  print( "mcdtg !\n" );
}

sub get_main_menu {
  my ( $window ) = @_;

  my $accel_group = new Gtk::AccelGroup();
  my $item_factory = new Gtk::ItemFactory( 'Gtk::MenuBar', '<main>', $accel_group );
  $item_factory->create_items( @menu_items );
  $window->add_accel_group( $accel_group );
  return ( $item_factory->get_widget( '<main>' ) );
}