General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Pages: 12Next
Current Page: 1 of 2
Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: November 18, 2008 10:15PM

I am trying to write a macro which will change the picture on a toolbar button. I am using the instructions in http://kmeleon.sourceforge.net/wiki/PluginCommands .

I am not having any luck with this effort so I hope someone can tell me more of how this is to work. I think the "[HOT|COLD|DEAD]" is optional but I don't know if I must hold a place for it with an extra comma in the argument. I have been making various changes in $_SnippetTag. So far I have not found an argument that works. I am not even sure that the second parameter in the pluginmsg statement should be "Search". Buttons are not named and must be called by command.

I have a test macro which looks like this:
#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- Snippet.kmm
# ---------- Located in KM 1.5.0 ---------------
# ---------- code testing 
#
# Dependencies        : main.kmm
# Resources           : -  16x16 bmp files in SearchButtons folder
# Preferences         : -
# Version             : -  0.1
# --------------------------------------------------------------------------------
#

_Snippet_RunCode{
	$_SnippetSearchName = getpref(STRING,"kmeleon.general.searchEngineName") ;
	if ($_SnippetSearchName == "Yahoo! Search") $_SnippetSearchIcon = $_Snippet_Path. "\\filter_url.bmp" ;	
	if ($_SnippetSearchName == "MSN Search") $_SnippetSearchIcon = $_Snippet_Path. "\\hourglass.bmp" ;
	if ($_SnippetSearchName == "Wikipedia, The Free Encyclopedia") $_SnippetSearchIcon = $_Snippet_Path. "\\red_clock.bmp.bmp" ;
	if ($_SnippetSearchName == "Google Images") $_SnippetSearchIcon = $_Snippet_Path. "\\yellow_clock.bmp" ;

	#$_SnippetTag =  "\"" . "&Search Buttons, Search, COLD,". $_SnippetSearchIcon . "\"" ;	
	#$_SnippetTag =  "\"" . "&Search Buttons, Search, ". $_SnippetSearchIcon . "\"" ;	
	$_SnippetTag =  "\"" . "&Search Buttons, Search, ,". $_SnippetSearchIcon . "\"" ;	
	#$_SnippetTag =  "\"" . "&Search Buttons, Search,". $_SnippetSearchIcon . "\"" ;	
	alert( $_SnippetTag , "String for third item of pluginmsg" );
	pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);

	}

_Snippet_BuildMenu{
	# add another option to Favorites menu 
	setmenu("F&avorites",macro,"Snippet Testing",_Snippet_RunCode,3);
	}

_Snippet_GetPath{
	### Snippet.js is supposed to be located in the same folder as Snippet.kmm (this file).
	### If it isn't, Windows Script Host will notify the user.
	### Double underscore makes variable local only.
	$__Data=readfile(getfolder(MacroFolder)."\\Snippet.kmm");
	#$_Snippet_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\Snippet.js";
	$_Snippet_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\SearchButtons";
	}

$OnStartup=$OnStartup."_Snippet_GetPath;";
$OnInit=$OnInit."_Snippet_BuildMenu;";
$macroModules=$macroModules."Snippet;";



Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: November 19, 2008 12:27AM

Hi, JamesD, I hope help you a little: smiling smiley

Documentation isn't very good but i'll tried explain to you:

pluginmsg(toolbars, "SetButtonImage", "<ToolbarName>, <ButtonID>, [HOT|COLD|DEAD], Path/to/new/image.bmp[0]");

For pieces:

0) pluginmsg => command name to send commands to plugins.
1) toolbars => plugin name
2) "SetButtonImage" => plugin function
3) "<...string...>" => Button definition similar to explained it in "toolbars.cfg" file:
- First remember toolbar.cfg file documentation:
# Tool Bar(16,16){	= NAME OF TOOLBAR (WIDTH, HEIGHT) *default = (16,16) 

# Print(16,16) {	= NAME OF BUTTON (WIDTH, HEIGHT) *none = Tool Bar specs
# ID_FILE_PRINT|Print 	= ID COMMAND, PLUGIN COMMAND, OR MACRO | MENU NAME (as defined in menus.cfg)
# Print this page 	= TOOL TIP		
# toolhot.bmp[0] 	= HOT IMAGE [INDEX WITHIN IMAGE FILE]
# toolcold.bmp[0] 	= COLD IMAGE [INDEX WITHIN IMAGE FILE]
# tooldead.bmp[0] 	= DISABLED IMAGE [INDEX WITHIN IMAGE FILE] *optional
# } 			= END OF BUTTON

# - 			= SEPARATOR

# } 			= END OF TOOL BAR

# NO TOOL BAR IMAGES 	= TEXT BASED TOOL BAR WITH BUTTON NAMES FOR IMAGES

- Now this same explained in pluginmsg() as string in the third parameter:
<ToolbarName>, => "Tool Bar" (in the documentation example)
<ButtonID>, => "Print" (also named button name)
[HOT|COLD|DEAD], => This isn't optional, you must define what image in button you like changed: HOT image, COLD image or DEAD image.
Path/to/new/image.bmp[0] => Path and index in bmp image to new image.

Example for your macro:
$_SnippetSearchIcon = $_Snippet_Path. "\\filter_url.bmp[0]";
$_SnippetTag = "&Search Buttons, Search, COLD," . $_SnippetSearchIcon;
pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);

Greetings.

K-Meleon in Spanish

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: November 19, 2008 03:55AM

@ desga2

This is the value in $_SnippetTag.
"&Search Buttons, Search, COLD,C:\Program Files\k-meleon\Profiles\tq3p1wcv.default\macros\SearchButtons\filter_url.bmp[0]"

This is the line in the macro.
pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);

The file "filter_url.bmp" exists in the folder "SearchButtons" within my user macro folder. I assume that COLD is the button state when the mouse pointer is not over the button. I run the macro, but I see no change.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: November 19, 2008 04:14AM

Sorry we didn't see this note:
Quote
Documentation
Currently, buttons are identified by command, not by name. Consequently, <ButtonID> must be replaced by the command associated to the button rather than the button's name.

We must used "macros(Search)" or "ID_NAV_SEARCH" instead "Search" (ButtonID isn't Button name, is Button command).

K-Meleon in Spanish



Edited 1 time(s). Last edit at 11/19/2008 04:15AM by desga2.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: November 19, 2008 04:44AM

@ desga2

Have tried with both <Button ids>
"&Search Buttons, macros(Search), COLD,C:\Program Files\k-meleon\Profiles\tq3p1wcv.default\macros\SearchButtons\filter_url.bmp[0]"
"&Search Buttons, ID_NAV_SEARCH, COLD,C:\Program Files\k-meleon\Profiles\tq3p1wcv.default\macros\SearchButtons\filter_url.bmp[0]"

I still don't see a picture change. Do I need the whole line from toolbars.cfg which is "macros(Search)|_Search_Engines"? Does it make some difference that this is in a "%if %else %endif" situation?

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: November 19, 2008 04:53AM

Quote
JamesD
I still don't see a picture change. Do I need the whole line from toolbars.cfg which is "macros(Search)|_Search_Engines"? Does it make some difference that this is in a "%if %else %endif" situation?

Now i don't know. sad smiley
Are you tried with whole line "macros(Search)|_Search_Engines"?

You are right, %if and %else define if your command button is "macros(Search)" or "ID_NAV_SEARCH". If you have macros plugin enabled command button must be "macros(Search)".



Edited 1 time(s). Last edit at 11/19/2008 04:54AM by desga2.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JujuLand
Date: November 19, 2008 08:08AM

The error is probably due to the path string.

Replace C:\Program Files\... by C:\\Program Files\\...

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: disrupted
Date: November 19, 2008 08:50AM

and program files contains space name perhaps could need \"

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JujuLand
Date: November 19, 2008 10:11AM

Quote

and program files contains space name perhaps could need \"

I don't think so ... because " is the delimitor of the a lot of parameters. The separator must be here "," and the space ought not to be a problem.

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc





Edited 1 time(s). Last edit at 11/19/2008 10:12AM by JujuLand.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: disrupted
Date: November 19, 2008 10:44AM

ah ok.. i think you're right

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: November 19, 2008 04:53PM

@ Jujuland

I have the path with \\ instead of \ but I don't see any change. I have even created another button in &Search Buttons where I have only the ID_NAV_SEARCH command and none of the if/then stuff. The button works but I cannot change the image on the button.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: November 19, 2008 05:10PM

I know how to avoid the path problem.
Created a "default" folder in "skins" subfolder.
Copy all your new bmp files for button here.
Now you can use this same command without path:

Example for your macro:
$_SnippetSearchIcon = "filter_url.bmp[0]";
$_SnippetTag = "&Search Buttons, macros(Search), COLD, " . $_SnippetSearchIcon;
pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);

K-Meleon in Spanish

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JujuLand
Date: November 19, 2008 06:18PM

@Desga,

This folder is already used by K-Meleon (see Noscript.kmm)

To change the button image, see also Noscript.kmm

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc





Edited 1 time(s). Last edit at 11/19/2008 06:19PM by JujuLand.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: November 19, 2008 06:40PM

I know it, but in NoScript.kmm macro we don't use "SetButtonImage" plugin toolbar command for change icon in button, because is a generated button not an existing button and is a check button that change between defined COLD and HOT images.

_NoScript_BuildToolbar{
# Toolbars
$Large=(index(readfile(getfolder("SkinFolder")."\\..\\skins.ini"),getpref(STRING,"kmeleon.general.skinsCurrent")."=1")>-1);
$Large ? pluginmsg(toolbars,"AddToolbar","NoScript,24,24",""): pluginmsg(toolbars,"AddToolbar","NoScript,16,16","");
$Large ? pluginmsg(toolbars,"AddButton","NoScript,NoScript,macros(NoScript_Toggle),&NoScript,".$_NoScript_Tooltip.",24,24,"."noscript_large.bmp[0],"."noscript_large.bmp[1]"."noscript_large.bmp[2]",""):0;
$Large ? 0: pluginmsg(toolbars,"AddButton","NoScript,NoScript,macros(NoScript_Toggle),&NoScript,".$_NoScript_Tooltip.",16,16,"."noscript.bmp[0],"."noscript.bmp[1]"."noscript.bmp[2]","");
}

K-Meleon in Spanish



Edited 3 time(s). Last edit at 11/19/2008 06:45PM by desga2.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: November 19, 2008 07:22PM

I don't think the "add button" will work for my project. That only works on startup. I cannot see any problem with the path to my buttons. I have tried with single \ and double \ and neither worked. I have used [] about COLD and I have used COLD without brackets. None of these have worked. The instructions do not show quotes about the path. They have quotes for the entire third parameter. So far I have not found any example of "SetButtonImage" in any macro.

Does anyone know of a working macro with the pluginmsg(toolbars, "SetButtonImage",... statement?

Is there any documentation on the "default" folder in the "skins" folder? Would I make one on the same level as "Klassic"?

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JujuLand
Date: November 19, 2008 09:28PM

Default folder under skins is used by K-Meleon to find the images not found in skin folder.

It's a good folder to put images which are not dependant of skin, and without working in skin folders.

For example, you can change the skin, Noscript image is always found.

For your button, have you tried, after having modify the image, to use rebarmenu() or a function like that to refresh the toolbar ?

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: November 19, 2008 10:04PM

@ Jujuland

I now have all the bmp files in the default folder. I know that folder is right because some I moved from Klassic folder and they are showing in my toolbar. This the last string that was in the third parameter.
"&Search Buttons, ID_NAV_SEARCH, COLD,filter_url.bmp[0]"

This code now in my toolbars.cfg file.
	display{
	ID_NAV_SEARCH
	Icon of general search engine
	checkered-flag.bmp
	}

It displays on the &Search Buttons bar and does work. I just cannot get the image on the button to change. I cannot find a statement to refresh the toolbars.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: December 03, 2008 10:36PM

@ JamesD:

About this problem, are you tried it with new K-Meleon 1.5.2RC?

I think that this can be a related bug with this other reported bug (#1050) for 1.5.0 and 1.5.1 and fixed in 1.5.2.

Or, are you tried with 1.1.X version to check if this worked in before versions?

K-Meleon in Spanish



Edited 1 time(s). Last edit at 12/03/2008 10:42PM by desga2.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: December 04, 2008 12:43AM

@ desga2

Not yet, I will try in 1.5.2 RC tomorrow.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JujuLand
Date: December 04, 2008 05:53PM

This code now in my toolbars.cfg file.

	display{
	ID_NAV_SEARCH
	Icon of general search engine
	checkered-flag.bmp
	}

if you want to change the image when checked, for example, you must have a bmp with two images minimum, anf change the code to :

display{
ID_NAV_SEARCH
Icon of general search engine
checkered-flag.bmp[0]
checkered-flag.bmp[1]
}

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: December 04, 2008 08:22PM

@ Jujuland

I think I understand about COLD|HOT, but first I have to get the image on the current search button replaced by code in a macro. What I want to do is to have images for many search engines and replace the standard button with another image based on which search engine is current. The idea comes from this thread. http://kmeleonbrowser.org/forum/read.php?2,85367

The current code for the search button is complex and I have some trouble understanding what shoud be the value for <button id>. Because of that and for testing only, I added another button with simple code. It has only the command id.

Unfortunately, I have not yet gotten the button to change images.

Looks to me like there are three items in the plugin command each separated by a comma.

pluginmsg(toolbars, "SetButtonImage",

These first two are easy as they are literal copied from the instructions.

"<ToolbarName>, <ButtonID>, [HOT|COLD|DEAD], Path/to/new/image.bmp[0]"

This third quoted string with items separated by commas is where I think that I am having a problem. I think that <ToolbarName> would be &Search Buttons. The value for <ButtonID> might be ID_NAV_SEARCH unless it should be "display".

I don't know if the value for "cold" should be COLD or [COLD]. I also don't know if the HOT|COLD|DEAD] means the field is optional or not. If it is optional, do I hold its place with a comma. A single image works. It just means there is no change when you mouseover the button.

I have tried the last item, the path to the image, with single and double backslashes. I have also put single quotes around the string.

I cannot find a single instance in the KM macros of this command. Usually an example helps me a great deal.

Any ideas or suggestions you might have will be greatly appreciated. I am preparing to start testing in 1.5.2 RC now.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: December 04, 2008 09:21PM

These are the values that I tested. No change on button image so far.

$_SnippetTag values

"&Search Buttons, ID_NAV_SEARCH, [COLD], 'C:\Program Files\K-M 152RC\Profiles\8rp6m7e9.default\macros\SearchButtons\\filter_url.bmp'"
"&Search Buttons, ID_NAV_SEARCH, [COLD], 'C:\Program Files\K-M 152RC\Profiles\8rp6m7e9.default\macros\SearchButtons\\filter_url.bmp[0]'"
"&Search Buttons, ID_NAV_SEARCH, [COLD], 'C:\\Program Files\\K-M 152RC\\Profiles\\8rp6m7e9.default\\macros\\SearchButtons\\filter_url.bmp'"
"&Search Buttons, ID_NAV_SEARCH, [COLD], 'C:\\Program Files\\K-M 152RC\\Profiles\\8rp6m7e9.default\\macros\\SearchButtons\\filter_url.bmp[0]'"

"&Search Buttons, ID_NAV_SEARCH, COLD, 'C:\Program Files\K-M 152RC\Profiles\8rp6m7e9.default\macros\SearchButtons\\filter_url.bmp'"
"&Search Buttons, ID_NAV_SEARCH, COLD, 'C:\Program Files\K-M 152RC\Profiles\8rp6m7e9.default\macros\SearchButtons\\filter_url.bmp[0]'"
"&Search Buttons, ID_NAV_SEARCH, COLD, 'C:\\Program Files\\K-M 152RC\\Profiles\\8rp6m7e9.default\\macros\\SearchButtons\\filter_url.bmp[0]'"
"&Search Buttons, ID_NAV_SEARCH, COLD, 'C:\\Program Files\\K-M 152RC\\Profiles\\8rp6m7e9.default\\macros\\SearchButtons\\filter_url.bmp'"



Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: December 04, 2008 09:26PM

Quote
desga2
I know how to avoid the path problem.
Created a "default" folder in "skins" subfolder.
Copy all your new bmp files for button here.
Now you can use this same command without path:

Example for your macro:
$_SnippetSearchIcon = "filter_url.bmp[0]";
$_SnippetTag = "&Search Buttons, macros(Search), COLD, " . $_SnippetSearchIcon;
pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);

I said you how i think this work based in my experience with similar functions like:

_NoScript_BuildToolbar{
# Toolbars
$Large=(index(readfile(getfolder("SkinFolder")."\\..\\skins.ini"),getpref(STRING,"kmeleon.general.skinsCurrent")."=1")>-1);
$Large ? pluginmsg(toolbars,"AddToolbar","NoScript,24,24",""): pluginmsg(toolbars,"AddToolbar","NoScript,16,16","");
$Large ? pluginmsg(toolbars,"AddButton","NoScript,NoScript,macros(NoScript_Toggle),&NoScript,".$_NoScript_Tooltip.",24,24,"."noscript_large.bmp[0],"."noscript_large.bmp[1]"."noscript_large.bmp[2]",""):0;
$Large ? 0: pluginmsg(toolbars,"AddButton","NoScript,NoScript,macros(NoScript_Toggle),&NoScript,".$_NoScript_Tooltip.",16,16,"."noscript.bmp[0],"."noscript.bmp[1]"."noscript.bmp[2]","");
}

- Now this same explained in pluginmsg() as string in the third parameter:

<ToolbarName>, => Toolbar name => &Search Buttons => OK

<ButtonID>, => Currently, buttons are identified by command, not by name => "macros(Search)" or "ID_NAV_SEARCH" => OK

[HOT|COLD|DEAD], => This isn't optional, you must define (ONE of the list and without [brackets]) what image in button you like changed: HOT image, COLD image or DEAD image => OK

Path/to/new/image.bmp[0] => Path and index in bmp image to new image (With only one / and without quotes) => OK

(Remember that if you use image buttons in a "default" subfolder in skin folder path don't need be specified, only image name file and index)

Sentence is OK in my opinion.

I vote by this is the correct:
(Note that you similar line have double / at the end of path, this path is without quotes and added index in image file at the end of the path)

"&Search Buttons, ID_NAV_SEARCH, COLD, C:\Program Files\K-M 152RC\Profiles\8rp6m7e9.default\macros\SearchButtons\filter_url.bmp[0]"



Edited 5 time(s). Last edit at 12/04/2008 09:35PM by desga2.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: December 04, 2008 10:35PM

@ degas2

I made sure that default folder was in skins folder and contains the image files.

This is $_SnippetTag in current test under 1.5.2 RC.
"&Search Buttons, ID_NAV_SEARCH, COLD, filter_url.bmp[0]"
It is used in this line of code:
pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);

I observe no change in the button.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: December 05, 2008 07:20PM

I was definitely right. It work for me as I said in my before post.

This code work fine for me in K-Meleon 1.5.0 with default skin and configuration:
Add new "Snippet Testing" option in Tools menu.
(Note: Gbutton.bmp file in path K-Meleon\skins\default)

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- Snippet.kmm
# ---------- Located in KM 1.5.0 ---------------
# ---------- code testing 
#
# Dependencies        : main.kmm
# Resources           : -  16x16 bmp files in K-Meleon\skins\default\ folder
# Preferences         : -
# Version             : -  0.1
# --------------------------------------------------------------------------------
#

_Snippet_RunCode{
	$_SnippetSearchIcon = "Gbutton.bmp[0]";
	$_SnippetTag = "&Search Buttons, macros(Search), COLD, " . $_SnippetSearchIcon;
	pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);
	$_SnippetSearchIcon = "Gbutton.bmp[1]";
	$_SnippetTag = "&Search Buttons, macros(Search), HOT, " . $_SnippetSearchIcon;
	pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);
	$_SnippetSearchIcon = "Gbutton.bmp[2]";
	$_SnippetTag = "&Search Buttons, macros(Search), DEAD, " . $_SnippetSearchIcon;
	pluginmsg(toolbars, "SetButtonImage", $_SnippetTag);
	}

_Snippet_BuildMenu{
	setmenu("Misc",macro,"Snippet Testing",_Snippet_RunCode);
	}

$OnInit=$OnInit."_Snippet_BuildMenu;";
$macroModules=$macroModules."Snippet;";

To test "EnableButton", you can use this line of code (0=disable, 1=enable):
pluginmsg(toolbars, "EnableButton", "&Search Buttons, macros(Search), 0");


P.S.: Only one little problem, when button icon is changed before icon remain in backgrond until you move your mouse over it and button is refreshed.

K-Meleon in Spanish



Edited 5 time(s). Last edit at 12/05/2008 07:49PM by desga2.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: December 05, 2008 07:55PM

@ desga2

YES !! It works now. The documentation is wrong. Documentation shows the third item in quotes. It should not have quotes.

Thanks very much for your help. Now I can get on with the rest of the project.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: December 05, 2008 08:26PM

@ JamesD:

Quote
toolbar
pluginmsg(toolbars, "SetButtonImage", "<ToolbarName>, <ButtonID>, [HOT|COLD|DEAD], Path/to/new/image.bmp[0]");

Where are the quotes in path? tongue sticking out smiley <<Path/to/new/image.bmp[0]>>

Almost I think that I said you in before post that path haven't quotes.

Documentation isn't very good, but with some test and examples I could explain to you how work this functions.

K-Meleon in Spanish

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: December 05, 2008 09:21PM

@ desga2

I got my documentation from here. http://kmeleon.sourceforge.net/wiki/PluginCommands

This is what I saw and was working from.
 pluginmsg(toolbars, "SetButtonImage", "<ToolbarName>, <ButtonID>, [HOT|COLD|DEAD], Path/to/new/image.bmp[0]");

With your help, I have SearchIcon.kmm working now. I just have to find icons from a large number of search engines and I need to find out how to put all the 16x16 bmp files into a long file which uses the index system. ie [0],[1],[2], etc.

SearchIcon.kmm
#  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 
# Resources           : - 
# Preferences         : - 
# Version             : - 0.2   2008-12-06
# --------------------------------------------------------------------------------
_SearchIcon_RunCode{
	$_SearchIconSearchName = getpref(STRING,"kmeleon.general.searchEngineName") ;
	if ($_SearchIconSearchName == "Yahoo! Search") $_SearchIconSearchIcon =  "Yahoo.bmp[0]";  	
	if ($_SearchIconSearchName == "MSN Search") $_SearchIconSearchIcon = "MSN.bmp[0]" ;
	if ($_SearchIconSearchName == "Wikipedia, The Free Encyclopedia") $_SearchIconSearchIcon = "Wikipedia.bmp[0]" ;
	if ($_SearchIconSearchName == "Google Images") $_SearchIconSearchIcon =  "Google.bmp[0]" ;
	$_SearchIconTag =  "&Search Buttons, macros(Search), COLD,". $_SearchIconSearchIcon ;
	pluginmsg(toolbars, "SetButtonImage", $_SearchIconTag);
	}

$OnStartup=$OnStartup."_SearchIcon_RunCode;";
$macroModules=$macroModules."SearchIcon;";


Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: desga2
Date: December 06, 2008 03:36PM

Quote
JamesD
I just have to find icons from a large number of search engines and I need to find out how to put all the 16x16 bmp files into a long file which uses the index system. ie [0],[1],[2], etc.

This is easy, I'm using IrfanView to create a "panorama" image.

If you post the list of search engines I can do the bmp file with all icons.

But I think is better have a bmp file with two icons (COLD [0], HOT [1]) for each search engine. And I would change your function code to:

_SearchIcon_RunCode{
	$_SearchIconSearchName = getpref(STRING,"kmeleon.general.searchEngineName");
	if ($_SearchIconSearchName == "Yahoo! Search") $_SearchIconSearchIcon =  "Yahoo.bmp";  	
	if ($_SearchIconSearchName == "MSN Search") $_SearchIconSearchIcon = "MSN.bmp";
	if ($_SearchIconSearchName == "Wikipedia, The Free Encyclopedia") $_SearchIconSearchIcon = "Wikipedia.bmp";
	if ($_SearchIconSearchName == "Google Images") $_SearchIconSearchIcon =  "Google.bmp";
	$_SearchIconTag =  "&Search Buttons, macros(Search), COLD,". $_SearchIconSearchIcon . "[0]";
	pluginmsg(toolbars, "SetButtonImage", $_SearchIconTag);
	$_SearchIconTag =  "&Search Buttons, macros(Search), HOT,". $_SearchIconSearchIcon . "[1]";
	pluginmsg(toolbars, "SetButtonImage", $_SearchIconTag);
	}

K-Meleon in Spanish



Edited 2 time(s). Last edit at 12/06/2008 03:47PM by desga2.

Options: ReplyQuote
Re: Help needed with pluginmsg for toolbars
Posted by: JamesD
Date: December 06, 2008 10:03PM

@ desga2

OK, I like the idea of HOT and COLD. Easy to fix in the macro. As to the list of search engines, that is not so easy. I have icons for the four that I use. If this is to go into MacroLibrary I guess I would need a fair number of the most used engines. I just don't know which ones in the list that comes with KM should be included. I just use the four that are already in the macro.

I noticed that there are multiple entries for Google, Yahoo and some others. I doubt they have separate icons for each type of search. I may need to just look at the first word for those engines.

What would be used to make the HOT images? Do we just change the brightness of the background or something like that?

One other thing is to find a way to update the icon if the user changes default engine during a session. I don't think I want to explain to users how to add an item to the macro that changes default engine to call this macro. An option would be to check the current default engine against a pref with engine used at startup. Would have to do this on all $OnLoad events. Hopefully this "compare" would not take too many resources. Something like "CHECK; IF DIFFERENT THEN FIX : ELSE NOTHING".

Options: ReplyQuote
Pages: 12Next
Current Page: 1 of 2


K-Meleon forum is powered by Phorum.