1- # Copyright (C) 2013 Kai Willadsen <kai.willadsen@gmail.com>
1+ # Copyright (C) 2013-2014 Kai Willadsen <kai.willadsen@gmail.com>
22#
33# This program is free software: you can redistribute it and/or modify
44# it under the terms of the GNU General Public License as published by
1717from gi .repository import GtkSource
1818
1919from meld .conf import _
20+ from meld .const import MODE_REPLACE , MODE_DELETE , MODE_INSERT
2021
22+ # Fixed size of the renderer. Ideally this would be font-dependent and
23+ # would adjust to other textview attributes, but that's both quite difficult
24+ # and not necessarily desirable.
25+ LINE_HEIGHT = 16
2126
22- # FIXME: This is obviously beyond horrible
23- line_height = 16
24- icon_theme = Gtk .IconTheme .get_default ()
25- load = lambda x : icon_theme .load_icon (x , line_height , 0 )
26- pixbuf_apply0 = load ("meld-change-apply-right" )
27- pixbuf_apply1 = load ("meld-change-apply-left" )
28- pixbuf_delete = load ("meld-change-delete" )
29- pixbuf_copy = load ("meld-change-copy" )
3027
31- # FIXME: import order issues
32- MODE_REPLACE , MODE_DELETE , MODE_INSERT = 0 , 1 , 2
28+ def load (icon_name ):
29+ icon_theme = Gtk .IconTheme .get_default ()
30+ return icon_theme .load_icon (icon_name , LINE_HEIGHT , 0 )
3331
3432
3533class GutterRendererChunkAction (GtkSource .GutterRendererPixbuf ):
3634 __gtype_name__ = "GutterRendererChunkAction"
3735
3836 ACTION_MAP = {
3937 'LTR' : {
40- MODE_REPLACE : pixbuf_apply0 ,
41- MODE_DELETE : pixbuf_delete ,
42- MODE_INSERT : pixbuf_copy ,
38+ MODE_REPLACE : load ( "meld-change-apply-right" ) ,
39+ MODE_DELETE : load ( "meld-change-delete" ) ,
40+ MODE_INSERT : load ( "meld-change-copy" ) ,
4341 },
4442 'RTL' : {
45- MODE_REPLACE : pixbuf_apply1 ,
46- MODE_DELETE : pixbuf_delete ,
47- MODE_INSERT : pixbuf_copy ,
43+ MODE_REPLACE : load ( "meld-change-apply-left" ) ,
44+ MODE_DELETE : load ( "meld-change-delete" ) ,
45+ MODE_INSERT : load ( "meld-change-copy" ) ,
4846 }
4947 }
5048
@@ -58,7 +56,7 @@ def __init__(self, from_pane, to_pane, views, filediff, linediffer):
5856 # FIXME: Don't pass in the linediffer; pass a generator like elsewhere
5957 self .linediffer = linediffer
6058 self .mode = MODE_REPLACE
61- self .set_size (line_height )
59+ self .set_size (LINE_HEIGHT )
6260 direction = 'LTR' if from_pane < to_pane else 'RTL'
6361 self .action_map = self .ACTION_MAP [direction ]
6462 self .filediff = filediff
0 commit comments