resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / WindowRightPalete.vala
1 static Xcls_RightPalete  _RightPalete;
2
3 public class Xcls_RightPalete : Object
4 {
5     public Gtk.Box el;
6     private Xcls_RightPalete  _this;
7
8     public static Xcls_RightPalete singleton()
9     {
10         if (_RightPalete == null) {
11             _RightPalete= new Xcls_RightPalete();
12         }
13         return _RightPalete;
14     }
15     public Xcls_viewbox viewbox;
16     public Xcls_model model;
17     public Xcls_txtrender txtrender;
18
19         // my vars (def)
20     public signal void after_node_change(JsRender.Node? node) ;
21     public signal void before_node_change(JsRender.Node? node) ;
22     public signal void drag_end() ;
23
24     // ctor
25     public Xcls_RightPalete()
26     {
27         _this = this;
28         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
29
30         // my vars (dec)
31
32         // set gobject values
33         var child_0 = new Xcls_viewbox( _this );
34         child_0.ref();
35         this.el.pack_start (  child_0.el , true,true,0 );
36     }
37
38     // user defined functions
39     public void load (Palete.Palete pal, string cls ) {
40        
41        // this.get('model').expanded();
42         
43         var tr = pal.getChildList(cls);
44         this.model.el.clear();
45     
46     
47         Gtk.TreeIter citer;
48     
49         for(var i =0 ; i < tr.length; i++) {
50              this.model.el.append(out citer);   
51              
52             this.model.el.set_value(citer, 0,   tr[i] ); // title 
53             
54         }
55         this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
56         
57     }
58     public void clear () {
59        this.model.el.clear();
60     }
61     public class Xcls_viewbox : Object
62     {
63         public Gtk.Box el;
64         private Xcls_RightPalete  _this;
65
66
67             // my vars (def)
68
69         // ctor
70         public Xcls_viewbox(Xcls_RightPalete _owner )
71         {
72             _this = _owner;
73             _this.viewbox = this;
74             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
75
76             // my vars (dec)
77
78             // set gobject values
79             var child_0 = new Xcls_ScrolledWindow3( _this );
80             child_0.ref();
81             this.el.pack_start (  child_0.el , true,true,0 );
82         }
83
84         // user defined functions
85     }
86     public class Xcls_ScrolledWindow3 : Object
87     {
88         public Gtk.ScrolledWindow el;
89         private Xcls_RightPalete  _this;
90
91
92             // my vars (def)
93
94         // ctor
95         public Xcls_ScrolledWindow3(Xcls_RightPalete _owner )
96         {
97             _this = _owner;
98             this.el = new Gtk.ScrolledWindow( null, null );
99
100             // my vars (dec)
101
102             // set gobject values
103             this.el.shadow_type = Gtk.ShadowType.IN;
104             var child_0 = new Xcls_TreeView4( _this );
105             child_0.ref();
106             this.el.add (  child_0.el  );
107
108             // init method
109
110             this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
111                this.el.set_size_request(-1,200);
112         }
113
114         // user defined functions
115     }
116     public class Xcls_TreeView4 : Object
117     {
118         public Gtk.TreeView el;
119         private Xcls_RightPalete  _this;
120
121
122             // my vars (def)
123         public string dragData;
124
125         // ctor
126         public Xcls_TreeView4(Xcls_RightPalete _owner )
127         {
128             _this = _owner;
129             this.el = new Gtk.TreeView();
130
131             // my vars (dec)
132
133             // set gobject values
134             this.el.enable_tree_lines = true;
135             this.el.headers_visible = true;
136             var child_0 = new Xcls_model( _this );
137             child_0.ref();
138             this.el.set_model (  child_0.el  );
139             var child_1 = new Xcls_TreeViewColumn6( _this );
140             child_1.ref();
141             this.el.append_column (  child_1.el  );
142
143             // init method
144
145             {
146                 this.el.set_size_request(150,-1);
147                                       //  set_reorderable: [1]
148                                               
149                 var description = new Pango.FontDescription();
150                 description.set_size(8000);
151                 this.el.override_font(description);
152                 
153                 var selection = this.el.get_selection();
154                 selection.set_mode( Gtk.SelectionMode.SINGLE);
155                // this.selection.signal['changed'].connect(function() {
156                 //    _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
157                 //});
158                 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
159                  
160                 Gtk.drag_source_set (
161                         this.el,            /* widget will be drag-able */
162                         Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */
163                         BuilderApplication.targetList,            /* lists of target to support */
164                         Gdk.DragAction.COPY         /* what to do with data after dropped */
165                 );
166                 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
167                
168                // Gtk.drag_source_set_target_list(this.el, Application.targetList);
169                // Gtk.drag_source_add_text_targets(this.el); 
170              
171             }
172
173             //listeners
174             this.el.button_press_event.connect( ( event) => {
175             
176              // if (!this.get('/Editor').save()) {
177              //     // popup!! - click handled.. 
178             //      return true;
179             //        }
180                 return false;
181             });
182             this.el.drag_begin.connect( ( ctx) => {
183                 // we could fill this in now...
184             //        Seed.print('SOURCE: drag-begin');
185                     
186                     
187                     
188                     Gtk.TreeIter iter;
189                     var s = this.el.get_selection();
190                     
191                     Gtk.TreeModel mod;
192                     s.get_selected(out mod, out iter);
193                     var path = mod.get_path(iter);
194                     
195                     /// pix is a surface..
196                     var pix = this.el.create_row_drag_icon ( path);
197                         
198                             
199                     Gtk.drag_set_icon_surface (ctx, pix);
200                     GLib.Value value;
201                     
202             
203                     _this.model.el.get_value(iter, 0, out value);
204                     
205                     this.dragData = (string) value;
206                      
207                     
208                     return;
209             });
210             this.el.drag_end.connect( ( drag_context)  => {
211                  print("SOURCE: drag-end\n");
212                 
213                 this.dragData = "";
214                 //this.dropList = null;
215                 _this.drag_end(); // call signal..
216                 //this.get('/LeftTree.view').highlight(false);
217                  
218             });
219             this.el.drag_data_get.connect( (drag_context, selection_data, info, time) => {
220                 //Seed.print('Palete: drag-data-get: ' + target_type);
221                 if (this.dragData.length < 1 ) {
222                     return; 
223                 }
224                 
225                 print("setting drag data to %s\n", this.dragData);
226                // selection_data.set_text(this.dragData ,this.dragData.length);
227                selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());
228             
229                     //this.el.dragData = "TEST from source widget";
230                     
231                     
232             });
233         }
234
235         // user defined functions
236     }
237     public class Xcls_model : Object
238     {
239         public Gtk.ListStore el;
240         private Xcls_RightPalete  _this;
241
242
243             // my vars (def)
244
245         // ctor
246         public Xcls_model(Xcls_RightPalete _owner )
247         {
248             _this = _owner;
249             _this.model = this;
250             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
251
252             // my vars (dec)
253
254             // set gobject values
255         }
256
257         // user defined functions
258         public string getValue (Gtk.TreeIter iter, int col)  {
259             GLib.Value gval;
260              this.el.get_value(iter, col , out gval);
261             return  (string)gval;
262             
263             
264         }
265     }
266
267     public class Xcls_TreeViewColumn6 : Object
268     {
269         public Gtk.TreeViewColumn el;
270         private Xcls_RightPalete  _this;
271
272
273             // my vars (def)
274
275         // ctor
276         public Xcls_TreeViewColumn6(Xcls_RightPalete _owner )
277         {
278             _this = _owner;
279             this.el = new Gtk.TreeViewColumn();
280
281             // my vars (dec)
282
283             // set gobject values
284             this.el.title = "Drag to add Object";
285             var child_0 = new Xcls_txtrender( _this );
286             child_0.ref();
287             this.el.pack_start (  child_0.el , true );
288
289             // init method
290
291             this.el.add_attribute(_this.txtrender.el , "markup", 0 );
292         }
293
294         // user defined functions
295     }
296     public class Xcls_txtrender : Object
297     {
298         public Gtk.CellRendererText el;
299         private Xcls_RightPalete  _this;
300
301
302             // my vars (def)
303
304         // ctor
305         public Xcls_txtrender(Xcls_RightPalete _owner )
306         {
307             _this = _owner;
308             _this.txtrender = this;
309             this.el = new Gtk.CellRendererText();
310
311             // my vars (dec)
312
313             // set gobject values
314         }
315
316         // user defined functions
317     }
318
319
320
321
322
323 }