[bijiben] Install a single css file. Amend it at runtime.
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] Install a single css file. Amend it at runtime.
- Date: Sun, 24 Aug 2014 13:13:16 +0000 (UTC)
commit 61c55df2ffa57c9c65ee394118be38b5b0e6586f
Author: mtbar131 <mtbar131 gmail com>
Date: Sun Aug 24 14:49:57 2014 +0200
Install a single css file. Amend it at runtime.
data/Default-white.css | 32 -----------------
data/{Default-black.css => Default.css} | 2 +-
data/Makefile.am | 3 +-
src/libbiji/editor/biji-webkit-editor.c | 58 ++++++++++++++++++++++++++----
4 files changed, 52 insertions(+), 43 deletions(-)
---
diff --git a/data/Default-black.css b/data/Default.css
similarity index 94%
rename from data/Default-black.css
rename to data/Default.css
index d319187..3bb4265 100644
--- a/data/Default-black.css
+++ b/data/Default.css
@@ -9,7 +9,7 @@ body {
rgba(97%,97%,100%,0) 0%,
rgba(97%,97%,100%,0) 90%,
rgba(0%,0%,0%,0.15) 100%);
- color: black;
+ color: _BIJI_TEXT_COLOR;
background-size: 2.0em 2.0em;
line-height: 2.0em;
padding: 2.0em;
diff --git a/data/Makefile.am b/data/Makefile.am
index 1ceabbd..8bba979 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -40,8 +40,7 @@ org.gnome.Bijiben.SearchProvider.service: org.gnome.Bijiben.SearchProvider.servi
searchproviderdir = $(datadir)/gnome-shell/search-providers
searchprovider_DATA = bijiben-search-provider.ini
-css_files = Default-black.css \
- Default-white.css
+css_files = Default.css
cssdir = $(pkgdatadir)
css_DATA = $(css_files)
diff --git a/src/libbiji/editor/biji-webkit-editor.c b/src/libbiji/editor/biji-webkit-editor.c
index 1160004..af418ef 100644
--- a/src/libbiji/editor/biji-webkit-editor.c
+++ b/src/libbiji/editor/biji-webkit-editor.c
@@ -465,29 +465,71 @@ biji_webkit_editor_new (BijiNoteObj *note)
NULL);
}
+
void
biji_webkit_editor_change_css_file(BijiWebkitEditor *self)
{
BijiWebkitEditorPrivate *priv;
- gchar *css_path;
+ const gchar *system_temp_dir;
+ gchar *path_src, *path_dest, *css_path, *bijiben_temp_dir_path;
+ GFile *src, *dest, *bijiben_temp_dir_URI;
+ GString *sed_command;
GdkRGBA color;
+ GError *error;
priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_WEBKIT_EDITOR, BijiWebkitEditorPrivate);
biji_note_obj_get_rgba(priv->note,&color);
+ /* Get temp directory from system */
+ system_temp_dir = g_get_tmp_dir();
+
+ /* build the path for source and Destination of Default.css */
+ path_src = g_build_filename(DATADIR, "bijiben", "Default.css", NULL);
+ src = g_file_new_for_path(path_src);
+
+ path_dest = g_build_filename(system_temp_dir, "bijiben", "Default.css", NULL);
+ dest = g_file_new_for_path(path_dest);
+
+ /* Generate Temp directory path and URI for bijiben */
+ bijiben_temp_dir_path = g_build_filename(system_temp_dir, "bijiben", NULL);
+ bijiben_temp_dir_URI = g_file_new_for_path(bijiben_temp_dir_path);
+ g_file_make_directory(bijiben_temp_dir_URI, NULL, NULL);
+
+ /* Generate sed for Default.css Color */
if(color.red < 0.5)
- css_path = g_build_filename ("file://",
- DATADIR, "bijiben",
- "Default-white.css",NULL);
+ sed_command = g_string_new("sed -i s/_BIJI_TEXT_COLOR/white/g ");
else
- css_path = g_build_filename ("file://",
- DATADIR, "bijiben",
- "Default-black.css",NULL);
+ sed_command = g_string_new("sed -i s/_BIJI_TEXT_COLOR/black/g ");
+
+ g_string_append_printf(sed_command, "%s", path_dest);
+
+ /* copy the Default.css file */
+ g_file_copy(src, dest, G_FILE_COPY_OVERWRITE,
+ NULL, NULL, NULL, &error);
+ g_spawn_command_line_sync(sed_command->str, NULL,
+ NULL, NULL, &error);
+
+ css_path = g_file_get_uri(dest);
+
+ /* Change the css path to NULL and then
+ again set it back to actual css path
+ so that changes in css file are considered
+ immediately */
g_object_set (G_OBJECT(priv->settings),
- "user-stylesheet-uri", css_path, NULL);
+ "user-stylesheet-uri", NULL,
+ NULL);
+
+ g_object_set (G_OBJECT(priv->settings),
+ "user-stylesheet-uri", css_path,
+ NULL);
g_free (css_path);
+ g_free (path_src);
+ g_free (path_dest);
+ g_free (bijiben_temp_dir_path);
+ g_string_free(sed_command, TRUE);
+
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]