-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmikutter-hide-ui.rb
165 lines (124 loc) · 3.3 KB
/
mikutter-hide-ui.rb
1
2
3
4
5
6
7
8
9
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
61
62
63
64
65
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# -*- coding: utf-8 -*-
Plugin.create :test do
on_boot do |service|
UserConfig[:hide_ui_postbox] = true if UserConfig[:hide_ui_postbox].nil?
UserConfig[:hide_ui_tab] = true if UserConfig[:hide_ui_tab].nil?
UserConfig[:hide_ui_statusbar] = true if UserConfig[:hide_ui_statusbar].nil?
end
on_window_created do |i_window|
begin
# メインウインドウを取得
window_tmp = Plugin.filtering(:gui_get_gtk_widget,i_window)
if (window_tmp == nil) || (window_tmp[0] == nil) then
next
end
window = window_tmp[0]
prev_pos = nil
monitering = false
active = true
# 終了モニタ
monitor = lambda {
if monitering
next
end
monitering = true
if !mouse_in_window?(window)
furo_futa(window, false)
else
Reserver.new(1, &monitor)
end
monitering = false
}
window.ssc("enter-notify-event") {
if active
furo_futa(window, true)
end
# 消去モニタ
monitor.call
false
}
window.ssc("focus-in-event"){
active = true
# 表示する
furo_futa(window, true)
# 消去モニタ
monitor.call
false
}
window.ssc("focus-out-event"){
active = false
false
}
rescue => e
puts e
puts e.backtrace
end
end
settings "隠す" do
boolean("ポストボックスを隠す", :hide_ui_postbox)
boolean("タブを隠す", :hide_ui_tab)
boolean("ステータスバーを隠す", :hide_ui_statusbar)
end
def mouse_in_window?(window)
size = window.window.size
pos = window.window.pointer
# pos = ::Gdk::Display.default.pointer
(((pos[1] >= 0) && (pos[1] <= size[0])) && ((pos[2] >= 0) && (pos[2] <= size[1])))
end
def furo_futa(window, show)
begin
result = get_all_widgets(window, ::Gtk::Notebook)
result.each { |notebook|
notebook.show_tabs = (show || !UserConfig[:hide_ui_tab])
}
result = get_all_widgets(window, ::Gtk::PostBox)
postbox_available = result.length != 0
result.each { |postbox|
if show || !UserConfig[:hide_ui_postbox]
postbox.show_all
else
postbox.hide_all
end
}
if defined?(::Gtk::AccountBox) && postbox_available
result = get_all_widgets(window, ::Gtk::AccountBox)
result.each { |accountbox|
if show || !UserConfig[:hide_ui_postbox]
accountbox.show_all
else
accountbox.hide_all
end
}
end
result = get_all_widgets(window, ::Gtk::Statusbar)
result.each { |statusbar|
if show || !UserConfig[:hide_ui_statusbar]
statusbar.show_all
else
statusbar.hide_all
end
}
rescue => e
puts e
puts e.backtrace
end
end
def get_all_widgets(root, klass)
proc = lambda { |widget|
result = []
begin
widget.each_forall { |child|
if child.is_a?(klass)
result << child
end
if child.is_a?(::Gtk::Container)
result += proc.call(child)
end
}
rescue => e
end
result
}
proc.call(root)
end
end