Commit 621eedb5 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

Various style fixes

parent 4c03d1c4
Pipeline #103463 passed with stages
in 28 minutes and 51 seconds
......@@ -2,12 +2,12 @@
<schemalist>
<schema path="/org/gnome/design/BannerViewer/" id="@app-id@" gettext-domain="@gettext-package@">
<key name="window-width" type="i">
<default>-1</default>
<default>800</default>
<summary>Default window width</summary>
<description>Default window width</description>
</key>
<key name="window-height" type="i">
<default>-1</default>
<default>700</default>
<summary>Default window height</summary>
<description>Default window height</description>
</key>
......
......@@ -19,8 +19,19 @@ button:disabled label {
font-weight: bold;
}
.banner-widget{
border: 1px solid mix(@theme_fg_color, @theme_bg_color, 0.7);
.banner{
border-width: 1px;
border-style: solid;
}
.banner-widget.revealed .banner{
border-bottom-width:0;
}
.source-code{
border-color: darker(#EEE8D5);
border-bottom-width:1px;
border-left-width:1px;
border-right-width:1px;
border-style: solid;
}
......@@ -3,11 +3,7 @@
<interface>
<requires lib="gtk+" version="3.20"/>
<requires lib="gtksourceview" version="3.0"/>
<object class="GtkSourceBuffer" id="source_buffer">
</object>
<object class="GtkBox" id="banner">
<object class="GtkBox" id="banner_widget">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
......@@ -17,11 +13,18 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
<object class="GtkBox" id="banner">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<style>
<class name="banner"/>
</style>
</object>
</child>
<style>
<class name="banner"/>
</style>
</object>
<packing>
<property name="expand">False</property>
......@@ -34,23 +37,25 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="reveal_child">False</property>
<child>
<object class="GtkScrolledWindow">
<property name="height_request">200</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkSourceView" id="source_view">
<property name="visible">True</property>
<property name="editable">True</property>
<property name="highlight_current_line">True</property>
<property name="show_line_numbers">True</property>
<property name="can_focus">True</property>
<property name="buffer">source_buffer</property>
</object>
</child>
</object>
<object class="GtkScrolledWindow">
<property name="height_request">200</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkSourceView" id="source_view">
<property name="visible">True</property>
<property name="editable">True</property>
<property name="highlight_current_line">True</property>
<property name="show_line_numbers">True</property>
<property name="can_focus">True</property>
<property name="buffer">source_buffer</property>
</object>
</child>
<style>
<class name="source-code"/>
</style>
</object>
</child>
</object>
<packing>
......@@ -60,4 +65,6 @@
</packing>
</child>
</object>
<object class="GtkSourceBuffer" id="source_buffer">
</object>
</interface>
......@@ -157,11 +157,11 @@ impl Application {
Ok(mut response) => {
let mut dest = File::create(cache_file).expect("Failed to create dest file");
copy(&mut response, &mut dest).expect("Couldn't download the file");
sender.send(Action::RemoveError(resource_url));
sender.send(Action::RemoveError(resource_url)).unwrap();
}
Err(err) => {
warn!("Failed to download the file {}", err);
sender.send(Action::AddError(resource_url, "Failed to download".to_string()));
sender.send(Action::AddError(resource_url, "Failed to download".to_string())).unwrap();
}
});
}
......
......@@ -15,7 +15,7 @@ pub struct Banner {
impl Banner {
pub fn new(sender: Sender<Action>, banner: banners::Banner) -> Rc<Self> {
let builder = gtk::Builder::new_from_resource("/org/gnome/design/BannerViewer/banner.ui");
let widget: gtk::Box = builder.get_object("banner").unwrap();
let widget: gtk::Box = builder.get_object("banner_widget").unwrap();
widget.get_style_context().add_class("banner-widget");
widget.show();
......@@ -51,9 +51,15 @@ impl Banner {
let scheme = sourceview::StyleSchemeManager::get_default().map_or(None, |scm| scm.get_scheme("solarized-light")).unwrap();
source_buffer.set_style_scheme(Some(&scheme));
let parent = self.widget.clone();
event_box.connect_button_press_event(move |_, _| {
let is_revealed = code_revealer.get_reveal_child();
code_revealer.set_reveal_child(!is_revealed);
if !is_revealed {
parent.get_style_context().add_class("revealed");
} else {
parent.get_style_context().remove_class("revealed");
}
gtk::Inhibit(false)
});
......@@ -67,16 +73,19 @@ impl Banner {
}
fn inject_css(&self, css: &str) {
let event_box: gtk::EventBox = self.builder.get_object("banner_eventbox").unwrap();
let banner: gtk::Box = self.builder.get_object("banner").unwrap();
let ctx = banner.get_style_context();
// Inject the banner CSS
let provider = gtk::CssProvider::new();
let mut css = css.replace("@datadir@/gnome-software", &self.banner.resources_dir);
for (url, cache_path) in self.banner.web_resources.borrow().iter() {
css = css.replace(url, cache_path);
}
let css = format!(".banner{{ {} }}", css);
let banner_id = &self.banner.id;
let provider = gtk::CssProvider::new();
match provider.load_from_data(css.as_bytes()) {
Ok(_) => self.sender.send(Action::RemoveError(banner_id.to_string())).unwrap(),
Err(err) => {
......@@ -84,6 +93,6 @@ impl Banner {
self.sender.send(Action::AddError(banner_id.to_string(), err.to_string())).unwrap();
}
};
event_box.get_style_context().add_provider(&provider, 300);
ctx.add_provider(&provider, 300);
}
}
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