Commit 56d4b275 authored by Kai Willadsen's avatar Kai Willadsen

filediff, ui.statusbar: Add encoding-changed signal and hook it up

With the other API changes and cleanups around file loading, this is now
straightforward: just add a signal, emit it and have FileDiff listen and
reload files with their new encoding when it fires.
parent 752c01e1
......@@ -232,6 +232,12 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
'encoding', statusbar, 'source-encoding',
GObject.BindingFlags.DEFAULT)
def reload_with_encoding(widget, encoding, pane):
self.set_file(pane, self.textbuffer[pane].data.gfile, encoding)
pane = self.statusbar.index(statusbar)
statusbar.connect('encoding-changed', reload_with_encoding, pane)
# Prototype implementation
from meld.gutterrendererchunk import GutterRendererChunkAction, GutterRendererChunkLines
......
......@@ -101,6 +101,11 @@ class MeldStatusMenuButton(Gtk.MenuButton):
class MeldStatusBar(Gtk.Statusbar):
__gtype_name__ = "MeldStatusBar"
__gsignals__ = {
'encoding-changed': (
GObject.SignalFlags.RUN_FIRST, None, (GtkSource.Encoding,)),
}
source_encoding = GObject.property(
type=GtkSource.Encoding,
nick="The file encoding displayed in the status bar",
......@@ -142,6 +147,7 @@ class MeldStatusBar(Gtk.Statusbar):
def construct_encoding_selector(self):
def change_encoding(selector, encoding):
self.props.source_encoding = encoding
self.emit('encoding-changed', encoding)
pop.hide()
def set_initial_encoding(selector):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment