Author Topic: ThreadSearch 0.7 release  (Read 31964 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #15 on: June 29, 2007, 07:37:16 pm »
Is there a way to get rid of that little window on the left?

It's too small for me (old eyes), and it just gets in the way of my reading the search results.


Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch 0.7 release
« Reply #16 on: June 29, 2007, 07:49:42 pm »
Is there a way to get rid of that little window on the left?

Not for now. The minimum width is 25px.
I put it on my to-do list, if I can hide widgets and directories items, I should succeed in hiding editor !  :D

Dje

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #17 on: June 29, 2007, 09:52:42 pm »
hmm...  it would be possible to specify a sequence of wxBitMaps in an XRC file as follows:

Code: [Select]
<resource>
    <object class="wxBitmap" name="img1">images/image1.png</object>
    <object class="wxBitmap" name="img2">images/image2.png</object> 
etc...
</resource>

zip the XRC in with the images and manifest (using the relative paths for the images as in the xrc). Then after you call

Code: [Select]
Manager::LoadResource(_T("myplugin.zip");

you can access your images with

Code: [Select]
    wxBitmap bmp;
    // typedef
    bmp = wxXmlResource::Get()->LoadBitmap(_T("img1"));

After three hours of trying. I think I'll give this one up.
It doesn't complain, but it doesn't load the images either.

ThreadImages.xrc
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<resource>
    <object class="wxBitmap" name="findf"><bitmap>findf.png</bitmap></object>
    <object class="wxBitmap" name="findfdisabled"><bitmap>findfdisabled.png</bitmap></object>
    <object class="wxBitmap" name="options"><bitmap>options.png</bitmap></object>
    <object class="wxBitmap" name="optionsdisabled"><bitmap>optionsdisabled.png</bitmap></object>
    <object class="wxBitmap" name="stop"><bitmap>stop.png</bitmap></object>
    <object class="wxBitmap" name="stopdisabled"><bitmap>stopdisabled.png</bitmap></object>
    <object class="wxBitmap" name="ThreadSearch"><bitmap>ThreadSearch.png</bitmap></object>
    <object class="wxBitmap" name="ThreadSearchoff"><bitmap>ThreadSearch-off.png</bitmap></object>
</resource>

Files in ThreadSearch.zip
Code: [Select]
findf.png
findfdisabled.png
manifest.xml
options.png
optionsdisabled.png
stop.png
stopdisabled.png
ThreadImages.xrc
ThreadSearch.png
ThreadSearch-off.png
Code: [Select]
    if (!Manager::LoadResource(_T("ThreadSearch.zip")))
    {
        NotifyMissingFile(_T("ThreadSearch.zip"));
    }

......
    wxBitmap bmp = wxXmlResource::Get()->LoadBitmap(_T("findf"));
wxBitmapButton* pBtnSearch = new wxBitmapButton(toolBar, idBtnSearch, bmp);


It just seems to do nothing. Even when I change the name of the .png to one that doesn't exist, it doesn't even error out.

It always just shows the button without the bitmap.
« Last Edit: June 29, 2007, 09:55:46 pm by Pecan »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: ThreadSearch 0.7 release
« Reply #18 on: June 29, 2007, 10:18:34 pm »
Pecan: strange that it doesn't work... I assume you tried without enclosing the filename in <bitmap></bitmap>

EDIT: seems to be working fine for me when I exclude the <bitmap> tokens
« Last Edit: June 29, 2007, 10:26:56 pm by dmoore »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #19 on: June 29, 2007, 10:32:45 pm »
Edit: I seem to have it working now. But I have no idea how I did it; or what was wrong before.


Pecan: strange that it doesn't work... I assume you tried without enclosing the filename in <bitmap></bitmap>

EDIT: seems to be working fine for me when I exclude the <bitmap> tokens

Nope. Can't get it to work with or without the <bitmap></bitmap> tokens.

What system are you on. I'm on XpSp2 wx284


If you have it working, could you give us a patch?
« Last Edit: June 29, 2007, 10:57:16 pm by Pecan »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: ThreadSearch 0.7 release
« Reply #20 on: June 29, 2007, 10:57:03 pm »
running same as you. full source attached



[attachment deleted by admin]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: ThreadSearch 0.7 release
« Reply #21 on: June 29, 2007, 10:58:48 pm »
dje: this really is a nicely done plugin. any thoughts on allowing user to have the threadsearchview in a dockable instead of the messages window? (no reason not to allow the user to choose)

and... when do we get replace in files?  :lol:
« Last Edit: June 29, 2007, 11:02:26 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: ThreadSearch 0.7 release
« Reply #22 on: June 29, 2007, 11:07:31 pm »
one thing to be careful of is polluting the xrc namespace. because the names are shared application wide it probably makes sense to preface all names with an abbreviated version of the plugin name. so "findf" would be "threadsearch_findf" (or tsrch_findf)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #23 on: June 29, 2007, 11:09:10 pm »
Here's an interesting bug in CB.

When I change the LoadResource() name to a non-existing file here's what you get:



a one-letter file name from NotifyMissingFile.
« Last Edit: June 29, 2007, 11:10:59 pm by Pecan »

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch 0.7 release
« Reply #24 on: June 30, 2007, 12:41:21 am »
dje: this really is a nicely done plugin
Thank you  :D  Nice to write it !

any thoughts on allowing user to have the threadsearchview in a dockable instead of the messages window? (no reason not to allow the user to choose)
I think it is possible, we'll just need a 25'' screen to display the configuration panel  :)

and... when do we get replace in files?  :lol:
I already thought about it but for now, it remains a thought...

So, now:
  • Morten's bug fix (crash on plugin disable).
  • windows project rework to put threadSearch plugin under SVN contrib plugins.
  • pictures management
  • External requests management
  • possibility to hide preview editor
  • choice between Messages notebook tab and dockable window

You will have noticed it is not a numbered list, it is a random list  :)

I keep in mind the replace idea but I don't put it in the to do list before thinking about it a little more...


Dje
« Last Edit: June 30, 2007, 12:46:53 am by dje »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #25 on: June 30, 2007, 01:02:09 am »
I notice when I try to paste a search string into the search window, it pastes it into the editor instead.

What's that all about?

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #26 on: June 30, 2007, 01:12:26 am »
Here are the diffs that allow the .zip to contain all the .png files.
Thank you dmoore

ThreadSearch.cpp
Code: [Select]
c:\Usr\Proj\ThreadSearch>C:\Usr\bin\GnuWin32\bin\diff.exe -u --strip-trailing-cr E:\User\Downloads\_Pending\cbPlugins\temp\ThreadSearch\ThreadSearch.cpp ThreadSearch.cpp     
--- E:\User\Downloads\_Pending\cbPlugins\temp\ThreadSearch\ThreadSearch.cpp 2007-06-28 21:12:28.000000000 -0500
+++ ThreadSearch.cpp 2007-06-29 18:08:03.953125000 -0500
@@ -250,8 +250,7 @@
  {
  // set log image
  wxBitmap bmp;
- wxString prefix = ConfigManager::GetDataFolder() + _T("/images/16x16/");
- bmp = cbLoadBitmap(prefix + _T("filefind.png"), wxBITMAP_TYPE_PNG);
+        bmp = wxXmlResource::Get()->LoadBitmap(_T("findf"));
 
  m_ThreadSearchId = pMsgMan->AddLog(m_pThreadSearchView, _T("Thread search"), bmp);
  }
@@ -501,13 +500,12 @@
  m_pToolbar = toolBar;
  m_pThreadSearchView->SetToolBar(toolBar);
 
- wxString prefix = ConfigManager::GetDataFolder() + _T("/images/16x16/");
  wxComboBox*     pCboSearchExpr = new wxComboBox    (toolBar, idCboSearchExpr, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN);
- wxBitmapButton* pBtnSearch     = new wxBitmapButton(toolBar, idBtnSearch, wxBitmap(prefix + wxT("findf.png"), wxBITMAP_TYPE_PNG));
- wxBitmapButton* pBtnOptions    = new wxBitmapButton(toolBar, idBtnOptions, wxBitmap(prefix + wxT("options.png"), wxBITMAP_TYPE_PNG));
+ wxBitmapButton* pBtnSearch     = new wxBitmapButton(toolBar, idBtnSearch, wxXmlResource::Get()->LoadBitmap(_T("findf")));
+ wxBitmapButton* pBtnOptions    = new wxBitmapButton(toolBar, idBtnOptions, wxXmlResource::Get()->LoadBitmap(_T("options")));
 
- pBtnSearch->SetBitmapDisabled(wxBitmap(prefix + wxT("findfdisabled.png"), wxBITMAP_TYPE_PNG));
- pBtnOptions->SetBitmapDisabled(wxBitmap(prefix + wxT("optionsdisabled.png"), wxBITMAP_TYPE_PNG));
+ pBtnSearch->SetBitmapDisabled(wxXmlResource::Get()->LoadBitmap(_T("findfdisabled")));
+ pBtnOptions->SetBitmapDisabled(wxXmlResource::Get()->LoadBitmap(_T("optionsdisabled")));
 
  toolBar->AddControl(pCboSearchExpr);
  toolBar->AddControl(pBtnSearch);


ThreadSearchView.cpp
Code: [Select]
c:\Usr\Proj\ThreadSearch>C:\Usr\bin\GnuWin32\bin\diff.exe -u --strip-trailing-cr E:\User\Downloads\_Pending\cbPlugins\temp\ThreadSearch\ThreadSearchView.cpp ThreadSearchView.cpp     
--- E:\User\Downloads\_Pending\cbPlugins\temp\ThreadSearch\ThreadSearchView.cpp 2007-06-28 21:46:04.000000000 -0500
+++ ThreadSearchView.cpp 2007-06-29 18:47:14.171875000 -0500
@@ -8,6 +8,8 @@
  * License:   GPL
  **************************************************************/
 
+#include <wx/xrc/xmlres.h>
+
 #include "messagemanager.h"
 #include "configmanager.h"
 #include "configurationpanel.h"
@@ -924,13 +926,13 @@
 
  wxString prefix = ConfigManager::GetDataFolder() + _T("/images/16x16/");
 
- wxString searchButtonPathsEnabled[]  = {prefix + wxT("findf.png"),
- prefix + wxT("stop.png") ,
- wxEmptyString};
-
- wxString searchButtonPathsDisabled[] = {prefix + wxT("findfdisabled.png"),
- prefix + wxT("stopdisabled.png") ,
- wxEmptyString};
+ wxString searchButtonPathsEnabled[]  = {wxT("findf"),
+ wxT("stop") ,
+ wxEmptyString};
+
+ wxString searchButtonPathsDisabled[] = {wxT("findfdisabled"),
+ wxT("stopdisabled") ,
+ wxEmptyString};
 
  // Gets toolbar search button pointer
  wxBitmapButton* pToolBarSearchBtn = static_cast<wxBitmapButton*>(m_pToolBar->FindControl(idBtnSearch));
@@ -939,8 +941,8 @@
  if ( label != skip )
  {
  m_pBtnSearch->SetLabel(searchButtonLabels[label]);
- pToolBarSearchBtn->SetBitmapLabel   (wxBitmap(searchButtonPathsEnabled [label], wxBITMAP_TYPE_PNG));
- pToolBarSearchBtn->SetBitmapDisabled(wxBitmap(searchButtonPathsDisabled[label], wxBITMAP_TYPE_PNG));
+ pToolBarSearchBtn->SetBitmapLabel   (wxXmlResource::Get()->LoadBitmap(searchButtonPathsEnabled [label]));
+ pToolBarSearchBtn->SetBitmapDisabled(wxXmlResource::Get()->LoadBitmap(searchButtonPathsDisabled [label]));
  }
 
  // Sets enable state


ThreadImages.xrc to be put in ThreadSearch.zip
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<resource>
    <object class="wxBitmap" name="findf">findf.png</object>
    <object class="wxBitmap" name="findfdisabled">findfdisabled.png</object>
    <object class="wxBitmap" name="options">options.png</object>
    <object class="wxBitmap" name="optionsdisabled">optionsdisabled.png</object>
    <object class="wxBitmap" name="stop">stop.png</object>
    <object class="wxBitmap" name="stopdisabled">stopdisabled.png</object>
    <object class="wxBitmap" name="ThreadSearch">ThreadSearch.png</object>
    <object class="wxBitmap" name="ThreadSearchoff">ThreadSearch-off.png</object>
</resource>


Contents of ThreadSearch.zip
Code: [Select]
findf.png
findfdisabled.png
options.png
optionsdisabled.png
stop.png
stopdisabled.png
ThreadSearch.png
ThreadSearch-off.png
manifest.xml
ThreadImages.xrc

Post Build Step
Code: [Select]
zip -j9 .\ThreadSearch.zip manifest.xml *.png ThreadImages.xrc
zip -j9 ThreadSearch.cbplugin .\bin\debug\ThreadSearch.dll .\ThreadSearch.zip

« Last Edit: June 30, 2007, 01:17:41 am by Pecan »

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch 0.7 release
« Reply #27 on: June 30, 2007, 03:34:42 pm »
Hi all !

So, now:
  • Morten's bug fix (crash on plugin disable).

The naughty bug is FIXED  :D :D :D :D :D

I had misunderstood a part of plugins management.
I tought that disable = uninstall without removing dll/zip but in fact, a plugin instance exists even it plugin is disabled.

The following OnRelease method solves the problem on XP. It see no reason why it could be different on Linux but it is not tested yet.

Code: [Select]
void ThreadSearch::OnRelease(bool appShutDown)
{
// do de-initialization for your plugin
// if appShutDown is false, the plugin is unloaded because Code::Blocks is being shut down,
// which means you must not use any of the SDK Managers
// NOTE: after this function, the inherited member variable
// m_IsAttached will be FALSE...

// Removes Thread search menu item from the View menu
RemoveMenuItems();

m_pToolbar = NULL;

// Saves configuration to default.conf
SaveConfig(m_ThreadSearchId != -1);

wxASSERT(m_pThreadSearchView != NULL);
if ( m_ThreadSearchId != -1 )
{
// As id is != from -1, ThreadSearchView is managed by MessageManager
// We remove it from the notebook
MessageManager* pMsgMan = Manager::Get()->GetMessageManager();
wxASSERT(pMsgMan != NULL);
pMsgMan->RemoveLog(m_pThreadSearchView);
m_ThreadSearchId = -1;
}

m_pThreadSearchView->Destroy();
m_pThreadSearchView = NULL;
}

Thanks to Pecan and Dmoore for pngs embedding code, i'll have a look at it.

I confirm the paste bug. The same happens with copy from the preview editor.
It does not work anymore with keyboard shortcuts but works with contextual menus.

EDIT: Paste works with default target (nightly build environment) but not with DevDebug target (debug development environment).
EDIT: Copy from preview editor does not works (whereas it did).

This is a regression but I don't see at first glance where it comes from.

Dje
« Last Edit: June 30, 2007, 04:28:26 pm by dje »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #28 on: June 30, 2007, 04:13:20 pm »
I notice when I try to paste a search string into the search window, it pastes it into the editor instead.

What's that all about?


Found it. CodeBlocks main.cpp UpdateUI is enabling Edit/Paste for the editors only.
So when you paste into the search combo box, it ends up in the editor.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #29 on: June 30, 2007, 05:34:18 pm »


I confirm the paste bug. The same happens with copy from the preview editor.
It does not work anymore with keyboard shortcuts but works with contextual menus.

EDIT: Paste works with default target (nightly build environment) but not with DevDebug target (debug development environment).
EDIT: Copy from preview editor does not works (whereas it did).

This is a regression but I don't see at first glance where it comes from.

I've found the cause of the copy/paste bug. And am working up a fix for it now.

It's a bug in the way CB main.cpp handles the clipboard/copy/paste events. It always thinks the paste is for the current editor even when the editor DOES NOT have the focus.

Edit: I've tested the work-around and will paste a diff.
« Last Edit: June 30, 2007, 11:25:32 pm by Pecan »