Temporarily disable glava-config by default

This commit is contained in:
Jarcode
2019-09-09 14:05:26 -07:00
parent 5ff291fe51
commit aa875b2a81
4 changed files with 110 additions and 78 deletions

View File

@@ -2,7 +2,8 @@ local lfs = require "lfs"
local mappings = require "glava-config.mappings" local mappings = require "glava-config.mappings"
local config = { local config = {
Profile = { mt = {} } Profile = { mt = {} },
PROFILES_DIR = "profiles"
} }
config.Profile.__index = config.Profile config.Profile.__index = config.Profile
@@ -19,13 +20,17 @@ local function path_split(str, sep)
end end
-- Concatenates paths such that duplicate path separators are removed. -- Concatenates paths such that duplicate path separators are removed.
-- Can be used on non-split arguments -- Can be used on non-split arguments, and resolves `..` syntax
local function path_concat(...) local function path_concat(...)
local ret = {} local ret = {}
for _, v in ipairs({...}) do for _, v in ipairs({...}) do
for _, e in ipairs(path_split(v, "/")) do for _, e in ipairs(path_split(v, "/")) do
if e ~= "" or #ret == 0 then if e ~= "" or #ret == 0 then
ret[#ret + 1] = e if e == ".." and #ret >= 1 then
ret[#ret] = nil
else
ret[#ret + 1] = e
end
end end
end end
end end
@@ -66,27 +71,12 @@ local function none(...) return ... end
local MATCH_ENTRY_PATTERN = "^%s*%#(%a+)%s+(%a+)" local MATCH_ENTRY_PATTERN = "^%s*%#(%a+)%s+(%a+)"
local MATCH_DATA_PREFIX = "^%s*%#%a+%s+%a+" local MATCH_DATA_PREFIX = "^%s*%#%a+%s+%a+"
local MATCH_TYPES = { local MATCH_TYPES = {
["float"] = { ["float"] = { pattern = "(%d+.?%d*)" },
pattern = "(%d+.?%d*)", ["int"] = { pattern = "(%d+)" },
cast = tonumber, ["color-expr"] = { pattern = "(.+)" },
serialize = tostring ["expr"] = { pattern = "(.+)" },
}, ["int"] = { ["ident"] = { pattern = "(%a%w*)" },
pattern = "(%d+)", ["string"] = {
cast = tonumber,
serialize = function(x) tostring(math.floor(x)) end
}, ["color-expr"] = {
pattern = "(.+)",
cast = none,
serialize = none
}, ["expr"] = {
pattern = "(.+)",
cast = none,
serialize = none
}, ["ident"] = {
pattern = "(%w+)",
cast = none,
serialize = none
}, ["string"] = {
pattern = "(.+)", pattern = "(.+)",
cast = unquote, cast = unquote,
-- Read-ahead function to generate a fixed-width pattern -- Read-ahead function to generate a fixed-width pattern
@@ -195,18 +185,22 @@ local function unwrap(ret, err)
end end
function config.Profile:__call(args) function config.Profile:__call(args)
local self = { name = args.name } local self = { name = args.name or ".." }
self:rebuild() self:rebuild()
return setmetatable(self, config.Profile) return setmetatable(self, config.Profile)
end end
function config.Profile:rename(new) function config.Profile:rename(new)
error("not implemented")
end
function config.Profile:get_path()
return path_concat(glava.config_path, config.PROFILES_DIR, self.name)
end end
function config.Profile:rebuild() function config.Profile:rebuild()
self.store = {} self.store = {}
self.path = path_concat(glava.config_path, "profiles", self.name) self.path = path_concat(glava.config_path, config.PROFILES_DIR, self.name)
unwrap(create_p(self.path, "directory", true)) unwrap(create_p(self.path, "directory", true))
local unbuilt = {} local unbuilt = {}
for k, _ in pairs(mappings) do for k, _ in pairs(mappings) do
@@ -252,7 +246,7 @@ function config.Profile:rebuild_file(file, path, phony)
_, i, match = string.find(at, "%s*" .. MATCH_TYPES[v].transform(match)) _, i, match = string.find(at, "%s*" .. MATCH_TYPES[v].transform(match))
end end
if default == nil or fstore[key][t] == nil then if default == nil or fstore[key][t] == nil then
fstore[key][t] = MATCH_TYPES[v].cast(match) fstore[key][t] = MATCH_TYPES[v].cast and MATCH_TYPES[v].cast(match) or match
end end
at = string.sub(at, 1, i) at = string.sub(at, 1, i)
else break end else break end
@@ -297,7 +291,7 @@ function config.Profile:sync_file(fname)
local parts = { string.format("#%s", string.gsub(k, ":", " ")) } local parts = { string.format("#%s", string.gsub(k, ":", " ")) }
local field = fmap[k].field_type local field = fmap[k].field_type
for i, e in ipairs(type(field) == "table" and field or { field }) do for i, e in ipairs(type(field) == "table" and field or { field }) do
parts[#parts + 1] = MATCH_TYPES[e].serialize(v[i]) parts[#parts + 1] = MATCH_TYPES[e].serialize and MATCH_TYPES[e].serialize(v[i]) or v[i]
end end
local serialized = table.concat(parts, " ") local serialized = table.concat(parts, " ")
if v.line then buf[line] = serialized if v.line then buf[line] = serialized

View File

@@ -101,6 +101,13 @@ return function()
return unpack(ret) return unpack(ret)
end end
local function link(tbl)
for _, v in ipairs(tbl) do
v:get_style_context():add_class("linked")
end
return unpack(tbl)
end
local function ComboBoxFixed(tbl) local function ComboBoxFixed(tbl)
local inst = Gtk.ComboBoxText { id = tbl.id } local inst = Gtk.ComboBoxText { id = tbl.id }
for _, v in pairs(tbl) do for _, v in pairs(tbl) do
@@ -222,7 +229,7 @@ return function()
end end
-- Generators for producing widgets (and their layouts) that bind to configuration values -- Generators for producing widgets (and their layouts) that bind to configuration values
-- note: `get_data` returns _formatted_ data, such that it can be written directly in GLSL -- note: `get_data` returns stringified data
local widget_generators local widget_generators
widget_generators = { widget_generators = {
-- A switch to represent a true/false value -- A switch to represent a true/false value
@@ -268,7 +275,7 @@ return function()
if attrs.translate then if attrs.translate then
text = attrs.translate[text] text = attrs.translate[text]
end end
return (not attrs._ignore_format) and string.format("\"%s\"", text) or text return text
end, end,
connect = function(f) connect = function(f)
-- Note: the underlying widget can be `GtkComboBoxText` or `GtkEntry`; -- Note: the underlying widget can be `GtkComboBoxText` or `GtkEntry`;
@@ -279,7 +286,6 @@ return function()
end, end,
-- Entry for a valid C/GLSL identity, may have predefined selections -- Entry for a valid C/GLSL identity, may have predefined selections
["ident"] = function(attrs) ["ident"] = function(attrs)
attrs._ignore_format = true
local s = widget_generators.string(attrs) local s = widget_generators.string(attrs)
-- Set fixed-width font if the users enter/select identifiers by their name, -- Set fixed-width font if the users enter/select identifiers by their name,
-- rather than a description to indicate it's a GLSL identity -- rather than a description to indicate it's a GLSL identity
@@ -333,7 +339,7 @@ return function()
return { return {
widget = wrap_label(widget, attrs.label), widget = wrap_label(widget, attrs.label),
set_data = function(x) set_data = function(x)
widget:set_value(x) widget:set_text(x)
return true return true
end, end,
get_data = function() return widget:get_text() end, get_data = function() return widget:get_text() end,
@@ -359,7 +365,7 @@ return function()
return { return {
widget = wrap_label(apply { vexpand = false, widget }, attrs.label), widget = wrap_label(apply { vexpand = false, widget }, attrs.label),
set_data = function(x) set_data = function(x)
widget:set_value(x) widget:set_text(x)
return true return true
end, end,
get_data = function() return widget:get_text() end, get_data = function() return widget:get_text() end,
@@ -418,7 +424,7 @@ return function()
spacing = 0, spacing = 0,
entry, btn entry, btn
} }
widget:get_style_context():add_class("linked") link { widget }
widget = wrap_label(widget, attrs.label) widget = wrap_label(widget, attrs.label)
function btn:on_clicked() function btn:on_clicked()
local c_change_staged = false local c_change_staged = false
@@ -645,7 +651,6 @@ return function()
-- Extra widget for special service/autostart functionality -- Extra widget for special service/autostart functionality
local ServiceView = function(self) local ServiceView = function(self)
local switch = Gtk.Switch { local switch = Gtk.Switch {
id = "autostart_enabled",
sensitive = false, sensitive = false,
hexpand = false hexpand = false
} }
@@ -681,7 +686,7 @@ return function()
return ConfigView { return ConfigView {
{ "Enabled", Gtk.Box { Gtk.Box { hexpand = true }, switch } }, { "Enabled", Gtk.Box { Gtk.Box { hexpand = true }, switch } },
{ "Autostart Method", method } { "Autostart Method", method }
} }, switch
end end
-- Produce a widget containing a scroll area full of widgets bound to -- Produce a widget containing a scroll area full of widgets bound to
@@ -737,16 +742,27 @@ return function()
end end
args[#args + 1] = { tab_label = v.name, ConfigView(layout) } args[#args + 1] = { tab_label = v.name, ConfigView(layout) }
end end
local service, chk = ServiceView(self)
args[#args + 1] = { args[#args + 1] = {
tab_label = "Autostart", tab_label = "Autostart",
name ~= "Default" and ServiceView(self) or name ~= "Default" and service or
Gtk.Label { Gtk.Box {
label = "Autostart options are not available for the default user profile." valign = "CENTER",
} } orientation = "VERTICAL",
spacing = 8,
Gtk.Label {
label = "Autostart options are not available for the default user profile."
},
Gtk.Button {
hexpand = false,
halign = "CENTER",
label = "Show Profiles"
} } }
args.expand = true args.expand = true
notebook = Gtk.Notebook(args) notebook = Gtk.Notebook(args)
notebook:show_all() notebook:show_all()
self.widget = notebook self.widget = notebook
self.autostart_enabled = chk
function self:rename(new) function self:rename(new)
self.name = new self.name = new
end end
@@ -767,9 +783,10 @@ return function()
border_width = 5, border_width = 5,
Gtk.Box { Gtk.Box {
orientation = "HORIZONTAL", orientation = "HORIZONTAL",
spacing = 8, spacing = 6,
homogeneous = false, homogeneous = false,
Gtk.Box { Gtk.Box {
hexpand = false,
orientation = "VERTICAL", orientation = "VERTICAL",
spacing = 5, spacing = 5,
Gtk.ScrolledWindow { Gtk.ScrolledWindow {
@@ -798,31 +815,53 @@ return function()
activatable = ItemColumn.ACTIVABLE, activatable = ItemColumn.ACTIVABLE,
visible = ItemColumn.VISIBLE visible = ItemColumn.VISIBLE
} } } } } }, } } } } } },
(function() link {
local box = Gtk.Box { Gtk.Box {
homogeneous = true, hexpand = true,
bind { bind {
reload = Gtk.Button { reload = Gtk.Button {
label = "Reload", Gtk.Image {
icon_name = "view-refresh-symbolic"
} }, } },
bind { },
add = Gtk.Button { bind {
label = "New", add = Gtk.Button {
} }, halign = "FILL",
bind { hexpand = true,
remove = Gtk.Button { label = "Create Profile",
label = "Delete", } },
sensitive = false, bind {
} } } remove = Gtk.Button {
box:get_style_context():add_class("linked") halign = "END",
return box sensitive = false,
end)(), Gtk.Image {
}, icon_name = "user-trash-symbolic"
bind { } } } } } },
stack_view = Gtk.Stack { Gtk.Box {
expand = true, orientation = "VERTICAL",
transition_type = Gtk.StackTransitionType.CROSSFADE spacing = 6,
} } } } link {
Gtk.Box {
Gtk.ToggleButton {
Gtk.Image {
icon_name = "view-paged-symbolic"
},
on_clicked = function()
--
end
},
bind {
display_path = Gtk.Entry {
-- todo: bind to config
text = "~/.config/glava/rc.glsl",
editable = false,
hexpand = true
} } } },
bind {
stack_view = Gtk.Stack {
expand = true,
transition_type = Gtk.StackTransitionType.CROSSFADE
} } } } }
local selection = binds.view:get_selection() local selection = binds.view:get_selection()
selection.mode = 'SINGLE' selection.mode = 'SINGLE'
@@ -872,15 +911,12 @@ return function()
function binds.toggle_renderer:on_toggled(path_string) function binds.toggle_renderer:on_toggled(path_string)
local path = Gtk.TreePath.new_from_string(path_string) local path = Gtk.TreePath.new_from_string(path_string)
if view_registry[item_store[path][ItemColumn.PROFILE]] if view_registry[item_store[path][ItemColumn.PROFILE]].autostart_enabled.active
.widget:get_children()[1].autostart_enabled.active
~= not item_store[path][ItemColumn.ENABLED] then ~= not item_store[path][ItemColumn.ENABLED] then
view_registry[item_store[path][ItemColumn.PROFILE]] view_registry[item_store[path][ItemColumn.PROFILE]].autostart_enabled:activate()
.widget:get_children()[1].autostart_enabled:activate()
end end
item_store[path][ItemColumn.ENABLED] = item_store[path][ItemColumn.ENABLED] =
view_registry[item_store[path][ItemColumn.PROFILE]] view_registry[item_store[path][ItemColumn.PROFILE]].autostart_enabled.active
.widget:get_children()[1].autostart_enabled.active
end end
function binds.add:on_clicked() function binds.add:on_clicked()
@@ -889,7 +925,8 @@ return function()
[ItemColumn.PROFILE] = profile_name, [ItemColumn.PROFILE] = profile_name,
[ItemColumn.ENABLED] = false, [ItemColumn.ENABLED] = false,
[ItemColumn.ACTIVABLE] = false, [ItemColumn.ACTIVABLE] = false,
[ItemColumn.VISIBLE] = true [ItemColumn.VISIBLE] = true,
[ItemColumn.WEIGHT] = 400
} }
local view = ProfileView(profile_name) local view = ProfileView(profile_name)
item_store:append(entry) item_store:append(entry)
@@ -912,7 +949,7 @@ return function()
spacing = 8, spacing = 8,
border_width = 8, border_width = 8,
Gtk.Image { Gtk.Image {
icon_name = "dialog-warning", icon_name = "dialog-warning-symbolic",
icon_size = Gtk.IconSize.DIALOG, icon_size = Gtk.IconSize.DIALOG,
}, },
Gtk.Label { Gtk.Label {

View File

@@ -939,9 +939,9 @@ struct glava_renderer* rd_new(const char** paths, const char* entry,
} }
glava_abort(); glava_abort();
} }
if (verbose) printf("Using backend: '%s'\n", backend); if (verbose) printf("Using backend: '%s'\n", backend);
for (size_t t = 0; t < wcbs_idx; ++t) { for (size_t t = 0; t < wcbs_idx; ++t) {
if (wcbs[t]->name && !strcmp(wcbs[t]->name, backend)) { if (wcbs[t]->name && !strcmp(wcbs[t]->name, backend)) {
gl->wcb = wcbs[t]; gl->wcb = wcbs[t];
@@ -1061,7 +1061,8 @@ struct glava_renderer* rd_new(const char** paths, const char* entry,
}, },
{ .name = "nativeonly", .fmt = "b", { .name = "nativeonly", .fmt = "b",
.handler = RHANDLER(name, args, { .handler = RHANDLER(name, args, {
fprintf(stderr, "WARNING: `nativeonly` is deprecated, use `#if PREMULTIPLY_ALPHA == 1`!\n"); fprintf(stderr, "WARNING: `nativeonly` is deprecated,"
" use `#if PREMULTIPLY_ALPHA == 1`!\n");
if (current) if (current)
current->nativeonly = *(bool*) args[0]; current->nativeonly = *(bool*) args[0];
else { else {

View File

@@ -8,7 +8,7 @@ option('glad', type: 'boolean', value: false,
description: 'Download and build GLAD headers (non-reproducable)') description: 'Download and build GLAD headers (non-reproducable)')
option('disable_obs', type: 'boolean', value: false, option('disable_obs', type: 'boolean', value: false,
description: 'Disable OBS Studio plugin support') description: 'Disable OBS Studio plugin support')
option('disable_config', type: 'boolean', value: false, option('disable_config', type: 'boolean', value: true,
description: 'Skip building GLava GTK+ configuration tool') description: 'Skip building GLava GTK+ configuration tool')
option('shader_install_dir', type: 'string', value: '/etc/xdg', option('shader_install_dir', type: 'string', value: '/etc/xdg',
description: 'GLSL config/module system install directory') description: 'GLSL config/module system install directory')