Ajour des Fiches d'intervention + corrections de divers bugs
[bilio:bilio.git] / src / 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                 intervention_tb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/interventions.png" ), "Interventions" )
19         achat_tb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/documents.png" ), "Achats" )
20         devis_four_tb = Gtk::MenuItem.new @window.type_doc[6][:nom]
21         commande_four_tb = Gtk::MenuItem.new @window.type_doc[7][:nom]
22         facture_four_tb = Gtk::MenuItem.new @window.type_doc[8][:nom]
23         vente_tb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/documents.png" ), "Ventes" )
24         devis_tb = Gtk::MenuItem.new @window.type_doc[1][:nom]
25         commande_tb = Gtk::MenuItem.new @window.type_doc[2][:nom]
26         bl_tb = Gtk::MenuItem.new @window.type_doc[3][:nom]
27         facture_tb = Gtk::MenuItem.new @window.type_doc[4][:nom]
28         avoir_tb = Gtk::MenuItem.new @window.type_doc[5][:nom]
29         banques_tb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/wxbanker.png" ), "Banques" )
30         comptes_tb = Gtk::MenuItem.new "Liste des comptes"
31         assistant_tb = Gtk::MenuItem.new "Assistant de connexion"
32         configuration_tb = Gtk::MenuItem.new "Configuration"
33         paiements_tb = Gtk::MenuItem.new "Liste des paiements"
34         usertb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/users22.png" ), "Utilisateurs" )
35         configtb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/config.png" ), "Configuration" )
36         requetetb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/config.png" ), "RequĂȘtes" )
37         abouttb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/help22.png" ), "A Propos" )
38         quittb = Gtk::ToolButton.new( Gtk::Image.new( "./resources/icons/exit.png" ), "Quitter" )
39         
40         menu_achat = Gtk::Menu.new
41                 menu_achat.append devis_four_tb
42                 menu_achat.append commande_four_tb
43                 menu_achat.append facture_four_tb
44                 menu_achat.show_all
45         
46         menu_vente = Gtk::Menu.new
47                 menu_vente.append devis_tb
48                 menu_vente.append commande_tb
49                 menu_vente.append bl_tb
50                 menu_vente.append facture_tb
51                 menu_vente.append avoir_tb
52                 menu_vente.show_all
53                 
54                 menu_article = Gtk::Menu.new
55                 menu_article.append liste_article_tb
56                 #menu_article.append transfo_tb         
57                 menu_article.show_all
58                 
59                 menu_banques = Gtk::Menu.new
60                 menu_banques.append comptes_tb  
61                 menu_banques.append paiements_tb                
62                 menu_banques.show_all
63                 
64                 menu_config = Gtk::Menu.new
65                 menu_config.append assistant_tb 
66                 menu_config.append configuration_tb             
67                 menu_config.show_all
68                 
69                 tableau_bord.signal_connect( "clicked" ) {
70                         window.tableau_bord.refresh
71                         window.affiche window.tableau_bord
72                 }
73                 
74                 achat_tb.signal_connect( "clicked" ) {
75                         menu_achat.popup(nil, nil, 0, 0)
76                 }
77                                 
78                 vente_tb.signal_connect( "clicked" ) {
79                         menu_vente.popup(nil, nil, 0, 0)
80                 }
81                 
82                 article_tb.signal_connect( "clicked" ) {
83                         window.affiche window.liste_articles
84                         window.liste_articles.focus
85                 }
86                 
87                 intervention_tb.signal_connect( "clicked" ) {
88                         window.liste_interventions.refresh
89                         window.affiche window.liste_interventions
90                 }
91                 
92                 banques_tb.signal_connect( "clicked" ) {
93                         menu_banques.popup(nil, nil, 0, 0)
94                 }
95                 
96                 paiements_tb.signal_connect( "activate" ) { 
97                         window.affiche window.paiement
98                         window.paiement.refresh
99         }
100         
101         comptes_tb.signal_connect( "activate" ) { 
102                         window.affiche window.liste_compte
103                         window.liste_compte.refresh
104         }
105                 
106                 configtb.signal_connect( "clicked" ) {
107                         menu_config.popup(nil, nil, 0, 0)
108                 }
109                 
110                 assistant_tb.signal_connect( "activate" ) { 
111                         Assistant.new @window, first=false
112                 }
113                 
114                 configuration_tb.signal_connect( "activate" ) { 
115                         window.configuration.refresh
116                         window.affiche window.configuration
117                 }
118                 
119                 requetetb.signal_connect( "clicked" ) {
120                         #window.datas.create ["stock", "articles_stock"]
121                 }
122                 
123                 abouttb.signal_connect( "clicked" ) { 
124                         about = About.new window.version
125                         about.signal_connect('response') { about.destroy }
126                 }
127         
128         quittb.signal_connect( "clicked" ) { 
129                 window.quit
130         }
131         usertb.signal_connect( "clicked" ) { 
132                         window.affiche window.liste_users
133         }
134         
135         tiers_tb.signal_connect( "clicked" ) { 
136                         window.affiche window.liste_tiers
137                         window.liste_tiers.refresh
138                         window.liste_tiers.focus
139         }
140         
141         liste_article_tb.signal_connect( "activate" ) { 
142                         window.affiche window.liste_articles
143                         #window.liste_articles.refresh 
144                         window.liste_articles.focus
145         }
146         transfo_tb.signal_connect( "activate" ) { 
147                         window.affiche window.transformation
148                         window.transformation.focus
149         }
150         devis_tb.signal_connect( "activate" ) { 
151                         window.affiche window.liste_documents
152                         window.liste_documents.refresh 1
153         }
154         commande_tb.signal_connect( "activate" ) { 
155                         window.affiche window.liste_documents
156                         window.liste_documents.refresh 2
157         }
158         bl_tb.signal_connect( "activate" ) { 
159                         window.affiche window.liste_documents
160                         window.liste_documents.refresh 3
161         }
162         facture_tb.signal_connect( "activate" ) { 
163                         window.affiche window.liste_documents
164                         window.liste_documents.refresh 4
165         }
166         avoir_tb.signal_connect( "activate" ) { 
167                         window.affiche window.liste_documents
168                         window.liste_documents.refresh 5
169         }
170         
171         devis_four_tb.signal_connect( "activate" ) { 
172                         window.affiche window.liste_documents
173                         window.liste_documents.refresh 6
174         }
175         commande_four_tb.signal_connect( "activate" ) { 
176                         window.affiche window.liste_documents
177                         window.liste_documents.refresh 7
178         }
179         facture_four_tb.signal_connect( "activate" ) { 
180                         window.affiche window.liste_documents
181                         window.liste_documents.refresh 8
182         }
183         
184         tool = [tableau_bord, Gtk::SeparatorToolItem.new, article_tb, Gtk::SeparatorToolItem.new, tiers_tb, Gtk::SeparatorToolItem.new, intervention_tb, Gtk::SeparatorToolItem.new, achat_tb, vente_tb, Gtk::SeparatorToolItem.new, banques_tb, Gtk::SeparatorToolItem.new, usertb, configtb, Gtk::SeparatorToolItem.new, abouttb, quittb]
185         
186         tool.each_index { |i| 
187                 self.insert i, tool[i] 
188                 tool[i].sensitive = false unless ( i.eql?( tool.count-1 ) or i.eql?( tool.count-2 ) )
189         }
190         
191         end
192
193 end