@@ -16,6 +16,55 @@ ICON_ROOT = LIB_ROOT + '/icons'
1616
1717authors = [ "Chris \' xoebus\' Brown" , "Alex \' shearn89\' Shearn" ]
1818
19+ def get_cascader_info ( user )
20+ dialog = Gtk ::Dialog . new ( "Cascader Info" ,
21+ $main_application_window,
22+ Gtk ::Dialog ::MODAL ,
23+ [ Gtk ::Stock ::OK , Gtk ::Dialog ::RESPONSE_ACCEPT ] ,
24+ [ Gtk ::Stock ::CANCEL , Gtk ::Dialog ::RESPONSE_REJECT ] )
25+ dialog . set_default_size ( 300 , 100 )
26+ dialog . set_default_response ( Gtk ::Dialog ::RESPONSE_ACCEPT )
27+
28+ entry1 = Gtk ::Entry . new
29+ entry1 . max_length = 13
30+ entry1 . text = ENV [ 'USER' ]
31+ entry1 . select_region ( 0 , -1 )
32+
33+ entry1lbl = Gtk ::Label . new ( "Username: " )
34+ entry2lbl = Gtk ::Label . new ( "Topics: " )
35+
36+ entry2 = Gtk ::Entry . new
37+ entry2 . max_length = 50
38+ entry2 . set_activates_default ( true )
39+ entry2 . text = "comma,seperated,topics"
40+ entry2 . select_region ( 0 , -1 )
41+
42+ tableholder = Gtk ::Table . new ( 2 , 3 , true )
43+
44+ tableholder . attach ( entry1lbl , 0 , 1 , 0 , 1 )
45+ tableholder . attach ( entry1 , 1 , 3 , 0 , 1 )
46+ tableholder . attach ( entry2lbl , 0 , 1 , 1 , 2 )
47+ tableholder . attach ( entry2 , 1 , 3 , 1 , 2 )
48+
49+ dialog . vbox . add ( tableholder )
50+
51+ dialog . show_all
52+
53+ dialog . run do |reply |
54+ case reply
55+ when Gtk ::Dialog ::RESPONSE_ACCEPT
56+ @details = [ entry1 . text , entry2 . text ]
57+ @server = ServerGui . new ( @details [ 0 ] , @user . hostname , @details [ 1 ] )
58+ @first_run = false
59+ end
60+ dialog . destroy
61+ end
62+ end
63+
64+ #####
65+ ### WINDOW INIT
66+ #####
67+
1968window_icons = [
2069 Gdk ::Pixbuf . new ( ICON_ROOT +"/cascade16.png" ) ,
2170 Gdk ::Pixbuf . new ( ICON_ROOT +"/cascade32.png" ) ,
@@ -26,23 +75,22 @@ window_icons=[
2675window = Gtk ::Window . new
2776window . set_default_size ( 400 , 200 )
2877window . icon_list = ( window_icons )
29- # window.default_icon_list=(window_icons)
3078window . signal_connect ( "delete_event" ) {
3179 window . hide_all
3280}
3381
3482
3583#####
36- ### System tray
84+ ### SYSTEM TRAY
3785#####
86+
3887si = Gtk ::StatusIcon . new
39- # si.stock=Gtk::Stock::DIALOG_INFO
4088hearticon = Gdk ::Pixbuf . new ( LIB_ROOT + '/icons/cascade32.png' )
4189monkeyicon = Gdk ::Pixbuf . new ( LIB_ROOT + '/icons/cascading32.png' )
4290si . pixbuf = Gdk ::Pixbuf . new ( LIB_ROOT + '/icons/cascade32.png' )
4391si . tooltip = 'Cascader'
4492
45- # RIGHT CLICK
93+ # RIGHT CLICK MENU
4694## need both scascade and cascadebutton here in order for label changing to work.
4795scascade = Gtk ::ImageMenuItem . new ( label = "Cascade" , use_underline = false )
4896cascadebutton = Gtk ::ToggleButton . new ( label = "Cascade" )
@@ -76,7 +124,7 @@ sabout.signal_connect('activate'){
76124 aboutdialog . hide
77125 }
78126
79- # LEFT CLICK
127+ # LEFT CLICK TOGGLE
80128si . signal_connect ( 'activate' ) {
81129 if @first_run
82130 @user = UserGui . new
@@ -100,64 +148,26 @@ simenu.show_all
100148si . signal_connect ( 'popup-menu' ) { |tray , button , time | simenu . popup ( nil , nil , button , time ) }
101149
102150#####
103- ### MAIN WINDOW
151+ ### MAIN WINDOW FUNCTIONS
104152#####
105153
106154table1 = Gtk ::Table . new ( 2 , 3 , true )
107155
156+ #####
157+ ### FIND A CASCADER
158+ #####
159+
108160findbutton = Gtk ::Button . new ( "Find a Cascader" )
109161findbutton . signal_connect ( "clicked" ) { |b |
110162 @user = UserGui . new
111163 client = ClientGui . new ( @user )
112164 client . search ( window )
113165}
114166
115- def get_cascader_info ( user )
116- dialog = Gtk ::Dialog . new ( "Cascader Info" ,
117- $main_application_window,
118- Gtk ::Dialog ::MODAL ,
119- [ Gtk ::Stock ::OK , Gtk ::Dialog ::RESPONSE_ACCEPT ] ,
120- [ Gtk ::Stock ::CANCEL , Gtk ::Dialog ::RESPONSE_REJECT ] )
121- dialog . set_default_size ( 300 , 100 )
122- dialog . set_default_response ( Gtk ::Dialog ::RESPONSE_ACCEPT )
123-
124- entry1 = Gtk ::Entry . new
125- entry1 . max_length = 13
126- entry1 . text = ENV [ 'USER' ]
127- entry1 . select_region ( 0 , -1 )
128-
129- entry1lbl = Gtk ::Label . new ( "Username: " )
130- entry2lbl = Gtk ::Label . new ( "Topics: " )
131-
132- entry2 = Gtk ::Entry . new
133- entry2 . max_length = 50
134- entry2 . set_activates_default ( true )
135- entry2 . text = "comma,seperated,topics"
136- entry2 . select_region ( 0 , -1 )
137-
138- tableholder = Gtk ::Table . new ( 2 , 3 , true )
139-
140- tableholder . attach ( entry1lbl , 0 , 1 , 0 , 1 )
141- tableholder . attach ( entry1 , 1 , 3 , 0 , 1 )
142- tableholder . attach ( entry2lbl , 0 , 1 , 1 , 2 )
143- tableholder . attach ( entry2 , 1 , 3 , 1 , 2 )
144-
145- dialog . vbox . add ( tableholder )
146-
147- dialog . show_all
148-
149- dialog . run do |reply |
150- case reply
151- when Gtk ::Dialog ::RESPONSE_ACCEPT
152- @details = [ entry1 . text , entry2 . text ]
153- @server = ServerGui . new ( @details [ 0 ] , @user . hostname , @details [ 1 ] )
154- @first_run = false
155- end
156- dialog . destroy
157- end
158- end
167+ #####
168+ ### CASCADE
169+ #####
159170
160- # CASCADE BUTTON
161171cascadebutton . signal_connect ( "toggled" ) { |w |
162172 w . active? ? false : true
163173
@@ -173,6 +183,9 @@ cascadebutton.signal_connect("toggled") { |w|
173183 end
174184}
175185
186+ #####
187+ ### ABOUT
188+ #####
176189
177190aboutdialog . name = "Cascader"
178191aboutdialog . version = "1.0"
@@ -181,19 +194,26 @@ aboutdialog.license = "This program shared under a Creative Commons license.\nSe
181194aboutdialog . website = "http://github.com/shearn89/cascader-gui"
182195aboutdialog . website_label = "Fork us on GitHub"
183196aboutdialog . authors = authors
184- # aboutdialog.logo = Gdk::Pixbuf.new(LIB_ROOT + '/icons/300x100-license.png')
185197
186198about = Gtk ::Button . new ( "About" )
187199about . signal_connect ( "clicked" ) {
188200 aboutdialog . run
189201 aboutdialog . hide
190202}
191203
204+ #####
205+ ### EXIT
206+ #####
207+
192208exitbutton = Gtk ::Button . new ( "Quit" )
193209exitbutton . signal_connect ( "clicked" ) {
194210 Gtk . main_quit
195211}
196212
213+ #####
214+ ### GENERAL START
215+ #####
216+
197217window . border_width = 10
198218window . add ( table1 )
199219
0 commit comments