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;
21 public signal void before_node_change (JsRender.Node? node);
22 public signal void drag_end ();
23 public Xcls_MainWindow mainwindow;
24 public signal void after_node_change (JsRender.Node? node);
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) {
53 var tr = pal.getChildList(cls);
54 this.model.el.clear();
58 var ic = Gtk.IconTheme.get_default();
59 var pixdef = ic.load_icon("emblem-new", 16,0);
61 for(var i =0 ; i < tr.length; i++) {
62 this.model.el.append(out citer);
65 if (dname.contains(":")) {
66 var ar = dname.split(":");
67 dname = "<b>" + ar[1] +"</b> - <i>"+ar[0]+"</i>";
68 clsname = ar[0]; /// possibly?
71 this.model.el.set_value(citer, 0, tr[i] ); // used data.
72 this.model.el.set_value(citer, 1, dname ); // displayed value.
74 var clsb = clsname.split(".");
75 var sub = clsb.length > 1 ? clsb[1].down() : "";
78 var fn = "/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-" + sub + ".png";
79 if (FileUtils.test (fn, FileTest.IS_REGULAR)) {
80 pix = new Gdk.Pixbuf.from_file (fn);
84 this.model.el.set_value(citer, 2, pix );
88 this.model.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);
96 this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
98 this.mainwindow.el.get_size(out w, out h);
100 // left tree = 250, editor area = 500?
104 this.el.set_size_request( 350, h); // full height?
108 if (this.el.relative_to == null) {
109 this.el.set_relative_to(onbtn);
113 while(Gtk.events_pending()) {
114 Gtk.main_iteration();
116 // this.hpane.el.set_position( 0);
118 public void hide () {
122 public void clear () {
123 this.model.el.clear();
125 public class Xcls_ScrolledWindow2 : Object
127 public Gtk.ScrolledWindow el;
128 private Xcls_PopoverAddObject _this;
134 public Xcls_ScrolledWindow2(Xcls_PopoverAddObject _owner )
137 this.el = new Gtk.ScrolledWindow( null, null );
141 // set gobject values
142 this.el.shadow_type = Gtk.ShadowType.IN;
143 var child_0 = new Xcls_TreeView3( _this );
145 this.el.add ( child_0.el );
149 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
150 this.el.set_size_request(-1,200);
153 // user defined functions
155 public class Xcls_TreeView3 : Object
157 public Gtk.TreeView el;
158 private Xcls_PopoverAddObject _this;
162 public string dragData;
165 public Xcls_TreeView3(Xcls_PopoverAddObject _owner )
168 this.el = new Gtk.TreeView();
172 // set gobject values
173 this.el.enable_tree_lines = true;
174 this.el.headers_visible = true;
175 var child_0 = new Xcls_model( _this );
177 this.el.set_model ( child_0.el );
178 var child_1 = new Xcls_TreeViewColumn5( _this );
180 this.el.append_column ( child_1.el );
185 this.el.set_size_request(150,-1);
186 // set_reorderable: [1]
188 var description = new Pango.FontDescription();
189 description.set_size(10000);
190 this.el.override_font(description);
192 var selection = this.el.get_selection();
193 selection.set_mode( Gtk.SelectionMode.SINGLE);
194 // this.selection.signal['changed'].connect(function() {
195 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
197 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
199 Gtk.drag_source_set (
200 this.el, /* widget will be drag-able */
201 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
202 BuilderApplication.targetList, /* lists of target to support */
203 Gdk.DragAction.COPY /* what to do with data after dropped */
205 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
207 // Gtk.drag_source_set_target_list(this.el, Application.targetList);
208 // Gtk.drag_source_add_text_targets(this.el);
213 this.el.button_press_event.connect( ( event) => {
215 // if (!this.get('/Editor').save()) {
216 // // popup!! - click handled..
221 this.el.drag_begin.connect( ( ctx) => {
222 // we could fill this in now...
223 // Seed.print('SOURCE: drag-begin');
228 var s = this.el.get_selection();
231 s.get_selected(out mod, out iter);
232 var path = mod.get_path(iter);
234 /// pix is a surface..
235 var pix = this.el.create_row_drag_icon ( path);
238 Gtk.drag_set_icon_surface (ctx, pix);
242 _this.model.el.get_value(iter, 0, out value);
244 this.dragData = (string) value;
249 this.el.drag_data_get.connect( (drag_context, selection_data, info, time) => {
250 //Seed.print('Palete: drag-data-get: ' + target_type);
251 if (this.dragData.length < 1 ) {
255 GLib.debug("setting drag data to %s\n", this.dragData);
256 // selection_data.set_text(this.dragData ,this.dragData.length);
257 selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());
259 //this.el.dragData = "TEST from source widget";
263 this.el.drag_end.connect( ( drag_context) => {
264 GLib.debug("SOURCE: drag-end (call listener on this)\n");
267 //this.dropList = null;
268 _this.drag_end(); // call signal..
269 //this.get('/LeftTree.view').highlight(false);
274 // user defined functions
276 public class Xcls_model : Object
278 public Gtk.ListStore el;
279 private Xcls_PopoverAddObject _this;
285 public Xcls_model(Xcls_PopoverAddObject _owner )
289 this.el = new Gtk.ListStore( 3, typeof(string),typeof(string),typeof(Gdk.Pixbuf) );
293 // set gobject values
296 // user defined functions
297 public string getValue (Gtk.TreeIter iter, int col) {
299 this.el.get_value(iter, col , out gval);
305 public class Xcls_TreeViewColumn5 : Object
307 public Gtk.TreeViewColumn el;
308 private Xcls_PopoverAddObject _this;
314 public Xcls_TreeViewColumn5(Xcls_PopoverAddObject _owner )
317 this.el = new Gtk.TreeViewColumn();
321 // set gobject values
322 this.el.title = "Drag to add Object";
323 var child_0 = new Xcls_iconrender( _this );
325 this.el.pack_start ( child_0.el , true );
326 var child_1 = new Xcls_txtrender( _this );
328 this.el.pack_start ( child_1.el , true );
332 this.el.add_attribute(_this.txtrender.el , "markup", 1 );
333 this.el.add_attribute(_this.iconrender.el , "pixbuf", 2 );
336 // user defined functions
338 public class Xcls_iconrender : Object
340 public Gtk.CellRendererPixbuf el;
341 private Xcls_PopoverAddObject _this;
347 public Xcls_iconrender(Xcls_PopoverAddObject _owner )
350 _this.iconrender = this;
351 this.el = new Gtk.CellRendererPixbuf();
355 // set gobject values
358 // user defined functions
361 public class Xcls_txtrender : Object
363 public Gtk.CellRendererText el;
364 private Xcls_PopoverAddObject _this;
370 public Xcls_txtrender(Xcls_PopoverAddObject _owner )
373 _this.txtrender = this;
374 this.el = new Gtk.CellRendererText();
378 // set gobject values
381 // user defined functions