@@ -27,7 +27,9 @@ public class Sequeler.Layouts.DataBaseView : Gtk.Grid {
2727 public Sequeler . Layouts . Views . Structure structure;
2828 public Sequeler . Layouts . Views . Content content;
2929 public Sequeler . Layouts . Views . Relations relations;
30- public Sequeler . Layouts . Views . Query query;
30+ public Granite . Widgets . DynamicNotebook query;
31+
32+ private Sequeler . Layouts . Views . Query tab_to_restore;
3133
3234 public Gtk . MenuButton font_style;
3335
@@ -98,7 +100,9 @@ public class Sequeler.Layouts.DataBaseView : Gtk.Grid {
98100 zoom_out_button. action_name = Sequeler . Services . ActionManager . ACTION_PREFIX + Sequeler . Services . ActionManager . ACTION_ZOOM_OUT ;
99101 zoom_out_button. tooltip_markup = Granite . markup_accel_tooltip ({" <Control>minus" }, _(" Zoom Out" ));
100102
101- var zoom_default_button = new Gtk .Button .with_label (" 100%" );
103+ var zoom_default_button = new Gtk .Button .with_label (
104+ " %.0f %%" . printf (window. action_manager. get_current_font_size () * 10 )
105+ );
102106 zoom_default_button. action_name = Sequeler . Services . ActionManager . ACTION_PREFIX + Sequeler . Services . ActionManager . ACTION_ZOOM_DEFAULT ;
103107 zoom_default_button. tooltip_markup = Granite . markup_accel_tooltip ({" <Control>0" }, _(" Zoom 1:1" ));
104108
@@ -164,17 +168,13 @@ public class Sequeler.Layouts.DataBaseView : Gtk.Grid {
164168
165169 view_options. add (font_style);
166170
167- // Content View buttons
168- // Structure View buttons
169- // Relations View buttons
170-
171171 toolbar. attach (view_options, 1 , 0 , 1 , 1 );
172172
173173 stack = new Gtk .Stack ();
174174 structure = new Sequeler .Layouts .Views .Structure (window);
175175 content = new Sequeler .Layouts .Views .Content (window);
176176 relations = new Sequeler .Layouts .Views .Relations (window);
177- query = new Sequeler . Layouts . Views . Query (window );
177+ query = get_query_notebook ( );
178178
179179 stack. add_named (structure, " Structure" );
180180 stack. add_named (content, " Content" );
@@ -203,17 +203,71 @@ public class Sequeler.Layouts.DataBaseView : Gtk.Grid {
203203
204204 color_button_dark. clicked. connect (() = > {
205205 Sequeler . settings. style_scheme = " solarized-dark" ;
206- query. update_color_style ();
206+ ( query. current . page as Layouts . Views . Query ) . update_color_style ();
207207 });
208208
209209 color_button_light. clicked. connect (() = > {
210210 Sequeler . settings. style_scheme = " solarized-light" ;
211- query. update_color_style ();
211+ ( query. current . page as Layouts . Views . Query ) . update_color_style ();
212212 });
213213
214214 color_button_white. clicked. connect (() = > {
215215 Sequeler . settings. style_scheme = " classic" ;
216- query. update_color_style ();
216+ (query. current. page as Layouts . Views . Query ). update_color_style ();
217+ });
218+ }
219+
220+ private Granite .Widgets .DynamicNotebook get_query_notebook () {
221+ var notebook = new Granite .Widgets .DynamicNotebook ();
222+ notebook. add_button_tooltip = _(" Create a new Query Tab" );
223+ notebook. expand = true ;
224+ notebook. allow_restoring = true ;
225+ notebook. max_restorable_tabs = 1 ;
226+
227+ var first_page = new Sequeler .Layouts .Views .Query (window);
228+ var first_tab = new Granite .Widgets .Tab (
229+ _(" Query" ), new ThemedIcon (" user-offline" ), first_page
230+ );
231+ first_page. update_tab_indicator. connect ((status) = > {
232+ var icon = status ? new ThemedIcon (" user-available" ) : new ThemedIcon (" dialog-error" );
233+ first_tab. icon = icon;
217234 });
235+ notebook. insert_tab (first_tab, 0 );
236+
237+ notebook. new_tab_requested. connect (() = > {
238+ var new_page = new Sequeler .Layouts .Views .Query (window);
239+ var new_tab = new Granite .Widgets .Tab (
240+ _(" Query %i " ). printf (notebook. n_tabs), new ThemedIcon (" user-offline" ), new_page
241+ );
242+ new_page. update_tab_indicator. connect ((status) = > {
243+ var icon = status ? new ThemedIcon (" user-available" ) : new ThemedIcon (" dialog-error" );
244+ new_tab. icon = icon;
245+ });
246+ notebook. insert_tab (new_tab, notebook. n_tabs - 1 );
247+ });
248+
249+ notebook. close_tab_requested. connect ((tab) = > {
250+ if (notebook. n_tabs == 1 ) {
251+ var new_page = new Sequeler .Layouts .Views .Query (window);
252+ var new_tab = new Granite .Widgets .Tab (
253+ _(" Query" ), new ThemedIcon (" user-offline" ), new_page
254+ );
255+ notebook. insert_tab (new_tab, notebook. n_tabs - 1 );
256+ }
257+ tab_to_restore = tab. page as Sequeler . Layouts . Views . Query ;
258+ tab. restore_data = tab. label;
259+ return true ;
260+ });
261+
262+ notebook. tab_restored. connect ((label, data, icon) = > {
263+ var tab = new Granite .Widgets .Tab (label, icon, tab_to_restore);
264+ tab_to_restore. update_tab_indicator. connect ((status) = > {
265+ var update_icon = status ? new ThemedIcon (" user-available" ) : new ThemedIcon (" dialog-error" );
266+ tab. icon = update_icon;
267+ });
268+ notebook. insert_tab (tab, notebook. n_tabs - 1 );
269+ });
270+
271+ return notebook;
218272 }
219273}
0 commit comments