Add operational icon and set as add remote for Remotes

This commit is contained in:
Alberto Fanjul 2023-12-19 00:24:14 +01:00
parent 7771b69c49
commit 348d6a283e
2 changed files with 42 additions and 2 deletions

View file

@ -446,6 +446,12 @@ public class RefHeader : RefTyped, Gtk.ListBoxRow
[GtkChild( name = "icon" )]
private unowned Gtk.Image d_icon;
[GtkChild( name = "op_icon" )]
private unowned Gtk.Image d_op_icon;
[GtkChild( name = "event_box_op_icon" )]
private unowned Gtk.EventBox d_event_box_op_icon;
public bool expanded { get; set; default = true; }
public Gitg.RefType ref_type
@ -517,6 +523,24 @@ public class RefHeader : RefTyped, Gtk.ListBoxRow
d_icon.visible = (value != null);
}
}
public string? op_icon_name
{
owned get { return d_op_icon.icon_name; }
set
{
d_op_icon.icon_name = value;
d_op_icon.visible = (value != null);
}
}
public void set_op_icon_action(GitgExt.Action action)
{
d_event_box_op_icon.button_press_event.connect(() => {
action.activate();
return true;
});
}
}
public class RefsList : Gtk.ListBox
@ -892,6 +916,10 @@ public class RefsList : Gtk.ListBox
{
var header = new RefHeader(ref_type, name);
init_header(header);
if (header.ref_type == Gitg.RefType.REMOTE && !header.is_sub_header_remote) {
header.op_icon_name = "list-add-symbolic";
header.set_op_icon_action(new Gitg.AddRemoteAction(application));
}
header.actions = actions;
add(header);

View file

@ -2,7 +2,6 @@
<interface>
<!-- interface-requires gtk+ 3.3 -->
<!-- interface-requires gitg 0.0 -->
<!-- interface-requires gd 1.0 -->
<template class="GitgHistoryRefHeader" parent="GtkListBoxRow">
<property name="visible">True</property>
<style>
@ -29,7 +28,20 @@
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="hexpand">False</property>
</object>
</child>
<child>
<object class="GtkEventBox" id="event_box_op_icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="op_icon">
<property name="visible">False</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
</object>
</child>
</object>
</child>
<child>