source: soft/build_system/build_system/mkcd/tags/V4_0_11_1mdk/gmkcd @ 1

Last change on this file since 1 was 1, checked in by fasma, 12 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 5.7 KB
Line 
1#!/usr/bin/perl
2#*****************************************************************************
3#
4#  Copyright (c) 2004 Mandrakesoft
5#       author: Florent Villard <warly@mandrakesoft.com>
6#
7#  This program is free software; you can redistribute it and/or modify
8#  it under the terms of the GNU General Public License version 2, as
9#  published by the Free Software Foundation.
10#
11#  This program is distributed in the hope that it will be useful,
12#  but WITHOUT ANY WARRANTY; without even the implied warranty of
13#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14#  GNU General Public License for more details.
15#
16#  You should have received a copy of the GNU General Public License
17#  along with this program; if not, write to the Free Software
18#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19#
20#*****************************************************************************
21#
22
23use MDK::Common 'any';
24
25BEGIN {  #- we want to run this code before the Gtk->init of the use-my_gtk
26    my $basename = sub { local $_ = shift; s|/*\s*$||; s|.*/||; $_ };
27    any { /^--?h/ } @ARGV and do {
28        printf qq(Usage: %s [OPTION]...
29  --no-confirmation      don't ask first confirmation question in update mode
30  --no-verify-rpm        don't verify packages signatures
31  --changelog-first      display changelog before filelist in the description window
32  --merge-all-rpmnew     propose to merge all .rpmnew/.rpmsave files found
33  --parallel=alias,host  be in parallel mode, use "alias" group, use "host" machine to show needed deps
34  --media=medium1,..     limit to given media
35  --pkg-sel=pkg1,..      preselect these packages
36  --pkg-nosel=pkg1,..    show only these packages
37), $basename->($0);
38        exit 0;
39    };
40}
41
42use strict;
43use diagnostics;
44use lib qw(/usr/lib/libDrakX);
45use common;
46use c;
47use standalone;
48use lang;
49
50#- This is needed because text printed by Gtk2 will always be encoded
51#- in UTF-8; we first check if LC_ALL is defined, because if it is,
52#- changing only LC_COLLATE will have no effect.
53use POSIX;
54use locale;
55my $collation_locale = $ENV{LC_ALL};
56if ($collation_locale) {
57  $collation_locale =~ /UTF-8/ or setlocale(LC_ALL, "$collation_locale.UTF-8");
58} else {
59  $collation_locale = setlocale(LC_COLLATE);
60  $collation_locale =~ /UTF-8/ or setlocale(LC_COLLATE, "$collation_locale.UTF-8");
61};
62
63eval { require ugtk2; ugtk2->import(qw(:all)); require Gtk2::Pango; require Gtk2::Gdk::Keysyms };
64if ($@) {
65    print "This program cannot be run in console mode.\n";
66    c::_exit(0);  #- skip ugtk2::END
67}
68
69my $version = "0.0.1";
70my $w;
71
72my $w = ugtk2->new(N("GMkcd"));
73
74my @size = (800, 600);
75gtkset_size_request($w->{window}, @size);
76
77my @menu_items = (
78                  [ N("/_File"), undef, undef, undef, '<Branch>' ],
79                  [ N("/_File") . N("/_Load"), N("<control>L"), \&load_project, undef, '<StockItem>', N("Load") ],
80                  [ N("/_File") . N("/_New"), N("<control>N"), \&new_project, undef, '<StockItem>', N("New") ],
81                  [ N("/_File") . N("/_Save"), N("<control>S"), \&save_project, undef, '<StockItem>', N("Save") ],
82                  [ N("/_File") . N("/_Quit"), N("<control>Q"), \&quit_global, undef, '<StockItem>', N("Quit") ],
83                  [ N("/_Help"), undef, undef, undef, '<Branch>' ],
84                  [ N("/_Help").N("/_About..."), undef, \&about_gmkcd, undef, '<Item>' ]
85                 );
86
87sub quit_global() {
88    gtkset_mousecursor_normal();
89    Gtk2::exit(0);
90}
91
92sub load_project {
93
94}
95
96sub new_project {
97
98}
99
100sub save_project {
101
102}
103
104sub new_dialog {
105    my ($title, $o_no_button) = @_;
106    my $dialog = gtkset_border_width(Gtk2::Dialog->new, 10);
107    $dialog->set_transient_for($w->{window});
108    $dialog->set_position('center-on-parent');
109    $dialog->set_title($title);
110    $dialog->action_area->pack_start(gtkadd(Gtk2::HButtonBox->new,
111                                            gtksignal_connect(Gtk2::Button->new(N("Close")), clicked => sub { $dialog->destroy })
112                                            ),
113                                     0,0,0) unless $o_no_button;
114    gtkset_modal($dialog, 1);
115}
116
117sub about_gmkcd() {
118    my $window_about = new_dialog(N("About - GMkcd"));
119
120    my $tree_model = Gtk2::TreeStore->new("Glib::String", "Glib::String", "Glib::String");
121    my $credits_model = Gtk2::TreeStore->new("Glib::String", "Glib::String");
122    my ($list, $clist) = (Gtk2::TreeView->new_with_model($tree_model), Gtk2::TreeView->new_with_model($credits_model));
123    $_->can_focus(0) foreach $list, $clist;
124    each_index {  $list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => $::i)) } 0..2;
125    each_index { $clist->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => $::i)) } 0..1;
126    $_->set_headers_visible(0) foreach $list, $clist;
127
128    foreach my $row (['Florent Villard (Warly)', N("(mkcd and gmkcd)") ],
129                     ) {
130        $tree_model->append_set(undef, [ map_index { $::i => $_ } @$row ]);
131    }
132
133    gtkpack_($window_about->vbox,
134             0, Gtk2::Label->new("Gmkcd"),
135             0, Gtk2::Label->new(N("Gmkcd is a frontend the the distro disc maker mkcd.")),
136             0, Gtk2::Label->new(N("Copyright (C) 1999-2004 Mandrakesoft SA") . "\n"),
137             0, Gtk2::HSeparator->new,
138             0, Gtk2::Label->new(""),
139             1, my $n = Gtk2::Notebook->new,
140             );
141
142    add2notebook($n, N("Authors"), $list);
143
144    $window_about->show_all;
145}
146my ($menu, $factory) = create_factory_menu($w->{window}, @menu_items);
147
148$w->{window}->set_resizable(1);
149
150my $window_global = gtkset_size_request(Gtk2::Window->new('toplevel'), 620, 460);
151
152gtkadd($w->{window},
153    gtkpack_(Gtk2::VBox->new(0, 0),
154        0, $menu, 
155    ),
156);
157
158$w->{window}->show_all;
159$w->main;
Note: See TracBrowser for help on using the repository browser.