def adjust_droplist_position(self, widget): '''Realize droplist.''' # Adjust coordinate. (screen_width, screen_height) = get_screen_size(self) droplist_width = 0 for droplist_item in self.droplist_items: if droplist_width == 0 and isinstance(droplist_item.item_box, gtk.Button): droplist_width = droplist_item.item_box_width droplist_width += self.padding_x * 2 droplist_height = self.allocation.height if self.x_align == ALIGN_START: dx = self.expect_x elif self.x_align == ALIGN_MIDDLE: dx = self.expect_x - droplist_width / 2 else: dx = self.expect_x - droplist_width if self.y_align == ALIGN_START: dy = self.expect_y elif self.y_align == ALIGN_MIDDLE: dy = self.expect_y - droplist_height / 2 else: dy = self.expect_y - droplist_height if self.expect_x + droplist_width > screen_width: dx = self.expect_x - droplist_width + self.offset_x if self.expect_y + droplist_height > screen_height: dy = self.expect_y - droplist_height + self.offset_y self.move(dx, dy)
def delay_show_notify(self, item): screen_width, screen_height = utils.get_screen_size() view_x, view_y = self.scrolled_window.get_child().get_view_window().get_size() (origin_x, origin_y) = get_widget_root_coordinate(self.draw_area, WIDGET_POS_TOP_LEFT, False) notify_width = self.song_notify.default_width if origin_x + view_x + notify_width + self.notify_offset_x > screen_width: x = origin_x - notify_width - self.notify_offset_x else: x = origin_x + view_x + self.notify_offset_x y = origin_y + self.get_item_offset_y(item) self.song_notify.update_song(item.song) self.song_notify.show(x, y)
def adjust_droplist_position(self): ''' Internal function to adjust droplist position after `realize` signal. ''' # Adjust coordinate. (screen_width, screen_height) = get_screen_size(self) droplist_width = 0 droplist_height = 0 for droplist_item in self.droplist_items: if droplist_width == 0 and isinstance(droplist_item.item_box, gtk.Button): droplist_width = droplist_item.item_box_width droplist_height += droplist_item.item_box_height droplist_width += self.padding_x * 2 if self.max_height != None: droplist_height = min(self.max_height, droplist_height + self.padding_y * 2) if self.x_align == ALIGN_START: dx = self.expect_x elif self.x_align == ALIGN_MIDDLE: dx = self.expect_x - droplist_width / 2 else: dx = self.expect_x - droplist_width if self.y_align == ALIGN_START: dy = self.expect_y elif self.y_align == ALIGN_MIDDLE: dy = self.expect_y - droplist_height / 2 else: dy = self.expect_y - droplist_height if self.expect_x + droplist_width > screen_width: dx = self.expect_x - droplist_width + self.offset_x if droplist_height != None: if self.expect_y + droplist_height > screen_height: dy = self.expect_y - droplist_height + self.offset_y if droplist_height != None: self.window.move_resize(dx, dy, droplist_width, droplist_height)
def adjust_menu_position(self): """ Internal function to realize menu position. """ # Adjust coordinate. (screen_width, screen_height) = get_screen_size(self) menu_width = menu_height = 0 for menu_item in self.menu_items: if isinstance(menu_item.item_box, gtk.Button): item_box_width = menu_item.item_box_width if item_box_width > menu_width: menu_width = item_box_width menu_height += menu_item.item_box_height (shadow_x, shadow_y) = get_window_shadow_size(self) menu_width += (self.padding_x + shadow_x) * 2 menu_height += (self.padding_y + shadow_y) * 2 if self.x_align == ALIGN_START: dx = self.expect_x elif self.x_align == ALIGN_MIDDLE: dx = self.expect_x - menu_width / 2 else: dx = self.expect_x - menu_width if self.y_align == ALIGN_START: dy = self.expect_y elif self.y_align == ALIGN_MIDDLE: dy = self.expect_y - menu_height / 2 else: dy = self.expect_y - menu_height if self.expect_x + menu_width > screen_width: dx = self.expect_x - menu_width + self.offset_x if self.expect_y + menu_height > screen_height: dy = self.expect_y - menu_height + self.offset_y self.move(dx, dy)
def adjust_menu_position(self): ''' Internal function to realize menu position. ''' # Adjust coordinate. (screen_width, screen_height) = get_screen_size(self) menu_width = menu_height = 0 for menu_item in self.menu_items: if isinstance(menu_item.item_box, gtk.Button): item_box_width = menu_item.item_box_width if item_box_width > menu_width: menu_width = item_box_width menu_height += menu_item.item_box_height (shadow_x, shadow_y) = get_window_shadow_size(self) menu_width += (self.padding_x + shadow_x) * 2 menu_height += (self.padding_y + shadow_y) * 2 if self.x_align == ALIGN_START: dx = self.expect_x elif self.x_align == ALIGN_MIDDLE: dx = self.expect_x - menu_width / 2 else: dx = self.expect_x - menu_width if self.y_align == ALIGN_START: dy = self.expect_y elif self.y_align == ALIGN_MIDDLE: dy = self.expect_y - menu_height / 2 else: dy = self.expect_y - menu_height if self.expect_x + menu_width > screen_width: dx = self.expect_x - menu_width + self.offset_x if self.expect_y + menu_height > screen_height: dy = self.expect_y - menu_height + self.offset_y self.move(dx, dy)
self.window_height, # minimum height self.window_width, self.window_height, -1, -1, -1, -1, -1, -1 ) def show(self, (expect_x, expect_y), (offset_x, offset_y)=(0, 0)): ''' Show poplist. @param expect_x: Expect x coordinate. @param expect_y: Expect y coordinate. @param offset_x: The offset x. @param offset_y: The offset y. ''' (screen_width, screen_height) = get_screen_size(self) if not self.get_realized(): self.realize() if self.x_align == ALIGN_START: dx = expect_x elif self.x_align == ALIGN_MIDDLE: dx = expect_x - self.window_width / 2 else: dx = expect_x - self.window_width if self.y_align == ALIGN_START: dy = expect_y elif self.y_align == ALIGN_MIDDLE: dy = expect_y - self.window_height / 2
-1, -1, -1, -1, -1) def show(self, (expect_x, expect_y), (offset_x, offset_y)=(0, 0)): ''' Show poplist. @param expect_x: Expect x coordinate. @param expect_y: Expect y coordinate. @param offset_x: The offset x. @param offset_y: The offset y. ''' (screen_width, screen_height) = get_screen_size(self) if not self.get_realized(): self.realize() if self.x_align == ALIGN_START: dx = expect_x elif self.x_align == ALIGN_MIDDLE: dx = expect_x - self.window_width / 2 else: dx = expect_x - self.window_width if self.y_align == ALIGN_START: dy = expect_y elif self.y_align == ALIGN_MIDDLE: dy = expect_y - self.window_height / 2