Sample/DialogTemplateSelect.js
authorAlan Knowles <alan@akbkhome.com>
Mon, 7 Jun 2010 08:08:21 +0000 (16:08 +0800)
committerAlan Knowles <alan@akbkhome.com>
Mon, 7 Jun 2010 08:08:21 +0000 (16:08 +0800)
Sample/DialogTemplateSelect.js [new file with mode: 0644]

diff --git a/Sample/DialogTemplateSelect.js b/Sample/DialogTemplateSelect.js
new file mode 100644 (file)
index 0000000..2ac6e1d
--- /dev/null
@@ -0,0 +1,94 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+DialogTemplateSelect=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        delete_event : function (self, event) {
+            this.el.hide();
+            return true;
+        }
+    },
+    default_height : 200,
+    default_width : 400,
+    modal : true,
+    show : function(node) {
+        
+        var pal = this.get('/Window.LeftTree').getPaleteProvider();
+        var opts = pal.listTemplates(node);
+        if (!opts.length) {
+            return node;
+        }
+      
+        opts.unshift('Just add Element')
+        this.get('combo.model').loadData(opts);
+     
+         
+        this.el.show_all();
+        print(this.el.run());
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            pack : function(p,e) {
+                                p.el.get_content_area().add(e.el)
+                            },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,false,0",
+                    pack : function(p,e) {
+                                        p.el.get_content_area().add(e.el)
+                                    },
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Select Template : ",
+                            pack : "pack_start,false,false"
+                        },
+                        {
+                            xtype: Gtk.ComboBox,
+                            id : "combo",
+                            pack : "add",
+                            init : function() {
+                                XObject.prototype.init.call(this);
+                                 this.el.add_attribute(this.items[0].el , 'markup', 1 );  
+                            },
+                            items : [
+                                {
+                                    xtype: Gtk.CellRendererText,
+                                    pack : false
+                                },
+                                {
+                                    xtype: Gtk.ListStore,
+                                    id : "model",
+                                    pack : "set_model"
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            label : "OK",
+            pack : "add_action_widget,1"
+        },
+        {
+            xtype: Gtk.Button,
+            label : "Just Add Element",
+            pack : "add_action_widget,0"
+        }
+    ]
+});
+DialogTemplateSelect.init();
+XObject.cache['/DialogTemplateSelect'] = DialogTemplateSelect;