Hey Guys,
Love your macro. I just stumbled upon it recently. When I concocted the search button macro for 0.9, this was one thing that wasn't available. I think the changing icon makes a big difference and is a great asset. Haven't really been in the "macro business" for a few years now
, and there's more to learn with the new stuff, but I made a variation of searchicon that I think opens it up a bit more. This version doesn't rely on one big panorama. Instead, each search engine has its own 32,16 bitmap consisting of a cold & hot image. The search engine name and it's corresponding bitmap name are also the same. And if the search engine is not in the list, the icon defaults to the search icon of the theme. This would mean that all skins/themes would have to standardize to a 32,16 search.bmp. What I like about the separate bitmaps is that it allows themers to include matching search icons in their themes. They could include all or just some like the most popular ones Google & Yahoo.
I also included the possibilty for separate search engine modules to hook into searchicon.kmm. Even though it's cool that we can add our own engines through cut & pasting into the preferences xul window, ideally end users would like and have come to expect a quick click & install way to add engines. Macro modules combined with a variation of alain's km ext setup would allow that.
Anyway, below is the macro along with a CNET search engine macro module. I based the CNET search engine macro on the code written into search.kmm to accomodate search9. search9 doesn't have to be engaged though. The CNET url address doesn't post here within the macro properly, so replace it with this minus the parenthesis:
(http://www.cnet.com/1770-5_1-0.html?query=)
There might be an easier template for both of these macros. Let me know. Comments, ideas, suggestions, criticisms?
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- SearchIcon.kmm
# ---------- K-Meleon Macro Language Display Search Engine Icons in Search Button ---
#
# Dependencies : - main.kmm Search.kmm KM ver 1.5.0 or later
# Resources : -
# Preferences : - "kmeleon.general.searchEngineName"
# Version : -
# By : - JamesD and desga2 and jsnj
# --------------------------------------------------------------------------------
_SearchIcon_RunCode{
#-- Get the currently chosen search engine's name
#-- and assign that name to the variable "$_SearchIconName"
$_SearchIconName = getpref(STRING,"kmeleon.general.searchEngineName") ;
#-- For search engines with multiple versions such as Google (Scroogle, Boogle, etc...)
#-- search within the name for a common sequence of letters such as "oogle"
#-- and assign them the same search icon name so that they can share the same image
$_n=index($_SearchIconName,"AOL"); $_n == -1 ? 0:$_SearchIconName = "AOL";
$_n=index($_SearchIconName,"oogle"); $_n == -1 ? 0:$_SearchIconName = "Google";
$_n=index($_SearchIconName,"Internet Movie D"); $_n == -1 ? 0:$_SearchIconName = "IMDB";
$_n=index($_SearchIconName,"LEO"); $_n == -1 ? 0:$_SearchIconName = "LEO";
$_n=index($_SearchIconName,"Viv"); $_n == -1 ? 0:$_SearchIconName = "Viv";
$_n=index($_SearchIconName,"Internet Archive"); $_n == -1 ? 0:$_SearchIconName = "Wayback";
$_n=index($_SearchIconName,"Webshots"); $_n == -1 ? 0:$_SearchIconName = "Webshots";
$_n=index($_SearchIconName,"Wikip"); $_n == -1 ? 0:$_SearchIconName = "Wikipedia";
$_n=index($_SearchIconName,"Yahoo"); $_n == -1 ? 0:$_SearchIconName = "Yahoo!";
#-- Assume the chosen search engine is not in the list below
#-- by setting the variable "$_SearchNameNew" to 1
$_SearchNameNew = 1;
#-- Recognize the search engines in the following list
#-- by setting the variable $_SearchNameNew to "0"
if ($_SearchIconName == _("A9.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Acronym Finder")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("AlltheWeb.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("AltaVista")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Amazon.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Answers.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("AOL")) $_SearchNameNew = 0;
if ($_SearchIconName == _("Ask.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Astalavista.box.sk")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Del.icio.us")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Dictionary.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Dogpile")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("eBay.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Find Travel To")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("GameFAQs Search")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Gigablast")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Google")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("HotBot")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("HowStuffWorks")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("IMDB")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Ixquick Metasearch")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Jux2")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("K-Meleon Forums Search")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("LEO")) $_SearchNameNew = 0;
if ($_SearchIconName == _("Lycos")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Mamma Metasearch")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("MetaCrawler")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("MobyGames")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("MSN Search")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Merriam-Webster Online Dictionary")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("OneLook Dictionary Search")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Open Directory (dmoz.org)")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Search.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("SnapFiles")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Viv")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Wayback")) $_SearchNameNew = 0;
if ($_SearchIconName == _("Webshots")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Weather.com")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Wikipedia")) $_SearchNameNew = 0 ;
if ($_SearchIconName == _("Yahoo!")) $_SearchNameNew = 0 ;
#### --------- Add other defined search engines above ------------------------
#-- For search macro modules to hook into this macro.
if ($_SearchIconName == $_SearchName) $_SearchNameNew = 0;
#-- If the search engine name is found in the list above, then do nothing
#-- otherwise set the search icon name to "search".
#-- Then start the macro named "_SearchIconButtons"
$_SearchNameNew == 0 ? 0: $_SearchIconName="search" ; &_SearchIconButtons;
}
_SearchIconButtons{
$_SearchIconTag = "&Search Buttons, macros(Search), COLD,". $_SearchIconName.".bmp[0]" ;
pluginmsg(toolbars, "SetButtonImage", $_SearchIconTag);
$_SearchIconTag = "&Search Buttons, macros(Search), HOT,". $_SearchIconName.".bmp[1]" ;
pluginmsg(toolbars, "SetButtonImage", $_SearchIconTag);
}
$OnStartup=$OnStartup."_SearchIcon_RunCode;";
$macroModules=$macroModules."SearchIcon;";
_________________________________________________
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- search_CNET.kmm
#
# Dependencies : - main.kmm, Search.kmm, SearchIcon.kmm, KM ver 1.5.x
# By : - jsnj
# --------------------------------------------------------------------------------
_CNET{
$_SearchName = "CNET"; $_Search_EngineName = "CNET";
$_Search_EngineURL = "
http://www.cnet.com/1770-5_1-0.html?query=";
&_Search_Init; index($macroModules,";SearchIcon;")>-1?&_SearchIcon_RunCode:0;
}
_CNETSync{
setcheck("macros(_CNET)", getpref(STRING, $sen) == "CNET" ? true:false);
}
_CNETMenu{
setmenu(_Search_Engines,macro,"CNET","_CNET",1);
}
_CNET_OnInit{
index($macroModules,";Search;")>-1?&_CNETMenu:0;
}
$OnInit=$OnInit."_CNET_OnInit;";
_CNET_Init{
$sen=$_Search_pref_DefaultName; &_CNETSync;
$_SearchIconName = getpref(STRING,"kmeleon.general.searchEngineName") ;
if ($_SearchIconName == _("CNET")) $_SearchName = "CNET";
# hook into search.kmm's menu sync
$_Search_SyncMenu=$_Search_SyncMenu."_CNETSync;";
}
_CNET_OnSetup{
index($macroModules,";Search;")>-1?&_CNET_Init:0;
}
$OnSetup=$OnSetup."_CNET_OnSetup;";
# ------------------------------------------------------------------------------------------------------------------
$macroModules=$macroModules."search_CNET;";