update gtk to stop using depricated warn_user API

This commit is contained in:
Vincent Sanders 2016-04-26 21:51:47 +01:00
parent 8fd04922cc
commit 6893866441
12 changed files with 117 additions and 81 deletions

View File

@ -32,6 +32,7 @@
#include "desktop/browser.h"
#include "desktop/version.h"
#include "gtk/warn.h"
#include "gtk/compat.h"
#include "gtk/about.h"
@ -61,7 +62,7 @@ static void about_open(const char *url_text)
}
if (ret != NSERROR_OK) {
warn_user(messages_get_errorcode(ret), 0);
nsgtk_warning(messages_get_errorcode(ret), 0);
}
}

View File

@ -31,6 +31,7 @@
#include "desktop/searchweb.h"
#include "desktop/browser.h"
#include "gtk/warn.h"
#include "gtk/window.h"
#include "gtk/completion.h"
@ -99,7 +100,7 @@ nsgtk_completion_match_select(GtkEntryCompletion *widget,
nsurl_unref(url);
}
if (ret != NSERROR_OK) {
warn_user(messages_get_errorcode(ret), 0);
nsgtk_warning(messages_get_errorcode(ret), 0);
}
return TRUE;

View File

@ -32,6 +32,7 @@
#include "desktop/download.h"
#include "desktop/gui_download.h"
#include "gtk/warn.h"
#include "gtk/scaffolding.h"
#include "gtk/window.h"
#include "gtk/compat.h"
@ -637,7 +638,7 @@ static gchar* nsgtk_download_dialog_show (const gchar *filename, const gchar *do
destination = malloc(strlen(nsoption_charp(downloads_directory))
+ strlen(filename) + SLEN("/") + 1);
if (destination == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
break;
}
sprintf(destination, "%s/%s",

View File

@ -52,6 +52,7 @@
#include "desktop/netsurf.h"
#include "gtk/compat.h"
#include "gtk/warn.h"
#include "gtk/completion.h"
#include "gtk/cookies.h"
#include "gtk/download.h"
@ -474,21 +475,14 @@ static nserror gui_launch_url(struct nsurl *url)
}
if (error) {
warn_user(messages_get("URIOpenError"), error->message);
nsgtk_warning(messages_get("URIOpenError"), error->message);
g_error_free(error);
}
return NSERROR_NO_FETCH_HANDLER;
}
/**
* Warn the user of an event.
*
* \param[in] warning A warning looked up in the message translation table
* \param[in] detail Additional text to be displayed or NULL.
* \return NSERROR_OK on success or error code if there was a
* faliure displaying the message to the user.
*/
static nserror nsgtk_warning(const char *warning, const char *detail)
/* exported function documented in gtk/warn.h */
nserror nsgtk_warning(const char *warning, const char *detail)
{
char buf[300]; /* 300 is the size the RISC OS GUI uses */
static GtkWindow *nsgtk_warning_window;

View File

@ -26,6 +26,7 @@
#include "gtk/compat.h"
#include "gtk/menu.h"
#include "gtk/warn.h"
/**
* Adds image menu item to a menu.
@ -135,12 +136,12 @@ static struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *gro
struct nsgtk_export_submenu *ret = malloc(sizeof(struct
nsgtk_export_submenu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->export_menu = GTK_MENU(gtk_menu_new());
if (ret->export_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -162,12 +163,12 @@ static struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(
struct nsgtk_scaleview_submenu *ret =
malloc(sizeof(struct nsgtk_scaleview_submenu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->scaleview_menu = GTK_MENU(gtk_menu_new());
if (ret->scaleview_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -186,12 +187,12 @@ static struct nsgtk_tabs_submenu *nsgtk_menu_tabs_submenu(GtkAccelGroup *group)
{
struct nsgtk_tabs_submenu *ret = malloc(sizeof(struct nsgtk_tabs_submenu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->tabs_menu = GTK_MENU(gtk_menu_new());
if (ret->tabs_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -212,12 +213,12 @@ static struct nsgtk_images_submenu *nsgtk_menu_images_submenu(GtkAccelGroup *gro
struct nsgtk_images_submenu *ret =
malloc(sizeof(struct nsgtk_images_submenu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->images_menu = GTK_MENU(gtk_menu_new());
if (ret->images_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -237,12 +238,12 @@ static struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(
struct nsgtk_toolbars_submenu *ret =
malloc(sizeof(struct nsgtk_toolbars_submenu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->toolbars_menu = GTK_MENU(gtk_menu_new());
if (ret->toolbars_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -266,12 +267,12 @@ static struct nsgtk_developer_submenu *nsgtk_menu_developer_submenu(
struct nsgtk_developer_submenu *dmenu =
malloc(sizeof(struct nsgtk_developer_submenu));
if (dmenu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
dmenu->developer_menu = GTK_MENU(gtk_menu_new());
if (dmenu->developer_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(dmenu);
return NULL;
}
@ -296,13 +297,13 @@ static struct nsgtk_file_menu *nsgtk_menu_file_submenu(GtkAccelGroup *group)
fmenu = malloc(sizeof(struct nsgtk_file_menu));
if (fmenu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
fmenu->file_menu = GTK_MENU(gtk_menu_new());
if (fmenu->file_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(fmenu);
return NULL;
}
@ -333,12 +334,12 @@ static struct nsgtk_edit_menu *nsgtk_menu_edit_submenu(GtkAccelGroup *group)
{
struct nsgtk_edit_menu *ret = malloc(sizeof(struct nsgtk_edit_menu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->edit_menu = GTK_MENU(gtk_menu_new());
if (ret->edit_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -365,12 +366,12 @@ static struct nsgtk_view_menu *nsgtk_menu_view_submenu(GtkAccelGroup *group)
{
struct nsgtk_view_menu *ret = malloc(sizeof(struct nsgtk_view_menu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->view_menu = GTK_MENU(gtk_menu_new());
if (ret->view_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -403,12 +404,12 @@ static struct nsgtk_nav_menu *nsgtk_menu_nav_submenu(GtkAccelGroup *group)
{
struct nsgtk_nav_menu *ret = malloc(sizeof(struct nsgtk_nav_menu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->nav_menu = GTK_MENU(gtk_menu_new());
if (ret->nav_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -437,12 +438,12 @@ static struct nsgtk_tools_menu *nsgtk_menu_tools_submenu(GtkAccelGroup *group)
{
struct nsgtk_tools_menu *ret = malloc(sizeof(struct nsgtk_tools_menu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->tools_menu = GTK_MENU(gtk_menu_new());
if (ret->tools_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
@ -463,12 +464,12 @@ static struct nsgtk_help_menu *nsgtk_menu_help_submenu(GtkAccelGroup *group)
{
struct nsgtk_help_menu *ret = malloc(sizeof(struct nsgtk_help_menu));
if (ret == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
ret->help_menu = GTK_MENU(gtk_menu_new());
if (ret->help_menu == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}

View File

@ -49,6 +49,7 @@
#include "content/hlcache.h"
#include "gtk/compat.h"
#include "gtk/warn.h"
#include "gtk/cookies.h"
#include "gtk/completion.h"
#include "gtk/preferences.h"
@ -409,7 +410,7 @@ gboolean nsgtk_window_url_activate_event(GtkWidget *widget, gpointer data)
nsurl_unref(url);
}
if (ret != NSERROR_OK) {
warn_user(messages_get_errorcode(ret), 0);
nsgtk_warning(messages_get_errorcode(ret), 0);
}
return TRUE;
@ -510,7 +511,7 @@ static void nsgtk_openfile_open(const char *filename)
error = nsurl_create(urltxt, &url);
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
nsgtk_warning(messages_get_errorcode(error), 0);
} else {
browser_window_navigate(bw,
url,
@ -550,7 +551,7 @@ MULTIHANDLER(newwindow)
nsurl_unref(url);
}
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
nsgtk_warning(messages_get_errorcode(error), 0);
}
return TRUE;
@ -571,7 +572,7 @@ nserror nsgtk_scaffolding_new_tab(struct gui_window *gw)
}
error = nsurl_create(addr, &url);
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
nsgtk_warning(messages_get_errorcode(error), 0);
}
}
@ -593,7 +594,7 @@ MULTIHANDLER(newtab)
error = nsgtk_scaffolding_new_tab(g->top_level);
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
nsgtk_warning(messages_get_errorcode(error), 0);
}
return TRUE;
}
@ -661,7 +662,7 @@ MULTIHANDLER(savepage)
if (res != NSERROR_OK) {
path = strdup(messages_get("SaveText"));
if (path == NULL) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
return FALSE;
}
}
@ -683,9 +684,9 @@ MULTIHANDLER(savepage)
if (d == NULL) {
LOG("Unable to open directory %s for complete save: %s", path, strerror(errno));
if (errno == ENOTDIR)
warn_user("NoDirError", path);
nsgtk_warning("NoDirError", path);
else
warn_user("gtkFileError", path);
nsgtk_warning("gtkFileError", path);
gtk_widget_destroy(fc);
g_free(path);
return TRUE;
@ -717,7 +718,7 @@ MULTIHANDLER(pdf)
res = nsurl_nice(browser_window_get_url(bw), &url_name, true);
if (res != NSERROR_OK) {
warn_user(messages_get_errorcode(res), 0);
nsgtk_warning(messages_get_errorcode(res), 0);
return TRUE;
}
@ -757,7 +758,7 @@ MULTIHANDLER(pdf)
g_free(filename);
if (settings == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
gtk_widget_destroy(save_dialog);
return TRUE;
}
@ -794,7 +795,7 @@ MULTIHANDLER(plaintext)
if (res != NSERROR_OK) {
filename = strdup(messages_get("SaveText"));
if (filename == NULL) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
return FALSE;
}
}
@ -846,7 +847,7 @@ MULTIHANDLER(print)
print_op = gtk_print_operation_new();
if (print_op == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return TRUE;
}
@ -867,7 +868,7 @@ MULTIHANDLER(print)
page_setup = gtk_print_run_page_setup_dialog(g->window, NULL, NULL);
if (page_setup == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
free(settings_fname);
g_object_unref(print_op);
return TRUE;
@ -951,7 +952,7 @@ MENUHANDLER(savelink)
NULL,
NULL);
if (err != NSERROR_OK) {
warn_user(messages_get_errorcode(err), 0);
nsgtk_warning(messages_get_errorcode(err), 0);
}
return TRUE;
@ -973,7 +974,7 @@ MENUHANDLER(link_openwin)
err = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
current_menu_features.link, NULL, bw, NULL);
if (err != NSERROR_OK) {
warn_user(messages_get_errorcode(err), 0);
nsgtk_warning(messages_get_errorcode(err), 0);
}
return TRUE;
@ -999,7 +1000,7 @@ MENUHANDLER(link_opentab)
BW_CREATE_TAB,
current_menu_features.link, NULL, bw, NULL);
if (err != NSERROR_OK) {
warn_user(messages_get_errorcode(err), 0);
nsgtk_warning(messages_get_errorcode(err), 0);
}
temp_open_background = -1;
@ -1174,7 +1175,7 @@ MULTIHANDLER(viewsource)
ret = nsgtk_viewsource(g->window, nsgtk_get_browser_window(g->top_level));
if (ret != NSERROR_OK) {
warn_user(messages_get_errorcode(ret), 0);
nsgtk_warning(messages_get_errorcode(ret), 0);
}
return TRUE;
@ -1317,7 +1318,7 @@ MULTIHANDLER(debugboxtree)
/* save data to temporary file */
f = fopen(fname, "w");
if (f == NULL) {
warn_user("Error saving box tree dump.",
nsgtk_warning("Error saving box tree dump.",
"Unable to open file for writing.");
unlink(fname);
return TRUE;
@ -1352,7 +1353,7 @@ MULTIHANDLER(debugdomtree)
/* save data to temporary file */
f = fopen(fname, "w");
if (f == NULL) {
warn_user("Error saving box tree dump.",
nsgtk_warning("Error saving box tree dump.",
"Unable to open file for writing.");
unlink(fname);
return TRUE;
@ -1444,7 +1445,7 @@ MULTIHANDLER(home)
error = nsurl_create(addr, &url);
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
nsgtk_warning(messages_get_errorcode(error), 0);
} else {
browser_window_navigate(bw,
url,
@ -1561,7 +1562,7 @@ MULTIHANDLER(contents)
error = nsurl_create("http://www.netsurf-browser.org/documentation/", &url);
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
nsgtk_warning(messages_get_errorcode(error), 0);
} else {
browser_window_navigate(bw,
url,
@ -1582,7 +1583,7 @@ MULTIHANDLER(guide)
nsurl *url;
if (nsurl_create("http://www.netsurf-browser.org/documentation/guide", &url) != NSERROR_OK) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
} else {
browser_window_navigate(bw,
url,
@ -1603,7 +1604,7 @@ MULTIHANDLER(info)
nsurl *url;
if (nsurl_create("http://www.netsurf-browser.org/documentation/info", &url) != NSERROR_OK) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
} else {
browser_window_navigate(bw,
url,

View File

@ -36,6 +36,7 @@
#include "desktop/searchweb.h"
#include "desktop/gui_search.h"
#include "gtk/warn.h"
#include "gtk/compat.h"
#include "gtk/search.h"
#include "gtk/scaffolding.h"
@ -214,7 +215,7 @@ gboolean nsgtk_websearch_activate(GtkWidget *widget, gpointer data)
nsurl_unref(url);
}
if (ret != NSERROR_OK) {
warn_user(messages_get_errorcode(ret), 0);
nsgtk_warning(messages_get_errorcode(ret), 0);
}
return TRUE;

View File

@ -28,6 +28,7 @@
#include "utils/utils.h"
#include "gtk/gui.h"
#include "gtk/warn.h"
#include "gtk/scaffolding.h"
#include "gtk/search.h"
#include "gtk/throbber.h"
@ -219,7 +220,7 @@ static struct nsgtk_theme *nsgtk_theme_load(GtkIconSize iconsize)
int btnloop;
if (theme == NULL) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
return NULL;
}
@ -431,7 +432,7 @@ nsgtk_toolbar_make_widget(struct nsgtk_scaffolding *g,
w = GTK_WIDGET(gtk_tool_item_new());
if ((entry == NULL) || (w == NULL)) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
@ -486,7 +487,7 @@ nsgtk_toolbar_make_widget(struct nsgtk_scaffolding *g,
w = GTK_WIDGET(gtk_tool_item_new());
if ((entry == NULL) || (w == NULL)) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
@ -582,7 +583,7 @@ nsgtk_toolbar_data(GtkWidget *widget,
struct nsgtk_theme *theme =
nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
if (theme == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return TRUE;
}
if (nsgtk_scaffolding_button(g, window->currentbutton)->location
@ -613,7 +614,7 @@ nsgtk_toolbar_data(GtkWidget *widget,
free(theme);
if (nsgtk_scaffolding_button(g, window->currentbutton)->button
== NULL) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
return TRUE;
}
/* update logical schema */
@ -735,7 +736,7 @@ static void nsgtk_toolbar_close(struct nsgtk_scaffolding *g)
while (list) {
theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
if (theme == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
continue;
}
/* clear toolbar */
@ -810,7 +811,7 @@ static bool nsgtk_toolbar_add_store_widget(GtkWidget *widget)
if (window->numberh >= NSGTK_STORE_WIDTH) {
window->currentbar = gtk_toolbar_new();
if (window->currentbar == NULL) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
return false;
}
gtk_toolbar_set_style(GTK_TOOLBAR(window->currentbar),
@ -840,7 +841,7 @@ static void nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g)
int i;
FILE *f = fopen(toolbar_indices_file_location, "w");
if (f == NULL){
warn_user("gtkFileError", toolbar_indices_file_location);
nsgtk_warning("gtkFileError", toolbar_indices_file_location);
return;
}
for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
@ -996,7 +997,7 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g)
theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
if (theme == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
nsgtk_toolbar_cancel_clicked(NULL, g);
return;
}
@ -1004,7 +1005,7 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g)
res = nsgtk_builder_new_from_resname("toolbar", &window->builder);
if (res != NSERROR_OK) {
LOG("Toolbar UI builder init failed");
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
nsgtk_toolbar_cancel_clicked(NULL, g);
free(theme);
return;
@ -1015,7 +1016,7 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g)
window->window = GTK_WIDGET(gtk_builder_get_object(window->builder,
"toolbarwindow"));
if (window->window == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
nsgtk_toolbar_cancel_clicked(NULL, g);
free(theme);
return;
@ -1024,7 +1025,7 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g)
window->widgetvbox = GTK_WIDGET(gtk_builder_get_object(window->builder,
"widgetvbox"));
if (window->widgetvbox == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
nsgtk_toolbar_cancel_clicked(NULL, g);
free(theme);
return;
@ -1042,7 +1043,7 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g)
window->store_buttons[i] =
nsgtk_toolbar_make_widget(g, i, theme);
if (window->store_buttons[i] == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
continue;
}
nsgtk_toolbar_add_store_widget(window->store_buttons[i]);
@ -1189,7 +1190,7 @@ void nsgtk_toolbar_set_physical(struct nsgtk_scaffolding *g)
struct nsgtk_theme *theme =
nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
if (theme == NULL) {
warn_user(messages_get("NoMemory"), 0);
nsgtk_warning(messages_get("NoMemory"), 0);
return;
}
/* simplest is to clear the toolbar then reload it from memory */
@ -1389,7 +1390,7 @@ void nsgtk_toolbar_customization_load(struct nsgtk_scaffolding *g)
(i <= THROBBER_ITEM) ? i : -1;
FILE *f = fopen(toolbar_indices_file_location, "r");
if (f == NULL) {
warn_user(messages_get("gtkFileError"),
nsgtk_warning(messages_get("gtkFileError"),
toolbar_indices_file_location);
return;
}

View File

@ -36,6 +36,7 @@
#include "desktop/tree.h"
#include "desktop/plotters.h"
#include "gtk/warn.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
#include "gtk/plotters.h"
@ -536,7 +537,7 @@ struct nsgtk_treeview *nsgtk_treeview_create(unsigned int flags,
tv = malloc(sizeof(struct nsgtk_treeview));
if (tv == NULL) {
LOG("malloc failed");
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
return NULL;
}

View File

@ -45,6 +45,7 @@
#include "content/hlcache.h"
#include "content/content.h"
#include "gtk/warn.h"
#include "gtk/about.h"
#include "gtk/fetch.h"
#include "gtk/compat.h"
@ -544,7 +545,7 @@ tab_init(const char *title,
/* save data to temporary file */
f = fopen(fname, "w");
if (f == NULL) {
warn_user(messages_get("gtkSourceTabError"), 0);
nsgtk_warning(messages_get("gtkSourceTabError"), 0);
g_free(fname);
return NSERROR_SAVE_FAILED;
}
@ -907,7 +908,7 @@ editor_init(const char *title,
/* save data to temporary file */
f = fopen(fname, "w");
if (f == NULL) {
warn_user(messages_get("gtkSourceTabError"), 0);
nsgtk_warning(messages_get("gtkSourceTabError"), 0);
g_free(fname);
return NSERROR_SAVE_FAILED;
}

32
gtk/warn.h Normal file
View File

@ -0,0 +1,32 @@
/*
* Copyright 2016 Vincent Sanders <vince@netsurf-browser.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 GTK_WARN_H
#define GTK_WARN_H
/**
* Warn the user of an event.
*
* \param[in] warning A warning looked up in the message translation table
* \param[in] detail Additional text to be displayed or NULL.
* \return NSERROR_OK on success or error code if there was a
* faliure displaying the message to the user.
*/
nserror nsgtk_warning(const char *warning, const char *detail);
#endif

View File

@ -47,6 +47,7 @@
#include "desktop/plotters.h"
#include "render/form.h"
#include "gtk/warn.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
@ -753,7 +754,7 @@ gui_window_create(struct browser_window *bw,
g = calloc(1, sizeof(*g));
if (!g) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
g_object_unref(tab_builder);
return NULL;
}
@ -777,7 +778,7 @@ gui_window_create(struct browser_window *bw,
g->scaffold = nsgtk_new_scaffolding(g);
}
if (g->scaffold == NULL) {
warn_user("NoMemory", 0);
nsgtk_warning("NoMemory", 0);
free(g);
g_object_unref(tab_builder);
return NULL;