Skip to content

Commit

Permalink
fix #1280
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed May 18, 2024
1 parent e79a77f commit 4b37981
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
31 changes: 19 additions & 12 deletions core/Widgets/ContextMenu/MenuItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
*/

public class Widgets.ContextMenu.MenuItem : Gtk.Button {
private Gtk.Image menu_icon;
private Gtk.Revealer menu_icon_revealer;
private Gtk.Label menu_title;
private Gtk.Label secondary_label;
private Gtk.Revealer loading_revealer;
private Gtk.Revealer secondary_label_revealer;
private Gtk.Revealer select_revealer;
private Gtk.Revealer arrow_revealer;

public signal void activate_item ();

public string title {
set {
menu_title.label = value;
Expand All @@ -37,17 +48,6 @@ public class Widgets.ContextMenu.MenuItem : Gtk.Button {
}
}

private Gtk.Image menu_icon;
private Gtk.Revealer menu_icon_revealer;
private Gtk.Label menu_title;
private Gtk.Label secondary_label;
private Gtk.Revealer loading_revealer;
private Gtk.Revealer secondary_label_revealer;
private Gtk.Revealer select_revealer;
private Gtk.Revealer arrow_revealer;

public signal void activate_item ();

public string secondary_text {
set {
secondary_label.label = value;
Expand Down Expand Up @@ -91,6 +91,12 @@ public class Widgets.ContextMenu.MenuItem : Gtk.Button {
}
}

public int max_width_chars {
set {
menu_title.max_width_chars = value;
}
}

public MenuItem (string title, string? icon = null) {
Object (
title: title,
Expand All @@ -115,7 +121,8 @@ public class Widgets.ContextMenu.MenuItem : Gtk.Button {
};

menu_title = new Gtk.Label (null) {
use_markup = true
use_markup = true,
ellipsize = Pango.EllipsizeMode.END
};

var select_icon = new Gtk.Image.from_icon_name ("object-select-symbolic");
Expand Down
11 changes: 7 additions & 4 deletions core/Widgets/ProjectPicker/ProjectPickerButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Widgets.ProjectPicker.ProjectPickerButton : Adw.Bin {
public Objects.Section section {
set {
_section = value;
section_label.label = _section.short_name;
section_label.label = _section.name;
}
}

Expand Down Expand Up @@ -58,7 +58,8 @@ public class Widgets.ProjectPicker.ProjectPickerButton : Adw.Bin {
// Section Button
section_label = new Gtk.Label (_("No Section")) {
valign = Gtk.Align.CENTER,
ellipsize = Pango.EllipsizeMode.END
ellipsize = Pango.EllipsizeMode.END,
max_width_chars = 16
};

sections_popover = build_sections_popover ();
Expand Down Expand Up @@ -127,7 +128,9 @@ public class Widgets.ProjectPicker.ProjectPickerButton : Adw.Bin {
}

private Gtk.ListBoxRow get_section_row (Objects.Section? section) {
var button = new Widgets.ContextMenu.MenuItem (section != null ? section.short_name : _("No Section"));
var button = new Widgets.ContextMenu.MenuItem (section != null ? section.name : _("No Section")) {
max_width_chars = 16
};

var row = new Gtk.ListBoxRow () {
css_classes = { "row" },
Expand All @@ -136,7 +139,7 @@ public class Widgets.ProjectPicker.ProjectPickerButton : Adw.Bin {

button.clicked.connect (() => {
sections_popover.popdown ();
section_label.label = section != null ? section.short_name : _("No Section");
section_label.label = section != null ? section.name : _("No Section");
section_change (section);
});

Expand Down

0 comments on commit 4b37981

Please sign in to comment.