mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-27 14:29:42 +03:00
Merge r9731:HEAD from branches/MarkieB/gtkmain to trunk.
svn path=/trunk/netsurf/; revision=9737
This commit is contained in:
parent
46eaa6a058
commit
b75b2ae8bb
@ -433,6 +433,7 @@ gtkFileError:File error: %s
|
||||
gtkInfo:%s from %s is %s in size
|
||||
gtkSave:Save file as...
|
||||
gtkSourceSave:Save Source
|
||||
gtkSourceTabError:Error handling source data
|
||||
gtkPlainSave:Save as text
|
||||
gtkFullSave:Save webpage complete - select an empty directory
|
||||
gtkUnknownHost:an unknown host
|
||||
|
@ -434,6 +434,7 @@ gtkFileError:File error: %s
|
||||
gtkInfo:%s from %s is %s in size
|
||||
gtkSave:Save file as...
|
||||
gtkSourceSave:Save source
|
||||
gtkSourceTabError:Error handling source data
|
||||
gtkplainSave:Save plain text
|
||||
gtkcompleteSave:Save webpage complete - select an empty directory
|
||||
gtkSaveConfirm:File saved
|
||||
|
@ -433,6 +433,7 @@ gtkFileError:File error: %s
|
||||
gtkInfo:%s from %s is %s in size
|
||||
gtkSave:Save file as...
|
||||
gtkSourceSave:Save Source
|
||||
gtkSourceTabError:Error handling source data
|
||||
gtkPlainSave:Save as text
|
||||
gtkFullSave:Save webpage complete - select an empty directory
|
||||
gtkUnknownHost:an unknown host
|
||||
|
@ -437,6 +437,7 @@ gtkFileError:Errore File: %s
|
||||
gtkInfo:%s da %s è %s come dimensione
|
||||
gtkSave:Salva file come...
|
||||
gtkSourceSave:Salva sorgente
|
||||
gtkSourceTabError:Error handling source data
|
||||
gtkPlainSave:Save as text
|
||||
gtkFullSave:Save webpage complete - select an empty directory
|
||||
gtkSaveConfirm:File salvato
|
||||
|
@ -433,6 +433,7 @@ gtkFileError:File error: %s
|
||||
gtkInfo:%s from %s is %s in size
|
||||
gtkSave:Save file as...
|
||||
gtkSourceSave:Save Source
|
||||
gtkSourceTabError:Error handling source data
|
||||
gtkPlainSave:Save as text
|
||||
gtkFullSave:Save webpage complete - select an empty directory
|
||||
gtkUnknownHost:an unknown host
|
||||
|
@ -752,7 +752,8 @@ void fetchcache_error_page(struct content *c, const char *error,
|
||||
fetchcache_search_redirect(c, error);
|
||||
free(host);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
free(host);
|
||||
}
|
||||
if ((length = snprintf(error_page, sizeof(error_page),
|
||||
messages_get("ErrorPage"), error)) < 0)
|
||||
|
@ -97,13 +97,22 @@ static void free_matches(struct search_context *context);
|
||||
bool search_create_context(struct browser_window *bw,
|
||||
struct search_callbacks *callbacks, void *p)
|
||||
{
|
||||
struct search_context *context = malloc(sizeof(struct search_context));
|
||||
struct list_entry *search_head = malloc(sizeof(struct list_entry));
|
||||
struct search_context *context;
|
||||
struct list_entry *search_head;
|
||||
|
||||
if ((context == NULL) || (search_head == NULL)) {
|
||||
context = malloc(sizeof(struct search_context));
|
||||
if (context == NULL) {
|
||||
warn_user("NoMemory", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
search_head = malloc(sizeof(struct list_entry));
|
||||
if (search_head == NULL) {
|
||||
warn_user("NoMemory", 0);
|
||||
free(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bw->search_context != NULL)
|
||||
search_destroy_context(bw->search_context);
|
||||
|
||||
@ -195,8 +204,10 @@ void search_step(struct search_context *context, search_flags_t flags,
|
||||
|
||||
void free_matches(struct search_context *context)
|
||||
{
|
||||
struct list_entry *a = context->found->next;
|
||||
struct list_entry *a;
|
||||
struct list_entry *b;
|
||||
|
||||
a = context->found->next;
|
||||
|
||||
/* empty the list before clearing and deleting the
|
||||
selections because the the clearing updates the
|
||||
|
@ -77,9 +77,11 @@ bool search_is_url(const char *url)
|
||||
if (url_normalize(url, &url2) != URL_FUNC_OK)
|
||||
return false;
|
||||
|
||||
if (url_host(url2, &host) != URL_FUNC_OK)
|
||||
if (url_host(url2, &host) != URL_FUNC_OK) {
|
||||
free(url2);
|
||||
return false;
|
||||
|
||||
}
|
||||
free(url2);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -106,6 +108,7 @@ void search_web_provider_details(int reference)
|
||||
if (ref++ == (int)reference)
|
||||
break;
|
||||
}
|
||||
fclose(f);
|
||||
if (current_search_provider.name != NULL)
|
||||
free(current_search_provider.name);
|
||||
current_search_provider.name = strdup(strtok(buf, "|"));
|
||||
|
@ -476,6 +476,7 @@ static void nsgtk_options_theme_combo(void) {
|
||||
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(combotheme), buf);
|
||||
}
|
||||
fclose(fp);
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(combotheme),
|
||||
option_current_theme);
|
||||
gtk_box_pack_start(box, combotheme, FALSE, TRUE, 0);
|
||||
@ -855,14 +856,17 @@ BUTTON_CLICKED(buttonaddtheme)
|
||||
"gtkThemeFolderInstructions"),
|
||||
0);
|
||||
gtk_widget_destroy(GTK_WIDGET(fc));
|
||||
free(filename);
|
||||
free(themesfolder);
|
||||
if (filename != NULL)
|
||||
free(filename);
|
||||
if (themesfolder != NULL)
|
||||
free(themesfolder);
|
||||
return FALSE;
|
||||
} else {
|
||||
directory++;
|
||||
}
|
||||
} else {
|
||||
free(filename);
|
||||
if (filename != NULL)
|
||||
free(filename);
|
||||
filename = gtk_file_chooser_get_filename(
|
||||
GTK_FILE_CHOOSER(fc));
|
||||
if (strcmp(filename, themesfolder) == 0) {
|
||||
@ -877,7 +881,8 @@ BUTTON_CLICKED(buttonaddtheme)
|
||||
}
|
||||
gtk_widget_destroy(GTK_WIDGET(fc));
|
||||
nsgtk_theme_add(directory);
|
||||
free(filename);
|
||||
if (filename != NULL)
|
||||
free(filename);
|
||||
}
|
||||
|
||||
END_HANDLER
|
||||
|
@ -225,8 +225,17 @@ void nsgtk_source_tab_init(GtkWindow *parent, struct browser_window *bw)
|
||||
gchar *filename;
|
||||
char *fileurl;
|
||||
gint handle = g_file_open_tmp("nsgtksourceXXXXXX", &filename, NULL);
|
||||
if ((handle == -1) || (filename == NULL)) {
|
||||
warn_user(messages_get("gtkSourceTabError"), 0);
|
||||
return;
|
||||
}
|
||||
close (handle); /* in case it was binary mode */
|
||||
FILE *f = fopen(filename, "w");
|
||||
if (f == NULL) {
|
||||
warn_user(messages_get("gtkSourceTabError"), 0);
|
||||
g_free(filename);
|
||||
return;
|
||||
}
|
||||
fprintf(f, "%s", ndata);
|
||||
fclose(f);
|
||||
free(ndata);
|
||||
|
@ -1205,31 +1205,32 @@ MULTIHANDLER(stop)
|
||||
|
||||
MULTIHANDLER(reload)
|
||||
{
|
||||
struct browser_window *bw =
|
||||
struct browser_window *bw =
|
||||
gui_window_get_browser_window(g->top_level);
|
||||
if (bw == NULL)
|
||||
return TRUE;
|
||||
|
||||
/* clear potential search effects */
|
||||
|
||||
if ((bw != NULL) && (bw->search_context != NULL))
|
||||
if (bw->search_context != NULL)
|
||||
search_destroy_context(bw->search_context);
|
||||
nsgtk_search_set_forward_state(true, bw);
|
||||
nsgtk_search_set_back_state(true, bw);
|
||||
|
||||
browser_window_reload(bw, true);
|
||||
browser_window_reload(bw, true);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
MULTIHANDLER(back)
|
||||
{
|
||||
struct browser_window *bw =
|
||||
struct browser_window *bw =
|
||||
gui_window_get_browser_window(g->top_level);
|
||||
|
||||
if (!history_back_available(bw->history))
|
||||
if ((bw == NULL) || (!history_back_available(bw->history)))
|
||||
return TRUE;
|
||||
|
||||
/* clear potential search effects */
|
||||
if ((bw != NULL) && (bw->search_context != NULL))
|
||||
if (bw->search_context != NULL)
|
||||
search_destroy_context(bw->search_context);
|
||||
nsgtk_search_set_forward_state(true, bw);
|
||||
nsgtk_search_set_back_state(true, bw);
|
||||
@ -1242,14 +1243,14 @@ MULTIHANDLER(back)
|
||||
|
||||
MULTIHANDLER(forward)
|
||||
{
|
||||
struct browser_window *bw =
|
||||
struct browser_window *bw =
|
||||
gui_window_get_browser_window(g->top_level);
|
||||
|
||||
if (!history_forward_available(bw->history))
|
||||
if ((bw == NULL) || (!history_forward_available(bw->history)))
|
||||
return TRUE;
|
||||
|
||||
/* clear potential search effects */
|
||||
if ((bw != NULL) && (bw->search_context != NULL))
|
||||
if (bw->search_context != NULL)
|
||||
search_destroy_context(bw->search_context);
|
||||
nsgtk_search_set_forward_state(true, bw);
|
||||
nsgtk_search_set_back_state(true, bw);
|
||||
@ -1464,6 +1465,7 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
||||
g->search = malloc(sizeof(struct gtk_search));
|
||||
if (g->search == NULL) {
|
||||
warn_user("NoMemory", 0);
|
||||
free(g);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1837,13 +1839,17 @@ void gui_window_start_throbber(struct gui_window* _g)
|
||||
|
||||
void gui_window_stop_throbber(struct gui_window* _g)
|
||||
{
|
||||
struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
|
||||
g->buttons[STOP_BUTTON]->sensitivity = false;
|
||||
g->buttons[RELOAD_BUTTON]->sensitivity = true;
|
||||
struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
|
||||
if (g == NULL)
|
||||
return;
|
||||
nsgtk_window_update_back_forward(g);
|
||||
schedule_remove(nsgtk_throb, g);
|
||||
if (g->buttons[STOP_BUTTON] != NULL)
|
||||
g->buttons[STOP_BUTTON]->sensitivity = false;
|
||||
if (g->buttons[RELOAD_BUTTON] != NULL)
|
||||
g->buttons[RELOAD_BUTTON]->sensitivity = true;
|
||||
|
||||
if ((g == NULL) || (g->throbber == NULL) || (nsgtk_throbber == NULL) ||
|
||||
if ((g->throbber == NULL) || (nsgtk_throbber == NULL) ||
|
||||
(nsgtk_throbber->framedata == NULL) ||
|
||||
(nsgtk_throbber->framedata[0] == NULL))
|
||||
return;
|
||||
@ -2221,6 +2227,8 @@ void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget,
|
||||
{
|
||||
struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
|
||||
int i = nsgtk_toolbar_get_id_from_widget(widget, g);
|
||||
if (i == -1)
|
||||
return;
|
||||
if ((g->toolbarmem == alloc->x) ||
|
||||
(g->buttons[i]->location <
|
||||
g->buttons[HISTORY_BUTTON]->location))
|
||||
|
@ -193,13 +193,16 @@ void nsgtk_tab_page_changed(GtkNotebook *notebook, GtkNotebookPage *page,
|
||||
GtkWidget *window = gtk_notebook_get_nth_page(notebook, page_num);
|
||||
struct gui_window *gw = g_object_get_data(G_OBJECT(window),
|
||||
"gui_window");
|
||||
if (gw == NULL)
|
||||
return;
|
||||
struct browser_window *bw = gui_window_get_browser_window(gw);
|
||||
if ((bw != NULL) && (bw->search_context != NULL))
|
||||
if (bw == NULL)
|
||||
return;
|
||||
if (bw->search_context != NULL)
|
||||
search_destroy_context(bw->search_context);
|
||||
nsgtk_search_set_forward_state(true, bw);
|
||||
nsgtk_search_set_back_state(true, bw);
|
||||
if (gw)
|
||||
nsgtk_scaffolding_set_top_level(gw);
|
||||
nsgtk_scaffolding_set_top_level(gw);
|
||||
}
|
||||
|
||||
void nsgtk_tab_close_current(GtkNotebook *notebook)
|
||||
|
@ -213,6 +213,7 @@ bool nsgtk_theme_verify(const char *themename)
|
||||
+ 1);
|
||||
if (filecontent == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
strcpy(filecontent, "gtk default theme\n");
|
||||
@ -226,6 +227,7 @@ bool nsgtk_theme_verify(const char *themename)
|
||||
if (testfile == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
free(filecontent);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
sprintf(testfile, "%sthemes/%s", res_dir_location,
|
||||
@ -381,8 +383,8 @@ struct nsgtk_theme *nsgtk_theme_load(GtkIconSize s)
|
||||
return nsgtk_theme_default(s);
|
||||
|
||||
struct nsgtk_theme *theme = malloc(sizeof(struct nsgtk_theme));
|
||||
if (theme == NULL)
|
||||
return theme;
|
||||
if (theme == NULL)
|
||||
return theme;
|
||||
|
||||
if ((theme_cache_menu == NULL) || (theme_cache_toolbar == NULL))
|
||||
nsgtk_theme_prepare();
|
||||
@ -390,8 +392,10 @@ struct nsgtk_theme *nsgtk_theme_load(GtkIconSize s)
|
||||
/* load theme from cache */
|
||||
struct nsgtk_theme_cache *cachetheme = (s == GTK_ICON_SIZE_MENU) ?
|
||||
theme_cache_menu : theme_cache_toolbar;
|
||||
if (cachetheme == NULL)
|
||||
if (cachetheme == NULL) {
|
||||
free(theme);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define SET_BUTTON_IMAGE(p, q, r)\
|
||||
if (p->image[q##_BUTTON] != NULL)\
|
||||
@ -731,6 +735,7 @@ bool theme_install_read(const char *data, unsigned long len)
|
||||
if (handle == -1) {
|
||||
warn_user(messages_get("gtkFileError"),
|
||||
"temporary theme file");
|
||||
return false;
|
||||
}
|
||||
ssize_t written = write(handle, data, len);
|
||||
close(handle);
|
||||
|
@ -201,16 +201,20 @@ void nsgtk_toolbar_window_open(nsgtk_scaffolding *g)
|
||||
}
|
||||
glade_xml_signal_autoconnect(window->glade);
|
||||
|
||||
#define GET_TOOLWIDGET(p, q, r, s) r->p = glade_xml_get_widget(r->s, #q);\
|
||||
if (r->p == NULL) {\
|
||||
warn_user(messages_get("NoMemory"), 0);\
|
||||
nsgtk_toolbar_cancel_clicked(NULL, g);\
|
||||
return;\
|
||||
}
|
||||
|
||||
GET_TOOLWIDGET(window, toolbarwindow, window, glade)
|
||||
GET_TOOLWIDGET(widgetvbox, widgetvbox, window, glade)
|
||||
#undef GET_TOOLWIDGET
|
||||
window->window = glade_xml_get_widget(window->glade, "toolbarwindow");
|
||||
if (window->window == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
nsgtk_toolbar_cancel_clicked(NULL, g);
|
||||
free(theme);
|
||||
return;
|
||||
}
|
||||
window->widgetvbox = glade_xml_get_widget(window->glade, "widgetvbox");
|
||||
if (window->widgetvbox == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
nsgtk_toolbar_cancel_clicked(NULL, g);
|
||||
free(theme);
|
||||
return;
|
||||
}
|
||||
|
||||
window->numberh = NSGTK_STORE_WIDTH; /* preset to width [in buttons] of */
|
||||
/* store to cause creation of a new toolbar */
|
||||
|
@ -92,13 +92,13 @@ char *favicon_get_icon_ref(struct content *c, xmlNode *html)
|
||||
url2 = NULL;
|
||||
}
|
||||
res = url_normalize(url, &url2);
|
||||
free(url);
|
||||
if (res != URL_FUNC_OK) {
|
||||
url2 = NULL;
|
||||
if (res == URL_FUNC_NOMEM)
|
||||
goto no_memory;
|
||||
continue;
|
||||
}
|
||||
free(url);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
*
|
||||
* gcc -I../ -DNSTHEME -o themetool container.c
|
||||
*
|
||||
* [needs a c99 compiler]
|
||||
*
|
||||
* then for instance to create a theme file called mythemefilename
|
||||
* ./themetool --verbose --create -n"My theme name" mythemefilename\
|
||||
* --author "Myname" /path/to/directory/containing/theme/files/
|
||||
@ -41,10 +43,15 @@
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#ifdef WITH_MMAP
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#ifdef NSTHEME
|
||||
bool verbose_log = true;
|
||||
#endif
|
||||
|
||||
struct container_dirent {
|
||||
unsigned char filename[64];
|
||||
u_int32_t startoffset;
|
||||
@ -73,14 +80,21 @@ struct container_ctx {
|
||||
|
||||
inline static size_t container_filelen(FILE *fd)
|
||||
{
|
||||
size_t o = ftell(fd);
|
||||
size_t a;
|
||||
long o = ftell(fd);
|
||||
long a;
|
||||
|
||||
fseek(fd, 0, SEEK_END);
|
||||
a = ftell(fd);
|
||||
fseek(fd, o, SEEK_SET);
|
||||
|
||||
return a;
|
||||
if (a == -1) {
|
||||
LOG(("could not ascertain size of file in theme container; omitting"));
|
||||
return 0;
|
||||
}
|
||||
if (((unsigned long) a) > SIZE_MAX) {
|
||||
LOG(("overlarge file in theme container; possible truncation"));
|
||||
return SIZE_MAX;
|
||||
}
|
||||
return (size_t) a;
|
||||
}
|
||||
|
||||
static void container_add_to_dir(struct container_ctx *ctx,
|
||||
@ -88,9 +102,15 @@ static void container_add_to_dir(struct container_ctx *ctx,
|
||||
const u_int32_t offset,
|
||||
const u_int32_t length)
|
||||
{
|
||||
struct container_dirent *temp;
|
||||
temp = realloc(ctx->directory, ctx->entries *
|
||||
sizeof(struct container_dirent));
|
||||
if (temp == NULL) {
|
||||
printf("error adding entry for %s to theme container\n", entryname);
|
||||
return;
|
||||
}
|
||||
ctx->entries += 1;
|
||||
ctx->directory = realloc(ctx->directory, ctx->entries *
|
||||
sizeof(struct container_dirent));
|
||||
ctx->directory = temp;
|
||||
|
||||
strncpy((char *)ctx->directory[ctx->entries - 1].filename,
|
||||
(char *)entryname, sizeof(ctx->directory[
|
||||
@ -503,7 +523,7 @@ static void extract_theme(const char *themefile, const char *dirname)
|
||||
FILE *fh;
|
||||
const unsigned char *e, *d;
|
||||
char path[PATH_MAX];
|
||||
int state = 0;
|
||||
int i, state = 0;
|
||||
u_int32_t flen;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user