You need to sign in or sign up before continuing.
Commit 4b54d144 authored by Victor Ananjevsky's avatar Victor Ananjevsky

add customizable options for text dialog (with using css)

parent 04318ff1
......@@ -881,7 +881,13 @@ Show cursor in read-only mode.
.B \-\-show-uri
Make links in text clickable. Links opens with \fIxdg-open\fP command.
.TP
.B \-\-uri-color
.B \-\-fore=\fICOLOR\fP
Set default color for text.
.TP
.B \-\-back=\fICOLOR\fP
Set default color for background.
.TP
.B \-\-uri-color=\fICOLOR\fP
Set color for links. Default is \fIblue\fP.
.TP
.B \-\-lang=LANGUAGE
......@@ -893,6 +899,7 @@ Set used theme to \fITHEME\fP. This option works only if yad builds with gtksour
.B \-\-listen
Listen data from stdin even if filename was specified.
If \fIfontname\fP option is specified for text dialog, the description of font must be in CSS style (not in a Pango style).
Sending FormFeed character to text dialog clears it. This symbol may be sent as \fIecho \-e '\\f'\fP.
Pressing \fICtrl+S\fP popups the search entry in text dialog.
......
......@@ -601,6 +601,10 @@ static GOptionEntry text_options[] = {
N_("Set justification (left, right, center or fill)"), N_("TYPE") },
{ "margins", 0, 0, G_OPTION_ARG_INT, &options.text_data.margins,
N_("Set text margins"), N_("SIZE") },
{ "fore", 0, 0, G_OPTION_ARG_STRING, &options.text_data.fore,
N_("Use specified color for text"), N_("COLOR") },
{ "back", 0, 0, G_OPTION_ARG_STRING, &options.text_data.back,
N_("Use specified color for background"), N_("COLOR") },
{ "show-cursor", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &options.text_data.hide_cursor,
N_("Show cursor in read-only mode"), NULL },
{ "show-uri", 0, 0, G_OPTION_ARG_NONE, &options.text_data.uri,
......@@ -1707,6 +1711,8 @@ yad_options_init (void)
options.text_data.justify = GTK_JUSTIFY_LEFT;
options.text_data.margins = 0;
options.text_data.hide_cursor = TRUE;
options.text_data.fore = NULL;
options.text_data.back = NULL;
#ifndef STANDALONE
options.text_data.uri_color = g_settings_get_string (settings, "uri-color");
#else
......
......@@ -449,6 +449,30 @@ text_create_widget (GtkWidget * dlg)
if (options.text_data.wrap)
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD_CHAR);
if (options.common_data.font || options.text_data.fore || options.text_data.back)
{
GtkCssProvider *provider;
GtkStyleContext *context;
GString *css;
css = g_string_new ("textview, textview text {\n");
if (options.common_data.font)
g_string_append_printf (css, " font: %s;\n", options.common_data.font);
if (options.text_data.fore)
g_string_append_printf (css, " color: %s;\n", options.text_data.fore);
if (options.text_data.back)
g_string_append_printf (css, " background-color: %s;\n", options.text_data.back);
g_string_append (css, "}\n");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css->str, -1, NULL);
context = gtk_widget_get_style_context (text_view);
gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_string_free (css, TRUE);
}
#ifdef HAVE_SOURCEVIEW
if (options.source_data.theme)
{
......
......@@ -439,6 +439,8 @@ typedef struct {
gboolean hide_cursor;
gchar *uri_color;
gboolean formatted;
gchar *fore;
gchar *back;
} YadTextData;
#ifdef HAVE_SOURCEVIEW
......
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