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_iconrender iconrender;
17 public Xcls_txtrender txtrender;
20 public signal void before_node_change (JsRender.Node? node);
21 public signal void after_node_change (JsRender.Node? node);
22 public signal void drag_end ();
23 public Xcls_MainWindow mainwindow;
27 public Xcls_PopoverAddObject()
30 this.el = new Gtk.Popover( null );
36 this.el.width_request = 900;
37 this.el.height_request = 800;
38 this.el.hexpand = false;
40 this.el.position = Gtk.PositionType.RIGHT;
41 var child_0 = new Xcls_ScrolledWindow2( _this );
43 this.el.add ( child_0.el );
46 // user defined functions
47 public void show (Palete.Palete pal, string cls, Gtk.Widget onbtn) {
52 var tr = pal.getChildList(cls);
53 this.model.el.clear();
57 var ic = Gtk.IconTheme.get_default();
58 Gdk.Pixbuf pixdef = null;
60 pixdef = ic.load_icon("emblem-new", 16,0);
64 for(var i =0 ; i < tr.length; i++) {
65 this.model.el.append(out citer);
68 if (dname.contains(":")) {
69 var ar = dname.split(":");
70 dname = "<b>" + ar[1] +"</b> - <i>"+ar[0]+"</i>";
71 clsname = ar[0]; /// possibly?
74 this.model.el.set_value(citer, 0, tr[i] ); // used data.
75 this.model.el.set_value(citer, 1, dname ); // displayed value.
77 var clsb = clsname.split(".");
78 var sub = clsb.length > 1 ? clsb[1].down() : "";
81 var fn = "/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-" + sub + ".png";
82 if (FileUtils.test (fn, FileTest.IS_REGULAR)) {
84 pix = new Gdk.Pixbuf.from_file (fn);
90 this.model.el.set_value(citer, 2, pix );
94 this.model.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);
100 this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
102 this.mainwindow.el.get_size(out w, out h);
104 // left tree = 250, editor area = 500?
108 this.el.set_size_request( 350, h); // full height?
112 if (this.el.relative_to == null) {
113 this.el.set_relative_to(onbtn);
117 while(Gtk.events_pending()) {
118 Gtk.main_iteration();
120 // this.hpane.el.set_position( 0);
122 public void clear () {
123 this.model.el.clear();
125 public void hide () {
129 public class Xcls_ScrolledWindow2 : Object
131 public Gtk.ScrolledWindow el;
132 private Xcls_PopoverAddObject _this;
138 public Xcls_ScrolledWindow2(Xcls_PopoverAddObject _owner )
141 this.el = new Gtk.ScrolledWindow( null, null );
145 // set gobject values
146 this.el.shadow_type = Gtk.ShadowType.IN;
147 var child_0 = new Xcls_TreeView3( _this );
149 this.el.add ( child_0.el );
153 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
154 this.el.set_size_request(-1,200);
157 // user defined functions
159 public class Xcls_TreeView3 : Object
161 public Gtk.TreeView el;
162 private Xcls_PopoverAddObject _this;
166 public string dragData;
169 public Xcls_TreeView3(Xcls_PopoverAddObject _owner )
172 this.el = new Gtk.TreeView();
176 // set gobject values
177 this.el.enable_tree_lines = true;
178 this.el.headers_visible = true;
179 var child_0 = new Xcls_model( _this );
181 this.el.set_model ( child_0.el );
182 var child_1 = new Xcls_TreeViewColumn5( _this );
184 this.el.append_column ( child_1.el );
189 this.el.set_size_request(150,-1);
190 // set_reorderable: [1]
192 var description = new Pango.FontDescription();
193 description.set_size(10000);
194 this.el.override_font(description);
196 var selection = this.el.get_selection();
197 selection.set_mode( Gtk.SelectionMode.SINGLE);
198 // this.selection.signal['changed'].connect(function() {
199 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
201 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
203 Gtk.drag_source_set (
204 this.el, /* widget will be drag-able */
205 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
206 BuilderApplication.targetList, /* lists of target to support */
207 Gdk.DragAction.COPY /* what to do with data after dropped */
209 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
211 // Gtk.drag_source_set_target_list(this.el, Application.targetList);
212 // Gtk.drag_source_add_text_targets(this.el);
217 this.el.button_press_event.connect( ( event) => {
219 // if (!this.get('/Editor').save()) {
220 // // popup!! - click handled..
225 this.el.drag_begin.connect( ( ctx) => {
226 // we could fill this in now...
227 // Seed.print('SOURCE: drag-begin');
232 var s = this.el.get_selection();
235 s.get_selected(out mod, out iter);
236 var path = mod.get_path(iter);
238 /// pix is a surface..
239 var pix = this.el.create_row_drag_icon ( path);
242 Gtk.drag_set_icon_surface (ctx, pix);
246 _this.model.el.get_value(iter, 0, out value);
248 this.dragData = (string) value;
253 this.el.drag_data_get.connect( (drag_context, selection_data, info, time) => {
254 //Seed.print('Palete: drag-data-get: ' + target_type);
255 if (this.dragData.length < 1 ) {
259 GLib.debug("setting drag data to %s\n", this.dragData);
260 // selection_data.set_text(this.dragData ,this.dragData.length);
261 selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());
263 //this.el.dragData = "TEST from source widget";
267 this.el.drag_end.connect( ( drag_context) => {
268 GLib.debug("SOURCE: drag-end (call listener on this)\n");
271 //this.dropList = null;
272 _this.drag_end(); // call signal..
273 //this.get('/LeftTree.view').highlight(false);
278 // user defined functions
280 public class Xcls_model : Object
282 public Gtk.ListStore el;
283 private Xcls_PopoverAddObject _this;
289 public Xcls_model(Xcls_PopoverAddObject _owner )
293 this.el = new Gtk.ListStore.newv( { typeof(string),typeof(string),typeof(Gdk.Pixbuf) } );
297 // set gobject values
300 // user defined functions
301 public string getValue (Gtk.TreeIter iter, int col) {
303 this.el.get_value(iter, col , out gval);
309 public class Xcls_TreeViewColumn5 : Object
311 public Gtk.TreeViewColumn el;
312 private Xcls_PopoverAddObject _this;
318 public Xcls_TreeViewColumn5(Xcls_PopoverAddObject _owner )
321 this.el = new Gtk.TreeViewColumn();
325 // set gobject values
326 this.el.title = "Drag to add Object";
327 var child_0 = new Xcls_iconrender( _this );
329 this.el.pack_start ( child_0.el , true );
330 var child_1 = new Xcls_txtrender( _this );
332 this.el.pack_start ( child_1.el , true );
336 this.el.add_attribute(_this.txtrender.el , "markup", 1 );
337 this.el.add_attribute(_this.iconrender.el , "pixbuf", 2 );
340 // user defined functions
342 public class Xcls_iconrender : Object
344 public Gtk.CellRendererPixbuf el;
345 private Xcls_PopoverAddObject _this;
351 public Xcls_iconrender(Xcls_PopoverAddObject _owner )
354 _this.iconrender = this;
355 this.el = new Gtk.CellRendererPixbuf();
359 // set gobject values
362 // user defined functions
365 public class Xcls_txtrender : Object
367 public Gtk.CellRendererText el;
368 private Xcls_PopoverAddObject _this;
374 public Xcls_txtrender(Xcls_PopoverAddObject _owner )
377 _this.txtrender = this;
378 this.el = new Gtk.CellRendererText();
382 // set gobject values
385 // user defined functions