Amélioration du panneau de configuration, et préparation d'un assistant de premier...
[bilio:bilio.git] / toolbargen.rb
1 # coding: utf-8
2
3 class ToolBarGen_box < Gtk::Toolbar
4
5         def initialize window
6         
7                 super()
8                 
9         @window = window
10         
11         set_toolbar_style Gtk::Toolbar::Style::BOTH
12                 
13                 tableau_bord = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/tb.png" ), "Tableau de bord" )
14                 article_tb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/articles.png" ), "Articles" )
15                 liste_article_tb = Gtk::MenuItem.new "Liste d'article"
16                 transfo_tb = Gtk::MenuItem.new "Transformation"
17                 tiers_tb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/tiers.png" ), "Tiers" )
18         achat_tb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/attachment.png" ), "Achats" )
19         devis_four_tb = Gtk::MenuItem.new @window.type_doc[6][:nom]
20         commande_four_tb = Gtk::MenuItem.new @window.type_doc[7][:nom]
21         facture_four_tb = Gtk::MenuItem.new @window.type_doc[8][:nom]
22         vente_tb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/attachment.png" ), "Ventes" )
23         devis_tb = Gtk::MenuItem.new @window.type_doc[1][:nom]
24         commande_tb = Gtk::MenuItem.new @window.type_doc[2][:nom]
25         bl_tb = Gtk::MenuItem.new @window.type_doc[3][:nom]
26         facture_tb = Gtk::MenuItem.new @window.type_doc[4][:nom]
27         avoir_tb = Gtk::MenuItem.new @window.type_doc[5][:nom]
28         usertb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/users22.png" ), "Utilisateurs" )
29         configtb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/config.png" ), "Configuration" )
30         requetetb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/config.png" ), "Requêtes" )
31         abouttb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/help22.png" ), "A Propos" )
32         quittb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/exit.png" ), "Quitter" )
33         
34         menu_achat = Gtk::Menu.new
35                 menu_achat.append devis_four_tb
36                 menu_achat.append commande_four_tb
37                 menu_achat.append facture_four_tb
38                 menu_achat.show_all
39         
40         menu_vente = Gtk::Menu.new
41                 menu_vente.append devis_tb
42                 menu_vente.append commande_tb
43                 menu_vente.append bl_tb
44                 menu_vente.append facture_tb
45                 menu_vente.append avoir_tb
46                 menu_vente.show_all
47                 
48                 menu_article = Gtk::Menu.new
49                 menu_article.append liste_article_tb
50                 menu_article.append transfo_tb          
51                 menu_article.show_all
52                 
53                 tableau_bord.signal_connect( "clicked" ) {
54                         window.tableau_bord.refresh
55                         window.affiche window.tableau_bord
56                 }
57                 
58                 achat_tb.signal_connect( "clicked" ) {
59                         menu_achat.popup(nil, nil, 0, 0)
60                 }
61                                 
62                 vente_tb.signal_connect( "clicked" ) {
63                         menu_vente.popup(nil, nil, 0, 0)
64                 }
65                 
66                 article_tb.signal_connect( "clicked" ) {
67                         menu_article.popup(nil, nil, 0, 0)
68                 }
69                 
70                 configtb.signal_connect( "clicked" ) {
71                         window.config_db.dialogue
72                 }
73                 
74                 requetetb.signal_connect( "clicked" ) {
75                         #window.datas.create ["stock", "articles_stock"]
76                 }
77                 
78                 abouttb.signal_connect( "clicked" ) { 
79                         about = About.new window.version
80                         about.signal_connect('response') { about.destroy }
81                 }
82         
83         quittb.signal_connect( "clicked" ) { 
84                 window.quit
85         }
86         usertb.signal_connect( "clicked" ) { 
87                         window.affiche window.liste_users
88         }
89         
90         tiers_tb.signal_connect( "clicked" ) { 
91                         window.affiche window.liste_tiers
92                         window.liste_tiers.focus
93         }
94         
95         liste_article_tb.signal_connect( "activate" ) { 
96                         window.affiche window.liste_articles
97                         window.liste_articles.focus
98         }
99         transfo_tb.signal_connect( "activate" ) { 
100                         window.affiche window.transformation
101                         window.transformation.focus
102         }
103         devis_tb.signal_connect( "activate" ) { 
104                         window.affiche window.liste_documents
105                         window.liste_documents.refresh 1
106         }
107         commande_tb.signal_connect( "activate" ) { 
108                         window.affiche window.liste_documents
109                         window.liste_documents.refresh 2
110         }
111         bl_tb.signal_connect( "activate" ) { 
112                         window.affiche window.liste_documents
113                         window.liste_documents.refresh 3
114         }
115         facture_tb.signal_connect( "activate" ) { 
116                         window.affiche window.liste_documents
117                         window.liste_documents.refresh 4
118         }
119         avoir_tb.signal_connect( "activate" ) { 
120                         window.affiche window.liste_documents
121                         window.liste_documents.refresh 5
122         }
123         
124         devis_four_tb.signal_connect( "activate" ) { 
125                         window.affiche window.liste_documents
126                         window.liste_documents.refresh 6
127         }
128         commande_four_tb.signal_connect( "activate" ) { 
129                         window.affiche window.liste_documents
130                         window.liste_documents.refresh 7
131         }
132         facture_four_tb.signal_connect( "activate" ) { 
133                         window.affiche window.liste_documents
134                         window.liste_documents.refresh 8
135         }
136         
137         tool = [tableau_bord, Gtk::SeparatorToolItem.new, article_tb, Gtk::SeparatorToolItem.new, tiers_tb, Gtk::SeparatorToolItem.new, achat_tb, vente_tb, Gtk::SeparatorToolItem.new, usertb, configtb, Gtk::SeparatorToolItem.new, abouttb, quittb]
138         
139         tool.each_index { |i| 
140                 self.insert i, tool[i] 
141                 tool[i].sensitive = false unless ( i.eql?( tool.count-1 ) or i.eql?( tool.count-2 ) )
142         }
143         
144         end
145
146 end