Skip to content
Permalink
Browse files
fix missing scroll bar in view source
On Fedora 18, scroll bars were missing, #4903.

On Fedora 20, impossible arguments were given to X server, resulting in
desktop instability.  dev.laptop.org #12872.

Regression introduced in 4be3f9e and #4273, in the SourceDisplay class,
where a GtkBox is inserted between the GtkScrolledWindow and any child.

Fix is

- remove GtkBox intermediary; unnecessary,

- add methods for managing a single child of the GtkScrolledWindow,
  which will be either a GtkSourceView or a GtkEventBox in a
  GtkViewport,

- remove some GtkWidget.show calls; made redundant by .show_all,
  • Loading branch information
quozl committed Nov 4, 2015
1 parent 257757e commit d6cc2de
Showing 1 changed file with 21 additions and 18 deletions.
@@ -706,18 +706,23 @@ def __init__(self):
self.props.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC
self.props.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC

self._box = Gtk.Box()
self.add(self._box)
self._box.show()

self._file_path = None

def _replace(self, child):
self._remove_children()
self.add(child)

def _replace_with_viewport(self, child):
self._remove_children()
self.add_with_viewport(child)

def _remove_children(self):
for child in self.get_children():
self.remove(child)

def _set_file_path(self, file_path):
self._file_path = file_path

for child in self._box.get_children():
self._box.remove(child)

if self._file_path is None:
self._show_no_file()
return
@@ -765,16 +770,16 @@ def _show_text_viewer(self):

source_buffer.set_language(detected_language)
text = open(self._file_path, 'r').read()
works = True
try:
text.encode()
source_buffer.set_text(text)
self._box.pack_start(source_view, True, True, 0)
self._box.show_all()
except UnicodeDecodeError:
works = False
return False

source_view.show()
self._replace(source_view)

return works
return True

def _get_file_path(self):
return self._file_path
@@ -790,16 +795,14 @@ def _show_image_viewer(self, icon=None, image=False):
pixbuf = GdkPixbuf.Pixbuf.new_from_file(self._file_path)
image.set_from_pixbuf(pixbuf)
media_box.add(image)
image.show()

if icon:
h = Gdk.Screen.width() / 3
icon = Icon(icon_name=icon, pixel_size=h)
media_box.add(icon)
icon.show()

self._box.pack_start(media_box, True, True, 0)
self._box.show_all()
media_box.show_all()
self._replace_with_viewport(media_box)

def _show_no_file(self):
nofile_label = Gtk.Label()
@@ -809,5 +812,5 @@ def _show_no_file(self):
nofile_box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('white'))

nofile_box.add(nofile_label)
self._box.pack_start(nofile_box, True, True, 0)
self._box.show_all()
nofile_box.show_all()
self._replace_with_viewport(nofile_box)

0 comments on commit d6cc2de

Please sign in to comment.