Sample/DialogTemplateSelect.js
[app.Builder.js] / Sample / DialogTemplateSelect.js
1 Gtk = imports.gi.Gtk;
2 Gdk = imports.gi.Gdk;
3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
5 Gio = imports.gi.Gio;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
9 Vte = imports.gi.Vte;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
12 DialogTemplateSelect=new XObject({
13     xtype: Gtk.Dialog,
14     listeners : {
15         delete_event : function (self, event) {
16             this.el.hide();
17             return true;
18         }
19     },
20     default_height : 200,
21     default_width : 400,
22     modal : true,
23     show : function(node) {
24         
25         var pal = this.get('/Window.LeftTree').getPaleteProvider();
26         var opts = pal.listTemplates(node);
27         if (!opts.length) {
28             return node;
29         }
30       
31         opts.unshift('Just add Element')
32         this.get('combo.model').loadData(opts);
33      
34          
35         this.el.show_all();
36         print(this.el.run());
37     },
38     items : [
39         {
40             xtype: Gtk.VBox,
41             pack : function(p,e) {
42                                 p.el.get_content_area().add(e.el)
43                             },
44             items : [
45                 {
46                     xtype: Gtk.HBox,
47                     pack : "pack_start,false,false,0",
48                     pack : function(p,e) {
49                                         p.el.get_content_area().add(e.el)
50                                     },
51                     items : [
52                         {
53                             xtype: Gtk.Label,
54                             label : "Select Template : ",
55                             pack : "pack_start,false,false"
56                         },
57                         {
58                             xtype: Gtk.ComboBox,
59                             id : "combo",
60                             pack : "add",
61                             init : function() {
62                                 XObject.prototype.init.call(this);
63                                  this.el.add_attribute(this.items[0].el , 'markup', 1 );  
64                             },
65                             items : [
66                                 {
67                                     xtype: Gtk.CellRendererText,
68                                     pack : false
69                                 },
70                                 {
71                                     xtype: Gtk.ListStore,
72                                     id : "model",
73                                     pack : "set_model"
74                                 }
75                             ]
76                         }
77                     ]
78                 }
79             ]
80         },
81         {
82             xtype: Gtk.Button,
83             label : "OK",
84             pack : "add_action_widget,1"
85         },
86         {
87             xtype: Gtk.Button,
88             label : "Just Add Element",
89             pack : "add_action_widget,0"
90         }
91     ]
92 });
93 DialogTemplateSelect.init();
94 XObject.cache['/DialogTemplateSelect'] = DialogTemplateSelect;