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