Commit 35f6ad5c authored by Victor Ananjevsky's avatar Victor Ananjevsky

load user css from file or arbitrary string

parent 2a61b5f2
......@@ -637,8 +637,8 @@ Set external handler for clicked uri. \fI%s\fP will be replaced by activated uri
.B \-\-user-agent=\fISTRING\fP
Set user agent string. Default is \fIYAD-Webkit (@VERSION@)\fP
.TP
.B \-\-user-style=\fIURI\fP
Set path or uri to custom user styles. Path to local file can be an absolute file name or uri with \fIfile://\fP prefix.
.B \-\-user-style=\fISTRING\fP
Load custom custom user styles from file or arbitrary data. \fISTRING\fP may be a path to local file with CSS code or CSS code itself.
.TP
.B \-\-disable-search
Disable search bar.
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: YAD\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-12-06 15:26+0200\n"
"POT-Creation-Date: 2022-12-27 17:48+0200\n"
"PO-Revision-Date: 2021-11-28 19:00+0200\n"
"Last-Translator: Victor Ananjevsky <ananasik@gmail.com>\n"
"Language-Team: \n"
......@@ -71,13 +71,13 @@ msgid "Select files"
msgstr "Вибрати файли"
#: ../src/form.c:507 ../src/form.c:515 ../src/form.c:594 ../src/form.c:602
#: ../src/form.c:653 ../src/html.c:220 ../src/html.c:253 ../src/picture.c:296
#: ../src/form.c:653 ../src/html.c:227 ../src/html.c:260 ../src/picture.c:296
#: ../src/text.c:121 ../src/text.c:192 ../src/util.c:40
msgid "Cancel"
msgstr "Скасувати"
#: ../src/form.c:508 ../src/form.c:516 ../src/form.c:595 ../src/form.c:603
#: ../src/form.c:654 ../src/html.c:221 ../src/picture.c:297 ../src/text.c:122
#: ../src/form.c:654 ../src/html.c:228 ../src/picture.c:297 ../src/text.c:122
#: ../src/text.c:193 ../src/util.c:46
msgid "OK"
msgstr "Гаразд"
......@@ -110,23 +110,23 @@ msgstr "Вибрати теку"
msgid "Link"
msgstr "Посилання"
#: ../src/html.c:217 ../src/text.c:118 ../src/text.c:189
#: ../src/html.c:224 ../src/text.c:118 ../src/text.c:189
msgid "YAD - Select File"
msgstr "YAD - Вибір файлу"
#: ../src/html.c:251 ../src/html.c:299
#: ../src/html.c:258 ../src/html.c:306
msgid "Open URI"
msgstr "Відкрити URI"
#: ../src/html.c:254 ../src/util.c:47
#: ../src/html.c:261 ../src/util.c:47
msgid "Open"
msgstr "Відкрити"
#: ../src/html.c:260
#: ../src/html.c:267
msgid "Enter URI or file name:"
msgstr "Введіть URI або ім'я файлу:"
#: ../src/html.c:309 ../src/util.c:49
#: ../src/html.c:316 ../src/util.c:49
msgid "Quit"
msgstr "Вихід"
......@@ -189,35 +189,35 @@ msgstr "Невідома команда '%s'\n"
msgid "Yad notification"
msgstr "Діалог повідомлень"
#: ../src/list.c:1115
#: ../src/list.c:1112
msgid "Add row"
msgstr "Додати рядок"
#: ../src/list.c:1122
#: ../src/list.c:1119
msgid "Add child row"
msgstr "Додати дочірній рядок"
#: ../src/list.c:1129
#: ../src/list.c:1126
msgid "Delete row"
msgstr "Видалити рядок"
#: ../src/list.c:1136
#: ../src/list.c:1133
msgid "Edit row"
msgstr "Редагувати рядок"
#: ../src/list.c:1142
#: ../src/list.c:1139
msgid "Duplicate row"
msgstr "Скопіювати рядок"
#: ../src/list.c:1151
#: ../src/list.c:1148
msgid "Move row up"
msgstr "Перемістити рядок вгору"
#: ../src/list.c:1156
#: ../src/list.c:1153
msgid "Move row down"
msgstr "Перемістити рядок вниз"
#: ../src/list.c:1297
#: ../src/list.c:1294
#, c-format
msgid ""
"WARNING: You are use --checklist or --radiolist option. Those options "
......@@ -226,7 +226,7 @@ msgstr ""
"УВАГА: Використовуються опції --checklist або --radiolist. Ці опції "
"застаріли та будуть видалені у майбутніх випусках\n"
#: ../src/list.c:1303
#: ../src/list.c:1300
#, c-format
msgid "No column titles specified for List dialog.\n"
msgstr "Не задані заголовки стовпчиків для діалогу зі списком\n"
......@@ -647,8 +647,8 @@ msgid "Set application name"
msgstr "Задати ім'я програми"
#: ../src/option.c:256 ../src/option.c:258 ../src/option.c:260
#: ../src/option.c:270 ../src/option.c:416 ../src/option.c:541
#: ../src/option.c:729
#: ../src/option.c:270 ../src/option.c:416 ../src/option.c:418
#: ../src/option.c:541 ../src/option.c:729
msgid "STRING"
msgstr "РЯДОК"
......@@ -941,8 +941,8 @@ msgid "Set user agent string"
msgstr "Задати стрічку агента"
#: ../src/option.c:418
msgid "Set path or uri to user styles"
msgstr "Задати URI або шлях до стилей користувача"
msgid "Set custom user style"
msgstr "Задати стиль користувача"
#: ../src/option.c:420
msgid "Set WebKit property"
......
......@@ -515,24 +515,28 @@ html_create_widget (GtkWidget * dlg)
/* add user defined css */
if (options.html_data.user_style)
{
gchar *css;
gchar *css = NULL;
GError *err = NULL;
if (g_file_get_contents (options.html_data.user_style, &css, NULL, &err))
if (g_file_test (options.html_data.user_style, G_FILE_TEST_EXISTS))
{
WebKitUserStyleSheet *wk_css;
if (!g_file_get_contents (options.html_data.user_style, &css, NULL, &err))
{
g_printerr ("yad_html: unable to load user css file: %s\n", err->message);
g_error_free (err);
}
}
else
css = g_strdup (options.html_data.user_style);
if (css)
{
WebKitUserStyleSheet *wk_css;
wk_css = webkit_user_style_sheet_new (css, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL);
webkit_user_content_manager_add_style_sheet (wk_cman, wk_css);
g_free (css);
}
else
{
g_printerr ("yad_html: unable to load user css file: %s\n", err->message);
g_error_free (err);
}
}
gtk_widget_show_all (sw);
......
......@@ -415,7 +415,7 @@ static GOptionEntry html_options[] = {
{ "user-agent", 0, 0, G_OPTION_ARG_STRING, &options.html_data.user_agent,
N_("Set user agent string"), N_("STRING") },
{ "user-style", 0, 0, G_OPTION_ARG_STRING, &options.html_data.user_style,
N_("Set path or uri to user styles"), "URI" },
N_("Set custom user style"), N_("STRING") },
{ "wk-prop", 0, 0, G_OPTION_ARG_STRING_ARRAY, &options.html_data.wk_props,
N_("Set WebKit property"), N_("PROP") },
{ NULL }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment