From 936baddabaac148f7c8831f38ec7f0d25f12078a Mon Sep 17 00:00:00 2001 From: Chris Young Date: Thu, 9 Jun 2011 22:29:46 +0000 Subject: Only show external app context menu item if an external app is actually defined svn path=/trunk/netsurf/; revision=12470 --- amiga/context_menu.c | 19 +++++++++++-------- amiga/filetype.c | 17 ++++++++++++++++- amiga/filetype.h | 3 +-- amiga/plugin_hack.c | 25 ++++++++++--------------- 4 files changed, 38 insertions(+), 26 deletions(-) (limited to 'amiga') diff --git a/amiga/context_menu.c b/amiga/context_menu.c index d3bb8ae6f..70fc602f1 100755 --- a/amiga/context_menu.c +++ b/amiga/context_menu.c @@ -367,15 +367,18 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y) if(curbox->object && (content_get_type(curbox->object) == CONTENT_PLUGIN)) { - IDoMethod(gwin->objects[OID_MENU],PM_INSERT, - NewObject(POPUPMENU_GetItemClass(), NULL, - PMIA_Title, (ULONG)ctxmenulab[CMID_PLUGINCMD], - PMIA_ID, CMID_PLUGINCMD, - PMIA_UserData, curbox->object, - TAG_DONE), - ~0); + if(ami_mime_content_to_cmd(curbox->object)) + { + IDoMethod(gwin->objects[OID_MENU],PM_INSERT, + NewObject(POPUPMENU_GetItemClass(), NULL, + PMIA_Title, (ULONG)ctxmenulab[CMID_PLUGINCMD], + PMIA_ID, CMID_PLUGINCMD, + PMIA_UserData, curbox->object, + TAG_DONE), + ~0); - menuhascontent = true; + menuhascontent = true; + } } if (curbox->gadget) { diff --git a/amiga/filetype.c b/amiga/filetype.c index bdc273365..e99a0fb33 100644 --- a/amiga/filetype.c +++ b/amiga/filetype.c @@ -564,6 +564,21 @@ struct Node *ami_mime_to_plugincmd(lwc_string *mimetype, } } +lwc_string *ami_mime_content_to_cmd(struct hlcache_handle *c) +{ + struct Node *node; + lwc_string *plugincmd; + lwc_string *mimetype; + + mimetype = content_get_mime_type(c); + + node = ami_mime_to_plugincmd(mimetype, + &plugincmd, NULL); + + if(node && (plugincmd != NULL)) return plugincmd; + else return NULL; +} + /** * Compare the MIME type of an hlcache_handle to a DefIcons type */ @@ -595,7 +610,7 @@ bool ami_mime_compare(struct hlcache_handle *c, const char *type) void ami_mime_dump(void) { - struct Node *node; + struct Node *node = NULL; struct ami_mime_entry *mimeentry; while(mimeentry = ami_mime_entry_locate(NULL, AMI_MIME_MIMETYPE, &node)) diff --git a/amiga/filetype.h b/amiga/filetype.h index 1750950d0..03302bf57 100644 --- a/amiga/filetype.h +++ b/amiga/filetype.h @@ -36,9 +36,8 @@ struct Node *ami_mime_from_datatype(struct DataType *dt, lwc_string **mimetype, struct Node *start_node); struct Node *ami_mime_to_filetype(lwc_string *mimetype, lwc_string **filetype, struct Node *start_node); -struct Node *ami_mime_to_plugincmd(lwc_string *mimetype, - lwc_string **plugincmd, struct Node *start_node); +lwc_string *ami_mime_content_to_cmd(struct hlcache_handle *c); struct Node *ami_mime_has_cmd(lwc_string **mimetype, struct Node *start_node); bool ami_mime_compare(struct hlcache_handle *c, const char *type); diff --git a/amiga/plugin_hack.c b/amiga/plugin_hack.c index e450b1c6a..08a96e25b 100644 --- a/amiga/plugin_hack.c +++ b/amiga/plugin_hack.c @@ -240,29 +240,25 @@ content_type amiga_plugin_hack_content_type(lwc_string *mime_type) void amiga_plugin_hack_execute(struct hlcache_handle *c) { - lwc_string *mimetype; lwc_string *plugincmd; - struct Node *node; char *full_cmd; BPTR in, out; if(c == NULL) return; - mimetype = content_get_mime_type(c); - node = ami_mime_to_plugincmd(mimetype, &plugincmd, NULL); + plugincmd = ami_mime_content_to_cmd(c); + if(plugincmd == NULL) return; - if(node && plugincmd) - { - full_cmd = ASPrintf("%s %s", lwc_string_data(plugincmd), content_get_url(c)); + full_cmd = ASPrintf("%s %s", lwc_string_data(plugincmd), content_get_url(c)); - if(full_cmd) - { - LOG(("Attempting to execute %s", full_cmd)); + if(full_cmd) + { + LOG(("Attempting to execute %s", full_cmd)); - in = Open("NIL:", MODE_OLDFILE); - out = Open("NIL:", MODE_NEWFILE); + in = Open("NIL:", MODE_OLDFILE); + out = Open("NIL:", MODE_NEWFILE); - SystemTags(full_cmd, + SystemTags(full_cmd, SYS_Input, in, SYS_Output, out, SYS_Error, out, @@ -270,7 +266,6 @@ void amiga_plugin_hack_execute(struct hlcache_handle *c) NP_Name, "NetSurf External Process", TAG_DONE); - FreeVec(full_cmd); - } + FreeVec(full_cmd); } } -- cgit v1.2.3