Move relationship button to header

This commit is contained in:
Bleak Grey 2020-07-01 13:26:32 +03:00
parent 25e4d870e4
commit 34c1de1eb8
6 changed files with 79 additions and 236 deletions

View File

@ -75,9 +75,9 @@
<child>
<object class="TootleWidgetsAccountsButton" id="accounts_button">
<property name="visible">True</property>
<style>
<class name="image-button"/>
</style>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
@ -113,11 +113,27 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRevealer" id="view_controls">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">slide-left</property>
<property name="transition_duration">200</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRevealer" id="view_navigation">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">slide-right</property>
<property name="transition_duration">200</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>

View File

@ -2,102 +2,11 @@
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<object class="GtkPopover" id="filter_popover">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">8</property>
<property name="margin_right">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkRadioButton" id="filter_all">
<property name="label" translatable="yes">Posts</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="filter_replies">
<property name="label" translatable="yes">Posts and Replies</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">filter_all</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="filter_media">
<property name="label" translatable="yes">Media</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">filter_all</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkMenu" id="options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">__glade_unnamed_3</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">__glade_unnamed_8</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">__glade_unnamed_9</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
<object class="GtkGrid" id="grid">
<property name="width_request">400</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">8</property>
<property name="margin_bottom">16</property>
<property name="row_spacing">8</property>
<property name="column_spacing">8</property>
<child>
@ -181,85 +90,6 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="activatable">False</property>
<property name="selectable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">8</property>
<property name="margin_right">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="spacing">8</property>
<child>
<object class="GtkLabel" id="old-relationship">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="actions">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="follow_button">
<property name="label" translatable="yes">Follow</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="options_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="draw_indicator">True</property>
<property name="popup">options</property>
<property name="use_popover">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="horizontal"/>
<class name="linked"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="note_row">
<property name="visible">True</property>
@ -300,4 +130,16 @@
<placeholder/>
</child>
</object>
<object class="GtkButton" id="rs_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkLabel" id="rs_button_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
</object>
</interface>

View File

@ -275,15 +275,16 @@
<property name="draw_indicator">True</property>
<property name="popover">popover</property>
<child>
<object class="GtkStack">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_duration">100</property>
<property name="transition_type">crossfade</property>
<property name="halign">center</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">User</property>
<property name="ellipsize">end</property>
<property name="single_line_mode">True</property>
<attributes>
@ -291,47 +292,21 @@
</attributes>
</object>
<packing>
<property name="name">title</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="spacing">8</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">mail-send-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="title_scrolled">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">1K</property>
<property name="ellipsize">end</property>
<property name="single_line_mode">True</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<property name="icon_name">pan-down-symbolic</property>
</object>
<packing>
<property name="name">title_scrolled</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>

View File

@ -16,6 +16,8 @@ public class Tootle.Dialogs.MainWindow: Gtk.Window, ISavedWindow {
[GtkChild]
protected Revealer view_navigation;
[GtkChild]
protected Revealer view_controls;
[GtkChild]
protected Button back_button;
[GtkChild]
protected Button compose_button;
@ -130,6 +132,18 @@ public class Tootle.Dialogs.MainWindow: Gtk.Window, ISavedWindow {
timeline_stack.visible_child_name = num.to_string ();
}
public void set_header_controls (Widget w) {
reset_header_controls ();
view_controls.add (w);
view_controls.reveal_child = true;
}
public void reset_header_controls () {
view_controls.reveal_child = false;
view_controls.get_children ().@foreach (w => {
view_controls.remove (w);
});
}
bool on_button_press (EventButton ev) {
if (ev.button == 8)
return back ();
@ -147,7 +161,7 @@ public class Tootle.Dialogs.MainWindow: Gtk.Window, ISavedWindow {
void update_header () {
bool primary_mode = get_visible_id () == 0;
switcher_navbar.visible = timeline_switcher.sensitive = primary_mode;
timeline_switcher.opacity = primary_mode ? 1 : 0; //Prevent HeaderBar height jitter
// timeline_switcher.opacity = primary_mode ? 1 : 0; //Prevent HeaderBar height jitter
view_navigation.reveal_child = !primary_mode;
if (primary_mode)

View File

@ -7,12 +7,11 @@ public class Tootle.Views.Profile : Views.Timeline {
ListBox profile_list;
Label relationship;
Box actions;
Button follow_button;
MenuButton options_button;
Widgets.TimelineFilter filter;
Button rs_button;
Label rs_button_label;
public bool exclude_replies { get; set; default = true; }
public bool only_media { get; set; default = false; }
@ -40,16 +39,15 @@ public class Tootle.Views.Profile : Views.Timeline {
return true;
});
var note_row = builder.get_object ("note_row") as ListBoxRow;
var note = builder.get_object ("note") as Widgets.RichLabel;
profile.bind_property ("note", note, "text", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
target.set_string (Html.simplify ((string) src));
var text = Html.simplify ((string) src);
target.set_string (text);
note_row.visible = text != "";
return true;
});
actions = builder.get_object ("actions") as Box;
follow_button = builder.get_object ("follow_button") as Button;
follow_button.clicked.connect (on_follow_button_clicked);
options_button = builder.get_object ("options_button") as MenuButton;
relationship = builder.get_object ("relationship") as Label;
// posts_label = builder.get_object ("posts_label") as Label;
@ -71,6 +69,10 @@ public class Tootle.Views.Profile : Views.Timeline {
// return true;
// });
rs_button = builder.get_object ("rs_button") as Button;
rs_button.clicked.connect (on_rs_button_clicked);
rs_button_label = builder.get_object ("rs_button_label") as Label;
rebuild_fields ();
}
@ -84,20 +86,22 @@ public class Tootle.Views.Profile : Views.Timeline {
public override void on_shown () {
window.header.custom_title = filter;
window.set_header_controls (rs_button);
}
public override void on_hidden () {
window.header.custom_title = null;
window.reset_header_controls ();
}
void on_follow_button_clicked () {
actions.sensitive = false;
void on_rs_button_clicked () {
rs_button.sensitive = false;
profile.set_following (!profile.rs.following);
}
void on_rs_updated () {
var rs = profile.rs;
var label = "";
if (actions.sensitive = rs != null) {
if (rs_button.sensitive = rs != null) {
if (rs.requested)
label = _("Sent follow request");
else if (rs.followed_by && rs.following)
@ -105,22 +109,14 @@ public class Tootle.Views.Profile : Views.Timeline {
else if (rs.followed_by)
label = _("Follows you");
foreach (Widget w in new Widget[] { follow_button, options_button }) {
foreach (Widget w in new Widget[] { rs_button }) {
var ctx = w.get_style_context ();
ctx.remove_class (STYLE_CLASS_SUGGESTED_ACTION);
ctx.remove_class (STYLE_CLASS_DESTRUCTIVE_ACTION);
ctx.add_class (rs.following ? STYLE_CLASS_DESTRUCTIVE_ACTION : STYLE_CLASS_SUGGESTED_ACTION);
}
var label2 = "";
if (rs.followed_by && !rs.following)
label2 = _("Follow back");
else if (rs.following)
label2 = _("Unfollow");
else
label2 = _("Follow");
follow_button.label = label2;
rs_button_label.label = rs.following ? _("Unfollow") : _("Follow");
}
relationship.label = label;
@ -171,7 +167,7 @@ public class Tootle.Views.Profile : Views.Timeline {
if (profile.fields != null) {
foreach (Entity e in profile.fields) {
var w = new Field (e as API.AccountField);
profile_list.insert (w, 2);
profile_list.insert (w, -1);
}
}
}

View File

@ -106,7 +106,7 @@ public class Tootle.Widgets.Status : EventBox {
bind_property ("escaped-spoiler", content, "text", BindingFlags.SYNC_CREATE);
bind_property ("escaped-content", revealer_content, "text", BindingFlags.SYNC_CREATE);
status.formal.account.bind_property ("avatar", avatar, "url", BindingFlags.SYNC_CREATE);
status.account.bind_property ("handle", handle_label, "label", BindingFlags.SYNC_CREATE);
status.formal.account.bind_property ("handle", handle_label, "label", BindingFlags.SYNC_CREATE);
bind_property ("display_name", name_label, "text", BindingFlags.SYNC_CREATE);
bind_property ("date", date_label, "label", BindingFlags.SYNC_CREATE);
status.formal.bind_property ("pinned", pin_indicator, "visible", BindingFlags.SYNC_CREATE);