Content of the material
- Where are GIMP Plugins found?
- Video
- 17.8.13 View Plug-in Utilization
- 16. Exercise – Adapters for the Properties view
- 12. Optional Exercise: Add icon to your toolbar entry
- How secure are plug-ins?
- Sign the plug-in
- 17.8.5 Adding Custom Attributes to a Plug-in
- What is an add-on and what does it do?
- How to Use GIMP Plugins
- Gimp Plugins FAQs
- Conclusion:
- Next steps
Where are GIMP Plugins found?
Scripts Folder in Mac File Manager
GIMP plugins don’t have a single repository online, so Google will be your friend if you need to go searching. Software developers upload their own projects and try to keep them functional, but some become out of date and even disappear completely.
As for where GIMP Plugins are found on your computer:
Mac
System-wide script-fu scripts are stored in /Applications/GIMP.app/Contents/Resources/share/gimp/2.0/scripts/. Executable and python plugins are located in /Applications/GIMP.app/Contents/Resources/lib/gimp/2.0/plug-ins/
User-private plugins are stored under $HOME/Library/Application Support/GIMP/2.8/plug-ins/.
Windows
Go to the folder GIMP is installed in (usually somewhere in Program Files). Once in the GIMP main folder navigate to lib\gimp\*version*\ where as *version* represents the version of Gimp. Then double click the “plug-ins” folder.
Linux
Look for a hidden folder: $HOME/.gimp-*.* (where you should replace $HOME with path to your home catalogue and gimp-*.* with the version you use.
Video
17.8.13 View Plug-in Utilization
The Plug-in Utilization page displays which pages, components, and regions use each plug-in.
To view plug-in utilization:
-
Navigate to the Plug-ins page. See “Accessing Plug-ins”.
-
Click Utilization.
The Utilization page appears.
16. Exercise – Adapters for the Properties view
We will simply use an adapter to show our data in the Properties view.
Create a new plug-in project de.vogella.plugin.adapter.
Add the following dependencies in the dependencies tab of the MANIFEST.MF file:
-
ntime
-
org.eclipse.e4.ui.model.workbench
-
org.eclipse.e4.ui.services
-
org.eclipse.e4.ui.workbench
-
org.eclipse.ui
-
org.eclipse.ui.views
Create the following Todo
class as data model.
package de.vogella.plugin.adapter.model; public class Todo { private String summary; private String description; private boolean done; public String getSummary() { return summary; } public void setSummary(String summary) { this.summary = summary; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public boolean isDone() { return done; } public void setDone(boolean done) { this.done = done; } }
Create a model fragment (fragment.e4xmi) and add a PartDescriptor called Sample View.
Create SampleView.java as part for the PartDescriptor implementation.
package de.vogella.plugin.adapter.views; import java.util.ArrayList; import java.util.List; import javax.annotation.PostConstruct; import org.eclipse.e4.ui.workbench.modeling.ESelectionService; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import de.vogella.plugin.adapter.model.Todo; public class SampleView { private TableViewer viewer; class ViewLabelProvider extends LabelProvider implements ITableLabelProvider { public String getColumnText(Object obj, int index) { Todo todo = (Todo) obj; return todo.getSummary(); } public Image getColumnImage(Object obj, int index) { return getImage(obj); } public Image getImage(Object obj) { return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT); } } /** * This is a callback that will allow us to create the viewer and initialize * it. */ @PostConstruct public void createPartControl(Composite parent, ESelectionService selectionService) { viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { selectionService.setSelection(event.getSelection()); } }); viewer.setInput(getElements()); } // Build up a simple data model private List<Todo> getElements() { List<Todo> todos = new ArrayList<>(); Todo todo = new Todo(); todo.setSummary(“First Todo”); todo.setDescription(“A very good description”); todo.setDone(true); todos.add(todo); todo = new Todo(); todo.setSummary(“Second Todo”); todo.setDescription(“Second super description”); todos.add(todo); return todos; } }
After this change, you should be able to run your project, open your view and see your to-do items.
To display the Todo
values in the Properties view, add the extension point ntime.adapters to your project.
The data of the extension point should be like the following:
<extension point=“ntime.adapters”> <factory adaptableType=“de.vogella.plugin.adapter.model.Todo” class=“de.vogella.plugin.adapter.TodoAdapterFactory”> <adapter type=“perties.IPropertySource”> </adapter> </factory> </extension>
Implement the IPropertySource
interface to provide it for the Properties view.
package de.vogella.plugin.adapter; import perties.IPropertyDescriptor; import perties.IPropertySource; import perties.TextPropertyDescriptor; import de.vogella.plugin.adapter.model.Todo; public class TodoPropertySource implements IPropertySource { private final Todo todo; public TodoPropertySource(Todo todo) { this.todo = todo; } @Override public boolean isPropertySet(Object id) { return false; } @Override public Object getEditableValue() { return this; } @Override public IPropertyDescriptor[] getPropertyDescriptors() { return new IPropertyDescriptor[] { new TextPropertyDescriptor(“summary”, “Summary”), new TextPropertyDescriptor(“description”, “Description”) }; } @Override public Object getPropertyValue(Object id) { if (id.equals(“summary”)) { return todo.getSummary(); } if (id.equals(“description”)) { return todo.getDescription(); } return null; } @Override public void resetPropertyValue(Object id) { } @Override public void setPropertyValue(Object id, Object value) { String s = (String) value; if (id.equals(“summary”)) { todo.setSummary(s); } if (id.equals(“description”)) { todo.setDescription(s); } } }
Implement the factory and the new class TodoPropertySource
which implements IPropertySource
.
package de.vogella.plugin.adapter; import ntime.IAdapterFactory; import perties.IPropertySource; import de.vogella.plugin.adapter.model.Todo; public class TodoAdapterFactory implements IAdapterFactory { // use a static final field so that the adapterList is only instanciated once private static final Class<?>[] adapterList = new Class<?>[] { IPropertySource.class }; @Override public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (adapterType== IPropertySource.class && adaptableObject instanceof Todo){ return adapterType.cast(new TodoPropertySource((Todo) adaptableObject)); } return null; } @Override public Class<?>[] getAdapterList() { return adapterList; } }
If you run your workbench and open your view via Windows Show View Others Sample Category Sample View and you select a data element in your viewer you should see your data in the Properties view.
12. Optional Exercise: Add icon to your toolbar entry
Create an icons
folder. Use the Plug-in Image Browser to save an icon in your project.
Assign this icon to your toolbar entry.
How secure are plug-ins?
Plug-ins always present certain security risks because hackers can use these add-ons as attack gateways. In recent years, attackers have increasingly exploited plug-ins (especially browser add-ons) in order to spread malicious code and gain unauthorized access to websites. There are many reasons for this trend. One reason is plug-ins have a large user base. Popular plug-ins are often installed by millions of users. If hackers manage to exploit a security vulnerability, they can potentially reach a large number of victims. In addition, plug-ins are used in many different areas and cover a wide range of applications. This means that the security risks are not limited to a specific target group of users. Another fundamental problem: Many plug-ins (such as WordPress plug-ins) are developed by single individuals or hobbyist programmers. As a user, it’s often impossible or difficult to determine how clean the code really is and whether it has vulnerabilities that cybercriminals could exploit. Even more problematic are plug-ins that are specifically programmed to spread malware, spyware and other malicious code. That’s why it’s important to choose plug-ins carefully. Most importantly, always use plug-ins from reputable sources instead of just installing the first plug-in you come across with features that sound interesting. Ultimately, even plug-ins that are installed but not activated can pose a threat. Last but not least, always keep installed plug-ins up to date by installing the latest updates to eliminate known security vulnerabilities.
Sign the plug-in
In Solution Explorer, right click the BasicPlugin project and in the context menu select Properties.
In the project properties, select the Signing tab and select the Sign the assembly checkbox.
In the Choose a strong name key file: dropdown, select <New…>.
In the Create Strong Name Keydialog, enter a key file name and deselect the Protect my key file with a password checkbox.
Click OK to close the Create Strong Name Key dialog.
In the project properties Build tab, verify that the Configuration is set to Debug.
Press F6 to build the plug-in again.
Using windows explorer, find the built plug-in at:
\bin\Debug\BasicPlugin.dll
.
Note
Build the assembly using Debug configuration because you will use the Plug-in Profiler to debug it in a later tutorial. Before you include a plug-in with your solution, you should build it using the release configuration.
17.8.5 Adding Custom Attributes to a Plug-in
A plug-in attribute is used to prompt the developer for additional data in the Application Builder when the plug-in is used.
Tip:
During the following steps, see item help to learn more about a specific field.To add custom attributes to the plug-in:
-
Navigate to the Plug-ins page. See Accessing Plug-ins.
-
Click the plug-in you want to modify.
The Plug-in Create/Edit page appears.
-
Under Custom Attributes, enable or disable substitution of attribute values.
-
Substitute Attribute Values – Custom attribute values specified by the developer might contain items referenced with substitution syntax, for example
&P1_DNAME
.If set to Yes, Application Express automatically replaces substitution syntax with their actual values.
If set to No, substitution syntax is written unchanged into the
attribute_01
throughattribute_15
record type attributes ofp_plugin
,p_item
,p_region
, and so on. The plug-in developer is responsible for replacing those substitution syntax references with a call toapex_plugin_util.replace_substitutions
or perform similar replacements. See item help for further details.
-
-
Under Custom Attributes click Add Attribute.
The Edit Attribute page appears.
-
Under name:
-
Scope – Select Application if the attribute is only defined once for the application. Select Component if the attribute is defined each time the plug-in is referenced in a component.
-
Attribute – Enter the sequence that correlates with the
ATTRBUTE_XX
columns and to the PL/SQL types defined in theAPEX_PLUGIN
package. -
Display Sequence – Enter the display sequence for this plug-in attribute in the Application Builder.
-
Label – Enter the label that displays for this attribute in the Application Builder.
-
-
For Settings:
-
Type – Select the attribute type.
-
Required – Select Yes if this attribute must be specified. Otherwise, select No.
-
Translatable – Select Yes if this attribute is included in the translation file, otherwise, select No.
-
Display Width – Enter the length in characters displayed for this attribute in the Application Builder.
-
Maximum Width – Enter the maximum number of characters users are allowed to enter for this attribute in the Application Builder.
-
-
Under Default Value, specify a value to be used for this plug-in attribute when a new component is created that uses this plug-in. Use Y and N for attributes of type
Yes/No
. -
Under Condition:
-
Depending on – Select the attribute on which the current attribute depends.
-
Condition Type (only displays if dependent attribute) – Select the type of condition that must be met in order for this attribute to render.
-
Expression (only displays if needed for condition type)- Enter expression that must meet the selected condition type. See item help for details.
-
-
For Help Text, specify the help text that is displayed as context sensitive help for the attribute in the Application Builder.
-
Under Comments, enter comments or notes that are never displayed when the application is running.
-
Click Create to create the attribute and go back to the Edit page, or click Create and Create Another to create the attribute and continue to create another attribute.
Note:
If you click Create or Create and Create Another and the Return To Page check box on the right panel under Plug-ins is checked, this same Edit Attribute page displays.What is an add-on and what does it do?
Add-ons can hardly be kept away from today’s browsers. They expand your browser with additional features and give you the chance to customize it to your own needs. In this article, you can find out exactly what add-ons are and what you can do with them. Do you know the difference between add-ons and plug-ins? You’ll learn more about that, too, in this post.
How to Use GIMP Plugins
After you’ve installed your GIMP plugin, you may be confused about how to actually use it.
Different GIMP plugins are accessed and run in different ways. Some may show up under the Filters menu; others can be accessed by options in the Layers menu or Image menu, and others appear under a menu called Script-Fu.
Others, like FX Foundary listed above, add an entirely new menu item to the top of GIMP.
Because of this variability, finding your way around each new GIMP plugin can be a little bit of a learning and exploring process.
The good news is that, once you’ve found how to access them, many of the best GIMP plugins are easy and intuitive to use. For more complex processes or if you run into issues, try searching for the plugin’s help and support documentation online.
Gimp Plugins FAQs
What are GIMP plugins?
GIMP plugins are small, add-on pieces of software that expand the functionality of GIMP. For example, they might allow you to apply filters, adjust image quality, process raw images, etc.
How do I add plugins to GIMP?
Some plugins come as software packages that install automatically. Others require you to install them manually by moving unzipped files to a specific location. For the precise steps, see the instructions above.
Can GIMP use Photoshop plugins?
Yes – the latest version of GIMP can run a range of Photoshop plugins. You may need to check the compatibility of individual plugins, however, as not all will work 100%.
Conclusion:
And that’s about it for plug-ins. Once you’ve grasped the concept of Interfaces, and have understood the code for actually initializing instances of plug-ins, creating an actual plug-in is not a very difficult task. I will leave you to explore the rest of the code by yourself. Hopefully you have learned something from this tutorial, and can successfully implement plug-ins into your own programs!
Next steps
In this tutorial you have created a simple plug-in and registered it. Complete Tutorial: Debug a plug-in to learn how to debug this plug-in.