mirror of
https://github.com/elementary/gala.git
synced 2024-11-23 20:07:21 +03:00
grab colors for labels from theme (.label and .title)
This commit is contained in:
parent
7815a6e87a
commit
892cf01dab
@ -24,3 +24,7 @@
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.gala-notification .title, .gala-notification .label {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,40 @@ namespace Gala.Plugins.Notify
|
||||
body_label.use_markup = true;
|
||||
body_label.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
|
||||
|
||||
var style_path = new Gtk.WidgetPath ();
|
||||
style_path.append_type (typeof (Gtk.Window));
|
||||
style_path.append_type (typeof (Gtk.EventBox));
|
||||
style_path.iter_add_class (1, "gala-notification");
|
||||
style_path.append_type (typeof (Gtk.Label));
|
||||
|
||||
var label_style_context = new Gtk.StyleContext ();
|
||||
label_style_context.add_provider (Notification.default_css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK);
|
||||
label_style_context.set_path (style_path);
|
||||
|
||||
Gdk.RGBA color;
|
||||
|
||||
label_style_context.save ();
|
||||
label_style_context.add_class ("title");
|
||||
color = label_style_context.get_color (Gtk.StateFlags.NORMAL);
|
||||
summary_label.color = {
|
||||
(uint8) (color.red * 255),
|
||||
(uint8) (color.green * 255),
|
||||
(uint8) (color.blue * 255),
|
||||
(uint8) (color.alpha * 255)
|
||||
};
|
||||
label_style_context.restore ();
|
||||
|
||||
label_style_context.save ();
|
||||
label_style_context.add_class ("label");
|
||||
color = label_style_context.get_color (Gtk.StateFlags.NORMAL);
|
||||
body_label.color = {
|
||||
(uint8) (color.red * 255),
|
||||
(uint8) (color.green * 255),
|
||||
(uint8) (color.blue * 255),
|
||||
(uint8) (color.alpha * 255)
|
||||
};
|
||||
label_style_context.restore ();
|
||||
|
||||
add_child (summary_label);
|
||||
add_child (body_label);
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ namespace Gala.Plugins.Notify
|
||||
{
|
||||
public abstract class Notification : Actor
|
||||
{
|
||||
public static Gtk.CssProvider? default_css = null;
|
||||
|
||||
public const int WIDTH = 300;
|
||||
public const int ICON_SIZE = 48;
|
||||
public const int MARGIN = 12;
|
||||
@ -111,11 +113,13 @@ namespace Gala.Plugins.Notify
|
||||
add_child (icon_container);
|
||||
add_child (close_button);
|
||||
|
||||
var default_css = new Gtk.CssProvider ();
|
||||
try {
|
||||
default_css.load_from_path (Config.PKGDATADIR + "/gala.css");
|
||||
} catch (Error e) {
|
||||
warning ("Loading default styles failed: %s", e.message);
|
||||
if (default_css == null) {
|
||||
default_css = new Gtk.CssProvider ();
|
||||
try {
|
||||
default_css.load_from_path (Config.PKGDATADIR + "/gala.css");
|
||||
} catch (Error e) {
|
||||
warning ("Loading default styles failed: %s", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
var style_path = new Gtk.WidgetPath ();
|
||||
@ -127,6 +131,10 @@ namespace Gala.Plugins.Notify
|
||||
style_context.add_class ("gala-notification");
|
||||
style_context.set_path (style_path);
|
||||
|
||||
var label_style_path = style_path.copy ();
|
||||
label_style_path.iter_add_class (1, "gala-notification");
|
||||
label_style_path.append_type (typeof (Gtk.Label));
|
||||
|
||||
var canvas = new Canvas ();
|
||||
canvas.draw.connect (draw);
|
||||
content = canvas;
|
||||
|
Loading…
Reference in New Issue
Block a user