General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Pages: 12Next
Current Page: 1 of 2
Bookmark keywords lookup
Posted by: asmpgmr
Date: March 26, 2003 03:24PM

MonkeeSage and Andrew,

Here's a first draft fix which should allow bookmark keywords lookup from the URL bar:

#include "kmeleon_plugin.h" - must be added to BrowserView.cpp for the SendMessage call. Also the SendMessage line will probably wrap in the posting, it's a long line with 5 parameters.


void CBrowserView::OnNewUrlEnteredInUrlBar()
{
char nickUrl[INTERNET_MAX_URL_LENGTH];

mpBrowserFrame->m_wndUrlBar.EditChanged(FALSE);

nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(mWebBrowser));
if(focus)
focus->Activate();

// Get the currently entered URL
CString strUrl;
mpBrowserFrame->m_wndUrlBar.GetEnteredURL(strUrl);

// Check for a nickname
*nickUrl = 0;
theApp.plugins.SendMessage("bookmarks", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);

if (*nickUrl != 0)
OpenURL(nickUrl);
else {
if(IsViewSourceUrl(strUrl))
OpenViewSourceWindow(strUrl.GetBuffer(0));
else
// Navigate to that URL
OpenURL(strUrl.GetBuffer(0));
}

// Add what was just entered into the UrlBar
mpBrowserFrame->m_wndUrlBar.AddURLToList(strUrl);
}

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 26, 2003 04:45PM

asmpgmr:

Yup, that woked..., BrowserView.cpp also needs to have <wininet.h> included.

Here is a spin-off your code with checking for keywords for all three plugins...

========
void CBrowserView::OnNewUrlEnteredInUrlBar()
{
char nickUrl[INTERNET_MAX_URL_LENGTH];

mpBrowserFrame->m_wndUrlBar.EditChanged(FALSE);

nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(mWebBrowser));
if(focus)
focus->Activate();

// Get the currently entered URL
CString strUrl;
mpBrowserFrame->m_wndUrlBar.GetEnteredURL(strUrl);

// Check for a nickname
*nickUrl = 0;
theApp.plugins.SendMessage("favorites", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);

if (*nickUrl != 0)
OpenURL(nickUrl);

else if (*nickUrl == 0) {
theApp.plugins.SendMessage("bookmarks", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);
if (*nickUrl != 0)
OpenURL(nickUrl);
else
theApp.plugins.SendMessage("hotlist", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);
if (*nickUrl != 0)
OpenURL(nickUrl);
}

else {
if(IsViewSourceUrl(strUrl))
OpenViewSourceWindow(strUrl.GetBuffer(0));
else
// Navigate to that URL
OpenURL(strUrl.GetBuffer(0));
}

// Add what was just entered into the UrlBar
mpBrowserFrame->m_wndUrlBar.AddURLToList(strUrl);
}
========

And of course, the order of the checking can be changed (not that it really matters since it does the whole check in literally milliseconds)...but I had the order with favorites first to test if it was going into the else if block correctly, by typing a keyword in the URL bar that I know is not in the Favorites, but is in Bookmarks... it worked correctly. smiling smiley


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 26, 2003 05:00PM

Oops...that should be:

========
void CBrowserView::OnNewUrlEnteredInUrlBar()
{
char nickUrl[INTERNET_MAX_URL_LENGTH];

mpBrowserFrame->m_wndUrlBar.EditChanged(FALSE);

nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(mWebBrowser));
if(focus)
focus->Activate();

// Get the currently entered URL
CString strUrl;
mpBrowserFrame->m_wndUrlBar.GetEnteredURL(strUrl);

// Check for a nickname
*nickUrl = 0;
theApp.plugins.SendMessage("favorites", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);

if (*nickUrl != 0)
OpenURL(nickUrl);

else {
theApp.plugins.SendMessage("bookmarks", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);
if (*nickUrl != 0)
OpenURL(nickUrl);
else
theApp.plugins.SendMessage("hotlist", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);
if (*nickUrl != 0)
OpenURL(nickUrl);
else
if(IsViewSourceUrl(strUrl))
OpenViewSourceWindow(strUrl.GetBuffer(0));
else
// Navigate to that URL
OpenURL(strUrl.GetBuffer(0));
}

// Add what was just entered into the UrlBar
mpBrowserFrame->m_wndUrlBar.AddURLToList(strUrl);
}
========

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 26, 2003 05:17PM

MonkeeSage,

Favorites do not have any such lookup facility since there's nothing like that in IE so you can remove that check. Also I don't know about checking two plugins for this, you really don't want to add too much overhead for this. Most people will likely be using bookmarks anyway so I would leave it checking only bookmarks.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 26, 2003 05:54PM

asmpgmr:

I see. I only use the bookmarks plugin myself, so I didn't know, I was using Ulf's macro as an example.

Here is what I have right now:

=======
void CBrowserView::OnNewUrlEnteredInUrlBar()
{
char nickUrl[INTERNET_MAX_URL_LENGTH];

mpBrowserFrame->m_wndUrlBar.EditChanged(FALSE);

nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(mWebBrowser));
if(focus)
focus->Activate();

// Get the currently entered URL
CString strUrl;
mpBrowserFrame->m_wndUrlBar.GetEnteredURL(strUrl);

// Check for a nickname
*nickUrl = 0;
theApp.plugins.SendMessage("bookmarks", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);
if (*nickUrl != 0)
OpenURL(nickUrl);

else
theApp.plugins.SendMessage("hotlist", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);
if (*nickUrl != 0)
OpenURL(nickUrl);

else
if(IsViewSourceUrl(strUrl))
OpenViewSourceWindow(strUrl.GetBuffer(0));
else
// Navigate to that URL
OpenURL(strUrl.GetBuffer(0));

// Add what was just entered into the UrlBar
mpBrowserFrame->m_wndUrlBar.AddURLToList(strUrl);
}
=======

Also, since Ulf made FindNick return a tab separated list of urls if a folder is nicknamed and not just a URL, there really should be a condition added where if "\t" is in nickURL, then the OnNewUrlEnteredInUrlBar function returns and does nothing (or, ideally, calls the new ReplaceLayersInWindows function from the layers plugin, which takes a tab separated list of urls as its input).


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 26, 2003 06:05PM

Nevermind...

He didn't actually make it so folders can have nicks...I guess that macro was only a rough example...


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 26, 2003 06:11PM

MonkeeSage,

I don't think you're supposed to be able to set nicknames for folders, that doesn't really make any sense. A folder can contain a LOT of bookmark entries which could easily overflow the return buffer and lead to a crash. Even if it didn't I certainly wouldn't want a bunch of new windows opening up for every bookmark in a folder, that's crazy. Plus the current bookmarks plugin editor doesn't even support entry of nicknames for folders, the nick field is greyed out. Personally I think the folder thing should be removed, nicknames should only be for regular bookmarks.

Could you upload the new k-meleon.exe somewhere.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 26, 2003 06:25PM

MonkeeSage,

I just now saw your followup message so I checked the code and folders can't have nicknames, the search code simply goes through the entries within the folder which is correct.

By the way check bug 74 (plugin names shouldn't be case-sensitive), I think this simply fix will address it:

In Plugins.cpp, function Cplugins::Load add strlwr(noPath); after const char *noPath = FileNoPath(file);

const char *noPath = FileNoPath(file);
strlwr(noPath);

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 26, 2003 06:50PM

asmpgmr:

Here is a build (built 1.2.1 backed) with the bookmarks nick stuff and the bug 74 fix:

http://monkeesage.d2g.com/k-meleon.exe

Also, re: bug 74 fix, for VC++, it has to be:

strlwr((char*)noPath);

Otherwise it can't figure out how to covert between types const char* and char* heh stupid compiler...


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 26, 2003 08:10PM

MonkeeSage,

You're missing a pair of braces on the nicknames lookup fix (I really wish the forums supported indentation)

void CBrowserView::OnNewUrlEnteredInUrlBar()
{
char nickUrl[INTERNET_MAX_URL_LENGTH];

mpBrowserFrame->m_wndUrlBar.EditChanged(FALSE);

nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(mWebBrowser));
if(focus)
focus->Activate();

// Get the currently entered URL
CString strUrl;
mpBrowserFrame->m_wndUrlBar.GetEnteredURL(strUrl);

// Check for a nickname
*nickUrl = 0;
theApp.plugins.SendMessage("bookmarks", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);
if (*nickUrl != 0)
OpenURL(nickUrl);
else {
theApp.plugins.SendMessage("hotlist", "* FindNick", "FindNick", (long)strUrl.GetBuffer(0), (long)&nickUrl);
if (*nickUrl != 0)
OpenURL(nickUrl);
else {
if(IsViewSourceUrl(strUrl))
OpenViewSourceWindow(strUrl.GetBuffer(0));
else
// Navigate to that URL
OpenURL(strUrl.GetBuffer(0));
}
}

// Add what was just entered into the UrlBar
mpBrowserFrame->m_wndUrlBar.AddURLToList(strUrl);
}

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 26, 2003 09:16PM

Oops...corrected that. I also fixed the diff for that. Updated binary same place as before.


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 26, 2003 09:39PM

Thanks for the formatted fixes! That is so much nicer to read. grinning smiley


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 26, 2003 10:33PM

MonkeeSage,

I just downloaded the updated .exe and bookmark keywords works great. I guess the similar Opera shortcuts will work equally well. I also verified my fix for 74, plugin names are now fully case insensitive. The filenames can be uppercase and you can specify the plugin names in uppercase in accel.cfg/menus.cfg.

By the way you should add 313 and 74 to the growing list of fixes on your download page.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: C
Date: March 27, 2003 01:18AM

Great work guys!

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 27, 2003 01:43AM

asmpgmr:

Updated the download page to reflect those two bug fixes as well. Awsome job for everything! smiling smiley


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: jsnj
Date: March 27, 2003 05:10AM

Tried it , and it works well. Question: The %s that is used in Mozilla/Phoenix for Quicksearch, is that complicated to add to the build?

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 27, 2003 05:17AM

Here is an easy way to bind bookmark nicks to accel keys...

macros.cfg:
-----------------
accel_1{
opennew(pluginmsgex("bookmarks", "FindNick", "SomeBookmarkNickname", STRING));
}


accels.cfg:
----------------
SHIFT 1 = macros(accel_1)


Nota bene:
* "SomeBookmarkNickname" is the nick you want the accel key to open.
* opennew can be changed to openbg() or open(), or to use layers, or whatever you like.
* SHIFT 1 This can be any keyboard or virtual keyboard (VK_) combination you like, numbers aren't used in K-M by default, and they are easy to access.

(asmpgmr & jsnj: I know you know this, but I didn't want to start a new thread).


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 27, 2003 03:32PM

jsnj,

The %s substitution facility is actually "custom keywords", sort of an extension to bookmark keywords. No it wouldn't be easy to add that because the %s can be anywhere in the URL, not just the end. Using sprintf wouldn't be good because someone could conceivably put in some other format code (%4s, %d, %c, etc.) and really screw things up. Also to my knowledge Opera doesn't have this sort of feature, only the nicknames. Anyway the substitution stuff is better served by K-Meleon macros, K-Meleon doesn't need to support everything that Mozilla does.

http://www.mozilla.org/docs/end-user/keywords.html

MonkeeSage,

By the way the original bug for bookmark keywords (an RFE) is 289.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 27, 2003 03:59PM

MonkeeSage,

About your posting on the dev-list regarding bookmarks groups - folders should not have nickname support so that FindNick could return a list. If it did then this would introduce a potential crash issue because there would be no way to know how large the return buffer would need to be. A buffer for a URL is defined to be INTERNET_MAX_URL_LENGTH but if more than one URL can be returned then potentially it would need to be the number of URLs times that amount. Since there's no limit to how many URLs can be in folder and no way to know this before hand, this probably isn't a good idea. Also why would anyone want all of the bookmarks in a folder to open at once anyway ???? For example I have a folder with 8 bookmarks and I certainly would never want to open them all at once. They're a logical grouping of bookmarks in a similar category. What if someone had 50 bookmarks in a folder ? Opening 50 windows at once would be completely unworkable and would probably crash windows.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 27, 2003 08:18PM

asmpgmr:

I agree that folders would not be ideal...

Here's my suggestion:

========
>>IF there were bookmarks groups in K-Meleon, how would you want them
>>to function? There are some possibilities discussed by Hyatt in his
>>blog:
>>http://www.mozillazine.org/weblogs/hyatt/archives/2003_03.html#00260
>>3
>>
>>/Ulf

>Wouldn't the simplest / most effective method of bookmark groups, be
>to use the same nickname for multiple bookmarks and then make the
>macro / URL bar code to recursively load all bookmarks with the same
>nick when there are more than one?
>
>
>Shelumi`El Jordan
>
>S.D.G

Actually, to make the FindNick function return a tab separated list when there are more than one bookmark with the same nick; then the macro / Url bar code can simply check for "\t" in the return of FindNick, and if present, can be passed it to the new layers function, ReplaceLayersInWindow.


Shelumi`El
Jordan

S.D.G
========

In other words, instead of FindNick returning once it finds the first bookmark with a given nick, it can return a tab separated list when it is the case that more than one bookmark has the same nick.

This would also give the user total control over the groups, and not all bookmarks in group need to be in the same folder in that case, they can be scattered all over, but so long as they all have the same nickname they will be counted as a group.

That seems like the easiest way to implement group support, as far as I can tell, instead of making whole folders to be groups. And there would not be any crash issue this way, unless one explicitly set like 30 bookmarks to have the same nick, which I'm pretty sure no one would do.

PErsonally, I'm content with my session macro, especially now that it can save all windows at once...I doubt I'd even use the groups that often, but it would nice to have the option available.

Like, for instance, I have the three bookmarks where builds of the XVID video codec are upped, and I have to check them all before I know who has the latest / most fixed version and can download. Currently, I have them as bookmark nicks:
xv1, xv2 and xv3. If I could name them all to xv, and load all three sites in the group xv by entering it like a normal nick in the URL bar, that would be somewhat more useful.


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 27, 2003 08:55PM

MonkeeSage,

It's a bad idea to put in code that could potentially crash, even in an extreme situation. Also that would completely screw up entering a nickname from the URL bar. If someone has the same nickname for multiple bookmarks then that's wrong and they should only get the first one. What is all of this group stuff anyway ? Is it more of the MDI/tabs/layers stuff ? If for whatever reason you want to open a bunch of sites then why not use a macro for this ? Just because other browsers (fat lady, burnt bird) do screwy things doesn't mean they should be mimiced by K-Meleon. Hey they aren't adding macros to their browsers and that's a good feature.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: jsnj
Date: March 27, 2003 10:28PM

If for whatever reason you want to open a bunch of sites then why not use a macro for this?

That's what I do now, and I only have a couple group bookmarks(via macros), so it's not a biggie for me, but it would be much easier to have a simple one step approach to bookmarking groups instead of having to go into the macros file and write them out every time. I guess that's what the session macro does right now, but it appears you need a whole new sessions menu to see the sessions that are bookmarked instead of being able to see them uniformly within the bookmarks menu which I think is where they should be listed since they are actually "bookmarks". Same is true for using macros for groups. I'm able to list the macros at the top of the bookmarks drop down menu listing, but there's no way that I know of to put them within folders for better organization as is possible with the other aforementioned browsers.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 28, 2003 08:29PM

MonkeeSage and jsnj,

I thought of a way to implement custom keywords but a few points:

- Selecting a bookmark with %s normally (menu or bookmark editor) will actually open the URL verbatim, with the %s included (I assume this is what Mozilla will do as well). This seems like a flaw in the custom keywords scheme.

- It will only work with Netscape/Mozilla bookmarks since Opera has no such substitution scheme to my knowledge and IE doesn't have any sort of nicknames to being with.

- Is it really worthwhile to add this especially considering K-Meleon has macros ?

What do you think ? Also MonkeeSage could you check out my posting regarding middle button scrolling.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: MonkeeSage
Date: March 28, 2003 10:46PM

asmpgmr:

I prolly wouldn't use it that much, but others might. I don't mind trying it. smiling smiley


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 28, 2003 11:36PM

What does Mozilla do if you select a bookmark with %s in it ? Does it open the URL with the %s intact or is the %s removed ?

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: jsnj
Date: March 29, 2003 12:01AM

Well it's definitely easier to manage and implement the quicksearch feature with the '%s' method(being able to add & manage the searches through the Edit Bookmarks prompt) rather than the somewhat complicated macros way. Also, I'm assuming it would take care of two features in one, bookmark keywords, and quicksearch. I don't know how much bloat is involved if any. That would be the only consideration in not doing it in my opinion.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: jsnj
Date: March 29, 2003 12:06AM

What does Mozilla do if you select a bookmark with %s in it ? Does it open the URL with the %s intact or is the %s removed ?

It opens with it intact. Actually it depends on the search. Yahoo searches for s. Dictionary.com tries to define %s.

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 29, 2003 12:19AM

jsnj,

What I don't like about keeping the %s intact is that the bookmark becomes useless as a normal bookmark which is kind of crappy. I'm not sure what you mean by quicksearch but what Mozilla does is this - if you have a shortcut gs for http://www.google.com/search?q=%s then entering gs k-meleon becomes http://www.google.com/search?q=k-meleon

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: jsnj
Date: March 29, 2003 12:42AM

Yeah, IE 5.5 had a plugin/patch that used the same thing(%s) and they called it Quicksearch and I believe Mozilla used to refer to it as Quicksearch at one time.

What I don't like about keeping the %s intact is that the bookmark becomes useless as a normal bookmark which is kind of crappy.

Yeah, but It's still easier and more user-friendly to manage than the macros way. But, I know that the argument that something is more user-friendly does not hold much weight with you. :-)

Options: ReplyQuote
Re: Bookmark keywords lookup
Posted by: asmpgmr
Date: March 29, 2003 12:54AM

jsnj,

The code itself isn't too complex, mainly a bunch a string functions. I don't like the fact %s precludes a bookmark from being used normally. Most search sites will bring up a default search page and other sites which use parameters will use a default value if nothing is specified (generally this will be a trailing =). I would be inclined to strip the %s if not accessed via a shortcut but I'm not sure what the devs would think of this since it doesn't match Mozilla (personally I don't care). In fact I'm not sure what they think of any of my code updates, all I know is that they haven't committed a single one to CVS as of yet.

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


K-Meleon forum is powered by Phorum.