Update url bar with nav url, send correct browser size to ns

This commit is contained in:
anthony 2020-12-03 20:24:15 +00:00
parent c05a705717
commit 65b9019f06
3 changed files with 25 additions and 8 deletions

View File

@ -26,4 +26,6 @@ struct browser_window;
-(void)newContent;
-(void)startThrobber;
-(void)stopThrobber;
-(void)setNavigationUrl: (NSString*)urlString;
-(void)setTitle: (NSString*)title;
@end

View File

@ -31,7 +31,7 @@
}
-(NSSize)getBrowserSize {
return [plotView frame].size;
return [[plotView superview] frame].size;
}
-(NSPoint)getBrowserScroll {
return [plotView visibleRect].origin;
@ -56,19 +56,21 @@
}
-(void)newContent {
NSLog(@"New content");
struct nsurl *url = browser_window_access_url(browser);
const char *urlcstr = nsurl_access(url);
[urlBar setStringValue: [NSString stringWithUTF8String: urlcstr]];
}
-(void)startThrobber {
struct nsurl *url = browser_window_access_url(browser);
const char *urlcstr = nsurl_access(url);
[urlBar setStringValue: [NSString stringWithUTF8String: urlcstr]];
}
-(void)stopThrobber {
}
-(void)setNavigationUrl: (NSString*)urlString {
[urlBar setStringValue: urlString];
}
-(void)setTitle: (NSString*)title {
[[self window] setTitle: title];
}
-(BOOL)control: (NSControl*)control textShouldEndEditing: (NSText*)fieldEditor {
NSLog(@"textShouldEndEditing");

View File

@ -4,6 +4,7 @@
#import "netsurf/netsurf.h"
#import "netsurf/window.h"
#import "netsurf/types.h"
#import "utils/nsurl.h"
/********************/
/****** Window ******/
@ -95,6 +96,16 @@ static nserror gnustep_window_event(struct gui_window *gw, enum gui_window_event
return NSERROR_OK;
}
static void gnustep_window_set_title(struct gui_window *gw, const char *title) {
[(id)gw setTitle: [NSString stringWithUTF8String: title]];
}
static nserror gnustep_window_set_url(struct gui_window *gw, struct nsurl *url) {
NSString *urlStr = [NSString stringWithUTF8String: nsurl_access(url)];
[(id)gw setNavigationUrl: urlStr];
return NSERROR_OK;
}
struct gui_window_table gnustep_window_table = {
.create = gnustep_window_create,
.destroy = gnustep_window_destroy,
@ -102,5 +113,7 @@ struct gui_window_table gnustep_window_table = {
.get_scroll = gnustep_window_get_scroll,
.set_scroll = gnustep_window_set_scroll,
.get_dimensions = gnustep_window_get_dimensions,
.event = gnustep_window_event
.event = gnustep_window_event,
.set_title = gnustep_window_set_title,
.set_url = gnustep_window_set_url
};