1 |
dirtyepic 13/01/01 03:04:56 |
2 |
|
3 |
Added: mcomix-0.99-auto-rotate.patch |
4 |
Log: |
5 |
Add missing gdk-pixbuf dependency, reported by abc def. Backport auto-rotate |
6 |
patch from upstream. |
7 |
|
8 |
(Portage version: 2.2.0_alpha149/cvs/Linux x86_64, signed Manifest commit with key 957A8463) |
9 |
|
10 |
Revision Changes Path |
11 |
1.1 media-gfx/mcomix/files/mcomix-0.99-auto-rotate.patch |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-gfx/mcomix/files/mcomix-0.99-auto-rotate.patch?rev=1.1&view=markup |
14 |
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 |
15 |
|
16 |
Index: mcomix-0.99-auto-rotate.patch |
17 |
=================================================================== |
18 |
http://sourceforge.net/tracker/?func=detail&aid=3548642&group_id=341051&atid=1427791 |
19 |
http://mcomix.svn.sourceforge.net/viewvc/mcomix?view=revision&revision=781 |
20 |
|
21 |
Add option for auto-rotating images based on size. |
22 |
|
23 |
This doesn't work for double-page mode, as it would kind of defeat |
24 |
the purpose of placing two images next to each other. |
25 |
|
26 |
|
27 |
--- mcomix/preferences.py |
28 |
+++ mcomix/preferences.py |
29 |
@@ -63,6 +63,7 @@ |
30 |
'show thumbnails': True, |
31 |
'rotation': 0, |
32 |
'auto rotate from exif': True, |
33 |
+ 'auto rotate depending on size': constants.AUTOROTATE_NEVER, |
34 |
'vertical flip': False, |
35 |
'horizontal flip': False, |
36 |
'keep transformation': False, |
37 |
--- mcomix/constants.py |
38 |
+++ mcomix/constants.py |
39 |
@@ -31,6 +31,8 @@ |
40 |
ZIP, RAR, TAR, GZIP, BZIP2, PDF, SEVENZIP, LHA = range(8) |
41 |
NORMAL_CURSOR, GRAB_CURSOR, WAIT_CURSOR, NO_CURSOR = range(4) |
42 |
LIBRARY_DRAG_EXTERNAL_ID, LIBRARY_DRAG_BOOK_ID, LIBRARY_DRAG_COLLECTION_ID = range(3) |
43 |
+AUTOROTATE_NEVER, AUTOROTATE_WIDTH_90, AUTOROTATE_WIDTH_270, \ |
44 |
+ AUTOROTATE_HEIGHT_90, AUTOROTATE_HEIGHT_270 = range(5) |
45 |
|
46 |
RESPONSE_REVERT_TO_DEFAULT = 3 |
47 |
RESPONSE_REMOVE = 4 |
48 |
--- mcomix/ui.py |
49 |
+++ mcomix/ui.py |
50 |
@@ -13,6 +13,7 @@ |
51 |
from mcomix import constants |
52 |
from mcomix import status |
53 |
from mcomix import file_chooser_main_dialog |
54 |
+from mcomix.preferences import prefs |
55 |
from mcomix.library import main_dialog as library_main_dialog |
56 |
|
57 |
class MainUI(gtk.UIManager): |
58 |
@@ -97,6 +98,9 @@ |
59 |
('menu_tools', None, _('_Tools')), |
60 |
('menu_help', None, _('_Help')), |
61 |
('menu_transform', 'mcomix-transform', _('_Transform image')), |
62 |
+ ('menu_autorotate', None, _('_Auto-rotate image')), |
63 |
+ ('menu_autorotate_width', None, _('...when width exceeds height')), |
64 |
+ ('menu_autorotate_height', None, _('...when height exceeds width')), |
65 |
('expander', None, None, None, None, None)]) |
66 |
|
67 |
self._actiongroup.add_toggle_actions([ |
68 |
@@ -146,6 +150,20 @@ |
69 |
'a', _('Manual zoom mode'), constants.ZOOM_MODE_MANUAL)], |
70 |
3, window.change_zoom_mode) |
71 |
|
72 |
+ # Automatically rotate image if width>height or height>width |
73 |
+ self._actiongroup.add_radio_actions([ |
74 |
+ ('no_autorotation', None, _('Never'), |
75 |
+ None, None, constants.AUTOROTATE_NEVER), |
76 |
+ ('rotate_90_width', 'mcomix-rotate-90', _('_Rotate 90 degrees CW'), |
77 |
+ None, None, constants.AUTOROTATE_WIDTH_90), |
78 |
+ ('rotate_270_width', 'mcomix-rotate-270', _('Rotat_e 90 degrees CCW'), |
79 |
+ None, None, constants.AUTOROTATE_WIDTH_270), |
80 |
+ ('rotate_90_height', 'mcomix-rotate-90', _('_Rotate 90 degrees CW'), |
81 |
+ None, None, constants.AUTOROTATE_HEIGHT_90), |
82 |
+ ('rotate_270_height', 'mcomix-rotate-270', _('Rotat_e 90 degrees CCW'), |
83 |
+ None, None, constants.AUTOROTATE_HEIGHT_270)], |
84 |
+ prefs['auto rotate depending on size'], window.change_autorotation) |
85 |
+ |
86 |
self._actiongroup.add_actions([ |
87 |
('about', gtk.STOCK_ABOUT, _('_About'), |
88 |
None, None, dialog_handler.open_dialog)], (window, 'about-dialog')) |
89 |
@@ -280,6 +298,20 @@ |
90 |
<menuitem action="rotate_270" /> |
91 |
<menuitem action="rotate_180" /> |
92 |
<separator /> |
93 |
+ <menu action="menu_autorotate"> |
94 |
+ <menuitem action="no_autorotation" /> |
95 |
+ <separator /> |
96 |
+ <menuitem action="menu_autorotate_height" /> |
97 |
+ <separator /> |
98 |
+ <menuitem action="rotate_90_height" /> |
99 |
+ <menuitem action="rotate_270_height" /> |
100 |
+ <separator /> |
101 |
+ <menuitem action="menu_autorotate_width" /> |
102 |
+ <separator /> |
103 |
+ <menuitem action="rotate_90_width" /> |
104 |
+ <menuitem action="rotate_270_width" /> |
105 |
+ </menu> |
106 |
+ <separator /> |
107 |
<menuitem action="flip_horiz" /> |
108 |
<menuitem action="flip_vert" /> |
109 |
<separator /> |
110 |
--- mcomix/main.py |
111 |
+++ mcomix/main.py |
112 |
@@ -203,6 +203,9 @@ |
113 |
prefs['vertical flip'] = False |
114 |
prefs['horizontal flip'] = False |
115 |
|
116 |
+ self.actiongroup.get_action('menu_autorotate_width').set_sensitive(False) |
117 |
+ self.actiongroup.get_action('menu_autorotate_height').set_sensitive(False) |
118 |
+ |
119 |
self.add(table) |
120 |
table.show() |
121 |
self._main_layout.show() |
122 |
@@ -305,15 +308,9 @@ |
123 |
right_unscaled_x = right_pixbuf.get_width() |
124 |
right_unscaled_y = right_pixbuf.get_height() |
125 |
|
126 |
- left_rotation = prefs['rotation'] |
127 |
- right_rotation = prefs['rotation'] |
128 |
+ left_rotation = self._get_pixbuf_rotation(left_pixbuf, True) |
129 |
+ right_rotation = self._get_pixbuf_rotation(right_pixbuf, True) |
130 |
|
131 |
- if prefs['auto rotate from exif']: |
132 |
- left_rotation += image_tools.get_implied_rotation(left_pixbuf) |
133 |
- left_rotation = left_rotation % 360 |
134 |
- right_rotation += image_tools.get_implied_rotation(right_pixbuf) |
135 |
- right_rotation = right_rotation % 360 |
136 |
- |
137 |
if left_rotation in (90, 270): |
138 |
total_width = left_unscaled_y |
139 |
total_height = left_unscaled_x |
140 |
@@ -385,11 +382,7 @@ |
141 |
pixbuf = self.imagehandler.get_pixbufs(single=True)[ 0 ] |
142 |
width, height = pixbuf.get_width(), pixbuf.get_height() |
143 |
|
144 |
- rotation = prefs['rotation'] |
145 |
- if prefs['auto rotate from exif']: |
146 |
- rotation += image_tools.get_implied_rotation(pixbuf) |
147 |
- rotation = rotation % 360 |
148 |
- |
149 |
+ rotation = self._get_pixbuf_rotation(pixbuf) |
150 |
if rotation in (90, 270): |
151 |
width, height = height, width |
152 |
|
153 |
@@ -502,6 +495,37 @@ |
154 |
self.statusbar.update() |
155 |
self.update_title() |
156 |
|
157 |
+ def _get_pixbuf_rotation(self, pixbuf, no_autorotation=False): |
158 |
+ """ Determines if a pixbuf must be rotated before being displayed. |
159 |
+ Returns the degree of rotation (0, 90, 180, 270). """ |
160 |
+ |
161 |
+ width, height = pixbuf.get_width(), pixbuf.get_height() |
162 |
+ rotation = prefs['rotation'] |
163 |
+ if prefs['auto rotate from exif']: |
164 |
+ rotation += image_tools.get_implied_rotation(pixbuf) |
165 |
+ rotation = rotation % 360 |
166 |
+ |
167 |
+ if (height > width and |
168 |
+ not no_autorotation and |
169 |
+ prefs['auto rotate depending on size'] in |
170 |
+ (constants.AUTOROTATE_HEIGHT_90, constants.AUTOROTATE_HEIGHT_270)): |
171 |
+ |
172 |
+ if prefs['auto rotate depending on size'] == constants.AUTOROTATE_HEIGHT_90: |
173 |
+ rotation = 90 |
174 |
+ else: |
175 |
+ rotation = 270 |
176 |
+ elif (width > height and |
177 |
+ not no_autorotation and |
178 |
+ prefs['auto rotate depending on size'] in |
179 |
+ (constants.AUTOROTATE_WIDTH_90, constants.AUTOROTATE_WIDTH_270)): |
180 |
+ |
181 |
+ if prefs['auto rotate depending on size'] == constants.AUTOROTATE_WIDTH_90: |
182 |
+ rotation = 90 |
183 |
+ else: |
184 |
+ rotation = 270 |
185 |
+ |
186 |
+ return rotation |
187 |
+ |
188 |
def _page_available(self, page): |
189 |
""" Called whenever a new page is ready for displaying. """ |
190 |
# Refresh display when currently opened page becomes available. |
191 |
@@ -623,6 +647,14 @@ |
192 |
fitmode.set_scale_up(prefs['stretch']) |
193 |
self.zoom.set_fit_mode(fitmode) |
194 |
|
195 |
+ def change_autorotation(self, radioaction=None, *args): |
196 |
+ """ Switches between automatic rotation modes, depending on which |
197 |
+ radiobutton is currently activated. """ |
198 |
+ if radioaction: |
199 |
+ prefs['auto rotate depending on size'] = radioaction.get_current_value() |
200 |
+ |
201 |
+ self.draw_image() |
202 |
+ |
203 |
def change_stretch(self, toggleaction, *args): |
204 |
""" Toggles stretching small images. """ |
205 |
prefs['stretch'] = toggleaction.get_active() |