On Jul 25, 2014 8:40 AM, "Christoph Brill" <[email protected]> wrote:
>
> From my understanding having a GObject.property is kind of redundant to a
global GSettings. I
> simply might be mistaken, feel free to correct me :-)
> ---
>  meld/filediff.py | 18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/meld/filediff.py b/meld/filediff.py
> index be3f6c8..9e57f80 100644
> --- a/meld/filediff.py
> +++ b/meld/filediff.py
> @@ -141,19 +141,6 @@ class FileDiff(melddoc.MeldDoc,
gnomeglade.Component):
>
>      __gtype_name__ = "FileDiff"
>
> -    __gsettings_bindings__ = (
> -        ('highlight-current-line', 'highlight-current-line'),
> -        ('ignore-blank-lines', 'ignore-blank-lines'),
> -    )
> -
> -    highlight_current_line = GObject.property(type=bool, default=False)
> -    ignore_blank_lines = GObject.property(
> -        type=bool,
> -        nick="Ignore blank lines",
> -        blurb="Whether to ignore blank lines when comparing file
contents",
> -        default=False,
> -    )
> -
>      differ = diffutil.Differ
>
>      keylookup = {
> @@ -176,7 +163,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
>          """
>          melddoc.MeldDoc.__init__(self)
>          gnomeglade.Component.__init__(self, "filediff.ui", "filediff")
> -        bind_settings(self)
>
>          widget_lists = [
>              "diffmap", "file_save_button", "file_toolbar", "fileentry",
> @@ -1201,7 +1187,7 @@ class FileDiff(melddoc.MeldDoc,
gnomeglade.Component):
>      def _diff_files(self, refresh=False):
>          yield _("[%s] Computing differences") % self.label_text
>          texts = self.buffer_filtered[:self.num_panes]
> -        self.linediffer.ignore_blanks = self.props.ignore_blank_lines
> +        self.linediffer.ignore_blanks =
settings.get_boolean('ignore-blank-lines')
>          step = self.linediffer.set_sequences_iter(texts)
>          while next(step) is None:
>              yield 1
> @@ -1539,7 +1525,7 @@ class FileDiff(melddoc.MeldDoc,
gnomeglade.Component):
>              context.set_source_rgba(*self.line_colors[change[0]])
>              context.stroke()
>
> -        if (self.props.highlight_current_line and textview.is_focus() and
> +        if (settings.get_boolean('highlight-current-line') and
textview.is_focus() and
>                  self.cursor.line is not None):
>              it = textbuffer.get_iter_at_line(self.cursor.line)
>              ypos, line_height = textview.get_line_yrange(it)
> --

This is a bit of a personal choice thing, but certainly a 'correct' way to
handle gsettings is to bind to a gobject property. This has additional
benefits like being able to expose these properties to other users of the
object easily, as well as documenting their use.

Now granted, i'm not sure whether we make any use of these properties in
this manner, but as a matter of principle I'd tend to prefer this idiom.
Thanks anyway.

Cheers
Kai
_______________________________________________
meld-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/meld-list

Reply via email to