Need help creating a tracker add-on

I would like to create some tracker add-ons to manipulate a tagged image. For this I would use imagemagick, where I override the original with the convert command.

Since i am not a c or cpp programmer and i am very hard to learn this i would like to run already working yab script in a c program. I have already done that.

Now I would need someone who helps with making this program a tracker add-on. Have already done some tests for me, but so far without success.

The example CopyNameToClipboard uses stdlib.h, which I have bundled with. In addition, I have also determined all other required header files and placed in the program folder (wchar_t.h, div_t.h, alloca.h, wait.h, types.h, limits.h, stddef.h).

The program is only properly compiled but if I select it via the context menu add-ons I get only message: “Error No such file or directory when loading the add-ons flipimage”

My C Code: C and using a yab script to proceed

#include <stdio.h>
#include <stdlib.h>

int main(void) 
{
	system("yab /boot/home/Desktop/im_realtime_add-on/flip_image.yab");
	return 0;
}

Who wants to help me?

Would not it be great to be able to just flip, rotate, normalize, convert grayscale…

Humdinger already tried to help me, but the code he gave gives massive parse errors (Thanks for this Humdinger).

Humdingers code using the CopyNameToClipboard example and a direct running of the imagemagick command.

#include <stdio.h>
#include <stdlib.h>

extern "C" void

process_refs(entry_ref directoryRef, BMessage *msg, void *)
{
	BString command;
	BPath path;

	int refs;
	entry_ref file_ref;

	for (refs = 0; msg->FindRef("refs", refs, &file_ref) == B_NO_ERROR; refs++) {
		BEntry(&file_ref).GetPath(&path);
		command = "convert -flip %filepath%";
		command.ReplaceFirst("%filepath%", path.Path());
		system(command.String());
	}
}
1 Like

Have you tried TAResizer (The github version)? Does almost everything you have mentioned…

I see a problem working with the original image, some actions are irreversible… if you mess up you will lose informations (a simple example is convert grayscale).

1 Like

No i does not. I am no c or cpp developer, so what should i do with it? I need something i understand, so i hope to find someone help me, make my c source a valid tracker add-on. If this would be running i can make a clear programming in yab :slight_smile:

That snippet was supposed to replace the process_refs() of the CopyNameToClipboard code. The rest should be kept untouched.

This would be the complete main.cpp (with the system calling ‘open’ instead of some imagemagick command; you can exchange for your yab app):

#include <Entry.h>
#include <Path.h>
#include <String.h>

#include <stdio.h>
#include <stdlib.h>

extern "C" void
process_refs(entry_ref directoryRef, BMessage *msg, void *)
{
	BString command;
	BPath path;

	int refs;
	entry_ref file_ref;

	for (refs = 0; msg->FindRef("refs", refs, &file_ref) == B_NO_ERROR; refs++) {
		BEntry(&file_ref).GetPath(&path);
		
		command = "open %filepath%";
		command.ReplaceFirst("%filepath%", path.Path());
		
		system(command.String());
	}
}


int
main(int /*argc*/, char **/*argv*/)
{
	fprintf(stderr, "This can only be used as a Tracker add-on.\n");
	return -1; 
}

If you don’t use CopyNameToClipboard’s makefile, please paste how you compile the app and the error output.

Use the app like a user.

git clone https://github.com/HaikuArchives/TheAwesomeResizer.git
cd TheAwesomeResizer/source
make
./objects.x86-cc2-release/TAResizer

I have tried compiling with the make file, but i get 10-12 parse errors. And i have not expierience with it, i does not understand c or cpp… So makefiles, git, etc too

If you paste the parse errors, that may give a hint.

I am not at home. I get every line starting with extern “C” void a parse error

that means you are using yourfile.c (with .c extension), the keyword extern is c++ only.

Choose one of:

  • just rename it to .cpp
  • delete extern “C”
  • wrap each ocurrence of extern "C"in ifdefs this way
#ifdef __cplusplus
extern "C"
#endif

If i get an cpp code i compile it like this :slight_smile: too

This are two different ways to make my project. C or cpp. My first thinking was the c program to run yab and now humdinger comes with cpp

OK, I modified a tracker add-on to launch a file in HelpViewer:

I started with the source for CopyNameToClipboard

I modified the make file:

NAME= Open_HelpVewer

and the Rdef file:

resource app_signature "application/x-vnd.Open_HelpvVewer";

resource app_flags B_SINGLE_LAUNCH;

resource app_version {
	major  = 1,
	middle = 0,
	minor  = 0,

	/* 0 = development	1 = alpha			2 = beta
	   3 = gamma		4 = golden master	5 = final */
	variety = 5,

	internal = 0,

	short_info = "Tracker add-on to open in HelpViewer",
	long_info  =  "racker add-on to open in HelpViewer"
};

resource vector_icon{
	$"6E63696605020102023DC0000000000000003D80004A00004A40007D01000044"
$"FF0100000003010000020116043B73F1366FD3B526223A3B22497CE64B43AE70"
$"F2A38ED4E1FF59020106033DC0000000000000003DC00049000048000031FFFF"
$"FFD5FFE500FFFFC800020106033DC0000000000000003DC00049000048000000"
$"FFE6A5FFFFBF00E2FFBB03070204402052202E202040202E205240602E605260"
$"60406052602E0405FE0148534858485848CAB0405EC18E5EBDF15E385838CAB0"
$"3858530405FE014B4B4B4D4B4D4BC6D24056C22956BD5656354D35C6D2354D4B"
$"0005444D444DC56BC42F563856C0D4C883B7C14022C49622BAE9222A382AB7C1"
$"2AC0D43C4DBA14C42F3C4D08024050404202043C3C3CBF713CBCDE4036BED836"
$"C0A736443C44BCDE44BF714042C0A742BED8420203344A344ABBEAC4533C4DBD"
$"00C4B83C4D344B374D344B0A0A000100023EE0000000000000003C8000484000"
$"4AC0000A0101011001178400040A020101000A010202031001178400040A0301"
$"02000A030103000A0401041001178422040A0401051001178422040A01010600"
$"0A01010602C000000000000000004000004C0000000000"

};

resource(100, “BEOS:default_shortcut”) “V”;

resource file_types message {
“types” = “text/plain”,
“types” = “text”,
“types” = “text/Help”,
“types” = “Help”
};

next main.cpp

#include <stdlib.h>

and

BString command;
	command.Append ( "HelpViewer " );

if (quote)
		
			ClipString.Append(command).Append("\"").Append(FileString).Append("\"");
		else
			ClipString.Append(command).Append(FileString);

if (refs != 0) {
		int i;
		i=system(ClipString);
		
		
		/*BClipboard Clipboard("system");
		BMessage *clip = (BMessage *)NULL;
		
		if (Clipboard.Lock()) {
			Clipboard.Clear();

			if ((clip = Clipboard.Data())) {
				clip->AddData("text/plain", B_MIME_TYPE, ClipString.String(),
					ClipString.Length()); 
				Clipboard.Commit();
			}
			Clipboard.Unlock();
		}*/
	}

http://coquilletkd.com/jim/Open_HelpViewer.zip

1 Like

Thanks for your help. Have it tried and compiled.

But so have my principle problems with it, because I understand the source only partially and therefore can not be sure that it does not create a security hole. Therefore, I would have preferred to learn how to define a c program as a tracker add-on.

In addition many features used in the template and data obtained from me are not used and are therefore unnecessary data garbage.

But I will deal with it and try to set my idea.