Skip to content

Commit

Permalink
Better block button horizontal space usage
Browse files Browse the repository at this point in the history
	- the block domain option is in a drop down of the block button
	- when blocking the domain, the "Blocked domain" button appears
	  and block button disappears and vice versa.
  • Loading branch information
eerielili committed Jun 21, 2024
1 parent 51fe91d commit 625465b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
23 changes: 12 additions & 11 deletions main/data/conversation_details.ui
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
</object>
</child>
<child>
<object class="GtkButton" id="block_button">
<object class="AdwSplitButton" id="block_button">
<property name="menu_model">block_menu_model</property>
<property name="visible" bind-source="model" bind-property="show-blocked" bind-flags="sync-create"/>
<child>
<object class="AdwButtonContent" id="block_button_content">
Expand All @@ -132,26 +133,18 @@
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">13</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="GtkButton" id="block_domain_button">
<property name="visible" bind-source="model" bind-property="show-blocked" bind-flags="sync-create"/>
<child>
<object class="AdwButtonContent" id="block_domain_button_content">
<property name="icon-name">action-unavailable-symbolic</property>
<property name="label">Block domain</property>
<property name="label">Domain blocked</property>
</object>
</child>
</object>
</child>
</object>
</object>
</child>
</object>
</child>
Expand Down Expand Up @@ -222,4 +215,12 @@
</item>
</section>
</menu>
<menu id="block_menu_model">
<section>
<item>
<attribute name="label">Block domain</attribute>
<attribute name="action">domain.on</attribute>
</item>
</section>
</menu>
</interface>
13 changes: 8 additions & 5 deletions main/src/windows/conversation_details.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Dino.Ui.ConversationDetails {
[GtkChild] public unowned Box about_box;
[GtkChild] public unowned Button pin_button;
[GtkChild] public unowned Adw.ButtonContent pin_button_content;
[GtkChild] public unowned Button block_button;
[GtkChild] public unowned Adw.SplitButton block_button;
[GtkChild] public unowned Adw.ButtonContent block_button_content;
[GtkChild] public unowned Button block_domain_button;
[GtkChild] public unowned Adw.ButtonContent block_domain_button_content;
Expand All @@ -29,6 +29,7 @@ namespace Dino.Ui.ConversationDetails {
install_action("notification.off", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.OFF); } );
install_action("notification.highlight", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.HIGHLIGHT); } );
install_action("notification.default", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.DEFAULT); } );
install_action("domain.on", null, (widget, action_name) => { ((Dialog) widget).model.domain_block_changed(); } );
}

construct {
Expand Down Expand Up @@ -71,19 +72,21 @@ namespace Dino.Ui.ConversationDetails {
block_button_content.icon_name = "dino-block-symbolic";
block_domain_button_content.icon_name = block_button_content.icon_name;
block_button_content.label = model.blocked ? _("Blocked") : _("Block");
block_domain_button_content.label = model.domain_blocked ? _("Domain blocked") : _("Block domain");
block_domain_button.visible = false;
if (model.blocked) {
block_button.visible = true;
block_domain_button.visible = false;
block_button.add_css_class("error");
} else {
block_button.remove_css_class("error");
}

if (model.domain_blocked) {
block_domain_button.visible = true;
block_button.visible = false;
block_domain_button.add_css_class("error");
block_button.set_sensitive(false);
} else {
block_domain_button.remove_css_class("error");
block_button.set_sensitive(true);
block_button.visible = true;
}
}

Expand Down

0 comments on commit 625465b

Please sign in to comment.