summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2011-12-17 18:47:35 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2011-12-17 18:47:35 +0000
commit0ed26d727f703d91ccd114375ee0aee72b24ad54 (patch)
treebfeb612b3c126ec97fbdf3ed4404462b94f53bf6
parentdc082c96cb3d90096fe2761f24127a0ad99f5b2d (diff)
downloadnetsurf-0ed26d727f703d91ccd114375ee0aee72b24ad54.tar.gz
netsurf-0ed26d727f703d91ccd114375ee0aee72b24ad54.tar.bz2
Start popuating treeview context menu
Remove add folder/bookmark buttons from hotlist svn path=/trunk/netsurf/; revision=13287
-rw-r--r--!NetSurf/Resources/de/Messages2
-rw-r--r--!NetSurf/Resources/en/Messages2
-rw-r--r--!NetSurf/Resources/fr/Messages2
-rw-r--r--!NetSurf/Resources/it/Messages2
-rw-r--r--!NetSurf/Resources/nl/Messages2
-rwxr-xr-xamiga/context_menu.c92
-rwxr-xr-xamiga/context_menu.h5
-rwxr-xr-xamiga/tree.c25
8 files changed, 107 insertions, 25 deletions
diff --git a/!NetSurf/Resources/de/Messages b/!NetSurf/Resources/de/Messages
index fc8b43e6e..eed8e874d 100644
--- a/!NetSurf/Resources/de/Messages
+++ b/!NetSurf/Resources/de/Messages
@@ -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
diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages
index cf3ddebe2..414214985 100644
--- a/!NetSurf/Resources/en/Messages
+++ b/!NetSurf/Resources/en/Messages
@@ -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
diff --git a/!NetSurf/Resources/fr/Messages b/!NetSurf/Resources/fr/Messages
index ab9d11333..a4d0f3436 100644
--- a/!NetSurf/Resources/fr/Messages
+++ b/!NetSurf/Resources/fr/Messages
@@ -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
diff --git a/!NetSurf/Resources/it/Messages b/!NetSurf/Resources/it/Messages
index 6555d6576..4d3b059b6 100644
--- a/!NetSurf/Resources/it/Messages
+++ b/!NetSurf/Resources/it/Messages
@@ -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
diff --git a/!NetSurf/Resources/nl/Messages b/!NetSurf/Resources/nl/Messages
index fd63a5c8a..e1e973e7a 100644
--- a/!NetSurf/Resources/nl/Messages
+++ b/!NetSurf/Resources/nl/Messages
@@ -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
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 939ec42db..26ff2f0c9 100755
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -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"
@@ -51,7 +52,8 @@
#include <string.h>
-static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved);
+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)
{
diff --git a/amiga/context_menu.h b/amiga/context_menu.h
index d95cd2628..60224f4e6 100755
--- a/amiga/context_menu.h
+++ b/amiga/context_menu.h
@@ -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
diff --git a/amiga/tree.c b/amiga/tree.c
index 676cf108a..a8282bb9d 100755
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -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;
}
}