Пример #1
0
int Dialog::select(const String& heading, const std::vector<String>& list, int autoclose) throw (WindowException)
{
    DelayedCallGuard dcguard(languageHook);
    const int window = WINDOW_DIALOG_SELECT;
    CGUIDialogSelect* pDialog= (CGUIDialogSelect*)g_windowManager.GetWindow(window);
    if (pDialog == NULL)
        throw WindowException("Error: Window is NULL, this is not possible :-)");

    pDialog->Reset();
    if (!heading.empty())
        pDialog->SetHeading(heading);

    String listLine;
    for(unsigned int i = 0; i < list.size(); i++)
    {
        listLine = list[i];
        pDialog->Add(listLine);
    }
    if (autoclose > 0)
        pDialog->SetAutoClose(autoclose);

    //send message and wait for user input
    XBMCWaitForThreadMessage(TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW);

    return pDialog->GetSelectedLabel();
}
Пример #2
0
    void Window::doModal()
    {
      TRACE;
      if (!existingWindow)
      {
        bModal = true;

        if(iWindowId != ACTIVE_WINDOW) 
          show();

        while (bModal && !g_application.m_bStop)
        {
// TODO: garbear added this code to the pythin window.cpp class and
//  commented in XBPyThread.cpp. I'm not sure how to handle this 
//  in this native implementation.
//          // Check if XBPyThread::stop() raised a SystemExit exception
//          if (PyThreadState_Get()->async_exc == PyExc_SystemExit)
//          {
//            CLog::Log(LOGDEBUG, "PYTHON: doModal() encountered a SystemExit exception, closing window and returning");
//            Window_Close(self, NULL);
//            break;
//          }
          languageHook->makePendingCalls(); // MakePendingCalls
          {
            DelayedCallGuard dcguard(languageHook);            
            WaitForActionEvent();
          }
        }
      }
    }
Пример #3
0
std::vector<String> Dialog::browseMultiple(int type, const String& heading, const String& s_shares,
        const String& mask, bool useThumbs,
        bool useFileDirectories, const String& defaultt ) throw (WindowException)
{
    DelayedCallGuard dcguard(languageHook);
    VECSOURCES *shares = CMediaSourceSettings::Get().GetSources(s_shares);
    CStdStringArray tmpret;
    String lmask = mask;
    if (!shares)
        throw WindowException("Error: GetSourcesFromType given %s is NULL.",s_shares.c_str());

    if (useFileDirectories && (!lmask.empty() && !(lmask.size() == 0)))
        lmask += "|.rar|.zip";

    if (type == 1)
        CGUIDialogFileBrowser::ShowAndGetFileList(*shares, lmask, heading, tmpret, useThumbs, useFileDirectories);
    else if (type == 2)
        CGUIDialogFileBrowser::ShowAndGetImageList(*shares, heading, tmpret);
    else
        throw WindowException("Error: Cannot retreive multuple directories using browse %s is NULL.",s_shares.c_str());

    std::vector<String> valuelist;
    int index = 0;
    for (CStdStringArray::iterator iter = tmpret.begin(); iter != tmpret.end(); iter++)
        valuelist[index++] = (*iter);

    return valuelist;
}
Пример #4
0
 void Addon::setSetting(const char* id, const String& value)
 {
   DelayedCallGuard dcguard(languageHook);
   ADDON::AddonPtr addon(pAddon);
   bool save=true;
   if (g_windowManager.IsWindowActive(WINDOW_DIALOG_ADDON_SETTINGS))
   {
     CGUIDialogAddonSettings* dialog = (CGUIDialogAddonSettings*)g_windowManager.GetWindow(WINDOW_DIALOG_ADDON_SETTINGS);
     if (dialog->GetCurrentID() == addon->ID())
     {
       CGUIMessage message(GUI_MSG_SETTING_UPDATED,0,0);
       std::vector<std::string> params;
       params.push_back(id);
       params.push_back(value);
       message.SetStringParams(params);
       g_windowManager.SendThreadMessage(message,WINDOW_DIALOG_ADDON_SETTINGS);
       save=false;
     }
   }
   if (save)
   {
     addon->UpdateSetting(id, value);
     addon->SaveSettings();
   }
 }
Пример #5
0
bool Dialog::ok(const String& heading, const String& line1,
                const String& line2,
                const String& line3) throw (WindowException)
{
    DelayedCallGuard dcguard(languageHook);
    const int window = WINDOW_DIALOG_OK;

    CGUIDialogOK* pDialog = (CGUIDialogOK*)g_windowManager.GetWindow(window);
    if (pDialog == NULL)
        throw WindowException("Error: Window is NULL, this is not possible :-)");

    if (!heading.empty())
        pDialog->SetHeading(heading);
    if (!line1.empty())
        pDialog->SetLine(0, line1);
    if (!line2.empty())
        pDialog->SetLine(1, line2);
    if (!line3.empty())
        pDialog->SetLine(2, line3);

    //send message and wait for user input
    XBMCWaitForThreadMessage(TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW);

    return pDialog->IsConfirmed();
}
Пример #6
0
 void Addon::openSettings()
 {
   DelayedCallGuard dcguard(languageHook);
   // show settings dialog
   ADDON::AddonPtr addon(pAddon);
   CGUIDialogAddonSettings::ShowAndGetInput(addon);
 }
Пример #7
0
    bool Dialog::yesno(const String& heading, const String& line1, 
                       const String& line2,
                       const String& line3,
                       const String& nolabel,
                       const String& yeslabel,
                       int autoclose)
    {
      DelayedCallGuard dcguard(languageHook);
      CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
      if (pDialog == NULL)
        throw WindowException("Error: Window is NULL, this is not possible :-)");

      // get lines, last 4 lines are optional.
      if (!heading.empty())
        pDialog->SetHeading(CVariant{heading});
      if (!line1.empty())
        pDialog->SetLine(0, CVariant{line1});
      if (!line2.empty())
        pDialog->SetLine(1, CVariant{line2});
      if (!line3.empty())
        pDialog->SetLine(2, CVariant{line3});

      if (!nolabel.empty())
        pDialog->SetChoice(0, CVariant{nolabel});
      if (!yeslabel.empty())
        pDialog->SetChoice(1, CVariant{yeslabel});

      if (autoclose > 0)
        pDialog->SetAutoClose(autoclose);

      pDialog->Open();

      return pDialog->IsConfirmed();
    }
Пример #8
0
    void DialogProgress::update(int percent, const String& line1, 
                                const String& line2,
                                const String& line3)
    {
      DelayedCallGuard dcguard(languageHook);
      CGUIDialogProgress* pDialog = dlg;

      if (pDialog == NULL)
        throw WindowException("Dialog not created.");

      if (percent >= 0 && percent <= 100)
      {
        pDialog->SetPercentage(percent);
        pDialog->ShowProgressBar(true);
      }
      else
      {
        pDialog->ShowProgressBar(false);
      }

      if (!line1.empty())
        pDialog->SetLine(0, CVariant{line1});
      if (!line2.empty())
        pDialog->SetLine(1, CVariant{line2});
      if (!line3.empty())
        pDialog->SetLine(2, CVariant{line3});
    }
Пример #9
0
 void Control::setEnabled(bool enabled)
 {
   DelayedCallGuard dcguard(languageHook);
   LOCKGUI;
   if (pGUIControl)
     pGUIControl->SetEnabled(enabled);
 }
Пример #10
0
    std::vector<int>* Dialog::multiselect(const String& heading,
        const std::vector<String>& options, int autoclose)
    {
      DelayedCallGuard dcguard(languageHook);
      CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
      if (pDialog == nullptr)
        throw WindowException("Error: Window is NULL");

      pDialog->Reset();
      pDialog->SetMultiSelection(true);
      pDialog->SetHeading(CVariant{heading});

      for (const auto& option : options)
        pDialog->Add(option);

      if (autoclose > 0)
        pDialog->SetAutoClose(autoclose);

      pDialog->Open();

      if (pDialog->IsConfirmed())
        return new std::vector<int>(pDialog->GetSelectedItems());
      else
        return nullptr;
    }
Пример #11
0
 void Control::setVisible(bool visible)
 {
   DelayedCallGuard dcguard(languageHook);
   LOCKGUI;
   if (pGUIControl)
     pGUIControl->SetVisible(visible);
 }
Пример #12
0
void DialogProgress::update(int percent, const String& line1,
                            const String& line2,
                            const String& line3) throw (WindowException)
{
    DelayedCallGuard dcguard(languageHook);
    CGUIDialogProgress* pDialog= dlg;

    if (pDialog == NULL)
        throw WindowException("Error: Window is NULL, this is not possible :-)");

    if (percent >= 0 && percent <= 100)
    {
        pDialog->SetPercentage(percent);
        pDialog->ShowProgressBar(true);
    }
    else
    {
        pDialog->ShowProgressBar(false);
    }

    if (!line1.empty())
        pDialog->SetLine(0, line1);
    if (!line2.empty())
        pDialog->SetLine(1, line2);
    if (!line3.empty())
        pDialog->SetLine(2, line3);
}
Пример #13
0
    bool Dialog::yesno(const String& heading, const String& line1, 
                       const String& line2,
                       const String& line3,
                       const String& nolabel,
                       const String& yeslabel) throw (WindowException)
    {
      DelayedCallGuard dcguard(languageHook);
      const int window = WINDOW_DIALOG_YES_NO;
      CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(window);
      if (pDialog == NULL)
        throw WindowException("Error: Window is NULL, this is not possible :-)");

      // get lines, last 4 lines are optional.
      if (!heading.empty())
        pDialog->SetHeading(heading);
      if (!line1.empty())
        pDialog->SetLine(0, line1);
      if (!line2.empty())
        pDialog->SetLine(1, line2);
      if (!line3.empty())
        pDialog->SetLine(2, line3);

      if (!nolabel.empty())
        pDialog->SetChoice(0,nolabel);
      if (!yeslabel.empty())
        pDialog->SetChoice(1,yeslabel);

      //send message and wait for user input
      XBMCWaitForThreadMessage(TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW);

      return pDialog->IsConfirmed();
    }
Пример #14
0
    void Window::show()
    {
      XBMC_TRACE;
      DelayedCallGuard dcguard(languageHook);
      popActiveWindowId();

      CApplicationMessenger::GetInstance().SendMsg(TMSG_GUI_ACTIVATE_WINDOW, iWindowId, 0);
    }
Пример #15
0
 void DialogProgressBG::close()
 {
   DelayedCallGuard dcguard(languageHook);
   if (handle == NULL)
     throw WindowException("Dialog not created.");
   handle->MarkFinished();
   open = false;
 }
Пример #16
0
 void DialogProgress::close()
 {
   DelayedCallGuard dcguard(languageHook);
   if (dlg == NULL)
     throw WindowException("Dialog not created.");
   dlg->Close();
   open = false;
 }
Пример #17
0
 void Control::setHeight(long height)
 {
   DelayedCallGuard dcguard(languageHook);
   LOCKGUI;
   dwHeight = height;
   if (pGUIControl)
     pGUIControl->SetHeight((float)dwHeight);
 }
Пример #18
0
 void Control::setWidth(long width)
 {
   DelayedCallGuard dcguard(languageHook);
   LOCKGUI;
   dwWidth = width;
   if (pGUIControl)
     pGUIControl->SetWidth((float)dwWidth);
 }
Пример #19
0
    void Control::setEnableCondition(const char* enable)
    {
      DelayedCallGuard dcguard(languageHook);
      LOCKGUI;

      if (pGUIControl)
        pGUIControl->SetEnableCondition(enable);
    }
Пример #20
0
    void Control::setVisibleCondition(const char* visible, bool allowHiddenFocus)
    {
      DelayedCallGuard dcguard(languageHook);
      LOCKGUI;

      if (pGUIControl)
        pGUIControl->SetVisibleCondition(visible, allowHiddenFocus ? "true" : "false");
    }
Пример #21
0
 void Control::setPosition(long x, long y)
 {
   DelayedCallGuard dcguard(languageHook);
   LOCKGUI;
   dwPosX = x;
   dwPosY = y;
   if (pGUIControl)
     pGUIControl->SetPosition((float)dwPosX, (float)dwPosY);
 }
Пример #22
0
    void Window::show()
    {
      TRACE;
      DelayedCallGuard dcguard(languageHook);
      popActiveWindowId();

      std::vector<CStdString> params;
      CApplicationMessenger::Get().ActivateWindow(iWindowId, params, false);
    }
Пример #23
0
    void Addon::openSettings()
    {
      AddonPtr temp;
      if (!ADDON::CAddonMgr::Get().GetAddon(pAddon->ID(), temp))
        return;

      DelayedCallGuard dcguard(languageHook);
      // show settings dialog
      ADDON::AddonPtr addon(pAddon);
      CGUIDialogAddonSettings::ShowAndGetInput(addon);
    }
Пример #24
0
String Dialog::numeric(int inputtype, const String& heading, const String& defaultt)
{
    DelayedCallGuard dcguard(languageHook);
    CStdString value;
    SYSTEMTIME timedate;
    GetLocalTime(&timedate);

    if (!heading.empty())
    {
        if (inputtype == 1)
        {
            if (!defaultt.empty() && defaultt.size() == 10)
            {
                CStdString sDefault = defaultt;
                timedate.wDay = atoi(sDefault.Left(2));
                timedate.wMonth = atoi(sDefault.Mid(3,4));
                timedate.wYear = atoi(sDefault.Right(4));
            }
            if (CGUIDialogNumeric::ShowAndGetDate(timedate, heading))
                value.Format("%2d/%2d/%4d", timedate.wDay, timedate.wMonth, timedate.wYear);
            else
                return emptyString;
        }
        else if (inputtype == 2)
        {
            if (!defaultt.empty() && defaultt.size() == 5)
            {
                CStdString sDefault = defaultt;
                timedate.wHour = atoi(sDefault.Left(2));
                timedate.wMinute = atoi(sDefault.Right(2));
            }
            if (CGUIDialogNumeric::ShowAndGetTime(timedate, heading))
                value.Format("%2d:%02d", timedate.wHour, timedate.wMinute);
            else
                return emptyString;
        }
        else if (inputtype == 3)
        {
            value = defaultt;
            if (!CGUIDialogNumeric::ShowAndGetIPAddress(value, heading))
                return emptyString;
        }
        else
        {
            value = defaultt;
            if (!CGUIDialogNumeric::ShowAndGetNumber(value, heading))
                return emptyString;
        }
    }
    return value;
}
Пример #25
0
    void Dialog::textviewer(const String& heading, const String& text)
    {
      DelayedCallGuard dcguard(languageHook);
      const int window = WINDOW_DIALOG_TEXT_VIEWER;

      CGUIDialogTextViewer* pDialog = (CGUIDialogTextViewer*)g_windowManager.GetWindow(window);
      if (pDialog == NULL)
        throw WindowException("Error: Window is NULL, this is not possible :-)");
      if (!heading.empty())
        pDialog->SetHeading(heading);
      if (!text.empty())
        pDialog->SetText(text);
      pDialog->Open();
    }
Пример #26
0
    void DialogProgressBG::update(int percent, const String& heading, const String& message)
    {
      DelayedCallGuard dcguard(languageHook);
      CGUIDialogProgressBarHandle* pHandle = handle;

      if (pHandle == NULL)
        throw WindowException("Dialog not created.");

      if (percent >= 0 && percent <= 100)
        pHandle->SetPercentage((float)percent);
      if (!heading.empty())
        pHandle->SetTitle(heading);
      if (!message.empty())
        pHandle->SetText(message);
    }
Пример #27
0
    void Window::close()
    {
      XBMC_TRACE;
      bModal = false;

      if (!existingWindow)
        PulseActionEvent();

      {
        DelayedCallGuard dcguard(languageHook);
        CApplicationMessenger::GetInstance().SendMsg(TMSG_GUI_PREVIOUS_WINDOW, iOldWindowId, 0);
      }

      iOldWindowId = 0;
    }
Пример #28
0
    void Window::close()
    {
      XBMC_TRACE;
      bModal = false;

      if (!existingWindow)
        PulseActionEvent();

      std::vector<std::string> params;
      {
        DelayedCallGuard dcguard(languageHook);
        CApplicationMessenger::Get().ActivateWindow(iOldWindowId, params, false);
      }

      iOldWindowId = 0;
    }
Пример #29
0
void DialogProgressBG::update(int percent, const String& heading, const String& message) throw (WindowException)
{
    DelayedCallGuard dcguard(languageHook);
    CGUIDialogExtendedProgressBar* pDialog = dlg;
    CGUIDialogProgressBarHandle* pHandle = handle;

    if (pDialog == NULL)
        throw WindowException("Error: Window is NULL, this is not possible :-)");

    if (percent >= 0 && percent <= 100)
        pHandle->SetPercentage((float)percent);
    if (!heading.empty())
        pHandle->SetTitle(heading);
    if (!message.empty())
        pHandle->SetText(message);
}
Пример #30
0
    long ControlList::getSelectedPosition()
    {
      DelayedCallGuard dcguard(languageHook);
      LOCKGUI;

      // create message
      CGUIMessage msg(GUI_MSG_ITEM_SELECTED, iParentId, iControlId);
      long pos = -1;

      // send message
      if ((vecItems.size() > 0) && pGUIControl)
      {
        pGUIControl->OnMessage(msg);
        pos = msg.GetParam1();
      }

      return pos;
    }