Fix #7214 - move edit code into popover
[roobuilder] / src / Builder4 / WindowRightPalete.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "$ xns" : "Gtk",
6    "* pack" : "add",
7    "@ void after_node_change(JsRender.Node? node)" : "",
8    "@ void before_node_change(JsRender.Node? node)" : "",
9    "@ void drag_end()" : "",
10    "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
11    "id" : "RightPalete",
12    "items" : [
13     {
14      "$ xns" : "Gtk",
15      "* pack" : "pack_start,true,true,0",
16      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
17      "id" : "viewbox",
18      "items" : [
19       {
20        "$ shadow_type" : "Gtk.ShadowType.IN",
21        "$ xns" : "Gtk",
22        "* init" : [
23         "  this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
24         "   this.el.set_size_request(-1,200);",
25         " ",
26         ""
27        ],
28        "* pack" : "pack_start,true,true,0",
29        "items" : [
30         {
31          "# string dragData" : "",
32          "$ enable_tree_lines" : true,
33          "$ headers_visible" : true,
34          "$ xns" : "Gtk",
35          "* init" : [
36           " {",
37           "    this.el.set_size_request(150,-1);",
38           "                          //  set_reorderable: [1]",
39           "                                  ",
40           "    var description = new Pango.FontDescription();",
41           "    description.set_size(8000);",
42           "    this.el.override_font(description);",
43           "    ",
44           "    var selection = this.el.get_selection();",
45           "    selection.set_mode( Gtk.SelectionMode.SINGLE);",
46           "   // this.selection.signal['changed'].connect(function() {",
47           "    //    _view.listeners['cursor-changed'].apply(_view, [ _view, '']);",
48           "    //});",
49           "    // see: http://live.gnome.org/GnomeLove/DragNDropTutorial",
50           "     ",
51           "    Gtk.drag_source_set (",
52           "            this.el,            /* widget will be drag-able */",
53           "            Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */",
54           "            BuilderApplication.targetList,            /* lists of target to support */",
55           "            Gdk.DragAction.COPY         /* what to do with data after dropped */",
56           "    );",
57           "    //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);",
58           "   ",
59           "   // Gtk.drag_source_set_target_list(this.el, Application.targetList);",
60           "   // Gtk.drag_source_add_text_targets(this.el); ",
61           " ",
62           "}",
63           ""
64          ],
65          "* pack" : "add",
66          "items" : [
67           {
68            "$ columns" : "typeof(string),typeof(string)",
69            "$ xns" : "Gtk",
70            "* pack" : "set_model",
71            "id" : "model",
72            "n_columns" : 2,
73            "xtype" : "ListStore",
74            "| string getValue" : [
75             " (Gtk.TreeIter iter, int col)  {",
76             "    GLib.Value gval;",
77             "     this.el.get_value(iter, col , out gval);",
78             "    return  (string)gval;",
79             "    ",
80             "    ",
81             "}"
82            ]
83           },
84           {
85            "$ xns" : "Gtk",
86            "* init" : [
87             " this.el.add_attribute(_this.txtrender.el , \"markup\",  1 );",
88             " ",
89             ""
90            ],
91            "* pack" : "append_column",
92            "items" : [
93             {
94              "$ xns" : "Gtk",
95              "* pack" : "pack_start,true",
96              "id" : "txtrender",
97              "xtype" : "CellRendererText"
98             }
99            ],
100            "utf8 title" : "Drag to add Object",
101            "xtype" : "TreeViewColumn"
102           }
103          ],
104          "listeners" : {
105           "button_press_event" : [
106            " ( event) => {",
107            "",
108            " //\tif (!this.get('/Editor').save()) {",
109            " //\t    // popup!! - click handled.. ",
110            "// \t    return true;",
111            "//        }",
112            "    return false;",
113            "}"
114           ],
115           "drag_begin" : [
116            "  ( ctx) => {",
117            "    // we could fill this in now...",
118            "//        Seed.print('SOURCE: drag-begin');",
119            "        ",
120            "        ",
121            "        ",
122            "        Gtk.TreeIter iter;",
123            "        var s = this.el.get_selection();",
124            "        ",
125            "        Gtk.TreeModel mod;",
126            "        s.get_selected(out mod, out iter);",
127            "        var path = mod.get_path(iter);",
128            "        ",
129            "        /// pix is a surface..",
130            "        var pix = this.el.create_row_drag_icon ( path);",
131            "            ",
132            "                ",
133            "        Gtk.drag_set_icon_surface (ctx, pix);",
134            "        GLib.Value value;",
135            "        ",
136            "",
137            "        _this.model.el.get_value(iter, 0, out value);",
138            "        ",
139            "        this.dragData = (string) value;",
140            "         ",
141            "        ",
142            "        return;",
143            "}"
144           ],
145           "drag_data_get" : [
146            "(drag_context, selection_data, info, time) => {",
147            " \t//Seed.print('Palete: drag-data-get: ' + target_type);",
148            "    if (this.dragData.length < 1 ) {",
149            "        return; ",
150            "    }",
151            "    ",
152            "    GLib.debug(\"setting drag data to %s\\n\", this.dragData);",
153            "   // selection_data.set_text(this.dragData ,this.dragData.length);",
154            "   selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());",
155            "",
156            "        //this.el.dragData = \"TEST from source widget\";",
157            "        ",
158            "        ",
159            "}"
160           ],
161           "drag_end" : [
162            "( drag_context)  => {",
163            " \t GLib.debug(\"SOURCE: drag-end (call listener on this)\\n\");",
164            "\t",
165            "\tthis.dragData = \"\";",
166            "\t//this.dropList = null;",
167            "\t_this.drag_end(); // call signal..",
168            "\t//this.get('/LeftTree.view').highlight(false);",
169            "\t ",
170            "}"
171           ]
172          },
173          "xtype" : "TreeView"
174         }
175        ],
176        "xtype" : "ScrolledWindow"
177       }
178      ],
179      "xtype" : "Box"
180     }
181    ],
182    "xtype" : "Box",
183    "| void clear" : [
184     "() {",
185     "   this.model.el.clear();",
186     "} "
187    ],
188    "| void load" : [
189     " (Palete.Palete pal, string cls ) {",
190     "   ",
191     "   // this.get('model').expanded();",
192     "    ",
193     "    var tr = pal.getChildList(cls);",
194     "    this.model.el.clear();",
195     "",
196     "",
197     "    Gtk.TreeIter citer;",
198     "",
199     "    for(var i =0 ; i < tr.length; i++) {",
200     "         this.model.el.append(out citer);   ",
201     "         var dname = tr[i];",
202     "         if (dname.contains(\":\")) {",
203     "\t\t\tvar ar = dname.split(\":\");",
204     "\t\t\tdname = \"<b>\" + ar[1] +\"</b> - <i>\"+ar[0]+\"</i>\";",
205     "\t\t}",
206     "         ",
207     "        this.model.el.set_value(citer, 0,   tr[i] ); // used data. ",
208     "        this.model.el.set_value(citer, 1,   dname ); // displayed value.",
209     "        ",
210     "    }",
211     "    this.model.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);",
212     "    ",
213     "} ",
214     "",
215     ""
216    ]
217   }
218  ],
219  "modOrder" : "",
220  "name" : "WindowRightPalete",
221  "parent" : "",
222  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowRightPalete.bjs",
223  "permname" : "",
224  "title" : ""
225 }