1 //<Script type="text/javascript">
5 GObject = imports.gi.GObject;
6 Pango = imports.gi.Pango ;
8 XObject = imports.XObject.XObject;
9 console = imports.console;
12 LeftTree = imports.Builder.LeftTree.LeftTree;
13 Roo = imports.Builder.Provider.Palete.Roo.Roo;
14 // normally appears as a vbox with a expander button,
15 // when you put your mouse over though, it expands.
17 RightPalete = new XObject({
21 pack : [ 'pack_start', false, false ],
24 this.get('hidden').el.show();
25 this.get('visible').el.hide();
28 this.get('hidden').el.hide();
29 this.get('visible').el.show();
30 this.get('model').expanded();
47 pack : [ 'pack_start', false, true ],
49 clicked : function() {
58 stock : Gtk.STOCK_GOTO_FIRST,
59 'icon-size' : Gtk.IconSize.MENU,
65 pack : [ 'pack_start', true, true ],
71 XObject.prototype.init.call(this);
72 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
75 'enter-notify-event' : function (w,e)
78 //console.log("enter!");
79 //this.el.expanded = !this.el.expanded;
80 //this.listeners.activate.call(this);
98 pack : [ 'pack_start', false, true ],
110 pack : [ 'pack_start', false, true ],
112 clicked : function() {
120 stock : Gtk.STOCK_GOTO_LAST,
121 'icon-size' : Gtk.IconSize.MENU,
130 // expandable here...( show all.. )
132 // our pallete goes here...
133 // two trees technically...
139 xtype: Gtk.ScrolledWindow,
140 smooth_scroll : true,
141 shadow_type : Gtk.ShadowType.IN ,
144 XObject.prototype.init.call(this);
146 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
147 this.el.set_size_request(-1,200);
154 xtype : Gtk.TreeView,
155 headers_visible : false,
156 enable_tree_lines : true ,
159 XObject.prototype.init.call(this);
160 this.el.set_size_request(150,-1);
161 // set_reorderable: [1]
163 var description = new Pango.FontDescription.c_new();
164 description.set_size(8000);
165 this.el.modify_font(description);
167 this.selection = this.el.get_selection();
168 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
169 // this.selection.signal['changed'].connect(function() {
170 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
172 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
174 Gtk.drag_source_set (
175 this.el, /* widget will be drag-able */
176 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
177 null, /* lists of target to support */
178 0, /* size of list */
179 Gdk.DragAction.COPY /* what to do with data after dropped */
181 Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
183 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
184 targets = new Gtk.TargetList();
185 targets.add( LeftTree.atoms["STRING"], 0, 0);
186 targets.add_text_targets( 1 );
187 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
189 //if you want to allow text to be output elsewhere..
190 //Gtk.drag_source_add_text_targets(this.el);
197 'drag-data-get' : function (w, ctx, selection_data, target_type, time, ud)
200 Seed.print('Palete: drag-data-get: ' + target_type);
201 if (this.el.dragData && this.el.dragData.length ) {
202 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
206 //this.el.dragData = "TEST from source widget";
213 'drag-begin' : function (w, ctx, ud)
215 // we could fill this in now...
216 Seed.print('SOURCE: drag-begin');
220 var iter = new Gtk.TreeIter();
221 var s = this.selection;
222 s.get_selected(RightPalete.get('model').el, iter);
223 var path = RightPalete.get('model').el.get_path(iter);
225 var pix = this.el.create_row_drag_icon ( path);
228 Gtk.drag_set_icon_pixmap (ctx,
235 var value = new GObject.Value('');
236 RightPalete.get('model').el.get_value(iter, 0, value);
237 if (!RightPalete.provider) {
240 this.el.dropList = RightPalete.provider.getDropList(value.value);
241 this.el.dragData = value.value;
248 'drag-end' : function ()
250 Seed.print('SOURCE: drag-end');
251 this.el.dragData = false;
252 this.el.dropList = false;
253 LeftTree.get('view').highlight(false);
258 'cursor-changed' : function(tv, a) {
259 //select -- should save existing...
260 var iter = new Gtk.TreeIter();
262 if (this.selection.count_selected_rows() < 1) {
264 Builder.LeftTree._model.load( false);
269 //console.log('changed');
270 var s = this.selection;
271 s.get_selected(_model, iter);
272 value = new GObject.Value('');
273 _model.el.get_value(iter, 2, value);
275 console.log(value.value);
276 var file = _model.project.get(value.value);
280 _expander.el.set_expanded(false);
282 Builder.LeftTree._model.loadFile(file);
294 pack : ['set_model'],
297 xtype : Gtk.ListStore,
302 XObject.prototype.init.call(this);
307 this.el.set_column_types ( 2, [
308 GObject.TYPE_STRING, // title
309 GObject.TYPE_STRING // tip
316 expanded : function() // event handler realy.
318 // should ask tree for list of current compeents.
320 //console.dump(this.provider);
321 //var li = this.provider.gatherList([]);
323 //this.load( this.provider.gatherList([]));
330 load : function(tr,iter)
335 //console.log('Project tree load: ' + tr.length);
336 var citer = new Gtk.TreeIter();
337 //this.insert(citer,iter,0);
338 for(var i =0 ; i < tr.length; i++) {
341 this.el.append(citer);
343 this.el.insert(citer,iter,-1);
348 this.el.set_value(citer, 0, '' + r ); // title
350 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
351 //if (r.cn && r.cn.length) {
352 // this.load(r.cn, citer);
362 getValue: function (iter, col) {
363 var gval = new GObject.Value('');
364 this.el.get_value(iter, col ,gval);
372 // this.expand_all();
377 pack : ['append_column'],
379 xtype : Gtk.TreeViewColumn,
383 XObject.prototype.init.call(this);
384 this.el.add_attribute(this.items[0].el , 'markup', 0 );
390 xtype : Gtk.CellRendererText,
391 pack: [ 'pack_start']