Skip to content

Commit c86f30d

Browse files
committed
Replacing sidebar stack switcher with a more compact widget.
1 parent e34b071 commit c86f30d

File tree

5 files changed

+55
-26
lines changed

5 files changed

+55
-26
lines changed

data/com.github.phase1geo.minder.gschema.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,5 @@
304304
<summary>When 'default-global-style' is set to a value of 2, the name of the saved global style to use.</summary>
305305
<description>When 'default-global-style' is set to a value of 2, the name of the saved global style to use.</description>
306306
</key>
307-
<key name="compact-sidebar-width" type="b">
308-
<default>false</default>
309-
<summary>Displays the sidebar using vertical tabs to allow the sidebar width to be smaller.</summary>
310-
<description>When set, displays the sidebar with vertical tabs to keep the sidebar width as small as possible;
311-
otherwise, displays the sidebar with horizontal tabs to maximize horizontal space in the sidebar.</description>
312-
</key>
313307
</schema>
314308
</schemalist>

src/MainWindow.vala

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public class MainWindow : Gtk.ApplicationWindow {
7373
private Paned _pane = null;
7474
private Notebook? _inspector_nb = null;
7575
private Stack? _stack = null;
76-
private StackSwitcher? _sidebar_switcher = null;
7776
private Popover? _zoom = null;
7877
private Popover? _search = null;
7978
private MenuButton? _search_btn = null;
@@ -325,7 +324,6 @@ public class MainWindow : Gtk.ApplicationWindow {
325324
case "auto-parse-embedded-urls" : setting_changed_embedded_urls(); break;
326325
case "enable-markdown" : setting_changed_markdown(); break;
327326
case "enable-unicode-input" : setting_changed_unicode_input(); break;
328-
case "compact-sidebar-width" : setting_changed_compact_sidebar(); break;
329327
}
330328
});
331329

@@ -454,13 +452,6 @@ public class MainWindow : Gtk.ApplicationWindow {
454452
}
455453
}
456454

457-
//-------------------------------------------------------------
458-
// Called whenever the compact sidebar width setting is changed.
459-
private void setting_changed_compact_sidebar() {
460-
_sidebar_switcher.orientation = Minder.settings.get_boolean( "compact-sidebar-width" ) ? Orientation.VERTICAL : Orientation.HORIZONTAL;
461-
_pane.position = get_width() - 100;
462-
}
463-
464455
//-------------------------------------------------------------
465456
// Called whenever the current tab is switched in the notebook
466457
private void tab_switched( Widget page, uint page_num ) {
@@ -1238,14 +1229,38 @@ public class MainWindow : Gtk.ApplicationWindow {
12381229
// Handle the enable-ui-animations value
12391230
setting_changed_ui_animations();
12401231

1241-
_sidebar_switcher = new StackSwitcher() {
1242-
orientation = Minder.settings.get_boolean( "compact-sidebar-width" ) ? Orientation.VERTICAL : Orientation.HORIZONTAL,
1243-
halign = Align.FILL,
1244-
stack = _stack
1232+
var sidebar_switcher = new ModeButtons() {
1233+
halign = Align.CENTER
12451234
};
12461235

1236+
sidebar_switcher.add_stack_tab( _( "Current" ) );
1237+
sidebar_switcher.add_stack_tab( _( "Style" ) );
1238+
sidebar_switcher.add_stack_tab( _( "Tags" ) );
1239+
sidebar_switcher.add_stack_tab( _( "Stickers" ) );
1240+
sidebar_switcher.add_stack_tab( _( "Map" ) );
1241+
1242+
sidebar_switcher.changed.connect((index) => {
1243+
switch( index ) {
1244+
case 0 : _stack.visible_child_name = "current"; break;
1245+
case 1 : _stack.visible_child_name = "style"; break;
1246+
case 2 : _stack.visible_child_name = "tag"; break;
1247+
case 3 : _stack.visible_child_name = "sticker"; break;
1248+
case 4 : _stack.visible_child_name = "map"; break;
1249+
}
1250+
});
1251+
1252+
_stack.notify["visible-child-name"].connect(() => {
1253+
switch( _stack.visible_child_name ) {
1254+
case "current" : sidebar_switcher.selected = 0; break;
1255+
case "style" : sidebar_switcher.selected = 1; break;
1256+
case "tag" : sidebar_switcher.selected = 2; break;
1257+
case "sticker" : sidebar_switcher.selected = 3; break;
1258+
case "map" : sidebar_switcher.selected = 4; break;
1259+
}
1260+
});
1261+
12471262
// Make sure that the tabs are displayed nicely
1248-
Utils.set_switcher_tab_widths( _sidebar_switcher );
1263+
Utils.set_switcher_tab_widths( sidebar_switcher );
12491264

12501265
var box = new Box( Orientation.VERTICAL, 20 ) {
12511266
halign = Align.FILL,
@@ -1255,7 +1270,7 @@ public class MainWindow : Gtk.ApplicationWindow {
12551270
margin_top = 5,
12561271
margin_bottom = 5
12571272
};
1258-
box.append( _sidebar_switcher );
1273+
box.append( sidebar_switcher );
12591274
box.append( _stack );
12601275

12611276
_themer = new ThemeEditor( this );

src/ModeButtons.vala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,28 @@ public class ModeButtons : Box {
8787

8888
}
8989

90+
//-------------------------------------------------------------
91+
// Adds a label tab to this ModeButton item.
92+
public void add_stack_tab( string label ) {
93+
94+
var button = new ToggleButton.with_label( label ) {
95+
halign = Align.CENTER
96+
};
97+
98+
button.clicked.connect(() => {
99+
_selected = Utils.get_child_index( this, button );
100+
changed( _selected );
101+
});
102+
103+
var first = get_first_child();
104+
if( first != null ) {
105+
button.set_group( (ToggleButton)first );
106+
} else {
107+
button.active = true;
108+
}
109+
110+
append( button );
111+
112+
}
113+
90114
}

src/Preferences.vala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ public class Preferences : Granite.Dialog {
188188
grid.attach( make_switch( "hide-themes-not-matching-visual-style" ), 1, row );
189189
row++;
190190

191-
grid.attach( make_label( _( "Compact sidebar width" ) ), 0, row );
192-
grid.attach( make_switch( "compact-sidebar-width" ), 1, row );
193-
row++;
194-
195191
grid.attach( make_label( _( "Default theme" ) ), 0, row );
196192
grid.attach( make_themes(), 1, row, 2 );
197193
grid.attach( make_info( _( "Sets the default theme to use for newly created mindmaps (use Map sidebar panel to make immediate changes)." ) ), 3, row );

src/Utils.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public class Utils {
505505
//-------------------------------------------------------------
506506
// Causes the given switcher to adjust tab widths to be the same
507507
// based on the largest tab.
508-
public static void set_switcher_tab_widths( StackSwitcher switcher ) {
508+
public static void set_switcher_tab_widths( Widget switcher ) {
509509

510510
Widget child;
511511
var i = 0;

0 commit comments

Comments
 (0)