add support for icons and desktop file - precursor to removing autotools build
authorAlan Knowles <alan@roojs.com>
Tue, 23 Jan 2024 15:49:57 +0000 (23:49 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 23 Jan 2024 15:49:57 +0000 (23:49 +0800)
meson.build
src/Builder4/DialogFiles.bjs
src/Builder4/DialogFiles.vala
src/JsRender/Dir.vala
src/Project/Meson.vala
src/Project/Project.vala

index 12bb9e1..ec1d61f 100644 (file)
@@ -46,6 +46,35 @@ add_project_arguments(['--vapidir',  meson.current_source_dir() / 'src/vapi'], l
 
 
 
+install_data(
+       'pixmaps/16x16/apps/roobuilder.png',
+       install_dir:  get_option('datadir') + '/icons/hicolor/16x16/apps/'
+)
+
+install_data(
+       'pixmaps/22x22/apps/roobuilder.png',
+       install_dir:  get_option('datadir') + '/icons/hicolor/22x22/apps/'
+)
+
+install_data(
+       'pixmaps/24x24/apps/roobuilder.png',
+       install_dir:  get_option('datadir') + '/icons/hicolor/24x24/apps/'
+)
+
+install_data(
+       'pixmaps/32x32/apps/roobuilder.png',
+       install_dir:  get_option('datadir') + '/icons/hicolor/32x32/apps/'
+)
+
+install_data(
+       'pixmaps/48x48/apps/roobuilder.png',
+       install_dir:  get_option('datadir') + '/icons/hicolor/48x48/apps/'
+)
+
+gnome = import('gnome')
+gnome.post_install(gtk_update_icon_cache : true)
+
+
 roobuilder_src = files([
    'src/Builder4/About.vala',
    'src/Builder4/DialogConfirm.vala',
index 83b43db..1fba75d 100644 (file)
                     "\tvar str = _this.searchbox.el.text.down();\t",
                     "\tif (j.xtype == \"Dir\") {",
                     "\t",
-                    "\t\tif (str.length < 1) {",
-                    "\t\t\treturn true;",
-                    "\t\t}",
+                    "\t\t",
                     "\t\tfor (var i =0 ; i < j.childfiles.n_items; i++) {",
                     "\t\t\tvar f = (JsRender.JsRender) j.childfiles.get_item(i);",
                     "\t\t\tif (f.xtype != \"PlainFile\") {",
                     "\t\t\t\tcontinue;",
                     "\t\t\t}",
+                    "\t\t\tif (f.content_type.contains(\"image\")) {",
+                    "\t\t\t\tcontinue;",
+                    "\t\t\t}",
+                    "\t\t\tif (str.length < 1) {",
+                    "\t\t\t\treturn true;",
+                    "\t\t\t}",
                     "\t\t\tif (f.name.down().contains(str)) {",
                     "\t\t\t\treturn true;",
                     "\t\t\t}",
+                    "\t\t\t",
                     "\t\t}",
+                    "\t\t ",
                     "\t\treturn false;",
                     "\t}",
                     "\tif (j.xtype != \"PlainFile\") {",
                     "\t\treturn false;",
                     "\t}",
-                    "",
-                    "\tif (str.length < 1) {",
+                    " \tif (j.content_type.contains(\"image\")) {",
+                    "\t\treturn false;",
+                    "\t}",
+                    "\t\t\t ",
+                    "\tif (str.length < 1) { // no search.",
                     "\t\treturn true;",
                     "\t}",
                     "\tif (j.name.down().contains(str)) {",
index 346b64f..318e186 100644 (file)
@@ -1533,25 +1533,34 @@ public class DialogFiles : Object
        var str = _this.searchbox.el.text.down();       
        if (j.xtype == "Dir") {
        
-               if (str.length < 1) {
-                       return true;
-               }
+               
                for (var i =0 ; i < j.childfiles.n_items; i++) {
                        var f = (JsRender.JsRender) j.childfiles.get_item(i);
                        if (f.xtype != "PlainFile") {
                                continue;
                        }
+                       if (f.content_type.contains("image")) {
+                               continue;
+                       }
+                       if (str.length < 1) {
+                               return true;
+                       }
                        if (f.name.down().contains(str)) {
                                return true;
                        }
+                       
                }
+                
                return false;
        }
        if (j.xtype != "PlainFile") {
                return false;
        }
-
-       if (str.length < 1) {
+       if (j.content_type.contains("image")) {
+               return false;
+       }
+                        
+       if (str.length < 1) { // no search.
                return true;
        }
        if (j.name.down().contains(str)) {
index f51972e..448db42 100644 (file)
@@ -5,9 +5,10 @@
 
 namespace JsRender {
        int did = 1;
+       
        public  class Dir : JsRender
        {  
-               
+               //Gee.ArrayList<Dir> subdirs;
                public Dir(Project.Project project, string path) {
            
                base( project, path);
index 427b826..fd727c8 100644 (file)
@@ -45,8 +45,12 @@ namespace Project {
                        //add_project_arguments(['--vapidir', vapi_dir], language: 'vala')
 
                        var targets = "";
+                       var icons = "";
+                       var desktops = "";
                        foreach(var cg in this.project.compilegroups.values) {
                                targets += this.addTarget(cg);
+                               icons += this.addIcons(cg);
+                               desktops += this.addDesktop(cg);
                        }
                        var data = 
 
@@ -79,11 +83,14 @@ conf.set('PROJECT_NAME', meson.project_name())
 
 $addvapidir
 
+$icons
+
+$desktops
 
 $targets
 ";             
 
-
+GLib.debug("write meson : %s" , data);
 // removed.. add_project_arguments(['--enable-gobject-tracing', '--fatal-warnings'], language: 'vala')
 
                        try {
@@ -118,5 +125,50 @@ $targets
 
                        return str;
                }
-       }
+               
+               string addIcons(GtkValaSettings cg)
+               {
+                        
+                       var ret = "";
+                       string[] sizes = { "16x16", "22x22","24x24","32x32", "48x48" } ;
+                       foreach(var size in sizes) {
+                               GLib.debug("looking for on : %s" ,  "pixmaps/" + size + "/apps/" + cg.name  + ".png");
+                               var img = this.project.getByRelPath( "pixmaps/" + size + "/apps/" + cg.name  + ".png");
+                               if (img == null) {
+                                       continue;
+                               }
+                               var path = img.relpath;
+                               ret += @"
+install_data(
+       '$path',
+       install_dir:  get_option('datadir') + '/icons/hicolor/$size/apps/'
+)
+";
+                       }
+                       if (ret == "") {
+                               return "";
+                       }
+                       ret += "
+gnome = import('gnome')
+gnome.post_install(gtk_update_icon_cache : true)
+";
+                       return ret;
+               }
+               
+               string addDesktop(GtkValaSettings cg)
+               {
+                       // we could actually generate this!?!
+                       var d  = this.project.getByRelPath(   cg.name  + ".desktop");
+                       if (d == null) {
+                               return "";
+                       }
+                       var path = d.relpath;
+                       return @"
+install_data(
+       '$path',
+       install_dir : get_option('datadir') + '/applications/''
+)
+";
+
+}
 }
\ No newline at end of file
index c15db61..f7b24e6 100644 (file)
@@ -736,7 +736,7 @@ namespace Project {
                                                subs.add(dir  + "/" + fn);
                                                continue;
                                        }
-                                       if (Regex.match_simple("\\.(o|cache|gif|jpg|png|gif|out|stamp|~)$", fn)) { // object..
+                                       if (Regex.match_simple("\\.(o|cache|out|stamp|~)$", fn)) { // object..
                                                continue;
                                        }
                                        if (Regex.match_simple("^(config1.builder|a.out|stamp-h1|depcomp|config.log|config.status)$", fn)) { // object..