topinambour 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2017 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -17,59 +17,227 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
17
17
  def initialize(window)
18
18
  super(nil, nil)
19
19
  @window = window
20
+ @notebook = @window.notebook
21
+ @notebook.generate_tab_preview
22
+ initialize_list_box
23
+ initialize_hidden_list_box
24
+ initialize_main_box
25
+ configure_window
26
+ end
27
+
28
+ private
29
+
30
+ def configure_window
20
31
  set_halign(:end)
21
32
  set_valign(:center)
22
33
  set_policy(:never, :automatic)
23
34
  set_name("terminal_chooser")
35
+ add(@box)
36
+ set_size_request(-1, @notebook.current.term.allocation.to_a[3] - 8)
37
+ end
24
38
 
25
- window.notebook.generate_tab_preview
26
- generate_grid
27
- fill_grid
28
-
39
+ def initialize_main_box
29
40
  @box = Gtk::Box.new(:vertical, 4)
30
41
  @box.name = "topinambour-overview-box"
31
- @box.pack_start(@grid, :expand => true, :fill => true, :padding => 4)
32
- add(@box)
33
- set_size_request(-1, @window.notebook.current.term.allocation.to_a[3] - 8)
42
+ @box.pack_start(main_title, :expand => false, :fill => true, :padding => 6)
43
+ @box.pack_start(@listbox, :expand => true, :fill => true, :padding => 12)
44
+ @box.pack_start(box_title("Hidden terminals"),
45
+ :expand => false, :fill => true, :padding => 6)
46
+ @box.pack_start(@listbox_hidden, :expand => true, :fill => true,
47
+ :padding => 12)
34
48
  end
35
49
 
36
- private
50
+ def main_title
51
+ hbox = Gtk::Box.new(:horizontal, 6)
52
+ hbox.pack_start(box_title("Terminals"),
53
+ :expand => true, :fill => true, :padding => 6)
54
+ hbox.pack_start(box_close_button,
55
+ :expand => false, :fill => false, :padding => 6)
56
+ hbox
57
+ end
37
58
 
38
- def generate_grid
39
- @grid = Gtk::Grid.new
40
- @grid.row_spacing = 4
41
- @grid.column_spacing = 6
59
+ def box_title(label)
60
+ title = Gtk::Label.new("> #{label} :")
61
+ title.halign = :start
62
+ title
42
63
  end
43
64
 
44
- def fill_grid
45
- @window.notebook.children.each_with_index do |child, i|
46
- generate_row_grid(child.term, i)
65
+ def box_close_button
66
+ button = Gtk::Button.new(:icon_name => "window-close-symbolic",
67
+ :size => :button)
68
+ button.relief = :none
69
+ button.signal_connect("clicked") { @window.exit_overlay_mode }
70
+ button
71
+ end
72
+
73
+ def initialize_list_box
74
+ @listbox = Gtk::ListBox.new
75
+ @listbox.margin = 12
76
+ @listbox.selection_mode = :single
77
+ fill_list_box
78
+ end
79
+
80
+ def initialize_hidden_list_box
81
+ @listbox_hidden = Gtk::ListBox.new
82
+ @listbox_hidden.placeholder = Gtk::Label.new("Hidden terminals")
83
+ @listbox_hidden.margin = 12
84
+ @listbox_hidden.show_all
85
+ @listbox_hidden.selection_mode = :single
86
+ fill_hidden_list_box
87
+ end
88
+
89
+ def fill_list_box
90
+ @listbox.signal_connect "row-selected" do |_list, row|
91
+ @notebook.current_page = row.nil? ? @notebook.children.size : row.index
92
+ end
93
+
94
+ @notebook.children.each_with_index do |child, i|
95
+ row = generate_list_box_row(child.term, i)
96
+ @listbox.insert(row, i)
97
+ end
98
+ current_row = @listbox.get_row_at_index(@notebook.current_page)
99
+ @listbox.select_row(current_row)
100
+ current_row.grab_focus
101
+ end
102
+
103
+ def fill_hidden_list_box
104
+ @notebook.hidden.each_with_index do |child, i|
105
+ row = generate_hidden_list_box_row(child.term, i)
106
+ @listbox_hidden.insert(row, i)
47
107
  end
48
- @grid.attach(generate_separator, 0, @window.notebook.n_pages, 2, 1)
49
- button = generate_quit_button
50
- @grid.attach(button, 0, @window.notebook.n_pages + 1, 2, 1)
51
108
  end
52
109
 
53
- def generate_row_grid(term, index)
54
- button = Gtk::Label.new("tab. #{index + 1}")
55
- button.angle = 45
56
- @grid.attach(button, 0, index, 1, 1)
57
- button = generate_preview_button(term, index)
58
- @grid.attach(button, 1, index, 1, 1)
110
+ def generate_list_box_row(term, index)
111
+ list_box_row = Gtk::ListBoxRow.new
112
+ hbox = _generate_hbox_list_box_row(list_box_row, term, index)
113
+ button = generate_hide_button(list_box_row)
114
+ hbox.pack_start(button, :expand => false, :fill => false, :padding => 6)
115
+ list_box_row.add(hbox)
116
+ end
117
+
118
+ def generate_hidden_list_box_row(term, index)
119
+ list_box_row = Gtk::ListBoxRow.new
120
+ hbox = _generate_hbox_list_box_row(list_box_row, term, index)
121
+ button = generate_show_button(list_box_row)
122
+ hbox.pack_start(button, :expand => false, :fill => false, :padding => 6)
123
+ list_box_row.add(hbox)
124
+ end
125
+
126
+ def _generate_hbox_list_box_row(list_box_row, term, index)
127
+ hbox = Gtk::Box.new(:horizontal, 6)
128
+ label = leaning_label(index)
129
+ hbox.pack_start(label, :expand => false, :fill => false, :padding => 6)
130
+ button = generate_preview_button(term, list_box_row)
59
131
  add_drag_and_drop_functionalities(button)
132
+ hbox.pack_start(button, :expand => false, :fill => false, :padding => 6)
60
133
  label = generate_label(term)
61
- @grid.attach(label, 2, index, 1, 1)
62
- button = generate_close_tab_button
63
- @grid.attach(button, 3, index, 1, 1)
134
+ hbox.pack_start(label, :expand => true, :fill => false, :padding => 6)
135
+ button = generate_hidden_list_box_row_close(list_box_row)
136
+ hbox.pack_start(button, :expand => false, :fill => false, :padding => 6)
137
+ hbox
64
138
  end
65
139
 
66
- def add_label_popup_entry_activate_signal(entry, popup, label, term)
67
- entry.signal_connect "activate" do |widget|
68
- label.text = widget.buffer.text
69
- term.custom_title = widget.buffer.text
70
- term.toplevel.current_label.text = widget.buffer.text
71
- popup.destroy
140
+ def generate_hidden_list_box_row_close(list_box_row)
141
+ button = Gtk::Button.new(:icon_name => "window-close-symbolic",
142
+ :size => :button)
143
+ button.relief = :none
144
+ button.signal_connect "clicked" do
145
+ @notebook.hidden.delete_at(list_box_row.index)
146
+ list_box_row.destroy
72
147
  end
148
+ button
149
+ end
150
+
151
+ def leaning_label(index)
152
+ label = Gtk::Label.new("tab. #{index + 1}")
153
+ label.angle = 45
154
+ label
155
+ end
156
+
157
+ def generate_preview_button(child, list_box_row)
158
+ button = Gtk::Button.new
159
+ button.image = generate_preview_image(child.preview)
160
+ button.signal_connect("clicked") do
161
+ if list_box_row.parent == @listbox
162
+ @notebook.current_page = list_box_row.index
163
+ end
164
+ end
165
+ button
166
+ end
167
+
168
+ def generate_preview_image(pixbuf)
169
+ # scaled_pix = pixbuf.scale(150, 75, :bilinear)
170
+ scaled_pix = pixbuf.scale(200, 100, :bilinear)
171
+ img = Gtk::Image.new(:pixbuf => scaled_pix)
172
+ img.show
173
+ img
174
+ end
175
+
176
+ def generate_hide_button(list_box_row)
177
+ button = Gtk::Button.new(:label => "Hide")
178
+ button.valign = :center
179
+ button.vexpand = false
180
+ button.signal_connect "clicked" do
181
+ num = list_box_row.index
182
+ @notebook.n_pages == 1 ? @window.quit_gracefully : @notebook.hide(num)
183
+ list_box_row_bkp = change_button_hide_to_show(list_box_row)
184
+ @listbox.remove(list_box_row)
185
+ @listbox_hidden.insert(list_box_row_bkp, -1)
186
+ update_tabs_num_labels
187
+ end
188
+ button
189
+ end
190
+
191
+ def generate_show_button(list_box_row)
192
+ button = Gtk::Button.new(:label => "Show")
193
+ button.valign = :center
194
+ button.vexpand = false
195
+ button.signal_connect "clicked" do
196
+ tab_num = list_box_row.index
197
+ @window.notebook.unhide(tab_num)
198
+ list_box_row_bkp = change_button_show_to_hide(list_box_row)
199
+ @listbox_hidden.remove(list_box_row)
200
+ @listbox.insert(list_box_row_bkp, -1)
201
+ update_tabs_num_labels
202
+ end
203
+ button
204
+ end
205
+
206
+ def change_button_hide_to_show(list_box_row)
207
+ list_box_row_bkp = list_box_row
208
+ container = list_box_row_bkp.children[0]
209
+ hide_button = list_box_row_bkp.children[0].children[4]
210
+ container.remove(hide_button)
211
+ show_button = generate_show_button(list_box_row_bkp)
212
+ show_button.show
213
+ container.pack_start(show_button,
214
+ :expand => false, :fill => false, :padding => 6)
215
+ list_box_row_bkp
216
+ end
217
+
218
+ def change_button_show_to_hide(list_box_row)
219
+ list_box_row_bkp = list_box_row
220
+ container = list_box_row_bkp.children[0]
221
+ show_button = list_box_row_bkp.children[0].children[4]
222
+ container.remove(show_button)
223
+ hide_button = generate_hide_button(list_box_row_bkp)
224
+ hide_button.show
225
+ container.pack_start(hide_button,
226
+ :expand => false, :fill => false, :padding => 6)
227
+ list_box_row_bkp
228
+ end
229
+
230
+ def generate_close_tab_button(list_box_row)
231
+ button = Gtk::Button.new(:icon_name => "window-close-symbolic",
232
+ :size => :button)
233
+ button.relief = :none
234
+ button.signal_connect "clicked" do
235
+ tab = @notebook.get_nth_page(list_box_row.index)
236
+ @notebook.n_pages == 1 ? @window.quit_gracefully : @notebook.remove(tab)
237
+ list_box_row.destroy
238
+ update_tabs_num_labels
239
+ end
240
+ button
73
241
  end
74
242
 
75
243
  def add_label_popup_entry_icon_release(entry, label, term)
@@ -83,22 +251,38 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
83
251
  end
84
252
  end
85
253
 
254
+ def add_label_popup_entry_activate_signal(entry, popup, label, term)
255
+ entry.signal_connect "activate" do |widget|
256
+ label.text = widget.buffer.text
257
+ term.custom_title = widget.buffer.text
258
+ popup.destroy
259
+ end
260
+ end
261
+
86
262
  def generate_label_popup(label, event, term)
87
- entry = Gtk::Entry.new
88
- entry.max_width_chars = 50
89
- entry.buffer.text = label.text
90
- entry.set_icon_from_icon_name(:secondary, "edit-clear")
263
+ entry = initialize_entry_popup(label)
91
264
  pp = Gtk::Popover.new
92
265
  add_label_popup_entry_activate_signal(entry, pp, label, term)
93
266
  add_label_popup_entry_icon_release(entry, label, term)
94
-
95
267
  pp.add(entry)
268
+ set_popup_position(pp, label, event)
269
+ end
270
+
271
+ def initialize_entry_popup(label)
272
+ entry = Gtk::Entry.new
273
+ entry.max_width_chars = 50
274
+ entry.buffer.text = label.text
275
+ entry.set_icon_from_icon_name(:secondary, "edit-clear-symbolic")
276
+ entry
277
+ end
278
+
279
+ def set_popup_position(popup, label, event)
96
280
  x, y = event.window.coords_to_parent(event.x, event.y)
97
281
  rect = Gdk::Rectangle.new(x - label.allocation.x, y - label.allocation.y,
98
282
  1, 1)
99
- pp.pointing_to = rect
100
- pp.relative_to = label
101
- pp.show_all
283
+ popup.pointing_to = rect
284
+ popup.relative_to = label
285
+ popup.show_all
102
286
  end
103
287
 
104
288
  def generate_label(term)
@@ -111,69 +295,23 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
111
295
  label
112
296
  end
113
297
 
114
- def generate_close_tab_button
115
- button = Gtk::EventBox.new
116
- button.tooltip_text = "Close Tab"
117
- image = Gtk::Image.new(:icon_name => "window-close-symbolic",
118
- :size => :button)
119
- button.add(image)
120
- button.hexpand = false
121
- button.vexpand = false
122
- button.valign = :start
123
- button.halign = :center
124
- button.signal_connect "button_press_event" do
125
- n = @grid.child_get_property(button, "top-attach")
126
- tab = @window.notebook.get_nth_page(n)
127
- if @window.notebook.n_pages == 1
128
- @window.quit_gracefully
129
- else
130
- remove_tab(tab, n)
131
- end
298
+ def update_tabs_num_labels
299
+ @listbox.children.each_with_index do |row, i|
300
+ hbox = row.children[0]
301
+ label = hbox.children[0]
302
+ label.text = "tab. #{i + 1}"
132
303
  end
133
- button
304
+ update_hidden_tabs_num_labels
134
305
  end
135
306
 
136
- def remove_tab(tab, n)
137
- @window.notebook.remove(tab)
138
- @grid.remove_row(n)
139
- last_tab = @window.notebook.n_pages - 1
140
- update_tab_num_label(n..last_tab)
141
- end
142
-
143
- def update_tab_num_label(range)
144
- range.each do |j|
145
- @grid.get_child_at(0, j).text = "tab. #{(j + 1)}"
307
+ def update_hidden_tabs_num_labels
308
+ @listbox_hidden.children.each_with_index do |row, i|
309
+ hbox = row.children[0]
310
+ label = hbox.children[0]
311
+ label.text = "tab. #{i + 1}"
146
312
  end
147
313
  end
148
314
 
149
- def generate_preview_button(child, i)
150
- button = Gtk::Button.new
151
- button.image = generate_preview_image(child.preview)
152
- button.signal_connect("clicked") { @window.notebook.current_page = i }
153
- button
154
- end
155
-
156
- def generate_preview_image(pixbuf)
157
- scaled_pix = pixbuf.scale(150, 75, :bilinear)
158
- img = Gtk::Image.new(:pixbuf => scaled_pix)
159
- img.show
160
- img
161
- end
162
-
163
- def generate_separator
164
- Gtk::Separator.new(:horizontal)
165
- end
166
-
167
- def generate_quit_button
168
- button = Gtk::EventBox.new
169
- button.tooltip_text = "Quit Topinambour"
170
- image = Gtk::Image.new(:icon_name => "application-exit-symbolic",
171
- :size => :dialog)
172
- button.add(image)
173
- button.signal_connect("button_press_event") { @window.quit_gracefully }
174
- button
175
- end
176
-
177
315
  def add_drag_and_drop_functionalities(button)
178
316
  add_dnd_source(button)
179
317
  add_dnd_destination(button)
@@ -182,7 +320,7 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
182
320
  def add_dnd_source(button)
183
321
  button.drag_source_set(Gdk::ModifierType::BUTTON1_MASK |
184
322
  Gdk::ModifierType::BUTTON2_MASK,
185
- [["test", Gtk::TargetFlags::SAME_APP, 12_345]],
323
+ [["drag_term", Gtk::TargetFlags::SAME_APP, 12_345]],
186
324
  Gdk::DragAction::COPY |
187
325
  Gdk::DragAction::MOVE)
188
326
  # Drag source signals
@@ -198,7 +336,7 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
198
336
  end
199
337
 
200
338
  button.signal_connect("drag-data-get") do |widget, _, selection_data, _, _|
201
- index = grid_line_of(widget)
339
+ index = widget.parent.parent.index
202
340
  selection_data.set(Gdk::Selection::TYPE_INTEGER, index.to_s)
203
341
  end
204
342
  # button.signal_connect "drag-data-delete" do
@@ -212,7 +350,7 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
212
350
  def add_dnd_destination(button)
213
351
  button.drag_dest_set(Gtk::DestDefaults::MOTION |
214
352
  Gtk::DestDefaults::HIGHLIGHT,
215
- [["test", :same_app, 12_345]],
353
+ [["drag_term", :same_app, 12_345]],
216
354
  Gdk::DragAction::COPY |
217
355
  Gdk::DragAction::MOVE)
218
356
 
@@ -229,10 +367,11 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
229
367
  end
230
368
 
231
369
  button.signal_connect("drag-data-received") do |widget, context, _x, _y, selection_data|
232
- index = grid_line_of(widget)
370
+ index = widget.parent.parent.index
233
371
  index_of_dragged_object = index
234
372
  context.targets.each do |target|
235
- next unless target.name == "test" || selection_data.type == :type_integer
373
+ next unless target.name == "drag_term" ||
374
+ selection_data.type == :type_integer
236
375
  data_len = selection_data.data.size
237
376
  index_of_dragged_object = selection_data.data.pack("C#{data_len}").to_i
238
377
  end
@@ -246,12 +385,10 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
246
385
  dragged = @window.notebook.get_nth_page(src_index)
247
386
  @window.notebook.reorder_child(dragged, dest_index)
248
387
  @window.notebook.children.each_with_index do |child, i|
249
- @grid.get_child_at(1, i).image = generate_preview_image(child.term.preview)
250
- @grid.get_child_at(2, i).label = child.term.terminal_title
388
+ list_box_row = @listbox.get_row_at_index(i)
389
+ row_h_box = list_box_row.children[0]
390
+ row_h_box.children[1].image = generate_preview_image(child.term.preview)
391
+ row_h_box.children[2].text = child.term.terminal_title
251
392
  end
252
393
  end
253
-
254
- def grid_line_of(widget)
255
- @grid.child_get_property(widget, "top-attach")
256
- end
257
394
  end
data/lib/window.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2017 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -14,14 +14,13 @@
14
14
  # You should have received a copy of the GNU General Public License
15
15
  # along with Topinambour. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
- class TopinambourWindow
17
+ class TopinambourWindow < Gtk::ApplicationWindow
18
18
  attr_reader :notebook, :bar, :overlay, :current_label, :current_tab
19
- attr_accessor :shell
20
19
  def initialize(application)
21
- super(:application => application)
20
+ super(application)
22
21
  set_icon_name("utilities-terminal-symbolic")
23
22
  set_name("topinambour-window")
24
- load_properties
23
+ load_settings
25
24
  set_position(:center)
26
25
  create_header_bar
27
26
  create_containers
@@ -29,20 +28,19 @@ class TopinambourWindow
29
28
  signal_connect "key-press-event" do |widget, event|
30
29
  TopinambourShortcuts.handle_key_press(widget, event)
31
30
  end
32
- signal_connect "scroll-event" do |widget, event|
33
- TopinambourShortcuts.handle_scroll(widget, event)
34
- end
35
31
  end
36
32
 
37
- def add_terminal(cmd = @shell)
33
+ def add_terminal(cmd = nil)
34
+ cmd = cmd || application.settings["default-shell"]
35
+
38
36
  exit_overlay_mode
39
37
  working_dir = nil
40
38
  working_dir = @notebook.current.term.pid_dir if @notebook.current
41
-
42
39
  terminal = TopinambourTabTerm.new(cmd, working_dir)
43
40
  terminal.show_all
44
41
 
45
42
  @notebook.append_page(terminal)
43
+ terminal.term.load_settings
46
44
  @notebook.set_tab_reorderable(terminal, true)
47
45
  @notebook.set_page(@notebook.n_pages - 1)
48
46
  @notebook.current.term.grab_focus
@@ -78,10 +76,6 @@ class TopinambourWindow
78
76
  toggle_overlay(TopinambourTermChooser)
79
77
  end
80
78
 
81
- def show_terminal_chooser2
82
- toggle_overlay(TopinambourTermChooserb)
83
- end
84
-
85
79
  def exit_overlay_mode
86
80
  @overlay.children[1].destroy if in_overlay_mode?
87
81
  end
@@ -94,7 +88,7 @@ class TopinambourWindow
94
88
  "license" => "This program is licenced under the licence GPL-3.0 and later.",
95
89
  "logo_icon_name" => "utilities-terminal-symbolic",
96
90
  "program_name" => "Topinambour",
97
- "version" => "1.0.11",
91
+ "version" => "1.0.12",
98
92
  "website" => "https://github.com/cedlemo/topinambour",
99
93
  "website_label" => "Topinambour github repository"
100
94
  )
@@ -126,8 +120,22 @@ class TopinambourWindow
126
120
  end
127
121
  end
128
122
 
123
+ def show_shortcuts
124
+ resource_file = "/com/github/cedlemo/topinambour/shortcuts.ui"
125
+ builder = Gtk::Builder.new(:resource => resource_file)
126
+ shortcuts_win = builder["shortcuts-window"]
127
+ shortcuts_win.transient_for = self
128
+ shortcuts_win.show
129
+ end
130
+
129
131
  private
130
132
 
133
+ def load_settings
134
+ height = application.settings["height"]
135
+ width = application.settings["width"]
136
+ resize(width, height)
137
+ end
138
+
131
139
  def add_overlay(widget)
132
140
  @overlay.add_overlay(widget)
133
141
  @overlay.set_overlay_pass_through(widget, false)
@@ -146,13 +154,17 @@ class TopinambourWindow
146
154
  headerbar = builder["headerbar"]
147
155
  headerbar.name = "topinambour-headerbar"
148
156
  set_titlebar(headerbar)
157
+ # Text is modified when notebook switch tabs or
158
+ # Vte::Terminal command change and if it is the current Vte.
149
159
  @current_label = builder["current_label"]
150
160
  current_label_signals
161
+ # Value is changed when notebook switch tabs or notebook add tab.
151
162
  @current_tab = builder["current_tab"]
163
+ headerbar.remove(@current_label)
164
+ headerbar.custom_title = @current_label
152
165
  next_prev_new_signals(builder)
153
- overview_font_color_signals(builder)
166
+ overview_signal(builder)
154
167
  main_menu_signal(builder)
155
- reload_css_conf_signal(builder)
156
168
  end
157
169
 
158
170
  def current_label_signals
@@ -162,9 +174,7 @@ class TopinambourWindow
162
174
  end
163
175
 
164
176
  @current_label.signal_connect "icon-release" do |entry, position|
165
- if position == :primary
166
- close_current_tab
167
- elsif position == :secondary
177
+ if position == :secondary
168
178
  @notebook.current.term.custom_title = nil
169
179
  entry.text = @notebook.current.term.window_title
170
180
  end
@@ -185,44 +195,35 @@ class TopinambourWindow
185
195
  end
186
196
  end
187
197
 
188
- def overview_font_color_signals(builder)
198
+ def overview_signal(builder)
189
199
  builder["term_overv_button"].signal_connect "clicked" do
190
200
  show_terminal_chooser
191
201
  end
192
-
193
- builder["font_sel_button"].signal_connect "clicked" do
194
- show_font_selector
195
- end
196
-
197
- builder["colors_sel_button"].signal_connect "clicked" do
198
- show_color_selector
199
- end
200
202
  end
201
203
 
202
204
  def main_menu_signal(builder)
203
- builder["menu_button"].signal_connect "clicked" do |button|
204
- ui_file = "/com/github/cedlemo/topinambour/window-menu.ui"
205
- winmenu = Gtk::Builder.new(:resource => ui_file)["winmenu"]
206
- event = Gtk.current_event
207
- menu = Gtk::Popover.new(button, winmenu)
208
- x, y = event.window.coords_to_parent(event.x,
209
- event.y)
210
- rect = Gdk::Rectangle.new(x - button.allocation.x,
211
- y - button.allocation.y,
212
- 1, 1)
213
- menu.set_pointing_to(rect)
214
- menu.show
215
- end
205
+ button = builder["menu_button"]
206
+ ui_file = "/com/github/cedlemo/topinambour/main-menu-popover.ui"
207
+ menu_builder = Gtk::Builder.new(:resource => ui_file)
208
+ main_menu = menu_builder["main_menu_popover"]
209
+ button.set_popover(main_menu)
210
+ button.popover.modal = true
211
+ add_theme_menu_buttons_signals(menu_builder)
216
212
  end
217
213
 
218
- def reload_css_conf_signal(builder)
219
- button = builder["css_reload_button"]
220
- button.signal_connect "clicked" do
214
+ def add_theme_menu_buttons_signals(builder)
215
+ builder["css_reload_button"].signal_connect "clicked" do
221
216
  application.reload_css_config
222
- notebook.each { |tab| tab.term.load_properties }
223
- load_properties
224
217
  queue_draw
225
218
  end
219
+
220
+ builder["font_sel_button"].signal_connect "clicked" do
221
+ show_font_selector
222
+ end
223
+
224
+ builder["colors_sel_button"].signal_connect "clicked" do
225
+ show_color_selector
226
+ end
226
227
  end
227
228
 
228
229
  def toggle_overlay(klass)