diff options
Diffstat (limited to 'frontends/gtk/gui.c')
-rw-r--r-- | frontends/gtk/gui.c | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c index 609662e05..c65c360fb 100644 --- a/frontends/gtk/gui.c +++ b/frontends/gtk/gui.c @@ -258,35 +258,73 @@ static nserror set_defaults(struct nsoption_s *defaults) return NSERROR_OK; } +#if GTK_CHECK_VERSION(3,14,0) /** * adds named icons into gtk theme */ static nserror nsgtk_add_named_icons_to_theme(void) { -#if GTK_CHECK_VERSION(3,14,0) gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(), "/org/netsurf/icons"); + return NSERROR_OK; +} + #else + +static nserror +add_builtin_icon(const char *prefix, const char *name, int x, int y) +{ GdkPixbuf *pixbuf; nserror res; - - res = nsgdk_pixbuf_new_from_resname("icons/local-history.png", &pixbuf); - if (res != NSERROR_OK) { - pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 8, 32); + char *resname; + int resnamelen; + + /* resource name string length allowing for / .png and termination */ + resnamelen = strlen(prefix) + strlen(name) + 5 + 1 + 4 + 1; + resname = malloc(resnamelen); + if (resname == NULL) { + return NSERROR_NOMEM; } - gtk_icon_theme_add_builtin_icon("local-history", 32, pixbuf); + snprintf(resname, resnamelen, "icons%s/%s.png", prefix, name); - res = nsgdk_pixbuf_new_from_resname("icons/show-cookie.png", &pixbuf); + res = nsgdk_pixbuf_new_from_resname(resname, &pixbuf); + NSLOG(netsurf, WARNING, "%d %s", res, resname); + free(resname); if (res != NSERROR_OK) { - pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 24, 24); + pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, x, y); } - gtk_icon_theme_add_builtin_icon("show-cookie", 24, pixbuf); + gtk_icon_theme_add_builtin_icon(name, y, pixbuf); -#endif return NSERROR_OK; } +/** + * adds named icons into gtk theme + */ +static nserror nsgtk_add_named_icons_to_theme(void) +{ + /* these must also be in gtk/resources.c pixbuf_resource *and* + * gtk/res/netsurf.gresource.xml + */ + add_builtin_icon("", "local-history", 8, 32); + add_builtin_icon("", "show-cookie", 24, 24); + add_builtin_icon("/24x24/actions", "page-info-insecure", 24, 24); + add_builtin_icon("/24x24/actions", "page-info-internal", 24, 24); + add_builtin_icon("/24x24/actions", "page-info-local", 24, 24); + add_builtin_icon("/24x24/actions", "page-info-secure", 24, 24); + add_builtin_icon("/24x24/actions", "page-info-warning", 24, 24); + add_builtin_icon("/48x48/actions", "page-info-insecure", 48, 48); + add_builtin_icon("/48x48/actions", "page-info-internal", 48, 48); + add_builtin_icon("/48x48/actions", "page-info-local", 48, 48); + add_builtin_icon("/48x48/actions", "page-info-secure", 48, 48); + add_builtin_icon("/48x48/actions", "page-info-warning", 48, 48); + + return NSERROR_OK; +} + +#endif + /** * Initialize GTK specific parts of the browser. |