Add secondary stack to main window
This commit is contained in:
parent
5785a5d06f
commit
0b697a1b6e
|
@ -3,11 +3,13 @@ using Gtk;
|
||||||
public class Tootle.MainWindow: Gtk.Window {
|
public class Tootle.MainWindow: Gtk.Window {
|
||||||
|
|
||||||
HeaderBar header;
|
HeaderBar header;
|
||||||
Stack stack;
|
Stack primary_stack;
|
||||||
|
Stack secondary_stack;
|
||||||
AccountsButton accounts;
|
AccountsButton accounts;
|
||||||
Granite.Widgets.ModeButton mode;
|
Granite.Widgets.ModeButton button_mode;
|
||||||
Spinner spinner;
|
Spinner spinner;
|
||||||
Button button_toot;
|
Button button_toot;
|
||||||
|
Button button_back;
|
||||||
|
|
||||||
public HomeView home = new HomeView ();
|
public HomeView home = new HomeView ();
|
||||||
public LocalView feed_local = new LocalView ();
|
public LocalView feed_local = new LocalView ();
|
||||||
|
@ -31,16 +33,23 @@ public class Tootle.MainWindow: Gtk.Window {
|
||||||
provider.load_from_resource ("/com/github/bleakgrey/tootle/Application.css");
|
provider.load_from_resource ("/com/github/bleakgrey/tootle/Application.css");
|
||||||
StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
stack = new Stack();
|
secondary_stack = new Stack();
|
||||||
stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
|
secondary_stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
|
||||||
stack.show ();
|
secondary_stack.show ();
|
||||||
stack.set_size_request (400, 500);
|
secondary_stack.set_size_request (400, 500);
|
||||||
|
primary_stack = new Stack();
|
||||||
|
primary_stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
|
||||||
|
primary_stack.show ();
|
||||||
|
primary_stack.add_named (secondary_stack, "modes");
|
||||||
|
|
||||||
spinner = new Spinner ();
|
spinner = new Spinner ();
|
||||||
spinner.active = true;
|
spinner.active = true;
|
||||||
|
|
||||||
accounts = new AccountsButton ();
|
accounts = new AccountsButton ();
|
||||||
|
|
||||||
|
button_back = new Button ();
|
||||||
|
button_back.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON);
|
||||||
|
|
||||||
button_toot = new Button ();
|
button_toot = new Button ();
|
||||||
button_toot.tooltip_text = "Toot";
|
button_toot.tooltip_text = "Toot";
|
||||||
button_toot.image = new Gtk.Image.from_icon_name ("edit-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
|
button_toot.image = new Gtk.Image.from_icon_name ("edit-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
|
||||||
|
@ -48,24 +57,23 @@ public class Tootle.MainWindow: Gtk.Window {
|
||||||
TootDialog.open (this);
|
TootDialog.open (this);
|
||||||
});
|
});
|
||||||
|
|
||||||
mode = new Granite.Widgets.ModeButton ();
|
button_mode = new Granite.Widgets.ModeButton ();
|
||||||
mode.get_style_context ().add_class ("mode");
|
button_mode.get_style_context ().add_class ("mode");
|
||||||
mode.mode_changed.connect(widget => {
|
button_mode.mode_changed.connect(widget => {
|
||||||
stack.set_visible_child_name(widget.tooltip_text);
|
secondary_stack.set_visible_child_name(widget.tooltip_text);
|
||||||
});
|
});
|
||||||
|
|
||||||
header = new HeaderBar ();
|
header = new HeaderBar ();
|
||||||
|
header.custom_title = button_mode;
|
||||||
header.show_close_button = true;
|
header.show_close_button = true;
|
||||||
|
//header.pack_start (button_back);
|
||||||
header.pack_start (button_toot);
|
header.pack_start (button_toot);
|
||||||
header.custom_title = mode;
|
|
||||||
|
|
||||||
header.pack_end (accounts);
|
header.pack_end (accounts);
|
||||||
header.pack_end (spinner);
|
header.pack_end (spinner);
|
||||||
|
button_mode.valign = Gtk.Align.FILL;
|
||||||
header.show ();
|
header.show ();
|
||||||
|
|
||||||
mode.valign = Gtk.Align.FILL;
|
|
||||||
|
|
||||||
add (stack);
|
add (primary_stack);
|
||||||
show_all ();
|
show_all ();
|
||||||
|
|
||||||
NetManager.instance.started.connect (() => spinner.show ());
|
NetManager.instance.started.connect (() => spinner.show ());
|
||||||
|
@ -73,10 +81,10 @@ public class Tootle.MainWindow: Gtk.Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_account_changed(Account? account){
|
private void on_account_changed(Account? account){
|
||||||
mode.hide ();
|
button_mode.hide ();
|
||||||
button_toot.hide ();
|
button_toot.hide ();
|
||||||
accounts.hide ();
|
accounts.hide ();
|
||||||
stack.forall (widget => stack.remove (widget));
|
secondary_stack.forall (widget => secondary_stack.remove (widget));
|
||||||
|
|
||||||
if(account == null)
|
if(account == null)
|
||||||
show_setup_views ();
|
show_setup_views ();
|
||||||
|
@ -86,17 +94,17 @@ public class Tootle.MainWindow: Gtk.Window {
|
||||||
|
|
||||||
private void show_setup_views (){
|
private void show_setup_views (){
|
||||||
var add_account = new AddAccountView ();
|
var add_account = new AddAccountView ();
|
||||||
stack.add_named (add_account, add_account.get_name ());
|
secondary_stack.add_named (add_account, add_account.get_name ());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_main_views (){
|
private void show_main_views (){
|
||||||
mode.clear_children ();
|
button_mode.clear_children ();
|
||||||
add_view (home);
|
add_view (home);
|
||||||
add_view (notifications);
|
add_view (notifications);
|
||||||
add_view (feed_local);
|
add_view (feed_local);
|
||||||
add_view (feed_federated);
|
add_view (feed_federated);
|
||||||
mode.set_active (0);
|
button_mode.set_active (0);
|
||||||
mode.show ();
|
button_mode.show ();
|
||||||
button_toot.show ();
|
button_toot.show ();
|
||||||
accounts.show ();
|
accounts.show ();
|
||||||
}
|
}
|
||||||
|
@ -105,10 +113,9 @@ public class Tootle.MainWindow: Gtk.Window {
|
||||||
if (view.show_in_header){
|
if (view.show_in_header){
|
||||||
var img = new Gtk.Image.from_icon_name(view.get_icon (), Gtk.IconSize.LARGE_TOOLBAR);
|
var img = new Gtk.Image.from_icon_name(view.get_icon (), Gtk.IconSize.LARGE_TOOLBAR);
|
||||||
img.tooltip_text = view.get_name ();
|
img.tooltip_text = view.get_name ();
|
||||||
mode.append (img);
|
button_mode.append (img);
|
||||||
view.image = img;
|
view.image = img;
|
||||||
|
secondary_stack.add_named(view, view.get_name ());
|
||||||
stack.add_named(view, view.get_name ());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,9 @@ public class Tootle.HomeView : Tootle.AbstractView {
|
||||||
var widget = new StatusWidget(status);
|
var widget = new StatusWidget(status);
|
||||||
widget.separator = separator;
|
widget.separator = separator;
|
||||||
widget.rebind (status);
|
widget.rebind (status);
|
||||||
|
widget.button_press_event.connect(() => {
|
||||||
|
//TODO: status page
|
||||||
|
});
|
||||||
view.pack_start(separator, false, false, 0);
|
view.pack_start(separator, false, false, 0);
|
||||||
view.pack_start(widget, false, false, 0);
|
view.pack_start(widget, false, false, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue