topinambour 1.0.13 → 1.0.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f39664ed80b51cfc2df2f4210e4ee36e4ce8b2d4
4
- data.tar.gz: 649ba523bd608e16392ac95f920ce614e46401b1
3
+ metadata.gz: a0096f33f7deda14242cf4d17ff738edcd8596a7
4
+ data.tar.gz: 3495922b871cf7a0b9bacab870c34452cafb21c9
5
5
  SHA512:
6
- metadata.gz: 84f94e1173d5fd2b5f2e4b5c1745dda97c845d90cf2b02786c2f83013812c4f51d53e9e1bacb26e1db32e7ea2da7bf4317bce25551e8103bd5fa18e9db3e142a
7
- data.tar.gz: 7d67ab78fd8d2e64176d510342688b385979a6a86ff77d93be18b546543ebaf21a7c588efffdaa0241284d5bc2c7211ecb6bb128d63fc7e1f72328e11ad9e785
6
+ metadata.gz: 82c72cf7a2ddbe9ded6b50c657587565752b0ee0647fc19be298e7b6b2176a755d93d7a7c910341ba1d1eb0c65dd0f143e0fa2afbbb966757a57741531aa74e5
7
+ data.tar.gz: aa040c19ca5f66c91a3d43be69e15bf7f7f876b5a8c7ebf712ef3bbb45a8fdc0213eb69de618affc1a59ce68a703f9a843127f8deeabef3eb97ba46a310d2568
data/README.md CHANGED
@@ -135,8 +135,10 @@ the ruby gem binaries (for example).
135
135
 
136
136
  export PATH="${PATH}:/home/${USER}/bin:${HOME}/gem/ruby/2.3.0/bin"
137
137
 
138
-
139
-
138
+ ## TODOs
139
+ * find out why there is the warning message related to the Vte::Regex.
140
+ * http://www.pcre.org/current/doc/html/pcre2.html
141
+ * https://www.regexbuddy.com/pcre.html
140
142
  ## Old version (before 1.0.11)
141
143
 
142
144
  <a href="https://raw.github.com/cedlemo/topinambour/master/terminal_selector_screen.gif"><img src="https://raw.github.com/cedlemo/topinambour/master/terminal_selector_screen.gif" style="width:576px;height:324px;" alt="Color selection gif"></a>
@@ -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
@@ -33,8 +33,7 @@ class TopinambourFontSelector < Gtk::Box
33
33
  font_button.use_font = true
34
34
  font_button.use_size = false
35
35
  font_button.signal_connect "font-set" do
36
- font_desc = Pango::FontDescription.new(font_button.font_name)
37
- @window.notebook.current.term.font = font_desc
36
+ @window.notebook.current.term.font = font_button.font_name
38
37
  end
39
38
  pack_start(font_button, :expand => false, :fill => false, :padding => 0)
40
39
 
@@ -86,7 +86,7 @@ class TopinambourNotebook < Gtk::Notebook
86
86
  w, h)
87
87
  cr = Cairo::Context.new(surface)
88
88
  current.term.draw(cr)
89
- pix = surface.to_pixbuf(0, 0, w, h)
89
+ pix = surface.to_pixbuf(:src_x => 0, :src_y => 0, :width => w, :height => h)
90
90
  current.term.preview = pix if pix
91
91
  end
92
92
 
@@ -91,7 +91,8 @@ class TopinambourTerminal < Vte::Terminal
91
91
  end
92
92
 
93
93
  def font=(font_str)
94
- application.settings["font"] = Pango::FontDescription.new(font_str)
94
+ application.settings["font"] = font_str
95
+ font = Pango::FontDescription.new(font_str)
95
96
  set_font(font)
96
97
  @font = font
97
98
  end
@@ -152,10 +153,20 @@ class TopinambourTerminal < Vte::Terminal
152
153
  :CSS_COLORS]
153
154
  @regexes.each do |name|
154
155
  regex_name = TopinambourRegex.const_get(name)
155
- flags = [GLib::RegexCompileFlags::OPTIMIZE,
156
- GLib::RegexCompileFlags::MULTILINE]
157
- regex = GLib::Regex.new(regex_name, :compile_options => flags)
158
- match_add_gregex(regex, 0)
156
+ flags = [:optimize,
157
+ :multiline]
158
+ if Vte::Regex
159
+ # PCRE2_UTF | PCRE2_NO_UTF_CHECK | PCRE2_MULTILINE
160
+ pcre2_utf = "0x00080000".to_i(16)
161
+ pcre2_no_utf_check = "0x40000000".to_i(16)
162
+ pcre2_multiline = "0x00000400".to_i(16)
163
+ flags = pcre2_utf | pcre2_no_utf_check | pcre2_multiline
164
+ regex = Vte::Regex.new(regex_name, flags, :for_match => true)
165
+ match_add_regex(regex, 0)
166
+ else
167
+ regex = GLib::Regex.new(regex_name, :compile_options => flags)
168
+ match_add_gregex(regex, 0)
169
+ end
159
170
  end
160
171
  end
161
172
 
@@ -94,6 +94,9 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
94
94
  @notebook.children.each_with_index do |child, i|
95
95
  row = generate_list_box_row(child.term, i)
96
96
  @listbox.insert(row, i)
97
+ row.close_button.signal_connect "clicked" do |widget|
98
+ close_button_action(widget)
99
+ end
97
100
  end
98
101
  current_row = @listbox.get_row_at_index(@notebook.current_page)
99
102
  @listbox.select_row(current_row)
@@ -104,217 +107,147 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
104
107
  @notebook.hidden.each_with_index do |child, i|
105
108
  row = generate_hidden_list_box_row(child.term, i)
106
109
  @listbox_hidden.insert(row, i)
110
+ row.close_button.signal_connect "clicked" do |widget|
111
+ close_button_action(widget)
112
+ end
107
113
  end
108
114
  end
109
115
 
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)
131
- add_drag_and_drop_functionalities(button)
132
- hbox.pack_start(button, :expand => false, :fill => false, :padding => 6)
133
- label = generate_label(term)
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
138
- end
139
-
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
116
+ def close_button_action(button)
117
+ row = button.parent.parent
118
+ listbox = row.parent
119
+ if listbox == @listbox
120
+ tab = @notebook.get_nth_page(row.index)
121
+ @notebook.n_pages == 1 ? @window.quit_gracefully : @notebook.remove(tab)
122
+ row.destroy
123
+ update_tabs_num_labels
124
+ elsif listbox == @listbox_hidden
125
+ @notebook.hidden.delete_at(row.index)
126
+ row.destroy
127
+ update_tabs_num_labels
147
128
  end
148
- button
149
129
  end
150
130
 
151
- def leaning_label(index)
152
- label = Gtk::Label.new("tab. #{index + 1}")
153
- label.angle = 45
154
- label
131
+ def generate_list_box_row(term, index)
132
+ list_box_row = ChooserListRow.new(term, index, @notebook)
133
+ generate_hide_button(list_box_row)
155
134
  end
156
135
 
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
136
+ def generate_hidden_list_box_row(term, index)
137
+ list_box_row = ChooserListRow.new(term, index, @notebook)
138
+ generate_show_button(list_box_row)
166
139
  end
167
140
 
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
141
+ def generate_show_button(list_box_row)
142
+ list_box_row.generate_new_action_button("Show")
143
+ list_box_row.action_button.signal_connect "clicked" do
144
+ tab_num = list_box_row.index
145
+ @window.notebook.unhide(tab_num)
146
+ list_box_row_bkp = generate_hide_button(list_box_row)
147
+ @listbox_hidden.remove(list_box_row)
148
+ @listbox.insert(list_box_row_bkp, -1)
149
+ update_tabs_num_labels
150
+ end
151
+ list_box_row
174
152
  end
175
153
 
176
154
  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
155
+ list_box_row.generate_new_action_button("Hide")
156
+ list_box_row.action_button.signal_connect "clicked" do
181
157
  num = list_box_row.index
182
158
  @notebook.n_pages == 1 ? @window.quit_gracefully : @notebook.hide(num)
183
- list_box_row_bkp = change_button_hide_to_show(list_box_row)
159
+ list_box_row_bkp = generate_show_button(list_box_row)
184
160
  @listbox.remove(list_box_row)
185
161
  @listbox_hidden.insert(list_box_row_bkp, -1)
186
162
  update_tabs_num_labels
187
163
  end
188
- button
164
+ list_box_row
189
165
  end
190
166
 
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
167
+ def update_tabs_num_labels
168
+ @listbox.children.each_with_index do |row, i|
169
+ hbox = row.children[0]
170
+ label = hbox.children[0]
171
+ label.text = "tab. #{i + 1}"
202
172
  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
173
+ update_hidden_tabs_num_labels
228
174
  end
229
175
 
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
176
+ def update_hidden_tabs_num_labels
177
+ @listbox_hidden.children.each_with_index do |row, i|
178
+ hbox = row.children[0]
179
+ label = hbox.children[0]
180
+ label.text = "tab. #{i + 1}"
239
181
  end
240
- button
241
182
  end
183
+ end
242
184
 
243
- def add_label_popup_entry_icon_release(entry, label, term)
244
- entry.signal_connect "icon-release" do |widget, position|
245
- if position == :secondary
246
- term.custom_title = nil
247
- label.text = term.window_title
248
- term.toplevel.current_label.text = label.text
249
- widget.buffer.text = label.text
250
- end
251
- end
185
+ class ChooserListRow < Gtk::ListBoxRow
186
+ attr_reader :close_button
187
+ def initialize(term, index, notebook)
188
+ super()
189
+ @notebook = notebook
190
+ @hbox = Gtk::Box.new(:horizontal, 6)
191
+ fill_hbox_list_box_row(term, index)
192
+ generate_action_button
193
+ add(@hbox)
252
194
  end
253
195
 
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
196
+ def action_button
197
+ @hbox.children[4]
260
198
  end
261
199
 
262
- def generate_label_popup(label, event, term)
263
- entry = initialize_entry_popup(label)
264
- pp = Gtk::Popover.new
265
- add_label_popup_entry_activate_signal(entry, pp, label, term)
266
- add_label_popup_entry_icon_release(entry, label, term)
267
- pp.add(entry)
268
- set_popup_position(pp, label, event)
200
+ def generate_new_action_button(label)
201
+ button = Gtk::Button.new(:label => label)
202
+ button.valign = :center
203
+ button.vexpand = false
204
+ @hbox.remove(action_button)
205
+ @hbox.pack_start(button,
206
+ :expand => false, :fill => false, :padding => 6)
207
+ show_all
269
208
  end
270
209
 
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
210
+ private
278
211
 
279
- def set_popup_position(popup, label, event)
280
- x, y = event.window.coords_to_parent(event.x, event.y)
281
- rect = Gdk::Rectangle.new(x - label.allocation.x, y - label.allocation.y,
282
- 1, 1)
283
- popup.pointing_to = rect
284
- popup.relative_to = label
285
- popup.show_all
212
+ def fill_hbox_list_box_row(term, index)
213
+ label = leaning_label(index)
214
+ @hbox.pack_start(label, :expand => false, :fill => false, :padding => 6)
215
+ @prev_button = generate_preview_button(term)
216
+ add_drag_and_drop_functionalities
217
+ @hbox.pack_start(@prev_button, :expand => false, :fill => false, :padding => 6)
218
+ label = EditableLabel.new(term)
219
+ @hbox.pack_start(label, :expand => true, :fill => false, :padding => 6)
220
+ generate_close_button
221
+ @hbox.pack_start(@close_button, :expand => false, :fill => false, :padding => 6)
222
+ @hbox
286
223
  end
287
224
 
288
- def generate_label(term)
289
- label = Gtk::Label.new(term.terminal_title)
290
- label.halign = :start
291
- label.selectable = true
292
- label.signal_connect "button-release-event" do |w, e|
293
- generate_label_popup(w, e, term)
294
- end
225
+ def leaning_label(index)
226
+ label = Gtk::Label.new("tab. #{index + 1}")
227
+ label.angle = 45
295
228
  label
296
229
  end
297
230
 
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}"
231
+ def generate_preview_button(child)
232
+ button = Gtk::Button.new
233
+ button.image = generate_preview_image(child.preview)
234
+ button.signal_connect("clicked") do
235
+ @notebook.current_page = index parent.class == Gtk::ListBox
303
236
  end
304
- update_hidden_tabs_num_labels
237
+ button
305
238
  end
306
239
 
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}"
312
- end
240
+ def generate_preview_image(pixbuf)
241
+ # scaled_pix = pixbuf.scale(150, 75, :bilinear)
242
+ scaled_pix = pixbuf.scale(200, 100, :bilinear)
243
+ img = Gtk::Image.new(:pixbuf => scaled_pix)
244
+ img.show
245
+ img
313
246
  end
314
247
 
315
- def add_drag_and_drop_functionalities(button)
316
- add_dnd_source(button)
317
- add_dnd_destination(button)
248
+ def add_drag_and_drop_functionalities
249
+ add_dnd_source(@prev_button)
250
+ add_dnd_destination(@prev_button)
318
251
  end
319
252
 
320
253
  def add_dnd_source(button)
@@ -382,13 +315,83 @@ class TopinambourTermChooser < Gtk::ScrolledWindow
382
315
  end
383
316
 
384
317
  def drag_image_and_reorder_terms(src_index, dest_index)
385
- dragged = @window.notebook.get_nth_page(src_index)
386
- @window.notebook.reorder_child(dragged, dest_index)
387
- @window.notebook.children.each_with_index do |child, i|
318
+ dragged = @notebook.get_nth_page(src_index)
319
+ @notebook.reorder_child(dragged, dest_index)
320
+ @notebook.children.each_with_index do |child, i|
388
321
  list_box_row = @listbox.get_row_at_index(i)
389
322
  row_h_box = list_box_row.children[0]
390
323
  row_h_box.children[1].image = generate_preview_image(child.term.preview)
391
324
  row_h_box.children[2].text = child.term.terminal_title
392
325
  end
393
326
  end
327
+
328
+ def generate_close_button
329
+ @close_button = Gtk::Button.new(:icon_name => "window-close-symbolic",
330
+ :size => :button)
331
+ @close_button.relief = :none
332
+ end
333
+
334
+ def generate_action_button
335
+ action_button = Gtk::Button.new(:label => "")
336
+ action_button.valign = :center
337
+ action_button.vexpand = false
338
+ @hbox.pack_start(action_button,
339
+ :expand => false, :fill => false, :padding => 6)
340
+ end
341
+ end
342
+
343
+ class EditableLabel < Gtk::Label
344
+ def initialize(term)
345
+ super(term.terminal_title)
346
+ set_halign(:start)
347
+ set_selectable(true)
348
+ signal_connect "button-release-event" do |w, e|
349
+ generate_label_popup(w, e, term)
350
+ end
351
+ label
352
+ end
353
+
354
+ def generate_label_popup(label, event, term)
355
+ initialize_entry_popup(label)
356
+ @popup = Gtk::Popover.new
357
+ add_label_popup_entry_activate_signal(label, term)
358
+ add_label_popup_entry_icon_release(label, term)
359
+ @popup.add(@entry)
360
+ set_popup_position(label, event)
361
+ end
362
+
363
+ def initialize_entry_popup(label)
364
+ @entry = Gtk::Entry.new
365
+ @entry.max_width_chars = 50
366
+ @entry.buffer.text = label.text
367
+ @entry.set_icon_from_icon_name(:secondary, "edit-clear-symbolic")
368
+ end
369
+
370
+ def add_label_popup_entry_icon_release(label, term)
371
+ @entry.signal_connect "icon-release" do |widget, position|
372
+ if position == :secondary
373
+ term.custom_title = nil
374
+ label.text = term.window_title
375
+ term.toplevel.current_label.text = label.text
376
+ widget.buffer.text = label.text
377
+ end
378
+ end
379
+ end
380
+
381
+ def add_label_popup_entry_activate_signal(label, term)
382
+ @entry.signal_connect "activate" do |widget|
383
+ label.text = widget.buffer.text
384
+ term.custom_title = widget.buffer.text
385
+ @popup.destroy
386
+ end
387
+ end
388
+
389
+ def set_popup_position(label, event)
390
+ x, y = event.window.coords_to_parent(event.x, event.y)
391
+ rect = Gdk::Rectangle.new(x - label.allocation.x, y - label.allocation.y,
392
+ 1, 1)
393
+ @popup.pointing_to = rect
394
+ @popup.relative_to = label
395
+ @popup.show_all
396
+ end
394
397
  end
@@ -86,11 +86,11 @@ class TopinambourWindow < Gtk::ApplicationWindow
86
86
  Gtk::AboutDialog.show(self,
87
87
  "authors" => ["Cedric Le Moigne <cedlemo@gmx.com>"],
88
88
  "comments" => "Terminal Emulator based on the ruby bindings of Gtk3 and Vte3",
89
- "copyright" => "Copyright (C) 2015-2016 Cedric Le Moigne",
89
+ "copyright" => "Copyright (C) 2015-2017 Cedric Le Moigne",
90
90
  "license" => "This program is licenced under the licence GPL-3.0 and later.",
91
91
  "logo_icon_name" => "utilities-terminal-symbolic",
92
92
  "program_name" => "Topinambour",
93
- "version" => "1.0.13",
93
+ "version" => "1.0.14",
94
94
  "website" => "https://github.com/cedlemo/topinambour",
95
95
  "website_label" => "Topinambour github repository"
96
96
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topinambour
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cedric LE MOIGNE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-17 00:00:00.000000000 Z
11
+ date: 2017-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vte3
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.6.11
90
+ rubygems_version: 2.6.13
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Ruby-gnome2 Terminal emulator