Skip to content

Commit 2d2bb4e

Browse files
committed
Use Granite.AlleLabel for menu popover
1 parent 44a7262 commit 2d2bb4e

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

src/Layouts/HeaderBar.vala

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2018 Alecaddd (http://alecaddd.com)
2+
* Copyright (c) 2017-2020 Alecaddd (https://alecaddd.com)
33
*
44
* This program is free software; you can redistribute it and/or
55
* modify it under the terms of the GNU General Public
@@ -8,7 +8,7 @@
88
*
99
* This program is distributed in the hope that it will be useful,
1010
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1212
* General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU General Public
@@ -65,13 +65,13 @@ public class Sequeler.Layouts.HeaderBar : Gtk.HeaderBar {
6565
mode_switch.active = true;
6666
}
6767

68-
var new_window_item = new_menuitem (_("New Window"), {"<Control>n"});
68+
var new_window_item = new_menuitem (_("New Window"), "<Control>n");
6969
new_window_item.action_name = Sequeler.Services.ActionManager.ACTION_PREFIX + Sequeler.Services.ActionManager.ACTION_NEW_WINDOW;
7070

71-
var new_connection_item = new_menuitem (_("New Connection"), {"<Control><Shift>n"});
71+
var new_connection_item = new_menuitem (_("New Connection"), "<Control><Shift>n");
7272
new_connection_item.action_name = Sequeler.Services.ActionManager.ACTION_PREFIX + Sequeler.Services.ActionManager.ACTION_NEW_CONNECTION;
7373

74-
var quit_item = new_menuitem (_("Quit"), {"<Control>q"});
74+
var quit_item = new_menuitem (_("Quit"), "<Control>q");
7575
quit_item.action_name = Sequeler.Services.ActionManager.ACTION_PREFIX + Sequeler.Services.ActionManager.ACTION_QUIT;
7676

7777
var menu_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
@@ -109,29 +109,12 @@ public class Sequeler.Layouts.HeaderBar : Gtk.HeaderBar {
109109
pack_end (mode_switch);
110110
}
111111

112-
private Gtk.Button new_menuitem (string label, string[] accels) {
113-
var item_label = new Gtk.Label (label);
114-
item_label.halign = Gtk.Align.START;
115-
item_label.hexpand = true;
116-
item_label.margin_start = 6;
117-
118-
var item_accel_label = new Gtk.Label (Granite.markup_accel_tooltip (accels));
119-
item_accel_label.halign = Gtk.Align.END;
120-
item_accel_label.margin_end = item_accel_label.margin_start = 6;
121-
item_accel_label.use_markup = true;
122-
123-
var item_grid = new Gtk.Grid ();
124-
item_grid.add (item_label);
125-
item_grid.add (item_accel_label);
126-
127-
var item = new Gtk.Button ();
128-
item.add (item_grid);
129-
item.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM);
130-
item.clicked.connect (() => {
131-
menu_popover.hide ();
132-
});
112+
private Gtk.ModelButton new_menuitem (string label, string accels) {
113+
var button = new Gtk.ModelButton ();
114+
button.get_child ().destroy ();
115+
button.add (new Granite.AccelLabel (label, accels));
133116

134-
return item;
117+
return button;
135118
}
136119

137120
public async void toggle_logout () {

0 commit comments

Comments
 (0)