reterm 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/designer/src/ComponentParams.rb +89 -42
  3. data/designer/src/ComponentsList.rb +26 -25
  4. data/designer/src/CreatedList.rb +9 -0
  5. data/designer/src/Designer.rb +23 -1
  6. data/designer/src/ToggleArea.rb +20 -3
  7. data/designer/src/about.rb +35 -0
  8. data/designer/src/component_factory.rb +18 -0
  9. data/designer/src/component_map.rb +7 -0
  10. data/designer/src/file_chooser.rb +25 -0
  11. data/designer/src/glade/Designer.glade +1 -19
  12. data/designer/src/images/{slist.png → scroll_list.png} +0 -0
  13. data/lib/reterm.rb +10 -1
  14. data/lib/reterm/color_pair.rb +166 -10
  15. data/lib/reterm/component.rb +89 -2
  16. data/lib/reterm/components.rb +16 -1
  17. data/lib/reterm/components/alphalist.rb +45 -0
  18. data/lib/reterm/components/ascii_text.rb +14 -1
  19. data/lib/reterm/components/asciimator.rb +1 -0
  20. data/lib/reterm/components/button.rb +35 -5
  21. data/lib/reterm/components/button_box.rb +108 -0
  22. data/lib/reterm/components/close_button.rb +22 -0
  23. data/lib/reterm/components/cmd_output.rb +69 -0
  24. data/lib/reterm/components/dial.rb +11 -2
  25. data/lib/reterm/components/dialog.rb +41 -1
  26. data/lib/reterm/components/drop_down_menu.rb +140 -0
  27. data/lib/reterm/components/entry.rb +42 -14
  28. data/lib/reterm/components/histogram.rb +55 -0
  29. data/lib/reterm/components/hslider.rb +9 -0
  30. data/lib/reterm/components/image.rb +9 -0
  31. data/lib/reterm/components/isometric.rb +38 -0
  32. data/lib/reterm/components/label.rb +20 -3
  33. data/lib/reterm/components/matrix.rb +9 -0
  34. data/lib/reterm/components/multi_line_entry.rb +54 -0
  35. data/lib/reterm/components/password_entry.rb +15 -0
  36. data/lib/reterm/components/radio.rb +10 -0
  37. data/lib/reterm/components/revealing_label.rb +126 -0
  38. data/lib/reterm/components/rocker.rb +21 -11
  39. data/lib/reterm/components/scroll_list.rb +96 -0
  40. data/lib/reterm/components/scrolling_area.rb +50 -0
  41. data/lib/reterm/components/select_list.rb +67 -0
  42. data/lib/reterm/components/splash.rb +85 -0
  43. data/lib/reterm/components/template.rb +12 -1
  44. data/lib/reterm/components/treeview.rb +1 -0
  45. data/lib/reterm/components/vslider.rb +11 -2
  46. data/lib/reterm/components/youtube.rb +20 -0
  47. data/lib/reterm/config.rb +22 -0
  48. data/lib/reterm/init.rb +131 -6
  49. data/lib/reterm/layout.rb +147 -11
  50. data/lib/reterm/layouts.rb +1 -0
  51. data/lib/reterm/layouts/grid.rb +69 -0
  52. data/lib/reterm/layouts/horizontal.rb +25 -4
  53. data/lib/reterm/layouts/vertical.rb +26 -5
  54. data/lib/reterm/loader.rb +2 -2
  55. data/lib/reterm/mixins/button_helpers.rb +7 -0
  56. data/lib/reterm/mixins/cdk_component.rb +66 -2
  57. data/lib/reterm/mixins/common_controls.rb +15 -0
  58. data/lib/reterm/mixins/common_keys.rb +20 -0
  59. data/lib/reterm/mixins/component_input.rb +62 -14
  60. data/lib/reterm/mixins/event_dispatcher.rb +2 -0
  61. data/lib/reterm/mixins/item_helpers.rb +8 -0
  62. data/lib/reterm/mixins/key_bindings.rb +23 -0
  63. data/lib/reterm/mixins/log_helpers.rb +13 -0
  64. data/lib/reterm/mixins/mouse_input.rb +58 -0
  65. data/lib/reterm/mixins/nav_controls.rb +33 -0
  66. data/lib/reterm/mixins/nav_input.rb +161 -69
  67. data/lib/reterm/terminal.rb +6 -2
  68. data/lib/reterm/util.rb +121 -0
  69. data/lib/reterm/version.rb +1 -1
  70. data/lib/reterm/window.rb +295 -29
  71. metadata +33 -17
  72. data/designer/src/images/orig/Check.png +0 -0
  73. data/designer/src/images/orig/ascii_text.png +0 -0
  74. data/designer/src/images/orig/button.png +0 -0
  75. data/designer/src/images/orig/dial.png +0 -0
  76. data/designer/src/images/orig/entry.png +0 -0
  77. data/designer/src/images/orig/hslider.png +0 -0
  78. data/designer/src/images/orig/label.png +0 -0
  79. data/designer/src/images/orig/matrix.png +0 -0
  80. data/designer/src/images/orig/radio.png +0 -0
  81. data/designer/src/images/orig/rocker.png +0 -0
  82. data/designer/src/images/orig/slist.png +0 -0
  83. data/designer/src/images/orig/vslider.png +0 -0
  84. data/lib/reterm/components/slist.rb +0 -32
  85. data/lib/reterm/menu.rb +0 -81
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8eccbffc9e67c0b58c4ecce6689ed983192fdfc
4
- data.tar.gz: fa932fa439231e95d1bb945c33a3e760da491f4a
3
+ metadata.gz: 4a718fe1f9ad7dbe389aaba371d9456c88957cbb
4
+ data.tar.gz: 1deb434bf5d7296cbcf7c2dd12a277490241ddec
5
5
  SHA512:
6
- metadata.gz: 45677b6521f05935d939bac79b2ab237508ce109cf177868a69136f89cfb0993fa3404202b87d0c90cc2734439250db8a00401c4509b5eb7ddabcb0128ddc282
7
- data.tar.gz: 5800ed5af8c81a8909a3ce6f50a4ee7fba3db37bfd932a14d927fba956accb60d1b603cf196a2e5e9105ab748072f1d5d53b460a707f1e9c914ecccf08376c1f
6
+ metadata.gz: caeaaef04e95b928996a7e11fb49478a3b6a4365a3ede393fe6f434f24ca562e9a477a4cdfedb6a15ed44d65fc5b6bd8df754e6cbd92dc245dc8fa2b920fa1eb
7
+ data.tar.gz: d98622a223979d12bdc27c50df65ecfdd728d455fa2d2524022eb1d3cf734f619c889e9252fcb9d5dc6d30916b062b8c25a000ffc3eace21f1ee0d26040b9d80
@@ -18,66 +18,106 @@ class ComponentParams
18
18
  end
19
19
 
20
20
  def before_show
21
+ set_title
22
+ add_component_params
23
+ add_general_params
24
+ end
25
+
26
+ private
27
+
28
+ def set_title
21
29
  @builder[:component_edit_title].text = "Edit \"#{@component}\" params"
30
+ end
22
31
 
32
+ def add_component_params
23
33
  COMPONENTS[@component][:params].each { |label, type|
24
- layout = Gtk::HBox.new
25
-
26
- glabel = Gtk::Label.new label
27
- glabel.margin = 5
28
- layout.add glabel
29
- glabel.show
30
-
31
- if type.is_a?(Array)
32
- placeholder = Gtk::Image.new(:file => "#{IMG_DIR}/blank_sm.png")
33
- layout.pack_end placeholder
34
- placeholder.margin = 14
35
- placeholder.show
36
-
37
- add_img = Gtk::Image.new(:file => "#{IMG_DIR}/add.png")
38
- add_btn = Gtk::Button.new
39
- add_btn.margin = 5
40
- add_btn.add(add_img)
41
-
42
- layout.pack_end add_btn
43
- add_btn.signal_connect("clicked") {
44
- add_row(label, type)
45
- }
46
-
47
- add_img.show
48
- add_btn.show
49
- end
34
+ add_params(label, type)
35
+ }
36
+ end
37
+
38
+ def add_general_params
39
+ COMPONENTS[:generic][:params].each { |label, type|
40
+ add_params(label, type)
41
+ }
42
+
43
+ # TODO if adding to Grid Layout also add x/y params
44
+ # (required, default to 1)
45
+ end
46
+
47
+ def add_params(label, type)
48
+ layout = Gtk::HBox.new
49
+
50
+ glabel = Gtk::Label.new label
51
+ glabel.margin = 5
52
+ layout.add glabel
53
+ glabel.show
50
54
 
55
+ if type.is_a?(Array)
56
+ placeholder = Gtk::Image.new(:file => "#{IMG_DIR}/blank_sm.png")
57
+ layout.pack_end placeholder
58
+ placeholder.margin = 14
59
+ placeholder.show
60
+
61
+ add_img = Gtk::Image.new(:file => "#{IMG_DIR}/add.png")
62
+ add_btn = Gtk::Button.new
63
+ add_btn.margin = 5
64
+ add_btn.add(add_img)
65
+
66
+ layout.pack_end add_btn
67
+ add_btn.signal_connect("clicked") {
68
+ add_row(type)
69
+ }
70
+
71
+ add_img.show
72
+ add_btn.show
73
+ end
74
+
75
+ if type == :bool
76
+ gchk = Gtk::CheckButton.new
77
+ layout.pack_end gchk
78
+ gchk.show
79
+
80
+ else
51
81
  gedit = Gtk::Entry.new
52
82
  layout.pack_end gedit
53
83
  gedit.show
84
+ end
54
85
 
55
86
 
56
- @builder[:component_edit_layout].add layout
57
- layout.show
58
- }
87
+ @builder[:component_edit_layout].add layout
88
+ layout.show
59
89
  end
60
90
 
61
- private
62
-
63
91
  def component_params
64
92
  @builder[:component_edit_layout].children.collect { |c|
65
93
  p = c.children.first # label
66
94
  .text
67
95
 
68
- t = COMPONENTS[@component][:params][p]
96
+
97
+ t = (COMPONENTS.key?(@component) &&
98
+ COMPONENTS[@component].key?(:params) &&
99
+ COMPONENTS[@component][:params].key?(p)) ?
100
+ COMPONENTS[@component][:params][p] :
101
+ COMPONENTS[:generic][:params][p]
102
+
69
103
  t = t.first if t.is_a?(Array)
70
104
 
71
- txt = c.children[1].text
72
- if t == :int
73
- txt.to_i
74
- else # if t == :string
75
- txt
105
+ if t == :bool
106
+ !!c.children[1].active?
107
+
108
+ else
109
+ txt = c.children[1].text
110
+
111
+ if t == :int
112
+ txt.to_i
113
+ else # if t == :string
114
+ txt
115
+ end
76
116
  end
77
117
  }
78
118
  end
79
119
 
80
- def add_row(label, type)
120
+ def add_row(type)
81
121
  layout = Gtk::HBox.new
82
122
  glabel = Gtk::Label.new
83
123
  glabel.margin = 5
@@ -101,14 +141,21 @@ class ComponentParams
101
141
  add_btn.add(add_img)
102
142
  layout.pack_end add_btn
103
143
  add_btn.signal_connect("clicked") {
104
- add_row(label, type)
144
+ add_row(type)
105
145
  }
106
146
  add_img.show
107
147
  add_btn.show
108
148
 
109
- gedit = Gtk::Entry.new
110
- layout.pack_end gedit
111
- gedit.show
149
+ if type == :bool
150
+ gchk = Gtk::CheckButton.new
151
+ layout.pack_end gchk
152
+ gchk.show
153
+
154
+ else
155
+ gedit = Gtk::Entry.new
156
+ layout.pack_end gedit
157
+ gedit.show
158
+ end
112
159
 
113
160
  @builder[:component_edit_layout].add layout
114
161
  layout.show
@@ -1,6 +1,6 @@
1
1
  # List of supported components
2
2
  class ComponentsList < VR::ListView
3
- attr_accessor :designer
3
+ attr_accessor :designer, :selected
4
4
 
5
5
  def initialize(designer)
6
6
  @designer = designer
@@ -22,11 +22,24 @@ class ComponentsList < VR::ListView
22
22
  first = true
23
23
  selection.signal_connect("changed") {
24
24
  unless selection.selected.nil?
25
- changed unless first
25
+ _changed(selected_component) unless first
26
26
  selection.unselect_all
27
27
  first = false
28
28
  end
29
29
  }
30
+
31
+ enable_model_drag_source(Gdk::ModifierType::BUTTON1_MASK,
32
+ [["reterm", Gtk::TargetFlags::SAME_APP, 0]],
33
+ Gdk::DragAction::DEFAULT | Gdk::DragAction::COPY)
34
+
35
+ lv = self
36
+ signal_connect("drag_data_get") do |widget, context, selection_data, info, time|
37
+ selection_data.set(Gdk::Selection::TYPE_STRING, lv.selected)
38
+ end
39
+ end
40
+
41
+ def selected_component
42
+ selection.selected[1]
30
43
  end
31
44
 
32
45
  def add_component(c)
@@ -37,40 +50,28 @@ class ComponentsList < VR::ListView
37
50
  end
38
51
 
39
52
  def self__row_activated(*args)
40
- changed
53
+ _changed(selected_component)
54
+ end
55
+
56
+ def change_to(target)
57
+ _changed(target)
41
58
  end
42
59
 
43
60
  private
44
61
 
45
- def changed
46
- unless designer.has_toggled_area?
47
- dialog = Gtk::MessageDialog.new(:parent => designer.window,
48
- :flags => :destroy_with_parent,
49
- :type => :info,
50
- :buttons => :close,
51
- :message => "Must select area to add component")
52
-
53
- dialog.signal_connect("response") { |*args|
54
- dialog.destroy
55
- }
56
- dialog.show
57
- return
58
- end
62
+ def _changed(selected)
63
+ @selected = selected
59
64
 
65
+ return unless designer.has_toggled_area?
60
66
 
61
- c = selection.selected[1]
62
- e = COMPONENTS[c.intern]
63
- if e.key?(:params)
64
- w = ComponentParams.new(c.intern, designer)
65
- w.show_glade(designer)
66
- else
67
- designer.create_component(c.intern, [])
68
- end
67
+ w = ComponentParams.new(@selected.intern, designer)
68
+ w.show_glade(designer)
69
69
  end
70
70
 
71
71
  DEFAULT_IMG = GdkPixbuf::Pixbuf.new(:file => "#{IMG_DIR}/blank.png")
72
72
 
73
73
  def desc_for(c)
74
+ return "" unless COMPONENTS.key?(c)
74
75
  COMPONENTS[c][:desc]
75
76
  end
76
77
 
@@ -88,6 +88,10 @@ class CreatedList < VR::TreeView
88
88
  component_for(row_for(widget))
89
89
  end
90
90
 
91
+ def reset!
92
+ unregister(rows_by_parent[nil].first)
93
+ end
94
+
91
95
  def unregister(row)
92
96
  0.upto(row.n_children-1) { |child|
93
97
  unregister(row.nth_child(child))
@@ -95,9 +99,12 @@ class CreatedList < VR::TreeView
95
99
 
96
100
  parent = parent_for(row)
97
101
  widget = widget_for(row)
102
+ component = component_for(row)
98
103
 
99
104
  rows_by_parent[parent].delete(row)
105
+ rows_by_component.delete(component)
100
106
  rows_by_widget.delete(widget)
107
+ params_by_widget.delete(widget)
101
108
  model.remove(row)
102
109
 
103
110
  designer.remove_component(widget)
@@ -114,6 +121,8 @@ class CreatedList < VR::TreeView
114
121
  win = {'window' => {}}
115
122
 
116
123
  top = rows_by_parent[nil].first # there should be only one element here
124
+ return win if top.nil?
125
+
117
126
  tc = component_for(top)
118
127
  wg = widget_for(top)
119
128
 
@@ -28,6 +28,7 @@ class Designer
28
28
  @builder["created_window"].add(@created_list, :expand => true)
29
29
  @builder["viewer"].add(@component.btn)
30
30
  @component.show
31
+ wire_menus
31
32
  end
32
33
 
33
34
  def create_component(component, params)
@@ -106,9 +107,30 @@ class Designer
106
107
  end
107
108
 
108
109
  def set_components
110
+ RETerm::Config.load_plugins
111
+
109
112
  (RETerm::Layouts.all.sort +
110
113
  RETerm::Components.all.sort).each { |c|
111
- @component_list.add_component c if COMPONENTS.key?(c)
114
+ @component_list.add_component c
112
115
  }
113
116
  end
117
+
118
+ def wire_menus
119
+ @builder["file_menu_new"].signal_connect("activate") do
120
+ created_list.reset!
121
+ end
122
+
123
+ @builder["file_menu_save"].signal_connect("activate") do
124
+ file = FileChooser.new(window).show
125
+ File.write(file, created_list.schema)
126
+ end
127
+
128
+ @builder["file_menu_quit"].signal_connect("activate") do
129
+ window.destroy
130
+ end
131
+
132
+ @builder["help_menu_about"].signal_connect("activate") do
133
+ About.new
134
+ end
135
+ end
114
136
  end
@@ -1,17 +1,17 @@
1
1
  # Mechanism which user specifies area to add component
2
2
  class ToggleArea
3
- attr_accessor :toggled
3
+ attr_accessor :toggled, :designer
4
4
 
5
5
  def toggle_on
6
6
  @toggled = true
7
- btn.remove(add)
7
+ btn.remove(btn.children[0])
8
8
  btn.add(rm)
9
9
  @designer.toggle_area = self
10
10
  end
11
11
 
12
12
  def toggle_off
13
13
  @toggled = false
14
- btn.remove(rm)
14
+ btn.remove(btn.children[0])
15
15
  btn.add(add)
16
16
  show
17
17
  @designer.clear_toggle_area
@@ -46,6 +46,23 @@ class ToggleArea
46
46
  css_provider.load(data: "button:hover {background-image: image(#FFFF00);}")
47
47
  b.style_context.add_provider(css_provider, Gtk::StyleProvider::PRIORITY_USER)
48
48
 
49
+ b.drag_dest_set(Gtk::DestDefaults::ALL | Gtk::DestDefaults::MOTION | Gtk::DestDefaults::HIGHLIGHT,
50
+ [["reterm", :same_app, 0]],
51
+ [Gdk::DragAction::COPY.to_i,
52
+ Gdk::DragAction::MOVE.to_i])
53
+
54
+ ta = self
55
+ dragged = nil
56
+
57
+ b.signal_connect("drag-data-received") do |widget, context, x, y, selection_data, info, time|
58
+ dragged = selection_data.text
59
+ end
60
+
61
+ b.signal_connect("drag-drop") do |widget, context, x, y, time|
62
+ ta.designer.toggle_area = self
63
+ ta.designer.component_list.change_to(dragged)
64
+ end
65
+
49
66
  b
50
67
  end
51
68
  end
@@ -0,0 +1,35 @@
1
+ require 'reterm/version'
2
+
3
+ class About
4
+ def initialize
5
+ Gtk::AboutDialog.set_email_hook {|about, link|
6
+ p "mo@morsi.org"
7
+ p link
8
+ }
9
+ Gtk::AboutDialog.set_url_hook {|about, link|
10
+ p "http://github.com/movitto/reterm"
11
+ p link
12
+ }
13
+
14
+ a = Gtk::AboutDialog.new
15
+ #a.artists = ["Artist 1 <no1@foo.bar.com>"]
16
+ a.authors = ["Mo Morsi <mo@morsi.org>"]
17
+ a.comments = "RETerm Terminal UI Designer"
18
+ a.copyright = "Copyright (C) 2017 Mo Morsi"
19
+ #a.documenters = ["Documenter 1 <no1@foo.bar.com>"]
20
+ a.license = "MIT License"
21
+
22
+ icon_theme = Gtk::IconTheme.default
23
+ a.logo = icon_theme.load_icon(icon_theme.icons.first, 48, 0)
24
+
25
+ a.program_name = "RETerm Designer"
26
+ #a.translator_credits = "Translator 1\nTranslator 2\n"
27
+ a.version = RETerm::VERSION
28
+ a.website = "http://github.com/movitto/reterm"
29
+ a.website_label = "RETerm Project Website"
30
+
31
+ a.run
32
+ a.destroy
33
+ end
34
+ end # class About
35
+
@@ -1,4 +1,13 @@
1
1
  def build_component(designer, component, params)
2
+ # TODO all graphical components created here
3
+ # should be resizable by dragging widget border
4
+ # (unless fill or expand property is true).
5
+ # Widgets created in Grid layouts should be
6
+ # moveable by dragging component.
7
+ #
8
+ # Resizing or dragging component should update
9
+ # backend component / effect final output params
10
+
2
11
  if component == :Horizontal
3
12
  areas = []
4
13
  c = Gtk::HBox.new
@@ -23,7 +32,16 @@ def build_component(designer, component, params)
23
32
 
24
33
  return [c, areas]
25
34
 
35
+ # elsif component == :Grid
36
+ # TODO need to create a new component based
37
+ # on Gtk Grid Layout and use here in lieu
38
+ # of ToggleArea.
39
+
26
40
  else
41
+ # TODO visual properties based on component params
42
+ # eg actually render component of width/height at
43
+ # x/y coordinate w/ component-specific params,
44
+ # such as text for labels, options for radios, etc
27
45
  return designer.component_list.image_for(component)
28
46
 
29
47
  end