GtkListStore* AP_UnixDialog_CollaborationAccounts::_constructModel() { GtkTreeIter iter; GtkListStore* model = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); for (UT_uint32 i = 0; i < pManager->getAccounts().size(); i++) { AccountHandler* pHandler = pManager->getAccounts()[i]; if (pHandler) { UT_DEBUGMSG(("Got account: %s of type %s\n", pHandler->getDescription().utf8_str(), pHandler->getDisplayType().utf8_str() )); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, ONLINE_COLUMN, pHandler->isOnline(), DESC_COLUMN, pHandler->getDescription().utf8_str(), TYPE_COLUMN, pHandler->getDisplayType().utf8_str(), HANDLER_COLUMN, pHandler, -1); } } return model; }
void AP_Dialog_CollaborationShare::eventAccountChanged() { UT_DEBUGMSG(("AP_Dialog_CollaborationShare::eventAccountChanged()\n")); AccountHandler* pHandler = _getActiveAccountHandler(); UT_return_if_fail(pHandler); UT_DEBUGMSG(("Changed account handler to type: %s\n", pHandler->getDisplayType().utf8_str())); PD_Document *pDoc = static_cast<PD_Document*>(XAP_App::getApp()->getLastFocussedFrame()->getCurrentDoc()); UT_return_if_fail(pDoc); _setAccountHint(pHandler->getShareHint(pDoc)); _populateBuddyModel(true); }
void AP_UnixDialog_CollaborationAccounts::eventDelete() { UT_DEBUGMSG(("AP_UnixDialog_CollaborationAccounts::eventDelete()\n")); AccountHandler* pHandler = _getSelectedAccountHandler(); UT_return_if_fail(pHandler); // TODO: we should ask for confirmation, as this account handler // could be in use by serveral AbiCollab Sessions UT_DEBUGMSG(("Delete account: %s of type %s\n", pHandler->getDescription().utf8_str(), pHandler->getDisplayType().utf8_str() )); _deleteAccount(pHandler); // for now, recreate the whole model; but we should really just delete // the iter we got above _setModel(_constructModel()); }
void AP_Win32Dialog_CollaborationAccounts::_populateWindowData() { AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_if_fail(pManager); m_bPopulating = true; // clear out the old contents, if any ListView_DeleteAllItems(m_hAccountList); for (UT_uint32 i = 0; i < pManager->getAccounts().size(); i++) { AccountHandler* pAccount = pManager->getAccounts()[i]; UT_continue_if_fail(pAccount); UT_Win32LocaleString sAccountText = AP_Win32App::s_fromUTF8ToWinLocale(pAccount->getDescription().utf8_str()); UT_Win32LocaleString sAccountTypeText = AP_Win32App::s_fromUTF8ToWinLocale(pAccount->getDisplayType().utf8_str()); // insert a new account record LVITEMW lviAccount; lviAccount.mask = LVIF_STATE | LVIF_IMAGE | LVIF_PARAM; lviAccount.state = 1; lviAccount.iItem = i; lviAccount.iSubItem = 0; lviAccount.lParam = (LPARAM)pAccount; SendMessageW(m_hAccountList, LVM_INSERTITEMW, 0, (LPARAM) &lviAccount); ListView_SetCheckState(m_hAccountList, i, pAccount->isOnline()); lviAccount.iSubItem=1; lviAccount.pszText= const_cast<LPWSTR>(sAccountText.c_str()); SendMessageW(m_hAccountList, LVM_SETITEMTEXTW, i, (LPARAM) &lviAccount); lviAccount.iSubItem=2; lviAccount.pszText= const_cast<LPWSTR>(sAccountTypeText.c_str()); SendMessageW(m_hAccountList, LVM_SETITEMTEXTW, i, (LPARAM) &lviAccount); } _updateSelection(); m_bPopulating = false; }
// return true if we process the command, false otherwise BOOL AP_Win32Dialog_CollaborationAccounts::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { WORD wNotifyCode = HIWORD(wParam); WORD wId = LOWORD(wParam); switch (wId) { case AP_RID_DIALOG_COLLABORATIONACCOUNTS_CLOSE_BUTTON: m_answer=AP_Dialog_CollaborationAccounts::a_CLOSE; EndDialog(hWnd,0); return true; case AP_RID_DIALOG_COLLABORATIONACCOUNTS_ADD_BUTTON: // open the Add dialog createNewAccount(); // TODO: only refresh if it actually changed. _populateWindowData(); return true; case AP_RID_DIALOG_COLLABORATIONACCOUNTS_DELETE_BUTTON: { AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_val_if_fail(pManager, false); bool hasSelection = ListView_GetSelectedCount(m_hAccountList); if (!hasSelection) return true; UT_sint32 iIndex = ListView_GetSelectionMark(m_hAccountList); UT_return_val_if_fail(iIndex >= 0, false); LVITEM lviAccount; lviAccount.mask = LVIF_PARAM; lviAccount.iItem = iIndex; lviAccount.iSubItem = 0; UT_return_val_if_fail(ListView_GetItem(m_hAccountList, &lviAccount), false); UT_return_val_if_fail(lviAccount.lParam, false); AccountHandler* pAccount = reinterpret_cast<AccountHandler*>(lviAccount.lParam); // TODO: we should ask for confirmation, as this account handler // could be in use by serveral AbiCollab Sessions UT_DEBUGMSG(("Delete account: %s of type %s\n", pAccount->getDescription().utf8_str(), pAccount->getDisplayType().utf8_str() )); pManager->destroyAccount(pAccount); // for now, recreate the whole model; but we should really just delete // the iter we got above _populateWindowData(); } return true; case AP_RID_DIALOG_COLLABORATIONACCOUNTS_PROPERTIES_BUTTON: // open the Properties dialog. This does not exist yet, but when it does, we'll be ready. UT_DEBUGMSG(("AP_Win32Dialog_CollaborationAccounts::eventProperties()\n")); // TODO: implement me return true; default: // WM_COMMAND message NOT processed return false; } }