local PT = AhUI
local L = PT.L
local LDB = LibStub("LibDataBroker-1.1")
local LDBIcon = LibStub("LibDBIcon-1.0")

local broker = LDB:NewDataObject("AhUI", {
    type = "data source",
    text = "AhUI",
    icon = "Interface\\AddOns\\AhUI\\media\\AhUI.tga",

OnClick = function(self, button)
    if button == "LeftButton" then
        if PT.Settings and PT.Settings.category then
            Settings.OpenToCategory(PT.Settings.category:GetID())
        end
    elseif button == "RightButton" then
        if PT.WelcomeUI then
            PT.WelcomeUI:Show()
        end
    end
end,
OnTooltipShow = function(tt)
    tt:AddLine(L["LDB_TITLE"])
    tt:AddLine(L["LDB_LEFT_CLICK"], 1, 1, 1)
    tt:AddLine(L["LDB_RIGHT_CLICK"], 1, 1, 1)
end,
})

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function()
    AhUI_DB = AhUI_DB or {}
    AhUI_DB.minimap = AhUI_DB.minimap or { hide = false }

    LDBIcon:Register("AhUI", broker, AhUI_DB.minimap)
end)
