-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add KXMLGUI support and add konsole options for toolbar customization #362
Closed
HeitorAugustoLN
wants to merge
2
commits into
nix-community:trunk
from
HeitorAugustoLN:kxmlgui-rewrite
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
{ lib, ... }: | ||
let | ||
boolToString = bool: if bool then "1" else "0"; | ||
|
||
propertyType = lib.types.submodule { | ||
options = { | ||
name = lib.mkOption { | ||
type = lib.types.str; | ||
description = "The name of the property."; | ||
}; | ||
shortcut = lib.mkOption { | ||
type = lib.types.str; | ||
description = "The shortcut of the property."; | ||
}; | ||
}; | ||
}; | ||
|
||
actionPropertiesType = lib.types.submodule { | ||
options = { | ||
scheme = lib.mkOption { | ||
type = lib.types.str; | ||
description = "The scheme of the action properties."; | ||
}; | ||
properties = lib.mkOption { | ||
type = lib.types.listOf propertyType; | ||
description = "The properties of the action properties."; | ||
}; | ||
}; | ||
}; | ||
|
||
toolbarType = lib.types.submodule { | ||
options = { | ||
alreadyVisited = lib.mkOption { | ||
type = with lib.types; nullOr bool; | ||
default = null; | ||
example = true; | ||
description = "Whether the toolbar has already been visited."; | ||
apply = value: if value != null then boolToString value else null; | ||
}; | ||
noMerge = lib.mkOption { | ||
type = with lib.types; nullOr bool; | ||
default = null; | ||
example = true; | ||
description = "Whether the toolbar should not be merged."; | ||
apply = value: if value != null then boolToString value else null; | ||
}; | ||
items = lib.mkOption { | ||
type = lib.types.listOf itemType; | ||
description = "The items of the toolbar."; | ||
}; | ||
}; | ||
}; | ||
|
||
itemType = lib.types.submodule { | ||
options = { | ||
type = lib.mkOption { | ||
type = lib.types.enum [ | ||
"action" | ||
"group" | ||
"text" | ||
"separator" | ||
]; | ||
description = "The type of the item."; | ||
example = "action"; | ||
}; | ||
group = lib.mkOption { | ||
type = with lib.types; nullOr str; | ||
default = null; | ||
description = "The group of the item."; | ||
}; | ||
value = lib.mkOption { | ||
type = lib.types.str; | ||
description = "The value of the item."; | ||
}; | ||
}; | ||
}; | ||
|
||
menuType = lib.types.submodule { | ||
options = { | ||
name = lib.mkOption { | ||
type = lib.types.str; | ||
description = "The name of the menu."; | ||
}; | ||
items = lib.mkOption { | ||
type = lib.types.listOf itemType; | ||
description = "The items of the menu."; | ||
}; | ||
}; | ||
}; | ||
|
||
menuBarType = lib.types.submodule { | ||
options = { | ||
alreadyVisited = lib.mkOption { | ||
type = with lib.types; nullOr bool; | ||
default = null; | ||
example = true; | ||
description = "Whether the menu bar has already been visited."; | ||
apply = value: if value != null then boolToString value else null; | ||
}; | ||
noMerge = lib.mkOption { | ||
type = with lib.types; nullOr bool; | ||
default = null; | ||
example = true; | ||
description = "Whether the menu bar should not be merged."; | ||
apply = value: if value != null then boolToString value else null; | ||
}; | ||
menus = lib.mkOption { | ||
type = lib.types.listOf menuType; | ||
description = "The menus of the menu bar."; | ||
}; | ||
}; | ||
}; | ||
|
||
kxmlguiType = lib.types.submodule { | ||
options = { | ||
name = lib.mkOption { | ||
type = lib.types.str; | ||
description = "The name of the configuration."; | ||
}; | ||
version = lib.mkOption { | ||
type = lib.types.ints.unsigned; | ||
description = "The version of the configuration."; | ||
}; | ||
translationDomain = lib.mkOption { | ||
type = with lib.types; nullOr str; | ||
default = null; | ||
example = "kxmlgui6"; | ||
description = "The translation domain of the configuration"; | ||
}; | ||
menubar = lib.mkOption { | ||
type = lib.types.nullOr menuBarType; | ||
default = null; | ||
description = "The menu bar of the configuration."; | ||
}; | ||
toolbar = lib.mkOption { | ||
type = lib.types.nullOr toolbarType; | ||
default = null; | ||
description = "The toolbar of the configuration."; | ||
}; | ||
actionProperties = lib.mkOption { | ||
type = lib.types.nullOr actionPropertiesType; | ||
default = null; | ||
description = "The action properties of the configuration."; | ||
}; | ||
}; | ||
}; | ||
|
||
generateKXMLGUI = | ||
name: version: translationDomain: menubar: toolbar: actionProperties: | ||
let | ||
generateItem = | ||
item: | ||
if item.type == "action" then | ||
''<Action ${ | ||
lib.optionalString (item.group != null) ''group="${item.group}"'' | ||
} name="${item.value}"/>'' | ||
else if item.type == "group" then | ||
''<DefineGroup name="${item.value}"/>'' | ||
else if item.type == "text" then | ||
"<text ${ | ||
lib.optionalString (translationDomain != null) ''translationDomain="${translationDomain}"'' | ||
} >${item.value}</text>" | ||
else | ||
"<Separator ${lib.optionalString (item.group != null) ''group="${item.group}"''}/>"; | ||
generateActionProperty = | ||
property: ''<Action name="${property.name}" shortcut="${property.shortcut}">''; | ||
in | ||
'' | ||
<?xml version='1.0'?> | ||
<!DOCTYPE gui SYSTEM 'kpartgui.dtd'> | ||
<gui name="${name}" ${ | ||
lib.optionalString (translationDomain != null) ''translationDomain="${translationDomain}"'' | ||
} version="${toString version}"> | ||
${ | ||
lib.optionalString (menubar != null) '' | ||
<MenuBar ${ | ||
lib.optionalString (menubar.alreadyVisited != null) ''alreadyVisited="${menubar.alreadyVisited}"'' | ||
}> | ||
${ | ||
lib.concatMapStringsSep "\n" (menu: '' | ||
<Menu ${ | ||
lib.optionalString (menubar.alreadyVisited != null) ''alreadyVisited="${menubar.alreadyVisited}"'' | ||
} name="${menu.name}" ${ | ||
lib.optionalString (menubar.noMerge != null) ''noMerge="${menubar.noMerge}"'' | ||
}> | ||
${ | ||
lib.concatMapStringsSep "\n" (item: '' | ||
${generateItem item} | ||
'') menu.items | ||
} | ||
</Menu> | ||
'') menubar.menus | ||
} | ||
</MenuBar> | ||
'' | ||
} | ||
${ | ||
lib.optionalString (toolbar != null) '' | ||
<ToolBar ${ | ||
lib.optionalString (toolbar.alreadyVisited != null) ''alreadyVisited="${toolbar.alreadyVisited}"'' | ||
} name="${toolbar.name}" ${ | ||
lib.optionalString (toolbar.noMerge != null) ''noMerge="${toolbar.noMerge}"'' | ||
}> | ||
${lib.concatMapStringsSep "\n" (item: ''${generateItem item}'') toolbar.items} | ||
</ToolBar> | ||
'' | ||
} | ||
${ | ||
lib.optionalString (actionProperties != null) '' | ||
${lib.concatMapStringsSep "\n" (actionProps: '' | ||
<ActionProperties scheme="${actionProps.scheme}"> | ||
${ | ||
lib.concatMapStringsSep "\n" (property: '' | ||
${generateActionProperty property} | ||
'') actionProps.properties | ||
} | ||
</ActionProperties> | ||
'') actionProperties} | ||
'' | ||
} | ||
</gui> | ||
''; | ||
in | ||
{ | ||
inherit generateKXMLGUI kxmlguiType; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this not just be a submodule of
listOf itemType
, so instead of having something likeyou could have