Skip to content

Commit 1a3da99

Browse files
authored
Move some more style code into CSS & misc extra CSS work (#255)
* panel: prioritise default.css slightly lower than user-supplied css panel: remove static-value set-spacing and move to default.css notifications: add css classes command-output: add class defining icon-direction to allow css themes to use this * uncrustify
1 parent 3e7576f commit 1a3da99

File tree

9 files changed

+63
-13
lines changed

9 files changed

+63
-13
lines changed

data/css/default.css

+40
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,43 @@
2020
transition: 500ms linear;
2121
-gtk-icon-transform: scale(1.2);
2222
}
23+
24+
.wf-panel .battery label,
25+
.wf-panel .battery:hover label,
26+
.wf-panel .window-button label,
27+
.wf-panel .window-button:hover label,
28+
.wf-panel .tray-button,
29+
.wf-panel .tray-button:hover,
30+
.wf-panel .notification button {
31+
padding-left: 5px;
32+
}
33+
34+
.wf-panel .notification .time {
35+
padding-left: 5px;
36+
padding-right: 5px;
37+
}
38+
39+
.wf-panel .tray .tray-button:first-child,
40+
.wf-panel .notification button:first-child {
41+
padding-left: 0px;
42+
}
43+
44+
.wf-panel .network label {
45+
padding-left: 6px;
46+
}
47+
48+
.wf-panel .command-output.icon-left label {
49+
padding-left: 5px;
50+
}
51+
52+
.wf-panel .command-output.icon-right label {
53+
padding-right: 5px;
54+
}
55+
56+
.wf-panel .command-output.icon-top label {
57+
padding-top: 5px;
58+
}
59+
60+
.wf-panel .command-output.icon-bottom label {
61+
padding-bottom: 5px;
62+
}

src/panel/panel.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,13 @@ void WayfirePanelApp::on_css_reload()
387387
{
388388
if (p.path().extension() == ext)
389389
{
390-
add_css_file(p.path().string());
390+
int priority = GTK_STYLE_PROVIDER_PRIORITY_USER;
391+
if (p.path().filename() == "default.css")
392+
{
393+
priority = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION;
394+
}
395+
396+
add_css_file(p.path().string(), priority);
391397
}
392398
}
393399

@@ -396,7 +402,7 @@ void WayfirePanelApp::on_css_reload()
396402
std::string custom_css = custom_css_config;
397403
if (custom_css != "")
398404
{
399-
add_css_file(custom_css);
405+
add_css_file(custom_css, GTK_STYLE_PROVIDER_PRIORITY_USER);
400406
}
401407
}
402408

@@ -412,7 +418,7 @@ void WayfirePanelApp::clear_css_rules()
412418
css_rules.clear();
413419
}
414420

415-
void WayfirePanelApp::add_css_file(std::string file)
421+
void WayfirePanelApp::add_css_file(std::string file, int priority)
416422
{
417423
auto screen = Gdk::Screen::get_default();
418424
auto style_context = Gtk::StyleContext::create();
@@ -422,7 +428,7 @@ void WayfirePanelApp::add_css_file(std::string file)
422428
if (css_provider)
423429
{
424430
style_context->add_provider_for_screen(
425-
screen, css_provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
431+
screen, css_provider, priority);
426432
css_rules.push_back(css_provider);
427433
}
428434
}

src/panel/panel.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class WayfirePanelApp : public WayfireShellApp
4242
WayfirePanelApp(int argc, char **argv);
4343

4444
void clear_css_rules();
45-
void add_css_file(std::string file);
45+
void add_css_file(std::string file, int priority);
4646

4747
class impl;
4848
std::vector<Glib::RefPtr<Gtk::CssProvider>> css_rules;

src/panel/widgets/battery.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ void WayfireBatteryInfo::init(Gtk::HBox *container)
246246

247247
container->pack_start(button, Gtk::PACK_SHRINK);
248248
button_box.add(label);
249-
button_box.set_spacing(5);
250249

251250
button.add(button_box);
252251
button.property_scale_factor().signal_changed()

src/panel/widgets/command-output.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ WfCommandOutputButtons::CommandOutput::CommandOutput(const std::string & name,
5454
}
5555

5656
get_style_context()->add_class("command-output");
57+
get_style_context()->add_class("icon-" + icon_position);
5758

5859
main_label.set_ellipsize(Pango::ELLIPSIZE_END);
5960
main_label.set_max_width_chars(max_chars_opt);
@@ -67,8 +68,6 @@ WfCommandOutputButtons::CommandOutput::CommandOutput(const std::string & name,
6768
main_label.set_max_width_chars(max_chars_opt);
6869
});
6970

70-
box.set_spacing(5);
71-
7271
box.set_orientation(
7372
icon_position == "bottom" ||
7473
icon_position ==

src/panel/widgets/network.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ void WayfireNetworkInfo::init(Gtk::HBox *container)
413413
button_content.set_valign(Gtk::ALIGN_CENTER);
414414
button_content.pack_start(icon, Gtk::PACK_SHRINK);
415415
button_content.pack_start(status, Gtk::PACK_SHRINK);
416-
button_content.set_spacing(6);
417416

418417
icon.set_valign(Gtk::ALIGN_CENTER);
419418
icon.property_scale_factor().signal_changed().connect(

src/panel/widgets/notifications/single-notification.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,22 @@ WfSingleNotification::WfSingleNotification(const Notification & notification)
6161
app_icon.set_from_icon_name("dialog-information", Gtk::ICON_SIZE_LARGE_TOOLBAR);
6262
}
6363

64+
get_style_context()->add_class("notification");
65+
66+
app_icon.get_style_context()->add_class("app-icon");
67+
68+
top_bar.get_style_context()->add_class("top-bar");
6469
top_bar.pack_start(app_icon, false, true);
6570

6671
app_name.set_label(notification.app_name);
6772
app_name.set_halign(Gtk::ALIGN_START);
6873
app_name.set_ellipsize(Pango::ELLIPSIZE_END);
74+
app_name.get_style_context()->add_class("app-name");
6975
top_bar.pack_start(app_name);
7076

7177
time_label.set_sensitive(false);
7278
time_label.set_label(format_recv_time(notification.additional_info.recv_time));
79+
time_label.get_style_context()->add_class("time");
7380
time_label_update = Glib::signal_timeout().connect(
7481
[=]
7582
{
@@ -83,10 +90,10 @@ WfSingleNotification::WfSingleNotification(const Notification & notification)
8390
close_image.set_from_icon_name("window-close", Gtk::ICON_SIZE_LARGE_TOOLBAR);
8491
close_button.add(close_image);
8592
close_button.get_style_context()->add_class("flat");
93+
close_button.get_style_context()->add_class("close");
8694
close_button.signal_clicked().connect(
8795
[=] { Daemon::Instance()->closeNotification(notification.id, Daemon::CloseReason::Dismissed); });
8896
top_bar.pack_start(close_button, false, true);
89-
top_bar.set_spacing(5);
9097

9198
child.add(top_bar);
9299

@@ -104,6 +111,7 @@ WfSingleNotification::WfSingleNotification(const Notification & notification)
104111
}
105112
}
106113

114+
content.get_style_context()->add_class("notification-contents");
107115
content.pack_end(image);
108116

109117
text.set_halign(Gtk::ALIGN_START);
@@ -122,6 +130,8 @@ WfSingleNotification::WfSingleNotification(const Notification & notification)
122130

123131
child.add(content);
124132

133+
actions.get_style_context()->add_class("actions");
134+
125135
if (!notification.actions.empty())
126136
{
127137
for (uint i = 0; i + 1 < notification.actions.size(); ++++ i)
@@ -150,7 +160,6 @@ WfSingleNotification::WfSingleNotification(const Notification & notification)
150160

151161
if (!actions.get_children().empty())
152162
{
153-
actions.set_spacing(5);
154163
actions.set_homogeneous();
155164
child.add(actions);
156165
}

src/panel/widgets/tray/tray.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
void WayfireStatusNotifier::init(Gtk::HBox *container)
44
{
55
icons_hbox.get_style_context()->add_class("tray");
6-
icons_hbox.set_spacing(5);
76
container->add(icons_hbox);
87
}
98

src/panel/widgets/window-list/toplevel.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class WayfireToplevel::impl
6161
button_contents.add(image);
6262
button_contents.add(label);
6363
button_contents.set_halign(Gtk::ALIGN_START);
64-
button_contents.set_spacing(5);
6564
button.add(button_contents);
6665
button.set_tooltip_text("none");
6766

0 commit comments

Comments
 (0)