|
15 | 15 |
|
16 | 16 | private Adw.TimedAnimation resize_animation; |
17 | 17 | private List<Launcher> launchers; // Only used to keep track of launcher indices |
| 18 | + private List<IconGroup> icon_groups; // Only used to keep track of icon group indices |
| 19 | + private DynamicWorkspaceIcon dynamic_workspace_item; |
18 | 20 |
|
19 | 21 | static construct { |
20 | 22 | settings = new Settings ("io.elementary.dock"); |
21 | 23 | } |
22 | 24 |
|
23 | 25 | construct { |
24 | 26 | launchers = new List<Launcher> (); |
| 27 | + icon_groups = new List<IconGroup> (); |
| 28 | + |
| 29 | + // Idle is used here to because DynamicWorkspaceIcon depends on ItemManager |
| 30 | + Idle.add_once (() => { |
| 31 | + dynamic_workspace_item = new DynamicWorkspaceIcon (); |
| 32 | + add_item (dynamic_workspace_item); |
| 33 | + }); |
25 | 34 |
|
26 | 35 | overflow = VISIBLE; |
27 | 36 |
|
|
110 | 119 | add_item (launcher); |
111 | 120 | }); |
112 | 121 |
|
113 | | - map.connect (AppSystem.get_default ().load); |
| 122 | + WorkspaceSystem.get_default ().workspace_added.connect ((workspace) => { |
| 123 | + add_item (new IconGroup (workspace)); |
| 124 | + }); |
| 125 | + |
| 126 | + map.connect (() => { |
| 127 | + AppSystem.get_default ().load.begin (); |
| 128 | + WorkspaceSystem.get_default ().load.begin (); |
| 129 | + }); |
114 | 130 | } |
115 | 131 |
|
116 | 132 | private void reposition_items () { |
117 | | - var launcher_size = get_launcher_size (); |
118 | | - |
119 | 133 | int index = 0; |
120 | 134 | foreach (var launcher in launchers) { |
121 | | - var position = index * launcher_size; |
| 135 | + position_item (launcher, ref index); |
| 136 | + } |
122 | 137 |
|
123 | | - if (launcher.parent != this) { |
124 | | - put (launcher, position, 0); |
125 | | - launcher.current_pos = position; |
126 | | - } else { |
127 | | - launcher.animate_move (position); |
128 | | - } |
| 138 | + foreach (var icon_group in icon_groups) { |
| 139 | + position_item (icon_group, ref index); |
| 140 | + } |
| 141 | + |
| 142 | + position_item (dynamic_workspace_item, ref index); |
| 143 | + } |
| 144 | + |
| 145 | + private void position_item (BaseItem item, ref int index) { |
| 146 | + var position = get_launcher_size () * index; |
129 | 147 |
|
130 | | - index++; |
| 148 | + if (item.parent != this) { |
| 149 | + put (item, position, 0); |
| 150 | + item.current_pos = position; |
| 151 | + } else { |
| 152 | + item.animate_move (position); |
131 | 153 | } |
| 154 | + |
| 155 | + index++; |
132 | 156 | } |
133 | 157 |
|
134 | 158 | private void add_launcher_via_dnd (Launcher launcher, int index) { |
|
144 | 168 |
|
145 | 169 | if (item is Launcher) { |
146 | 170 | launchers.append ((Launcher) item); |
| 171 | + } else if (item is IconGroup) { |
| 172 | + icon_groups.append ((IconGroup) item); |
147 | 173 | } |
148 | 174 |
|
149 | 175 | resize_animation.easing = EASE_OUT_BACK; |
|
163 | 189 | private void remove_item (BaseItem item) { |
164 | 190 | if (item is Launcher) { |
165 | 191 | launchers.remove ((Launcher) item); |
| 192 | + } else if (item is IconGroup) { |
| 193 | + icon_groups.remove ((IconGroup) item); |
166 | 194 | } |
167 | 195 |
|
168 | 196 | item.set_revealed (false); |
|
0 commit comments