[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk
Subject:    Custom GtkTextBuffer objects - virtually impossible?
From:       Mike Birch <Mike () ImmortalSoFar ! com>
Date:       2015-03-23 4:35:31
Message-ID: 1427085331.2894.52.camel () mike-mini
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I'm not an expert (or a particular fan) of MVC architecture but I
thought the idea was to disengage the storage from the display. Writing
a custom GtkTextBuffer should be relatively straight forward (or as
straight forward as deriving a new GObject ever is) but having examined
the source, it would appear that because of the number of hard-coded
"helper" functions that are not part of the object, it is virtually
impossible to disentangle it from GtkTextView.

For example, GtkTextView, quite understandably, calls
gtk_text_buffer_get_insert (). This function is a hard-coded,
non-overrideable reference to _gtk_text_btree_get_insert (). Why? The
architecture should not care *how* the information is stored, just that
it is accessible.

This is assuming that the data is, by nature, textual which is not a
valid assumption. My data is not, the text is generated but in such a
way that in any given state I can say exactly how many character *would*
be generated and what characters or text would be produced from any
given offset.

Let's take a really simple (although, admittedly, not very useful)
example - an infinite Pi view which holds every single digit of Pi. It
is mathematically possible to calculate the value of any digit from its
position so the "buffer" can calculate what to display at any given
position of Pi at the view's request. Similarly, it can search for, for
example, your phone number. Maybe the buffer calculates the text, maybe
it goes off to the internet and fetches it when needed, maybe it just
produces random garbage - that's the text buffer's job and all the view
has to do is display it.

Am I missing something? Surely, the idea is to connect any model with a
conformant interface to the view (perhaps via the controller). Isn't
GtkTextBuffer supposed to be overrideable?

Mike.


[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.6.6">
</HEAD>
<BODY>
I'm not an expert (or a particular fan) of MVC architecture but I thought the idea \
was to disengage the storage from the display. Writing a custom GtkTextBuffer should \
be relatively straight forward (or as straight forward as deriving a new GObject ever \
is) but having examined the source, it would appear that because of the number of \
hard-coded &quot;helper&quot; functions that are not part of the object, it is \
virtually impossible to disentangle it from GtkTextView.<BR> <BR>
For example, GtkTextView, quite understandably, calls gtk_text_buffer_get_insert<TT> \
(). This function is a hard-coded, non-overrideable reference to \
</TT>_gtk_text_btree_get_insert<TT> (). Why? The architecture should not care *how* \
the information is stored, just that it is accessible.</TT><BR> <BR>
This is assuming that the data is, by nature, textual which is not a valid \
assumption. My data is not, the text is generated but in such a way that in any given \
state I can say exactly how many character *would* be generated and what characters \
or text would be produced from any given offset.<BR> <BR>
Let's take a really simple (although, admittedly, not very useful) example - an \
infinite Pi view which holds every single digit of Pi. It is mathematically possible \
to calculate the value of any digit from its position so the &quot;buffer&quot; can \
calculate what to display at any given position of Pi at the view's request. \
Similarly, it can search for, for example, your phone number. Maybe the buffer \
calculates the text, maybe it goes off to the internet and fetches it when needed, \
maybe it just produces random garbage - that's the text buffer's job and all the view \
has to do is display it.<BR> <BR>
Am I missing something? Surely, the idea is to connect any model with a conformant \
interface to the view (perhaps via the controller). Isn't GtkTextBuffer supposed to \
be overrideable?<BR> <BR>
Mike.<BR>
<BR>
</BODY>
</HTML>



_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic