2020public class Calendar.Widgets.SourcePopover : Gtk .Popover {
2121 private GLib . HashTable<string, SourceRow ?> src_map;
2222
23- private Gtk . Stack stack;
2423 private Maya . View . SourceDialog src_dialog = null ;
2524
2625 private Gtk . Grid main_grid;
@@ -68,6 +67,7 @@ public class Calendar.Widgets.SourcePopover : Gtk.Popover {
6867 };
6968
7069 main_grid = new Gtk .Grid () {
70+ margin_bottom = 3 ,
7171 orientation = Gtk . Orientation . VERTICAL
7272 };
7373
@@ -76,18 +76,13 @@ public class Calendar.Widgets.SourcePopover : Gtk.Popover {
7676 main_grid.add (add_calendar_button );
7777 main_grid.add (import_calendar_button );
7878 main_grid.add (accounts_button );
79+ main_grid.show_all ();
7980
80- stack = new Gtk .Stack () {
81- margin_bottom = 3
82- };
83- stack.add_named (main_grid , "main ");
84-
85- add (stack );
81+ add (main_grid );
8682 populate.begin ();
87- stack.show_all ();
8883
8984 add_calendar_button.button_release_event.connect (() => {
90- create_source ();
85+ edit_source ();
9186 return Gdk . EVENT_STOP ;
9287 });
9388
@@ -181,17 +176,6 @@ public class Calendar.Widgets.SourcePopover : Gtk.Popover {
181176 source_item. source_has_changed ();
182177 }
183178
184- private void create_source () {
185- if (src_dialog == null ) {
186- src_dialog = new Maya .View .SourceDialog ();
187- src_dialog. go_back. connect (() = > {switch_to_main ();});
188- stack. add_named (src_dialog, " source" );
189- }
190-
191- src_dialog. set_source (null );
192- switch_to_source ();
193- }
194-
195179 private void add_source_to_view (E .Source source ) {
196180 if (source. enabled == false )
197181 return ;
@@ -234,30 +218,20 @@ public class Calendar.Widgets.SourcePopover : Gtk.Popover {
234218 source_item. show_calendar_removed ();
235219 }
236220
237- private void edit_source (E .Source source ) {
221+ private void edit_source (E .Source ? source = null ) {
238222 if (src_dialog == null ) {
239- src_dialog = new Maya .View .SourceDialog ();
240- src_dialog. go_back. connect (() = > {switch_to_main ();});
241- stack. add_named (src_dialog, " source" );
223+ src_dialog = new Maya .View .SourceDialog () {
224+ modal = true ,
225+ transient_for = ((Gtk . Application ) GLib . Application . get_default ()). active_window
226+ };
227+
228+ src_dialog. go_back. connect (() = > {
229+ src_dialog. hide ();
230+ });
242231 }
243232
233+ popdown ();
244234 src_dialog. set_source (source);
245- switch_to_source ();
246- }
247-
248- private void switch_to_main () {
249- main_grid. no_show_all = false ;
250- main_grid. show ();
251- stack. set_visible_child_full (" main" , Gtk . StackTransitionType . SLIDE_RIGHT );
252- src_dialog. hide ();
253- src_dialog. no_show_all = true ;
254- }
255-
256- private void switch_to_source () {
257- src_dialog. no_show_all = false ;
258- src_dialog. show ();
259- stack. set_visible_child_full (" source" , Gtk . StackTransitionType . SLIDE_LEFT );
260- main_grid. hide ();
261- main_grid. no_show_all = true ;
235+ src_dialog. present ();
262236 }
263237}
0 commit comments