Skip to content

Commit

Permalink
MessageListItem: GTK4 prep (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Dec 4, 2024
1 parent 29da72f commit 3bb6095
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/MessageList/MessageListItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
small_fields_grid.attach (small_from_label, 0, 0, 1, 1);

header_stack = new Gtk.Stack () {
homogeneous = false,
hhomogeneous = false,
vhomogeneous = false,
transition_type = CROSSFADE
};
header_stack.add_named (fields_grid, "large");
Expand Down Expand Up @@ -290,12 +291,12 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
margin_bottom = 12,
margin_start = 12,
margin_end = 12,
message_type = WARNING
message_type = WARNING,
revealed = false
};
blocked_images_infobar.add_button (_("Show Images"), 1);
blocked_images_infobar.add_button (_("Always Show from Sender"), 2);
blocked_images_infobar.get_style_context ().add_class (Gtk.STYLE_CLASS_FRAME);
blocked_images_infobar.no_show_all = true;

var infobar_content = blocked_images_infobar.get_content_area ();
infobar_content.add (new Gtk.Label (_("This message contains remote images.")));
Expand Down Expand Up @@ -323,9 +324,9 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
secondary_box.add (web_view);

secondary_revealer = new Gtk.Revealer () {
child = secondary_box,
transition_type = SLIDE_UP
};
secondary_revealer.add (secondary_box);

var base_box = new Gtk.Box (VERTICAL, 0) {
hexpand = true,
Expand All @@ -349,7 +350,7 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
secondary_box.add (attachment_bar);
}

add (base_box);
child = base_box;
expanded = false;
show_all ();

Expand All @@ -360,13 +361,6 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
});
}

/* Override default handler to stop event propagation. Otherwise clicking the menu will
expand or collapse the MessageListItem. */
actions_menu_button.button_release_event.connect ((event) => {
actions_menu_button.set_active (true);
return Gdk.EVENT_STOP;
});

header_event_box.enter_notify_event.connect ((event) => {
if (event.detail != Gdk.NotifyType.INFERIOR) {
var window = header_event_box.get_window ();
Expand All @@ -381,17 +375,18 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
}
});

header_event_box.button_release_event.connect ((event) => {
var click_gesture = new Gtk.GestureMultiPress (header_event_box);

click_gesture.released.connect (() => {
expanded = !expanded;
return Gdk.EVENT_STOP;
click_gesture.set_state (CLAIMED);
});

destroy.connect (() => {
loading_cancellable.cancel ();
});

/* Connecting to clicked () doesn't allow us to prevent the event from propagating to header_event_box */
starred_button.button_release_event.connect (() => {
starred_button.clicked.connect (() => {
if (Camel.MessageFlags.FLAGGED in (int) message_info.flags) {
message_info.set_flags (Camel.MessageFlags.FLAGGED, 0);
starred_icon.icon_name = "non-starred-symbolic";
Expand All @@ -401,12 +396,10 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
starred_icon.icon_name = "starred-symbolic";
starred_icon.tooltip_text = _("Unstar message");
}

return Gdk.EVENT_STOP;
});

web_view.image_load_blocked.connect (() => {
blocked_images_infobar.show ();
blocked_images_infobar.revealed = true;
});
web_view.link_activated.connect ((uri) => {
try {
Expand Down Expand Up @@ -550,7 +543,7 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
}

web_view.load_images ();
blocked_images_infobar.destroy ();
blocked_images_infobar.revealed = false;
});
}

Expand Down

0 comments on commit 3bb6095

Please sign in to comment.