Permalink
Browse files

Merge pull request #1510 from yursan9/caffein-applet

[RFC] Inclusion of Caffeine Applet
  • Loading branch information...
JoshStrobl committed Aug 1, 2018
2 parents c61b221 + e196fca commit e3f69e25a33df95bac09f00dc7e6e6a0c24014cd
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="SVGRoot"
version="1.1"
viewBox="0 0 16 16"
height="16"
width="16">
<defs
id="defs4504">
<marker
style="overflow:visible"
id="DiamondLstart"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(0.8,0,0,0.8,5.6,0)"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
d="M 0,-7.0710768 -7.0710894,0 0,7.0710589 7.0710462,0 Z"
id="path5191" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path5103" />
</marker>
</defs>
<metadata
id="metadata4507">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.84728652;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
d="m 3.1370099,0.849609 c -0.1762595,0.0074 -0.3480867,0.0419 -0.3601195,0.15625 -0.028124,0.267258 0.7560153,0.321565 0.8207549,0.320313 1.5913874,0.0161 1.4311084,1.134769 1.3732267,2.720703 -0.02776,0.760609 -0.055386,1.571527 0.4035077,2.505859 -2.6119763,0.157227 -3.1600858,0.50586 -3.1600858,0.50586 v 6.933593 c 0,0.847585 0.9599403,1.529297 1.6501868,1.529297 0,0 0.4180006,6.34e-4 0.54958,0.298177 h 7.5892683 c 0.152438,-0.297553 0.548857,-0.298177 0.548857,-0.298177 0.913903,0 1.650187,-0.681712 1.650187,-1.529297 V 7.058594 c 0,0 -0.667952,-0.403419 -3.868032,-0.53711 C 9.9135543,5.675619 9.971018,4.874882 10.002423,4.052734 10.067203,2.356933 9.8402237,0.890013 7.9668073,0.855469 7.9069013,0.868159 7.2438777,0.777159 7.219812,1.005859 7.191689,1.273117 7.975827,1.327424 8.0405667,1.326172 c 1.5913876,0.0161 1.4311086,1.134769 1.3732273,2.720703 -0.02723,0.746142 -0.05591,1.540552 0.3760283,2.452474 -0.486913,-0.014 -1.0137213,-0.02336 -1.609691,-0.02344 -0.033493,-4e-6 -0.057263,0.0013 -0.090391,0.0013 C 7.692745,5.64765 7.7501053,4.860531 7.7809626,4.05273 7.8457456,2.356929 7.618763,0.890009 5.7453466,0.855464 5.6854406,0.868154 5.022417,0.777154 4.9983516,1.005855 4.9702246,1.273112 5.7543666,1.32742 5.8191063,1.326168 7.4104936,1.342268 7.250215,2.460937 7.1923333,4.046871 7.1652433,4.789144 7.1362203,5.579053 7.5611306,6.485022 6.9382383,6.491522 6.3837973,6.505662 5.895035,6.527992 5.470634,5.679695 5.528015,4.877015 5.559502,4.052733 5.624285,2.356932 5.3973023,0.890012 3.523886,0.855468 3.493933,0.861768 3.3132699,0.842178 3.1370102,0.849568 Z M 8.158437,6.609375 a 5.858712,0.63984413 0 0 1 0.045558,0 5.858712,0.63984413 0 0 1 1.6552483,0.02669 c 0.025627,0.04941 0.045985,0.09766 0.074483,0.147787 0.2521217,0.442688 0.9241627,0.747396 0.9241627,0.747396 0,0 -0.198066,-0.431993 -0.413631,-0.796875 -0.01539,-0.026 -0.02535,-0.05157 -0.03977,-0.07747 A 5.858712,0.63984413 0 0 1 14.062811,7.248699 5.858712,0.63984413 0 0 1 8.2039973,7.888673 5.858712,0.63984413 0 0 1 2.3451834,7.248699 5.858712,0.63984413 0 0 1 5.4409106,6.685548 c 0.017697,0.03306 0.030917,0.06493 0.049896,0.09831 0.252121,0.442688 0.9241627,0.747396 0.9241627,0.747396 0,0 -0.1980667,-0.431992 -0.4136317,-0.796875 -0.015017,-0.02537 -0.024947,-0.05024 -0.039049,-0.07552 a 5.858712,0.63984413 0 0 1 1.6639263,-0.04622 c 0.02917,0.05709 0.053051,0.11318 0.086053,0.171224 0.2521207,0.442688 0.9241623,0.747396 0.9241623,0.747396 0,0 -0.1980663,-0.431992 -0.4136316,-0.796875 -0.024837,-0.04196 -0.042005,-0.08328 -0.064359,-0.125 z"
id="rect5075" />
</svg>
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="48px"
height="48px"
viewBox="0 0 48 48"
version="1.1"
id="SVGRoot">
<defs
id="defs4504">
<marker
orient="auto"
refY="0.0"
refX="0.0"
id="DiamondLstart"
style="overflow:visible">
<path
id="path5191"
d="M 0,-7.0710768 L -7.0710894,0 L 0,7.0710589 L 7.0710462,0 L 0,-7.0710768 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(7,0)" />
</marker>
<marker
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lstart"
style="overflow:visible">
<path
id="path5103"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(12.5,0)" />
</marker>
</defs>
<metadata
id="metadata4507">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
id="rect5075"
d="m 16.123139,19.658203 c -7.8359288,0.47168 -9.4802572,1.517578 -9.4802572,1.517578 v 20.800781 c 0,2.542753 2.8798209,4.587891 4.9505602,4.587891 0,0 1.254002,0.0019 1.64874,0.894531 h 22.767805 c 0.457314,-0.89266 1.646572,-0.894531 1.646572,-0.894531 2.741708,0 4.950559,-2.045138 4.950559,-4.587891 V 21.175781 c 0,0 -2.003855,-1.210257 -11.604095,-1.611328 l -1.633556,-0.06641 c -1.848594,-0.04765 -3.551492,-0.0691 -5.100247,-0.06641 l -1.585829,0.02344 c -1.868677,0.01959 -3.532,0.06193 -4.998287,0.128906 z m 8.352172,0.169922 c 1.762443,0.008 3.575706,0.03134 5.102418,0.08008 l 1.635725,0.0625 c 6.622854,0.293109 10.961497,0.994959 10.974971,1.775389 0.002,1.060294 -7.867897,1.91994 -17.576441,1.919922 -9.708545,1.8e-5 -17.5784122,-0.859628 -17.5764417,-1.919922 0.010837,-0.706961 3.5789707,-1.356049 9.2871817,-1.689453 l 1.564134,-0.08008 c 1.592545,-0.07274 3.274528,-0.11947 4.991779,-0.138671 l 1.596674,-0.0098 z"
style="fill:#d3dae3;fill-opacity:1;stroke:none;stroke-width:2.54185963;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" />
</svg>
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="48px"
height="48px"
viewBox="0 0 48 48"
version="1.1"
id="SVGRoot">
<defs
id="defs4504">
<marker
orient="auto"
refY="0.0"
refX="0.0"
id="DiamondLstart"
style="overflow:visible">
<path
id="path5191"
d="M 0,-7.0710768 L -7.0710894,0 L 0,7.0710589 L 7.0710462,0 L 0,-7.0710768 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(7,0)" />
</marker>
<marker
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lstart"
style="overflow:visible">
<path
id="path5103"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(12.5,0)" />
</marker>
</defs>
<metadata
id="metadata4507">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
id="rect5075"
d="M 9.4110298,2.5488281 C 8.8822511,2.5711291 8.3667696,2.6745293 8.3306713,3.0175781 8.2463,3.8193504 10.598717,3.9822733 10.792936,3.9785156 c 4.774162,0.048308 4.293325,3.4043069 4.11968,8.1621094 -0.08328,2.281828 -0.166158,4.71458 1.210523,7.517578 -7.8359288,0.47168 -9.4802572,1.517578 -9.4802572,1.517578 v 20.800781 c 0,2.542753 2.8798209,4.587891 4.9505602,4.587891 0,0 1.254002,0.0019 1.64874,0.894531 h 22.767805 c 0.457314,-0.89266 1.646572,-0.894531 1.646572,-0.894531 2.741708,0 4.950559,-2.045138 4.950559,-4.587891 V 21.175781 c 0,0 -2.003855,-1.210257 -11.604095,-1.611328 -1.26236,-2.537596 -1.089969,-4.939806 -0.995754,-7.40625 0.194348,-5.0874041 -0.486598,-9.4881628 -6.106847,-9.5917968 -0.179718,0.038066 -2.168789,-0.2349258 -2.240986,0.4511719 -0.08437,0.8017723 2.268045,0.9646952 2.462264,0.9609375 4.774163,0.048308 4.293326,3.4043069 4.119682,8.1621094 -0.08169,2.238425 -0.167729,4.621656 1.128085,7.357422 -1.460739,-0.042 -3.041164,-0.07009 -4.829073,-0.07031 -0.10048,-1.2e-5 -0.171788,0.0038 -0.271174,0.0039 -1.190986,-2.488677 -1.018905,-4.850035 -0.926333,-7.273438 0.194348,-5.0874041 -0.486599,-9.4881628 -6.106848,-9.5917968 -0.179717,0.038066 -2.168789,-0.2349258 -2.240985,0.4511719 -0.08438,0.8017723 2.268045,0.9646952 2.462264,0.9609375 4.774162,0.048308 4.293326,3.4043069 4.119681,8.1621094 -0.08127,2.226819 -0.168339,4.596546 1.106392,7.314453 -1.868677,0.01959 -3.532,0.06193 -4.998287,0.128906 -1.273203,-2.544891 -1.10106,-4.952933 -1.006599,-7.425777 C 16.872853,7.0707989 16.191906,2.6700402 10.571657,2.5664062 10.481799,2.5854393 9.9398087,2.526527 9.4110298,2.5488281 Z M 24.475311,19.828125 a 17.576136,1.9195324 0 0 1 0.136673,0 17.576136,1.9195324 0 0 1 4.965745,0.08008 c 0.07688,0.148233 0.137955,0.292991 0.223448,0.443359 0.756363,1.328065 2.772488,2.242188 2.772488,2.242188 0,0 -0.5942,-1.295977 -1.240895,-2.390625 -0.04616,-0.07799 -0.07604,-0.154714 -0.119316,-0.232422 A 17.576136,1.9195324 0 0 1 42.188425,21.746094 17.576136,1.9195324 0 0 1 24.611984,23.666016 17.576136,1.9195324 0 0 1 7.0355423,21.746094 17.576136,1.9195324 0 0 1 16.322724,20.056641 c 0.05309,0.09919 0.09275,0.194776 0.149688,0.294921 0.756363,1.328065 2.772488,2.242188 2.772488,2.242188 0,0 -0.5942,-1.295977 -1.240895,-2.390625 -0.04505,-0.07612 -0.07484,-0.150711 -0.117147,-0.226563 a 17.576136,1.9195324 0 0 1 4.991779,-0.138671 c 0.08751,0.171275 0.159154,0.33954 0.258158,0.513671 0.756362,1.328065 2.772487,2.242188 2.772487,2.242188 0,0 -0.594199,-1.295977 -1.240895,-2.390625 -0.07451,-0.125893 -0.126014,-0.249826 -0.193076,-0.375 z"
style="fill:#d3dae3;fill-opacity:1;stroke:none;stroke-width:2.54185963;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" />
</svg>
@@ -20,11 +20,14 @@ app_icons = [
join_paths('.', 'icons', 'apps', 'notifications-applet-symbolic.svg'),
join_paths('.', 'icons', 'apps', 'separator-symbolic.svg'),
join_paths('.', 'icons', 'apps', 'task-list-symbolic.svg'),
join_paths('.', 'icons', 'apps', 'my-caffeine-on-symbolic.svg'),
]

status_icons = [
join_paths('.', 'icons', 'status', 'num-lock-symbolic.svg'),
join_paths('.', 'icons', 'status', 'caps-lock-symbolic.svg'),
join_paths('.', 'icons', 'status', 'caffeine-cup-full.svg'),
join_paths('.', 'icons', 'status', 'caffeine-cup-empty.svg'),
]


@@ -0,0 +1,8 @@
[Plugin]
Module=caffeineapplet.so
Name=Caffeine
_Description=Caffeine
Authors=Budgie Desktop Developers
Copyright=Copyright © 2018 Budgie Desktop Developers
Website=https://budgie-desktop.org/
Icon=my-caffeine-on-symbolic
@@ -0,0 +1,112 @@

/*
* This file is part of budgie-desktop
*
* Copyright © 2018 Budgie Desktop Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/

namespace Caffeine
{

public class Plugin : Budgie.Plugin, Peas.ExtensionBase
{
public Budgie.Applet get_panel_widget(string uuid)
{
return new Applet(uuid);
}
}

public class Applet : Budgie.Applet
{
private Gtk.EventBox event_box;
private Budgie.Popover? popover = null;
private unowned Budgie.PopoverManager? manager = null;
private Settings? settings;

public string uuid { public set; public get; }

public Applet(string uuid)
{
Object(uuid: uuid);

settings_schema = "com.solus-project.caffeine";
settings_prefix = "/com/solus-project/budgie-panel/instance/caffeine";

settings = this.get_applet_settings(uuid);

event_box = new Gtk.EventBox();
var icon = new Gtk.Image.from_icon_name("caffeine-cup-empty", Gtk.IconSize.MENU);
event_box.add(icon);
this.add(event_box);

popover = new Budgie.Popover(event_box);
popover.get_style_context().add_class("caffeine-popover");
var win = new AppletWindow (event_box, settings);
popover.add(win);

// On click icon
event_box.button_press_event.connect((e)=> {
switch (e.button) {
case 1:
if (popover.get_visible()) {
popover.hide();
} else {
this.manager.show_popover(event_box);
}
break;
case 2:
win.toggle_applet ();
break;
default:
return Gdk.EVENT_PROPAGATE;
}

return Gdk.EVENT_STOP;
});

this.show_all();
}

public override void update_popovers(Budgie.PopoverManager? manager)
{
manager.register_popover(event_box, popover);
this.manager = manager;
}

public override bool supports_settings()
{
return true;
}

public override Gtk.Widget? get_settings_ui()
{
return new AppletSettings(this.get_applet_settings(uuid));
}
}
} // end Namespace

[ModuleInit]
public void peas_register_types(TypeModule module)
{
// boilerplate - all modules need this
var objmodule = module as Peas.ObjectModule;
objmodule.register_extension_type(typeof(Budgie.Plugin), typeof(Caffeine.Plugin));
}

/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=4 expandtab:
* :indentSize=4:tabSize=4:noTabs=true:
*/
@@ -0,0 +1,45 @@
namespace Caffeine
{

[GtkTemplate (ui = "/com/solus-project/caffeine/settings.ui")]
public class AppletSettings : Gtk.Grid
{
private Settings? settings = null;

[GtkChild]
private Gtk.Switch? notify_switch;

[GtkChild]
private Gtk.Switch? brightness_switch;

[GtkChild]
private Gtk.SpinButton? brightness_level;

public AppletSettings(Settings? settings)
{
Object();
this.settings = settings;

// Bind settings to widget value
settings.bind("enable-notification", notify_switch, "active",
SettingsBindFlags.DEFAULT);
settings.bind("toggle-brightness", brightness_switch, "active",
SettingsBindFlags.DEFAULT);
settings.bind("screen-brightness", brightness_level, "value",
SettingsBindFlags.DEFAULT);
}
}
} //End namespace

/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=4 expandtab:
* :indentSize=4:tabSize=4:noTabs=true:
*/
Oops, something went wrong.

0 comments on commit e3f69e2

Please sign in to comment.