@@ -27,7 +27,9 @@ public class Sequeler.Layouts.DataBaseView : Gtk.Grid {
27
27
public Sequeler . Layouts . Views . Structure structure;
28
28
public Sequeler . Layouts . Views . Content content;
29
29
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;
31
33
32
34
public Gtk . MenuButton font_style;
33
35
@@ -98,7 +100,9 @@ public class Sequeler.Layouts.DataBaseView : Gtk.Grid {
98
100
zoom_out_button. action_name = Sequeler . Services . ActionManager . ACTION_PREFIX + Sequeler . Services . ActionManager . ACTION_ZOOM_OUT ;
99
101
zoom_out_button. tooltip_markup = Granite . markup_accel_tooltip ({" <Control>minus" }, _(" Zoom Out" ));
100
102
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
+ );
102
106
zoom_default_button. action_name = Sequeler . Services . ActionManager . ACTION_PREFIX + Sequeler . Services . ActionManager . ACTION_ZOOM_DEFAULT ;
103
107
zoom_default_button. tooltip_markup = Granite . markup_accel_tooltip ({" <Control>0" }, _(" Zoom 1:1" ));
104
108
@@ -164,17 +168,13 @@ public class Sequeler.Layouts.DataBaseView : Gtk.Grid {
164
168
165
169
view_options. add (font_style);
166
170
167
- // Content View buttons
168
- // Structure View buttons
169
- // Relations View buttons
170
-
171
171
toolbar. attach (view_options, 1 , 0 , 1 , 1 );
172
172
173
173
stack = new Gtk .Stack ();
174
174
structure = new Sequeler .Layouts .Views .Structure (window);
175
175
content = new Sequeler .Layouts .Views .Content (window);
176
176
relations = new Sequeler .Layouts .Views .Relations (window);
177
- query = new Sequeler . Layouts . Views . Query (window );
177
+ query = get_query_notebook ( );
178
178
179
179
stack. add_named (structure, " Structure" );
180
180
stack. add_named (content, " Content" );
@@ -203,17 +203,71 @@ public class Sequeler.Layouts.DataBaseView : Gtk.Grid {
203
203
204
204
color_button_dark. clicked. connect (() = > {
205
205
Sequeler . settings. style_scheme = " solarized-dark" ;
206
- query. update_color_style ();
206
+ ( query. current . page as Layouts . Views . Query ) . update_color_style ();
207
207
});
208
208
209
209
color_button_light. clicked. connect (() = > {
210
210
Sequeler . settings. style_scheme = " solarized-light" ;
211
- query. update_color_style ();
211
+ ( query. current . page as Layouts . Views . Query ) . update_color_style ();
212
212
});
213
213
214
214
color_button_white. clicked. connect (() = > {
215
215
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;
217
234
});
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;
218
272
}
219
273
}
0 commit comments