! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Patch for adding emblem support to thunarx master
Status:
RESOLVED: FIXED
Severity:
enhancement

Comments

Description Adam Plumb editbugs 2009-12-07 13:27:22 CET
Created attachment 2718 
Emblem Patch file

This is my first attempt at writing a patch for Thunar, and I'm also somewhat new to C, so please excuse any mistakes I may have made.

I've written a patch that adds emblem support to thunarx master.  Basically I started by adding a set_emblem method to the ThunarxFileInfoIface struct and then working from there.  I also used some code from thunar-emblem-chooser.c to get it working right.

The patch file is attached, as is a modified thunar-wallpaper extension that I've added Set/Remove menu items to for testing purposes.

I'd appreciate any feedback on my work, and hopefully this will get accepted into the thunar master branch.

Thanks,
Adam Plumb
Comment 1 Adam Plumb editbugs 2009-12-07 13:28:43 CET
Created attachment 2719 
Extension for testing emblem support

To install, replace the thunar-wallpaper plugin folder with this one in the /plugins folder.
Comment 2 Jannis Pohlmann editbugs 2009-12-07 13:42:18 CET
Did you test this with more than on emblem? It looks like thunar_file_info_set_emblem() overwrites existing emblems and replaces them with a single string.
Comment 3 Adam Plumb editbugs 2009-12-07 14:01:38 CET
(In reply to comment #2)
> Did you test this with more than on emblem? It looks like
> thunar_file_info_set_emblem() overwrites existing emblems and replaces them
> with a single string.

I figured it would be simpler for the extension writer to only have to deal with the one "set_emblem" method.  But I can see the reasoning behind allowing one to work with multiple emblems and having more granularity, and also keeping an existing set of assigned emblems intact.  I'll work on the patch to add this.

BTW, is using the reserved[0-9] spaces in thunarx-file-info.h the correct way to add new methods to the ThunarxFileInfoIface interface?  Also, Benedikt responded to my thunar mailing list email with a suggestion to have the following functions:

 thunarx_file_info_add_emblem(file_info, emblem_name)
 thunarx_file_info_remove_emblem(file_info, emblem_name)
 thunarx_file_info_remove_emblems(file_info)

This seems reasonable to me.  What do you think?
Comment 4 Jannis Pohlmann editbugs 2009-12-07 14:08:40 CET
(In reply to comment #3)
> BTW, is using the reserved[0-9] spaces in thunarx-file-info.h the correct way
> to add new methods to the ThunarxFileInfoIface interface?

Yeah, it is. The reserved members in interface structs exist for this purpose in particular.

> Also, Benedikt responded to my thunar mailing list email with a suggestion 
> to have the following functions:
>
>  thunarx_file_info_add_emblem(file_info, emblem_name)
>  thunarx_file_info_remove_emblem(file_info, emblem_name)
>  thunarx_file_info_remove_emblems(file_info)
> 
> This seems reasonable to me.  What do you think?

Yeah, sounds good indeed.
Comment 5 Adam Plumb editbugs 2009-12-07 16:20:08 CET
Created attachment 2720 
Patch file

I've updated the patch as follows:

 - Changed the set_emblem function name to add_emblem
 - Added the remove_emblem and remove_emblems functions
 - Modified the add_emblem function so that it will not add a duplicate emblem

How does this look?  I will upload a new test extension as well that exercises the new functionality.
Comment 6 Adam Plumb editbugs 2009-12-07 16:21:00 CET
Created attachment 2721 
Extension for testing emblem support

Updated the extension to use the new add_emblem method as well as the remove_emblem and remove_emblems methods.
Comment 7 Adam Plumb editbugs 2009-12-11 20:01:38 CET
Can you give me some feedback on this when you get a chance?  Is there anything holding it back from getting integrated into thunar?  Let me know if there is anything I can do.

Adam
Comment 8 Jannis Pohlmann editbugs 2009-12-11 20:12:48 CET
(In reply to comment #7)
> Can you give me some feedback on this when you get a chance?  Is there anything
> holding it back from getting integrated into thunar? 

Yes: the lack of free time. I'll get back to you as soon as I find the time to take a closer look. The patch is incredible helpful in getting this feature merged into master, thanks!
Comment 9 Jonathan Liu 2012-08-20 15:48:33 CEST
Any updates?
Comment 10 Nick Schermer editbugs 2012-09-27 12:37:42 CEST
We use metadata::emblems in GFileInfo now, so everybody can set those.

Bug #6055

Reported by:
Adam Plumb
Reported on: 2009-12-07
Last modified on: 2012-09-27

People

Assignee:
Jannis Pohlmann
CC List:
5 users

Version

Version:
unspecified

Attachments

Emblem Patch file (4.36 KB, patch)
2009-12-07 13:27 CET , Adam Plumb
no flags
Extension for testing emblem support (50.83 KB, application/x-gzip)
2009-12-07 13:28 CET , Adam Plumb
no flags
Patch file (7.07 KB, patch)
2009-12-07 16:20 CET , Adam Plumb
no flags
Extension for testing emblem support (50.32 KB, application/x-gzip)
2009-12-07 16:21 CET , Adam Plumb
no flags

Additional information