Convert ConversationWebView HML CSS file to a resource, remove theme dir.

* src/client/application/geary-application.vala
  (GearyApplication::read_theme_file): Renamed to ::read_resource, do the
  lookup on a GResource instead of from the file system.
  (GearyApplication::get_ui_file): Remove unused method.

* src/client/conversation-viewer/conversation-web-view.vala
  (ConversationWebView): Chase CSS file rename and load method.

* theming/CMakeLists.txt: Removed, no longer needed.

* theming/message-viewer.css: Moved to ui/conversation-web-view.css.

* ui/CMakeLists.txt: Add conversation-web-view.css resource.

* CMakeLists.txt: Remove theming include.

* src/client/application/geary-application.vala :
This commit is contained in:
Michael James Gratton 2016-04-22 15:41:05 +10:00
parent aa0471f17a
commit 3dcf3ce7d6
6 changed files with 13 additions and 24 deletions

View file

@ -212,4 +212,3 @@ add_subdirectory(po)
add_subdirectory(sql)
add_subdirectory(ui)
add_subdirectory(src)
add_subdirectory(theming)

View file

@ -295,23 +295,16 @@ public class GearyApplication : Gtk.Application {
return builder;
}
public string? read_theme_file(string filename) {
try {
File file = get_resource_directory().get_child("theming").get_child(filename);
DataInputStream data_input_stream = new DataInputStream(file.read());
size_t length;
return data_input_stream.read_upto("\0", 1, out length);
} catch(Error error) {
debug("Unable to load text from theme file: %s", error.message);
return null;
}
public string read_resource(string name) throws Error {
InputStream input_stream = resources_open_stream(
"/org/gnome/Geary/" + name,
ResourceLookupFlags.NONE
);
DataInputStream data_stream = new DataInputStream(input_stream);
size_t length;
return data_stream.read_upto("\0", 1, out length);
}
public File get_ui_file(string filename) {
return get_resource_directory().get_child("ui").get_child(filename);
}
// Loads a UI GResource into the specified UI manager.
public void load_ui_resource_for_manager(Gtk.UIManager ui, string name) {
try {

View file

@ -69,7 +69,7 @@ public class ConversationWebView : StylishWebView {
// Overridden since WebKitGTK+ 2.4.10 at least doesn't want to
// report a useful height. In combination with the rules from
// theming/message-viewer.css we can get an accurate idea of
// ui/conversation-web-view.css we can get an accurate idea of
// the actual height of the content from the BODY element, but
// only once loaded.
public override void get_preferred_height(out int minimum_height,
@ -134,14 +134,14 @@ public class ConversationWebView : StylishWebView {
WebKit.DOM.Document document = get_dom_document();
WebKit.DOM.Element style_element = document.create_element(STYLE_NAME);
string css_text = GearyApplication.instance.read_theme_file("message-viewer.css") ?? "";
string css_text = GearyApplication.instance.read_resource("conversation-web-view.css");
WebKit.DOM.Text text_node = document.create_text_node(css_text);
style_element.append_child(text_node);
WebKit.DOM.HTMLHeadElement head_element = document.get_head();
head_element.append_child(style_element);
} catch (Error error) {
debug("Unable to load message-viewer document from files: %s", error.message);
debug("Error loading conversation-web-view.css: %s", error.message);
}
on_document_font_changed();

View file

@ -1,4 +0,0 @@
set(THEMING_DEST share/geary/theming)
install(FILES message-viewer.html DESTINATION ${THEMING_DEST})
install(FILES message-viewer.css DESTINATION ${THEMING_DEST})

View file

@ -12,6 +12,7 @@ set(RESOURCE_LIST
STRIPBLANKS "conversation-message.ui"
STRIPBLANKS "conversation-message-menu.ui"
STRIPBLANKS "conversation-viewer.ui"
"conversation-web-view.css"
STRIPBLANKS "edit_alternate_emails.glade"
STRIPBLANKS "find_bar.glade"
STRIPBLANKS "folder-popover.ui"