r10673 chris_y - /trunk/netsurf/amiga/gui.c
by netsurf@semichrome.net
Author: chris_y
Date: Sat Jul 31 06:43:25 2010
New Revision: 10673
URL: http://source.netsurf-browser.org?rev=10673&view=rev
Log:
off by one
Modified:
trunk/netsurf/amiga/gui.c
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=10673&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Sat Jul 31 06:43:25 2010
@@ -3180,7 +3180,7 @@
gui_window_remove_caret(g->bw->window);
ScrollWindowRaster(g->win,hcurrent-oldh,vcurrent-oldv,
- xoffset,yoffset,xoffset+width,yoffset+height);
+ xoffset,yoffset,xoffset+width-1,yoffset+height-1);
g->bw->window->c_h = g->bw->window->c_h_temp;
13 years, 1 month
r10672 chris_y - in /trunk/netsurf/amiga: dist/NetSurf.guide download.c options.h theme.c
by netsurf@semichrome.net
Author: chris_y
Date: Thu Jul 29 16:41:25 2010
New Revision: 10672
URL: http://source.netsurf-browser.org?rev=10672&view=rev
Log:
Add option to control whether drags have icons or just a pointer change.
Modified:
trunk/netsurf/amiga/dist/NetSurf.guide
trunk/netsurf/amiga/download.c
trunk/netsurf/amiga/options.h
trunk/netsurf/amiga/theme.c
Modified: trunk/netsurf/amiga/dist/NetSurf.guide
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/dist/NetSurf.guide?...
==============================================================================
--- trunk/netsurf/amiga/dist/NetSurf.guide (original)
+++ trunk/netsurf/amiga/dist/NetSurf.guide Thu Jul 29 16:41:25 2010
@@ -41,6 +41,7 @@
@{b}kiosk_mode@{ub} No gadgets
@{b}no_iframes@{ub} Disable IFrames
@{b}printer_unit@{ub} Specifies which printer.device unit to print to
+@{b}drag_save_icons@{ub} Enables displaying Workbench-style transparent icons under the pointer when performing drag saves (ctrl-drag of objects available if NetSurf is running on the Workbench screen) and text selection drags. If set to 0 the pointer style will change instead. OS 4.0 users may want to set this to 0 as icons will appear opaque and obscure the drop position.
@{b}url_file@{ub} Path to URL database file
@{b}hotlist_file@{ub} Path to Hotlist file
Modified: trunk/netsurf/amiga/download.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/download.c?rev=1067...
==============================================================================
--- trunk/netsurf/amiga/download.c (original)
+++ trunk/netsurf/amiga/download.c Thu Jul 29 16:41:25 2010
@@ -59,7 +59,7 @@
ULONG drag_icon_width;
ULONG drag_icon_height;
-struct Window *ami_drag_icon_show(char *type, ULONG *x, ULONG *y);
+struct Window *ami_drag_icon_show(struct gui_window *g, char *type, ULONG *x, ULONG *y);
void ami_drag_icon_close(struct Window *win);
struct gui_download_window *gui_download_window_create(download_context *ctx,
@@ -337,11 +337,6 @@
if(strcmp(option_use_pubscreen,"Workbench")) return;
- gui_window_set_pointer(g,AMI_GUI_POINTER_DRAG);
- drag_save_data = c;
- drag_save_gui = g;
- drag_save = type;
-
switch(type)
{
case GUI_SAVE_OBJECT_ORIG: // object
@@ -363,16 +358,19 @@
break;
}
- drag_icon = ami_drag_icon_show(filetype, &drag_icon_width, &drag_icon_height);
+ drag_icon = ami_drag_icon_show(g, filetype, &drag_icon_width, &drag_icon_height);
+
+ drag_save_data = c;
+ drag_save_gui = g;
+ drag_save = type;
}
void gui_drag_save_selection(struct selection *s, struct gui_window *g)
{
- gui_window_set_pointer(g,AMI_GUI_POINTER_DRAG);
+ drag_icon = ami_drag_icon_show(g, "ascii", &drag_icon_width, &drag_icon_height);
+
drag_save_data = s;
drag_save = GUI_SAVE_TEXT_SELECTION;
-
- drag_icon = ami_drag_icon_show("ascii", &drag_icon_width, &drag_icon_height);
}
void ami_drag_save(struct Window *win)
@@ -493,7 +491,7 @@
ami_update_pointer(win,GUI_POINTER_DEFAULT);
}
-struct Window *ami_drag_icon_show(char *type, ULONG *x, ULONG *y)
+struct Window *ami_drag_icon_show(struct gui_window *g, char *type, ULONG *x, ULONG *y)
{
struct Window *win;
struct DiskObject *dobj = NULL;
@@ -502,6 +500,16 @@
long format = 0;
int err = 0;
int deftype = WBPROJECT;
+
+ if(option_drag_save_icons == false)
+ {
+ gui_window_set_pointer(g, AMI_GUI_POINTER_DRAG);
+ return NULL;
+ }
+ else
+ {
+ gui_window_set_pointer(g, GUI_POINTER_DEFAULT);
+ }
if(type == "drawer") deftype = WBDRAWER;
@@ -543,6 +551,8 @@
void ami_drag_icon_move(struct Window *win)
{
+ if(win == NULL) return;
+
ChangeWindowBox(win, scrn->MouseX - (drag_icon_width / 2),
scrn->MouseY - (drag_icon_height / 2),
drag_icon_width, drag_icon_height);
@@ -550,7 +560,7 @@
void ami_drag_icon_close(struct Window *win)
{
- CloseWindow(win);
+ if(win) CloseWindow(win);
drag_icon = NULL;
}
Modified: trunk/netsurf/amiga/options.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/options.h?rev=10672...
==============================================================================
--- trunk/netsurf/amiga/options.h (original)
+++ trunk/netsurf/amiga/options.h Thu Jul 29 16:41:25 2010
@@ -49,6 +49,7 @@
extern bool option_close_no_quit;
extern bool option_hide_docky_icon;
extern char *option_font_unicode;
+extern bool option_drag_save_icons;
#define EXTRA_OPTION_DEFINE \
char *option_url_file = 0; \
@@ -80,6 +81,7 @@
bool option_close_no_quit = false; \
bool option_hide_docky_icon = false; \
char *option_font_unicode = 0; \
+bool option_drag_save_icons = true; \
#define EXTRA_OPTION_TABLE \
{ "url_file", OPTION_STRING, &option_url_file }, \
@@ -110,5 +112,6 @@
{ "startup_no_window", OPTION_BOOL, &option_startup_no_window}, \
{ "close_no_quit", OPTION_BOOL, &option_close_no_quit}, \
{ "hide_docky_icon", OPTION_BOOL, &option_hide_docky_icon}, \
-{ "font_unicode", OPTION_STRING, &option_font_unicode },
+{ "font_unicode", OPTION_STRING, &option_font_unicode }, \
+{ "drag_save_icons", OPTION_BOOL, &option_drag_save_icons},
#endif
Modified: trunk/netsurf/amiga/theme.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/theme.c?rev=10672&r...
==============================================================================
--- trunk/netsurf/amiga/theme.c (original)
+++ trunk/netsurf/amiga/theme.c Thu Jul 29 16:41:25 2010
@@ -191,7 +191,7 @@
void ami_update_pointer(struct Window *win, gui_pointer_shape shape)
{
if(mouseptrcurrent == shape) return;
- if(drag_save) return;
+ if(drag_save_data) return;
if(option_use_os_pointers)
{
13 years, 1 month
r10671 chris_y - /trunk/netsurf/amiga/gui.c
by netsurf@semichrome.net
Author: chris_y
Date: Wed Jul 28 16:33:51 2010
New Revision: 10671
URL: http://source.netsurf-browser.org?rev=10671&view=rev
Log:
Show an icon under the pointer for drag saves (missed from previous commit)
Modified:
trunk/netsurf/amiga/gui.c
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=10671&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Wed Jul 28 16:33:51 2010
@@ -1003,6 +1003,9 @@
switch(result & WMHI_CLASSMASK) // class
{
case WMHI_MOUSEMOVE:
+ if(drag_icon)
+ ami_drag_icon_move(drag_icon);
+
GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER],
(ULONG *)&bbox);
@@ -1128,7 +1131,7 @@
break;
}
- if(drag_save && !gwin->mouse_state)
+ if(drag_save_data && !gwin->mouse_state)
ami_drag_save(gwin->win);
break;
13 years, 1 month
r10670 chris_y - in /trunk/netsurf/amiga: download.c download.h filetype.c
by netsurf@semichrome.net
Author: chris_y
Date: Wed Jul 28 16:33:16 2010
New Revision: 10670
URL: http://source.netsurf-browser.org?rev=10670&view=rev
Log:
Show an icon under the pointer for drag save operations. Might need disabling under
4.0.
Modified:
trunk/netsurf/amiga/download.c
trunk/netsurf/amiga/download.h
trunk/netsurf/amiga/filetype.c
Modified: trunk/netsurf/amiga/download.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/download.c?rev=1067...
==============================================================================
--- trunk/netsurf/amiga/download.c (original)
+++ trunk/netsurf/amiga/download.c Wed Jul 28 16:33:16 2010
@@ -42,6 +42,7 @@
#include "desktop/save_complete.h"
#include "utils/errors.h"
+#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
@@ -54,6 +55,12 @@
#include <gadgets/layout.h>
#include <reaction/reaction_macros.h>
+
+ULONG drag_icon_width;
+ULONG drag_icon_height;
+
+struct Window *ami_drag_icon_show(char *type, ULONG *x, ULONG *y);
+void ami_drag_icon_close(struct Window *win);
struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *gui)
@@ -326,21 +333,46 @@
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
{
+ char *filetype;
+
if(strcmp(option_use_pubscreen,"Workbench")) return;
gui_window_set_pointer(g,AMI_GUI_POINTER_DRAG);
drag_save_data = c;
drag_save_gui = g;
drag_save = type;
+
+ switch(type)
+ {
+ case GUI_SAVE_OBJECT_ORIG: // object
+ case GUI_SAVE_SOURCE:
+ filetype = ami_content_type_to_file_type(content_get_type(c));
+ break;
+ case GUI_SAVE_COMPLETE:
+ filetype = "drawer";
+ break;
+ case GUI_SAVE_OBJECT_NATIVE:
+ if(content_get_type(c) == CONTENT_SVG)
+ {
+ filetype = "dr2d";
+ }
+ else
+ {
+ filetype = "ilbm";
+ }
+ break;
+ }
+
+ drag_icon = ami_drag_icon_show(filetype, &drag_icon_width, &drag_icon_height);
}
void gui_drag_save_selection(struct selection *s, struct gui_window *g)
{
-// if(strcmp(option_use_pubscreen,"Workbench")) return;
-
gui_window_set_pointer(g,AMI_GUI_POINTER_DRAG);
drag_save_data = s;
drag_save = GUI_SAVE_TEXT_SELECTION;
+
+ drag_icon = ami_drag_icon_show("ascii", &drag_icon_width, &drag_icon_height);
}
void ami_drag_save(struct Window *win)
@@ -349,6 +381,8 @@
char path[1025],dpath[1025];
char *source_data;
ULONG source_size;
+
+ if(drag_icon) ami_drag_icon_close(drag_icon);
if(strcmp(option_use_pubscreen,"Workbench") == 0)
{
@@ -448,11 +482,76 @@
#endif
}
break;
+
+ default:
+ LOG(("Unsupported drag save operation %ld",drag_save));
+ break;
}
drag_save = 0;
drag_save_data = NULL;
ami_update_pointer(win,GUI_POINTER_DEFAULT);
+}
+
+struct Window *ami_drag_icon_show(char *type, ULONG *x, ULONG *y)
+{
+ struct Window *win;
+ struct DiskObject *dobj = NULL;
+ ULONG *icondata1;
+ ULONG width, height;
+ long format = 0;
+ int err = 0;
+ int deftype = WBPROJECT;
+
+ if(type == "drawer") deftype = WBDRAWER;
+
+ dobj = GetIconTags(NULL, ICONGETA_GetDefaultName, type,
+ ICONGETA_GetDefaultType, deftype,
+ TAG_DONE);
+
+ err = IconControl(dobj,
+ ICONCTRLA_GetWidth,&width,
+ ICONCTRLA_GetHeight,&height,
+ TAG_DONE);
+
+ *x = width;
+ *y = height;
+
+ win = OpenWindowTags(NULL,
+ WA_Left, scrn->MouseX - (width/2),
+ WA_Top, scrn->MouseY - (height/2),
+ WA_Width, width,
+ WA_Height, height,
+ WA_PubScreen, scrn,
+ WA_Borderless, TRUE,
+ WA_ToolBox, TRUE,
+ WA_StayTop, TRUE,
+ WA_Opaqueness, 128,
+ WA_OverrideOpaqueness, TRUE,
+ TAG_DONE);
+
+/* probably need layouticon and drawinfo stuff too */
+
+ DrawIconState(win->RPort, dobj, NULL, 0, 0, IDS_NORMAL,
+ ICONDRAWA_Frameless, TRUE,
+ ICONDRAWA_Borderless, TRUE,
+// ICONDRAWA_Transparency, 128,
+ TAG_DONE);
+
+ return win;
+}
+
+void ami_drag_icon_move(struct Window *win)
+{
+ ChangeWindowBox(win, scrn->MouseX - (drag_icon_width / 2),
+ scrn->MouseY - (drag_icon_height / 2),
+ drag_icon_width, drag_icon_height);
+}
+
+void ami_drag_icon_close(struct Window *win)
+{
+ CloseWindow(win);
+ drag_icon = NULL;
}
void ami_superimpose_favicon(STRPTR path, struct hlcache_handle *icon, STRPTR type)
Modified: trunk/netsurf/amiga/download.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/download.h?rev=1067...
==============================================================================
--- trunk/netsurf/amiga/download.h (original)
+++ trunk/netsurf/amiga/download.h Wed Jul 28 16:33:16 2010
@@ -45,10 +45,14 @@
int drag_save;
void *drag_save_data;
struct gui_window *drag_save_gui;
+struct Window *drag_icon;
void ami_download_window_abort(struct gui_download_window *dw);
BOOL ami_download_window_event(struct gui_download_window *dw);
void ami_drag_save(struct Window *win);
+void ami_drag_icon_move(struct Window *win);
void ami_free_download_list(struct List *dllist);
void ami_superimpose_favicon(STRPTR path, struct hlcache_handle *icon, STRPTR type);
+
+const char *ami_content_type_to_file_type(content_type type);
#endif
Modified: trunk/netsurf/amiga/filetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/filetype.c?rev=1067...
==============================================================================
--- trunk/netsurf/amiga/filetype.c (original)
+++ trunk/netsurf/amiga/filetype.c Wed Jul 28 16:33:16 2010
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include "content/fetch.h"
+#include "content/content_type.h"
#include "utils/log.h"
#include "utils/utils.h"
#include <proto/icon.h>
@@ -130,3 +131,73 @@
{
return strdup(fetch_filetype(ro_path));
}
+
+const char *ami_content_type_to_file_type(content_type type)
+{
+ switch(type)
+ {
+ case CONTENT_HTML:
+ return "html";
+ break;
+
+ case CONTENT_TEXTPLAIN:
+ return "ascii";
+ break;
+
+ case CONTENT_CSS:
+ return "css";
+ break;
+
+#ifdef WITH_JPEG
+ case CONTENT_JPEG:
+ return "jpeg";
+ break;
+#endif
+#ifdef WITH_GIF
+ case CONTENT_GIF:
+ return "gif";
+ break;
+#endif
+#ifdef WITH_BMP
+ case CONTENT_BMP:
+ return "bmp";
+ break;
+
+ case CONTENT_ICO:
+ return "ico";
+ break;
+#endif
+#if defined(WITH_MNG) || defined(WITH_PNG)
+ case CONTENT_PNG:
+ return "png";
+ break;
+#endif
+#ifdef WITH_MNG
+ case CONTENT_JNG:
+ return "jng";
+ break;
+
+ case CONTENT_MNG:
+ return "mng";
+ break;
+#endif
+#if defined(WITH_SPRITE) || defined(WITH_NSSPRITE)
+ case CONTENT_SPRITE:
+ return "rosprite";
+ break;
+#endif
+
+ case CONTENT_DIRECTORY:
+ return "drawer";
+ break;
+
+#if defined(WITH_NS_SVG) || defined(WITH_RSVG)
+ case CONTENT_SVG:
+ return "svg";
+ break;
+#endif
+ default:
+ return "project";
+ break;
+ }
+}
13 years, 1 month
r10669 vince - in /trunk/netsurf/gtk/res: C/ C/Messages de/ de/Messages en/ en/Messages fr/ fr/Messages it/ it/Messages nl/ nl/Messages
by netsurf@semichrome.net
Author: vince
Date: Wed Jul 28 10:26:02 2010
New Revision: 10669
URL: http://source.netsurf-browser.org?rev=10669&view=rev
Log:
Add GTK language resources
Added:
trunk/netsurf/gtk/res/C/
trunk/netsurf/gtk/res/C/Messages (with props)
trunk/netsurf/gtk/res/de/
trunk/netsurf/gtk/res/de/Messages (with props)
trunk/netsurf/gtk/res/en/
trunk/netsurf/gtk/res/en/Messages (with props)
trunk/netsurf/gtk/res/fr/
trunk/netsurf/gtk/res/fr/Messages (with props)
trunk/netsurf/gtk/res/it/
trunk/netsurf/gtk/res/it/Messages (with props)
trunk/netsurf/gtk/res/nl/
trunk/netsurf/gtk/res/nl/Messages (with props)
Added: trunk/netsurf/gtk/res/C/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/C/Messages?rev=10...
==============================================================================
--- trunk/netsurf/gtk/res/C/Messages (added)
+++ trunk/netsurf/gtk/res/C/Messages Wed Jul 28 10:26:02 2010
@@ -1,0 +1,1 @@
+link ../../../!NetSurf/Resources/en/Messages
Propchange: trunk/netsurf/gtk/res/C/Messages
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/gtk/res/de/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/de/Messages?rev=1...
==============================================================================
--- trunk/netsurf/gtk/res/de/Messages (added)
+++ trunk/netsurf/gtk/res/de/Messages Wed Jul 28 10:26:02 2010
@@ -1,0 +1,1 @@
+link ../../../!NetSurf/Resources/de/Messages
Propchange: trunk/netsurf/gtk/res/de/Messages
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/gtk/res/en/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/en/Messages?rev=1...
==============================================================================
--- trunk/netsurf/gtk/res/en/Messages (added)
+++ trunk/netsurf/gtk/res/en/Messages Wed Jul 28 10:26:02 2010
@@ -1,0 +1,1 @@
+link ../../../!NetSurf/Resources/en/Messages
Propchange: trunk/netsurf/gtk/res/en/Messages
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/gtk/res/fr/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/fr/Messages?rev=1...
==============================================================================
--- trunk/netsurf/gtk/res/fr/Messages (added)
+++ trunk/netsurf/gtk/res/fr/Messages Wed Jul 28 10:26:02 2010
@@ -1,0 +1,1 @@
+link ../../../!NetSurf/Resources/fr/Messages
Propchange: trunk/netsurf/gtk/res/fr/Messages
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/gtk/res/it/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/it/Messages?rev=1...
==============================================================================
--- trunk/netsurf/gtk/res/it/Messages (added)
+++ trunk/netsurf/gtk/res/it/Messages Wed Jul 28 10:26:02 2010
@@ -1,0 +1,1 @@
+link ../../../!NetSurf/Resources/it/Messages
Propchange: trunk/netsurf/gtk/res/it/Messages
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/gtk/res/nl/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/nl/Messages?rev=1...
==============================================================================
--- trunk/netsurf/gtk/res/nl/Messages (added)
+++ trunk/netsurf/gtk/res/nl/Messages Wed Jul 28 10:26:02 2010
@@ -1,0 +1,1 @@
+link ../../../!NetSurf/Resources/nl/Messages
Propchange: trunk/netsurf/gtk/res/nl/Messages
------------------------------------------------------------------------------
svn:special = *
13 years, 1 month
r10668 vince - in /trunk/netsurf: ./ desktop/ gtk/ gtk/dialogs/ utils/
by netsurf@semichrome.net
Author: vince
Date: Wed Jul 28 10:22:44 2010
New Revision: 10668
URL: http://source.netsurf-browser.org?rev=10668&view=rev
Log:
Clean up how GTK frontend finds resources
Added:
trunk/netsurf/utils/findresource.c
trunk/netsurf/utils/findresource.h
Modified:
trunk/netsurf/Makefile.sources
trunk/netsurf/desktop/netsurf.c
trunk/netsurf/gtk/dialogs/gtk_options.c
trunk/netsurf/gtk/gtk_download.c
trunk/netsurf/gtk/gtk_download.h
trunk/netsurf/gtk/gtk_gui.c
trunk/netsurf/gtk/gtk_gui.h
trunk/netsurf/gtk/gtk_history.c
trunk/netsurf/gtk/gtk_history.h
trunk/netsurf/gtk/gtk_tabs.c
trunk/netsurf/utils/messages.c
Modified: trunk/netsurf/Makefile.sources
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile.sources?rev=1066...
==============================================================================
--- trunk/netsurf/Makefile.sources (original)
+++ trunk/netsurf/Makefile.sources Wed Jul 28 10:22:44 2010
@@ -11,8 +11,8 @@
S_RENDER := box.c box_construct.c box_normalise.c directory.c favicon.c \
font.c form.c html.c html_interaction.c html_redraw.c \
hubbub_binding.c imagemap.c layout.c list.c table.c textplain.c
-S_UTILS := base64.c filename.c hashtable.c http.c locale.c \
- messages.c talloc.c url.c utf8.c utils.c useragent.c
+S_UTILS := base64.c filename.c hashtable.c http.c locale.c messages.c \
+ talloc.c url.c utf8.c utils.c useragent.c findresource.c
S_DESKTOP := knockout.c options.c plot_style.c print.c search.c \
searchweb.c scroll.c textarea.c tree.c version.c
Modified: trunk/netsurf/desktop/netsurf.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/netsurf.c?rev=106...
==============================================================================
--- trunk/netsurf/desktop/netsurf.c (original)
+++ trunk/netsurf/desktop/netsurf.c Wed Jul 28 10:22:44 2010
@@ -151,10 +151,7 @@
LOG(("Using '%s' for Options file", options));
options_read(options);
- if (messages != NULL) {
- LOG(("Using '%s' as Messages file", messages));
- messages_load(messages);
- }
+ messages_load(messages);
lwc_initialise(netsurf_lwc_alloc, NULL, 0);
Modified: trunk/netsurf/gtk/dialogs/gtk_options.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/dialogs/gtk_options.c...
==============================================================================
--- trunk/netsurf/gtk/dialogs/gtk_options.c (original)
+++ trunk/netsurf/gtk/dialogs/gtk_options.c Wed Jul 28 10:22:44 2010
@@ -136,11 +136,9 @@
GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent)
{
- char glade_location[strlen(res_dir_location) + SLEN("options.glade")
- + 1];
- sprintf(glade_location, "%soptions.glade", res_dir_location);
- LOG(("Using '%s' as Glade template file", glade_location));
- gladeFile = glade_xml_new(glade_location, NULL, NULL);
+ gladeFile = glade_xml_new(glade_options_file_location, NULL, NULL);
+ if (gladeFile == NULL)
+ return NULL;
current_browser = bw;
wndPreferences = GTK_DIALOG(glade_xml_get_widget(gladeFile,
@@ -288,7 +286,6 @@
void nsgtk_options_load(void)
{
GtkBox *box;
- char languagefile[strlen(res_dir_location) + SLEN("languages") + 1];
const char *default_accept_language =
option_accept_language ? option_accept_language : "en";
int combo_row_count = 0;
@@ -301,33 +298,33 @@
box = GTK_BOX(glade_xml_get_widget(gladeFile, "combolanguagevbox"));
comboLanguage = gtk_combo_box_new_text();
- sprintf(languagefile, "%slanguages", res_dir_location);
-
/* Populate combobox from languages file */
- fp = fopen((const char *) languagefile, "r");
- if (fp == NULL) {
+ if ((languages_file_location != NULL) &&
+ ((fp = fopen(languages_file_location, "r")) != NULL)) {
+ LOG(("Used %s for languages", languages_file_location));
+ while (fgets(buf, sizeof(buf), fp)) {
+ /* Ignore blank lines */
+ if (buf[0] == '\0')
+ continue;
+
+ /* Remove trailing \n */
+ buf[strlen(buf) - 1] = '\0';
+
+ gtk_combo_box_append_text(GTK_COMBO_BOX(comboLanguage), buf);
+
+ if (strcmp(buf, default_accept_language) == 0)
+ active_language = combo_row_count;
+
+ combo_row_count++;
+ }
+
+ fclose(fp);
+ } else {
LOG(("Failed opening languages file"));
- warn_user("FileError", (const char *) languagefile);
- return;
- }
-
- while (fgets(buf, sizeof(buf), fp)) {
- /* Ignore blank lines */
- if (buf[0] == '\0')
- continue;
-
- /* Remove trailing \n */
- buf[strlen(buf) - 1] = '\0';
-
- gtk_combo_box_append_text(GTK_COMBO_BOX(comboLanguage), buf);
-
- if (strcmp(buf, default_accept_language) == 0)
- active_language = combo_row_count;
-
- combo_row_count++;
- }
-
- fclose(fp);
+ warn_user("FileError", languages_file_location);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(comboLanguage), "en");
+ }
+
gtk_combo_box_set_active(GTK_COMBO_BOX(comboLanguage), active_language);
/** \todo localisation */
Modified: trunk/netsurf/gtk/gtk_download.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_download.c?rev=10...
==============================================================================
--- trunk/netsurf/gtk/gtk_download.c (original)
+++ trunk/netsurf/gtk/gtk_download.c Wed Jul 28 10:22:44 2010
@@ -36,7 +36,6 @@
#include "gtk/gtk_compat.h"
#define UPDATE_RATE 500 /* In milliseconds */
-#define GLADE_NAME "downloads.glade"
static GtkWindow *nsgtk_download_window, *nsgtk_download_parent;
static GtkProgressBar *nsgtk_download_progress_bar;
@@ -85,12 +84,14 @@
-void nsgtk_download_init()
-{
- char glade_location[strlen(res_dir_location) + SLEN(GLADE_NAME) + 1];
- sprintf(glade_location, "%s" GLADE_NAME, res_dir_location);
- GladeXML *gladeFile = glade_xml_new(glade_location, NULL, NULL);
-
+bool nsgtk_download_init()
+{
+ GladeXML *gladeFile;
+
+ gladeFile = glade_xml_new(glade_downloads_file_location, NULL, NULL);
+ if (gladeFile == NULL)
+ return false;
+
nsgtk_download_buttons =
glade_xml_get_widget_prefix(gladeFile, "button");
nsgtk_download_progress_bar = GTK_PROGRESS_BAR(glade_xml_get_widget(
@@ -150,7 +151,8 @@
nsgtk_download_store_cancel_item);
g_signal_connect(G_OBJECT(nsgtk_download_window), "delete-event",
G_CALLBACK(nsgtk_download_hide), NULL);
-
+
+ return true;
}
void nsgtk_download_destroy ()
Modified: trunk/netsurf/gtk/gtk_download.h
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_download.h?rev=10...
==============================================================================
--- trunk/netsurf/gtk/gtk_download.h (original)
+++ trunk/netsurf/gtk/gtk_download.h Wed Jul 28 10:22:44 2010
@@ -72,7 +72,7 @@
typedef void (*nsgtk_download_selection_action)(struct gui_download_window *dl);
-void nsgtk_download_init(void);
+bool nsgtk_download_init(void);
void nsgtk_download_destroy (void);
bool nsgtk_check_for_downloads(GtkWindow *parent);
void nsgtk_download_show(GtkWindow *parent);
Modified: trunk/netsurf/gtk/gtk_gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_gui.c?rev=10668&r...
==============================================================================
--- trunk/netsurf/gtk/gtk_gui.c (original)
+++ trunk/netsurf/gtk/gtk_gui.c Wed Jul 28 10:22:44 2010
@@ -65,6 +65,7 @@
#include "gtk/gtk_filetype.h"
#include "gtk/gtk_download.h"
#include "gtk/gtk_schedule.h"
+
#include "render/box.h"
#include "render/form.h"
#include "render/html.h"
@@ -73,35 +74,34 @@
#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "utils/findresource.h"
char *default_stylesheet_url;
char *quirks_stylesheet_url;
char *adblock_stylesheet_url;
char *options_file_location;
+char *toolbar_indices_file_location;
+char *res_dir_location;
+char *print_options_file_location;
+char *languages_file_location;
+
char *glade_netsurf_file_location;
char *glade_password_file_location;
char *glade_warning_file_location;
char *glade_login_file_location;
char *glade_ssl_file_location;
char *glade_toolbar_file_location;
-char *toolbar_indices_file_location;
-char *res_dir_location;
-char *print_options_file_location;
+char *glade_downloads_file_location;
+char *glade_history_file_location;
+char *glade_options_file_location;
GtkWindow *wndWarning;
-GladeXML *gladeNetsurf;
-GladeXML *gladePassword;
-GladeXML *gladeWarning;
-GladeXML *gladeLogin;
-GladeXML *gladeSsl;
+GtkWidget *widWarning;
static GtkWidget *select_menu;
static struct browser_window *select_menu_bw;
static struct form_control *select_menu_control;
-static void nsgtk_init_glade(void);
-static void nsgtk_check_homedir(void);
-static bool nsgtk_throbber_init(int framec);
static void nsgtk_ssl_accept(GtkButton *w, gpointer data);
static void nsgtk_ssl_reject(GtkButton *w, gpointer data);
static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
@@ -113,190 +113,222 @@
#define THROBBER_FRAMES 9
+#define MAX_RESPATH 128 /* maximum number of elements in the resource vector */
+
+/* expand ${} in a string into environment variables */
static char *
-nsgtk_vsfindfile(char *str, const char *format, va_list ap)
-{
- char *realpathname;
- char *pathname;
- int len;
-
- pathname = malloc(PATH_MAX);
- if (pathname == NULL)
- return NULL; /* unable to allocate memory */
-
- len = vsnprintf(pathname, PATH_MAX, format, ap);
-
- if ((len < 0) || (len >= PATH_MAX)) {
- /* error or output exceeded PATH_MAX length so
- * operation is doomed to fail.
- */
- free(pathname);
+expand_path(const char *path)
+{
+ char *exp = strdup(path);
+ int explen;
+ int cstart = -1;
+ int cloop = 0;
+ char *envv;
+ int envlen;
+ int replen; /* length of replacement */
+
+ if (exp == NULL)
return NULL;
- }
-
- realpathname = realpath(pathname, str);
-
- free(pathname);
-
- if (realpathname != NULL) {
- /* sucessfully expanded pathname */
- if (access(realpathname, R_OK) != 0) {
- /* unable to read the file */
- return NULL;
- }
- }
-
- return realpathname;
-}
+
+ explen = strlen(exp) + 1;
+
+ while (exp[cloop] != 0) {
+ if ((exp[cloop] == '$') &&
+ (exp[cloop + 1] == '{')) {
+ cstart = cloop;
+ cloop++;
+ }
+
+ if ((cstart != -1) &&
+ (exp[cloop] == '}')) {
+ replen = cloop - cstart;
+ exp[cloop] = 0;
+ envv = getenv(exp + cstart + 2);
+ if (envv == NULL) {
+ memmove(exp + cstart,
+ exp + cloop + 1,
+ explen - cloop - 1);
+ explen -= replen;
+ } else {
+ envlen = strlen(envv);
+ exp = realloc(exp, explen + envlen - replen);
+ memmove(exp + cstart + envlen,
+ exp + cloop + 1,
+ explen - cloop - 1);
+ memmove(exp + cstart, envv, envlen);
+ explen += envlen - replen;
+ }
+ cloop -= replen;
+ cstart = -1;
+ }
+
+ cloop++;
+ }
+
+ return exp;
+}
+
+/* convert a colon separated list of path elements into a string vector */
+static char **
+path_to_strvec(const char *path)
+{
+ char **strvec;
+ int strc = 0;
+
+ strvec = calloc(MAX_RESPATH, sizeof(char *));
+ if (strvec == NULL)
+ return NULL;
+
+ strvec[strc] = expand_path(path);
+ if (strvec[strc] == NULL) {
+ free(strvec);
+ return NULL;
+ }
+ strc++;
+
+ strvec[strc] = strchr(strvec[0], ':');
+ while ((strc < (MAX_RESPATH - 2)) &&
+ (strvec[strc] != NULL)) {
+ /* null terminate previous entry */
+ *strvec[strc] = 0;
+ strvec[strc]++;
+
+ /* skip colons */
+ while (*strvec[strc] == ':')
+ strvec[strc]++;
+
+ if (*strvec[strc] == 0)
+ break; /* string is terminated */
+
+ strc++;
+
+ strvec[strc] = strchr(strvec[strc - 1], ':');
+ }
+
+ return strvec;
+}
+
+
+/** Create an array of valid paths to search for resources.
+ *
+ * The idea is that all the complex path computation to find resources
+ * is performed here, once, rather than every time a resource is
+ * searched for.
+ */
+static char **
+nsgtk_init_resource(const char *resource_path)
+{
+ const gchar * const *langv;
+ char **pathv; /* resource path string vector */
+ char **respath; /* resource paths vector */
+
+ pathv = path_to_strvec(resource_path);
+
+ langv = g_get_language_names();
+
+ respath = findresource_generate(pathv, langv);
+
+ free(pathv[0]);
+ free(pathv);
+
+ return respath;
+}
+
+/* This is an ugly hack to just get the new-style throbber going.
+ * It, along with the PNG throbber loader, need making more generic.
+ */
+static bool nsgtk_throbber_init(char **respath, int framec)
+{
+ char **filenames;
+ char targetname[PATH_MAX];
+ int frame_num;
+ bool ret;
+
+ filenames = calloc(framec, sizeof(char *));
+ if (filenames == NULL)
+ return false;
+
+ for (frame_num = 0; frame_num < framec; frame_num++) {
+ snprintf(targetname, PATH_MAX, "throbber/throbber%d.png", frame_num);
+ filenames[frame_num] = findresource(respath, targetname);
+ }
+
+ ret = nsgtk_throbber_initialise_from_png(frame_num, filenames);
+
+ for (frame_num = 0; frame_num < framec; frame_num++) {
+ free(filenames[frame_num]);
+ }
+ free(filenames);
+
+ return ret;
+
+}
+
+#define NEW_GLADE_ERROR_SIZE 128
static char *
-nsgtk_sfindfile(char *str, const char *format, ...)
-{
- va_list ap;
- char *ret;
-
- va_start(ap, format);
- ret = nsgtk_vsfindfile(str, format, ap);
- va_end(ap);
-
- return ret;
-}
-
-/* create a normalised path
- *
- * if the file described by the format exists and is accessible the
- * normalised path is returned or NULL if not.
+nsgtk_new_glade(char **respath, const char *name, GladeXML **pglade)
+{
+ GladeXML *newglade;
+ char *filepath;
+ char errorstr[NEW_GLADE_ERROR_SIZE];
+ char resname[PATH_MAX];
+
+ snprintf(resname, PATH_MAX, "%s.glade", name);
+
+ filepath = findresource(respath, resname);
+ if (filepath == NULL) {
+ snprintf(errorstr, NEW_GLADE_ERROR_SIZE,
+ "Unable to locate %s glade template file.\n", name);
+ die(errorstr);
+ }
+
+ newglade = glade_xml_new(filepath, NULL, NULL);
+ if (newglade == NULL) {
+ snprintf(errorstr, NEW_GLADE_ERROR_SIZE,
+ "Unable to load glade %s window definitions.\n", name);
+
+ die(errorstr);
+ }
+ glade_xml_signal_autoconnect(newglade);
+
+ LOG(("Using '%s' as %s glade template file", filepath, name));
+
+ if (pglade != NULL) {
+ *pglade = newglade;
+ }
+
+ return filepath;
+}
+
+/**
+ * Load definitions from glade files.
*/
-static char *
-nsgtk_findfile(const char *format, ...)
-{
- char *str;
- char *ret;
- va_list ap;
-
- str = malloc(PATH_MAX);
- if (str == NULL)
- return NULL; /* unable to allocate memory */
-
- va_start(ap, format);
- ret = nsgtk_vsfindfile(str, format, ap);
- va_end(ap);
-
- if (ret == NULL)
- free(str);
-
- return ret;
-}
-
-
-static char *
-nsgtk_find_messages(void)
-{
- int lang_loop = 0;
- char *buf;
- const gchar * const *lang_list;
-
- lang_list = g_get_language_names();
-
- while (lang_list[lang_loop] != NULL) {
- buf = nsgtk_findfile("%s/%s/Messages", getenv("NETSURFRES"), lang_list[lang_loop]);
-
- if (buf != NULL)
- return buf;
-
- buf = nsgtk_findfile("%s/%s/Messages", GTK_RESPATH, lang_list[lang_loop]);
- if (buf != NULL)
- return buf;
-
- lang_loop++;
- }
-
- buf = nsgtk_findfile("./gtk/res/en/Messages");
- if (buf != NULL)
- return buf;
-
- buf = strdup("./gtk/res/messages");
-
- return buf;
-}
-
-/**
- * Locate a shared resource file by searching known places in order.
- *
- * \param buf buffer to write to. must be at least PATH_MAX chars. May be NULL and routine will allocate string which must be freed by caller.
- * \param filename file to look for
- * \param def default to return if file not found
- * \return buf
- *
- * Search order is: ~/.netsurf/, $NETSURFRES/ (where NETSURFRES is an
- * environment variable), and finally the path specified by the define
- * GTK_RESPATH.
- */
-static char *
-nsgtk_find_resource(char *buf, const char *filename, const char *def)
-{
- if (buf == NULL) {
- buf = malloc(PATH_MAX);
- if (buf == NULL)
- return NULL;
- }
-
- if (nsgtk_sfindfile(buf, "%s/.netsurf/%s", getenv("HOME"), filename) != NULL)
- return buf;
-
- if (nsgtk_sfindfile(buf, "%s/%s", getenv("NETSURFRES"), filename) != NULL)
- return buf;
-
- if (nsgtk_sfindfile(buf, "%s/%s", GTK_RESPATH, filename) != NULL)
- return buf;
-
-
- if (def[0] == '~') {
- char t[PATH_MAX];
- snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1);
- if (realpath(t, buf) == NULL) {
- strcpy(buf, t);
- }
- } else {
- if (realpath(def, buf) == NULL) {
- strcpy(buf, def);
- }
- }
-
- return buf;
-}
-
-
-/**
- * Initialize GTK interface.
- */
-static void gui_init(int argc, char** argv)
-{
+static void
+nsgtk_init_glade(char **respath)
+{
+ GladeXML *gladeWarning;
+
+ glade_init();
+
+ glade_netsurf_file_location = nsgtk_new_glade(respath, "netsurf", NULL);
+ glade_password_file_location = nsgtk_new_glade(respath, "password", NULL);
+ glade_login_file_location = nsgtk_new_glade(respath, "login", NULL);
+ glade_ssl_file_location = nsgtk_new_glade(respath, "ssl", NULL);
+ glade_toolbar_file_location = nsgtk_new_glade(respath, "toolbar", NULL);
+ glade_downloads_file_location = nsgtk_new_glade(respath, "downloads", NULL);
+ glade_history_file_location = nsgtk_new_glade(respath, "history", NULL);
+ glade_options_file_location = nsgtk_new_glade(respath, "options", NULL);
+
+ glade_warning_file_location = nsgtk_new_glade(respath, "warning", &gladeWarning);
+ wndWarning = GTK_WINDOW(glade_xml_get_widget(gladeWarning, "wndWarning"));
+ widWarning = glade_xml_get_widget(gladeWarning, "labelWarning");
+}
+
+static void check_options(char **respath)
+{
+ char *hdir = getenv("HOME");
char buf[PATH_MAX];
- struct browser_window *bw;
- const char *addr = NETSURF_HOMEPAGE;
-
- nsgtk_check_homedir();
-
- nsgtk_find_resource(buf, "netsurf.glade", "./gtk/res/netsurf.glade");
- buf[strlen(buf) - 13] = 0;
- LOG(("Using '%s' as Resources directory", buf));
- res_dir_location = strdup(buf);
-
- nsgtk_init_glade();
-
- nsgtk_find_resource(buf, "Aliases", "./gtk/res/Aliases");
- LOG(("Using '%s' as Aliases file", buf));
- if (hubbub_initialise(buf, ns_realloc, NULL) != HUBBUB_OK)
- die("Unable to initialise HTML parsing library.\n");
-
- nsgtk_find_resource(buf, "netsurf.xpm", "./gtk/res/netsurf.xpm");
- gtk_window_set_default_icon_from_file(buf, NULL);
-
- nsgtk_completion_init();
-
- if (nsgtk_throbber_init(THROBBER_FRAMES) == false)
- die("Unable to load throbber image.\n");
option_core_select_menu = true;
@@ -309,6 +341,48 @@
if (option_toolbar_status_width < 1500) {
option_toolbar_status_width = 6667;
}
+
+ /* user options should be stored in the users home directory */
+ snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir);
+ options_file_location = strdup(buf);
+
+ /* VRS - I do not beleive these setting should search the
+ * resource path, they should just be set to the default
+ * values!
+ */
+ if (!option_cookie_file) {
+ sfindresourcedef(respath, buf, "Cookies", "~/.netsurf/");
+ LOG(("Using '%s' as Cookies file", buf));
+ option_cookie_file = strdup(buf);
+ }
+ if (!option_cookie_jar) {
+ sfindresourcedef(respath, buf, "Cookies", "~/.netsurf/");
+ LOG(("Using '%s' as Cookie Jar file", buf));
+ option_cookie_jar = strdup(buf);
+ }
+ if (!option_cookie_file || !option_cookie_jar)
+ die("Failed initialising cookie options");
+
+ if (!option_url_file) {
+ sfindresourcedef(respath, buf, "URLs", "~/.netsurf/");
+ LOG(("Using '%s' as URL file", buf));
+ option_url_file = strdup(buf);
+ }
+
+ if (!option_ca_path) {
+ sfindresourcedef(respath, buf, "certs", "/etc/ssl/");
+ LOG(("Using '%s' as certificate path", buf));
+ option_ca_path = strdup(buf);
+ }
+
+ if (!option_downloads_directory) {
+ LOG(("Using '%s' as download directory", hdir));
+ option_downloads_directory = hdir;
+ }
+
+ sfindresourcedef(respath, buf, "Print", "~/.netsurf/");
+ LOG(("Using '%s' as Print Settings file", buf));
+ print_options_file_location = strdup(buf);
/* check what the font settings are, setting them to a default font
* if they're not set - stops Pango whinging
@@ -320,75 +394,96 @@
SETFONTDEFAULT(option_font_cursive, "Serif");
SETFONTDEFAULT(option_font_fantasy, "Serif");
- if (!option_cookie_file) {
- nsgtk_find_resource(buf, "Cookies", "~/.netsurf/Cookies");
- LOG(("Using '%s' as Cookies file", buf));
- option_cookie_file = strdup(buf);
- }
- if (!option_cookie_jar) {
- nsgtk_find_resource(buf, "Cookies", "~/.netsurf/Cookies");
- LOG(("Using '%s' as Cookie Jar file", buf));
- option_cookie_jar = strdup(buf);
- }
- if (!option_cookie_file || !option_cookie_jar)
- die("Failed initialising cookie options");
-
- if (!option_url_file) {
- nsgtk_find_resource(buf, "URLs", "~/.netsurf/URLs");
- LOG(("Using '%s' as URL file", buf));
- option_url_file = strdup(buf);
- }
-
- if (!option_ca_path) {
- nsgtk_find_resource(buf, "certs", "/etc/ssl/certs");
- LOG(("Using '%s' as certificate path", buf));
- option_ca_path = strdup(buf);
- }
-
- if (!option_downloads_directory) {
- char *home = getenv("HOME");
- LOG(("Using '%s' as download directory", home));
- option_downloads_directory = home;
- }
-
-
- nsgtk_find_resource(buf, "mime.types", "/etc/mime.types");
+}
+
+/**
+ * Initialize GTK interface.
+ */
+static void gui_init(int argc, char** argv, char **respath)
+{
+ char buf[PATH_MAX];
+ struct browser_window *bw;
+ const char *addr = NETSURF_HOMEPAGE;
+ char *resource_filename;
+
+ /* check user options */
+ check_options(respath);
+
+ /* Character encoding mapping file *must* be available */
+ resource_filename = findresource(respath, "Aliases");
+ if (resource_filename == NULL)
+ die("Unable to locate file for character encoding mapping\n");
+ LOG(("Using '%s' as Aliases file", resource_filename));
+ if (hubbub_initialise(resource_filename, ns_realloc, NULL) != HUBBUB_OK)
+ die("Unable to initialise HTML parsing library.\n");
+ free(resource_filename);
+
+ /* Obtain resources path location.
+ *
+ * Uses the directory the languages file was found in,
+ * previously the location of the glade files was used,
+ * however these may be translated which breaks things
+ * relying on res_dir_location.
+ */
+ resource_filename = findresource(respath, "languages");
+ resource_filename[strlen(resource_filename) - 9] = 0;
+ res_dir_location = resource_filename;
+
+ /* languages file */
+ languages_file_location = findresource(respath, "languages");
+
+ /* initialise the glade templates */
+ nsgtk_init_glade(respath);
+
+ /* set default icon if its available */
+ resource_filename = findresource(respath, "netsurf.xpm");
+ if (resource_filename != NULL) {
+ gtk_window_set_default_icon_from_file(resource_filename, NULL);
+ free(resource_filename);
+ }
+
+ /* Search engine sources */
+ search_engines_file_location = findresource(respath, "SearchEngines");
+ LOG(("Using '%s' as Search Engines file", search_engines_file_location));
+
+ /* Default Icon */
+ search_default_ico_location = findresource(respath, "default.ico");
+ LOG(("Using '%s' as default search ico", search_default_ico_location));
+
+ /* Toolbar inicies file */
+ toolbar_indices_file_location = findresource(respath, "toolbarIndices");
+ LOG(("Using '%s' as custom toolbar settings file", toolbar_indices_file_location));
+
+ /* load throbber images */
+ if (nsgtk_throbber_init(respath, THROBBER_FRAMES) == false)
+ die("Unable to load throbber image.\n");
+
+ /* Initialise completions - cannot fail */
+ nsgtk_completion_init();
+
+ sfindresourcedef(respath, buf, "mime.types", "/etc/");
gtk_fetch_filetype_init(buf);
/* set up stylesheet urls */
- nsgtk_find_resource(buf, "gtkdefault.css", "./gtk/res/gtkdefault.css");
+ sfindresourcedef(respath, buf, "gtkdefault.css", "./gtk/res/");
default_stylesheet_url = path_to_url(buf);
LOG(("Using '%s' as Default CSS URL", default_stylesheet_url));
- nsgtk_find_resource(buf, "quirks.css", "./gtk/res/quirks.css");
+ sfindresourcedef(respath, buf, "quirks.css", "./gtk/res/");
quirks_stylesheet_url = path_to_url(buf);
- nsgtk_find_resource(buf, "adblock.css", "./gtk/res/adblock.css");
+ sfindresourcedef(respath, buf, "adblock.css", "./gtk/res/");
adblock_stylesheet_url = path_to_url(buf);
LOG(("Using '%s' as AdBlock CSS URL", adblock_stylesheet_url));
- nsgtk_find_resource(buf, "Print", "~/.netsurf/Print");
- LOG(("Using '%s' as Print Settings file", buf));
- print_options_file_location = strdup(buf);
-
- nsgtk_find_resource(buf, "SearchEngines", "./gtk/res/SearchEngines");
- LOG(("Using '%s' as Search Engines file", buf));
- search_engines_file_location = strdup(buf);
-
- nsgtk_find_resource(buf, "default.ico", "./gtk/res/default.ico");
- LOG(("Using '%s' as default search ico", buf));
- search_default_ico_location = strdup(buf);
-
- nsgtk_find_resource(buf, "toolbarIndices", "./gtk/res/toolbarIndices");
- LOG(("Using '%s' as custom toolbar settings file", buf));
- toolbar_indices_file_location = strdup(buf);
-
urldb_load(option_url_file);
urldb_load_cookies(option_cookie_file);
- nsgtk_history_init();
- nsgtk_download_init();
-
+ if (nsgtk_history_init() == false)
+ die("Unable to initialise history window.\n");
+
+ if (nsgtk_download_init() == false)
+ die("Unable to initialise download window.\n");
if (option_homepage_url != NULL && option_homepage_url[0] != '\0')
addr = option_homepage_url;
@@ -397,71 +492,33 @@
addr = argv[1];
/* Last step of initialization. Opens the main browser window. */
-
bw = browser_window_create(addr, 0, 0, true, false);
-
}
/**
- * Load definitions from glade files.
+ * Check that ~/.netsurf/ exists, and if it doesn't, create it.
*/
-void nsgtk_init_glade(void)
-{
+static void nsgtk_check_homedir(void)
+{
+ char *hdir = getenv("HOME");
char buf[PATH_MAX];
- glade_init();
-
- nsgtk_find_resource(buf, "netsurf.glade", "./gtk/res/netsurf.glade");
- LOG(("Using '%s' as Netsurf glade template file", buf));
- glade_netsurf_file_location = strdup(buf);
-
- nsgtk_find_resource(buf, "password.glade", "./gtk/res/password.glade");
- LOG(("Using '%s' as password glade template file", buf));
- glade_password_file_location = strdup(buf);
-
- nsgtk_find_resource(buf, "warning.glade", "./gtk/res/warning.glade");
- LOG(("Using '%s' as warning glade template file", buf));
- glade_warning_file_location = strdup(buf);
-
- nsgtk_find_resource(buf, "login.glade", "./gtk/res/login.glade");
- LOG(("Using '%s' as login glade template file", buf));
- glade_login_file_location = strdup(buf);
-
- nsgtk_find_resource(buf, "ssl.glade", "./gtk/res/ssl.glade");
- LOG(("Using '%s' as ssl glade template file", buf));
- glade_ssl_file_location = strdup(buf);
-
- gladeWarning = glade_xml_new(glade_warning_file_location, NULL, NULL);
- if (gladeWarning == NULL)
- die("Unable to load glade warning window definitions.\n");
- glade_xml_signal_autoconnect(gladeWarning);
-
- gladeNetsurf = glade_xml_new(glade_netsurf_file_location, NULL, NULL);
- if (gladeNetsurf == NULL)
- die("Unable to load glade Netsurf window definitions.\n");
- glade_xml_signal_autoconnect(gladeNetsurf);
-
- gladePassword = glade_xml_new(glade_password_file_location, NULL, NULL);
- if (gladePassword == NULL)
- die("Unable to load glade password window definitions.\n");
- glade_xml_signal_autoconnect(gladePassword);
-
- gladeLogin = glade_xml_new(glade_login_file_location, NULL, NULL);
- if (gladeLogin == NULL)
- die("Unable to load glade login window definitions.\n");
- glade_xml_signal_autoconnect(gladeLogin);
-
- gladeSsl = glade_xml_new(glade_ssl_file_location, NULL, NULL);
- if (gladeSsl == NULL)
- die("Unable to load glade ssl window definitions.\n");
- glade_xml_signal_autoconnect(gladeSsl);
-
- nsgtk_find_resource(buf, "toolbar.glade", "./gtk/res/toolbar.glade");
- LOG(("Using '%s' as glade toolbar file", buf));
- glade_toolbar_file_location = strdup(buf);
-
- wndWarning = GTK_WINDOW(glade_xml_get_widget(gladeWarning, "wndWarning"));
+ if (hdir == NULL) {
+ /* we really can't continue without a home directory. */
+ LOG(("HOME is not set - nowhere to store state!"));
+ die("NetSurf requires HOME to be set in order to run.\n");
+
+ }
+
+ snprintf(buf, PATH_MAX, "%s/.netsurf", hdir);
+ if (access(buf, F_OK) != 0) {
+ LOG(("You don't have a ~/.netsurf - creating one for you."));
+ if (mkdir(buf, 0777) == -1) {
+ LOG(("Unable to create %s", buf));
+ die("NetSurf requires ~/.netsurf to exist, but it cannot be created.\n");
+ }
+ }
}
/**
@@ -469,8 +526,14 @@
*/
int main(int argc, char** argv)
{
- char options[PATH_MAX];
char *messages;
+ char *options;
+ char **respaths;
+
+ /* check home directory is available */
+ nsgtk_check_homedir();
+
+ respaths = nsgtk_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res");
/* Some modern distributions can set ALL_PROXY/all_proxy if configured
* to by the user. Due to a bug in many versions of libcurl
@@ -488,21 +551,21 @@
/* set standard error to be non-buffering */
setbuf(stderr, NULL);
- nsgtk_find_resource(options, "Choices", "~/.netsurf/Choices");
- options_file_location = strdup(options);
-
- messages = nsgtk_find_messages();
-
- /* initialise netsurf */
+ options = findresource(respaths, "Choices");
+
+ messages = findresource(respaths, "Messages");
+
netsurf_init(&argc, &argv, options, messages);
- gui_init(argc, argv);
+ free(messages);
+ free(options);
+
+ gui_init(argc, argv, respaths);
netsurf_main_loop();
netsurf_exit();
- free(messages);
return 0;
}
@@ -598,64 +661,9 @@
-/**
- * Check that ~/.netsurf/ exists, and if it doesn't, create it.
- */
-void nsgtk_check_homedir(void)
-{
- char *hdir = getenv("HOME");
- char buf[BUFSIZ];
-
- if (hdir == NULL) {
- /* we really can't continue without a home directory. */
- LOG(("HOME is not set - nowhere to store state!"));
- die("NetSurf requires HOME to be set in order to run.\n");
-
- }
-
- snprintf(buf, BUFSIZ, "%s/.netsurf", hdir);
- if (access(buf, F_OK) != 0) {
- LOG(("You don't have a ~/.netsurf - creating one for you."));
- if (mkdir(buf, 0777) == -1) {
- LOG(("Unable to create %s", buf));
- die("NetSurf requires ~/.netsurf to exist, but it cannot be created.\n");
- }
- }
-}
-
-
-
-/* This is an ugly hack to just get the new-style throbber going.
- * It, along with the PNG throbber loader, need making more generic.
- */
-bool nsgtk_throbber_init(int framec)
-{
- char **filenames;
- char targetname[PATH_MAX];
- char targetdefault[PATH_MAX];
- int frame_num;
- bool ret;
-
- filenames = calloc(framec, sizeof(char *));
- if (filenames == NULL)
- return false;
-
- for (frame_num = 0; frame_num < framec; frame_num++) {
- snprintf(targetname, PATH_MAX, "throbber/throbber%d.png", frame_num);
- snprintf(targetdefault, PATH_MAX, "./gtk/res/%s", targetname);
- filenames[frame_num] = nsgtk_find_resource(NULL, targetname, targetdefault);
- }
-
- ret = nsgtk_throbber_initialise_from_png(frame_num, filenames);
-
- for (frame_num = 0; frame_num < framec; frame_num++) {
- free(filenames[frame_num]);
- }
- free(filenames);
-
- return ret;
-
-}
+
+
+
static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
@@ -726,7 +734,7 @@
detail ? detail : "");
buf[sizeof(buf) - 1] = 0;
- gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(gladeWarning, "labelWarning")), buf);
+ gtk_label_set_text(GTK_LABEL(widWarning), buf);
gtk_widget_show_all(GTK_WIDGET(wndWarning));
}
Modified: trunk/netsurf/gtk/gtk_gui.h
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_gui.h?rev=10668&r...
==============================================================================
--- trunk/netsurf/gtk/gtk_gui.h (original)
+++ trunk/netsurf/gtk/gtk_gui.h Wed Jul 28 10:22:44 2010
@@ -31,19 +31,19 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
-extern GladeXML *gladeNetsurf;
-extern GladeXML *gladePassword;
-extern GladeXML *gladeWarning;
-extern GladeXML *gladeLogin;
-extern GladeXML *gladeSsl;
extern char *glade_netsurf_file_location;
extern char *glade_password_file_location;
extern char *glade_warning_file_location;
extern char *glade_login_file_location;
extern char *glade_ssl_file_location;
extern char *glade_toolbar_file_location;
+extern char *glade_downloads_file_location;
+extern char *glade_history_file_location;
+extern char *glade_options_file_location;
+
+extern char *languages_file_location;
extern char *toolbar_indices_file_location;
-extern char *options_file_location;
+extern char *options_file_location; /**< location where user options are written */
extern char *res_dir_location;
extern char *print_options_file_location;
Modified: trunk/netsurf/gtk/gtk_history.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_history.c?rev=106...
==============================================================================
--- trunk/netsurf/gtk/gtk_history.c (original)
+++ trunk/netsurf/gtk/gtk_history.c Wed Jul 28 10:22:44 2010
@@ -31,8 +31,6 @@
#include "gtk/gtk_window.h"
#include "gtk/gtk_bitmap.h"
-#define GLADE_NAME "history.glade"
-
enum
{
SITE_TITLE = 0,
@@ -100,20 +98,19 @@
gboolean domain);
static void nsgtk_history_scroll_top (GtkScrolledWindow *scrolled_window);
-void nsgtk_history_init(void)
+bool nsgtk_history_init(void)
{
dateToday = messages_get("DateToday");
dateYesterday = messages_get("DateYesterday");
dateAt = messages_get("DateAt");
domainAll = messages_get("DomainAll");
-
- char glade_location[strlen(res_dir_location) + SLEN(GLADE_NAME) + 1];
- sprintf(glade_location, "%s" GLADE_NAME, res_dir_location);
- gladeFile = glade_xml_new(glade_location, NULL, NULL);
+
+ gladeFile = glade_xml_new(glade_history_file_location, NULL, NULL);
+ if (gladeFile == NULL)
+ return false;
glade_xml_signal_autoconnect(gladeFile);
- wndHistory = GTK_WINDOW(glade_xml_get_widget(gladeFile,
- "wndHistory"));
+ wndHistory = GTK_WINDOW(glade_xml_get_widget(gladeFile, "wndHistory"));
nsgtk_history_init_model();
nsgtk_history_init_list();
@@ -122,6 +119,8 @@
nsgtk_history_init_treeviews();
nsgtk_history_show_all();
+
+ return true;
}
void nsgtk_history_init_model(void)
Modified: trunk/netsurf/gtk/gtk_history.h
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_history.h?rev=106...
==============================================================================
--- trunk/netsurf/gtk/gtk_history.h (original)
+++ trunk/netsurf/gtk/gtk_history.h Wed Jul 28 10:22:44 2010
@@ -39,6 +39,6 @@
GtkTreeSelection *domain_selection;
};
-void nsgtk_history_init(void);
+bool nsgtk_history_init(void);
#endif /* __NSGTK_HISTORY_H__ */
Modified: trunk/netsurf/gtk/gtk_tabs.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_tabs.c?rev=10668&...
==============================================================================
--- trunk/netsurf/gtk/gtk_tabs.c (original)
+++ trunk/netsurf/gtk/gtk_tabs.c Wed Jul 28 10:22:44 2010
@@ -30,7 +30,6 @@
#include "gtk/gtk_tabs.h"
#define TAB_WIDTH_N_CHARS 15
-#define GET_WIDGET(x) glade_xml_get_widget(gladeNetsurf, (x))
static GtkWidget *nsgtk_tab_label_setup(struct gui_window *window);
static void nsgtk_tab_visibility_update(GtkNotebook *notebook, GtkWidget *child,
Added: trunk/netsurf/utils/findresource.c
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/findresource.c?rev=...
==============================================================================
--- trunk/netsurf/utils/findresource.c (added)
+++ trunk/netsurf/utils/findresource.c Wed Jul 28 10:22:44 2010
@@ -1,0 +1,210 @@
+/*
+ * Copyright 2010 Vincent Sanders <vince(a)kyllikki.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Provides utility functions for finding readable files.
+ *
+ * These functions are intended to make finding resource files more straightforward.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdarg.h>
+#include <malloc.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "utils/findresource.h"
+
+#define MAX_RESPATH 128 /* maximum number of elements in the resource vector */
+
+/* exported interface documented in findresource.h */
+char *vsfindfile(char *str, const char *format, va_list ap)
+{
+ char *realpathname;
+ char *pathname;
+ int len;
+
+ pathname = malloc(PATH_MAX);
+ if (pathname == NULL)
+ return NULL; /* unable to allocate memory */
+
+ len = vsnprintf(pathname, PATH_MAX, format, ap);
+
+ if ((len < 0) || (len >= PATH_MAX)) {
+ /* error or output exceeded PATH_MAX length so
+ * operation is doomed to fail.
+ */
+ free(pathname);
+ return NULL;
+ }
+
+ realpathname = realpath(pathname, str);
+
+ free(pathname);
+
+ if (realpathname != NULL) {
+ /* sucessfully expanded pathname */
+ if (access(realpathname, R_OK) != 0) {
+ /* unable to read the file */
+ return NULL;
+ }
+ }
+
+ return realpathname;
+}
+
+/* exported interface documented in findresource.h */
+char *sfindfile(char *str, const char *format, ...)
+{
+ va_list ap;
+ char *ret;
+
+ va_start(ap, format);
+ ret = vsfindfile(str, format, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+/* exported interface documented in findresource.h */
+char *findfile(const char *format, ...)
+{
+ char *str;
+ char *ret;
+ va_list ap;
+
+ str = malloc(PATH_MAX);
+ if (str == NULL)
+ return NULL; /* unable to allocate memory */
+
+ va_start(ap, format);
+ ret = vsfindfile(str, format, ap);
+ va_end(ap);
+
+ if (ret == NULL)
+ free(str);
+
+ return ret;
+}
+
+/* exported interface documented in findresource.h */
+char *sfindresource(char **respathv, char *filepath, const char *filename)
+{
+ int respathc = 0;
+
+ if ((respathv == NULL) || (respathv[0] == NULL) || (filepath == NULL))
+ return NULL;
+
+ while (respathv[respathc] != NULL) {
+ if (sfindfile(filepath, "%s/%s", respathv[respathc], filename) != NULL)
+ return filepath;
+
+ respathc++;
+ }
+
+ return NULL;
+}
+
+/* exported interface documented in findresource.h */
+char *findresource(char **respathv, const char *filename)
+{
+ char *ret;
+ char *filepath;
+
+ if ((respathv == NULL) || (respathv[0] == NULL))
+ return NULL;
+
+ filepath = malloc(PATH_MAX);
+ if (filepath == NULL)
+ return NULL;
+
+ ret = sfindresource(respathv, filepath, filename);
+
+ if (ret == NULL)
+ free(filepath);
+
+ return ret;
+}
+
+/* exported interface documented in findresource.h */
+char *sfindresourcedef(char **respathv, char *filepath, const char *filename, const char *def)
+{
+ char t[PATH_MAX];
+ char *ret;
+
+ if ((respathv == NULL) || (respathv[0] == NULL) || (filepath == NULL))
+ return NULL;
+
+ ret = sfindresource(respathv, filepath, filename);
+
+ if ((ret == NULL) &&
+ (def != NULL)) {
+ /* search failed, return the path specified */
+ ret = filepath;
+ if (def[0] == '~') {
+ snprintf(t, PATH_MAX, "%s/%s/%s", getenv("HOME"), def + 1, filename);
+ } else {
+ snprintf(t, PATH_MAX, "%s/%s", def, filename);
+ }
+ if (realpath(t, ret) == NULL) {
+ strcpy(ret, t);
+ }
+
+ }
+ return ret;
+}
+
+
+/* exported interface documented in findresource.h */
+char **
+findresource_generate(char * const *pathv, const char * const *langv)
+{
+ char **respath; /* resource paths vector */
+ int pathc = 0;
+ int langc = 0;
+ int respathc = 0;
+ struct stat dstat;
+ char tmppath[PATH_MAX];
+
+ respath = calloc(MAX_RESPATH, sizeof(char *));
+
+ while (pathv[pathc] != NULL) {
+ if ((stat(pathv[pathc], &dstat) == 0) &&
+ S_ISDIR(dstat.st_mode)) {
+ /* path element exists and is a directory */
+ langc = 0;
+ while (langv[langc] != NULL) {
+ snprintf(tmppath, PATH_MAX,"%s/%s",pathv[pathc],langv[langc]);
+ if ((stat(tmppath, &dstat) == 0) &&
+ S_ISDIR(dstat.st_mode)) {
+ /* path element exists and is a directory */
+ respath[respathc++] = strdup(tmppath);
+ }
+ langc++;
+ }
+ respath[respathc++] = strdup(pathv[pathc]);
+ }
+ pathc++;
+ }
+
+ return respath;
+}
Added: trunk/netsurf/utils/findresource.h
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/findresource.h?rev=...
==============================================================================
--- trunk/netsurf/utils/findresource.h (added)
+++ trunk/netsurf/utils/findresource.h Wed Jul 28 10:22:44 2010
@@ -1,0 +1,88 @@
+/*
+ * Copyright 2010 Vincent Sanders <vince(a)kyllikki.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _NETSURF_UTILS_FINDRESOURCE_H_
+#define _NETSURF_UTILS_FINDRESOURCE_H_
+
+/** Create a normalised file name.
+ *
+ * If the file described by the format exists and is accessible the
+ * normalised path is placed in str and a pointer to str returned
+ * otherwise NULL is returned. The string in str is always modified.
+ *
+ * @param str A buffer to contain the normalised file name must be at
+ * least PATH_MAX bytes long.
+ * @param format A printf format for the filename.
+ * @param ap The list of arguments for the format.
+ * @return A pointer to the expanded filename or NULL if the file is
+ * not present or accessible.
+ */
+char *vsfindfile(char *str, const char *format, va_list ap);
+
+/** Create a normalised file name.
+ *
+ * Similar to vsfindfile but takes variadic (printf like) parameters
+ */
+char *sfindfile(char *str, const char *format, ...);
+
+/** Create a normalised file name.
+ *
+ * Similar to sfindfile but allocates its own storage for the
+ * returned string. The caller must free this sorage.
+ */
+char *findfile(const char *format, ...);
+
+/** Searches an array of resource paths for a file.
+ *
+ * Iterates through a vector of resource paths and returns the
+ * normalised file name of the first acessible file or NULL if no file
+ * can be found in any of the resource paths.
+ *
+ * @param respathv The resource path vector to iterate.
+ * @param filepath The buffer to place the result in.
+ * @param filename The filename of the resource to search for.
+ * @return A pointer to filepath if a target is found or NULL if not.
+ */
+char *sfindresource(char **respathv, char *filepath, const char *filename);
+
+/** Searches an array of resource paths for a file.
+ *
+ * Similar to sfindresource except it allocates its own storage for
+ * the returned string. The caller must free this sorage.
+ */
+char *findresource(char **respathv, const char *filename);
+
+/** Searches an array of resource paths for a file optionally forcing a default.
+ *
+ * Similar to sfindresource except if no resource is found the default
+ * is used as an additional path element to search, if that still
+ * fails the returned path is set to the concatination of the default
+ * path and the filename.
+ */
+char *sfindresourcedef(char **respathv, char *filepath, const char *filename, const char *def);
+
+/** Merge two string vectors into a resource search path vector.
+ *
+ * @param pathv A string vector containing path elemets to scan.
+ * @param langv A string vector containing language names to enumerate.
+ * @return A pointer to a NULL terminated string vector of valid
+ * resource directories.
+ */
+char **findresource_generate(char * const *pathv, const char * const *langv);
+
+#endif
Modified: trunk/netsurf/utils/messages.c
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/messages.c?rev=1066...
==============================================================================
--- trunk/netsurf/utils/messages.c (original)
+++ trunk/netsurf/utils/messages.c Wed Jul 28 10:22:44 2010
@@ -116,8 +116,11 @@
struct hash_table *m;
char s[400];
- assert(path != NULL);
-
+ if (path == NULL)
+ return;
+
+ LOG(("Loading Messages from '%s'", path));
+
m = messages_load_ctx(path, messages_hash);
if (m == NULL) {
LOG(("Unable to open Messages file '%s'. Possible reason: %s",
13 years, 1 month
r10667 vince - in /trunk/netsurf/gtk/res: de en fr it nl
by netsurf@semichrome.net
Author: vince
Date: Wed Jul 28 10:19:30 2010
New Revision: 10667
URL: http://source.netsurf-browser.org?rev=10667&view=rev
Log:
remove symlinks to directories for Message translations
Removed:
trunk/netsurf/gtk/res/de
trunk/netsurf/gtk/res/en
trunk/netsurf/gtk/res/fr
trunk/netsurf/gtk/res/it
trunk/netsurf/gtk/res/nl
Removed: trunk/netsurf/gtk/res/de
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/de?rev=10666&view...
==============================================================================
--- trunk/netsurf/gtk/res/de (original)
+++ trunk/netsurf/gtk/res/de (removed)
@@ -1,1 +1,0 @@
-link ../../!NetSurf/Resources/de
Removed: trunk/netsurf/gtk/res/en
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/en?rev=10666&view...
==============================================================================
--- trunk/netsurf/gtk/res/en (original)
+++ trunk/netsurf/gtk/res/en (removed)
@@ -1,1 +1,0 @@
-link ../../!NetSurf/Resources/en
Removed: trunk/netsurf/gtk/res/fr
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/fr?rev=10666&view...
==============================================================================
--- trunk/netsurf/gtk/res/fr (original)
+++ trunk/netsurf/gtk/res/fr (removed)
@@ -1,1 +1,0 @@
-link ../../!NetSurf/Resources/fr
Removed: trunk/netsurf/gtk/res/it
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/it?rev=10666&view...
==============================================================================
--- trunk/netsurf/gtk/res/it (original)
+++ trunk/netsurf/gtk/res/it (removed)
@@ -1,1 +1,0 @@
-link ../../!NetSurf/Resources/it
Removed: trunk/netsurf/gtk/res/nl
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/nl?rev=10666&view...
==============================================================================
--- trunk/netsurf/gtk/res/nl (original)
+++ trunk/netsurf/gtk/res/nl (removed)
@@ -1,1 +1,0 @@
-link ../../!NetSurf/Resources/nl
13 years, 1 month
r10666 stevef - in /trunk/netsurf/riscos: print.c templates/de templates/en templates/fr templates/nl
by netsurf@semichrome.net
Author: stevef
Date: Tue Jul 27 17:50:51 2010
New Revision: 10666
URL: http://source.netsurf-browser.org?rev=10666&view=rev
Log:
Enable sideways print option.
Modified:
trunk/netsurf/riscos/print.c
trunk/netsurf/riscos/templates/de
trunk/netsurf/riscos/templates/en
trunk/netsurf/riscos/templates/fr
trunk/netsurf/riscos/templates/nl
Modified: trunk/netsurf/riscos/print.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/print.c?rev=10666&...
==============================================================================
--- trunk/netsurf/riscos/print.c (original)
+++ trunk/netsurf/riscos/print.c Tue Jul 27 17:50:51 2010
@@ -84,6 +84,7 @@
static int print_num_copies = 1;
static bool print_bg_images = false;
static int print_max_sheets = -1;
+static bool print_sideways = false;
/** List of fonts in current print. */
static char **print_fonts_list = 0;
/** Number of entries in print_fonts_list. */
@@ -270,6 +271,8 @@
ICON_PRINT_IN_BACKGROUND);
print_text_black = ro_gui_get_icon_selected_state(dialog_print,
ICON_PRINT_TEXT_BLACK);
+ print_sideways = ro_gui_get_icon_selected_state(dialog_print,
+ ICON_PRINT_SIDEWAYS);
print_num_copies = copies;
if (ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_SHEETS))
print_max_sheets = sheets;
@@ -578,8 +581,13 @@
return false;
}
- width = (right - left) / 800;
- height = (top - bottom) / 800;
+ if (print_sideways) {
+ width = (top - bottom) / 800;
+ height = (right - left) / 800;
+ } else {
+ width = (right - left) / 800;
+ height = (top - bottom) / 800;
+ }
/* layout the document to the correct width */
saved_width = content_get_width(h);
@@ -628,11 +636,38 @@
do {
int clip_x0, clip_y0, clip_x1, clip_y1;
- os_box b = {left / 400 - 2, bottom / 400 - 2,
- right / 400 + 2, top / 400 + 2};
- os_hom_trfm t = { { {65536, 0}, {0, 65536} } };
- os_coord p = {left, bottom};
+ os_box b;
+ os_hom_trfm t;
+ os_coord p;
osbool more;
+
+ if (print_sideways) {
+ b.x0 = bottom / 400 -2;
+ b.y0 = left / 400 - 2;
+ b.x1 = top / 400 + 2;
+ b.y1 = right / 400 + 2;
+ t.entries[0][0] = 0;
+ t.entries[0][1] = 65536;
+ t.entries[1][0] = -65536;
+ t.entries[1][1] = 0;
+ p.x = right;
+ p.y = bottom;
+ ro_plot_origin_x = bottom / 400;
+ ro_plot_origin_y = right / 400 + yscroll * 2;
+ } else {
+ b.x0 = left / 400 -2;
+ b.y0 = bottom / 400 - 2;
+ b.x1 = right / 400 + 2;
+ b.y1 = top / 400 + 2;
+ t.entries[0][0] = 65536;
+ t.entries[0][1] = 0;
+ t.entries[1][0] = 0;
+ t.entries[1][1] = 65536;
+ p.x = left;
+ p.y = bottom;
+ ro_plot_origin_x = left / 400;
+ ro_plot_origin_y = top / 400 + yscroll * 2;
+ }
xhourglass_percentage((int) (yscroll * 100 /
content_get_height(h)));
@@ -658,9 +693,6 @@
error_message = error->errmess;
goto error;
}
-
- ro_plot_origin_x = left / 400;
- ro_plot_origin_y = top / 400 + yscroll * 2;
while (more) {
LOG(("redrawing area: [(%d, %d), (%d, %d)]",
Modified: trunk/netsurf/riscos/templates/de
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/templates/de?rev=1...
==============================================================================
--- trunk/netsurf/riscos/templates/de (original)
+++ trunk/netsurf/riscos/templates/de Tue Jul 27 17:50:51 2010
@@ -2174,7 +2174,7 @@
}
wimp_icon {
extent:12,-452,228,-408
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_SHADED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
Modified: trunk/netsurf/riscos/templates/en
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/templates/en?rev=1...
==============================================================================
--- trunk/netsurf/riscos/templates/en (original)
+++ trunk/netsurf/riscos/templates/en Tue Jul 27 17:50:51 2010
@@ -2330,7 +2330,7 @@
}
wimp_icon {
extent:12,-452,196,-408
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_SHADED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
Modified: trunk/netsurf/riscos/templates/fr
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/templates/fr?rev=1...
==============================================================================
--- trunk/netsurf/riscos/templates/fr (original)
+++ trunk/netsurf/riscos/templates/fr Tue Jul 27 17:50:51 2010
@@ -2184,7 +2184,7 @@
}
wimp_icon {
extent:12,-452,196,-408
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_SHADED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
Modified: trunk/netsurf/riscos/templates/nl
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/templates/nl?rev=1...
==============================================================================
--- trunk/netsurf/riscos/templates/nl (original)
+++ trunk/netsurf/riscos/templates/nl Tue Jul 27 17:50:51 2010
@@ -2334,7 +2334,7 @@
}
wimp_icon {
extent:12,-452,196,-408
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_SHADED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
13 years, 1 month
r10665 chris_y - in /trunk/netsurf/amiga: clipboard.c download.c gui.c gui.h
by netsurf@semichrome.net
Author: chris_y
Date: Tue Jul 27 16:41:21 2010
New Revision: 10665
URL: http://source.netsurf-browser.org?rev=10665&view=rev
Log:
Allow text selection dragging across (NetSurf) windows. DisplayBeep if it is dropped
somewhere invalid.
Modified:
trunk/netsurf/amiga/clipboard.c
trunk/netsurf/amiga/download.c
trunk/netsurf/amiga/gui.c
trunk/netsurf/amiga/gui.h
Modified: trunk/netsurf/amiga/clipboard.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/clipboard.c?rev=106...
==============================================================================
--- trunk/netsurf/amiga/clipboard.c (original)
+++ trunk/netsurf/amiga/clipboard.c Tue Jul 27 16:41:21 2010
@@ -257,16 +257,30 @@
void ami_drag_selection(struct selection *s)
{
struct box *text_box;
- ULONG x = s->bw->window->shared->win->MouseX;
- ULONG y = s->bw->window->shared->win->MouseY;
-
- if(text_box = ami_text_box_at_point(s->bw->window, &x, &y))
+ ULONG x;
+ ULONG y;
+ struct gui_window_2 *gwin = ami_window_at_pointer();
+
+ if(!gwin)
+ {
+ DisplayBeep(scrn);
+ return;
+ }
+
+ x = gwin->win->MouseX;
+ y = gwin->win->MouseY;
+
+ if(text_box = ami_text_box_at_point(gwin, &x, &y))
{
if(gui_copy_to_clipboard(s))
{
- browser_window_mouse_click(s->bw, BROWSER_MOUSE_PRESS_1, x, y);
- browser_window_key_press(s->bw, KEY_PASTE);
- }
+ browser_window_mouse_click(gwin->bw, BROWSER_MOUSE_PRESS_1, x, y);
+ browser_window_key_press(gwin->bw, KEY_PASTE);
+ }
+ }
+ else
+ {
+ DisplayBeep(scrn);
}
}
Modified: trunk/netsurf/amiga/download.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/download.c?rev=1066...
==============================================================================
--- trunk/netsurf/amiga/download.c (original)
+++ trunk/netsurf/amiga/download.c Tue Jul 27 16:41:21 2010
@@ -345,18 +345,21 @@
void ami_drag_save(struct Window *win)
{
- ULONG which,type;
+ ULONG which = WBO_NONE,type;
char path[1025],dpath[1025];
char *source_data;
ULONG source_size;
- which = WhichWorkbenchObject(NULL,scrn->MouseX,scrn->MouseY,
+ if(strcmp(option_use_pubscreen,"Workbench") == 0)
+ {
+ which = WhichWorkbenchObject(NULL,scrn->MouseX,scrn->MouseY,
WBOBJA_Type,&type,
WBOBJA_FullPath,&path,
WBOBJA_FullPathSize,1024,
WBOBJA_DrawerPath,&dpath,
WBOBJA_DrawerPathSize,1024,
TAG_DONE);
+ }
if((which == WBO_DRAWER) || ((which == WBO_ICON) && (type > WBDRAWER)))
{
@@ -366,6 +369,7 @@
{
if(drag_save == GUI_SAVE_TEXT_SELECTION)
ami_drag_selection((struct selection *)drag_save_data);
+ else DisplayBeep(scrn);
drag_save = 0;
drag_save_data = NULL;
@@ -374,6 +378,7 @@
if(path[0] == '\0')
{
+ DisplayBeep(scrn);
drag_save = 0;
drag_save_data = NULL;
return;
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=10665&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Tue Jul 27 16:41:21 2010
@@ -73,6 +73,7 @@
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/keymap.h>
+#include <proto/layers.h>
#include <proto/locale.h>
#include <proto/Picasso96API.h>
#include <proto/timer.h>
@@ -3784,7 +3785,7 @@
/* return the text box at posn x,y in window coordinates
x,y are updated to be document co-ordinates */
-struct box *ami_text_box_at_point(struct gui_window *g, ULONG *x, ULONG *y)
+struct box *ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y)
{
struct IBox *bbox;
ULONG xs,ys,width,height;
@@ -3792,19 +3793,19 @@
hlcache_handle *content;
int box_x=0,box_y=0;
- GetAttr(SPACE_AreaBox, (Object *)g->shared->objects[GID_BROWSER],
+ GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER],
(ULONG *)&bbox);
- ami_get_hscroll_pos(g->shared, (ULONG *)&xs);
+ ami_get_hscroll_pos(gwin, (ULONG *)&xs);
*x = *x - (bbox->Left) +xs;
- ami_get_vscroll_pos(g->shared, (ULONG *)&ys);
+ ami_get_vscroll_pos(gwin, (ULONG *)&ys);
*y = *y - (bbox->Top) + ys;
width=bbox->Width;
height=bbox->Height;
- content = g->shared->bw->current_content;
+ content = gwin->bw->current_content;
box = html_get_box_tree(content);
while ((box = box_at_point(box, *x, *y, &box_x, &box_y, &content)))
{
@@ -3827,3 +3828,40 @@
}
return text_box;
}
+
+struct gui_window_2 *ami_find_gwin_by_id(struct Window *win)
+{
+ struct nsObject *node, *nnode;
+ struct gui_window_2 *gwin;
+
+ if(!IsMinListEmpty(window_list))
+ {
+ node = (struct nsObject *)GetHead((struct List *)window_list);
+
+ do
+ {
+ nnode=(struct nsObject *)GetSucc((struct Node *)node);
+
+ if(node->Type == AMINS_WINDOW) // or frame?
+ {
+ gwin = node->objstruct;
+ if(win == gwin->win) return gwin;
+ }
+ } while(node = nnode);
+ }
+ return NULL;
+}
+
+struct gui_window_2 *ami_window_at_pointer(void)
+{
+ struct Layer *layer;
+
+ LockLayerInfo(&scrn->LayerInfo);
+
+ layer = WhichLayer(&scrn->LayerInfo, scrn->MouseX, scrn->MouseY);
+
+ UnlockLayerInfo(&scrn->LayerInfo);
+
+ if(layer) return ami_find_gwin_by_id(layer->Window);
+ else return NULL;
+}
Modified: trunk/netsurf/amiga/gui.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.h?rev=10665&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.h (original)
+++ trunk/netsurf/amiga/gui.h Tue Jul 27 16:41:21 2010
@@ -127,7 +127,8 @@
void ami_quit_netsurf(void);
void ami_do_redraw(struct gui_window_2 *g);
STRPTR ami_locale_langs(void);
-struct box *ami_text_box_at_point(struct gui_window *g, ULONG *x, ULONG *y);
+struct box *ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y);
+struct gui_window_2 *ami_window_at_pointer(void);
struct TextFont *origrpfont;
struct MinList *window_list;
13 years, 1 month
r10664 chris_y - /trunk/netsurf/amiga/gui.c
by netsurf@semichrome.net
Author: chris_y
Date: Mon Jul 26 14:52:24 2010
New Revision: 10664
URL: http://source.netsurf-browser.org?rev=10664&view=rev
Log:
Fix clipping for non-HTML contents
Modified:
trunk/netsurf/amiga/gui.c
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=10664&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Mon Jul 26 14:52:24 2010
@@ -3062,8 +3062,8 @@
content_redraw(c,
-sx, -sy,
- width - sx,
- height - sy,
+ width, // - sx,
+ height, // - sy,
(x0 - sx) * g->shared->bw->scale,
(y0 - sy) * g->shared->bw->scale,
(x1 - sx) * g->shared->bw->scale,
@@ -3218,8 +3218,8 @@
{
content_redraw(c, -hcurrent,
-vcurrent,
- width - hcurrent,
- height - vcurrent,
+ width,
+ height,
0,0,width,
height,
g->bw->scale,0xFFFFFF);
@@ -3228,10 +3228,10 @@
{
content_redraw(c, -hcurrent /* * g->bw->scale */,
-vcurrent /* * g->bw->scale */,
- (width / g->bw->scale) - hcurrent,
- (height / g->bw->scale) - vcurrent,
- 0,0, content_get_width(c) /* * g->bw->scale */,
- content_get_height(c) /* * g->bw->scale */,
+ (width / g->bw->scale), //- hcurrent,
+ (height / g->bw->scale), // - vcurrent,
+ hcurrent, vcurrent, width + hcurrent /* * g->bw->scale */,
+ height + vcurrent /* * g->bw->scale */,
g->bw->scale,0xFFFFFF);
}
13 years, 1 month