src/Builder4/GtkView.bjs
authorAlan <alan@roojs.com>
Thu, 18 Aug 2022 10:51:29 +0000 (18:51 +0800)
committerAlan <alan@roojs.com>
Thu, 18 Aug 2022 10:51:29 +0000 (18:51 +0800)
src/Builder4/GtkView.vala

src/Builder4/GtkView.bjs
src/Builder4/GtkView.vala

index ea2b1c7..430336a 100644 (file)
           }
          ],
          "xtype" : "ScrolledWindow"
+        },
+        {
+         "$ xns" : "Gtk",
+         "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+         "bool homogeneous" : false,
+         "bool vexpand" : false,
+         "int spacing" : 0,
+         "items" : [
+          {
+           "$ xns" : "Gtk",
+           "* init" : [
+            "var description =   Pango.FontDescription.from_string(\"monospace\");",
+            "\tdescription.set_size(8000);",
+            "\t this.el.override_font(description);",
+            "",
+            ""
+           ],
+           "bool hexpand" : true,
+           "id" : "search_entry",
+           "int width_request" : 300,
+           "listeners" : {
+            "changed" : [
+             "() => {",
+             "\t/*",
+             "\tif (this.el.text == \"\") {",
+             "\t\t_this.search_results.el.hide();",
+             "\t\treturn;",
+             "\t}",
+             "\tvar res = 0;",
+             "\tswitch(_this.windowstate.state) {",
+             "\t\tcase WindowState.State.CODEONLY:",
+             "\t\t///case WindowState.State.CODE:",
+             "\t\t\t// search the code being edited..",
+             "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);",
+             "\t\t\t",
+             "\t\t\tbreak;",
+             "\t\tcase WindowState.State.PREVIEW:",
+             "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
+             "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);",
+             "\t\t\t} else { ",
+             "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t",
+             "\t\t\t}",
+             "\t\t",
+             "\t\t",
+             "\t\t\tbreak;",
+             "\t}",
+             "\t_this.search_results.el.show();",
+             "\tif (res > 0) {",
+             "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
+             "\t} else {",
+             "\t\t_this.search_results.el.label = \"No Matches\";",
+             "\t}",
+             "\t\t",
+             "\t*/",
+             "\t",
+             "}",
+             ""
+            ],
+            "key_press_event" : [
+             "(event) => {",
+             "    ",
+             "     if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
+             "\t    GLib.debug(\"SAVE: ctrl-g  pressed\");",
+             "\t\t_this.forwardSearch(true);",
+             "\t    return true;",
+             "\t}",
+             "    ",
+             "    ",
+             "  ",
+             " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {",
+             "\t\tvar res = _this.search(this.el.text);",
+             "\t\tif (res > 0) {",
+             "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
+             "\t\t} else {",
+             "\t\t\t_this.search_results.el.label = \"No Matches\";",
+             "\t\t}",
+             "\t\t",
+             "\t    return true;",
+             "",
+             "\t}    ",
+             "   // print(event.key.keyval)",
+             "   ",
+             "    return false;",
+             "",
+             "} "
+            ]
+           },
+           "string placeholder_text" : "Press enter to search",
+           "xtype" : "SearchEntry",
+           "| void forwardSearch" : [
+            "(bool change_focus) {",
+            "",
+            "",
+            "\t_this.forwardSearch(change_focus);",
+            "",
+            "/*",
+            "",
+            "\tswitch(_this.windowstate.state) {",
+            "\t\tcase WindowState.State.CODEONLY:",
+            "\t\t//case WindowState.State.CODE:",
+            "\t\t\t// search the code being edited..",
+            "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
+            "\t\t\t ",
+            "\t\t\tbreak;",
+            "\t\tcase WindowState.State.PREVIEW:",
+            "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
+            "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
+            "\t\t\t} else { ",
+            "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
+            "\t\t\t}",
+            "\t\t",
+            "\t\t\tbreak;",
+            "\t}",
+            "\t*/",
+            "\t",
+            "}",
+            ""
+           ]
+          },
+          {
+           "$ xns" : "Gtk",
+           "* pack" : "add",
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* pack" : "add",
+             "Xcls_ValaCompileErrors popup" : "",
+             "bool always_show_image" : true,
+             "id" : "search_results",
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* pack" : "set_image",
+               "bool sensitive" : false,
+               "utf8 icon_name" : "system-search",
+               "xtype" : "Image"
+              }
+             ],
+             "listeners" : {
+              "button_press_event" : [
+               "() => {",
+               "/*",
+               "    if (this.popup == null) {",
+               "        this.popup = new Xcls_ValaCompileErrors();",
+               "        this.popup.window = _this;",
+               "    }",
+               "   ",
+               "    ",
+               "    this.popup.show(this.notices, this.el);",
+               "    */",
+               "    return true;",
+               "}"
+              ]
+             },
+             "string label" : "Matches",
+             "xtype" : "ImageMenuItem"
+            }
+           ],
+           "xtype" : "MenuBar"
+          },
+          {
+           "$ xns" : "Gtk",
+           "bool always_show_image" : true,
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "image",
+             "string icon_name" : "go-down",
+             "xtype" : "Image"
+            }
+           ],
+           "listeners" : {
+            "button_press_event" : [
+             "(event) => {",
+             "",
+             "\t_this.forwardSearch(true);",
+             "\t",
+             "\treturn true;",
+             "}",
+             ""
+            ]
+           },
+           "string label" : "Next",
+           "xtype" : "Button"
+          },
+          {
+           "$ xns" : "Gtk",
+           "bool always_show_image" : true,
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "image",
+             "string icon_name" : "go-up",
+             "xtype" : "Image"
+            }
+           ],
+           "listeners" : {
+            "button_press_event" : [
+             "(event) => {",
+             "",
+             "\t_this.backSearch(true);",
+             "\t",
+             "\treturn true;",
+             "}",
+             ""
+            ]
+           },
+           "string label" : "Previous",
+           "xtype" : "Button"
+          },
+          {
+           "$ xns" : "Gtk",
+           "bool always_show_image" : true,
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "image",
+             "string icon_name" : "emblem-system",
+             "xtype" : "Image"
+            },
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "popup",
+             "id" : "search_settings",
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* init" : [
+                "{",
+                "\tthis.el.show();",
+                "}",
+                ""
+               ],
+               "id" : "case_sensitive",
+               "string label" : "Case Sensitive",
+               "xtype" : "CheckMenuItem"
+              },
+              {
+               "$ xns" : "Gtk",
+               "* init" : [
+                "{",
+                "\tthis.el.show();",
+                "}",
+                ""
+               ],
+               "id" : "regex",
+               "string label" : "Regex",
+               "xtype" : "CheckMenuItem"
+              },
+              {
+               "$ xns" : "Gtk",
+               "* init" : [
+                "{",
+                "\tthis.el.show();",
+                "}",
+                ""
+               ],
+               "id" : "multiline",
+               "string label" : "Multi-line (add \\n)",
+               "xtype" : "CheckMenuItem"
+              }
+             ],
+             "xtype" : "Menu"
+            }
+           ],
+           "string label" : "Settings",
+           "xtype" : "MenuButton"
+          }
+         ],
+         "xtype" : "Box"
         }
        ],
        "xtype" : "Box"
index 5d817ab..0bccb77 100644 (file)
@@ -18,6 +18,12 @@ public class Xcls_GtkView : Object
     public Xcls_view_layout view_layout;
     public Xcls_container container;
     public Xcls_sourceview sourceview;
+    public Xcls_search_entry search_entry;
+    public Xcls_search_results search_results;
+    public Xcls_search_settings search_settings;
+    public Xcls_case_sensitive case_sensitive;
+    public Xcls_regex regex;
+    public Xcls_multiline multiline;
 
         // my vars (def)
     public Gtk.Widget lastObj;
@@ -389,6 +395,9 @@ public class Xcls_GtkView : Object
             var child_0 = new Xcls_ScrolledWindow9( _this );
             child_0.ref();
             this.el.add(  child_0.el );
+            var child_1 = new Xcls_Box11( _this );
+            child_1.ref();
+            this.el.add(  child_1.el );
         }
 
         // user defined functions
@@ -760,6 +769,548 @@ public class Xcls_GtkView : Object
     }
 
 
+    public class Xcls_Box11 : Object
+    {
+        public Gtk.Box el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Box11(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = false;
+            this.el.vexpand = false;
+            var child_0 = new Xcls_search_entry( _this );
+            child_0.ref();
+            this.el.add(  child_0.el );
+            var child_1 = new Xcls_MenuBar13( _this );
+            child_1.ref();
+            this.el.add (  child_1.el  );
+            var child_2 = new Xcls_Button16( _this );
+            child_2.ref();
+            this.el.add(  child_2.el );
+            var child_3 = new Xcls_Button18( _this );
+            child_3.ref();
+            this.el.add(  child_3.el );
+            var child_4 = new Xcls_MenuButton20( _this );
+            child_4.ref();
+            this.el.add(  child_4.el );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_search_entry : Object
+    {
+        public Gtk.SearchEntry el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_search_entry(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.search_entry = this;
+            this.el = new Gtk.SearchEntry();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.width_request = 300;
+            this.el.hexpand = true;
+            this.el.placeholder_text = "Press enter to search";
+
+            // init method
+
+            var description =   Pango.FontDescription.from_string("monospace");
+               description.set_size(8000);
+                this.el.override_font(description);
+
+            //listeners
+            this.el.key_press_event.connect( (event) => {
+                
+                 if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
+                   GLib.debug("SAVE: ctrl-g  pressed");
+                       _this.forwardSearch(true);
+                   return true;
+               }
+                
+                
+              
+               if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {
+                       var res = _this.search(this.el.text);
+                       if (res > 0) {
+                               _this.search_results.el.label = "%d Matches".printf(res);
+                       } else {
+                               _this.search_results.el.label = "No Matches";
+                       }
+                       
+                   return true;
+            
+               }    
+               // print(event.key.keyval)
+               
+                return false;
+            
+            });
+            this.el.changed.connect( () => {
+               /*
+               if (this.el.text == "") {
+                       _this.search_results.el.hide();
+                       return;
+               }
+               var res = 0;
+               switch(_this.windowstate.state) {
+                       case WindowState.State.CODEONLY:
+                       ///case WindowState.State.CODE:
+                               // search the code being edited..
+                               res = _this.windowstate.code_editor_tab.search(this.el.text);
+                               
+                               break;
+                       case WindowState.State.PREVIEW:
+                               if (_this.windowstate.file.xtype == "Gtk") {
+                                        res = _this.windowstate.window_gladeview.search(this.el.text);
+                               } else { 
+                                        res = _this.windowstate.window_rooview.search(this.el.text);                   
+                               }
+                       
+                       
+                               break;
+               }
+               _this.search_results.el.show();
+               if (res > 0) {
+                       _this.search_results.el.label = "%d Matches".printf(res);
+               } else {
+                       _this.search_results.el.label = "No Matches";
+               }
+                       
+               */
+               
+            });
+        }
+
+        // user defined functions
+        public void forwardSearch (bool change_focus) {
+        
+        
+               _this.forwardSearch(change_focus);
+        
+        /*
+        
+               switch(_this.windowstate.state) {
+                       case WindowState.State.CODEONLY:
+                       //case WindowState.State.CODE:
+                               // search the code being edited..
+                               _this.windowstate.code_editor_tab.forwardSearch(change_focus);
+                                
+                               break;
+                       case WindowState.State.PREVIEW:
+                               if (_this.windowstate.file.xtype == "Gtk") {
+                                       _this.windowstate.window_gladeview.forwardSearch(change_focus);
+                               } else { 
+                                        _this.windowstate.window_rooview.forwardSearch(change_focus);
+                               }
+                       
+                               break;
+               }
+               */
+               
+        }
+    }
+
+    public class Xcls_MenuBar13 : Object
+    {
+        public Gtk.MenuBar el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_MenuBar13(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.MenuBar();
+
+            // my vars (dec)
+
+            // set gobject values
+            var child_0 = new Xcls_search_results( _this );
+            child_0.ref();
+            this.el.add (  child_0.el  );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_search_results : Object
+    {
+        public Gtk.ImageMenuItem el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+        public Xcls_ValaCompileErrors popup;
+
+        // ctor
+        public Xcls_search_results(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.search_results = this;
+            this.el = new Gtk.ImageMenuItem();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.always_show_image = true;
+            this.el.label = "Matches";
+            var child_0 = new Xcls_Image15( _this );
+            child_0.ref();
+            this.el.set_image (  child_0.el  );
+
+            //listeners
+            this.el.button_press_event.connect( () => {
+            /*
+                if (this.popup == null) {
+                    this.popup = new Xcls_ValaCompileErrors();
+                    this.popup.window = _this;
+                }
+               
+                
+                this.popup.show(this.notices, this.el);
+                */
+                return true;
+            });
+        }
+
+        // user defined functions
+    }
+    public class Xcls_Image15 : Object
+    {
+        public Gtk.Image el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Image15(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Image();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.icon_name = "system-search";
+            this.el.sensitive = false;
+        }
+
+        // user defined functions
+    }
+
+
+
+    public class Xcls_Button16 : Object
+    {
+        public Gtk.Button el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Button16(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Button();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.always_show_image = true;
+            this.el.label = "Next";
+            var child_0 = new Xcls_Image17( _this );
+            child_0.ref();
+            this.el.image = child_0.el;
+
+            //listeners
+            this.el.button_press_event.connect( (event) => {
+            
+               _this.forwardSearch(true);
+               
+               return true;
+            });
+        }
+
+        // user defined functions
+    }
+    public class Xcls_Image17 : Object
+    {
+        public Gtk.Image el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Image17(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Image();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.icon_name = "go-down";
+        }
+
+        // user defined functions
+    }
+
+
+    public class Xcls_Button18 : Object
+    {
+        public Gtk.Button el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Button18(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Button();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.always_show_image = true;
+            this.el.label = "Previous";
+            var child_0 = new Xcls_Image19( _this );
+            child_0.ref();
+            this.el.image = child_0.el;
+
+            //listeners
+            this.el.button_press_event.connect( (event) => {
+            
+               _this.backSearch(true);
+               
+               return true;
+            });
+        }
+
+        // user defined functions
+    }
+    public class Xcls_Image19 : Object
+    {
+        public Gtk.Image el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Image19(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Image();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.icon_name = "go-up";
+        }
+
+        // user defined functions
+    }
+
+
+    public class Xcls_MenuButton20 : Object
+    {
+        public Gtk.MenuButton el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_MenuButton20(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.MenuButton();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.always_show_image = true;
+            this.el.label = "Settings";
+            var child_0 = new Xcls_Image21( _this );
+            child_0.ref();
+            this.el.image = child_0.el;
+            var child_1 = new Xcls_search_settings( _this );
+            child_1.ref();
+            this.el.popup = child_1.el;
+        }
+
+        // user defined functions
+    }
+    public class Xcls_Image21 : Object
+    {
+        public Gtk.Image el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Image21(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Image();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.icon_name = "emblem-system";
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_search_settings : Object
+    {
+        public Gtk.Menu el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_search_settings(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.search_settings = this;
+            this.el = new Gtk.Menu();
+
+            // my vars (dec)
+
+            // set gobject values
+            var child_0 = new Xcls_case_sensitive( _this );
+            child_0.ref();
+            this.el.append(  child_0.el );
+            var child_1 = new Xcls_regex( _this );
+            child_1.ref();
+            this.el.append(  child_1.el );
+            var child_2 = new Xcls_multiline( _this );
+            child_2.ref();
+            this.el.append(  child_2.el );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_case_sensitive : Object
+    {
+        public Gtk.CheckMenuItem el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_case_sensitive(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.case_sensitive = this;
+            this.el = new Gtk.CheckMenuItem();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.label = "Case Sensitive";
+
+            // init method
+
+            {
+               this.el.show();
+            }
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_regex : Object
+    {
+        public Gtk.CheckMenuItem el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_regex(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.regex = this;
+            this.el = new Gtk.CheckMenuItem();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.label = "Regex";
+
+            // init method
+
+            {
+               this.el.show();
+            }
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_multiline : Object
+    {
+        public Gtk.CheckMenuItem el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_multiline(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.multiline = this;
+            this.el = new Gtk.CheckMenuItem();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.label = "Multi-line (add \\n)";
+
+            // init method
+
+            {
+               this.el.show();
+            }
+        }
+
+        // user defined functions
+    }
+
+
+
+
 
 
 }