From 65c9c3e003390719d08a8ccc1aa717cf2670370b Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Tue, 14 May 2019 14:20:37 +0100 Subject: [PATCH] Applications: Categories column always use natural width Ported from https://github.com/linuxmint/mintmenu/pull/227 --- .../linuxmint/mintMenu/plugins/applications.glade | 2 +- usr/lib/linuxmint/mintMenu/plugins/applications.py | 12 ++++++++---- usr/lib/linuxmint/mintMenu/plugins/easybuttons.py | 8 +++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.glade b/usr/lib/linuxmint/mintMenu/plugins/applications.glade index ffc4296..f74ec29 100644 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.glade +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.glade @@ -265,7 +265,7 @@ True False - + True True never diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index b952bf3..13cc462 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -247,8 +247,13 @@ class pluginclass(object): self.favorites = [] self.content_holder.set_size_request(self.width, self.height) - self.categoriesBox.set_size_request(self.width / 3, -1) - self.applicationsBox.set_size_request(self.width / 2, -1) + # Calculate applicationsBox width based on categoryBox width, but since + # we won't have that until the menu has been shown go with an estimate + self.applicationsBox.set_size_request(self.width - 155, -1) + # Add margin for scrollbars to categoriesBox + categoriesScrolledWindow = self.builder.get_object("categoriesScrolledWindow") + scrollbar_width = categoriesScrolledWindow.get_vscrollbar().get_preferred_width() + self.categoriesBox.set_margin_right(scrollbar_width.natural_width + 2) self.buildingButtonList = False self.stopBuildingButtonList = False @@ -327,8 +332,7 @@ class pluginclass(object): def changePluginSize(self, settings, key, args): if key == "width": self.width = settings.get_int(key) - self.categoriesBox.set_size_request(self.width / 3, -1) - self.applicationsBox.set_size_request(self.width / 2, -1) + self.applicationsBox.set_size_request(self.width - self.categoriesBox.get_preferred_width().natural_width, -1) elif key == "height": self.heigth = settings.get_int(key) diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py index cebd1ea..adf561c 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py @@ -101,12 +101,13 @@ GObject.type_register(IconManager) class easyButton(Gtk.Button): - def __init__(self, iconName, iconSize, labels = None, buttonWidth = -1, buttonHeight = -1): + def __init__(self, iconName, iconSize, labels=None, buttonWidth=-1, buttonHeight=-1, ellipsis=True): GObject.GObject.__init__(self) self.connections = [] self.iconName = iconName self.iconSize = iconSize self.showIcon = True + self.ellipsis = ellipsis self.set_relief(Gtk.ReliefStyle.NONE) self.set_size_request(buttonWidth, buttonHeight) @@ -170,7 +171,8 @@ class easyButton(Gtk.Button): labelStyle.insert(attr) label.set_attributes(labelStyle) - label.set_ellipsize(Pango.EllipsizeMode.END) + if self.ellipsis: + label.set_ellipsize(Pango.EllipsizeMode.END) label.set_alignment(0.0, 1.0) label.set_max_width_chars(0) label.show() @@ -521,7 +523,7 @@ class FavApplicationLauncher(ApplicationLauncher): class CategoryButton(easyButton): def __init__(self, iconName, iconSize, labels , f): - easyButton.__init__(self, iconName, iconSize, labels) + easyButton.__init__(self, iconName, iconSize, labels, ellipsis=False) self.filter = f iconManager = IconManager()