summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/interfaces/gui/controls/Label.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/addons/interfaces/gui/controls/Label.cpp
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/addons/interfaces/gui/controls/Label.cpp')
-rw-r--r--xbmc/addons/interfaces/gui/controls/Label.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/xbmc/addons/interfaces/gui/controls/Label.cpp b/xbmc/addons/interfaces/gui/controls/Label.cpp
new file mode 100644
index 0000000..3922e3f
--- /dev/null
+++ b/xbmc/addons/interfaces/gui/controls/Label.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2005-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "Label.h"
+
+#include "ServiceBroker.h"
+#include "addons/binary-addons/AddonDll.h"
+#include "addons/kodi-dev-kit/include/kodi/gui/controls/Label.h"
+#include "guilib/GUIComponent.h"
+#include "guilib/GUILabelControl.h"
+#include "guilib/GUIWindowManager.h"
+#include "utils/log.h"
+
+namespace ADDON
+{
+
+void Interface_GUIControlLabel::Init(AddonGlobalInterface* addonInterface)
+{
+ addonInterface->toKodi->kodi_gui->control_label =
+ new AddonToKodiFuncTable_kodi_gui_control_label();
+
+ addonInterface->toKodi->kodi_gui->control_label->set_visible = set_visible;
+ addonInterface->toKodi->kodi_gui->control_label->set_label = set_label;
+ addonInterface->toKodi->kodi_gui->control_label->get_label = get_label;
+}
+
+void Interface_GUIControlLabel::DeInit(AddonGlobalInterface* addonInterface)
+{
+ delete addonInterface->toKodi->kodi_gui->control_label;
+}
+
+void Interface_GUIControlLabel::set_visible(KODI_HANDLE kodiBase,
+ KODI_GUI_CONTROL_HANDLE handle,
+ bool visible)
+{
+ CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
+ CGUILabelControl* control = static_cast<CGUILabelControl*>(handle);
+ if (!addon || !control)
+ {
+ CLog::Log(LOGERROR,
+ "Interface_GUIControlLabel::{} - invalid handler data (kodiBase='{}', handle='{}') "
+ "on addon '{}'",
+ __func__, kodiBase, handle, addon ? addon->ID() : "unknown");
+ return;
+ }
+
+ control->SetVisible(visible);
+}
+
+void Interface_GUIControlLabel::set_label(KODI_HANDLE kodiBase,
+ KODI_GUI_CONTROL_HANDLE handle,
+ const char* label)
+{
+ CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
+ CGUILabelControl* control = static_cast<CGUILabelControl*>(handle);
+ if (!addon || !control || !label)
+ {
+ CLog::Log(LOGERROR,
+ "Interface_GUIControlLabel::{} - invalid handler data (kodiBase='{}', handle='{}', "
+ "label='{}') on addon '{}'",
+ __func__, kodiBase, handle, static_cast<const void*>(label),
+ addon ? addon->ID() : "unknown");
+ return;
+ }
+
+ CGUIMessage msg(GUI_MSG_LABEL_SET, control->GetParentID(), control->GetID());
+ msg.SetLabel(label);
+ CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg, control->GetParentID());
+}
+
+char* Interface_GUIControlLabel::get_label(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle)
+{
+ CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
+ CGUILabelControl* control = static_cast<CGUILabelControl*>(handle);
+ if (!addon || !control)
+ {
+ CLog::Log(LOGERROR,
+ "Interface_GUIControlLabel::{} - invalid handler data (kodiBase='{}', handle='{}') "
+ "on addon '{}'",
+ __func__, kodiBase, handle, addon ? addon->ID() : "unknown");
+ return nullptr;
+ }
+
+ return strdup(control->GetDescription().c_str());
+}
+
+} /* namespace ADDON */