Add non-CSD alternative for add chat + join channel

This commit is contained in:
fiaxh 2019-06-06 16:55:50 +02:00
parent 2fb51df8a2
commit 24f525628b
4 changed files with 118 additions and 50 deletions

View file

@ -23,7 +23,7 @@ public class AddConferenceDialog : Gtk.Dialog {
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
public AddConferenceDialog(StreamInteractor stream_interactor) { public AddConferenceDialog(StreamInteractor stream_interactor) {
Object(use_header_bar : 1); Object(use_header_bar : Util.use_csd() ? 1 : 0);
this.title = _("Join Channel"); this.title = _("Join Channel");
this.modal = true; this.modal = true;
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
@ -41,56 +41,65 @@ public class AddConferenceDialog : Gtk.Dialog {
} }
private void show_jid_add_view() { private void show_jid_add_view() {
if (cancel_image.get_parent() != null) cancel_button.remove(cancel_image); // Rewire headerbar (if CSD)
cancel_button.add(cancel_label); if (Util.use_csd()) {
cancel_button.clicked.disconnect(show_jid_add_view); if (cancel_image.get_parent() != null) cancel_button.remove(cancel_image);
cancel_button.clicked.connect(on_cancel); cancel_button.add(cancel_label);
ok_button.label = _("Next"); cancel_button.clicked.disconnect(show_jid_add_view);
ok_button.sensitive = select_fragment.done; cancel_button.clicked.connect(on_cancel);
ok_button.clicked.disconnect(on_ok_button_clicked); ok_button.label = _("Next");
ok_button.clicked.connect(on_next_button_clicked); ok_button.sensitive = select_fragment.done;
details_fragment.notify["done"].disconnect(set_ok_sensitive_from_details); ok_button.clicked.disconnect(on_ok_button_clicked);
select_fragment.notify["done"].connect(set_ok_sensitive_from_select); ok_button.clicked.connect(on_next_button_clicked);
details_fragment.notify["done"].disconnect(set_ok_sensitive_from_details);
select_fragment.notify["done"].connect(set_ok_sensitive_from_select);
}
stack.transition_type = StackTransitionType.SLIDE_RIGHT; stack.transition_type = StackTransitionType.SLIDE_RIGHT;
stack.set_visible_child_name("select"); stack.set_visible_child_name("select");
} }
private void show_conference_details_view() { private void show_conference_details_view() {
if (cancel_label.get_parent() != null) cancel_button.remove(cancel_label); // Rewire headerbar (if CSD)
cancel_button.add(cancel_image); if (Util.use_csd()) {
cancel_button.clicked.disconnect(on_cancel); if (cancel_label.get_parent() != null) cancel_button.remove(cancel_label);
cancel_button.clicked.connect(show_jid_add_view); cancel_button.add(cancel_image);
ok_button.label = _("Join"); cancel_button.clicked.disconnect(on_cancel);
ok_button.sensitive = details_fragment.done; cancel_button.clicked.connect(show_jid_add_view);
ok_button.clicked.disconnect(on_next_button_clicked); ok_button.label = _("Join");
ok_button.clicked.connect(on_ok_button_clicked); ok_button.sensitive = details_fragment.done;
select_fragment.notify["done"].disconnect(set_ok_sensitive_from_select); ok_button.clicked.disconnect(on_next_button_clicked);
details_fragment.notify["done"].connect(set_ok_sensitive_from_details); ok_button.clicked.connect(on_ok_button_clicked);
select_fragment.notify["done"].disconnect(set_ok_sensitive_from_select);
details_fragment.notify["done"].connect(set_ok_sensitive_from_details);
}
stack.transition_type = StackTransitionType.SLIDE_LEFT; stack.transition_type = StackTransitionType.SLIDE_LEFT;
stack.set_visible_child_name("details"); stack.set_visible_child_name("details");
animate_window_resize(); animate_window_resize();
} }
private void setup_headerbar() { private void setup_headerbar() {
HeaderBar header_bar = get_header_bar() as HeaderBar; cancel_button = new Button() { visible=true };
header_bar.show_close_button = false;
cancel_button = new Button(); ok_button = new Button() { can_focus=true, can_default=true, visible=true };
header_bar.pack_start(cancel_button);
cancel_button.visible = true;
ok_button = new Button();
header_bar.pack_end(ok_button);
ok_button.get_style_context().add_class("suggested-action"); ok_button.get_style_context().add_class("suggested-action");
ok_button.visible = true;
ok_button.can_focus = true; if (Util.use_csd()) {
ok_button.can_default = true; HeaderBar header_bar = get_header_bar() as HeaderBar;
ok_button.has_default = true; header_bar.show_close_button = false;
header_bar.pack_start(cancel_button);
header_bar.pack_end(ok_button);
ok_button.has_default = true;
}
} }
private void setup_jid_add_view() { private void setup_jid_add_view() {
conference_list = new ConferenceList(stream_interactor); conference_list = new ConferenceList(stream_interactor);
conference_list.row_activated.connect(() => { ok_button.clicked(); }); conference_list.row_activated.connect(() => { ok_button.clicked(); });
select_fragment = new SelectJidFragment(stream_interactor, conference_list, stream_interactor.get_accounts()); select_fragment = new SelectJidFragment(stream_interactor, conference_list, stream_interactor.get_accounts());
select_fragment.add_jid.connect((row) => { select_fragment.add_jid.connect((row) => {
AddGroupchatDialog dialog = new AddGroupchatDialog(stream_interactor); AddGroupchatDialog dialog = new AddGroupchatDialog(stream_interactor);
@ -101,12 +110,51 @@ public class AddConferenceDialog : Gtk.Dialog {
ConferenceListRow conference_row = row as ConferenceListRow; ConferenceListRow conference_row = row as ConferenceListRow;
stream_interactor.get_module(MucManager.IDENTITY).remove_bookmark(conference_row.account, conference_row.bookmark); stream_interactor.get_module(MucManager.IDENTITY).remove_bookmark(conference_row.account, conference_row.bookmark);
}); });
stack.add_named(select_fragment, "select");
Box wrap_box = new Box(Orientation.VERTICAL, 0) { visible=true };
wrap_box.add(select_fragment);
stack.add_named(wrap_box, "select");
if (!Util.use_csd()) {
Box box = new Box(Orientation.HORIZONTAL, 5) { halign=Align.END, margin_bottom=15, margin_start=80, margin_end=80, visible=true };
Button ok_button = new Button() { label=_("Next"), sensitive=false, halign = Align.END, can_focus=true, can_default=true, visible=true };
ok_button.get_style_context().add_class("suggested-action");
ok_button.clicked.connect(on_next_button_clicked);
select_fragment.notify["done"].connect(() => { ok_button.sensitive = select_fragment.done; });
Button cancel_button = new Button() { label=_("Cancel"), halign=Align.START, visible=true };
cancel_button.clicked.connect(on_cancel);
box.add(cancel_button);
box.add(ok_button);
wrap_box.add(box);
ok_button.has_default = true;
}
} }
private void setup_conference_details_view() { private void setup_conference_details_view() {
details_fragment = new ConferenceDetailsFragment(stream_interactor, ok_button); details_fragment = new ConferenceDetailsFragment(stream_interactor) { ok_button=ok_button };
stack.add_named(details_fragment, "details");
Box wrap_box = new Box(Orientation.VERTICAL, 0) { visible=true };
wrap_box.add(details_fragment);
if (!Util.use_csd()) {
Box box = new Box(Orientation.HORIZONTAL, 5) { halign=Align.END, margin_bottom=15, margin_start=80, margin_end=80, visible=true };
Button ok_button = new Button() { label=_("Join"), halign = Align.END, can_focus=true, can_default=true, visible=true };
ok_button.get_style_context().add_class("suggested-action");
ok_button.clicked.connect(on_ok_button_clicked);
details_fragment.notify["done"].connect(() => { ok_button.sensitive = select_fragment.done; });
details_fragment.ok_button = ok_button;
Button cancel_button = new Button() { label=_("Back"), halign=Align.START, visible=true };
cancel_button.clicked.connect(show_jid_add_view);
box.add(cancel_button);
box.add(ok_button);
wrap_box.add(box);
}
stack.add_named(wrap_box, "details");
} }
private void set_ok_sensitive_from_select() { private void set_ok_sensitive_from_select() {

View file

@ -80,9 +80,21 @@ protected class ConferenceDetailsFragment : Box {
[GtkChild] private Label notification_label; [GtkChild] private Label notification_label;
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
private Button ok_button; private Button ok_button_;
public Button ok_button {
get { return ok_button_; }
set {
if (value != null) {
value.clicked.connect(() => {
ok_button.label = _("Joining…");
ok_button.sensitive = false;
});
ok_button_ = value;
}
}
}
public ConferenceDetailsFragment(StreamInteractor stream_interactor, Button ok_button) { public ConferenceDetailsFragment(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
this.ok_button = ok_button; this.ok_button = ok_button;
@ -104,10 +116,6 @@ protected class ConferenceDetailsFragment : Box {
stream_interactor.get_module(MucManager.IDENTITY).enter_error.connect(on_enter_error); stream_interactor.get_module(MucManager.IDENTITY).enter_error.connect(on_enter_error);
notification_button.clicked.connect(() => { notification_revealer.set_reveal_child(false); }); notification_button.clicked.connect(() => { notification_revealer.set_reveal_child(false); });
ok_button.clicked.connect(() => {
ok_button.label = _("Joining…");
ok_button.sensitive = false;
});
clear(); clear();
} }

View file

@ -19,14 +19,14 @@ public class SelectContactDialog : Gtk.Dialog {
private Gee.List<Account> accounts; private Gee.List<Account> accounts;
public SelectContactDialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) { public SelectContactDialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
Object(use_header_bar : 1); Object(use_header_bar : Util.use_csd() ? 1 : 0);
modal = true; modal = true;
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
this.accounts = accounts; this.accounts = accounts;
setup_headerbar();
setup_view(); setup_view();
setup_headerbar();
} }
public void set_filter(string str) { public void set_filter(string str) {
@ -34,19 +34,31 @@ public class SelectContactDialog : Gtk.Dialog {
} }
private void setup_headerbar() { private void setup_headerbar() {
HeaderBar header_bar = get_header_bar() as HeaderBar;
header_bar.show_close_button = false;
Button cancel_button = new Button(); Button cancel_button = new Button();
cancel_button.set_label(_("Cancel")); cancel_button.set_label(_("Cancel"));
cancel_button.visible = true; cancel_button.visible = true;
header_bar.pack_start(cancel_button);
ok_button = new Button(); ok_button = new Button();
ok_button.get_style_context().add_class("suggested-action"); ok_button.get_style_context().add_class("suggested-action");
ok_button.sensitive = false; ok_button.sensitive = false;
ok_button.visible = true; ok_button.visible = true;
header_bar.pack_end(ok_button);
if (Util.use_csd()) {
HeaderBar header_bar = get_header_bar() as HeaderBar;
header_bar.show_close_button = false;
header_bar.pack_start(cancel_button);
header_bar.pack_end(ok_button);
} else {
Box box = new Box(Orientation.HORIZONTAL, 5) { halign=Align.END, margin_bottom=15, margin_start=80, margin_end=80, visible=true };
cancel_button.halign = Align.START;
ok_button.halign = Align.END;
box.add(cancel_button);
box.add(ok_button);
get_content_area().add(box);
}
cancel_button.clicked.connect(() => { close(); }); cancel_button.clicked.connect(() => { close(); });
ok_button.clicked.connect(() => { ok_button.clicked.connect(() => {

View file

@ -48,7 +48,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
dialog.modal = true; dialog.modal = true;
Button ok_button = dialog.get_widget_for_response(ResponseType.OK) as Button; Button ok_button = dialog.get_widget_for_response(ResponseType.OK) as Button;
ok_button.get_style_context().add_class("suggested-action"); ok_button.get_style_context().add_class("suggested-action");
ConferenceDetailsFragment conference_fragment = new ConferenceDetailsFragment(stream_interactor, ok_button); ConferenceDetailsFragment conference_fragment = new ConferenceDetailsFragment(stream_interactor) { ok_button=ok_button };
conference_fragment.jid = jid; conference_fragment.jid = jid;
Box content_area = dialog.get_content_area(); Box content_area = dialog.get_content_area();
content_area.add(conference_fragment); content_area.add(conference_fragment);