Skip to content

Commit

Permalink
Allow parse_dotdesktop() to mark libpnd origin or not, and convenienc…
Browse files Browse the repository at this point in the history
…e filter to ditch non-libpnd ones
  • Loading branch information
skeezix committed Nov 3, 2011
1 parent a9c9e10 commit 38d0da1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion include/pnd_desktop.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ extern "C" {
#define PND_DOTDESKTOP_HEADER "[Desktop Entry]"
#define PND_DOTDESKTOP_SOURCE "X-Pandora-Source=libpnd"
unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t *p );
pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath );

#define PND_DOTDESKTOP_LIBPND_ONLY 1 /* convenience flag; caller can do this himself as well */
pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath, unsigned int flags ); // sets object_flag CUSTOM1 for non-libpnd-origin

// emit_dotinfo() will spit out a .desktop 'info entry', similar to the way emit_dotdesktop does its thing
// - rather than slide this into emit_dotdesktop(), we wish to allow apps to do this or not by calling this
Expand Down
14 changes: 10 additions & 4 deletions lib/pnd_desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ unsigned char *pnd_emit_icon_to_buffer ( pnd_disco_t *p, unsigned int *r_buflen
// parse_dotdesktop() can be used to read a libpnd generated .desktop and return a limited
// but useful disco-t structure back; possibly useful for scanning .desktops rather than
// scanning pnd-files?
pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath ) {
pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath, unsigned int flags ) {

// will verify the .desktop has the libpnd-marking on it (X-Pandora-Source): PND_DOTDESKTOP_SOURCE

Expand Down Expand Up @@ -832,9 +832,15 @@ pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath ) {

// filter
if ( ! libpnd_origin ) {
pnd_disco_destroy ( p );
free ( p );
return ( NULL );
p -> object_flags |= PND_DISCO_CUSTOM1; // so caller can do something if it wishes

// convenience flag
if ( flags & PND_DOTDESKTOP_LIBPND_ONLY ) {
pnd_disco_destroy ( p );
free ( p );
return ( NULL );
}

}

// additional
Expand Down
2 changes: 1 addition & 1 deletion test/discotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int main ( int argc, char *argv[] ) {
pnd_box_handle applist;

if ( dotdesktoppath [ 0 ] ) {
pnd_disco_t *p = pnd_parse_dotdesktop ( dotdesktoppath );
pnd_disco_t *p = pnd_parse_dotdesktop ( dotdesktoppath, PND_DOTDESKTOP_LIBPND_ONLY );
pnd_box_handle disco_box = pnd_box_new ( "discovery" );
if ( p ) {
pnd_disco_t *ai = pnd_box_allocinsert ( disco_box, dotdesktoppath, sizeof(pnd_disco_t) );
Expand Down

0 comments on commit 38d0da1

Please sign in to comment.