Merge lp:~tombeckmann/switchboard/gcc-better-interop into lp:~elementary-pantheon/switchboard/switchboard

Proposed by Tom Beckmann
Status: Rejected
Rejected by: Tom Beckmann
Proposed branch: lp:~tombeckmann/switchboard/gcc-better-interop
Merge into: lp:~elementary-pantheon/switchboard/switchboard
Diff against target: 153 lines (+46/-9)
2 files modified
lib/PlugsManager.vala (+18/-5)
src/Switchboard.vala (+28/-4)
To merge this branch: bzr merge lp:~tombeckmann/switchboard/gcc-better-interop
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+225756@code.launchpad.net

Description of the change

This adds a get_toplevel() method and a embed_widget() widget signal to PlugsManager. Those two are required by GCC plugs and enabled via this MR https://code.launchpad.net/~tombeckmann/pantheon-plugs/gcc-get-toplevel-fix/+merge/225752

Designers, when a panel requests to put a widget in the header I just replace the searchbar, which is disabled anyway, and show it again once the plug is left. It would look like this then for the two plugs that require it:

http://imgur.com/kF5U6bQ,mfWJdp4#1

To post a comment you must log in.
Revision history for this message
Tom Beckmann (tombeckmann) wrote :

I reworked the mentioned MR so that no more API changes are required, so this branch is unnecessary.

Unmerged revisions

459. By Tom Beckmann

allow embedding widgets in the header, add get_toplevel method to PlugsManager

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/PlugsManager.vala'
2--- lib/PlugsManager.vala 2014-04-09 22:10:05 +0000
3+++ lib/PlugsManager.vala 2014-07-06 15:55:31 +0000
4@@ -23,12 +23,22 @@
5 public class Switchboard.PlugsManager : GLib.Object {
6
7 private static Switchboard.PlugsManager? plugs_manager = null;
8+
9+ public static void init (Gtk.Widget toplevel)
10+ {
11+ if (plugs_manager != null)
12+ return;
13+
14+ plugs_manager = new PlugsManager (toplevel);
15+ }
16
17- public static PlugsManager get_default () {
18- if (plugs_manager == null)
19- plugs_manager = new PlugsManager ();
20+ public static PlugsManager get_default ()
21+ requires (plugs_manager != null) {
22+
23 return plugs_manager;
24 }
25+
26+ public Gtk.Widget toplevel { get; construct; }
27
28 [CCode (has_target = false)]
29 private delegate Switchboard.Plug RegisterPluginFunction (Module module);
30@@ -36,8 +46,11 @@
31 private Gee.LinkedList<Switchboard.Plug> plugs;
32
33 public signal void plug_added (Switchboard.Plug plug);
34+ public signal void embed_widget_requested (Gtk.Widget widget);
35
36- private PlugsManager () {
37+ private PlugsManager (Gtk.Widget toplevel) {
38+ Object (toplevel: toplevel);
39+
40 plugs = new Gee.LinkedList<Switchboard.Plug> ();
41 var base_folder = File.new_for_path (Build.PLUGS_DIR);
42 find_plugins (base_folder);
43@@ -104,4 +117,4 @@
44 public Gee.Collection<Switchboard.Plug> get_plugs () {
45 return plugs.read_only_view;
46 }
47-}
48\ No newline at end of file
49+}
50
51=== modified file 'src/Switchboard.vala'
52--- src/Switchboard.vala 2014-05-27 05:48:46 +0000
53+++ src/Switchboard.vala 2014-07-06 15:55:31 +0000
54@@ -34,6 +34,7 @@
55 private Gtk.Window main_window;
56 private Gtk.Stack stack;
57 private Gtk.HeaderBar headerbar;
58+ private Gtk.Grid header_box;
59
60 private Granite.Widgets.EmbeddedAlert alert_view;
61 private Gtk.ScrolledWindow category_scrolled;
62@@ -50,7 +51,7 @@
63 private int default_width = 0;
64 private int default_height = 0;
65
66- private static string? plug_to_open = null;
67+ private static string? plug_to_open = null;
68 private static bool should_animate_next_transition = true;
69
70 static const OptionEntry[] entries = {
71@@ -124,7 +125,6 @@
72 }
73
74 loaded_plugs = new Gee.LinkedList <string> ();
75- Switchboard.PlugsManager.get_default ();
76 settings = new GLib.Settings ("org.pantheon.switchboard.saved-state");
77 build ();
78 category_view.load_default_plugs.begin ();
79@@ -196,6 +196,8 @@
80 main_window = new Gtk.Window();
81 add_window (main_window);
82
83+ Switchboard.PlugsManager.init (main_window);
84+
85 // Set up defaults
86 main_window.title = program_name;
87 main_window.icon_name = app_icon;
88@@ -259,7 +261,10 @@
89 category_view.recalculate_columns ();
90 });
91
92- if (Switchboard.PlugsManager.get_default ().has_plugs () == false) {
93+ var plug_manager = Switchboard.PlugsManager.get_default ();
94+ plug_manager.embed_widget_requested.connect (embed_widget);
95+
96+ if (plug_manager.has_plugs () == false) {
97 show_alert (_("No settings found"), _("Install some and re-launch Switchboard"), Gtk.MessageType.WARNING);
98 search_box.sensitive = false;
99 } else {
100@@ -269,6 +274,15 @@
101 }
102 }
103
104+ private void embed_widget (Gtk.Widget widget)
105+ {
106+ if (stack.get_visible_child () == category_scrolled)
107+ return;
108+
109+ header_box.remove (search_box);
110+ header_box.add (widget);
111+ }
112+
113 private void shut_down () {
114 if (current_plug != null)
115 current_plug.hidden ();
116@@ -345,11 +359,18 @@
117 stack.set_visible_child (category_scrolled);
118 current_plug.hidden ();
119
120+ // if we were told to embed a widget to the header, we now need to reset it
121+ if (search_box.get_parent () != header_box) {
122+ header_box.remove (header_box.get_children ().data);
123+ header_box.add (search_box);
124+ }
125+
126 // Reset state
127 reset_title ();
128 search_box.set_text ("");
129 search_box.sensitive = Switchboard.PlugsManager.get_default ().has_plugs ();
130
131+
132 return true;
133 }
134
135@@ -370,6 +391,9 @@
136 category_view.filter_plugs(search_box.get_text ());
137 });
138
139+ header_box = new Gtk.Grid ();
140+ header_box.add (search_box);
141+
142 // Focus typing to the search bar
143 main_window.key_press_event.connect ((event) => {
144 // Don't focus if it is a modifier or if search_box is already focused.
145@@ -386,7 +410,7 @@
146
147 // Add everything to the toolbar
148 headerbar.pack_start (navigation_button);
149- headerbar.pack_end (search_box);
150+ headerbar.pack_end (header_box);
151 }
152
153 #if HAVE_UNITY

Subscribers

People subscribed via source and target branches

to all changes: