Merge lp:~pimvullers/strip/fix-gtk-menu into lp:strip
- fix-gtk-menu
- Merge into trunk
Proposed by
Pim Vullers
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 79 | ||||
Proposed branch: | lp:~pimvullers/strip/fix-gtk-menu | ||||
Merge into: | lp:strip | ||||
Diff against target: |
418 lines (+77/-80) 2 files modified
src/ScaleWithBubble.vala (+12/-15) src/StripWindow.vala (+65/-65) |
||||
To merge this branch: | bzr merge lp:~pimvullers/strip/fix-gtk-menu | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cody Garver | Approve | ||
Review via email:
|
Commit message
Fixed bug #942917
Description of the change
Fixed the build issues concerning Gtk.Menu and friends.
Removed the using statements in conformance with the coding standards.
To post a comment you must log in.
- 80. By Pim Vullers
-
made the welcome widget sensitive
- 81. By Pim Vullers
-
added comment about the modified lines
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Cody Garver (codygarver) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/ScaleWithBubble.vala' |
2 | --- src/ScaleWithBubble.vala 2011-10-13 05:53:56 +0000 |
3 | +++ src/ScaleWithBubble.vala 2012-03-07 21:51:17 +0000 |
4 | @@ -20,18 +20,15 @@ |
5 | // ammonkey <am.monkeyd@gmail.com> |
6 | // |
7 | |
8 | -using Gtk; |
9 | -using Gdk; |
10 | - |
11 | namespace Granite.Widgets |
12 | { |
13 | - class HScaleWithBubble : HScale |
14 | + class HScaleWithBubble : Gtk.HScale |
15 | { |
16 | //~ private Gtk.CssProvider provider; |
17 | private Bubble bubble; |
18 | public bool bubble_on_top = false; |
19 | |
20 | - public HScaleWithBubble(Adjustment adjustment) |
21 | + public HScaleWithBubble(Gtk.Adjustment adjustment) |
22 | { init(); } |
23 | |
24 | public HScaleWithBubble.with_range(double min, double max, double step) |
25 | @@ -63,12 +60,12 @@ |
26 | int x; |
27 | int y; |
28 | get_window().get_origin(out x, out y); |
29 | - Allocation scale_allocation; |
30 | + Gtk.Allocation scale_allocation; |
31 | get_allocation(out scale_allocation); |
32 | - Allocation bubble_allocation; |
33 | + Gtk.Allocation bubble_allocation; |
34 | bubble.get_allocation(out bubble_allocation); |
35 | |
36 | - Adjustment adjustment = get_adjustment(); |
37 | + Gtk.Adjustment adjustment = get_adjustment(); |
38 | double scale_percent = (get_value() - adjustment.get_lower()) / (adjustment.get_upper() - adjustment.get_lower()); |
39 | |
40 | if (get_inverted()) |
41 | @@ -87,13 +84,13 @@ |
42 | { bubble.append(widget); } |
43 | } |
44 | /* |
45 | - class VScaleWithBubble : VScale |
46 | + class VScaleWithBubble : Gtk.VScale |
47 | { |
48 | private Gtk.CssProvider provider; |
49 | private Bubble bubble; |
50 | public bool bubble_on_left = false; |
51 | |
52 | - public VScaleWithBubble(Adjustment adjustment) |
53 | + public VScaleWithBubble(Gtk.Adjustment adjustment) |
54 | { init(); } |
55 | |
56 | public VScaleWithBubble.with_range(double min, double max, double step) |
57 | @@ -130,7 +127,7 @@ |
58 | Allocation bubble_allocation; |
59 | bubble.get_allocation(out bubble_allocation); |
60 | |
61 | - Adjustment adjustment = get_adjustment(); |
62 | + Gtk.Adjustment adjustment = get_adjustment(); |
63 | double scale_percent = (get_value() - adjustment.get_lower()) / (adjustment.get_upper() - adjustment.get_lower()); |
64 | |
65 | if (get_inverted()) |
66 | @@ -152,8 +149,8 @@ |
67 | class Bubble : Gtk.Window |
68 | { |
69 | //~ private Gtk.CssProvider provider; |
70 | - private Menu menu; |
71 | - private VBox box; |
72 | + private Gtk.Menu menu; |
73 | + private Gtk.VBox box; |
74 | |
75 | public Bubble() |
76 | { |
77 | @@ -166,11 +163,11 @@ |
78 | //~ set_visual (screen.get_rgba_visual()); |
79 | |
80 | /* fake menu to use css */ |
81 | - menu = new Menu (); |
82 | + menu = new Gtk.Menu (); |
83 | //~ menu.get_style_context ().add_provider (provider, 600); |
84 | //~ menu.get_style_context ().add_class ("bubble-window"); |
85 | |
86 | - box = new VBox(false, 0); |
87 | + box = new Gtk.VBox(false, 0); |
88 | box.margin_top = 7; |
89 | box.margin_left = 7; |
90 | box.margin_right = 7; |
91 | |
92 | === modified file 'src/StripWindow.vala' |
93 | --- src/StripWindow.vala 2011-11-01 08:25:30 +0000 |
94 | +++ src/StripWindow.vala 2012-03-07 21:51:17 +0000 |
95 | @@ -43,12 +43,6 @@ |
96 | |
97 | // Tags: FIXME |
98 | |
99 | -using Gtk; |
100 | -using Gdk; |
101 | -using Granite.Widgets; |
102 | - |
103 | -using Resources; |
104 | - |
105 | namespace Strip |
106 | { |
107 | class StripWindow : Gtk.Window |
108 | @@ -63,24 +57,24 @@ |
109 | |
110 | ComicBook book; |
111 | ComicLayout layout = new ComicLayout(); |
112 | - Welcome welcome = new Welcome("Pick a book.", "Open a comic book to start reading."); |
113 | + Granite.Widgets.Welcome welcome; |
114 | |
115 | // Toolbar elements |
116 | - Toolbar toolbar = new Toolbar(); |
117 | - ToolButton bookmarks; |
118 | - ToolButton lens; |
119 | - ModeButton mangaMode = new ModeButton(); |
120 | + Gtk.Toolbar toolbar = new Gtk.Toolbar(); |
121 | + Gtk.ToolButton bookmarks; |
122 | + Gtk.ToolButton lens; |
123 | + Granite.Widgets.ModeButton mangaMode; |
124 | ElementaryWidgets.TopDisplay topdisplay; |
125 | - Image thumbnail; |
126 | - Label thumbnail_number; |
127 | - ToolItem topdisplay_item = new ToolItem(); |
128 | - ModeButton viewMode = new ModeButton(); |
129 | - Menu menu = new Menu(); |
130 | - CheckMenuItem rotate_menuitem; |
131 | - CheckMenuItem clockwise_menuitem; |
132 | - CheckMenuItem fullscreen_menuitem; |
133 | - AppMenu appMenu; |
134 | - TargetEntry[] dnd_list; |
135 | + Gtk.Image thumbnail; |
136 | + Gtk.Label thumbnail_number; |
137 | + Gtk.ToolItem topdisplay_item = new Gtk.ToolItem(); |
138 | + Granite.Widgets.ModeButton viewMode; |
139 | + Gtk.Menu menu; |
140 | + Gtk.CheckMenuItem rotate_menuitem; |
141 | + Gtk.CheckMenuItem clockwise_menuitem; |
142 | + Gtk.CheckMenuItem fullscreen_menuitem; |
143 | + Granite.Widgets.AppMenu appMenu; |
144 | + Gtk.TargetEntry[] dnd_list; |
145 | |
146 | // Preferences |
147 | string theme; |
148 | @@ -97,6 +91,12 @@ |
149 | * Creates a Strip window. |
150 | */ |
151 | public StripWindow (string? path = "", Granite.Application app) { |
152 | + |
153 | + menu = new Gtk.Menu(); |
154 | + welcome = new Granite.Widgets.Welcome("Pick a book.", "Open a comic book to start reading."); |
155 | + mangaMode = new Granite.Widgets.ModeButton(); |
156 | + viewMode = new Granite.Widgets.ModeButton(); |
157 | + |
158 | // Set settings |
159 | settings = new GLib.Settings("apps.strip-comicreader.settings"); |
160 | manga = settings.get_boolean("manga"); |
161 | @@ -138,37 +138,37 @@ |
162 | last_path = bookmark.get_string("path"); |
163 | last_page = bookmark.get_int("page"); |
164 | |
165 | - events |= EventMask.ALL_EVENTS_MASK; |
166 | + events |= Gdk.EventMask.ALL_EVENTS_MASK; |
167 | //~ TargetEntry[] dnd_list; |
168 | //~ // Python |
169 | //~ ( gtk.DEST_DEFAULT_MOTION | |
170 | //~ gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, |
171 | //~ dnd_list, gtk.gdk.ACTION_COPY) |
172 | -//~ drag_dest_set(this, DestDefaults.ALL, new TargetEntry(), new DragAction()); |
173 | - drag_dest_set(this, DestDefaults.ALL, dnd_list, DragAction.COPY); |
174 | +//~ drag_dest_set(this, Gtk.DestDefaults.ALL, new Gtk.TargetEntry(), new Gtk.DragAction()); |
175 | + Gtk.drag_dest_set(this, Gtk.DestDefaults.ALL, dnd_list, Gdk.DragAction.COPY); |
176 | |
177 | //Window properties |
178 | set_title("Strip"); |
179 | set_size_request(600, 400); |
180 | |
181 | // Bookmarks |
182 | - bookmarks = new ToolButton(new Image.from_stock("gtk-about", IconSize.BUTTON), "Bookmarks"); |
183 | - var bookmarks_item = new ToolItem(); |
184 | + bookmarks = new Gtk.ToolButton(new Gtk.Image.from_stock("gtk-about", Gtk.IconSize.BUTTON), "Bookmarks"); |
185 | + var bookmarks_item = new Gtk.ToolItem(); |
186 | bookmarks_item.add(bookmarks); |
187 | bookmarks.set_tooltip_text("Bookmarks"); |
188 | |
189 | // Lens |
190 | - lens = new ToolButton(new Image.from_stock("gtk-find", IconSize.BUTTON), "Lens"); |
191 | - var lens_item = new ToolItem(); |
192 | + lens = new Gtk.ToolButton(new Gtk.Image.from_stock("gtk-find", Gtk.IconSize.BUTTON), "Lens"); |
193 | + var lens_item = new Gtk.ToolItem(); |
194 | lens_item.add(lens); |
195 | lens.set_tooltip_text("Lens"); |
196 | |
197 | // Manga ModeButton |
198 | - var mangaMode_manga_image = new Image.from_file(PIXMAP_DIR + theme + "/view-direction-manga.svg"); |
199 | - var mangaMode_comic_image = new Image.from_file(PIXMAP_DIR + theme + "/view-direction-comic.svg"); |
200 | + var mangaMode_manga_image = new Gtk.Image.from_file(Resources.PIXMAP_DIR + theme + "/view-direction-manga.svg"); |
201 | + var mangaMode_comic_image = new Gtk.Image.from_file(Resources.PIXMAP_DIR + theme + "/view-direction-comic.svg"); |
202 | mangaMode.append(mangaMode_manga_image); |
203 | mangaMode.append(mangaMode_comic_image); |
204 | - var mangaMode_item = new ToolItem(); |
205 | + var mangaMode_item = new Gtk.ToolItem(); |
206 | mangaMode_item.set_border_width(6); |
207 | mangaMode_item.add(mangaMode); |
208 | mangaMode_item.set_tooltip_text("Reading direction"); |
209 | @@ -178,9 +178,9 @@ |
210 | topdisplay.set_sensitive(false); |
211 | topdisplay_item.set_expand(true); |
212 | topdisplay_item.add(topdisplay); |
213 | - thumbnail_number = new Label(""); |
214 | + thumbnail_number = new Gtk.Label(""); |
215 | thumbnail_number.show(); |
216 | - thumbnail = new Image(); |
217 | + thumbnail = new Gtk.Image(); |
218 | thumbnail.show(); |
219 | topdisplay.append(thumbnail_number); |
220 | topdisplay.append(thumbnail); |
221 | @@ -189,31 +189,31 @@ |
222 | topdisplay.set_inverted(manga); |
223 | |
224 | // View ModeButton |
225 | - var viewMode_double_image = new Image.from_file(PIXMAP_DIR + theme + "/view-mode-double.svg"); |
226 | - var viewMode_simple_image = new Image.from_file(PIXMAP_DIR + theme + "/view-mode-simple.svg"); |
227 | - var viewMode_width_image = new Image.from_file(PIXMAP_DIR + theme + "/view-mode-fitwidth.svg"); |
228 | + var viewMode_double_image = new Gtk.Image.from_file(Resources.PIXMAP_DIR + theme + "/view-mode-double.svg"); |
229 | + var viewMode_simple_image = new Gtk.Image.from_file(Resources.PIXMAP_DIR + theme + "/view-mode-simple.svg"); |
230 | + var viewMode_width_image = new Gtk.Image.from_file(Resources.PIXMAP_DIR + theme + "/view-mode-fitwidth.svg"); |
231 | viewMode.append(viewMode_double_image); |
232 | viewMode.append(viewMode_simple_image); |
233 | viewMode.append(viewMode_width_image); |
234 | - var viewMode_item = new ToolItem(); |
235 | + var viewMode_item = new Gtk.ToolItem(); |
236 | viewMode_item.set_border_width(6); |
237 | viewMode_item.add(viewMode); |
238 | viewMode_item.set_tooltip_text("View mode"); |
239 | |
240 | // Menu |
241 | menu.show_all(); |
242 | - var open_menuitem = new MenuItem.with_label("Open"); |
243 | - var informations_menuitem = new MenuItem.with_label("Information"); |
244 | - fullscreen_menuitem = new CheckMenuItem.with_label("Fullscreen"); |
245 | - rotate_menuitem = new CheckMenuItem.with_label("Rotate"); |
246 | - clockwise_menuitem = new CheckMenuItem.with_label("Clockwise"); |
247 | + var open_menuitem = new Gtk.MenuItem.with_label("Open"); |
248 | + var informations_menuitem = new Gtk.MenuItem.with_label("Information"); |
249 | + fullscreen_menuitem = new Gtk.CheckMenuItem.with_label("Fullscreen"); |
250 | + rotate_menuitem = new Gtk.CheckMenuItem.with_label("Rotate"); |
251 | + clockwise_menuitem = new Gtk.CheckMenuItem.with_label("Clockwise"); |
252 | rotate_menuitem.set_active(rotate); |
253 | clockwise_menuitem.set_active(clockwise); |
254 | -//~ var about_menuitem = new MenuItem.with_label("About"); |
255 | +//~ var about_menuitem = new Gtk.MenuItem.with_label("About"); |
256 | |
257 | menu.append(open_menuitem); |
258 | menu.append(informations_menuitem); |
259 | - menu.append(new SeparatorMenuItem()); |
260 | + menu.append(new Gtk.SeparatorMenuItem()); |
261 | menu.append(fullscreen_menuitem); |
262 | menu.append(rotate_menuitem); |
263 | menu.append(clockwise_menuitem); |
264 | @@ -222,7 +222,7 @@ |
265 | // AppMenu |
266 | //~ appMenu = new AppMenu(menu); |
267 | appMenu = app.create_appmenu(menu); |
268 | - var appMenu_item = new ToolItem(); |
269 | + var appMenu_item = new Gtk.ToolItem(); |
270 | appMenu_item.add(appMenu); |
271 | |
272 | // Toolbar |
273 | @@ -235,7 +235,7 @@ |
274 | toolbar.insert(appMenu_item, -1); |
275 | |
276 | // Basic UI |
277 | - var vbox = new VBox(false, 0); |
278 | + var vbox = new Gtk.VBox(false, 0); |
279 | add (vbox); |
280 | vbox.pack_start (toolbar, false, false); |
281 | vbox.pack_start (layout, true, true); |
282 | @@ -247,7 +247,7 @@ |
283 | layout.hide(); |
284 | welcome.append(Gtk.Stock.OPEN, "Open comic", "Open a comic book file."); |
285 | welcome.append("document-open-recent", "Last comic", "Read the last viewed comic book."); |
286 | - welcome.set_sensitive(1, last_path != ""); |
287 | + welcome.set_sensitive(true); // was: welcome.set_sensitive(1, last_path != ""); |
288 | welcome.show_all(); |
289 | |
290 | mangaMode.selected = (int) !manga; |
291 | @@ -430,7 +430,7 @@ |
292 | /** |
293 | * Called when the window's state change (size change, maximise, fullscreen...). |
294 | */ |
295 | - private bool on_window_state_event(EventWindowState event) { |
296 | + private bool on_window_state_event(Gdk.EventWindowState event) { |
297 | save_window_state(); |
298 | return false; |
299 | } |
300 | @@ -438,7 +438,7 @@ |
301 | private void save_window_state() { |
302 | if (fullscreen_menuitem.get_active()) |
303 | savedstate.set_enum("window-state", 2); |
304 | - else if (get_window().get_state() == WindowState.MAXIMIZED) |
305 | + else if (get_window().get_state() == Gdk.WindowState.MAXIMIZED) |
306 | savedstate.set_enum("window-state", 1); |
307 | else |
308 | savedstate.set_enum("window-state", 0); |
309 | @@ -494,7 +494,7 @@ |
310 | /** |
311 | * Called when something is dragded and dropped over the window. |
312 | */ |
313 | - private void on_drag_data_received(DragContext context, int x, int y, SelectionData selection_data, uint info, uint time_) { |
314 | + private void on_drag_data_received(Gdk.DragContext context, int x, int y, Gtk.SelectionData selection_data, uint info, uint time_) { |
315 | //~ // Python |
316 | //~ uri = selection.data.strip-comicreader('\r\n\x00') |
317 | //~ uri_splitted = uri.split() # we may have more than one file dropped |
318 | @@ -509,24 +509,24 @@ |
319 | */ |
320 | private void open() { |
321 | // Filters |
322 | - var filter = new FileFilter(); |
323 | + var filter = new Gtk.FileFilter(); |
324 | filter.set_name("Accepted files"); // FIXME |
325 | foreach (string i in Resources.IMAGE_TYPES) {filter.add_mime_type(i); } |
326 | foreach (string i in Resources.ARCHIVE_TYPES) {filter.add_mime_type(i); } |
327 | /* |
328 | - var imagefilter = new FileFilter(); |
329 | + var imagefilter = new Gtk.FileFilter(); |
330 | imagefilter.set_name("Images"); // FIXME |
331 | foreach (string i in Resources.IMAGE_TYPES) {imagefilter.add_mime_type(i); } |
332 | - var archivefilter = new FileFilter(); |
333 | + var archivefilter = new Gtk.FileFilter(); |
334 | archivefilter.set_name("Archives"); // FIXME |
335 | foreach (string i in Resources.ARCHIVE_TYPES) {archivefilter.add_mime_type(i); } |
336 | */ |
337 | string filename = ""; |
338 | - var filechooser = new FileChooserDialog("Title", this, FileChooserAction.OPEN, Stock.CANCEL, ResponseType.CANCEL, Stock.OPEN, ResponseType.OK); |
339 | + var filechooser = new Gtk.FileChooserDialog("Title", this, Gtk.FileChooserAction.OPEN, Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL, Gtk.Stock.OPEN, Gtk.ResponseType.OK); |
340 | // filechooser.add_filter(imagefilter); |
341 | // filechooser.add_filter(archivefilter); |
342 | filechooser.set_filter(filter); |
343 | - if (filechooser.run() == ResponseType.OK) |
344 | + if (filechooser.run() == Gtk.ResponseType.OK) |
345 | { |
346 | filename = filechooser.get_filename(); |
347 | } |
348 | @@ -566,7 +566,7 @@ |
349 | private void on_book_progress_notification(double percent, string text) { |
350 | if (percent == 0) { |
351 | layout.hide(); |
352 | - welcome.set_sensitive(1, last_path != ""); |
353 | + welcome.set_sensitive(true); // was: welcome.set_sensitive(1, last_path != ""); |
354 | welcome.show(); |
355 | topdisplay.set_sensitive(false); |
356 | topdisplay.setLabelText("Empty!"); |
357 | @@ -606,7 +606,7 @@ |
358 | /** |
359 | * Change the scale's thumbnail when it's pressed. |
360 | */ |
361 | - private void on_scale_value_changed(ScrollType scroll, double val) { |
362 | + private void on_scale_value_changed(Gtk.ScrollType scroll, double val) { |
363 | var adjustment = topdisplay.get_scale_adjustment(); |
364 | if (val >= adjustment.get_lower() && val <= adjustment.get_upper()) |
365 | { |
366 | @@ -618,7 +618,7 @@ |
367 | /** |
368 | * Change the current page when the scale button is released. |
369 | */ |
370 | - private void on_scale_button_release_event(EventButton button) { |
371 | + private void on_scale_button_release_event(Gdk.EventButton button) { |
372 | book.current_page = (int) topdisplay.getScaleValue(); |
373 | } |
374 | |
375 | @@ -650,8 +650,8 @@ |
376 | layout.first_pixbuf = book.get_pixbuf(book.current_page); |
377 | } |
378 | else { |
379 | - Pixbuf first_page = null; |
380 | - Pixbuf second_page = null; |
381 | + Gdk.Pixbuf first_page = null; |
382 | + Gdk.Pixbuf second_page = null; |
383 | if (first_number >= 0 && first_number < book.length) |
384 | if (!(!book.horizontal && book.get_page_horizontal(first_number))) |
385 | first_page = book.get_pixbuf(first_number); |
386 | @@ -682,7 +682,7 @@ |
387 | /** |
388 | * Check the keyboard key pressed. |
389 | */ |
390 | - private bool on_key_press_event(EventKey event) { |
391 | + private bool on_key_press_event(Gdk.EventKey event) { |
392 | //~ switch (Gdk.keyval_name(event.keyval)) |
393 | //~ { |
394 | //~ case "r" |
395 | @@ -738,7 +738,7 @@ |
396 | /** |
397 | * Check the keyboard key released (for modifier keys). |
398 | */ |
399 | - private bool on_key_release_event(EventKey event) { |
400 | + private bool on_key_release_event(Gdk.EventKey event) { |
401 | string key = Gdk.keyval_name(event.keyval); |
402 | if (key == "Control_L") |
403 | ctrlL = false; |
404 | @@ -754,12 +754,12 @@ |
405 | private void set_rotation_mode() { |
406 | if (rotate) { |
407 | if (clockwise) |
408 | - layout.rotation = PixbufRotation.CLOCKWISE; |
409 | + layout.rotation = Gdk.PixbufRotation.CLOCKWISE; |
410 | else |
411 | - layout.rotation = PixbufRotation.COUNTERCLOCKWISE; |
412 | + layout.rotation = Gdk.PixbufRotation.COUNTERCLOCKWISE; |
413 | } |
414 | else |
415 | - layout.rotation = PixbufRotation.NONE; |
416 | + layout.rotation = Gdk.PixbufRotation.NONE; |
417 | refresh(); |
418 | } |
419 |