From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 015D91381FA for ; Tue, 1 Jan 2013 03:05:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 772F821C005; Tue, 1 Jan 2013 03:05:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D6BF121C005 for ; Tue, 1 Jan 2013 03:04:59 +0000 (UTC) Received: from flycatcher.gentoo.org (flycatcher.gentoo.org [81.93.255.6]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C8EF133D947 for ; Tue, 1 Jan 2013 03:04:58 +0000 (UTC) Received: by flycatcher.gentoo.org (Postfix, from userid 2145) id EEEA320081; Tue, 1 Jan 2013 03:04:56 +0000 (UTC) From: "Ryan Hill (dirtyepic)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, dirtyepic@gentoo.org Subject: [gentoo-commits] gentoo-x86 commit in media-gfx/mcomix/files: mcomix-0.99-auto-rotate.patch X-VCS-Repository: gentoo-x86 X-VCS-Files: mcomix-0.99-auto-rotate.patch X-VCS-Directories: media-gfx/mcomix/files X-VCS-Committer: dirtyepic X-VCS-Committer-Name: Ryan Hill Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Message-Id: <20130101030456.EEEA320081@flycatcher.gentoo.org> Date: Tue, 1 Jan 2013 03:04:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 6a54b58a-0bdd-4d7e-b5f5-a701e0c2818a X-Archives-Hash: 275bfbaf9aaea041ecba89e4ef93ae85 dirtyepic 13/01/01 03:04:56 Added: mcomix-0.99-auto-rotate.patch Log: Add missing gdk-pixbuf dependency, reported by abc def. Backport auto-rotate patch from upstream. (Portage version: 2.2.0_alpha149/cvs/Linux x86_64, signed Manifest commit with key 957A8463) Revision Changes Path 1.1 media-gfx/mcomix/files/mcomix-0.99-auto-rotate.patch file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-gfx/mcomix/files/mcomix-0.99-auto-rotate.patch?rev=1.1&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-gfx/mcomix/files/mcomix-0.99-auto-rotate.patch?rev=1.1&content-type=text/plain Index: mcomix-0.99-auto-rotate.patch =================================================================== http://sourceforge.net/tracker/?func=detail&aid=3548642&group_id=341051&atid=1427791 http://mcomix.svn.sourceforge.net/viewvc/mcomix?view=revision&revision=781 Add option for auto-rotating images based on size. This doesn't work for double-page mode, as it would kind of defeat the purpose of placing two images next to each other. --- mcomix/preferences.py +++ mcomix/preferences.py @@ -63,6 +63,7 @@ 'show thumbnails': True, 'rotation': 0, 'auto rotate from exif': True, + 'auto rotate depending on size': constants.AUTOROTATE_NEVER, 'vertical flip': False, 'horizontal flip': False, 'keep transformation': False, --- mcomix/constants.py +++ mcomix/constants.py @@ -31,6 +31,8 @@ ZIP, RAR, TAR, GZIP, BZIP2, PDF, SEVENZIP, LHA = range(8) NORMAL_CURSOR, GRAB_CURSOR, WAIT_CURSOR, NO_CURSOR = range(4) LIBRARY_DRAG_EXTERNAL_ID, LIBRARY_DRAG_BOOK_ID, LIBRARY_DRAG_COLLECTION_ID = range(3) +AUTOROTATE_NEVER, AUTOROTATE_WIDTH_90, AUTOROTATE_WIDTH_270, \ + AUTOROTATE_HEIGHT_90, AUTOROTATE_HEIGHT_270 = range(5) RESPONSE_REVERT_TO_DEFAULT = 3 RESPONSE_REMOVE = 4 --- mcomix/ui.py +++ mcomix/ui.py @@ -13,6 +13,7 @@ from mcomix import constants from mcomix import status from mcomix import file_chooser_main_dialog +from mcomix.preferences import prefs from mcomix.library import main_dialog as library_main_dialog class MainUI(gtk.UIManager): @@ -97,6 +98,9 @@ ('menu_tools', None, _('_Tools')), ('menu_help', None, _('_Help')), ('menu_transform', 'mcomix-transform', _('_Transform image')), + ('menu_autorotate', None, _('_Auto-rotate image')), + ('menu_autorotate_width', None, _('...when width exceeds height')), + ('menu_autorotate_height', None, _('...when height exceeds width')), ('expander', None, None, None, None, None)]) self._actiongroup.add_toggle_actions([ @@ -146,6 +150,20 @@ 'a', _('Manual zoom mode'), constants.ZOOM_MODE_MANUAL)], 3, window.change_zoom_mode) + # Automatically rotate image if width>height or height>width + self._actiongroup.add_radio_actions([ + ('no_autorotation', None, _('Never'), + None, None, constants.AUTOROTATE_NEVER), + ('rotate_90_width', 'mcomix-rotate-90', _('_Rotate 90 degrees CW'), + None, None, constants.AUTOROTATE_WIDTH_90), + ('rotate_270_width', 'mcomix-rotate-270', _('Rotat_e 90 degrees CCW'), + None, None, constants.AUTOROTATE_WIDTH_270), + ('rotate_90_height', 'mcomix-rotate-90', _('_Rotate 90 degrees CW'), + None, None, constants.AUTOROTATE_HEIGHT_90), + ('rotate_270_height', 'mcomix-rotate-270', _('Rotat_e 90 degrees CCW'), + None, None, constants.AUTOROTATE_HEIGHT_270)], + prefs['auto rotate depending on size'], window.change_autorotation) + self._actiongroup.add_actions([ ('about', gtk.STOCK_ABOUT, _('_About'), None, None, dialog_handler.open_dialog)], (window, 'about-dialog')) @@ -280,6 +298,20 @@ + + + + + + + + + + + + + + --- mcomix/main.py +++ mcomix/main.py @@ -203,6 +203,9 @@ prefs['vertical flip'] = False prefs['horizontal flip'] = False + self.actiongroup.get_action('menu_autorotate_width').set_sensitive(False) + self.actiongroup.get_action('menu_autorotate_height').set_sensitive(False) + self.add(table) table.show() self._main_layout.show() @@ -305,15 +308,9 @@ right_unscaled_x = right_pixbuf.get_width() right_unscaled_y = right_pixbuf.get_height() - left_rotation = prefs['rotation'] - right_rotation = prefs['rotation'] + left_rotation = self._get_pixbuf_rotation(left_pixbuf, True) + right_rotation = self._get_pixbuf_rotation(right_pixbuf, True) - if prefs['auto rotate from exif']: - left_rotation += image_tools.get_implied_rotation(left_pixbuf) - left_rotation = left_rotation % 360 - right_rotation += image_tools.get_implied_rotation(right_pixbuf) - right_rotation = right_rotation % 360 - if left_rotation in (90, 270): total_width = left_unscaled_y total_height = left_unscaled_x @@ -385,11 +382,7 @@ pixbuf = self.imagehandler.get_pixbufs(single=True)[ 0 ] width, height = pixbuf.get_width(), pixbuf.get_height() - rotation = prefs['rotation'] - if prefs['auto rotate from exif']: - rotation += image_tools.get_implied_rotation(pixbuf) - rotation = rotation % 360 - + rotation = self._get_pixbuf_rotation(pixbuf) if rotation in (90, 270): width, height = height, width @@ -502,6 +495,37 @@ self.statusbar.update() self.update_title() + def _get_pixbuf_rotation(self, pixbuf, no_autorotation=False): + """ Determines if a pixbuf must be rotated before being displayed. + Returns the degree of rotation (0, 90, 180, 270). """ + + width, height = pixbuf.get_width(), pixbuf.get_height() + rotation = prefs['rotation'] + if prefs['auto rotate from exif']: + rotation += image_tools.get_implied_rotation(pixbuf) + rotation = rotation % 360 + + if (height > width and + not no_autorotation and + prefs['auto rotate depending on size'] in + (constants.AUTOROTATE_HEIGHT_90, constants.AUTOROTATE_HEIGHT_270)): + + if prefs['auto rotate depending on size'] == constants.AUTOROTATE_HEIGHT_90: + rotation = 90 + else: + rotation = 270 + elif (width > height and + not no_autorotation and + prefs['auto rotate depending on size'] in + (constants.AUTOROTATE_WIDTH_90, constants.AUTOROTATE_WIDTH_270)): + + if prefs['auto rotate depending on size'] == constants.AUTOROTATE_WIDTH_90: + rotation = 90 + else: + rotation = 270 + + return rotation + def _page_available(self, page): """ Called whenever a new page is ready for displaying. """ # Refresh display when currently opened page becomes available. @@ -623,6 +647,14 @@ fitmode.set_scale_up(prefs['stretch']) self.zoom.set_fit_mode(fitmode) + def change_autorotation(self, radioaction=None, *args): + """ Switches between automatic rotation modes, depending on which + radiobutton is currently activated. """ + if radioaction: + prefs['auto rotate depending on size'] = radioaction.get_current_value() + + self.draw_image() + def change_stretch(self, toggleaction, *args): """ Toggles stretching small images. """ prefs['stretch'] = toggleaction.get_active()