1 static Xcls_PopoverAddObject _PopoverAddObject;
3 public class Xcls_PopoverAddObject : Object
6 private Xcls_PopoverAddObject _this;
8 public static Xcls_PopoverAddObject singleton()
10 if (_PopoverAddObject == null) {
11 _PopoverAddObject= new Xcls_PopoverAddObject();
13 return _PopoverAddObject;
15 public Xcls_model model;
16 public Xcls_txtrender txtrender;
20 public signal void before_node_change (JsRender.Node? node);
21 public signal void drag_end ();
22 public Xcls_MainWindow mainwindow;
23 public signal void after_node_change (JsRender.Node? node);
26 public Xcls_PopoverAddObject()
29 this.el = new Gtk.Popover( null );
35 this.el.width_request = 900;
36 this.el.height_request = 800;
37 this.el.hexpand = false;
39 this.el.position = Gtk.PositionType.RIGHT;
40 var child_0 = new Xcls_ScrolledWindow2( _this );
42 this.el.add ( child_0.el );
45 // user defined functions
46 public void show (Palete.Palete pal, string cls, Gtk.Widget onbtn) {
52 var tr = pal.getChildList(cls);
53 this.model.el.clear();
58 for(var i =0 ; i < tr.length; i++) {
59 this.model.el.append(out citer);
61 if (dname.contains(":")) {
62 var ar = dname.split(":");
63 dname = "<b>" + ar[1] +"</b> - <i>"+ar[0]+"</i>";
66 this.model.el.set_value(citer, 0, tr[i] ); // used data.
67 this.model.el.set_value(citer, 1, dname ); // displayed value.
70 this.model.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);
78 this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
80 this.mainwindow.el.get_size(out w, out h);
82 // left tree = 250, editor area = 500?
86 this.el.set_size_request( 350, h); // full height?
90 if (this.el.relative_to == null) {
91 this.el.set_relative_to(onbtn);
95 while(Gtk.events_pending()) {
98 // this.hpane.el.set_position( 0);
100 public void hide () {
104 public void clear () {
105 this.model.el.clear();
107 public class Xcls_ScrolledWindow2 : Object
109 public Gtk.ScrolledWindow el;
110 private Xcls_PopoverAddObject _this;
116 public Xcls_ScrolledWindow2(Xcls_PopoverAddObject _owner )
119 this.el = new Gtk.ScrolledWindow( null, null );
123 // set gobject values
124 this.el.shadow_type = Gtk.ShadowType.IN;
125 var child_0 = new Xcls_TreeView3( _this );
127 this.el.add ( child_0.el );
131 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
132 this.el.set_size_request(-1,200);
135 // user defined functions
137 public class Xcls_TreeView3 : Object
139 public Gtk.TreeView el;
140 private Xcls_PopoverAddObject _this;
144 public string dragData;
147 public Xcls_TreeView3(Xcls_PopoverAddObject _owner )
150 this.el = new Gtk.TreeView();
154 // set gobject values
155 this.el.enable_tree_lines = true;
156 this.el.headers_visible = true;
157 var child_0 = new Xcls_model( _this );
159 this.el.set_model ( child_0.el );
160 var child_1 = new Xcls_TreeViewColumn5( _this );
162 this.el.append_column ( child_1.el );
167 this.el.set_size_request(150,-1);
168 // set_reorderable: [1]
170 var description = new Pango.FontDescription();
171 description.set_size(10000);
172 this.el.override_font(description);
174 var selection = this.el.get_selection();
175 selection.set_mode( Gtk.SelectionMode.SINGLE);
176 // this.selection.signal['changed'].connect(function() {
177 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
179 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
181 Gtk.drag_source_set (
182 this.el, /* widget will be drag-able */
183 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
184 BuilderApplication.targetList, /* lists of target to support */
185 Gdk.DragAction.COPY /* what to do with data after dropped */
187 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
189 // Gtk.drag_source_set_target_list(this.el, Application.targetList);
190 // Gtk.drag_source_add_text_targets(this.el);
195 this.el.button_press_event.connect( ( event) => {
197 // if (!this.get('/Editor').save()) {
198 // // popup!! - click handled..
203 this.el.drag_begin.connect( ( ctx) => {
204 // we could fill this in now...
205 // Seed.print('SOURCE: drag-begin');
210 var s = this.el.get_selection();
213 s.get_selected(out mod, out iter);
214 var path = mod.get_path(iter);
216 /// pix is a surface..
217 var pix = this.el.create_row_drag_icon ( path);
220 Gtk.drag_set_icon_surface (ctx, pix);
224 _this.model.el.get_value(iter, 0, out value);
226 this.dragData = (string) value;
231 this.el.drag_data_get.connect( (drag_context, selection_data, info, time) => {
232 //Seed.print('Palete: drag-data-get: ' + target_type);
233 if (this.dragData.length < 1 ) {
237 GLib.debug("setting drag data to %s\n", this.dragData);
238 // selection_data.set_text(this.dragData ,this.dragData.length);
239 selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());
241 //this.el.dragData = "TEST from source widget";
245 this.el.drag_end.connect( ( drag_context) => {
246 GLib.debug("SOURCE: drag-end (call listener on this)\n");
249 //this.dropList = null;
250 _this.drag_end(); // call signal..
251 //this.get('/LeftTree.view').highlight(false);
256 // user defined functions
258 public class Xcls_model : Object
260 public Gtk.ListStore el;
261 private Xcls_PopoverAddObject _this;
267 public Xcls_model(Xcls_PopoverAddObject _owner )
271 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
275 // set gobject values
278 // user defined functions
279 public string getValue (Gtk.TreeIter iter, int col) {
281 this.el.get_value(iter, col , out gval);
287 public class Xcls_TreeViewColumn5 : Object
289 public Gtk.TreeViewColumn el;
290 private Xcls_PopoverAddObject _this;
296 public Xcls_TreeViewColumn5(Xcls_PopoverAddObject _owner )
299 this.el = new Gtk.TreeViewColumn();
303 // set gobject values
304 this.el.title = "Drag to add Object";
305 var child_0 = new Xcls_txtrender( _this );
307 this.el.pack_start ( child_0.el , true );
311 this.el.add_attribute(_this.txtrender.el , "markup", 1 );
314 // user defined functions
316 public class Xcls_txtrender : Object
318 public Gtk.CellRendererText el;
319 private Xcls_PopoverAddObject _this;
325 public Xcls_txtrender(Xcls_PopoverAddObject _owner )
328 _this.txtrender = this;
329 this.el = new Gtk.CellRendererText();
333 // set gobject values
336 // user defined functions