I will answer myself to this post, as I finally found the solution.
You have to create a custom action with controlclass, and in the control class you programmatically hide or show the custom action depending on the list name.
Here is the full code:
<CustomAction
Id="GoToGoogle"
Title="Go To Google"
Location="Microsoft.SharePoint.StandardMenu"
RegistrationId="101"
RegistrationType="List"
GroupId="ActionsMenu"
Sequence="1000"
ControlAssembly="Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cd112ea8ee9f48d3"
ControlClass="Assembly.CustomActions.MyCustomAction" >
<UrlAction Url="http://www.google.com"/>
</CustomAction>
Here is the class which you need:
public class MyCustomAction : WebControl
{
private MenuItemTemplate _MenuItemTemp;
private string list;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!Page.IsPostBack)
{
EnsureChildControls();
_MenuItemTemp.Visible = false;
ListViewWebPart listView = GetParentListViewWebPart();
if (listView != null)
{
list = SPContext.Current.List.ToString();
if (list == "Test")
{
if (SPContext.Current.Web.UserIsSiteAdmin)
{
_MenuItemTemp.Visible = true;
}
}
}
}
}
protected override void CreateChildControls()
{
base.CreateChildControls();
SPWeb site = SPContext.Current.Web;
Guid ListId = SPContext.Current.ListId;
_MenuItemTemp = new MenuItemTemplate
{
Text = "Go To Google",
Description = "Go To Google",
ImageUrl = "/_layouts/images/ActionsSettings.gif",
ClientOnClickNavigateUrl = @"http://www.google.com"}"
};
Controls.Add(_MenuItemTemp);
}
private ListViewWebPart GetParentListViewWebPart()
{
Control parent = Parent;
while (parent != null)
{
if (parent is ListViewWebPart)
{
return (ListViewWebPart)parent;
} parent = parent.Parent;
} return null;
}
}
IMPORTANT: make sure to register this class as safe class else you will have an issue, with not displaying anything (no error also)