diff options
Diffstat (limited to 'atari/ctxmenu.c')
-rw-r--r-- | atari/ctxmenu.c | 169 |
1 files changed, 93 insertions, 76 deletions
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c index 84f5d870d..d89060a65 100644 --- a/atari/ctxmenu.c +++ b/atari/ctxmenu.c @@ -22,8 +22,7 @@ #include <unistd.h>
#include <string.h>
#include <stdbool.h>
-#include <assert.h>
-#include <windom.h> +#include <assert.h> #include <mint/osbind.h>
#include "desktop/gui.h"
@@ -40,8 +39,7 @@ #include "utils/messages.h"
#include "atari/gui.h"
-#include "atari/browser.h"
-#include "atari/browser_win.h"
+#include "atari/rootwin.h"
#include "atari/misc.h"
#include "atari/clipboard.h"
#include "desktop/options.h"
@@ -50,7 +48,6 @@ #define CNT_INVALID 0
-#define CNT_URLINPUT 32
#define CNT_BROWSER 64
#define CNT_HREF 128
#define CNT_SELECTION 256
@@ -68,48 +65,52 @@ struct s_context_info ctxinfo; static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my )
{
hlcache_handle *h;
- LGRECT bwrect;
+ GRECT area;
struct contextual_content ccdata;
- struct browser_window * bw = gw->browser->bw;
+ struct browser_window * bw = gw->browser->bw; + int sx, sy;
h = bw->current_content;
- ctxinfo.flags = 0;
-
- browser_get_rect( gw, BR_CONTENT, &bwrect );
- mx -= bwrect.g_x;
- my -= bwrect.g_y;
- if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) ){
- // TODO: check for urlinput location
- // and set CNT_URLINPUT
- return(&ctxinfo);
- }
+ ctxinfo.flags = 0; + + window_get_grect(gw->root, BROWSER_AREA_CONTENT, &area); + if (POINT_WITHIN(mx, my, area)) { + + mx -= area.g_x;
+ my -= area.g_y; + + if (!bw->current_content || content_get_type(h) != CONTENT_HTML){
+ return(&ctxinfo);
+ }
- if (!bw->current_content || content_get_type(h) != CONTENT_HTML){
- return(&ctxinfo);
- }
+ ctxinfo.flags |= CNT_BROWSER;
+ + memset( &ctxinfo.ccdata, sizeof(struct contextual_content), 0 ); + + gui_window_get_scroll(gw, &sx, &sy); - ctxinfo.flags |= CNT_BROWSER;
- memset( &ctxinfo.ccdata, sizeof(struct contextual_content), 0 );
- browser_window_get_contextual_content(
- gw->browser->bw,
- mx+gw->browser->scroll.current.x,
- my+gw->browser->scroll.current.y,
- (struct contextual_content*)&ctxinfo.ccdata
- );
- if( ctxinfo.ccdata.link_url ){
- ctxinfo.flags |= CNT_HREF;
- }
- if( ctxinfo.ccdata.object) {
- if( content_get_type(ctxinfo.ccdata.object) == CONTENT_IMAGE ){
- ctxinfo.flags |= CNT_IMG;
+ browser_window_get_contextual_content( gw->browser->bw, mx+sx, my+sy,
+ (struct contextual_content*)&ctxinfo.ccdata); +
+ if( ctxinfo.ccdata.link_url ){
+ ctxinfo.flags |= CNT_HREF;
}
- }
- if ( ctxinfo.ccdata.form_features == CTX_FORM_TEXT )
- ctxinfo.flags |= (CNT_INTERACTIVE | CNT_SELECTION);
- return( &ctxinfo );
-}
+ if( ctxinfo.ccdata.object) {
+ if( content_get_type(ctxinfo.ccdata.object) == CONTENT_IMAGE ){
+ ctxinfo.flags |= CNT_IMG;
+ }
+ }
+ if ( ctxinfo.ccdata.form_features == CTX_FORM_TEXT )
+ ctxinfo.flags |= (CNT_INTERACTIVE | CNT_SELECTION); + } + + return(&ctxinfo); -void context_popup( struct gui_window * gw, short x, short y )
+
+}
+ +//TODO: do not open popup for gui_window, but for a rootwin?
+void context_popup(struct gui_window * gw, short x, short y)
{
#define POP_FIRST_ITEM POP_CTX_CUT_SEL
@@ -124,9 +125,10 @@ void context_popup( struct gui_window * gw, short x, short y ) char * tempfile;
int err = 0;
char * editor, *lastslash;
- char cmdline[PATH_MAX];
+ char cmdline[PATH_MAX]; + MENU pop_menu, me_data;
- pop = get_tree( POP_CTX );
+ pop = gemtk_obj_get_tree( POP_CTX );
if (pop == NULL)
return;
ctx = get_context_info(gw, x, y);
@@ -135,44 +137,48 @@ void context_popup( struct gui_window * gw, short x, short y ) Disable all items by default:
*/
for( choice = POP_FIRST_ITEM; choice<=POP_LAST_ITEM; choice++ ){
- SET_BIT(pop[ choice ].ob_state, DISABLED, 1);
+ SET_BIT(pop[ choice ].ob_state, OS_DISABLED, 1);
}
if( ctx->flags & CNT_INTERACTIVE ){
- SET_BIT(pop[ POP_CTX_PASTE_SEL ].ob_state, DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_PASTE_SEL ].ob_state, OS_DISABLED, 0);
}
if( (ctx->flags & CNT_BROWSER) ){
- SET_BIT(pop[ POP_CTX_SELECT_ALL ].ob_state, DISABLED, 0);
- SET_BIT(pop[ POP_CTX_COPY_SEL ].ob_state, DISABLED, 0);
- SET_BIT(pop[ POP_CTX_VIEW_SOURCE ].ob_state, DISABLED, 0);
- }
+ SET_BIT(pop[ POP_CTX_SELECT_ALL ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_COPY_SEL ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_VIEW_SOURCE ].ob_state, OS_DISABLED, 0);
+ } if( ctx->flags & CNT_HREF ){
- SET_BIT(pop[ POP_CTX_COPY_LINK ].ob_state, DISABLED, 0);
- SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, DISABLED, 0);
- SET_BIT(pop[ POP_CTX_SAVE_LINK_AS ].ob_state, DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_COPY_LINK ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_SAVE_LINK_AS ].ob_state, OS_DISABLED, 0);
}
if( ctx->flags & CNT_IMG ){
- SET_BIT(pop[ POP_CTX_SAVE_AS ].ob_state, DISABLED, 0);
- SET_BIT(pop[ POP_CTX_COPY_URL ].ob_state, DISABLED, 0);
- SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, DISABLED, 0);
- }
-
- choice = MenuPopUp(
- pop, x, y,
- -1, -1, -1,
- P_WNDW + P_CHCK
- );
-
+ SET_BIT(pop[ POP_CTX_SAVE_AS ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_COPY_URL ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, OS_DISABLED, 0);
+ } + + // point mn_tree tree to states popup: + pop_menu.mn_tree = gemtk_obj_get_tree(POP_CTX); + pop_menu.mn_menu = 0; + pop_menu.mn_item = POP_CTX_CUT_SEL; + pop_menu.mn_scroll = SCROLL_NO; + pop_menu.mn_keystate = 0;
+ + menu_popup(&pop_menu, x, y, &me_data); + choice = me_data.mn_item;
+ switch( choice ){
case POP_CTX_COPY_SEL:
- browser_window_key_press( gw->browser->bw, KEY_COPY_SELECTION );
+ browser_window_key_press(gw->browser->bw, KEY_COPY_SELECTION);
break;
case POP_CTX_CUT_SEL:
- browser_window_key_press( gw->browser->bw, KEY_CUT_SELECTION );
+ browser_window_key_press(gw->browser->bw, KEY_CUT_SELECTION);
break;
case POP_CTX_PASTE_SEL: @@ -180,11 +186,11 @@ void context_popup( struct gui_window * gw, short x, short y ) break;
case POP_CTX_SELECT_ALL:
- browser_window_key_press( gw->browser->bw, KEY_SELECT_ALL );
+ browser_window_key_press(gw->browser->bw, KEY_SELECT_ALL);
break;
case POP_CTX_SAVE_AS:
- if( ctx->ccdata.object != NULL ) {
+ if (ctx->ccdata.object != NULL) {
if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ) {
browser_window_download(
gw->browser->bw,
@@ -195,7 +201,7 @@ void context_popup( struct gui_window * gw, short x, short y ) }
case POP_CTX_SAVE_LINK_AS:
- if( ctx->ccdata.link_url != NULL ) {
+ if (ctx->ccdata.link_url != NULL) {
browser_window_download(
gw->browser->bw,
ctx->ccdata.link_url,
@@ -206,21 +212,22 @@ void context_popup( struct gui_window * gw, short x, short y ) break;
case POP_CTX_COPY_URL:
- if( (ctx->flags & CNT_IMG) && (ctx->ccdata.object != NULL) ){
+ if ((ctx->flags & CNT_IMG) && (ctx->ccdata.object != NULL)) {
if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ){
- scrap_txt_write(&app, (char*)nsurl_access(hlcache_handle_get_url(ctx->ccdata.object)) );
+ scrap_txt_write((char*)nsurl_access( + hlcache_handle_get_url(ctx->ccdata.object)));
}
}
break;
case POP_CTX_COPY_LINK:
- if( (ctx->flags & CNT_HREF) && ctx->ccdata.link_url != NULL ){
- scrap_txt_write(&app, (char*)ctx->ccdata.link_url);
+ if ((ctx->flags & CNT_HREF) && ctx->ccdata.link_url != NULL) {
+ scrap_txt_write((char*)ctx->ccdata.link_url);
}
break;
case POP_CTX_OPEN_NEW:
- if( (ctx->flags & CNT_HREF) && ctx->ccdata.link_url) {
+ if ((ctx->flags & CNT_HREF) && ctx->ccdata.link_url) {
browser_window_create(
ctx->ccdata.link_url,
gw->browser->bw,
@@ -241,6 +248,7 @@ void context_popup( struct gui_window * gw, short x, short y ) if (fp_tmpfile != NULL){
fwrite(data, size, 1, fp_tmpfile);
fclose(fp_tmpfile ); + /* lastslash = strrchr(editor, '/'); if (lastslash == NULL) lastslash = strrchr(editor, '\\'); @@ -248,16 +256,25 @@ void context_popup( struct gui_window * gw, short x, short y ) lastslash = editor; else lastslash++; - if(is_process_running(lastslash)){ - err = ShelWrite( editor, tempfile , editor, 1, 0); + */ + + if(strlen(tempfile)<=125){ + shel_write(1,1,0,editor,tempfile); + } + + /*if(is_process_running(lastslash)){ + if(strlen(tempfile)<=125){ + shel_write(1,1,0,editor,tempfile); + } } else { - /* check for max length of simple commandline param: */ + // check for max length of simple commandline param: if(strlen(tempfile)<=125){ sprintf(cmdline, "%c%s", (char)strlen(tempfile), tempfile); Pexec(100, editor, cmdline, NULL); } - }
+ } + */
} else {
printf("Could not open temp file: %s!\n", tempfile );
}
|