Class: MyWindow

Inherits:
Gtk::Window
  • Object
show all
Includes:
Conf, ManqodCommon
Defined in:
lib/mywindow.rb

Constant Summary

Constants included from ManqodCommon

ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING

Constants included from Eprint

Eprint::DOMAIN, Eprint::LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Conf

#get_conf, #load_conf, #save_conf, #set_conf

Methods included from ManqodCommon

#add_where, #admin, #admin_cache, #admin_qrow, #admin_rows, #backtrace_to_debug, #cache, #changed_ids_of_base, #client, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #qrow, #query, #reconnect_manqod_db, #rows, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick

Methods included from Eprint

#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception

Constructor Details

#initializeMyWindow

Returns a new instance of MyWindow.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/mywindow.rb', line 10

def initialize
ManqodRPC.instance.register_client
super()

#	set_auto_startup_notification(true)
#	set_window_position(Gtk::Window::POS_CENTER_ALWAYS)
	self.title='manqod login'
run
	
	signal_connect("delete-event"){|me,ev|
!shut_down?
	}
	signal_connect("destroy") {|me,ev|
if mainrouter
	mainrouter.destroy 
	save_conf
	edebug("quit","main","normal",false)
end
Gtk.main_quit
ManqodRPC.instance.unregister_client
	}
	signal_connect("configure-event"){|me,event|
if nick
	set_conf(0,0,"width",event.width.to_s)
	set_conf(0,0,"height",event.height.to_s)
	set_conf(0,0,"x",event.x.to_s)
	set_conf(0,0,"y",event.y.to_s)
end
false
	}
	signal_connect("window-state-event"){|me,event|
if nick
	set_conf(0,0,"maximized",(event.new_window_state &  Gdk::EventWindowState::MAXIMIZED == Gdk::EventWindowState::MAXIMIZED).to_s)
	set_conf(0,0,"minimized",(event.new_window_state &  Gdk::EventWindowState::ICONIFIED == Gdk::EventWindowState::ICONIFIED).to_s)
	set_conf(0,0,"minimized",(event.new_window_state &  Gdk::EventWindowState::FULLSCREEN == Gdk::EventWindowState::FULLSCREEN).to_s)
end
false
	}
	
	@@ag = Gtk::AccelGroup.new
	@@ag.connect(Gdk::Keyval::GDK_KEY_F5,nil ,Gtk::ACCEL_VISIBLE){
@mainrouter.reset_child
 @mymenu.update(self)
	}
	@@ag.connect(Gdk::Keyval::GDK_KEY_F4,nil ,Gtk::ACCEL_VISIBLE){
 gtk_set_edebug
	}
	add_accel_group(@@ag)
	
	
end

Instance Attribute Details

#holderObject

Returns the value of attribute holder.



62
63
64
# File 'lib/mywindow.rb', line 62

def holder
  @holder
end

#mainrouterObject

Returns the value of attribute mainrouter.



63
64
65
# File 'lib/mywindow.rb', line 63

def mainrouter
  @mainrouter
end

#mymenuObject

Returns the value of attribute mymenu.



61
62
63
# File 'lib/mywindow.rb', line 61

def mymenu
  @mymenu
end

#sbObject (readonly)

Returns the value of attribute sb.



64
65
66
# File 'lib/mywindow.rb', line 64

def sb
  @sb
end

Instance Method Details

#runObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/mywindow.rb', line 66

def run
SB.instance.set_parent_window(self)
load_conf
DrbImages.instance.load_images
	begin
if main_image_id_row = admin.qrow("select imageid from gtkmenu order by id limit 1")
	set_icon(DrbImages.instance.image_of_id(main_image_id_row["imageid"],"gtk-large-toolbar"))
end

if sw=get_conf(0,0,"width") and sh=get_conf(0,0,"height")
	resize(sw.to_i,sh.to_i)# if sw.to_i * sh.to_i >0
	else
	resize(600,400)
end
sx=get_conf(0,0,"x") || 50
sy=get_conf(0,0,"y") || 60
move(sx.to_i,sy.to_i)

maximize if get_conf(0,0,"maximized") == "true"
iconify if get_conf(0,0,"iconified") == "true"
fullscreen if get_conf(0,0,"fullscreen") == "true"

#realize;window.set_functions(Gdk::Window::WMFunction::ALL | Gdk::Window::WMFunction::CLOSE)

@holder = Gtk::Table.new(2,4,false)
@mainrouter=MainRouter.new(self)
case get_conf(0,0,"menu-position")
  when "top"
	@mymenu = if get_conf(0,0,"menu-type")=="buttons" then MenuHolder.new(mainrouter);else BarMenu.new(mainrouter);end
			holder.attach(mymenu    ,0,1,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::FILL)
			holder.attach(mainrouter,0,1,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL)
  when "bottom"
	@mymenu = if get_conf(0,0,"menu-type")=="buttons" then MenuHolder.new(mainrouter);else BarMenu.new(mainrouter);end
			holder.attach(mainrouter,0,1,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL)
			holder.attach(mymenu    ,0,1,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::FILL)
  when "left"
	@mymenu = if get_conf(0,0,"menu-type")=="buttons" then MenuHolder.new(mainrouter,"vertical");else BarMenu.new(mainrouter,"vertical");end
			holder.attach(mymenu    ,0,1,0,2,Gtk::FILL,Gtk::EXPAND)
			holder.attach(mainrouter,1,2,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL)
  when "right"
	@mymenu = if get_conf(0,0,"menu-type")=="buttons" then MenuHolder.new(mainrouter,"vertical");else BarMenu.new(mainrouter,"vertical");end
			holder.attach(mymenu    ,1,2,0,2,Gtk::FILL,Gtk::EXPAND)
			holder.attach(mainrouter,0,1,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL)
end
@holder.attach(SB.instance,0,2,3,4,Gtk::FILL,Gtk::FILL)
add(holder)
show_all
Gtk.show_thread_changes
mymenu.update(mymenu.last)
Messaging.instance.check_messages
 rescue  => err
	tell_exception("error occured",backtrace_to_debug(err),"main","warning")
	end
end

#shut_down?Boolean

Returns:

  • (Boolean)


121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/mywindow.rb', line 121

def shut_down?
	enormal("normal shutdown","main")
	if get_conf(0,0,"confirm-exit") == "true"
		warner=Gtk::MessageDialog.new(self,Gtk::Dialog::DESTROY_WITH_PARENT,Gtk::MessageDialog::QUESTION,Gtk::MessageDialog::BUTTONS_YES_NO,"quit")
		warner.set_image(Gtk::Image.new(Gtk::Stock::QUIT,Gtk::IconSize::DIALOG))
		ret=(warner.show_all.run == Gtk::Dialog::RESPONSE_YES)
		warner.destroy
	else
		ret=true
	end
	ret
end