[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haiku-commits
Subject:    [haiku-commits] Change in haiku[master]: Tracker: Live update identify and create link menu items
From:       Gerrit <review () review ! haiku-os ! org>
Date:       2020-02-29 0:43:13
Message-ID: gerrit.1582936991000.I5dfbd4d468fad02894f1f31aa08d1abf630a4b5d () review ! haiku-os ! org
[Download RAW message or body]

From John Scipione <jscipione@gmail.com>:

John Scipione has uploaded this change for review. ( https://review.haiku-os.org/c/haiku/+/2293 )


Change subject: Tracker: Live update identify and create link menu items
......................................................................

Tracker: Live update identify and create link menu items

when you press and release the shift key with the File menu or a
file's context menu open.

Identify => Force identify
Create link => Create relative link

Forward B_MODIFIERS_CHANGED message from MenuWindow::DispatchMessage()
to be_app_messenger to so that Tracker can then forward the message onto
its windows.
---
M src/kits/interface/MenuWindow.cpp
M src/kits/tracker/ContainerWindow.cpp
M src/kits/tracker/ContainerWindow.h
M src/kits/tracker/Tracker.cpp
M src/kits/tracker/Tracker.h
5 files changed, 135 insertions(+), 39 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/93/2293/1

diff --git a/src/kits/interface/MenuWindow.cpp b/src/kits/interface/MenuWindow.cpp
index e8e5eeb..b30140c 100644
--- a/src/kits/interface/MenuWindow.cpp
+++ b/src/kits/interface/MenuWindow.cpp
@@ -11,6 +11,7 @@

 #include <MenuWindow.h>

+#include <Application.h>
 #include <ControlLook.h>
 #include <Debug.h>
 #include <Menu.h>
@@ -256,6 +257,9 @@
 void
 BMenuWindow::DispatchMessage(BMessage *message, BHandler *handler)
 {
+	if (message->what == B_MODIFIERS_CHANGED)
+		be_app_messenger.SendMessage(message);
+
 	BWindow::DispatchMessage(message, handler);
 }

diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp
index 65d61b5..2d377bb 100644
--- a/src/kits/tracker/ContainerWindow.cpp
+++ b/src/kits/tracker/ContainerWindow.cpp
@@ -1514,6 +1514,10 @@
 			break;
 		}

+		case B_MODIFIERS_CHANGED:
+			UpdateMenuItemsForModifiersChanged();
+			break;
+
 		case kNewFolder:
 			PostMessage(message, PoseView());
 			break;
@@ -1573,6 +1577,7 @@
 		case kCreateLink:
 		case kCreateRelativeLink:
 		{
+			bool relative = message->what == kCreateRelativeLink;
 			entry_ref ref;
 			if (message->FindRef("refs", &ref) == B_OK) {
 				BRoster().AddToRecentFolders(&ref);
@@ -1582,14 +1587,12 @@
 					break;

 				PoseView()->MoveSelectionInto(&model, this, false, false,
-					message->what == kCreateLink,
-					message->what == kCreateRelativeLink);
+					relative, relative);
 			} else if (!TargetModel()->IsQuery()
 				&& !TargetModel()->IsVirtualDirectory()) {
 				// no destination specified, create link in same dir as item
-				PoseView()->MoveSelectionInto(TargetModel(), this, false, false,
-					message->what == kCreateLink,
-					message->what == kCreateRelativeLink);
+				PoseView()->MoveSelectionInto(TargetModel(), this, false,
+					false, relative, relative);
 			}
 			break;
 		}
@@ -2600,9 +2603,6 @@
 		return;
 	}

-	// Grab the modifiers state since we use it twice
-	uint32 modifierKeys = modifiers();
-
 	// re-parent items to this menu since they're shared
 	int32 index;
 	BMenuItem* trash = parent->FindItem(kMoveToTrash);
@@ -2632,13 +2632,6 @@
 		parent->AddItem(fCreateLinkItem, index);
 	}

-	// Set the "Create Link" item label here so it
-	// appears correctly when menus are disabled, too.
-	if (modifierKeys & B_SHIFT_KEY)
-		fCreateLinkItem->SetLabel(B_TRANSLATE("Create relative link"));
-	else
-		fCreateLinkItem->SetLabel(B_TRANSLATE("Create link"));
-
 	// only enable once the menus are built
 	fMoveToItem->SetEnabled(false);
 	fCopyToItem->SetEnabled(false);
@@ -2667,33 +2660,14 @@

 	// Set "Create Link" menu item message and
 	// add all mounted volumes (except the one this item lives on)
-	if (modifierKeys & B_SHIFT_KEY) {
-		fCreateLinkItem->SetMessage(new BMessage(kCreateRelativeLink));
-		PopulateMoveCopyNavMenu(dynamic_cast<BNavMenu*>
-				(fCreateLinkItem->Submenu()),
-			kCreateRelativeLink, item_ref, false);
-	} else {
-		fCreateLinkItem->SetMessage(new BMessage(kCreateLink));
-		PopulateMoveCopyNavMenu(dynamic_cast<BNavMenu*>
-			(fCreateLinkItem->Submenu()),
-		kCreateLink, item_ref, false);
-	}
+	UpdateCreateLinkMenuItem(fCreateLinkItem, item_ref);

 	fMoveToItem->SetEnabled(true);
 	fCopyToItem->SetEnabled(true);
 	fCreateLinkItem->SetEnabled(true);

 	// Set the "Identify" item label
-	BMenuItem* identifyItem = parent->FindItem(kIdentifyEntry);
-	if (identifyItem != NULL) {
-		if (modifierKeys & B_SHIFT_KEY) {
-			identifyItem->SetLabel(B_TRANSLATE("Force identify"));
-			identifyItem->Message()->ReplaceBool("force", true);
-		} else {
-			identifyItem->SetLabel(B_TRANSLATE("Identify"));
-			identifyItem->Message()->ReplaceBool("force", false);
-		}
-	}
+	UpdateIdentifyMenuItem(parent->FindItem(kIdentifyEntry));
 }


@@ -2710,16 +2684,16 @@
 	BMenuItem* item = fDropContextMenu->FindItem(kCreateLink);
 	if (item == NULL)
 		item = fDropContextMenu->FindItem(kCreateRelativeLink);
-	if (item && (modifiers() & B_SHIFT_KEY)) {
+	if (item != NULL && (modifiers() & B_SHIFT_KEY)) {
 		item->SetLabel(B_TRANSLATE("Create relative link here"));
 		item->SetMessage(new BMessage(kCreateRelativeLink));
-	} else if (item) {
+	} else if (item != NULL) {
 		item->SetLabel(B_TRANSLATE("Create link here"));
 		item->SetMessage(new BMessage(kCreateLink));
 	}

 	item = fDropContextMenu->Go(global, true, true);
-	if (item)
+	if (item != NULL)
 		return item->Command();
 
 	return 0;
@@ -2918,9 +2892,11 @@
 #endif

 	menu->AddSeparatorItem();
+
 	BMessage* message = new BMessage(kIdentifyEntry);
 	message->AddBool("force", false);
 	menu->AddItem(new BMenuItem(B_TRANSLATE("Identify"), message));
+
 	BMenu* addOnMenuItem = new BMenu(B_TRANSLATE("Add-ons"));
 	addOnMenuItem->SetFont(be_plain_font);
 	menu->AddItem(addOnMenuItem);
@@ -4361,6 +4337,101 @@
 }


+void
+BContainerWindow::UpdateMenuItemsForModifiersChanged()
+{
+	BMenuItem* item = NULL;
+
+	// File menu
+	if (fFileMenu != NULL) {
+		// Identify/Force identify
+		item = fFileMenu->FindItem(kIdentifyEntry);
+		UpdateIdentifyMenuItem(item);
+
+		// Create link/Create relative link
+		item = fFileMenu->FindItem(kCreateLink);
+		UpdateCreateLinkMenuItem(item);
+		item = fFileMenu->FindItem(kCreateRelativeLink);
+		UpdateCreateLinkMenuItem(item);
+
+	}
+
+	// File context menu
+	if (fFileContextMenu != NULL) {
+		// Identify/Force identify
+		item = fFileContextMenu->FindItem(kIdentifyEntry);
+		UpdateIdentifyMenuItem(item);
+
+		// Create link/Create relative link
+		item = fFileContextMenu->FindItem(kCreateLink);
+		UpdateCreateLinkMenuItem(item);
+		item = fFileContextMenu->FindItem(kCreateRelativeLink);
+		UpdateCreateLinkMenuItem(item);
+	}
+}
+
+
+void
+BContainerWindow::UpdateIdentifyMenuItem(BMenuItem* item)
+{
+	if (item == NULL || item->Menu() == NULL)
+		return;
+
+	if ((modifiers() & B_SHIFT_KEY) != 0) {
+		item->Message()->ReplaceBool("force", true);
+		item->SetLabel(B_TRANSLATE("Force identify"));
+	} else {
+		item->Message()->ReplaceBool("force", false);
+		// add some room for the label to grow
+		BString label(B_TRANSLATE("Identify"));
+		float shortLabel = item->Menu()->StringWidth(
+			B_TRANSLATE("Identify"));
+		float longLabel = item->Menu()->StringWidth(
+			B_TRANSLATE("Force identify"));
+		while (longLabel > shortLabel) {
+			label << " ";
+			longLabel -= item->Menu()->StringWidth(" ");
+		}
+		item->SetLabel(label.String());
+	}
+}
+
+
+void
+BContainerWindow::UpdateCreateLinkMenuItem(BMenuItem* item,
+	const entry_ref* ref)
+{
+	if (item == NULL || item->Menu() == NULL)
+		return;
+
+	if ((modifiers() & B_SHIFT_KEY) != 0) {
+		item->Message()->what = kCreateRelativeLink;
+		if (strcmp(item->Label(), B_TRANSLATE("Current folder")) != 0)
+			item->SetLabel(B_TRANSLATE("Create relative link"));
+	} else {
+		item->Message()->what = kCreateLink;
+		if (strcmp(item->Label(), B_TRANSLATE("Current folder")) != 0) {
+			// add some room for the label to grow
+			BString label(B_TRANSLATE("Create link"));
+			float shortLabel = item->Menu()->StringWidth(
+				B_TRANSLATE("Create link"));
+			float longLabel = item->Menu()->StringWidth(
+				B_TRANSLATE("Create relative link"));
+			while (longLabel > shortLabel) {
+				label << " ";
+				longLabel -= item->Menu()->StringWidth(" ");
+			}
+			item->SetLabel(label.String());
+		}
+	}
+
+	if (ref != NULL) {
+		BNavMenu* navMenu = dynamic_cast<BNavMenu*>(item->Submenu());
+		PopulateMoveCopyNavMenu(navMenu, item->Message()->what, ref, false);
+	}
+}
+
+
 //	#pragma mark - WindowStateNodeOpener


diff --git a/src/kits/tracker/ContainerWindow.h b/src/kits/tracker/ContainerWindow.h
index b556f8e..5602a2a 100644
--- a/src/kits/tracker/ContainerWindow.h
+++ b/src/kits/tracker/ContainerWindow.h
@@ -244,6 +244,10 @@
 	virtual void RepopulateMenus();
 	void PopulateArrangeByMenu(BMenu*);

+	void UpdateMenuItemsForModifiersChanged();
+	void UpdateIdentifyMenuItem(BMenuItem* item);
+	void UpdateCreateLinkMenuItem(BMenuItem* item, const entry_ref* ref = NULL);
+
 	virtual void SetCutItem(BMenu*);
 	virtual void SetCopyItem(BMenu*);
 	virtual void SetPasteItem(BMenu*);
diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp
index 93390c3..c59165b 100644
--- a/src/kits/tracker/Tracker.cpp
+++ b/src/kits/tracker/Tracker.cpp
@@ -1026,6 +1026,22 @@


 void
+TTracker::DispatchMessage(BMessage* message, BHandler* handler)
+{
+	if (message->what == B_MODIFIERS_CHANGED) {
+		for (int32 i = 0; i < fWindowList.CountItems(); i++) {
+			BContainerWindow* window = dynamic_cast<BContainerWindow*>(
+				fWindowList.ItemAt(i));
+			if (window != NULL)
+				window->PostMessage(message);
+		}
+	}
+
+	BApplication::DispatchMessage(message, handler);
+}
+
+
+void
 TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
 	OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen,
 	const BMessage* stateMessage)
diff --git a/src/kits/tracker/Tracker.h b/src/kits/tracker/Tracker.h
index efda7ae..34680bd 100644
--- a/src/kits/tracker/Tracker.h
+++ b/src/kits/tracker/Tracker.h
@@ -89,6 +89,7 @@
 	virtual void Pulse();
 	virtual void RefsReceived(BMessage* message);
 	virtual void ArgvReceived(int32 argc, char** argv);
+	virtual void DispatchMessage(BMessage* message, BHandler* handler);

 	MimeTypeList* MimeTypes() const;
 		// list of mime types that have a description and do not have

--
To view, visit https://review.haiku-os.org/c/haiku/+/2293
To unsubscribe, or for help writing mail filters, visit https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I5dfbd4d468fad02894f1f31aa08d1abf630a4b5d
Gerrit-Change-Number: 2293
Gerrit-PatchSet: 1
Gerrit-Owner: John Scipione <jscipione@gmail.com>
Gerrit-MessageType: newchange

[Attachment #3 (text/html)]

<p>John Scipione has uploaded this change for <strong>review</strong>.</p><p><a \
href="https://review.haiku-os.org/c/haiku/+/2293">View Change</a></p><pre \
style="font-family: monospace,monospace; white-space: pre-wrap;">Tracker: Live update \
identify and create link menu items<br><br>when you press and release the shift key \
with the File menu or a<br>file&#39;s context menu open.<br><br>Identify =&gt; Force \
identify<br>Create link =&gt; Create relative link<br><br>Forward B_MODIFIERS_CHANGED \
message from MenuWindow::DispatchMessage()<br>to be_app_messenger to so that Tracker \
can then forward the message onto<br>its windows.<br>---<br>M \
src/kits/interface/MenuWindow.cpp<br>M src/kits/tracker/ContainerWindow.cpp<br>M \
src/kits/tracker/ContainerWindow.h<br>M src/kits/tracker/Tracker.cpp<br>M \
src/kits/tracker/Tracker.h<br>5 files changed, 135 insertions(+), 39 \
deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: \
pre-wrap;">git pull ssh://git.haiku-os.org:22/haiku refs/changes/93/2293/1</pre><pre \
style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git \
a/src/kits/interface/MenuWindow.cpp \
b/src/kits/interface/MenuWindow.cpp</span><br><span>index e8e5eeb..b30140c \
100644</span><br><span>--- a/src/kits/interface/MenuWindow.cpp</span><br><span>+++ \
b/src/kits/interface/MenuWindow.cpp</span><br><span>@@ -11,6 +11,7 \
@@</span><br><span> </span><br><span> #include &lt;MenuWindow.h&gt;</span><br><span> \
</span><br><span style="color: hsl(120, 100%, 40%);">+#include \
&lt;Application.h&gt;</span><br><span> #include \
&lt;ControlLook.h&gt;</span><br><span> #include &lt;Debug.h&gt;</span><br><span> \
#include &lt;Menu.h&gt;</span><br><span>@@ -256,6 +257,9 @@</span><br><span> \
void</span><br><span> BMenuWindow::DispatchMessage(BMessage *message, BHandler \
*handler)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+	if \
(message-&gt;what == B_MODIFIERS_CHANGED)</span><br><span style="color: hsl(120, \
100%, 40%);">+		be_app_messenger.SendMessage(message);</span><br><span style="color: \
hsl(120, 100%, 40%);">+</span><br><span> 	BWindow::DispatchMessage(message, \
handler);</span><br><span> }</span><br><span> </span><br><span>diff --git \
a/src/kits/tracker/ContainerWindow.cpp \
b/src/kits/tracker/ContainerWindow.cpp</span><br><span>index 65d61b5..2d377bb \
100644</span><br><span>--- a/src/kits/tracker/ContainerWindow.cpp</span><br><span>+++ \
b/src/kits/tracker/ContainerWindow.cpp</span><br><span>@@ -1514,6 +1514,10 \
@@</span><br><span> 			break;</span><br><span> 		}</span><br><span> </span><br><span \
style="color: hsl(120, 100%, 40%);">+		case B_MODIFIERS_CHANGED:</span><br><span \
style="color: hsl(120, 100%, \
40%);">+			UpdateMenuItemsForModifiersChanged();</span><br><span style="color: \
hsl(120, 100%, 40%);">+			break;</span><br><span style="color: hsl(120, 100%, \
40%);">+</span><br><span> 		case kNewFolder:</span><br><span> 			PostMessage(message, \
PoseView());</span><br><span> 			break;</span><br><span>@@ -1573,6 +1577,7 \
@@</span><br><span> 		case kCreateLink:</span><br><span> 		case \
kCreateRelativeLink:</span><br><span> 		{</span><br><span style="color: hsl(120, \
100%, 40%);">+			bool relative = message-&gt;what == \
kCreateRelativeLink;</span><br><span> 			entry_ref ref;</span><br><span> 			if \
(message-&gt;FindRef(&quot;refs&quot;, &amp;ref) == B_OK) {</span><br><span> \
BRoster().AddToRecentFolders(&amp;ref);</span><br><span>@@ -1582,14 +1587,12 \
@@</span><br><span> 					break;</span><br><span> </span><br><span> \
PoseView()-&gt;MoveSelectionInto(&amp;model, this, false, false,</span><br><span \
style="color: hsl(0, 100%, 40%);">-					message-&gt;what == \
kCreateLink,</span><br><span style="color: hsl(0, 100%, 40%);">-					message-&gt;what \
== kCreateRelativeLink);</span><br><span style="color: hsl(120, 100%, \
40%);">+					relative, relative);</span><br><span> 			} else if \
(!TargetModel()-&gt;IsQuery()</span><br><span> 				&amp;&amp; \
!TargetModel()-&gt;IsVirtualDirectory()) {</span><br><span> 				// no destination \
specified, create link in same dir as item</span><br><span style="color: hsl(0, 100%, \
40%);">-				PoseView()-&gt;MoveSelectionInto(TargetModel(), this, false, \
false,</span><br><span style="color: hsl(0, 100%, 40%);">-					message-&gt;what == \
kCreateLink,</span><br><span style="color: hsl(0, 100%, 40%);">-					message-&gt;what \
== kCreateRelativeLink);</span><br><span style="color: hsl(120, 100%, \
40%);">+				PoseView()-&gt;MoveSelectionInto(TargetModel(), this, \
false,</span><br><span style="color: hsl(120, 100%, 40%);">+					false, relative, \
relative);</span><br><span> 			}</span><br><span> 			break;</span><br><span> \
}</span><br><span>@@ -2600,9 +2603,6 @@</span><br><span> 		return;</span><br><span> \
}</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-	// Grab the \
modifiers state since we use it twice</span><br><span style="color: hsl(0, 100%, \
40%);">-	uint32 modifierKeys = modifiers();</span><br><span style="color: hsl(0, \
100%, 40%);">-</span><br><span> 	// re-parent items to this menu since they&#39;re \
shared</span><br><span> 	int32 index;</span><br><span> 	BMenuItem* trash = \
parent-&gt;FindItem(kMoveToTrash);</span><br><span>@@ -2632,13 +2632,6 \
@@</span><br><span> 		parent-&gt;AddItem(fCreateLinkItem, index);</span><br><span> \
}</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-	// Set the \
&quot;Create Link&quot; item label here so it</span><br><span style="color: hsl(0, \
100%, 40%);">-	// appears correctly when menus are disabled, too.</span><br><span \
style="color: hsl(0, 100%, 40%);">-	if (modifierKeys &amp; \
B_SHIFT_KEY)</span><br><span style="color: hsl(0, 100%, \
40%);">-		fCreateLinkItem-&gt;SetLabel(B_TRANSLATE(&quot;Create relative \
link&quot;));</span><br><span style="color: hsl(0, 100%, \
40%);">-	else</span><br><span style="color: hsl(0, 100%, \
40%);">-		fCreateLinkItem-&gt;SetLabel(B_TRANSLATE(&quot;Create \
link&quot;));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> \
// only enable once the menus are built</span><br><span> \
fMoveToItem-&gt;SetEnabled(false);</span><br><span> \
fCopyToItem-&gt;SetEnabled(false);</span><br><span>@@ -2667,33 +2660,14 \
@@</span><br><span> </span><br><span> 	// Set &quot;Create Link&quot; menu item \
message and</span><br><span> 	// add all mounted volumes (except the one this item \
lives on)</span><br><span style="color: hsl(0, 100%, 40%);">-	if (modifierKeys &amp; \
B_SHIFT_KEY) {</span><br><span style="color: hsl(0, 100%, \
40%);">-		fCreateLinkItem-&gt;SetMessage(new \
BMessage(kCreateRelativeLink));</span><br><span style="color: hsl(0, 100%, \
40%);">-		PopulateMoveCopyNavMenu(dynamic_cast&lt;BNavMenu*&gt;</span><br><span \
style="color: hsl(0, 100%, \
40%);">-				(fCreateLinkItem-&gt;Submenu()),</span><br><span style="color: hsl(0, \
100%, 40%);">-			kCreateRelativeLink, item_ref, false);</span><br><span style="color: \
hsl(0, 100%, 40%);">-	} else {</span><br><span style="color: hsl(0, 100%, \
40%);">-		fCreateLinkItem-&gt;SetMessage(new BMessage(kCreateLink));</span><br><span \
style="color: hsl(0, 100%, \
40%);">-		PopulateMoveCopyNavMenu(dynamic_cast&lt;BNavMenu*&gt;</span><br><span \
style="color: hsl(0, 100%, \
40%);">-			(fCreateLinkItem-&gt;Submenu()),</span><br><span style="color: hsl(0, \
100%, 40%);">-		kCreateLink, item_ref, false);</span><br><span style="color: hsl(0, \
100%, 40%);">-	}</span><br><span style="color: hsl(120, 100%, \
40%);">+	UpdateCreateLinkMenuItem(fCreateLinkItem, item_ref);</span><br><span> \
</span><br><span> 	fMoveToItem-&gt;SetEnabled(true);</span><br><span> \
fCopyToItem-&gt;SetEnabled(true);</span><br><span> \
fCreateLinkItem-&gt;SetEnabled(true);</span><br><span> </span><br><span> 	// Set the \
&quot;Identify&quot; item label</span><br><span style="color: hsl(0, 100%, \
40%);">-	BMenuItem* identifyItem = \
parent-&gt;FindItem(kIdentifyEntry);</span><br><span style="color: hsl(0, 100%, \
40%);">-	if (identifyItem != NULL) {</span><br><span style="color: hsl(0, 100%, \
40%);">-		if (modifierKeys &amp; B_SHIFT_KEY) {</span><br><span style="color: hsl(0, \
100%, 40%);">-			identifyItem-&gt;SetLabel(B_TRANSLATE(&quot;Force \
identify&quot;));</span><br><span style="color: hsl(0, 100%, \
40%);">-			identifyItem-&gt;Message()-&gt;ReplaceBool(&quot;force&quot;, \
true);</span><br><span style="color: hsl(0, 100%, 40%);">-		} else {</span><br><span \
style="color: hsl(0, 100%, \
40%);">-			identifyItem-&gt;SetLabel(B_TRANSLATE(&quot;Identify&quot;));</span><br><span \
style="color: hsl(0, 100%, \
40%);">-			identifyItem-&gt;Message()-&gt;ReplaceBool(&quot;force&quot;, \
false);</span><br><span style="color: hsl(0, 100%, 40%);">-		}</span><br><span \
style="color: hsl(0, 100%, 40%);">-	}</span><br><span style="color: hsl(120, 100%, \
40%);">+	UpdateIdentifyMenuItem(parent-&gt;FindItem(kIdentifyEntry));</span><br><span> \
}</span><br><span> </span><br><span> </span><br><span>@@ -2710,16 +2684,16 \
@@</span><br><span> 	BMenuItem* item = \
fDropContextMenu-&gt;FindItem(kCreateLink);</span><br><span> 	if (item == \
NULL)</span><br><span> 		item = \
fDropContextMenu-&gt;FindItem(kCreateRelativeLink);</span><br><span style="color: \
hsl(0, 100%, 40%);">-	if (item &amp;&amp; (modifiers() &amp; B_SHIFT_KEY)) \
{</span><br><span style="color: hsl(120, 100%, 40%);">+	if (item != NULL &amp;&amp; \
(modifiers() &amp; B_SHIFT_KEY)) {</span><br><span> \
item-&gt;SetLabel(B_TRANSLATE(&quot;Create relative link \
here&quot;));</span><br><span> 		item-&gt;SetMessage(new \
BMessage(kCreateRelativeLink));</span><br><span style="color: hsl(0, 100%, 40%);">-	} \
else if (item) {</span><br><span style="color: hsl(120, 100%, 40%);">+	} else if \
(item != NULL) {</span><br><span> 		item-&gt;SetLabel(B_TRANSLATE(&quot;Create link \
here&quot;));</span><br><span> 		item-&gt;SetMessage(new \
BMessage(kCreateLink));</span><br><span> 	}</span><br><span> </span><br><span> 	item \
= fDropContextMenu-&gt;Go(global, true, true);</span><br><span style="color: hsl(0, \
100%, 40%);">-	if (item)</span><br><span style="color: hsl(120, 100%, 40%);">+	if \
(item != NULL)</span><br><span> 		return item-&gt;Command();</span><br><span> \
</span><br><span> 	return 0;</span><br><span>@@ -2918,9 +2892,11 @@</span><br><span> \
#endif</span><br><span> </span><br><span> \
menu-&gt;AddSeparatorItem();</span><br><span style="color: hsl(120, 100%, \
40%);">+</span><br><span> 	BMessage* message = new \
BMessage(kIdentifyEntry);</span><br><span> 	message-&gt;AddBool(&quot;force&quot;, \
false);</span><br><span> 	menu-&gt;AddItem(new \
BMenuItem(B_TRANSLATE(&quot;Identify&quot;), message));</span><br><span style="color: \
hsl(120, 100%, 40%);">+</span><br><span> 	BMenu* addOnMenuItem = new \
BMenu(B_TRANSLATE(&quot;Add-ons&quot;));</span><br><span> \
addOnMenuItem-&gt;SetFont(be_plain_font);</span><br><span> \
menu-&gt;AddItem(addOnMenuItem);</span><br><span>@@ -4361,6 +4337,101 \
@@</span><br><span> }</span><br><span> </span><br><span> </span><br><span \
style="color: hsl(120, 100%, 40%);">+void</span><br><span style="color: hsl(120, \
100%, 40%);">+BContainerWindow::UpdateMenuItemsForModifiersChanged()</span><br><span \
style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, \
40%);">+	BMenuItem* item = NULL;</span><br><span style="color: hsl(120, 100%, \
40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+	// File \
menu</span><br><span style="color: hsl(120, 100%, 40%);">+	if (fFileMenu != NULL) \
{</span><br><span style="color: hsl(120, 100%, 40%);">+		// Identify/Force \
identify</span><br><span style="color: hsl(120, 100%, 40%);">+		item = \
fFileMenu-&gt;FindItem(kIdentifyEntry);</span><br><span style="color: hsl(120, 100%, \
40%);">+		UpdateIdentifyMenuItem(item);</span><br><span style="color: hsl(120, 100%, \
40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+		// Create link/Create \
relative link</span><br><span style="color: hsl(120, 100%, 40%);">+		item = \
fFileMenu-&gt;FindItem(kCreateLink);</span><br><span style="color: hsl(120, 100%, \
40%);">+		UpdateCreateLinkMenuItem(item);</span><br><span style="color: hsl(120, \
100%, 40%);">+		item = fFileMenu-&gt;FindItem(kCreateRelativeLink);</span><br><span \
style="color: hsl(120, 100%, \
40%);">+		UpdateCreateLinkMenuItem(item);</span><br><span style="color: hsl(120, \
100%, 40%);">+</span><br><span style="color: hsl(120, 100%, \
40%);">+	}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span \
style="color: hsl(120, 100%, 40%);">+	// File context menu</span><br><span \
style="color: hsl(120, 100%, 40%);">+	if (fFileContextMenu != NULL) {</span><br><span \
style="color: hsl(120, 100%, 40%);">+		// Identify/Force identify</span><br><span \
style="color: hsl(120, 100%, 40%);">+		item = \
fFileContextMenu-&gt;FindItem(kIdentifyEntry);</span><br><span style="color: hsl(120, \
100%, 40%);">+		UpdateIdentifyMenuItem(item);</span><br><span style="color: hsl(120, \
100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+		// Create \
link/Create relative link</span><br><span style="color: hsl(120, 100%, 40%);">+		item \
= fFileContextMenu-&gt;FindItem(kCreateLink);</span><br><span style="color: hsl(120, \
100%, 40%);">+		UpdateCreateLinkMenuItem(item);</span><br><span style="color: \
hsl(120, 100%, 40%);">+		item = \
fFileContextMenu-&gt;FindItem(kCreateRelativeLink);</span><br><span style="color: \
hsl(120, 100%, 40%);">+		UpdateCreateLinkMenuItem(item);</span><br><span \
style="color: hsl(120, 100%, 40%);">+	}</span><br><span style="color: hsl(120, 100%, \
40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span \
style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, \
40%);">+void</span><br><span style="color: hsl(120, 100%, \
40%);">+BContainerWindow::UpdateIdentifyMenuItem(BMenuItem* item)</span><br><span \
style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, \
40%);">+	if (item == NULL || item-&gt;Menu() == NULL)</span><br><span style="color: \
hsl(120, 100%, 40%);">+		return;</span><br><span style="color: hsl(120, 100%, \
40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+	if ((modifiers() &amp; \
B_SHIFT_KEY) != 0) {</span><br><span style="color: hsl(120, 100%, \
40%);">+		item-&gt;Message()-&gt;ReplaceBool(&quot;force&quot;, \
true);</span><br><span style="color: hsl(120, 100%, \
40%);">+		item-&gt;SetLabel(B_TRANSLATE(&quot;Force identify&quot;));</span><br><span \
style="color: hsl(120, 100%, 40%);">+	} else {</span><br><span style="color: hsl(120, \
100%, 40%);">+		item-&gt;Message()-&gt;ReplaceBool(&quot;force&quot;, \
false);</span><br><span style="color: hsl(120, 100%, 40%);">+		// add some room for \
the label to grow</span><br><span style="color: hsl(120, 100%, 40%);">+		BString \
label(B_TRANSLATE(&quot;Identify&quot;));</span><br><span style="color: hsl(120, \
100%, 40%);">+		float shortLabel = item-&gt;Menu()-&gt;StringWidth(</span><br><span \

<div style="display:none"> Gerrit-Project: haiku </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: \
I5dfbd4d468fad02894f1f31aa08d1abf630a4b5d </div> <div style="display:none"> \
Gerrit-Change-Number: 2293 </div> <div style="display:none"> Gerrit-PatchSet: 1 \
</div> <div style="display:none"> Gerrit-Owner: John Scipione \
&lt;jscipione@gmail.com&gt; </div> <div style="display:none"> Gerrit-MessageType: \
newchange </div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic