Skip to content

Commit

Permalink
Added make_tree for TreeView
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzaare committed May 2, 2023
1 parent 6470e98 commit 7d588c9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
20 changes: 10 additions & 10 deletions example/content.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,16 @@ page(
# publications.html
# option 1: background for the page is set to start with white to emphasize the items
######################################
page(
title="publications",
background=bg_white,
sections=[
Section(
title="Publications",
items=Publications("publications.bib")
)
]
)
# page(
# title="publications",
# background=bg_white,
# sections=[
# Section(
# title="Publications",
# items=Publications("publications.bib")
# )
# ]
# )

######################################
# research.html
Expand Down
2 changes: 2 additions & 0 deletions src/StaticWebPages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export GitRepo
export TimeLine
export TimeLineColor

export ui

function load_example()
include(joinpath(@__DIR__,"..","example","content.jl"))
end
Expand Down
48 changes: 32 additions & 16 deletions src/ui.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
module UI

using Gtk
# using GtkReactive
function make_tree!(ts, item::Item, parent)
str = replace(String(Symbol(typeof(item))), "StaticWebPages." => "")
push!(ts, (str,), parent)
end

import ..content
function make_tree!(ts, nest::Nest, parent)
nest = push!(ts, ("Nest",), parent)
foreach(item -> make_tree!(ts, item, nest), nest.list)
end

export ui
function make_tree!(ts, s::Section, parent)
section = push!(ts, (s.title,), parent)
make_tree!(ts, s.items, section)
end

tree_dict(content, dict) = nothing
function make_tree!(ts, s::Double, parent)
double = push!(ts, ("Double",), parent)
make_tree!(ts, s.first, double)
make_tree!(ts, s.second, double)
end

tree_dict(x) = tree_dict(x, Dict{String, Any}())
function make_tree!(ts, x)
for (key, val) in x
page = push!(ts, (val.title,))
foreach(section -> make_tree!(ts, section, page), val.sections)
end
end

set_subtitle!(widget, str) = set_gtk_property!(widget, :subtitle, str)

function choose_project_folder(win)
dir = open_dialog("Select content.jl folder", win, action=GtkFileChooserAction.SELECT_FOLDER)
if isdir(dir)
set_subtitle!(header, "$(pwd())")
end
end

function ui()
ts = GtkTreeStore(String)
info = push!(ts,("Informations",))
Expand All @@ -21,10 +43,6 @@ function ui()
c1 = GtkTreeViewColumn("Content", r1, Dict([("text",0)]))
push!(tv,c1)

for page in keys(content)
push!(ts, (page,))
end

uifile = joinpath(@__DIR__, "builder", "StaticWebPages.glade")
builder = GtkBuilder(filename=uifile)

Expand All @@ -42,11 +60,9 @@ function ui()

push!(shokupan, tv)

set_subtitle!(header, "$(pwd())")

showall(win)

# make_tree!(ts, content)

return win
end

end

0 comments on commit 7d588c9

Please sign in to comment.