Bladeren bron

Add basic CSS theme for the HTML output

Matthias Vogelgesang 7 jaren geleden
bovenliggende
commit
34cff1e053
3 gewijzigde bestanden met toevoegingen van 25 en 3 verwijderingen
  1. 10 0
      src/iridium-theme.css
  2. 14 3
      src/iridium-window.c
  3. 1 0
      src/iridium.gresource.xml

+ 10 - 0
src/iridium-theme.css

@@ -0,0 +1,10 @@
+body {
+  font-family: 'PT serif', serif;
+  font-size: 18px;
+  margin: 12px;
+  line-height: 1.6em;
+}
+
+h1,h2,h3,h4,h5,h6 {
+  font-family: 'Roboto Condensed', 'Source Sans Pro', sans-serif;
+}

+ 14 - 3
src/iridium-window.c

@@ -46,12 +46,11 @@ struct _IridiumWindow
   GtkToggleButton   *toggle_html_view;
   GtkRevealer       *notification_revealer;
   WebKitWebView     *html_view;
-
   GBinding          *title_binding;
   GBinding          *content_binding;
 
-  IridiumMarkdown   *markdown;
-  IridiumStandardFile *client;
+  IridiumMarkdown       *markdown;
+  IridiumStandardFile   *client;
 };
 
 G_DEFINE_TYPE (IridiumWindow, iridium_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -328,6 +327,10 @@ iridium_window_init (IridiumWindow *self)
   GtkStyleProvider *provider;
   GtkSourceBuffer *buffer;
   GSimpleAction *action;
+  GBytes *style_data;
+  WebKitUserContentManager *content_manager;
+  WebKitUserStyleSheet *stylesheet;
+  GError *error = NULL;
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
@@ -337,6 +340,14 @@ iridium_window_init (IridiumWindow *self)
   self->markdown = iridium_markdown_new ();
   self->client = iridium_standard_file_new ();
 
+  style_data = g_resources_lookup_data ("/net/bloerg/Iridium/iridium-theme.css", 
+    G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
+  content_manager = webkit_web_view_get_user_content_manager (self->html_view);
+  stylesheet = webkit_user_style_sheet_new ((const gchar *) g_bytes_get_data (style_data, NULL),
+    WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, WEBKIT_USER_STYLE_LEVEL_AUTHOR, NULL, NULL);
+  webkit_user_content_manager_add_style_sheet (content_manager, stylesheet);
+  g_bytes_unref (style_data);
+
   action = g_simple_action_new ("search", NULL);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
   g_signal_connect (action, "activate", G_CALLBACK (search_activated), self);

+ 1 - 0
src/iridium.gresource.xml

@@ -2,6 +2,7 @@
 <gresources>
   <gresource prefix="/net/bloerg/Iridium">
     <file>iridium.css</file>
+    <file>iridium-theme.css</file>
     <file>iridium-menu.ui</file>
     <file>iridium-note-row.ui</file>
     <file>iridium-signin-dialog.ui</file>