Start popuating treeview context menu

Remove add folder/bookmark buttons from hotlist

svn path=/trunk/netsurf/; revision=13287
This commit is contained in:
Chris Young 2011-12-17 18:47:35 +00:00
parent dc082c96cb
commit 0ed26d727f
8 changed files with 107 additions and 25 deletions

View File

@ -340,6 +340,7 @@ TreeVersion2:RFC 2965
TreeSession:Sitzungsende
TreeUnused:Nicht benutzt
TreeImport:Importierte URL
TreeNewLink:New address
TreeNewFolder:Neues Verzeichnis
TreeLaunch:URL ansehen
TreeDelete:Löschen
@ -362,6 +363,7 @@ TreeHotlist:NetSurf Hotlist
#
NewLink:Neuen Eintrag erstellen
NewFolder:Verzeichnis anlegen
EditTitle:Edit title
EditLink:Eintrag bearbeiten
EditFolder:Verzeichnis umbenennen

View File

@ -342,6 +342,7 @@ TreeVersion2:RFC 2965
TreeSession:Session end
TreeUnused:Unused
TreeImport:Imported URL
TreeNewLink:New address
TreeNewFolder:New directory
TreeLaunch:Visit URL
TreeDelete:Delete
@ -365,6 +366,7 @@ TreeHotlist:NetSurf hotlist
#
NewLink:Create new address
NewFolder:Create new directory
EditTitle:Edit title
EditLink:Edit address
EditFolder:Rename directory

View File

@ -340,6 +340,7 @@ TreeVersion2:RFC 2965
TreeSession:Fin de session
TreeUnused:Inutilisé
TreeImport:URL importée
TreeNewLink:New address
TreeNewFolder:Nouv. répertoire
TreeLaunch:Visit URL
TreeDelete:Delete
@ -362,6 +363,7 @@ TreeHotlist:Favoris de NetSurf
#
NewLink:Créer une nouvelle adresse
NewFolder:Créer un nouveau dossier
EditTitle:Edit title
EditLink:Éditer l'adresse
EditFolder:Éditer le dossier

View File

@ -343,6 +343,7 @@ TreeVersion2:RFC 2965
TreeSession:Fine sessione
TreeUnused:Inutilizzato
TreeImport:URL importati
TreeNewLink:New address
TreeNewFolder:Nuova cartella
TreeLaunch:Visita URL
TreeDelete:Elimina
@ -365,6 +366,7 @@ TreeHotlist:Segnalibri di NetSurf
#
NewLink:Crea nuovo indirizzo
NewFolder:Crea nuova cartella
EditTitle:Edit title
EditLink:Modifica indirizzo
EditFolder:Rinomina cartella

View File

@ -340,6 +340,7 @@ TreeVersion2:RFC 2965
TreeSession:Sessie einde
TreeUnused:Ongebruikt
TreeImport:Ge-importeerde URL
TreeNewLink:New address
TreeNewFolder:Nieuwe map
TreeLaunch:Visit URL
TreeDelete:Delete
@ -362,6 +363,7 @@ TreeHotlist:NetSurf bladwijzers
#
NewLink:Nieuw adres aanmaken
NewFolder:Nieuwe map aanmaken
EditTitle:Edit title
EditLink:Bewerk adres
EditFolder:Map hernoemen

View File

@ -37,6 +37,7 @@
#include "amiga/options.h"
#include "amiga/plugin_hack.h"
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
#include "desktop/history_core.h"
#include "desktop/hotlist.h"
@ -52,6 +53,7 @@
#include <string.h>
static uint32 ami_context_menu_hook(struct Hook *hook, Object *item, APTR reserved);
static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR reserved);
static bool ami_context_menu_history(const struct history *history, int x0, int y0,
int x1, int y1, const struct history_entry *entry, void *user_data);
@ -105,6 +107,7 @@ enum {
CMID_TREE_SETDEFAULT,
CMID_TREE_CLEARDEFAULT,
CMID_TREE_DELETE,
CMID_TREE_EDITTITLE,
CMID_TREE_EDITLINK,
CMID_TREE_EDITFOLDER,
CMID_TREE_ADDHOTLIST,
@ -193,10 +196,11 @@ void ami_context_menu_init(void)
ctxmenulab[CMID_TREE_COLLAPSE] = ami_utf8_easy((char *)messages_get("Collapse"));
ctxmenulab[CMID_TREE_LAUNCH] = ami_utf8_easy((char *)messages_get("TreeLaunch"));
ctxmenulab[CMID_TREE_NEWFOLDER] = ami_utf8_easy((char *)messages_get("TreeNewFolder"));
ctxmenulab[CMID_TREE_NEWITEM] = ami_utf8_easy((char *)messages_get("New"));
ctxmenulab[CMID_TREE_NEWITEM] = ami_utf8_easy((char *)messages_get("TreeNewLink"));
ctxmenulab[CMID_TREE_SETDEFAULT] = ami_utf8_easy((char *)messages_get("TreeDefault"));
ctxmenulab[CMID_TREE_CLEARDEFAULT] = ami_utf8_easy((char *)messages_get("TreeClear"));
ctxmenulab[CMID_TREE_DELETE] = ami_utf8_easy((char *)messages_get("TreeDelete"));
ctxmenulab[CMID_TREE_EDITTITLE] = ami_utf8_easy((char *)messages_get("EditTitle"));
ctxmenulab[CMID_TREE_EDITLINK] = ami_utf8_easy((char *)messages_get("EditLink"));
ctxmenulab[CMID_TREE_EDITFOLDER] = ami_utf8_easy((char *)messages_get("EditFolder"));
ctxmenulab[CMID_TREE_ADDHOTLIST] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
@ -934,6 +938,90 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
return itemid;
}
void ami_context_menu_show_tree(struct tree *tree, struct Window *win, int type)
{
struct node *root = tree_get_root(tree);
struct node *sel_node = tree_get_selected_node(root);
bool has_selection = tree_node_has_selection(root);
if(ctxmenuobj) DisposeObject(ctxmenuobj);
ctxmenuhook.h_Entry = ami_context_menu_hook_tree;
ctxmenuhook.h_SubEntry = NULL;
ctxmenuhook.h_Data = tree;
ctxmenuobj = NewObject( POPUPMENU_GetClass(), NULL,
PMA_MenuHandler, &ctxmenuhook,
TAG_DONE);
if(has_selection && (type != AMI_TREE_COOKIES) &&
((sel_node == NULL) ||
(tree_node_is_folder(sel_node) == false))) {
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_LAUNCH],
PMIA_ID, CMID_TREE_LAUNCH,
PMIA_UserData, NULL,
TAG_DONE),
~0);
}
if(type == AMI_TREE_HOTLIST) {
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
PMIA_Title, ~0,
TAG_DONE),
~0);
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_NEWFOLDER],
PMIA_ID, CMID_TREE_NEWFOLDER,
PMIA_UserData, NULL,
TAG_DONE),
~0);
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_NEWITEM],
PMIA_ID, CMID_TREE_NEWITEM,
PMIA_UserData, NULL,
TAG_DONE),
~0);
}
IDoMethod(ctxmenuobj, PM_OPEN, win);
}
static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR reserved)
{
int32 itemid = 0;
struct tree *tree = hook->h_Data;
APTR userdata = NULL;
if(GetAttrs(item,PMIA_ID, &itemid,
PMIA_UserData, &userdata,
TAG_DONE))
{
switch(itemid)
{
case CMID_TREE_LAUNCH:
tree_launch_selected(tree, true);
break;
case CMID_TREE_NEWFOLDER:
hotlist_add_folder(true);
break;
case CMID_TREE_NEWITEM:
hotlist_add_entry(true);
break;
}
}
return itemid;
}
static bool ami_context_menu_history(const struct history *history, int x0, int y0,
int x1, int y1, const struct history_entry *entry, void *user_data)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
* Copyright 2008-9, 2011 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -20,8 +20,11 @@
#define AMIGA_CONTEXT_MENU_H
#include "amiga/gui.h"
struct tree;
void ami_context_menu_init(void);
void ami_context_menu_free(void);
BOOL ami_context_menu_mouse_trap(struct gui_window_2 *gwin, BOOL trap);
void ami_context_menu_show(struct gui_window_2 *gwin, int x, int y);
void ami_context_menu_show_tree(struct tree *tree, struct Window *win, int type);
#endif

View File

@ -43,6 +43,7 @@
#include <reaction/reaction_macros.h>
#include <intuition/icclass.h>
#include "amiga/context_menu.h"
#include "amiga/file.h"
#include "amiga/gui.h"
#include "amiga/tree.h"
@ -69,8 +70,6 @@
enum {
GID_OPEN = GID_LAST,
GID_NEWF,
GID_NEWB,
GID_DEL,
GID_DEFAULT,
GID_TREE_LAST
@ -685,18 +684,6 @@ void ami_tree_open(struct treeview_window *twin,int type)
GA_RelVerify,TRUE,
GA_Disabled,launchdisable,
ButtonEnd,
LAYOUT_AddChild, twin->objects[GID_NEWF] = ButtonObject,
GA_ID,GID_NEWF,
BUTTON_AutoButton,BAG_POPDRAWER,
GA_RelVerify,TRUE,
GA_Disabled,nothl,
ButtonEnd,
LAYOUT_AddChild, twin->objects[GID_NEWB] = ButtonObject,
GA_ID,GID_NEWB,
BUTTON_AutoButton,BAG_POPFILE,
GA_RelVerify,TRUE,
GA_Disabled,nothl,
ButtonEnd,
LAYOUT_AddChild, twin->objects[GID_DEL] = ButtonObject,
GA_ID,GID_DEL,
GA_Text,messages_get("TreeDelete"),
@ -828,14 +815,6 @@ BOOL ami_tree_event(struct treeview_window *twin)
return TRUE;
break;
case GID_NEWF:
hotlist_add_folder(true);
break;
case GID_NEWB:
hotlist_add_entry(true);
break;
case GID_DEFAULT:
hotlist_set_default_folder(false);
break;
@ -971,6 +950,8 @@ BOOL ami_tree_event(struct treeview_window *twin)
{
tree_set_node_selected_at(twin->tree, x, y, true);
}
ami_context_menu_show_tree(twin->tree, twin->win, twin->type);
break;
}
}