Skip to content

Commit

Permalink
Added the ability to customize application namespace (Resolves #6)
Browse files Browse the repository at this point in the history
- Fixed a few issues with compiling terminal app
  • Loading branch information
kjlaw89 committed Jun 17, 2018
1 parent 97bf2ac commit e606291
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 10 deletions.
2 changes: 2 additions & 0 deletions data/com.github.kjlaw89.archetype.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<file alias="lgpl-3.0-preamble" compressed="true">licenses/lgpl-3.0-preamble.txt</file>
<file alias="mit" compressed="true">licenses/mit.txt</file>
<file alias="mit-preamble" compressed="true">licenses/mit-preamble.txt</file>
<file alias="mpl-2.0" compressed="true">licenses/mpl-2.0.txt</file>
<file alias="mpl-2.0-preamble" compressed="true">licenses/mpl-2.0-preamble.txt</file>
<file alias="unlicense" compressed="true">licenses/unlicense.txt</file>
<file alias="unlicense-preamble" compressed="true">licenses/unlicense-preamble.txt</file>
<file alias="custom" compressed="true">licenses/custom.txt</file>
Expand Down
Binary file modified data/templates/blank.tar.gz
Binary file not shown.
Binary file modified data/templates/granite.tar.gz
Binary file not shown.
Binary file modified data/templates/terminal.tar.gz
Binary file not shown.
Binary file modified data/templates/utility.tar.gz
Binary file not shown.
Binary file modified data/templates/widget.tar.gz
Binary file not shown.
13 changes: 10 additions & 3 deletions src/models/Template.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ namespace App.Models {
public string directory { get; set; }
public string domain { get; set; }
public string executable { get; set; }
public bool git { get; set; default = false;}
public bool git { get; set; default = false; }
public string namespace { get; set; }
public string libraries { get; set; }
public string license { get; set; }
public string packages { get; set; }
Expand Down Expand Up @@ -67,6 +68,7 @@ namespace App.Models {
this.domain = view.domain_entry.text;
this.executable = view.exec_entry.text;
this.git = view.git_switch.active;
this.namespace = view.namespace_entry.text;
this.libraries = view.libraries_list ();
this.license = view.license_combo.active_id;
this.packages = view.packages_list ();
Expand Down Expand Up @@ -187,8 +189,9 @@ namespace App.Models {
* {{ author }} - replace with author
* {{ author-email }} - replace with author_email
* {{ rdnn-path }} - replace with rdnn_path
* {{ repo-url }} - still need to get
* {{ website-url }} - still need to get
* {{ repo-url }} - replace with repo_url
* {{ website-url }} - replace with website_url
* AppNamespace - replace with namespace
* {{ exe-name }} - replace with executable
* {{ path }} - replace with path application will be stored in
* {{ libraries-control }} - replace with packages (formatted for debian control file)
Expand Down Expand Up @@ -258,6 +261,7 @@ namespace App.Models {
replace_in_files (export_path, "{{ libraries-control }}", format_libraries_control (packages));
replace_in_files (export_path, "{{ libraries-readme }}", format_libraries_readme (packages));
replace_in_files (export_path, "{{ libraries-meson }}", format_libraries_meson (libraries));
replace_in_files (export_path, "AppNamespace", namespace);
replace_in_files (export_path, "{{ categories }}", "");
replace_in_files (export_path, "{{ keywords }}", "");
replace_in_files (export_path, "{{ terminal-mode }}", (template == "terminal" ? "true" : "false"));
Expand Down Expand Up @@ -451,6 +455,9 @@ namespace App.Models {
var libs = libraries.split (",");
foreach (var l in libs) {
var library = l.strip ();
if (library == "") {
continue;
}

if (i == 0) {
output = "dependency('"+ library +"'),\n";
Expand Down
46 changes: 39 additions & 7 deletions src/views/AppView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace App.Views {
private Gtk.Label domain_label;
private Gtk.Label exec_label;
private Gtk.Label git_label;
private Gtk.Label namespace_label;
private Gtk.Label license_label;
private Gtk.Label libraries_label;
private Gtk.Label punchline_label;
Expand All @@ -60,6 +61,7 @@ namespace App.Views {
public Gtk.Label executable_label { get; private set; }
public Gtk.Button generate_button { get; private set; }
public Gtk.Switch git_switch { get; private set; }
public Gtk.Entry namespace_entry { get; private set; }
public Gtk.Button next_button { get; private set; }
public Gtk.ComboBoxText license_combo { get; private set; }
public Gtk.Button license_lookup_button { get; private set; }
Expand Down Expand Up @@ -240,7 +242,7 @@ namespace App.Views {

switch (stage) {
case "project":
if (template_combo.active_id == null || license_combo.active_id == null || title_entry.text == "") {
if (template_combo.active_id == null || license_combo.active_id == null || title_entry.text == "" || namespace_entry.text == "") {
valid = false;
}

Expand Down Expand Up @@ -447,7 +449,7 @@ namespace App.Views {
title_label.mnemonic_widget = title_entry;

grid.attach (title_label, 0, 3, 1, 1);
grid.attach (title_entry, 1, 3, 1, 1);
grid.attach (title_entry, 1, 3, 3, 1);

// Executable Name Entry
exec_entry = new Gtk.Entry ();
Expand All @@ -469,8 +471,38 @@ namespace App.Views {
exec_label.halign = Gtk.Align.END;
exec_label.mnemonic_widget = exec_entry;

grid.attach (exec_label, 2, 3, 1, 1);
grid.attach (exec_entry, 3, 3, 1, 1);
grid.attach (exec_label, 0, 4, 1, 1);
grid.attach (exec_entry, 1, 4, 1, 1);

// Namespace Entry
namespace_entry = new Gtk.Entry ();
namespace_entry.hexpand = true;
namespace_entry.text = "App";
namespace_entry.secondary_icon_name = "dialog-information-symbolic";
namespace_entry.secondary_icon_tooltip_text = _("Namespaces are alpha only [a-zA-Z]");
namespace_entry.key_release_event.connect ((key) => {
validate_next ();

var text = namespace_entry.text;
var regex = new Regex ("[^a-zA-Z]+");
namespace_entry.text = regex.replace (text, text.length, 0, "");

return false;
});
namespace_entry.changed.connect (() => {
validate_next ();

var text = namespace_entry.text;
var regex = new Regex ("[^a-zA-Z]+");
namespace_entry.text = regex.replace (text, text.length, 0, "");
});

namespace_label = new Gtk.Label.with_mnemonic (_("Name_space") + ":");
namespace_label.halign = Gtk.Align.END;
namespace_label.mnemonic_widget = namespace_entry;

grid.attach (namespace_label, 2, 4, 1, 1);
grid.attach (namespace_entry, 3, 4, 1, 1);

// Domain Entry
domain_entry = new Gtk.Entry ();
Expand Down Expand Up @@ -498,9 +530,9 @@ namespace App.Views {
domain_label.margin_top = 4;
domain_label.mnemonic_widget = domain_entry;

grid.attach (domain_label, 0, 4, 1, 1);
grid.attach (domain_entry, 1, 4, 1, 1);
grid.attach (executable_label, 2, 4, 2, 1);
grid.attach (domain_label, 0, 5, 1, 1);
grid.attach (domain_entry, 1, 5, 1, 1);
grid.attach (executable_label, 2, 5, 2, 1);

this.stack_view.add_named (grid, "project");
}
Expand Down

0 comments on commit e606291

Please sign in to comment.