Merge lp:~l-admin-3/switchboard-plug-notifications/code-cleanup-and-new-backend into lp:~elementary-pantheon/switchboard-plug-notifications/trunk

Proposed by Marcus Wichelmann
Status: Merged
Approved by: Cody Garver
Approved revision: 140
Merged at revision: 129
Proposed branch: lp:~l-admin-3/switchboard-plug-notifications/code-cleanup-and-new-backend
Merge into: lp:~elementary-pantheon/switchboard-plug-notifications/trunk
Diff against target: 1970 lines (+922/-882)
17 files modified
data/notify-center.svg (+81/-0)
po/notifications-plug.pot (+46/-54)
src/Backend/App.vala (+34/-0)
src/Backend/NotifyManager.vala (+63/-0)
src/Backend/NotifySettings.vala (+36/-0)
src/CMakeLists.txt (+9/-5)
src/NotifySettings.vala (+0/-64)
src/Plug.vala (+90/-82)
src/Widgets/AppEntry.vala (+94/-237)
src/Widgets/AppList.vala (+76/-100)
src/Widgets/AppSettingsView.vala (+107/-152)
src/Widgets/Footer.vala (+31/-23)
src/Widgets/InfoScreen.vala (+0/-66)
src/Widgets/MainView.vala (+72/-99)
src/Widgets/SettingsHeader.vala (+50/-0)
src/Widgets/SettingsOption.vala (+74/-0)
src/Widgets/Sidebar.vala (+59/-0)
To merge this branch: bzr merge lp:~l-admin-3/switchboard-plug-notifications/code-cleanup-and-new-backend
Reviewer Review Type Date Requested Status
xapantu (community) Approve
Rico Tzschichholz Abstain
Danielle Foré Needs Fixing
Review via email: mp+263850@code.launchpad.net

Commit message

Code cleanup and new backend

Description of the change

This branch removes the old backend code that was mixed with the gui code and replaces it with a new separated backend. The app-id list is now based on the registered desktop files which are making use of the the x-notify key. Also the settings are now saved using child-schemas so there is no need for the string splitting anymore and the performance of the plug far better.
The control whether apps are listed in the notification-center is handled by the plug now, too.

Please test if everything works as expected and if there are any regressions.

To post a comment you must log in.
124. By Marcus Wichelmann

Update translations

125. By Marcus Wichelmann

apps -> applications

126. By Marcus Wichelmann

Resolve conflicts; Update to trunk

Revision history for this message
Danielle Foré (danrabbit) wrote :

It looks like there's a regression in the sidebar with the size of the "Bubbles sounds" etc text.

Might want to reduce your row spacing to something more sane like 32 instead of 60.

Needs merge conflicts resolved

review: Needs Fixing
127. By Marcus Wichelmann

Change row-spacing in settings view to 32

128. By Marcus Wichelmann

Move some app related code to the App class

129. By Marcus Wichelmann

Use small text for description labels for apps

130. By Marcus Wichelmann

Replace placeholder with new notify-center image by Dan

Revision history for this message
Danielle Foré (danrabbit) wrote :

I can't confirm that the notification center control actually works, but everything else looks okay here :)

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

A bunch of general code-design issues.

Construction: Use gobject-style construction. Use construct { ... } instead of private methods which called onece (build_ui, connect).

Properties: Only use "construct set;" if needed otherwise "construct;"

Arguments: Don't pass general arguments which can be created with already given information. Don't hold references to the same object in different local fields/properties.

Signals: Avoid using lambdas if you can pass existing callbacks/methods directly, or if it is possible to easily create one.

...

review: Needs Fixing
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Invocations: Avoid calling the very same function/retrieving the very same object multiple times in the same context/scope.

...

review: Needs Fixing
131. By Marcus Wichelmann

Code-style improvements.

Revision history for this message
Marcus Wichelmann (l-admin-3) wrote :

Okay, I've updated the code and changed some things.

132. By Marcus Wichelmann

Revert notify_manager fields and use them only inside methods

133. By Marcus Wichelmann

Don't create two variables for option widget

Revision history for this message
xapantu (xapantu) wrote :

Conflicts with trunk.

The code looks rather fine, I am not a big fan of the use of private everywhere, but that's not important. You also seem to like the use of Gtk.Grid, maybe too much, but that's your choice.

That would need more testing I think. Please fix the conflict so as we can merge this :)

review: Needs Fixing
134. By Marcus Wichelmann

Adopt renamed notification-center key.

135. By Marcus Wichelmann

Relove merge conflicts

136. By Marcus Wichelmann

Fix bug with app permission description

Revision history for this message
Rico Tzschichholz (ricotz) :
review: Abstain
137. By Marcus Wichelmann

Use make get_default () methods unowned.

138. By Marcus Wichelmann

Change field/method order

Revision history for this message
xapantu (xapantu) wrote :

That does not work here, this is a fix that seems to work:
=== modified file 'src/Backend/App.vala'
--- src/Backend/App.vala 2015-09-16 17:24:11 +0000
+++ src/Backend/App.vala 2015-10-11 10:01:12 +0000
@@ -29,6 +29,6 @@
         Object (app_info: app_info);

         app_id = app_info.get_id ().replace (".desktop", "");
- settings = new Settings.full (SettingsSchemaSource.get_default ().lookup (CHILD_SCHEMA_ID, false), null, CHILD_PATH.printf (app_id));
+ settings = new Settings.full (SettingsSchemaSource.get_default ().lookup (CHILD_SCHEMA_ID, true), null, CHILD_PATH.printf (app_id));
     }
-}
\ No newline at end of file
+}

See the doc for the rationale https://developer.gnome.org/gio/stable/gio-GSettingsSchema-GSettingsSchemaSource.html#g-settings-schema-source-get-default

The code looks fine, if you apply the patch above, feel free to merge it.

review: Approve
139. By Marcus Wichelmann

Apply settins patch by xapantu

140. By Marcus Wichelmann

Resolve merge conflicts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'data/notify-center.svg'
2--- data/notify-center.svg 1970-01-01 00:00:00 +0000
3+++ data/notify-center.svg 2015-10-11 11:46:23 +0000
4@@ -0,0 +1,81 @@
5+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
6+<!-- Created with Inkscape (http://www.inkscape.org/) -->
7+<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" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="124.056" height="86.056" id="svg4729" version="1.1" inkscape:version="0.48.4 r9939" sodipodi:docname="notify-center.svg">
8+ <defs id="defs4731">
9+ <linearGradient id="linearGradient3797">
10+ <stop id="stop3799" offset="0" style="stop-color:#616c8c;stop-opacity:1;"/>
11+ <stop id="stop3801" offset="1" style="stop-color:#6282ac;stop-opacity:1;"/>
12+ </linearGradient>
13+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient3924-4" id="linearGradient9678" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.6216216,0,0,0.43243243,359.32485,409.20951)" x1="23.99999" y1="4.999989" x2="23.99999" y2="43"/>
14+ <linearGradient id="linearGradient3924-4">
15+ <stop id="stop3926-8" style="stop-color:#ffffff;stop-opacity:1;" offset="0"/>
16+ <stop offset="0.06316455" style="stop-color:#ffffff;stop-opacity:0.23529412;" id="stop3928-5"/>
17+ <stop id="stop3930-6-4" style="stop-color:#ffffff;stop-opacity:0.15686275;" offset="0.95056331"/>
18+ <stop id="stop3932-25" style="stop-color:#ffffff;stop-opacity:0.39215687;" offset="1"/>
19+ </linearGradient>
20+ <linearGradient id="linearGradient5717">
21+ <stop style="stop-color:#fafafa;stop-opacity:1" offset="0" id="stop5719"/>
22+ <stop style="stop-color:#e7eef3;stop-opacity:1;" offset="1" id="stop5721"/>
23+ </linearGradient>
24+ <linearGradient id="linearGradient5709">
25+ <stop style="stop-color:#bec3d2;stop-opacity:1;" offset="0" id="stop5711"/>
26+ <stop style="stop-color:#b1c1d6;stop-opacity:1;" offset="1" id="stop5713"/>
27+ </linearGradient>
28+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient5717" id="linearGradient9688" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.33110384,0,0,0.32727369,484.49126,490.84661)" x1="-200.29341" y1="-321.39581" x2="-200.29341" y2="-266.54333"/>
29+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient5709" id="linearGradient9690" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.33110384,0,0,0.32727369,484.49126,490.84661)" x1="-320.87225" y1="-327.28119" x2="-320.87225" y2="-274.6741"/>
30+ <filter color-interpolation-filters="sRGB" inkscape:collect="always" id="filter5705">
31+ <feGaussianBlur inkscape:collect="always" stdDeviation="1.47" id="feGaussianBlur5707"/>
32+ </filter>
33+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient3797" id="linearGradient3795" x1="412.29114" y1="411.73077" x2="469.51785" y2="449.94507" gradientUnits="userSpaceOnUse"/>
34+ <linearGradient y2="-310.18402" x2="787.31219" y1="-315.36099" x1="787.31219" gradientTransform="matrix(0.33110384,0,0,9.420807,149.46323,3383.4914)" gradientUnits="userSpaceOnUse" id="linearGradient4459-2" xlink:href="#linearGradient5717-7-0" inkscape:collect="always"/>
35+ <linearGradient id="linearGradient5717-7-0">
36+ <stop style="stop-color:#fafafa;stop-opacity:1" offset="0" id="stop5719-4-2"/>
37+ <stop style="stop-color:#e7eef3;stop-opacity:1;" offset="1" id="stop5721-3-7"/>
38+ </linearGradient>
39+ <linearGradient y2="-310.14444" x2="920.43018" y1="-315.36102" x1="920.43018" gradientTransform="matrix(0.33110384,0,0,9.420807,149.46323,3383.4914)" gradientUnits="userSpaceOnUse" id="linearGradient4461-7" xlink:href="#linearGradient5709-7-1" inkscape:collect="always"/>
40+ <linearGradient id="linearGradient5709-7-1">
41+ <stop style="stop-color:#bec3d2;stop-opacity:1;" offset="0" id="stop5711-8-0"/>
42+ <stop style="stop-color:#b1c1d6;stop-opacity:1;" offset="1" id="stop5713-2-3"/>
43+ </linearGradient>
44+ </defs>
45+ <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1" inkscape:cx="87" inkscape:cy="24.5" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" fit-margin-top="0" fit-margin-left="0" fit-margin-right="0" fit-margin-bottom="0" inkscape:window-width="1440" inkscape:window-height="845" inkscape:window-x="0" inkscape:window-y="30" inkscape:window-maximized="1" showguides="false">
46+ <inkscape:grid type="xygrid" id="grid4301"/>
47+ </sodipodi:namedview>
48+ <metadata id="metadata4734">
49+ <rdf:RDF>
50+ <cc:Work rdf:about="">
51+ <dc:format>image/svg+xml</dc:format>
52+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
53+ <dc:title/>
54+ </cc:Work>
55+ </rdf:RDF>
56+ </metadata>
57+ <g inkscape:label="Ebene 1" inkscape:groupmode="layer" id="layer1" transform="translate(-360.21577,-385.05992)">
58+ <rect style="opacity:0.15;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;filter:url(#filter5705);enable-background:accumulate" id="rect4888-5" width="117" height="79" x="363.74377" y="388.58792" rx="4" ry="3.9999998"/>
59+ <rect style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a2a6b0;stroke-width:0.99999976;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4888" width="117" height="79" x="363.74377" y="387.58792" rx="4" ry="3.9999998"/>
60+ <path style="opacity:0.95;color:#000000;fill:url(#linearGradient9688);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient9690);stroke-width:0.9999218;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" d="m 367.74376,387.58791 c -2.216,0 -4,1.784 -4,4 l 0,10 117,0 0,-10 c 0,-2.216 -1.784,-4 -4,-4 z" id="rect4888-4" inkscape:connector-curvature="0" sodipodi:nodetypes="ssccsss"/>
61+ <rect style="color:#000000;fill:none;stroke:#a2a6b0;stroke-width:0.99999976;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4888-0" width="117" height="79" x="363.74377" y="387.58792" rx="4" ry="3.9999998"/>
62+ <rect style="opacity:0.6;fill:none;stroke:url(#linearGradient9678);stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" id="rect6741" y="411.58792" x="373.74377" ry="1" rx="1" height="16" width="97"/>
63+ <path inkscape:connector-curvature="0" style="opacity:0.94999999999999996;color:#000000;fill:url(#linearGradient4459-2);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4461-7);stroke-width:0.99992179999999997;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect5212-7-5" d="m 457.21576,406.50654 -5.5313,6 -43.96869,0 c -2.216,0 -3.00004,0.78437 -3.00004,3.00038 l 0,43 c 0,2.216 0.78404,2.99962 3.00004,2.99963 l 65,3.7e-4 c 2.216,1e-5 2.99999,-0.784 2.99999,-3 l 0,-43 c 0,-2.216 -0.79239,-2.80814 -2.99999,-3.00037 l -9.96881,0 z" sodipodi:nodetypes="ccsssssssccc"/>
64+ <g id="g4290" transform="matrix(0.73333333,0,0,0.73333333,448.96023,386.15458)" style="fill:#b5c4d8;fill-opacity:1">
65+ <path d="m 13.59377,5.125 c -0.25424,0.11867 -0.45328,0.33403 -0.53125,0.625 -0.003,0.0105 0.002,0.0208 0,0.0312 -1.78508,-0.0144 -3.41627,1.17138 -3.90625,3 -0.006,0.0206 -0.0261,0.0419 -0.0312,0.0625 -0.51898,1.93691 -1.52877,5.80495 -3.25,5.34375 -0.11466,-0.0307 -0.2454,0.0537 -0.28125,0.1875 l -0.125,0.46875 c -0.0358,0.13378 0.0103,0.28177 0.125,0.3125 l 11.1875,2.96875 c 0.11467,0.0307 0.24541,-0.0225 0.28125,-0.15625 l 0.125,-0.5 c 0.0358,-0.13378 -0.0416,-0.25052 -0.15625,-0.28125 -1.72795,-0.463 -0.67515,-4.34469 -0.15625,-6.28125 0.006,-0.0204 -0.005,-0.0419 0,-0.0625 0.12115,-0.45213 0.15537,-0.90892 0.125,-1.34375 -1.93948,0 -3.5,-1.56051 -3.5,-3.5 0,-0.29885 0.0235,-0.59799 0.0937,-0.875 z m -2.59375,12.5 c 0.0827,0.77146 0.95012,1.375 2,1.375 0.57062,0 1.07313,-0.18127 1.4375,-0.46875 L 11.00002,17.625 z" id="rect3022" style="color:#bebebe;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" inkscape:connector-curvature="0"/>
66+ <path class="info" d="m 19.00002,6 a 2,2 0 0 1 -4,0 2,2 0 1 1 4,0 z" id="path3009" style="color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" inkscape:connector-curvature="0"/>
67+ <g style="fill:#b5c4d8;fill-opacity:1;display:inline" id="layer10" transform="translate(-333.00018,430)"/>
68+ <g style="fill:#b5c4d8;fill-opacity:1;display:inline" id="layer13" transform="translate(-333.00018,430)"/>
69+ <g id="layer14" transform="translate(-333.00018,430)" style="fill:#b5c4d8;fill-opacity:1"/>
70+ <g style="fill:#b5c4d8;fill-opacity:1;display:inline" id="layer15" transform="translate(-333.00018,430)"/>
71+ <g style="fill:#b5c4d8;fill-opacity:1;display:inline" id="g71291" transform="translate(-333.00018,430)"/>
72+ <g style="fill:#b5c4d8;fill-opacity:1;display:inline" id="g4953" transform="translate(-333.00018,430)"/>
73+ <g style="fill:#b5c4d8;fill-opacity:1;display:inline" id="layer12" transform="translate(-333.00018,430)"/>
74+ </g>
75+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584" width="8" height="8" x="410.21576" y="418.11591" rx="2" ry="2"/>
76+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584-9" width="20" height="2" x="420.21576" y="423.11591" rx="1" ry="1"/>
77+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584-9-0" width="8" height="2" x="420.21576" y="419.11591" rx="1" ry="1"/>
78+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584-8" width="8" height="8" x="410.21576" y="448.11591" rx="2" ry="2"/>
79+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584-9-3" width="24" height="2" x="420.21576" y="453.11591" rx="1" ry="1"/>
80+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584-9-0-7" width="16" height="2" x="420.21576" y="449.11591" rx="1" ry="1"/>
81+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584-0" width="8" height="8" x="410.21576" y="433.11591" rx="2" ry="2"/>
82+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584-9-32" width="32" height="2" x="420.21576" y="438.11591" rx="1" ry="1"/>
83+ <rect style="opacity:0.95;color:#000000;fill:#b5c4d8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73333335;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" id="rect4584-9-0-2" width="12" height="2" x="420.21576" y="434.11591" rx="1" ry="1"/>
84+ </g>
85+</svg>
86\ No newline at end of file
87
88=== modified file 'po/notifications-plug.pot'
89--- po/notifications-plug.pot 2015-02-03 15:05:53 +0000
90+++ po/notifications-plug.pot 2015-10-11 11:46:23 +0000
91@@ -8,7 +8,7 @@
92 msgstr ""
93 "Project-Id-Version: PACKAGE VERSION\n"
94 "Report-Msgid-Bugs-To: \n"
95-"POT-Creation-Date: 2015-02-03 16:05+0100\n"
96+"POT-Creation-Date: 2015-09-22 15:49+0200\n"
97 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
98 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
99 "Language-Team: LANGUAGE <LL@li.org>\n"
100@@ -17,85 +17,77 @@
101 "Content-Type: text/plain; charset=CHARSET\n"
102 "Content-Transfer-Encoding: 8bit\n"
103
104-#: ../src/Plug.vala:30
105-msgid "Notifications"
106-msgstr ""
107-
108-#: ../src/Plug.vala:31
109-msgid "Enable or disable notifications."
110-msgstr ""
111-
112-#: ../src/Plug.vala:43
113-msgid "Nothing to do here"
114-msgstr ""
115-
116-#: ../src/Plug.vala:44
117-msgid ""
118-"Notifications preferences are for configuring which apps make use of "
119-"notifications, for changing how an app's notifications appear,\n"
120-"and for setting when you do not want to be disturbed by notifications."
121-msgstr ""
122-
123-#: ../src/Plug.vala:45
124-msgid ""
125-"When apps are installed that have notification options they will "
126-"automatically appear here."
127-msgstr ""
128-
129-#: ../src/Widgets/AppsView.vala:43
130+#: ../src/Widgets/MainView.vala:62
131 msgid "elementary OS is in Do Not Disturb mode"
132 msgstr ""
133
134-#: ../src/Widgets/AppsView.vala:44
135+#: ../src/Widgets/MainView.vala:64
136 msgid ""
137 "While in Do Not Disturb mode, notifications and alerts will be hidden and "
138 "notification sounds will be silenced."
139 msgstr ""
140
141-#: ../src/Widgets/AppsView.vala:45
142+#: ../src/Widgets/MainView.vala:66
143 msgid ""
144 "System notifications, such as volume and display brightness, will be "
145 "unaffected."
146 msgstr ""
147
148-#: ../src/Widgets/AppItem.vala:141 ../src/Widgets/AppSettings.vala:58
149+#: ../src/Widgets/AppEntry.vala:77 ../src/Widgets/AppSettingsView.vala:54
150 msgid "Bubbles"
151 msgstr ""
152
153-#: ../src/Widgets/AppItem.vala:144 ../src/Widgets/AppSettings.vala:99
154+#: ../src/Widgets/AppEntry.vala:81 ../src/Widgets/AppSettingsView.vala:60
155 msgid "Sounds"
156 msgstr ""
157
158-#: ../src/Widgets/AppItem.vala:147
159+#: ../src/Widgets/AppEntry.vala:85 ../src/Widgets/AppSettingsView.vala:66
160+msgid "Remember"
161+msgstr ""
162+
163+#: ../src/Widgets/AppEntry.vala:89
164 msgid "Disabled"
165 msgstr ""
166
167-#: ../src/Widgets/AppItem.vala:157
168-msgid "Unknown"
169-msgstr ""
170-
171-#: ../src/Widgets/AppItem.vala:159
172-msgid "Sound Menu"
173-msgstr ""
174-
175-#: ../src/Widgets/AppItem.vala:161
176-msgid "Network"
177-msgstr ""
178-
179-#: ../src/Widgets/AppItem.vala:163
180-msgid "System Configuration"
181-msgstr ""
182-
183-#: ../src/Widgets/Footer.vala:33
184-msgid "Do Not Disturb"
185-msgstr ""
186-
187-#: ../src/Widgets/AppSettings.vala:83
188+#: ../src/Widgets/AppSettingsView.vala:55
189 msgid ""
190 "Bubbles appear in the top right corner of the display and disappear "
191 "automatically."
192 msgstr ""
193
194-#: ../src/Widgets/AppSettings.vala:122
195+#: ../src/Widgets/AppSettingsView.vala:61
196 msgid "Sounds play once when a new notification arrives."
197 msgstr ""
198+
199+#: ../src/Widgets/AppSettingsView.vala:67
200+msgid "Show missed notifications in Notification Center."
201+msgstr ""
202+
203+#: ../src/Widgets/Footer.vala:36
204+msgid "Do Not Disturb"
205+msgstr ""
206+
207+#: ../src/Plug.vala:29
208+msgid "Notifications"
209+msgstr ""
210+
211+#: ../src/Plug.vala:30
212+msgid "Enable or disable notifications."
213+msgstr ""
214+
215+#: ../src/Plug.vala:78
216+msgid "Nothing to do here"
217+msgstr ""
218+
219+#: ../src/Plug.vala:80
220+msgid ""
221+"Notifications preferences are for configuring which apps make use of "
222+"notifications, for changing how an app's notifications appear,\n"
223+"and for setting when you do not want to be disturbed by notifications."
224+msgstr ""
225+
226+#: ../src/Plug.vala:82
227+msgid ""
228+"When apps are installed that have notification options they will "
229+"automatically appear here."
230+msgstr ""
231
232=== added directory 'src/Backend'
233=== added file 'src/Backend/App.vala'
234--- src/Backend/App.vala 1970-01-01 00:00:00 +0000
235+++ src/Backend/App.vala 2015-10-11 11:46:23 +0000
236@@ -0,0 +1,34 @@
237+/*
238+ * Copyright (c) 2011-2015 elementary Developers
239+ *
240+ * This program is free software; you can redistribute it and/or
241+ * modify it under the terms of the GNU General Public
242+ * License as published by the Free Software Foundation; either
243+ * version 2 of the License, or (at your option) any later version.
244+ *
245+ * This program is distributed in the hope that it will be useful,
246+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
247+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
248+ * General Public License for more details.
249+ *
250+ * You should have received a copy of the GNU General Public
251+ * License along with this program; if not, write to the
252+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
253+ * Boston, MA 02111-1307, USA.
254+ */
255+
256+public class Backend.App : Object {
257+ private static const string CHILD_SCHEMA_ID = "org.pantheon.desktop.gala.notifications.application";
258+ private static const string CHILD_PATH = "/org/pantheon/desktop/gala/notifications/applications/%s/";
259+
260+ public DesktopAppInfo app_info { get; construct; }
261+ public string app_id { get; private set; }
262+ public Settings settings { get; private set; }
263+
264+ public App (DesktopAppInfo app_info) {
265+ Object (app_info: app_info);
266+
267+ app_id = app_info.get_id ().replace (".desktop", "");
268+ settings = new Settings.full (SettingsSchemaSource.get_default ().lookup (CHILD_SCHEMA_ID, true), null, CHILD_PATH.printf (app_id));
269+ }
270+}
271\ No newline at end of file
272
273=== added file 'src/Backend/NotifyManager.vala'
274--- src/Backend/NotifyManager.vala 1970-01-01 00:00:00 +0000
275+++ src/Backend/NotifyManager.vala 2015-10-11 11:46:23 +0000
276@@ -0,0 +1,63 @@
277+/*
278+ * Copyright (c) 2011-2015 elementary Developers
279+ *
280+ * This program is free software; you can redistribute it and/or
281+ * modify it under the terms of the GNU General Public
282+ * License as published by the Free Software Foundation; either
283+ * version 2 of the License, or (at your option) any later version.
284+ *
285+ * This program is distributed in the hope that it will be useful,
286+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
287+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
288+ * General Public License for more details.
289+ *
290+ * You should have received a copy of the GNU General Public
291+ * License along with this program; if not, write to the
292+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
293+ * Boston, MA 02111-1307, USA.
294+ */
295+
296+public class Backend.NotifyManager : Object {
297+ public static NotifyManager? instance = null;
298+
299+ public static unowned NotifyManager get_default () {
300+ if (instance == null) {
301+ instance = new NotifyManager ();
302+ }
303+
304+ return instance;
305+ }
306+
307+ public bool do_not_disturb { get; set; }
308+ public Gee.HashMap<string, App> apps { get; construct; } /* string: app-id */
309+
310+ public string selected_app_id { get; set; }
311+
312+ construct {
313+ apps = new Gee.HashMap<string, App> ();
314+
315+ create_bindings ();
316+ read_app_list ();
317+ }
318+
319+ private void create_bindings () {
320+ NotifySettings.get_default ().schema.bind ("do-not-disturb", this, "do-not-disturb", SettingsBindFlags.DEFAULT);
321+ }
322+
323+ private void read_app_list () {
324+ var installed_apps = AppInfo.get_all ();
325+
326+ foreach (AppInfo app_info in installed_apps) {
327+ DesktopAppInfo? desktop_app_info = app_info as DesktopAppInfo;
328+
329+ if (desktop_app_info != null && desktop_app_info.get_boolean ("X-GNOME-UsesNotifications")) {
330+ register_app (desktop_app_info);
331+ }
332+ }
333+ }
334+
335+ private void register_app (DesktopAppInfo app_info) {
336+ App app = new App (app_info);
337+ apps.@set (app.app_id, app);
338+ }
339+}
340\ No newline at end of file
341
342=== added file 'src/Backend/NotifySettings.vala'
343--- src/Backend/NotifySettings.vala 1970-01-01 00:00:00 +0000
344+++ src/Backend/NotifySettings.vala 2015-10-11 11:46:23 +0000
345@@ -0,0 +1,36 @@
346+/*
347+ * Copyright (c) 2011-2015 elementary Developers
348+ *
349+ * This program is free software; you can redistribute it and/or
350+ * modify it under the terms of the GNU General Public
351+ * License as published by the Free Software Foundation; either
352+ * version 2 of the License, or (at your option) any later version.
353+ *
354+ * This program is distributed in the hope that it will be useful,
355+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
356+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
357+ * General Public License for more details.
358+ *
359+ * You should have received a copy of the GNU General Public
360+ * License along with this program; if not, write to the
361+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
362+ * Boston, MA 02111-1307, USA.
363+ */
364+
365+public class Backend.NotifySettings : Granite.Services.Settings {
366+ public static NotifySettings? instance = null;
367+
368+ public static unowned NotifySettings get_default () {
369+ if (instance == null) {
370+ instance = new NotifySettings ();
371+ }
372+
373+ return instance;
374+ }
375+
376+ public bool do_not_disturb { get; set; }
377+
378+ private NotifySettings () {
379+ base ("org.pantheon.desktop.gala.notifications");
380+ }
381+}
382\ No newline at end of file
383
384=== modified file 'src/CMakeLists.txt'
385--- src/CMakeLists.txt 2014-11-12 23:50:40 +0000
386+++ src/CMakeLists.txt 2015-10-11 11:46:23 +0000
387@@ -19,13 +19,17 @@
388 # Add all your vala files and requires packages to the List below to include them in the build
389 vala_precompile (VALA_C ${PLUGNAME}
390 Plug.vala
391- NotifySettings.vala
392- Widgets/AppsView.vala
393+ Widgets/AppEntry.vala
394 Widgets/AppList.vala
395- Widgets/AppItem.vala
396- Widgets/AppSettings.vala
397- Widgets/InfoScreen.vala
398+ Widgets/AppSettingsView.vala
399 Widgets/Footer.vala
400+ Widgets/MainView.vala
401+ Widgets/SettingsHeader.vala
402+ Widgets/SettingsOption.vala
403+ Widgets/Sidebar.vala
404+ Backend/NotifySettings.vala
405+ Backend/NotifyManager.vala
406+ Backend/App.vala
407 ${CMAKE_CURRENT_BINARY_DIR}/config.vala
408 PACKAGES
409 switchboard-2.0
410
411=== removed file 'src/NotifySettings.vala'
412--- src/NotifySettings.vala 2014-11-14 15:12:21 +0000
413+++ src/NotifySettings.vala 1970-01-01 00:00:00 +0000
414@@ -1,64 +0,0 @@
415-/***
416- BEGIN LICENSE
417-
418- Copyright (C) 2014 elementary Developers
419- This program is free software: you can redistribute it and/or modify it
420- under the terms of the GNU Lesser General Public License version 3, as published
421- by the Free Software Foundation.
422-
423- This program is distributed in the hope that it will be useful, but
424- WITHOUT ANY WARRANTY; without even the implied warranties of
425- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
426- PURPOSE. See the GNU General Public License for more details.
427-
428- You should have received a copy of the GNU General Public License along
429- with this program. If not, see <http://www.gnu.org/licenses/>
430-
431- END LICENSE
432- Written By: Marcus Wichelmann <admin@marcusw.de>
433-
434-***/
435-
436-public class NotifySettings : Object {
437- public Settings settings;
438-
439- static const string APPS_KEY = "apps";
440- static const string DEFAULT_BUBBLES_KEY = "default-bubbles";
441- static const string DEFAULT_SOUNDS_KEY = "default-sounds";
442- static const string DO_NOT_DISTURB_KEY = "do-not-disturb";
443-
444- public string[] apps { get; set; }
445- public bool default_bubbles { get; set; }
446- public bool default_sounds { get; set; }
447- public bool do_not_disturb { get; set; }
448-
449- public signal void apps_changed (string[] new_value);
450- public signal void do_not_disturb_changed (bool new_value);
451-
452- static NotifySettings? instance = null;
453-
454- private NotifySettings () {
455- settings = new Settings ("org.pantheon.desktop.gala.notifications");
456-
457- settings.bind (APPS_KEY, this, "apps", SettingsBindFlags.DEFAULT);
458- settings.bind (DEFAULT_BUBBLES_KEY, this, "default-bubbles", SettingsBindFlags.DEFAULT);
459- settings.bind (DEFAULT_SOUNDS_KEY, this, "default-sounds", SettingsBindFlags.DEFAULT);
460- settings.bind (DO_NOT_DISTURB_KEY, this, "do-not-disturb", SettingsBindFlags.DEFAULT);
461-
462- settings.changed[APPS_KEY].connect (() => {
463- apps_changed (apps);
464- });
465-
466- settings.changed[DO_NOT_DISTURB_KEY].connect (() => {
467- do_not_disturb_changed (do_not_disturb);
468- });
469- }
470-
471- public static NotifySettings get_default () {
472- if (instance == null) {
473- instance = new NotifySettings ();
474- }
475-
476- return instance;
477- }
478-}
479
480=== modified file 'src/Plug.vala'
481--- src/Plug.vala 2015-09-19 06:09:51 +0000
482+++ src/Plug.vala 2015-10-11 11:46:23 +0000
483@@ -1,87 +1,95 @@
484-/***
485- BEGIN LICENSE
486-
487- Copyright (C) 2014 elementary Developers
488- This program is free software: you can redistribute it and/or modify it
489- under the terms of the GNU Lesser General Public License version 3, as published
490- by the Free Software Foundation.
491-
492- This program is distributed in the hope that it will be useful, but
493- WITHOUT ANY WARRANTY; without even the implied warranties of
494- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
495- PURPOSE. See the GNU General Public License for more details.
496-
497- You should have received a copy of the GNU General Public License along
498- with this program. If not, see <http://www.gnu.org/licenses/>
499-
500- END LICENSE
501- Written By: Marcus Wichelmann <admin@marcusw.de>
502-
503-***/
504+/*
505+ * Copyright (c) 2011-2015 elementary Developers
506+ *
507+ * This program is free software; you can redistribute it and/or
508+ * modify it under the terms of the GNU General Public
509+ * License as published by the Free Software Foundation; either
510+ * version 2 of the License, or (at your option) any later version.
511+ *
512+ * This program is distributed in the hope that it will be useful,
513+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
514+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
515+ * General Public License for more details.
516+ *
517+ * You should have received a copy of the GNU General Public
518+ * License along with this program; if not, write to the
519+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
520+ * Boston, MA 02111-1307, USA.
521+ */
522
523 public class NotificationsPlug : Switchboard.Plug {
524- private Gtk.Stack stack;
525- private Widgets.AppsView appsview;
526- private Widgets.InfoScreen no_apps_info;
527-
528- public NotificationsPlug () {
529- Object (category: Category.PERSONAL,
530- code_name: "personal-pantheon-notifications",
531- display_name: _("Notifications"),
532- description: _("Enable or disable notifications."),
533- icon: "preferences-desktop-notifications");
534- }
535-
536- public override Gtk.Widget get_widget () {
537- if (stack != null) {
538- return stack;
539- }
540-
541- stack = new Gtk.Stack ();
542-
543- appsview = new Widgets.AppsView ();
544- no_apps_info = new Widgets.InfoScreen (_("Nothing to do here"),
545- _("Notifications preferences are for configuring which apps make use of notifications, for changing how an app's notifications appear,\nand for setting when you do not want to be disturbed by notifications.") + "\n\n" +
546- _("When apps are installed that have notification options they will automatically appear here."),
547- "dialog-information");
548-
549- stack.add_named (appsview, "apps-view");
550- stack.add_named (no_apps_info, "no-apps-info");
551-
552- appsview.applist.list_loaded.connect ((length) => {
553- if (length > 0) {
554- stack.set_visible_child (appsview);
555- } else {
556- no_apps_info.show ();
557- stack.set_visible_child (no_apps_info);
558- }
559- });
560-
561- stack.show_all ();
562-
563- return stack;
564- }
565-
566- public override void shown () {
567-
568- }
569-
570- public override void hidden () {
571-
572- }
573-
574- public override void search_callback (string location) {
575-
576- }
577-
578- public override async Gee.TreeMap<string, string> search (string search) {
579- return new Gee.TreeMap<string, string> (null, null);
580- }
581-
582+ private static Granite.Widgets.AlertView create_alert_view () {
583+ var title = _("Nothing to do here");
584+
585+ var description = _("Notifications preferences are for configuring which apps make use of notifications, for changing how an app's notifications appear,\nand for setting when you do not want to be disturbed by notifications.");
586+ description += "\n\n";
587+ description += _("When apps are installed that have notification options they will automatically appear here.");
588+
589+ var icon_name = "dialog-information";
590+
591+ return new Granite.Widgets.AlertView (title, description, icon_name);
592+ }
593+
594+ private Gtk.Stack stack;
595+
596+ private Widgets.MainView main_view;
597+ private Granite.Widgets.AlertView alert_view;
598+
599+ public NotificationsPlug () {
600+ Object (category: Category.PERSONAL,
601+ code_name: "personal-pantheon-notifications",
602+ display_name: _("Notifications"),
603+ description: _("Enable or disable notifications."),
604+ icon: "preferences-desktop-notifications");
605+ }
606+
607+ public override Gtk.Widget get_widget () {
608+ if (stack != null) {
609+ return stack;
610+ }
611+
612+ build_ui ();
613+ update_view ();
614+
615+ return stack;
616+ }
617+
618+ public override void shown () {
619+ }
620+
621+ public override void hidden () {
622+ }
623+
624+ public override void search_callback (string location) {
625+ }
626+
627+ public override async Gee.TreeMap<string, string> search (string search) {
628+ return new Gee.TreeMap<string, string> (null, null);
629+ }
630+
631+ private void build_ui () {
632+ stack = new Gtk.Stack ();
633+
634+ main_view = new Widgets.MainView ();
635+ alert_view = create_alert_view ();
636+
637+ main_view.show_all ();
638+ alert_view.show_all ();
639+
640+ stack.add_named (main_view, "main-view");
641+ stack.add_named (alert_view, "alert-view");
642+
643+ stack.show_all ();
644+ }
645+
646+ private void update_view () {
647+ stack.set_visible_child_name (Backend.NotifyManager.get_default ().apps.size > 0 ? "main-view" : "alert-view");
648+ }
649 }
650
651 public Switchboard.Plug get_plug (Module module) {
652- debug ("Activating Notifications plug");
653- var plug = new NotificationsPlug ();
654- return plug;
655-}
656+ debug ("Activating Notifications plug");
657+ var plug = new NotificationsPlug ();
658+
659+ return plug;
660+}
661\ No newline at end of file
662
663=== renamed file 'src/Widgets/AppItem.vala' => 'src/Widgets/AppEntry.vala'
664--- src/Widgets/AppItem.vala 2015-08-30 20:34:25 +0000
665+++ src/Widgets/AppEntry.vala 2015-10-11 11:46:23 +0000
666@@ -1,237 +1,94 @@
667-/***
668- BEGIN LICENSE
669-
670- Copyright (C) 2014 elementary Developers
671- This program is free software: you can redistribute it and/or modify it
672- under the terms of the GNU Lesser General Public License version 3, as published
673- by the Free Software Foundation.
674-
675- This program is distributed in the hope that it will be useful, but
676- WITHOUT ANY WARRANTY; without even the implied warranties of
677- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
678- PURPOSE. See the GNU General Public License for more details.
679-
680- You should have received a copy of the GNU General Public License along
681- with this program. If not, see <http://www.gnu.org/licenses/>
682-
683- END LICENSE
684- Written By: Marcus Wichelmann <admin@marcusw.de>
685-
686-***/
687-
688-public class Widgets.AppItem : Gtk.ListBoxRow {
689- private AppInfo appinfo;
690- private string appname;
691- private string appbubbles;
692- private string appsounds;
693- private Icon appicon;
694-
695- private Gtk.Grid row_grid;
696- private Gtk.Image row_image;
697- private Gtk.Label row_title;
698- private Gtk.Label row_description;
699-
700- private string[] cond_bubbles = ({"show", "hide"});
701- private string[] cond_sounds = ({"on", "off"});
702-
703- // Please add more exceptions! TODO: app-name, title and icon all in one array.
704- private string[] exceptions = ({"", "indicator-sound", "NetworkManager", "gnome-settings-daemon"});
705-
706- public AppItem (string app_name, string[] properties) {
707- if (search_appinfo_for_name (app_name) && load_icon ()) {
708- appname = app_name;
709- appbubbles = properties [0];
710- appsounds = properties[1];
711-
712- create_ui ();
713- }
714- }
715-
716- private bool search_appinfo_for_name (string app_name) {
717- try {
718- AppInfo found_info = AppInfo.create_from_commandline ("", app_name, AppInfoCreateFlags.NONE);
719-
720- if (!(app_name in exceptions)) {
721- var found = false;
722-
723- AppInfo.get_all ().foreach ((info) => {
724- if (app_name.down ().contains (info.get_name ().down ()) || app_name.down ().contains (info.get_executable ().down ())) {
725- found_info = info;
726- found = true;
727- }
728- });
729-
730- if (!found) {
731- AppInfo.get_all ().foreach ((info) => {
732- if (info.get_display_name ().down ().contains (app_name.down ())) {
733- found_info = info;
734- found = true;
735- }
736- });
737- }
738- }
739-
740- appinfo = found_info;
741- return true;
742- } catch {
743- return false;
744- }
745- }
746-
747- private bool load_icon () {
748- try {
749- if (appinfo.get_icon () == null) {
750- // Please add more exceptions! (See also string[] exceptions!)
751- switch (appinfo.get_display_name ()) {
752- case "indicator-sound":
753- appicon = Icon.new_for_string ("preferences-desktop-sound");
754- break;
755- case "NetworkManager":
756- appicon = Icon.new_for_string ("preferences-system-network");
757- break;
758- case "gnome-settings-daemon":
759- appicon = Icon.new_for_string ("applications-electronics");
760- break;
761- default:
762- appicon = Icon.new_for_string ("application-default-icon");
763- break;
764- }
765- } else {
766- appicon = appinfo.get_icon ();
767- }
768-
769- return true;
770- } catch {
771- return false;
772- }
773- }
774-
775- private void create_ui () {
776- row_grid = new Gtk.Grid ();
777- row_grid.margin = 6;
778- row_grid.column_spacing = 6;
779- this.add (row_grid);
780-
781- row_image = new Gtk.Image.from_gicon (appicon, Gtk.IconSize.DND);
782- row_image.pixel_size = 32;
783- row_grid.attach (row_image, 0, 0, 1, 2);
784-
785- row_title = new Gtk.Label (this.get_title ());
786- row_title.get_style_context ().add_class ("h3");
787- row_title.ellipsize = Pango.EllipsizeMode.END;
788- row_title.halign = Gtk.Align.START;
789- row_title.valign = Gtk.Align.END;
790- row_grid.attach (row_title, 1, 0, 1, 1);
791-
792- row_description = new Gtk.Label (null);
793- row_description.use_markup = true;
794- row_description.ellipsize = Pango.EllipsizeMode.END;
795- row_description.halign = Gtk.Align.START;
796- row_description.valign = Gtk.Align.START;
797- create_description ();
798- row_grid.attach (row_description, 1, 1, 1, 1);
799- }
800-
801- private void create_description () {
802- var desc = "";
803-
804- if (appbubbles != "hide") {
805- desc += _("Bubbles");
806-
807- if (appsounds == "on") {
808- desc += ", " + _("Sounds");
809- }
810- } else {
811- desc += _("Disabled");
812- }
813-
814- row_description.set_label (@"<span font_size=\"small\">$desc</span>");
815- }
816-
817- public string get_title () {
818- // Please add more exceptions! (See also string[] exceptions!)
819- switch (appinfo.get_display_name ()) {
820- case "":
821- return _("Unknown");
822- case "indicator-sound":
823- return _("Sound Menu");
824- case "NetworkManager":
825- return _("Network");
826- case "gnome-settings-daemon":
827- return _("System Configuration");
828- default:
829- switch (appinfo.get_executable ()) {
830- case "midori":
831- return "Midori";
832- default:
833- return appinfo.get_display_name ();
834- }
835- }
836- }
837-
838- public Icon get_icon () {
839- return appicon;
840- }
841-
842- public string get_bubbles () {
843- if (appbubbles in cond_bubbles) {
844- return appbubbles;
845- } else {
846- // Fallback to default
847- if (NotifySettings.get_default ().default_bubbles) {
848- return "show";
849- } else {
850- return "hide";
851- }
852- }
853- }
854-
855- public void set_bubbles (string bubbles) {
856- if (bubbles in cond_bubbles) {
857- appbubbles = bubbles;
858- rewrite_settings ();
859- create_description ();
860- }
861- }
862-
863- public string get_sounds () {
864- if (appsounds in cond_sounds) {
865- return appsounds;
866- } else {
867- // Fallback to default
868- if (NotifySettings.get_default ().default_sounds) {
869- return "on";
870- } else {
871- return "off";
872- }
873- }
874- }
875-
876- public void set_sounds (string sounds) {
877- if (sounds in cond_sounds) {
878- appsounds = sounds;
879- rewrite_settings ();
880- create_description ();
881- }
882- }
883-
884- private void rewrite_settings () {
885- var apps_new = new string[NotifySettings.get_default ().apps.length];
886-
887- for (int i = 0; i < NotifySettings.get_default ().apps.length; i++) {
888- var parameters = NotifySettings.get_default ().apps[i].split (":");
889-
890- if (parameters.length == 2) {
891- if (parameters[0] == appname) {
892- // Rewrite
893- apps_new[i] = appname + ":" + appbubbles + "," + appsounds;
894- } else {
895- // Keep
896- apps_new[i] = NotifySettings.get_default ().apps[i];
897- }
898- }
899- }
900-
901- NotifySettings.get_default ().apps = apps_new;
902- }
903-}
904+/*
905+ * Copyright (c) 2011-2015 elementary Developers
906+ *
907+ * This program is free software; you can redistribute it and/or
908+ * modify it under the terms of the GNU General Public
909+ * License as published by the Free Software Foundation; either
910+ * version 2 of the License, or (at your option) any later version.
911+ *
912+ * This program is distributed in the hope that it will be useful,
913+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
914+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
915+ * General Public License for more details.
916+ *
917+ * You should have received a copy of the GNU General Public
918+ * License along with this program; if not, write to the
919+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
920+ * Boston, MA 02111-1307, USA.
921+ */
922+
923+public class Widgets.AppEntry : Gtk.ListBoxRow {
924+ private static const string BUBBLES_KEY = "bubbles";
925+ private static const string SOUNDS_KEY = "sounds";
926+ private static const string REMEMBER_KEY = "remember";
927+
928+ public Backend.App app { get; construct; }
929+
930+ private Gtk.Grid grid;
931+
932+ private Gtk.Image image;
933+ private Gtk.Label title_label;
934+ private Gtk.Label description_label;
935+
936+ public AppEntry (Backend.App app) {
937+ Object (app: app);
938+
939+ build_ui ();
940+ connect_signals ();
941+ }
942+
943+ private void build_ui () {
944+ grid = new Gtk.Grid ();
945+ grid.margin = 6;
946+ grid.column_spacing = 6;
947+
948+ image = new Gtk.Image.from_gicon (app.app_info.get_icon (), Gtk.IconSize.DND);
949+ image.pixel_size = 32;
950+
951+ title_label = new Gtk.Label (Markup.escape_text (app.app_info.get_display_name ()));
952+ title_label.get_style_context ().add_class ("h3");
953+ title_label.ellipsize = Pango.EllipsizeMode.END;
954+ title_label.halign = Gtk.Align.START;
955+ title_label.valign = Gtk.Align.END;
956+
957+ description_label = new Gtk.Label (get_permissions_string (app));
958+ description_label.use_markup = true;
959+ description_label.ellipsize = Pango.EllipsizeMode.END;
960+ description_label.halign = Gtk.Align.START;
961+ description_label.valign = Gtk.Align.START;
962+
963+ grid.attach (image, 0, 0, 1, 2);
964+ grid.attach (title_label, 1, 0, 1, 1);
965+ grid.attach (description_label, 1, 1, 1, 1);
966+
967+ this.add (grid);
968+ }
969+
970+ private void connect_signals () {
971+ app.settings.changed.connect (() => {
972+ description_label.set_markup (get_permissions_string (app));
973+ });
974+ }
975+
976+ private string get_permissions_string (Backend.App app) {
977+ string[] items = {};
978+
979+ if (app.settings.get_boolean (BUBBLES_KEY)) {
980+ items += _("Bubbles");
981+ }
982+
983+ if (app.settings.get_boolean (SOUNDS_KEY)) {
984+ items += _("Sounds");
985+ }
986+
987+ if (app.settings.get_boolean (REMEMBER_KEY)) {
988+ items += _("Remember");
989+ }
990+
991+ if (items.length == 0) {
992+ items += _("Disabled");
993+ }
994+
995+ return "<span font_size=\"small\">%s</span>".printf (string.joinv (", ", items));
996+ }
997+}
998\ No newline at end of file
999
1000=== modified file 'src/Widgets/AppList.vala'
1001--- src/Widgets/AppList.vala 2015-09-19 06:10:39 +0000
1002+++ src/Widgets/AppList.vala 2015-10-11 11:46:23 +0000
1003@@ -1,102 +1,78 @@
1004-/***
1005- BEGIN LICENSE
1006-
1007- Copyright (C) 2014 elementary Developers
1008- This program is free software: you can redistribute it and/or modify it
1009- under the terms of the GNU Lesser General Public License version 3, as published
1010- by the Free Software Foundation.
1011-
1012- This program is distributed in the hope that it will be useful, but
1013- WITHOUT ANY WARRANTY; without even the implied warranties of
1014- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1015- PURPOSE. See the GNU General Public License for more details.
1016-
1017- You should have received a copy of the GNU General Public License along
1018- with this program. If not, see <http://www.gnu.org/licenses/>
1019-
1020- END LICENSE
1021- Written By: Marcus Wichelmann <admin@marcusw.de>
1022-
1023-***/
1024+/*
1025+ * Copyright (c) 2011-2015 elementary Developers
1026+ *
1027+ * This program is free software; you can redistribute it and/or
1028+ * modify it under the terms of the GNU General Public
1029+ * License as published by the Free Software Foundation; either
1030+ * version 2 of the License, or (at your option) any later version.
1031+ *
1032+ * This program is distributed in the hope that it will be useful,
1033+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1034+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1035+ * General Public License for more details.
1036+ *
1037+ * You should have received a copy of the GNU General Public
1038+ * License along with this program; if not, write to the
1039+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1040+ * Boston, MA 02111-1307, USA.
1041+ */
1042
1043 public class Widgets.AppList : Gtk.ListBox {
1044- private int item_count;
1045- private Cancellable list_apps_cancellable;
1046-
1047- public signal void item_changed (AppItem item);
1048- public signal void list_loaded (int length);
1049-
1050- public AppItem selected_row;
1051-
1052- public AppList () {
1053- this.selection_mode = Gtk.SelectionMode.SINGLE;
1054- this.row_selected.connect ((row) => {
1055- if (row != null) {
1056- selected_row = row as AppItem;
1057- item_changed (row as AppItem);
1058- }
1059- });
1060-
1061- list_apps_cancellable = new Cancellable ();
1062- NotifySettings.get_default ().apps_changed.connect (() => {
1063- if (NotifySettings.get_default ().apps.length != item_count) {
1064- queue_reload ();
1065- }
1066- });
1067-
1068- queue_reload ();
1069- }
1070-
1071- private void queue_reload () {
1072- list_apps_cancellable.cancel ();
1073- this.get_children ().foreach ((row) => {
1074- this.remove (row);
1075- });
1076- list_apps_cancellable.reset ();
1077- list_apps_async.begin ();
1078- }
1079-
1080- private async void list_apps_async () {
1081- var apps = NotifySettings.get_default ().apps;
1082- item_count = apps.length;
1083-
1084- foreach (var app in apps) {
1085- var idle_handler = Idle.add (list_apps_async.callback);
1086- var cancellable_handler = list_apps_cancellable.connect (() => {
1087- Source.remove(idle_handler);
1088- });
1089- yield;
1090- list_apps_cancellable.disconnect (cancellable_handler);
1091-
1092- var parameters = app.split (":");
1093-
1094- if (parameters.length == 2) {
1095- var properties = parameters[1].split (",");
1096-
1097- if (properties.length == 2 && parameters[0] != "notify-send") {
1098- var item = new AppItem (parameters[0], properties);
1099- this.add (item);
1100- }
1101- }
1102-
1103- if (selected_row == null && NotifySettings.get_default ().do_not_disturb == false)
1104- select_first ();
1105-
1106- this.show_all ();
1107- list_loaded (item_count);
1108- }
1109- }
1110-
1111- public void select_first () {
1112- if (item_count > 0) {
1113- var first_row = this.get_row_at_index (0);
1114-
1115- this.select_row (first_row);
1116- selected_row = first_row as AppItem;
1117- }
1118- }
1119-
1120- public void select_none () {
1121- this.select_row (null);
1122- }
1123-}
1124+ construct {
1125+ this.selection_mode = Gtk.SelectionMode.SINGLE;
1126+ this.set_sort_func (sort_func);
1127+
1128+ create_list ();
1129+ connect_signals ();
1130+ select_first_item ();
1131+ }
1132+
1133+ private void create_list () {
1134+ Backend.NotifyManager.get_default ().apps.@foreach ((entry) => {
1135+ AppEntry app_entry = new AppEntry (entry.value);
1136+ this.add (app_entry);
1137+
1138+ return true;
1139+ });
1140+ }
1141+
1142+ private void connect_signals () {
1143+ this.row_selected.connect (show_row);
1144+ }
1145+
1146+ private void show_row (Gtk.ListBoxRow? row) {
1147+ if (row == null) {
1148+ return;
1149+ }
1150+
1151+ if (!(row is AppEntry)) {
1152+ return;
1153+ }
1154+
1155+ Backend.NotifyManager.get_default ().selected_app_id = ((AppEntry)row).app.app_id;
1156+ }
1157+
1158+ private void select_first_item () {
1159+ List<weak Gtk.Widget> children = this.get_children ();
1160+
1161+ if (children.length () > 0) {
1162+ Gtk.ListBoxRow row = ((Gtk.ListBoxRow)children.nth_data (0));
1163+
1164+ this.select_row (row);
1165+ show_row (row);
1166+ }
1167+ }
1168+
1169+ private int sort_func (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) {
1170+ if (!(row1 is AppEntry && row2 is AppEntry)) {
1171+ return 0;
1172+ }
1173+
1174+ string row_name1 = ((AppEntry)row1).app.app_info.get_display_name ();
1175+ string row_name2 = ((AppEntry)row2).app.app_info.get_display_name ();
1176+
1177+ int order = strcmp (row_name1, row_name2);
1178+
1179+ return order.clamp (-1, 1);
1180+ }
1181+}
1182\ No newline at end of file
1183
1184=== renamed file 'src/Widgets/AppSettings.vala' => 'src/Widgets/AppSettingsView.vala'
1185--- src/Widgets/AppSettings.vala 2015-09-16 18:44:59 +0000
1186+++ src/Widgets/AppSettingsView.vala 2015-10-11 11:46:23 +0000
1187@@ -1,152 +1,107 @@
1188-/***
1189- BEGIN LICENSE
1190-
1191- Copyright (C) 2014 elementary Developers
1192- This program is free software: you can redistribute it and/or modify it
1193- under the terms of the GNU Lesser General Public License version 3, as published
1194- by the Free Software Foundation.
1195-
1196- This program is distributed in the hope that it will be useful, but
1197- WITHOUT ANY WARRANTY; without even the implied warranties of
1198- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1199- PURPOSE. See the GNU General Public License for more details.
1200-
1201- You should have received a copy of the GNU General Public License along
1202- with this program. If not, see <http://www.gnu.org/licenses/>
1203-
1204- END LICENSE
1205- Written By: Marcus Wichelmann <admin@marcusw.de>
1206-
1207-***/
1208-
1209-public class Widgets.AppSettings : Gtk.Grid {
1210- private Gtk.Image appicon;
1211- private Gtk.Label apptitle;
1212-
1213- private Gtk.Image bubblesimage;
1214- private Gtk.Label bubblestitle;
1215- private Gtk.Switch bubblesswitch;
1216- private Gtk.Label bubblesinfo;
1217-
1218- private Gtk.Image soundsimage;
1219- private Gtk.Label soundstitle;
1220- private Gtk.Switch soundsswitch;
1221- private Gtk.Label soundsinfo;
1222-
1223- public signal void bubbles_changed (string bubbles);
1224- public signal void sounds_changed (string sounds);
1225-
1226- public AppSettings () {
1227- this.margin = 12;
1228- this.row_spacing = 12;
1229- this.column_spacing = 12;
1230-
1231- appicon = new Gtk.Image ();
1232- this.attach (appicon, 0, 0, 1, 1);
1233-
1234- apptitle = new Gtk.Label (null);
1235- apptitle.halign = Gtk.Align.START;
1236- apptitle.hexpand = true;
1237- this.attach (apptitle, 1, 0, 2, 1);
1238-
1239- bubblesimage = new Gtk.Image.from_file (Constants.PKGDATADIR + "/bubbles.svg");
1240- bubblesimage.halign = Gtk.Align.START;
1241- bubblesimage.hexpand = false;
1242- bubblesimage.margin_top = 50;
1243- this.attach (bubblesimage, 1, 1, 1, 3);
1244-
1245- bubblestitle = new Gtk.Label ("<span font_weight=\"bold\" size=\"large\">" + _("Bubbles") + "</span>");
1246- bubblestitle.use_markup = true;
1247- bubblestitle.halign = Gtk.Align.START;
1248- bubblestitle.valign = Gtk.Align.START;
1249- bubblestitle.hexpand = true;
1250- bubblestitle.vexpand = false;
1251- bubblestitle.margin_top = 50 + 5;
1252- this.attach (bubblestitle, 2, 1, 1, 1);
1253-
1254- bubblesswitch = new Gtk.Switch ();
1255- bubblesswitch.halign = Gtk.Align.START;
1256- bubblesswitch.valign = Gtk.Align.CENTER;
1257- bubblesswitch.hexpand = false;
1258- bubblesswitch.vexpand = false;
1259- bubblesswitch.notify["active"].connect (() => {
1260- if (bubblesswitch.active) {
1261- bubbles_changed ("show");
1262- soundsswitch.set_sensitive (true);
1263- } else {
1264- bubbles_changed ("hide");
1265- soundsswitch.set_sensitive (false);
1266- }
1267- });
1268- this.attach (bubblesswitch, 2, 2, 1, 1);
1269-
1270- bubblesinfo = new Gtk.Label (_("Bubbles appear in the top right corner of the display and disappear automatically."));
1271- bubblesinfo.halign = Gtk.Align.START;
1272- bubblesinfo.valign = Gtk.Align.START;
1273- bubblesinfo.hexpand = true;
1274- bubblesinfo.vexpand = false;
1275- bubblesinfo.margin_bottom = 9;
1276- bubblesinfo.wrap = true;
1277- bubblesinfo.justify = Gtk.Justification.LEFT;
1278- this.attach (bubblesinfo, 2, 3, 1, 1);
1279-
1280- soundsimage = new Gtk.Image.from_file (Constants.PKGDATADIR + "/sounds.svg");
1281- soundsimage.halign = Gtk.Align.START;
1282- soundsimage.hexpand = false;
1283- soundsimage.margin_top = 50;
1284- this.attach (soundsimage, 1, 4, 1, 3);
1285-
1286- soundstitle = new Gtk.Label ("<span font_weight=\"bold\" size=\"large\">" + _("Sounds") + "</span>");
1287- soundstitle.use_markup = true;
1288- soundstitle.halign = Gtk.Align.START;
1289- soundstitle.valign = Gtk.Align.START;
1290- soundstitle.hexpand = true;
1291- soundstitle.vexpand = false;
1292- soundstitle.margin_top = 50 + 5;
1293- this.attach (soundstitle, 2, 4, 1, 1);
1294-
1295- soundsswitch = new Gtk.Switch ();
1296- soundsswitch.halign = Gtk.Align.START;
1297- soundsswitch.valign = Gtk.Align.CENTER;
1298- soundsswitch.hexpand = false;
1299- soundsswitch.vexpand = false;
1300- soundsswitch.notify["active"].connect (() => {
1301- if (soundsswitch.active) {
1302- sounds_changed ("on");
1303- } else {
1304- sounds_changed ("off");
1305- }
1306- });
1307- this.attach (soundsswitch, 2, 5, 1, 1);
1308-
1309- soundsinfo = new Gtk.Label (_("Sounds play once when a new notification arrives."));
1310- soundsinfo.halign = Gtk.Align.START;
1311- soundsinfo.valign = Gtk.Align.START;
1312- soundsinfo.hexpand = true;
1313- soundsinfo.vexpand = false;
1314- soundsinfo.margin_bottom = 9;
1315- soundsinfo.wrap = true;
1316- soundsinfo.justify = Gtk.Justification.LEFT;
1317- this.attach (soundsinfo, 2, 6, 1, 1);
1318-
1319- this.show_all ();
1320- }
1321-
1322- public void set_appicon (Icon icon) {
1323- appicon.set_from_gicon (icon, Gtk.IconSize.DIALOG);
1324- appicon.pixel_size = 48;
1325- }
1326-
1327- public void set_apptitle (string title) {
1328- apptitle.set_label (title);
1329- apptitle.get_style_context ().add_class ("h2");
1330- }
1331-
1332- public void set_bubbles (string bubbles) {
1333- bubblesswitch.set_active (bubbles == "show");
1334- }
1335-
1336- public void set_sounds (string sounds) {
1337- soundsswitch.set_active (sounds == "on");
1338- }
1339-}
1340+/*
1341+ * Copyright (c) 2011-2015 elementary Developers
1342+ *
1343+ * This program is free software; you can redistribute it and/or
1344+ * modify it under the terms of the GNU General Public
1345+ * License as published by the Free Software Foundation; either
1346+ * version 2 of the License, or (at your option) any later version.
1347+ *
1348+ * This program is distributed in the hope that it will be useful,
1349+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1350+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1351+ * General Public License for more details.
1352+ *
1353+ * You should have received a copy of the GNU General Public
1354+ * License along with this program; if not, write to the
1355+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1356+ * Boston, MA 02111-1307, USA.
1357+ */
1358+
1359+public class Widgets.AppSettingsView : Gtk.Grid {
1360+ private static const string BUBBLES_KEY = "bubbles";
1361+ private static const string SOUNDS_KEY = "sounds";
1362+ private static const string REMEMBER_KEY = "remember";
1363+
1364+ private Backend.App? selected_app = null;
1365+
1366+ private SettingsHeader header;
1367+
1368+ private Gtk.Switch bubbles_switch;
1369+ private SettingsOption bubbles_option;
1370+
1371+ private Gtk.Switch sound_switch;
1372+ private SettingsOption sound_option;
1373+
1374+ private Gtk.Switch remember_switch;
1375+ private SettingsOption remember_option;
1376+
1377+ construct {
1378+ build_ui ();
1379+ update_selected_app ();
1380+ create_bindings ();
1381+ update_header ();
1382+ connect_signals ();
1383+ }
1384+
1385+ private void build_ui () {
1386+ this.margin = 12;
1387+ this.row_spacing = 32;
1388+
1389+ header = new SettingsHeader ();
1390+
1391+ bubbles_option = new SettingsOption (
1392+ Constants.PKGDATADIR + "/bubbles.svg",
1393+ _("Bubbles"),
1394+ _("Bubbles appear in the top right corner of the display and disappear automatically."),
1395+ bubbles_switch = new Gtk.Switch ());
1396+
1397+ sound_option = new SettingsOption (
1398+ Constants.PKGDATADIR + "/sounds.svg",
1399+ _("Sounds"),
1400+ _("Sounds play once when a new notification arrives."),
1401+ sound_switch = new Gtk.Switch ());
1402+
1403+ remember_option = new SettingsOption (
1404+ Constants.PKGDATADIR + "/notify-center.svg",
1405+ _("Remember"),
1406+ _("Show missed notifications in Notification Center."),
1407+ remember_switch = new Gtk.Switch ());
1408+
1409+ this.attach (header, 0, 0, 1, 1);
1410+ this.attach (bubbles_option, 0, 1, 1, 1);
1411+ this.attach (sound_option, 0, 2, 1, 1);
1412+ this.attach (remember_option, 0, 3, 1, 1);
1413+ }
1414+
1415+ private void connect_signals () {
1416+ Backend.NotifyManager.get_default ().notify["selected-app-id"].connect (() => {
1417+ remove_bindings ();
1418+ update_selected_app ();
1419+ create_bindings ();
1420+ update_header ();
1421+ });
1422+ }
1423+
1424+ private void remove_bindings () {
1425+ Settings.unbind (bubbles_option.widget, "state");
1426+ Settings.unbind (sound_option.widget, "state");
1427+ Settings.unbind (remember_option.widget, "state");
1428+ }
1429+
1430+ private void update_selected_app () {
1431+ Backend.NotifyManager notify_manager = Backend.NotifyManager.get_default ();
1432+ string app_id = notify_manager.selected_app_id;
1433+ selected_app = notify_manager.apps.get (app_id);
1434+ }
1435+
1436+ private void create_bindings () {
1437+ selected_app.settings.bind (BUBBLES_KEY, bubbles_option.widget, "state", GLib.SettingsBindFlags.DEFAULT);
1438+ selected_app.settings.bind (SOUNDS_KEY, sound_option.widget, "state", GLib.SettingsBindFlags.DEFAULT);
1439+ selected_app.settings.bind (REMEMBER_KEY, remember_option.widget, "state", GLib.SettingsBindFlags.DEFAULT);
1440+ }
1441+
1442+ private void update_header () {
1443+ header.set_title (selected_app.app_info.get_display_name ());
1444+ header.set_icon (selected_app.app_info.get_icon ());
1445+ }
1446+}
1447\ No newline at end of file
1448
1449=== modified file 'src/Widgets/Footer.vala'
1450--- src/Widgets/Footer.vala 2015-10-06 16:47:07 +0000
1451+++ src/Widgets/Footer.vala 2015-10-11 11:46:23 +0000
1452@@ -1,29 +1,32 @@
1453-/***
1454- BEGIN LICENSE
1455-
1456- Copyright (C) 2014 elementary Developers
1457- This program is free software: you can redistribute it and/or modify it
1458- under the terms of the GNU Lesser General Public License version 3, as published
1459- by the Free Software Foundation.
1460-
1461- This program is distributed in the hope that it will be useful, but
1462- WITHOUT ANY WARRANTY; without even the implied warranties of
1463- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1464- PURPOSE. See the GNU General Public License for more details.
1465-
1466- You should have received a copy of the GNU General Public License along
1467- with this program. If not, see <http://www.gnu.org/licenses/>
1468-
1469- END LICENSE
1470- Written By: Marcus Wichelmann <admin@marcusw.de>
1471-
1472-***/
1473+/*
1474+ * Copyright (c) 2011-2015 elementary Developers
1475+ *
1476+ * This program is free software; you can redistribute it and/or
1477+ * modify it under the terms of the GNU General Public
1478+ * License as published by the Free Software Foundation; either
1479+ * version 2 of the License, or (at your option) any later version.
1480+ *
1481+ * This program is distributed in the hope that it will be useful,
1482+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1483+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1484+ * General Public License for more details.
1485+ *
1486+ * You should have received a copy of the GNU General Public
1487+ * License along with this program; if not, write to the
1488+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1489+ * Boston, MA 02111-1307, USA.
1490+ */
1491
1492 public class Widgets.Footer : Gtk.Grid {
1493 private Gtk.Label do_not_disturb_label;
1494 private Gtk.Switch do_not_disturb_switch;
1495
1496- public Footer () {
1497+ construct {
1498+ build_ui ();
1499+ create_bindings ();
1500+ }
1501+
1502+ private void build_ui () {
1503 this.margin = 12;
1504 this.column_spacing = 12;
1505
1506@@ -36,7 +39,12 @@
1507
1508 this.attach (do_not_disturb_label, 0, 0, 1, 1);
1509 this.attach (do_not_disturb_switch, 1, 0, 1, 1);
1510+ }
1511
1512- NotifySettings.get_default ().settings.bind ("do-not-disturb", do_not_disturb_switch, "active", SettingsBindFlags.DEFAULT);
1513+ private void create_bindings () {
1514+ Backend.NotifyManager.get_default ().bind_property ("do-not-disturb",
1515+ do_not_disturb_switch,
1516+ "state",
1517+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
1518 }
1519-}
1520+}
1521\ No newline at end of file
1522
1523=== removed file 'src/Widgets/InfoScreen.vala'
1524--- src/Widgets/InfoScreen.vala 2014-11-15 23:15:37 +0000
1525+++ src/Widgets/InfoScreen.vala 1970-01-01 00:00:00 +0000
1526@@ -1,66 +0,0 @@
1527-/***
1528- BEGIN LICENSE
1529-
1530- Copyright (C) 2014 elementary Developers
1531- This program is free software: you can redistribute it and/or modify it
1532- under the terms of the GNU Lesser General Public License version 3, as published
1533- by the Free Software Foundation.
1534-
1535- This program is distributed in the hope that it will be useful, but
1536- WITHOUT ANY WARRANTY; without even the implied warranties of
1537- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1538- PURPOSE. See the GNU General Public License for more details.
1539-
1540- You should have received a copy of the GNU General Public License along
1541- with this program. If not, see <http://www.gnu.org/licenses/>
1542-
1543- END LICENSE
1544- Written By: Marcus Wichelmann <admin@marcusw.de>
1545-
1546-***/
1547-
1548-public class Widgets.InfoScreen : Gtk.Frame {
1549- private Gtk.Grid grid;
1550-
1551- private Gtk.Image image;
1552- private Gtk.Label title;
1553- private Gtk.Label description;
1554-
1555- // Compareable to the widget of switchboard-plug-security-privacy.
1556- public InfoScreen (string header, string desc, string icon_name) {
1557- this.expand = true;
1558- this.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
1559- this.shadow_type = Gtk.ShadowType.NONE;
1560-
1561- grid = new Gtk.Grid ();
1562- grid.vexpand = false;
1563- grid.valign = Gtk.Align.CENTER;
1564- grid.halign = Gtk.Align.CENTER;
1565- grid.border_width = 24;
1566- grid.row_spacing = 12;
1567- grid.column_spacing = 12;
1568-
1569- image = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.DIALOG);
1570- image.valign = Gtk.Align.START;
1571- image.halign = Gtk.Align.END;
1572-
1573- grid.attach (image, 0, 0, 1, 2);
1574-
1575- title = new Gtk.Label (header);
1576- title.halign = Gtk.Align.START;
1577- title.set_line_wrap (true);
1578- title.justify = Gtk.Justification.FILL;
1579- title.get_style_context ().add_class ("h2");
1580- grid.attach (title, 1, 0, 1, 1);
1581-
1582- description = new Gtk.Label (desc);
1583- description.halign = Gtk.Align.START;
1584- description.set_line_wrap (true);
1585- description.justify = Gtk.Justification.FILL;
1586- grid.attach (description, 1, 1, 1, 1);
1587-
1588- grid.show_all ();
1589-
1590- this.add (grid);
1591- }
1592-}
1593
1594=== renamed file 'src/Widgets/AppsView.vala' => 'src/Widgets/MainView.vala'
1595--- src/Widgets/AppsView.vala 2015-09-12 23:27:51 +0000
1596+++ src/Widgets/MainView.vala 2015-10-11 11:46:23 +0000
1597@@ -1,99 +1,72 @@
1598-/***
1599- BEGIN LICENSE
1600-
1601- Copyright (C) 2014 elementary Developers
1602- This program is free software: you can redistribute it and/or modify it
1603- under the terms of the GNU Lesser General Public License version 3, as published
1604- by the Free Software Foundation.
1605-
1606- This program is distributed in the hope that it will be useful, but
1607- WITHOUT ANY WARRANTY; without even the implied warranties of
1608- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1609- PURPOSE. See the GNU General Public License for more details.
1610-
1611- You should have received a copy of the GNU General Public License along
1612- with this program. If not, see <http://www.gnu.org/licenses/>
1613-
1614- END LICENSE
1615- Written By: Marcus Wichelmann <admin@marcusw.de>
1616-
1617-***/
1618-
1619-public class Widgets.AppsView : Granite.Widgets.ThinPaned {
1620- private Gtk.Box sidebar;
1621-
1622- private Gtk.ScrolledWindow scrolled_window;
1623- public AppList applist;
1624- private Footer footer;
1625-
1626- private Gtk.Stack content;
1627-
1628- private AppSettings appsettings;
1629- private InfoScreen do_not_disturb_info;
1630-
1631- public AppsView () {
1632- sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
1633-
1634- applist = new AppList ();
1635- footer = new Footer ();
1636-
1637- content = new Gtk.Stack ();
1638-
1639- appsettings = new AppSettings ();
1640- do_not_disturb_info = new InfoScreen (_("elementary OS is in Do Not Disturb mode"),
1641- _("While in Do Not Disturb mode, notifications and alerts will be hidden and notification sounds will be silenced.") + "\n\n" +
1642- _("System notifications, such as volume and display brightness, will be unaffected."),
1643- "notification-disabled");
1644-
1645- content.add_named (appsettings, "app-settings");
1646- content.add_named (do_not_disturb_info, "do-not-disturb");
1647-
1648- scrolled_window = new Gtk.ScrolledWindow (null, null);
1649- scrolled_window.add (applist);
1650-
1651- sidebar.pack_start (scrolled_window, true, true);
1652- sidebar.pack_start (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), false, true);
1653- sidebar.pack_start (footer, false, true);
1654-
1655- this.pack1 (sidebar, true, false);
1656- this.pack2 (content, true, false);
1657- this.set_position (240);
1658-
1659- applist.item_changed.connect (select_app);
1660-
1661- appsettings.bubbles_changed.connect ((bubbles) => {
1662- (applist.selected_row as AppItem).set_bubbles (bubbles);
1663- });
1664-
1665- appsettings.sounds_changed.connect ((sounds) => {
1666- (applist.selected_row as AppItem).set_sounds (sounds);
1667- });
1668-
1669- set_do_not_disturb_mode (NotifySettings.get_default ().do_not_disturb);
1670-
1671- NotifySettings.get_default ().do_not_disturb_changed.connect ((do_not_disturb) => {
1672- set_do_not_disturb_mode (do_not_disturb);
1673- });
1674- }
1675-
1676- private void set_do_not_disturb_mode (bool do_not_disturb) {
1677- if (do_not_disturb) {
1678- applist.set_sensitive (false);
1679- applist.select_none ();
1680- do_not_disturb_info.show ();
1681- content.set_visible_child (do_not_disturb_info);
1682- } else {
1683- applist.set_sensitive (true);
1684- applist.select_first ();
1685- content.set_visible_child (appsettings);
1686- }
1687- }
1688-
1689- private void select_app (AppItem item) {
1690- appsettings.set_appicon (item.get_icon ());
1691- appsettings.set_apptitle (item.get_title ());
1692- appsettings.set_bubbles (item.get_bubbles ());
1693- appsettings.set_sounds (item.get_sounds ());
1694- appsettings.set_sensitive (true);
1695- }
1696-}
1697+/*
1698+ * Copyright (c) 2011-2015 elementary Developers
1699+ *
1700+ * This program is free software; you can redistribute it and/or
1701+ * modify it under the terms of the GNU General Public
1702+ * License as published by the Free Software Foundation; either
1703+ * version 2 of the License, or (at your option) any later version.
1704+ *
1705+ * This program is distributed in the hope that it will be useful,
1706+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1707+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1708+ * General Public License for more details.
1709+ *
1710+ * You should have received a copy of the GNU General Public
1711+ * License along with this program; if not, write to the
1712+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1713+ * Boston, MA 02111-1307, USA.
1714+ */
1715+
1716+public class Widgets.MainView : Gtk.Paned {
1717+ private static Granite.Widgets.AlertView create_alert_view () {
1718+ var title = _("elementary OS is in Do Not Disturb mode");
1719+
1720+ var description = _("While in Do Not Disturb mode, notifications and alerts will be hidden and notification sounds will be silenced.");
1721+ description += "\n\n";
1722+ description += _("System notifications, such as volume and display brightness, will be unaffected.");
1723+
1724+ var icon_name = "notification-disabled";
1725+
1726+ return new Granite.Widgets.AlertView (title, description, icon_name);
1727+ }
1728+
1729+ private Sidebar sidebar;
1730+
1731+ private Gtk.Stack content;
1732+
1733+ private AppSettingsView app_settings_view;
1734+ private Granite.Widgets.AlertView alert_view;
1735+
1736+ construct {
1737+ build_ui ();
1738+ update_view ();
1739+ connect_signals ();
1740+ }
1741+
1742+ private void build_ui () {
1743+ sidebar = new Sidebar ();
1744+
1745+ content = new Gtk.Stack ();
1746+
1747+ app_settings_view = new AppSettingsView ();
1748+ alert_view = create_alert_view ();
1749+
1750+ app_settings_view.show_all ();
1751+ alert_view.show_all ();
1752+
1753+ content.add_named (app_settings_view, "app-settings-view");
1754+ content.add_named (alert_view, "alert-view");
1755+
1756+ this.pack1 (sidebar, true, false);
1757+ this.pack2 (content, true, false);
1758+ this.set_position (240);
1759+ }
1760+
1761+ private void connect_signals () {
1762+ Backend.NotifyManager.get_default ().notify["do-not-disturb"].connect (update_view);
1763+ }
1764+
1765+ private void update_view () {
1766+ content.set_visible_child_name (Backend.NotifyManager.get_default ().do_not_disturb ? "alert-view" : "app-settings-view");
1767+ }
1768+}
1769\ No newline at end of file
1770
1771=== added file 'src/Widgets/SettingsHeader.vala'
1772--- src/Widgets/SettingsHeader.vala 1970-01-01 00:00:00 +0000
1773+++ src/Widgets/SettingsHeader.vala 2015-10-11 11:46:23 +0000
1774@@ -0,0 +1,50 @@
1775+/*
1776+ * Copyright (c) 2011-2015 elementary Developers
1777+ *
1778+ * This program is free software; you can redistribute it and/or
1779+ * modify it under the terms of the GNU General Public
1780+ * License as published by the Free Software Foundation; either
1781+ * version 2 of the License, or (at your option) any later version.
1782+ *
1783+ * This program is distributed in the hope that it will be useful,
1784+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1785+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1786+ * General Public License for more details.
1787+ *
1788+ * You should have received a copy of the GNU General Public
1789+ * License along with this program; if not, write to the
1790+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1791+ * Boston, MA 02111-1307, USA.
1792+ */
1793+
1794+public class Widgets.SettingsHeader : Gtk.Grid {
1795+ private Gtk.Image app_image;
1796+ private Gtk.Label app_label;
1797+
1798+ construct {
1799+ build_ui ();
1800+ }
1801+
1802+ public void set_title (string title) {
1803+ app_label.set_label ("<span font_weight=\"bold\" size=\"x-large\">%s</span>".printf (Markup.escape_text (title)));
1804+ }
1805+
1806+ public void set_icon (Icon icon) {
1807+ app_image.set_from_gicon (icon, Gtk.IconSize.DIALOG);
1808+ app_image.set_pixel_size (48);
1809+ }
1810+
1811+ private void build_ui () {
1812+ this.column_spacing = 12;
1813+
1814+ app_image = new Gtk.Image ();
1815+
1816+ app_label = new Gtk.Label (null);
1817+ app_label.use_markup = true;
1818+ app_label.halign = Gtk.Align.START;
1819+ app_label.hexpand = true;
1820+
1821+ this.attach (app_image, 0, 0, 1, 1);
1822+ this.attach (app_label, 1, 0, 1, 1);
1823+ }
1824+}
1825\ No newline at end of file
1826
1827=== added file 'src/Widgets/SettingsOption.vala'
1828--- src/Widgets/SettingsOption.vala 1970-01-01 00:00:00 +0000
1829+++ src/Widgets/SettingsOption.vala 2015-10-11 11:46:23 +0000
1830@@ -0,0 +1,74 @@
1831+/*
1832+ * Copyright (c) 2011-2015 elementary Developers
1833+ *
1834+ * This program is free software; you can redistribute it and/or
1835+ * modify it under the terms of the GNU General Public
1836+ * License as published by the Free Software Foundation; either
1837+ * version 2 of the License, or (at your option) any later version.
1838+ *
1839+ * This program is distributed in the hope that it will be useful,
1840+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1841+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1842+ * General Public License for more details.
1843+ *
1844+ * You should have received a copy of the GNU General Public
1845+ * License along with this program; if not, write to the
1846+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1847+ * Boston, MA 02111-1307, USA.
1848+ */
1849+
1850+public class Widgets.SettingsOption : Gtk.Grid {
1851+ public string image_path { get; construct; }
1852+ public string title { get; construct; }
1853+ public string description { get; construct; }
1854+ public Gtk.Widget widget { get; construct; }
1855+
1856+ private Gtk.Image image;
1857+ private Gtk.Label title_label;
1858+ private Gtk.Label description_label;
1859+
1860+ public SettingsOption (string image_path, string title, string description, Gtk.Widget widget) {
1861+ Object (image_path: image_path,
1862+ title: title,
1863+ description: description,
1864+ widget: widget);
1865+
1866+ build_ui ();
1867+ }
1868+
1869+ private void build_ui () {
1870+ this.column_spacing = 6;
1871+ this.row_spacing = 6;
1872+ this.margin_start = 60;
1873+ this.margin_end = 30;
1874+
1875+ image = new Gtk.Image.from_file (image_path);
1876+ image.halign = Gtk.Align.START;
1877+ image.hexpand = false;
1878+
1879+ title_label = new Gtk.Label (title);
1880+ title_label.get_style_context ().add_class ("h2");
1881+ title_label.halign = Gtk.Align.START;
1882+ title_label.valign = Gtk.Align.END;
1883+ title_label.hexpand = true;
1884+ title_label.vexpand = false;
1885+
1886+ widget.halign = Gtk.Align.START;
1887+ widget.valign = Gtk.Align.CENTER;
1888+ widget.hexpand = false;
1889+ widget.vexpand = false;
1890+
1891+ description_label = new Gtk.Label (description);
1892+ description_label.halign = Gtk.Align.START;
1893+ description_label.valign = Gtk.Align.START;
1894+ description_label.hexpand = true;
1895+ description_label.vexpand = false;
1896+ description_label.wrap = true;
1897+ description_label.justify = Gtk.Justification.LEFT;
1898+
1899+ this.attach (image, 0, 0, 1, 3);
1900+ this.attach (title_label, 1, 0, 1, 1);
1901+ this.attach (widget, 1, 1, 1, 1);
1902+ this.attach (description_label, 1, 2, 1, 1);
1903+ }
1904+}
1905\ No newline at end of file
1906
1907=== added file 'src/Widgets/Sidebar.vala'
1908--- src/Widgets/Sidebar.vala 1970-01-01 00:00:00 +0000
1909+++ src/Widgets/Sidebar.vala 2015-10-11 11:46:23 +0000
1910@@ -0,0 +1,59 @@
1911+/*
1912+ * Copyright (c) 2011-2015 elementary Developers
1913+ *
1914+ * This program is free software; you can redistribute it and/or
1915+ * modify it under the terms of the GNU General Public
1916+ * License as published by the Free Software Foundation; either
1917+ * version 2 of the License, or (at your option) any later version.
1918+ *
1919+ * This program is distributed in the hope that it will be useful,
1920+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1921+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1922+ * General Public License for more details.
1923+ *
1924+ * You should have received a copy of the GNU General Public
1925+ * License along with this program; if not, write to the
1926+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1927+ * Boston, MA 02111-1307, USA.
1928+ */
1929+
1930+public class Widgets.Sidebar : Gtk.Box {
1931+ private Gtk.ScrolledWindow scrolled_window;
1932+ private AppList app_list;
1933+
1934+ private Footer footer;
1935+
1936+ construct {
1937+ build_ui ();
1938+ create_bindings ();
1939+ }
1940+
1941+ private void build_ui () {
1942+ this.orientation = Gtk.Orientation.VERTICAL;
1943+
1944+ scrolled_window = create_scrolled_window ();
1945+
1946+ footer = new Footer ();
1947+
1948+ this.pack_start (scrolled_window);
1949+ this.pack_start (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), false, false);
1950+ this.pack_end (footer, false, false);
1951+ }
1952+
1953+ private void create_bindings () {
1954+ Backend.NotifyManager.get_default ().bind_property ("do-not-disturb",
1955+ app_list,
1956+ "sensitive",
1957+ BindingFlags.INVERT_BOOLEAN | BindingFlags.SYNC_CREATE);
1958+ }
1959+
1960+ private Gtk.ScrolledWindow create_scrolled_window () {
1961+ var scrolled_window = new Gtk.ScrolledWindow (null, null);
1962+
1963+ app_list = new AppList ();
1964+
1965+ scrolled_window.add (app_list);
1966+
1967+ return scrolled_window;
1968+ }
1969+}
1970\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: