diff options
author | Dan Winship <danw@gnome.org> | 2014-11-12 17:04:40 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-11-12 17:34:24 -0500 |
commit | 955f41d5f4734378080ba2d6a183b41981818c20 (patch) | |
tree | 6d75766e4506b11143d86a6032b02c5ac4d8a7ce | |
parent | c0c90fa65d0b63556c2743ae1bfae8080f349a01 (diff) | |
download | NetworkManager-955f41d5f4734378080ba2d6a183b41981818c20.tar.gz |
tui: fix alignment of pop-up menus
Pop-up menus were slightly mis-aligned in the main window, and even
more mis-aligned in slave-editing windows. Fix that.
Also add a bit of padding to the pop-up window, because it just looks
better that way.
-rw-r--r-- | clients/tui/newt/nmt-newt-popup.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/clients/tui/newt/nmt-newt-popup.c b/clients/tui/newt/nmt-newt-popup.c index 80fa0181c5..b604eaaa39 100644 --- a/clients/tui/newt/nmt-newt-popup.c +++ b/clients/tui/newt/nmt-newt-popup.c @@ -147,12 +147,27 @@ nmt_newt_popup_activated (NmtNewtWidget *widget) for (i = 0; i < priv->entries->len; i++) nmt_newt_listbox_append (NMT_NEWT_LISTBOX (listbox), entries[i].label, NULL); nmt_newt_listbox_set_active (NMT_NEWT_LISTBOX (listbox), priv->active); + nmt_newt_widget_set_padding (listbox, 1, 0, 1, 0); nmt_newt_widget_size_request (listbox, &list_w, &list_h); + + g_object_get (nmt_newt_widget_get_form (widget), + "x", &window_x, + "y", &window_y, + NULL); newtComponentGetPosition (nmt_newt_component_get_component (NMT_NEWT_COMPONENT (widget)), &button_x, &button_y); - window_x = button_x + 4; - window_y = button_y + 2 - priv->active; + /* (window_x + button_x) is the screen X coordinate of the newtComponent. A + * newtButton labelled "Foo" is rendered as " <Foo>" (with a preceding + * space), so the "F" is at (window_x + button_x + 2). We've added 1 column + * of padding to the left of the listbox, so we need to position the popup + * at (window_x + button_x + 1) in order for its text to be aligned with the + * button's text. (The x and y coordinates given to NmtNewtForm are the + * coordinates of the top left of the window content, ignoring the border + * graphics.) + */ + window_x += button_x + 1; + window_y += button_y - priv->active; form = g_object_new (NMT_TYPE_NEWT_FORM, "x", window_x, |