def initialize(self, builder: Any, result: Any, index: int, query: Query) -> None: self.builder = builder item_frame = self.builder.get_object('item-frame') item_frame.connect("button-release-event", self.on_click) item_frame.connect("enter_notify_event", self.on_mouse_hover) self.item_box = builder.get_object('item-box') self.result = result self.query = query self.set_index(index) self.scaling_factor = get_scaling_factor() item_container = builder.get_object('item-container') item_name = builder.get_object('name_wrapper') base_scaling = 1.0 if not item_name: item_name = builder.get_object('item-name') base_scaling = 0.67 item_container.set_property('margin-start', 18 * self.scaling_factor) item_container.set_property('margin-end', 18 * self.scaling_factor) item_container.set_property('margin-top', 5 * base_scaling * self.scaling_factor) item_container.set_property('margin-bottom', 5 * base_scaling * self.scaling_factor) item_name.set_property('margin-start', 12 * base_scaling * self.scaling_factor) item_name.set_property('margin-end', 12 * base_scaling * self.scaling_factor) item_name.set_property('width-request', 350 * self.scaling_factor) self.set_icon(load_icon(result.icon, result.ICON_SIZE * self.scaling_factor)) self.set_description(result.get_description(query)) self.set_name_highlighted()
def position_window(self): monitor = get_monitor( self.settings.get_property('render-on-screen') != "default-monitor" ) geo = monitor.get_geometry() max_height = geo.height - ( geo.height * 0.15) - 100 # 100 is roughly the height of the text input window_width = 500 * get_scaling_factor() self.set_property('width-request', window_width) self.scroll_container.set_property('max-content-height', max_height) self.move(geo.width * 0.5 - window_width * 0.5 + geo.x, geo.y + geo.height * 0.12)
def _render_prefs_icon(self): prefs_pixbuf = load_icon(get_asset('icons/gear.svg'), 16 * get_scaling_factor()) prefs_image = Gtk.Image.new_from_pixbuf(prefs_pixbuf) self.prefs_btn.set_image(prefs_image)