Merge lp:~tintou/switchboard/can-show into lp:~elementary-pantheon/switchboard/switchboard

Proposed by Corentin Noël
Status: Merged
Merged at revision: 717
Proposed branch: lp:~tintou/switchboard/can-show
Merge into: lp:~elementary-pantheon/switchboard/switchboard
Diff against target: 116 lines (+55/-3)
4 files modified
lib/Plug.vala (+2/-1)
src/CategoryView.vala (+48/-1)
src/Widgets/CategoryFlowBox.vala (+4/-0)
src/Widgets/CategoryIcon.vala (+1/-1)
To merge this branch: bzr merge lp:~tintou/switchboard/can-show
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+310828@code.launchpad.net

Commit message

Hide and Show settings panes when hardware devices are present/not present

Description of the change

To test: lp:switchboard-plug-bluetooth [Plug/Unplug a Bluetooth dongle]

To post a comment you must log in.
Revision history for this message
RabbitBot (rabbitbot-a) wrote :

Attempt to merge into lp:switchboard failed due to conflicts:

text conflict in src/CategoryView.vala

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Plug.vala'
2--- lib/Plug.vala 2016-11-02 00:24:55 +0000
3+++ lib/Plug.vala 2016-11-15 00:05:14 +0000
4@@ -75,7 +75,8 @@
5 public bool can_show { get; set; default=true; }
6
7 /**
8- * Inform the application that the plug can now be listed in the available plugs
9+ * Inform the application that the plug can now be listed in the available plugs.
10+ * The application will also listen to the notify::can-show signal.
11 */
12 public signal void visibility_changed ();
13
14
15=== modified file 'src/CategoryView.vala'
16--- src/CategoryView.vala 2016-05-12 17:41:11 +0000
17+++ src/CategoryView.vala 2016-11-15 00:05:14 +0000
18@@ -55,6 +55,7 @@
19 var plugsmanager = Switchboard.PlugsManager.get_default ();
20 plugsmanager.plug_added.connect ((plug) => {
21 plug.visibility_changed.connect (() => plug_visibility_changed (plug));
22+ plug.notify["can-show"].connect (() => plug_visibility_changed (plug));
23 add_plug (plug);
24 });
25
26@@ -71,8 +72,10 @@
27 }
28
29 private void plug_visibility_changed (Switchboard.Plug plug) {
30- if (plug.can_show == true) {
31+ if (plug.can_show) {
32 add_plug (plug);
33+ } else {
34+ remove_plug (plug);
35 }
36 }
37
38@@ -114,6 +117,50 @@
39 }
40 }
41
42+ public void remove_plug (Switchboard.Plug plug) {
43+ if (plug.can_show == true) {
44+ return;
45+ }
46+
47+ switch (plug.category) {
48+ case Switchboard.Plug.Category.PERSONAL:
49+ personal_category.get_flow_children ().foreach ((child) => {
50+ if (child is Switchboard.CategoryIcon && ((Switchboard.CategoryIcon) child).plug == plug) {
51+ child.destroy ();
52+ }
53+ });
54+ break;
55+ case Switchboard.Plug.Category.HARDWARE:
56+ hardware_category.get_flow_children ().foreach ((child) => {
57+ if (child is Switchboard.CategoryIcon && ((Switchboard.CategoryIcon) child).plug == plug) {
58+ child.destroy ();
59+ }
60+ });
61+ break;
62+ case Switchboard.Plug.Category.NETWORK:
63+ network_category.get_flow_children ().foreach ((child) => {
64+ if (child is Switchboard.CategoryIcon && ((Switchboard.CategoryIcon) child).plug == plug) {
65+ child.destroy ();
66+ }
67+ });
68+ break;
69+ case Switchboard.Plug.Category.SYSTEM:
70+ system_category.get_flow_children ().foreach ((child) => {
71+ if (child is Switchboard.CategoryIcon && ((Switchboard.CategoryIcon) child).plug == plug) {
72+ child.destroy ();
73+ }
74+ });
75+ break;
76+ default:
77+ return;
78+ }
79+
80+#if HAVE_UNITY
81+ unowned SwitchboardApp app = (SwitchboardApp) GLib.Application.get_default ();
82+ app.update_libunity_quicklist ();
83+#endif
84+ }
85+
86 public void grab_focus_first_icon_view () {
87 if (personal_category.has_child ()) {
88 personal_category.focus_first_child ();
89
90=== modified file 'src/Widgets/CategoryFlowBox.vala'
91--- src/Widgets/CategoryFlowBox.vala 2016-11-03 21:57:17 +0000
92+++ src/Widgets/CategoryFlowBox.vala 2016-11-15 00:05:14 +0000
93@@ -70,6 +70,10 @@
94 flowbox.add (widget);
95 }
96
97+ public GLib.List<weak Gtk.Widget> get_flow_children () {
98+ return flowbox.get_children ();
99+ }
100+
101 public void activate_first_child () {
102 foreach (unowned Gtk.Widget child in flowbox.get_children ()) {
103 if (child.get_child_visible ()) {
104
105=== modified file 'src/Widgets/CategoryIcon.vala'
106--- src/Widgets/CategoryIcon.vala 2016-05-12 18:08:35 +0000
107+++ src/Widgets/CategoryIcon.vala 2016-11-15 00:05:14 +0000
108@@ -22,7 +22,7 @@
109
110 public class CategoryIcon : Gtk.FlowBoxChild {
111
112- public Switchboard.Plug plug;
113+ public unowned Switchboard.Plug plug;
114
115 public CategoryIcon (Switchboard.Plug plug_item) {
116 plug = plug_item;

Subscribers

People subscribed via source and target branches

to all changes: