summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2000-12-19 17:44:30 +0000
committerdamien <damien@mandriva.com>2000-12-19 17:44:30 +0000
commitec42bbe9c1ee58b39ba8c263474beac64ab1de04 (patch)
tree39f1b37f4dfc8d94290653935b73a5f174599d68
parent0ceb07b387b50a38dcf4c74776239091d0e0ab06 (diff)
downloadcontrol-center-ec42bbe9c1ee58b39ba8c263474beac64ab1de04.tar
control-center-ec42bbe9c1ee58b39ba8c263474beac64ab1de04.tar.gz
control-center-ec42bbe9c1ee58b39ba8c263474beac64ab1de04.tar.bz2
control-center-ec42bbe9c1ee58b39ba8c263474beac64ab1de04.tar.xz
control-center-ec42bbe9c1ee58b39ba8c263474beac64ab1de04.zip
added control-center.
-rwxr-xr-xcontrol-center280
1 files changed, 280 insertions, 0 deletions
diff --git a/control-center b/control-center
new file mode 100755
index 00000000..155b1d1a
--- /dev/null
+++ b/control-center
@@ -0,0 +1,280 @@
+#!/usr/bin/perl
+
+# Control-center
+
+# Copyright (C) 1999 MandrakeSoft (damien@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;
+init Gtk;
+#use lib qw(/usr/lib/libDrakX);
+#use netconnect;
+#use c;
+#use Data::Dumper;
+#local $_ = join '', @ARGV;
+#if ($ARGV[1]= )
+#/-h/ and die "usage: draknet[--xf3] [--beginner] [--expert] [--auto] [--noauto] [--skiptest] [--testing]\n";
+
+my %pixmaps_global;
+my $xpm_path="/home/damien/cvs/gi/perl-install/standalone/pixmaps";
+#my $label_splash = new Gtk::Label();
+
+my $window_global = new Gtk::Window -toplevel;
+$window_global->set_usize(640, 480);
+$window_global->signal_connect ( delete_event => sub { Gtk->exit(0); });
+$window_global->set_position(1);
+$window_global->set_title("Control Center");
+$window_global->border_width(0);
+
+$vbox_global = new Gtk::VBox(0, 0);
+$window_global->add($vbox_global);
+
+######### menus
+my @item_factory_entries = (
+ ["/_File", undef, 0, "<Branch>"],
+ ["/File/tearoff1", undef, 0, "<Tearoff>"],
+ ["/File/_New", "<control>N", 1],
+ ["/File/_Open", "<control>O", 2],
+ ["/File/_Save", "<control>S", 3],
+ ["/File/Save _As...", undef, 4],
+ ["/File/sep1", undef, 0, "<Separator>"],
+ #["/File/_Quit", "<control>Q", 5],
+ {
+ 'path' => "/File/_Quit",
+ 'accelerator' => "<control>Q",
+ 'action' => 5,
+ 'type' => '<Item>'
+ },
+
+ ["/_Preferences", undef, 0, "<Branch>"],
+ ["/_Preferences/_Color", undef, 0, "<Branch>"],
+ ["/_Preferences/Color/_Red", undef, 10, "<RadioItem>"],
+ ["/_Preferences/Color/_Green", undef, 11, "<RadioItem>"],
+ ["/_Preferences/Color/_Blue", undef, 12, "<RadioItem>"],
+ ["/_Preferences/_Shape", undef, 0, "<Branch>"],
+ ["/_Preferences/Shape/_Square", undef, 20, "<RadioItem>"],
+ ["/_Preferences/Shape/_Rectangle", undef, 21, "<RadioItem>"],
+ ["/_Preferences/Shape/_Oval", undef, 22, "<RadioItem>"],
+
+ ["/_Help", undef, 0, "<LastBranch>"],
+ ["/Help/_About", undef, 30]
+ );
+
+my ($accel_group, $item_factory, $box1, $label, $box2);
+my ($separator, $button, $dummy);
+
+# $item_factory_window = new Gtk::Window('toplevel');
+# signal_connect $item_factory_window destroy => \&destroy_window, \$item_factory_window;
+# signal_connect $item_factory_window "delete-event" => \&destroy_window, \$item_factory_window;
+
+$accel_group = new Gtk::AccelGroup;
+$item_factory = new Gtk::ItemFactory('Gtk::MenuBar', "<main>", $accel_group);
+
+#$window_global->set_data('<main>', $item_factory);
+$accel_group->attach($window_global);
+#$item_factory->create_items();
+foreach (@item_factory_entries) {
+ $item_factory->create_item($_, \&item_factory_cb);
+}
+
+# $item_factory_window->set_title("Item Factory");
+# $item_factory_window->set_border_width(0);
+
+# $box1 = new Gtk::VBox(0, 0);
+# $item_factory_window->add($box1);
+$vbox_global->pack_start($item_factory->get_widget('<main>'), 0, 0, 0);
+$hseparator_global = new Gtk::HSeparator;
+$vbox_global->pack_start($hseparator_global, 0, 1, 0);
+######### menus end
+
+
+my $hbox_global = new Gtk::HBox(0,0);
+$vbox_global->pack_start($hbox_global, 1, 1, 0);
+$hbox_global->border_width(5);
+my $scrolled_global = new Gtk::ScrolledWindow;
+$scrolled_global->set_policy('automatic','automatic');
+$scrolled_global->set_usize(52, 0);
+$hbox_global->pack_start($scrolled_global,0,1,0);
+my $vseparator_global = new Gtk::VSeparator;
+$hbox_global->pack_start($vseparator_global,0,1,0);
+
+my $notebook_global = new Gtk::Notebook;
+$notebook_global->set_show_border(0);
+$notebook_global->set_show_tabs(0);
+$hbox_global->pack_start($notebook_global,1,1,0);
+
+my ($pix_about_map, $pix_about_mask) = Gtk::Gdk::Pixmap->create_from_xpm(NULL, Gtk::Widget->get_default_style->bg('normal'), "$xpm_path/logo1.xpm");
+my $pix_about = new Gtk::Pixmap ($pix_about_map, $pix_about_mask);
+my $vbox_about = new Gtk::VBox(1,0);
+$vbox_about->pack_start($pix_about, 1, 1, 0);
+my $text_about = new Gtk::Text ();
+$text_about->set_editable(0);
+$text_about->insert ( undef, undef, undef, "About, help, click on that button...");
+$vbox_about->pack_start($text_about, 1, 1, 0);
+my $label_about2 = new Gtk::Label ("");
+$vbox_about->pack_start($label_about2, 1, 1, 0);
+$notebook_global->append_page($vbox_about, "$arg");
+
+my $vbox_global_left = new Gtk::VBox(0,0);
+$scrolled_global->add_with_viewport($vbox_global_left);
+my %tools;
+
+for ( my $arg=0; $arg<=$#ARGV; $arg++) {
+ $tools[$arg]{socket} = new Gtk::Socket;
+ $tools[$arg]{socket}->show;
+ $notebook_global->append_page($tools[$arg]{socket}, "$ARGV[$arg]");
+ $tools[$arg]{socket}->realize;
+# print ("The XID of the sockets window n°$arg is [" . $tools[$arg]{socket}->window->XWINDOW . "]\n");
+ system ( $ARGV[$arg] . " --embedded " . $tools[$arg]{socket}->window->XWINDOW . "&");
+ map {
+ $pixmaps_global{$_ . '_pixmap'} =
+ Gtk::Gdk::Pixmap->create_from_xpm($window_global->window, Gtk::Widget->get_default_style->bg('normal'), "$xpm_path/$_.xpm");
+ } ('draknet1','draknet2','draknet3','draknet4', 'draknet5', 'drakgw');
+ $tools[$arg]{PIX_W} = 48;
+ $tools[$arg]{PIX_H} = 48;
+ $tools[$arg]{actual_pixmap}=1;
+ $tools[$arg]{save_pixmap}=0;
+ $tools[$arg]{anim_idle}=undef;
+ $tools[$arg]{timeout}=undef;
+ $tools[$arg]{darea} = new Gtk::DrawingArea;
+ $tools[$arg]{darea}->set_usize($tools[$arg]{PIX_W},$tools[$arg]{PIX_H});
+ $tools[$arg]{darea}->set_events(['exposure_mask', 'enter_notify_mask', 'leave_notify_mask', 'button_press_mask', 'button_release_mask' ]);
+
+
+ $tools[$arg]{darea}->signal_connect
+ (expose_event => sub {
+ my $arg=$_[1];
+# print Data::Dumper->Dump([%tools], ['$tools[$arg]']) . "\n";
+# print Data::Dumper->Dump([$tools[$arg]{darea}], ['area']) . "\n";
+ $tools[$arg]{darea}->window->draw_pixmap
+ ($tools[$arg]{darea}->style->bg_gc('normal'),
+ $pixmaps_global{'draknet' . $tools[$arg]{actual_pixmap} . '_pixmap'}, 0, 0,
+ ($tools[$arg]{darea}->allocation->[2]-$tools[$arg]{PIX_W})/2,
+ ($tools[$arg]{darea}->allocation->[3]-$tools[$arg]{PIX_H})/2,
+ $tools[$arg]{PIX_W} , $tools[$arg]{PIX_H} );
+ }, $arg );
+
+
+ $tools[$arg]{darea}->signal_connect
+ (enter_notify_event => sub {
+ my $arg=$_[1];
+
+ $tools[$arg]{anim_idle} ||= Gtk->idle_add
+ ( sub {
+ $tools[$arg]{actual_pixmap}==$tools[$arg]{save_pixmap} and return 1;
+ $tools[$arg]{darea}->window->draw_pixmap
+ ($tools[$arg]{darea}->style->bg_gc('normal'),
+ $pixmaps_global{'draknet' . $tools[$arg]{actual_pixmap} . '_pixmap'},
+ 0, 0,
+ ($tools[$arg]{darea}->allocation->[2]-$tools[$arg]{PIX_W})/2,
+ ($tools[$arg]{darea}->allocation->[3]-$tools[$arg]{PIX_H})/2,
+ $tools[$arg]{PIX_W} , $tools[$arg]{PIX_H} );
+ $tools[$arg]{save_pixmap}=$tools[$arg]{actual_pixmap};
+ return 1;
+ });
+
+ $tools[$arg]{timeout} ||= Gtk->timeout_add
+ ( 50, sub {
+ $tools[$arg]{actual_pixmap}++;
+ $tools[$arg]{actual_pixmap}>5 and $tools[$arg]{actual_pixmap}=1;
+ return 1;
+ });
+ }, $arg);
+
+
+ $tools[$arg]{darea}->signal_connect
+ (leave_notify_event => sub {
+ my $arg=$_[1];
+ Gtk->main_iteration() while ($tools[$arg]{save_pixmap}!=1);
+ Gtk->idle_remove($tools[$arg]{anim_idle});
+ Gtk->timeout_remove($tools[$arg]{timeout});
+ undef $tools[$arg]{anim_idle};
+ undef $tools[$arg]{timeout};
+ }, $arg);
+# $tools[$arg]{darea}->signal_connect(button_press_event => sub { });
+ $tools[$arg]{darea}->signal_connect(button_release_event => sub { $notebook_global->set_page($_[1]+1);}, $arg);
+ $vbox_global_left->pack_start($tools[$arg]{darea},0,1,5);
+ #$vbox_global_left->pack_start($pixmaps_global{'drakgw'},0,1,5);
+}
+
+$window_global->show_all;
+print "num : " . $notebook_global->page_num($vbox_about) . "\n";
+$notebook_global->set_page(0);
+Gtk->main;
+
+
+sub item_factory_cb {
+ my ($widget, $action, @data) = @_;
+
+ print "ItemFactory: activated ", $widget->item_factory_path(), " -> ", $action, "\n";
+ $action == 5 and Gtk->exit;
+}
+
+
+sub create_item_factory {
+ if (!defined $item_factory_window) {
+ my ($accel_group, $item_factory, $box1, $label, $box2);
+ my ($separator, $button, $dummy);
+
+
+ $item_factory_window = new Gtk::Window('toplevel');
+ signal_connect $item_factory_window destroy => \&destroy_window, \$item_factory_window;
+ signal_connect $item_factory_window "delete-event" => \&destroy_window, \$item_factory_window;
+
+ $accel_group = new Gtk::AccelGroup;
+ $item_factory = new Gtk::ItemFactory('Gtk::MenuBar', "<main>", $accel_group);
+
+ #$item_factory_window->set_data('<main>', $item_factory);
+ $accel_group->attach($item_factory_window);
+ # $item_factory->create_items();
+ foreach (@item_factory_entries) {
+ $item_factory->create_item($_, \&item_factory_cb);
+ }
+
+ $item_factory_window->set_title("Item Factory");
+ $item_factory_window->set_border_width(0);
+
+ $box1 = new Gtk::VBox(0, 0);
+ $item_factory_window->add($box1);
+ $box1->pack_start($item_factory->get_widget('<main>'), 0, 0, 0);
+
+ $label = new Gtk::Label "Type\n<alt>\nto start";
+
+ $label->set_usize(200, 200);
+ $label->set_alignment(0.5, 0.5);
+ $box1->pack_start($label, 1, 1, 0);
+
+ $separator = new Gtk::HSeparator;
+ $box1->pack_start($separator, 0, 1, 0);
+
+ $box2 = new Gtk::VBox(0, 10);
+ $box2->set_border_width(10);
+ $box1->pack_start($box2, 0, 1, 0);
+
+ $button = new Gtk::Button("close");
+ $button->signal_connect('clicked', sub {$item_factory_window->destroy;});
+ $box2->pack_start($button, 1, 1, 0);
+ $button->can_default(1);
+ $button->grab_default;
+
+ }
+ if (!visible $item_factory_window) {
+ show_all $item_factory_window;
+ } else {
+ destroy $item_factory_window;
+ }
+}