Author Topic: Plugin Settings Icons  (Read 13042 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2165
Plugin Settings Icons
« on: July 02, 2007, 01:45:39 pm »
Quote
4203     /     mandrav     0 minutes     * Binary .cbplugin files can now contain icons for the "Settings" dialogs. The two supported icon files should be named <plugin_name>.png and <plugin_name>-off.png.
* Updated all settings dialogs to locate icons through configmanager.
* If a settings icon for a plugin cannot be located, the generic-plugin icon will be used.

Beautiful!

thank you

Should the <plugin>.png's be loose in the .cbplugin file or zipped together in the <plugin>.zip along with the <plugin>.manifest.
« Last Edit: July 02, 2007, 01:54:13 pm by Pecan »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Plugin Settings Icons
« Reply #1 on: July 02, 2007, 02:09:40 pm »
Sample plugin (named TestPlugin) contents:


TestPlugin.cbplugin:
    TestPlugin.dll  <-- the plugin
    TestPlugin.zip  <-- its resources
    TestPlugin.png  <-- the highlighted settings icon
    TestPlugin-off.png  <-- the non-highlighted settings icon


These are the "easy" stuff to support, since they share a common base name (the plugin's name). To add support for, e.g. toolbar images, will take a little longer...

EDIT: for those wondering, the problem is not how to define additional files to be installed but rather how to know what files each plugin needs when exporting (saving).
« Last Edit: July 02, 2007, 02:39:23 pm by mandrav »
Be patient!
This bug will be fixed soon...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Plugin Settings Icons
« Reply #2 on: July 02, 2007, 03:49:40 pm »
OK, done with it.
Now binary plugins (.cbplugin) can also contain extra files to be installed/uninstalled/exported. Just define them inside the plugin's manifest XML.
E.g.:


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_plugin_manifest_file>
    <SdkVersion major="1" minor="10" release="0" />
    <Plugin name="Autosave">
        <Value title="Autosave" />
        <Value version="0.1" />
        <Value description="Saves your work in regular intervals" />
        <Value author="Thomas Denk" />
        <Value authorEmail="" />
        <Value authorWebsite="http://www.codeblocks.org" />
        <Value thanksTo="" />
        <Value license="GPL" />
    </Plugin>
   
    <Extra file="images/16x16/bookmark_add.png" />
    <Extra file="images/16x16/editcopy.png" />

</CodeBlocks_plugin_manifest_file>



Just make sure you define only your plugin's extra files as there is no check if they're needed by other plugins when deleting them...
Be patient!
This bug will be fixed soon...

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin Settings Icons
« Reply #3 on: July 02, 2007, 03:54:05 pm »
until now, I've been keeping bitmaps in <Plugin-name>.zip
so long as they have an XRC associated with them, they are easy to load and manage.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Plugin Settings Icons
« Reply #4 on: July 02, 2007, 06:48:27 pm »
until now, I've been keeping bitmaps in <Plugin-name>.zip
so long as they have an XRC associated with them, they are easy to load and manage.

Yes, most plugins are like that.
Be patient!
This bug will be fixed soon...

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin Settings Icons
« Reply #5 on: July 02, 2007, 08:50:14 pm »
well my only concern is that plugin writers will use <extra file> to unnecessarily pollute the shared folders because of the effort required to understand XRC.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Plugin Settings Icons
« Reply #6 on: July 02, 2007, 08:59:12 pm »
well my only concern is that plugin writers will use <extra file> to unnecessarily pollute the shared folders because of the effort required to understand XRC.

Do you have any hints for people to understand XRC?
Be patient!
This bug will be fixed soon...

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin Settings Icons
« Reply #7 on: July 02, 2007, 09:16:07 pm »
sure (i walked into this one didn't I  :lol: ). I'll put a page up on the wiki...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Plugin Settings Icons
« Reply #8 on: July 02, 2007, 09:22:07 pm »
sure (i walked into this one didn't I  :lol: ). I'll put a page up on the wiki...

That'd be perfect, thanks :)
Be patient!
This bug will be fixed soon...

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin Settings Icons
« Reply #9 on: July 05, 2007, 02:50:31 pm »
I've made a start: http://wiki.codeblocks.org/index.php?title=Managing_Plug-in_Resources
(it will probably take a couple of weeks to complete because I have other pressing demands on my time :) )

Anyone reading this should feel free to contribute - I'm certain there are many mistakes

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Plugin Settings Icons
« Reply #10 on: July 05, 2007, 03:07:10 pm »
I've made a start: http://wiki.codeblocks.org/index.php?title=Managing_Plug-in_Resources
(it will probably take a couple of weeks to complete because I have other pressing demands on my time :) )

Anyone reading this should feel free to contribute - I'm certain there are many mistakes

Thanks :)
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5177
Re: Plugin Settings Icons
« Reply #11 on: July 05, 2007, 04:48:07 pm »
we once made the suggestion in a sticky post, to use CamelCase, could you adopt your wiki page to use that too please.

MyPlugIn ;-)

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Plugin Settings Icons
« Reply #12 on: July 06, 2007, 12:48:07 am »
Hi !

After many tests, I don't succeed in installing my plugin pngs  :oops:

My manifest.xml
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_plugin_manifest_file>
    <SdkVersion major="1" minor="11"  release="10" />
    <Plugin name="ThreadSearch">
        <Value title="ThreadSearch" />
        <Value version="0.7" />
        <Value description="Multi-threaded 'Search in files' with preview window." />
        <Value author="Jerome ANTOINE" />
        <Value authorEmail="" />
        <Value authorWebsite="" />
        <Value thanksTo="wxWidgets team
Code::Blocks team
wxGlade team" />
        <Value license="GPL" />
    </Plugin>

    <Extra file="images/findf.png" />
    <Extra file="images/findfdisabled.png" />
    <Extra file="images/options.png" />
    <Extra file="images/optionsdisabled.png" />
    <Extra file="images/stop.png" />
    <Extra file="images/stopdisabled.png" />
</CodeBlocks_plugin_manifest_file>

My structure :
ThreadSearch.cbplugin
   findf.png
   findfdisabled.png
   options.png
   optionsdisabled.png
   stop.png
   stopdisabled.png
   ThreadSearch.dll
   ThreadSearch.png
   ThreadSearch-off.png
   ThreadSearch.zip
      manifest.xml

I also tried to put pngs (all except ThreadSearch.png and ThreadSearch-off.png) in ThreadSearch.zip but only settings pngs are copied.

Is there anything wrong ?

XP SP2, SVN 4229.

Dje

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin Settings Icons
« Reply #13 on: July 06, 2007, 01:10:34 am »
show your image loading code...

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Plugin Settings Icons
« Reply #14 on: July 06, 2007, 01:28:58 am »
In fact, I just checked the tree.
extra pngs are not copied at the right (expected) place.

i first tried to copy them with
Code: [Select]
<Extra file="images/ThreadSearch/findf.png" />As it didn't work, I tried with
Code: [Select]
<Extra file="images/findf.png" />I also tried with
Code: [Select]
<Extra file="images\ThreadSearch\findf.png" />
Shouldn't they be copied at install whatever my code is ?

It is
Code: [Select]
wxString prefix = ConfigManager::GetDataFolder() + _T("/images/ThreadSearch/");
...
pBtnSearch->SetBitmapDisabled(wxBitmap(prefix + wxT("findfdisabled.png"), wxBITMAP_TYPE_PNG));
@dmoore You already saw it isn't it ?

Dje

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin Settings Icons
« Reply #15 on: July 06, 2007, 01:38:49 am »
i haven't checked the sdk code, but perhaps you need to match the directory structure inside your zip file (e.g. put your images in image/ThreadSearch in the .cbplugin zip). otherwise, bug in the sdk?

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Plugin Settings Icons
« Reply #16 on: July 07, 2007, 12:38:34 am »
Hi all !

So, there were 2 errors.

The first:
my cbplugin did not contain path info, in my case images\ThreadSearch\

The second:
there is a bug.
Sorry for not submitting a patch but I'm not at home and pc A is my dev pc and pc B has internet...

in PluginManager::ExtractFile, the expression:
Code: [Select]
wxFileName(dst_filename).GetPath(wxPATH_GET_SEPARATOR)returns on my PC \Dev\codeblocks\src\devel\share\codeblocks\images\ThreadSearch\
The problem is that the volume is missing in the string.

CreateDirRecursively fails at line 399 in globals.cpp because currdir value is :\Dev due to missing volume.

I hope it helps and it is clear enough to be useful.
I'll submit a bug and a patch when I'm back at home if problem is not solved.

My conf:
WinXP SP2, dev SVN 0 on my built C::B ??
It is recent (less than one week).

Dje


Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Plugin Settings Icons
« Reply #17 on: July 07, 2007, 10:43:57 pm »
Hi !

Problem :
during plugin install, directories are not created on windows.

Solution:
Still not at home so I give the line instead of the patch:
Replace line 629 in pluginmanager.cpp in bool PluginManager::ExtractFile(...)
Code: [Select]
    CreateDirRecursively(wxFileName(dst_filename).GetPath(wxPATH_GET_SEPARATOR));by
Code: [Select]
    CreateDirRecursively(wxFileName(dst_filename).GetPath(wxPATH_GET_SEPARATOR|wxPATH_GET_VOLUME));
That works on windows and was not tested on other OSs.

Dje

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Plugin Settings Icons
« Reply #18 on: July 08, 2007, 10:11:28 am »
Quote
That works on windows and was not tested on other OSs.

Done, thanks Dje.
Be patient!
This bug will be fixed soon...

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Plugin Settings Icons
« Reply #19 on: July 19, 2007, 10:31:43 am »
Hi all !

I found a bug related to this topic.
It concerns extra icons relative path during plugin export.

In my SVN environment, my plugin extra icons are located in :
C:\Dev\codeblocks\src\devel\share\codeblocks\images\ThreadSearch

I export ThreadSearch plugin in
C:\Dev\codeblocks\src\plugins\contrib\ThreadSearchBin\Win

The .cbplugin contains all files, but if I unzip it, extra icons are extracted in
D:\tmp\ThreadSearch-0.8\Dev\codeblocks\src\devel\share\codeblocks\images\ThreadSearch
instead of
D:\tmp\ThreadSearch-0.8\images\ThreadSearch

I'll put it on BerliOS this evening.

Dje

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: Plugin Settings Icons
« Reply #20 on: July 19, 2007, 01:10:06 pm »
Quote
That works on windows and was not tested on other OSs.
Done, thanks Dje.
Please notice: This kind of issue we had several times recently. A quick search revealed even more candidates for this kind of bug (e.g. codecompletion.cpp). We should really carefully use the GetPath() method.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Plugin Settings Icons
« Reply #21 on: July 19, 2007, 11:37:59 pm »
Hi all !

I found a bug related to this topic.
It concerns extra icons relative path during plugin export.

In my SVN environment, my plugin extra icons are located in :
C:\Dev\codeblocks\src\devel\share\codeblocks\images\ThreadSearch

I export ThreadSearch plugin in
C:\Dev\codeblocks\src\plugins\contrib\ThreadSearchBin\Win

The .cbplugin contains all files, but if I unzip it, extra icons are extracted in
D:\tmp\ThreadSearch-0.8\Dev\codeblocks\src\devel\share\codeblocks\images\ThreadSearch
instead of
D:\tmp\ThreadSearch-0.8\images\ThreadSearch

I'll put it on BerliOS this evening.

Dje


Done : Bug #11585

Dje

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Plugin Settings Icons
« Reply #22 on: July 30, 2007, 05:49:58 pm »
OK. I have a fix. This should solve the issue. :)

Code: [Select]
Index: src/sdk/pluginmanager.cpp
===================================================================
--- src/sdk/pluginmanager.cpp (revision 4337)
+++ src/sdk/pluginmanager.cpp (working copy)
@@ -335,8 +335,9 @@
  ReadExtraFilesFromManifestFile(localName, extraFiles);
  for (size_t i = 0; i < extraFiles.GetCount(); ++i)
  {
+ wxFileName extraFileName(extraFiles[i]);
  ExtractFile(actualName,
- extraFiles[i],
+ extraFileName.GetFullName(),
  resourceDir + _T("/") + extraFiles[i],
  false);
  }
@@ -592,13 +593,9 @@
 
         wxFileInputStream in(extrafiles[i]);
 
-        wxString f = extrafiles[i];
-        if (f.StartsWith(ConfigManager::GetFolder(sdDataUser)))
- f.Remove(0, ConfigManager::GetFolder(sdDataUser).Length());
-        else if (f.StartsWith(ConfigManager::GetFolder(sdDataGlobal)))
- f.Remove(0, ConfigManager::GetFolder(sdDataGlobal).Length());
+        wxFileName extraFileName(extrafiles[i]);
 
-        zip.PutNextEntry(f);
+        zip.PutNextEntry(extraFileName.GetFullName());
         zip << in;
     }
     zip.SetComment(_T("This is a redistributable plugin for the Code::Blocks IDE.\n"

You have to keep all the icon files (extra) in the root of zip file just as you do with the setting icons. But in the manifest.xml file, you should provide the relative output dir.

I'm not sure if this method is correct or not and I've to get it confirmed from Yiannis before I put it in repo. :)

Best Regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Plugin Settings Icons
« Reply #23 on: August 13, 2007, 10:32:54 pm »
Hi Biplab !

It seems the correction does not work...

manifest.xml:
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_plugin_manifest_file>
    <SdkVersion major="1" minor="11"  release="10" />
    <Plugin name="ThreadSearch">
        <Value title="ThreadSearch" />
        <Value version="0.8beta" />
        <Value description="Multi-threaded 'Search in files' with preview window." />
        <Value author="Jerome ANTOINE" />
        <Value authorEmail="" />
        <Value authorWebsite="" />
        <Value thanksTo="wxWidgets team
Code::Blocks team
wxGlade team" />
        <Value license="GPL" />
    </Plugin>
    <Extra file="images/ThreadSearch/findf.png" />
    <Extra file="images/ThreadSearch/findfdisabled.png" />
    <Extra file="images/ThreadSearch/options.png" />
    <Extra file="images/ThreadSearch/optionsdisabled.png" />
    <Extra file="images/ThreadSearch/stop.png" />
    <Extra file="images/ThreadSearch/stopdisabled.png" />
</CodeBlocks_plugin_manifest_file>

zip content, see picture

After plugin install, the directory is created but is empty.

Sorry for late feedback...

Dje


[attachment deleted by admin]

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Plugin Settings Icons
« Reply #24 on: August 27, 2007, 07:04:13 am »
Hi dje,

Sorry for not updating this thread. Actually after a discussion with Yiannis, I committed a different patch. The only difference is that the extra files Source and Destination path will be used from the manifest file.

E.g., if a file is specified as <Extra file="images/ThreadSearch/findf.png" />
1) While installing this file from Zip file, C::B will search at images/ThreadSearch/findf.png folder inside zip file.
2) While exporting as a Zip C::B will again read the path from manifest file.

So your folder structure in zip file should look like-

Quote
|- plugin.dll
|- plugin.manifest
|- images
    |- ThreadSearch
         |- findf.png

Try this one and post your feedback. :)

Best Regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Plugin Settings Icons
« Reply #25 on: August 29, 2007, 01:09:12 am »
Hi all !

@Biplab
OK for me, it works  :D !

Dje