[vte/vte-next] vteapp: Add option to apply custom CSS
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next] vteapp: Add option to apply custom CSS
- Date: Sun, 22 May 2011 22:18:10 +0000 (UTC)
commit a804e33f0ebfc0fd970a47c06416711eed68ea74
Author: Christian Persch <chpe gnome org>
Date: Sun May 15 20:41:15 2011 +0200
vteapp: Add option to apply custom CSS
For testing purposes, allow loading extra CSS from either a file or
a string.
src/vteapp.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/src/vteapp.c b/src/vteapp.c
index b054720..acf598f 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -562,6 +562,8 @@ main(int argc, char **argv)
char *cursor_shape_string = NULL;
char *scrollbar_policy_string = NULL;
char *border_width_string = NULL;
+ char *css = NULL;
+ char *css_file = NULL;
GdkRGBA fore, back, highlight, cursor, tint;
const GOptionEntry options[]={
{
@@ -715,6 +717,16 @@ main(int argc, char **argv)
G_OPTION_ARG_STRING, &border_width_string,
"Border with", "WIDTH"
},
+ {
+ "css", 0, 0,
+ G_OPTION_ARG_STRING, &css,
+ "Inline CSS", "CSS"
+ },
+ {
+ "css-file", 0, 0,
+ G_OPTION_ARG_FILENAME, &css_file,
+ "CSS File", "FILE"
+ },
{ NULL }
};
GOptionContext *context;
@@ -760,6 +772,39 @@ main(int argc, char **argv)
g_free(pty_flags_string);
}
+ if (css_file) {
+ GtkCssProvider *provider;
+ GError *err = NULL;
+
+ provider = gtk_css_provider_new();
+ if (gtk_css_provider_load_from_path(provider, css_file, &err)) {
+ gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
+ GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ } else {
+ g_printerr("Failed to load CSS file: %s\n", err->message);
+ g_error_free(err);
+ }
+ g_object_unref(provider);
+ g_free(css_file);
+ }
+ if (css) {
+ GtkCssProvider *provider;
+ GError *err = NULL;
+
+ provider = gtk_css_provider_new();
+ if (gtk_css_provider_load_from_data(provider, css, -1, &err)) {
+ gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
+ GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ } else {
+ g_printerr("Failed to parse CSS: %s\n", err->message);
+ g_error_free(err);
+ }
+ g_object_unref(provider);
+ g_free(css_file);
+ }
+
if (!reverse) {
back.red = back.green = back.blue = 1.0; back.alpha = 1.0;
fore.red = fore.green = fore.blue = 0.0; fore.alpha = 1.0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]