From eec9f20d746805e772d38f8b338d882a6afb8df1 Mon Sep 17 00:00:00 2001
From: Alexei Arabadji <aarabadji@productengine.com>
Date: Thu, 18 Feb 2010 16:05:11 +0200
Subject: [PATCH] =?UTF-8?q?fixed=20EXT-5006=20=E2=80=9COne=20inventory=20o?=
 =?UTF-8?q?ffer=20cause=20blinking=20of=20both=20Conversations=20and=20Not?=
 =?UTF-8?q?ifications=20wells=E2=80=9D,=20embedded=20inventory=20offer=20p?=
 =?UTF-8?q?anel=20into=20IM=20window;?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

--HG--
branch : product-engine
---
 indra/llui/llbutton.h                        |  2 ++
 indra/newview/llchathistory.cpp              | 34 +++++++++++---------
 indra/newview/llnotificationhandler.h        |  5 ---
 indra/newview/llnotificationhandlerutil.cpp  | 27 ++--------------
 indra/newview/llnotificationofferhandler.cpp |  4 ---
 indra/newview/lltoastnotifypanel.cpp         |  3 ++
 indra/newview/lltoastnotifypanel.h           |  1 +
 7 files changed, 27 insertions(+), 49 deletions(-)

diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index 8f35db1007..6a0d8ef3d6 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -257,6 +257,8 @@ public:
 
 	void		setForcePressedState(bool b) { mForcePressedState = b; }
 	
+	void 		setAutoResize(bool auto_resize) { mAutoResize = auto_resize; }
+
 protected:
 	LLPointer<LLUIImage> getImageUnselected() const	{ return mImageUnselected; }
 	LLPointer<LLUIImage> getImageSelected() const	{ return mImageSelected; }
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index cf5ac6b2e6..8fb9decf7b 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -721,22 +721,26 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
 			notify_box->setFollowsRight();
 			notify_box->setFollowsTop();
 
-			LLButton* accept_button = notify_box->getChild<LLButton> ("Accept",
-					TRUE);
-			if (accept_button != NULL)
+			ctrl_list_t ctrls = notify_box->getControlPanel()->getCtrlList();
+			S32 offset = 0;
+			for (ctrl_list_t::iterator it = ctrls.begin(); it != ctrls.end(); it++)
 			{
-				accept_button->setFollowsNone();
-				accept_button->setOrigin(2*HPAD, accept_button->getRect().mBottom);
-			}
-
-			LLButton* decline_button = notify_box->getChild<LLButton> (
-					"Decline", TRUE);
-			if (accept_button != NULL && decline_button != NULL)
-			{
-				decline_button->setFollowsNone();
-				decline_button->setOrigin(4*HPAD
-						+ accept_button->getRect().getWidth(),
-						decline_button->getRect().mBottom);
+				LLButton * button = dynamic_cast<LLButton*> (*it);
+				if (button != NULL)
+				{
+					button->setOrigin( offset,
+							button->getRect().mBottom);
+					button->setLeftHPad(2 * HPAD);
+					button->setRightHPad(2 * HPAD);
+					// set zero width before perform autoResize()
+					button->setRect(LLRect(button->getRect().mLeft,
+							button->getRect().mTop, button->getRect().mLeft,
+							button->getRect().mBottom));
+					button->setAutoResize(true);
+					button->autoResize();
+					offset += 2 * HPAD + button->getRect().getWidth();
+					button->setFollowsNone();
+				}
 			}
 
 			LLTextEditor* text_editor = notify_box->getChild<LLTextEditor>("text_editor_box", TRUE);
diff --git a/indra/newview/llnotificationhandler.h b/indra/newview/llnotificationhandler.h
index 5f4768e321..0d5c431d75 100644
--- a/indra/newview/llnotificationhandler.h
+++ b/indra/newview/llnotificationhandler.h
@@ -334,11 +334,6 @@ public:
 	 * Adds notification panel to the IM floater.
 	 */
 	static void addNotifPanelToIM(const LLNotificationPtr& notification);
-
-	/**
-	 * Reloads IM floater messages.
-	 */
-	static void reloadIMFloaterMessages(const LLNotificationPtr& notification);
 };
 
 }
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index 35569cffac..c30a4fb253 100644
--- a/indra/newview/llnotificationhandlerutil.cpp
+++ b/indra/newview/llnotificationhandlerutil.cpp
@@ -94,7 +94,8 @@ bool LLHandlerUtil::canSpawnIMSession(const LLNotificationPtr& notification)
 // static
 bool LLHandlerUtil::canAddNotifPanelToIM(const LLNotificationPtr& notification)
 {
-	return OFFER_FRIENDSHIP == notification->getName();
+	return OFFER_FRIENDSHIP == notification->getName()
+					|| USER_GIVE_ITEM == notification->getName();
 }
 
 
@@ -269,27 +270,3 @@ void LLHandlerUtil::addNotifPanelToIM(const LLNotificationPtr& notification)
 
 	LLIMFloater::show(session_id);
 }
-
-// static
-void LLHandlerUtil::reloadIMFloaterMessages(
-		const LLNotificationPtr& notification)
-{
-	LLUUID from_id = notification->getPayload()["from_id"];
-	LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, from_id);
-	LLIMFloater* im_floater = LLFloaterReg::findTypedInstance<LLIMFloater>(
-			"impanel", session_id);
-	if (im_floater != NULL)
-	{
-		LLIMModel::LLIMSession * session = LLIMModel::getInstance()->findIMSession(
-				session_id);
-		if(session != NULL)
-		{
-			session->mMsgs.clear();
-			std::list<LLSD> chat_history;
-			LLLogChat::loadAllHistory(session->mHistoryFileName, chat_history);
-			session->addMessagesFromHistory(chat_history);
-		}
-
-		im_floater->reloadMessages();
-	}
-}
diff --git a/indra/newview/llnotificationofferhandler.cpp b/indra/newview/llnotificationofferhandler.cpp
index 8c13b0fafa..8ebd5de258 100644
--- a/indra/newview/llnotificationofferhandler.cpp
+++ b/indra/newview/llnotificationofferhandler.cpp
@@ -155,10 +155,6 @@ bool LLOfferHandler::processNotification(const LLSD& notify)
 		}
 		else
 		{
-			if (LLHandlerUtil::canAddNotifPanelToIM(notification))
-			{
-				LLHandlerUtil::reloadIMFloaterMessages(notification);
-			}
 			mChannel->killToastByNotificationID(notification->getID());
 		}
 	}
diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp
index ef3535042c..c47c017143 100644
--- a/indra/newview/lltoastnotifypanel.cpp
+++ b/indra/newview/lltoastnotifypanel.cpp
@@ -346,4 +346,7 @@ void LLToastNotifyPanel::onClickButton(void* data)
 		response[button_name] = true;
 	}
 	self->mNotification->respond(response);
+
+	// disable all buttons
+	self->mControlPanel->setEnabled(FALSE);
 }
diff --git a/indra/newview/lltoastnotifypanel.h b/indra/newview/lltoastnotifypanel.h
index 3d57c50386..e791eea469 100644
--- a/indra/newview/lltoastnotifypanel.h
+++ b/indra/newview/lltoastnotifypanel.h
@@ -55,6 +55,7 @@ class LLToastNotifyPanel: public LLToastPanel
 public:
 	LLToastNotifyPanel(LLNotificationPtr&);
 	virtual ~LLToastNotifyPanel();
+	LLPanel * getControlPanel() { return mControlPanel; }
 
 protected:
 	LLButton* createButton(const LLSD& form_element, BOOL is_option);
-- 
GitLab