InfTextGtkView

InfTextGtkView — Drawing remote cursors and selections in a GtkTextView

Stability Level

Unstable, unless otherwise indicated

Synopsis

#include <libinftextgtk/inf-text-gtk-view.h>

                    InfTextGtkView;
struct              InfTextGtkViewClass;
InfTextGtkView *    inf_text_gtk_view_new               (InfIo *io,
                                                         GtkTextView *view,
                                                         InfUserTable *user_table);
GtkTextView *       inf_text_gtk_view_get_text_view     (InfTextGtkView *view);
InfUserTable *      inf_text_gtk_view_get_user_table    (InfTextGtkView *view);
void                inf_text_gtk_view_set_active_user   (InfTextGtkView *view,
                                                         InfTextUser *user);
InfTextUser *       inf_text_gtk_view_get_active_user   (InfTextGtkView *view);
void                inf_text_gtk_view_set_show_remote_cursors
                                                        (InfTextGtkView *view,
                                                         gboolean show);
void                inf_text_gtk_view_set_show_remote_selections
                                                        (InfTextGtkView *view,
                                                         gboolean show);
void                inf_text_gtk_view_set_show_remote_current_lines
                                                        (InfTextGtkView *view,
                                                         gboolean show);

Object Hierarchy

  GObject
   +----InfTextGtkView

Properties

  "active-user"              InfTextUser*          : Read / Write
  "io"                       InfIo*                : Read / Write / Construct Only
  "show-remote-current-lines" gboolean              : Read / Write
  "show-remote-cursors"      gboolean              : Read / Write
  "show-remote-selections"   gboolean              : Read / Write
  "user-table"               InfUserTable*         : Read / Write / Construct Only
  "view"                     GtkTextView*          : Read / Write / Construct Only

Description

InfTextGtkView is a helper object which, as long as it is alive, draws the cursor position, selected text of remote users into a GtkTextView widget. It can also highlight the current line of a remote user in a similar way the GtkSourceView widget can highlight the current line of the local user.

This functionality was not implemented by subclassing GtkTextView such that it can also be used with existing subclasses, such as GtkSourceView.

With the function inf_text_gtk_view_set_active_user() the local InfTextUser who is editing the text can be set, if there is any. The insertion position, seleceted text or current line are not drawn for this user, since the normal GtkTextView takes care of that already. This assumes the local user cursor position and selection is synchronized to the corresponding InfTextUser properties, which is automatically the case when a InfTextGtkBuffer is used for the buffer the GtkTextView is displaying.

See InfTextGtkViewport for drawing a marker at remote users' location into the scrollbar.

Details

InfTextGtkView

typedef struct _InfTextGtkView InfTextGtkView;

InfTextGtkView is an opaque data type. You should only access it via the public API functions.


struct InfTextGtkViewClass

struct InfTextGtkViewClass {
};

This structure does not contain any public fields.


inf_text_gtk_view_new ()

InfTextGtkView *    inf_text_gtk_view_new               (InfIo *io,
                                                         GtkTextView *view,
                                                         InfUserTable *user_table);

Creates a new InfTextGtkView for view. This draws remote user's cursors and selections into the text view.

io :

A InfIo.

view :

A GtkTextView.

user_table :

The InfUserTable for the text session displayed in view.

Returns :

A new InfTextGtkView.

inf_text_gtk_view_get_text_view ()

GtkTextView *       inf_text_gtk_view_get_text_view     (InfTextGtkView *view);

Returns the underlying GtkTextView.

view :

A InfTextGtkView.

Returns :

The InfTextGtkView's GtkTextView.

inf_text_gtk_view_get_user_table ()

InfUserTable *      inf_text_gtk_view_get_user_table    (InfTextGtkView *view);

Returns the InfUserTable containing the users of the session the InfTextGtkView's GtkTextView is displaying.

view :

A InfTextGtkView.

Returns :

The InfTextGtkView's InfUserTable.

inf_text_gtk_view_set_active_user ()

void                inf_text_gtk_view_set_active_user   (InfTextGtkView *view,
                                                         InfTextUser *user);

Sets the user for which perspective to draw the view. The selection and cursor position is not drawn for this user since it is assumed that the view's buffer cursor position and selection match the active user ones (which is automatically the case if the buffer is managed by a InfTextGtkBuffer).

view :

A InfTextGtkView.

user :

A user from view's user table, or NULL.

inf_text_gtk_view_get_active_user ()

InfTextUser *       inf_text_gtk_view_get_active_user   (InfTextGtkView *view);

Returns the active user of view. See inf_text_gtk_view_set_active_user().

view :

A InfTextGtkView.

Returns :

The active user of view.

inf_text_gtk_view_set_show_remote_cursors ()

void                inf_text_gtk_view_set_show_remote_cursors
                                                        (InfTextGtkView *view,
                                                         gboolean show);

If show is TRUE then view draws a cursor for each non-local user in INF_USER_ACTIVE status in that user's color into its underlying GtkTextView. If it is FALSE then remote cursors are not drawn.

view :

A InfTextGtkView.

show :

Whether to show cursors of non-local users.

inf_text_gtk_view_set_show_remote_selections ()

void                inf_text_gtk_view_set_show_remote_selections
                                                        (InfTextGtkView *view,
                                                         gboolean show);

If show is TRUE then view draws the selection ranges for each non-local user in INF_USER_ACTIVE status. The selection range is drawn shaded in that user's color on top of the author color which indicates who wrote the selected text. If more than one user has a given piece of text selected then an alternating stripe pattern with each of the user's colors is drawn. If show is FALSE then selection ranges of remote users are not drawn.

view :

A InfTextGtkView.

show :

Whether to show selections of non-local users.

inf_text_gtk_view_set_show_remote_current_lines ()

void                inf_text_gtk_view_set_show_remote_current_lines
                                                        (InfTextGtkView *view,
                                                         gboolean show);

If show is TRUE then all lines in which the cursor of a non-local user in INF_USER_ACTIVE status is is highlighted with that user's color, similar to GtkSourceView's "highlight current line" functionality. If it is FALSE then the current line of non-local users is not highlighted.

view :

A InfTextGtkView.

show :

Whether to highlight the current line of non-local users.

Property Details

The "active-user" property

  "active-user"              InfTextUser*          : Read / Write

The user for which to show the view.


The "io" property

  "io"                       InfIo*                : Read / Write / Construct Only

The IO object to schedule timeouts.


The "show-remote-current-lines" property

  "show-remote-current-lines" gboolean              : Read / Write

Whether to highlight the line in which the cursor of non-local users is.

Default value: TRUE


The "show-remote-cursors" property

  "show-remote-cursors"      gboolean              : Read / Write

Whether to show cursors of non-local users.

Default value: TRUE


The "show-remote-selections" property

  "show-remote-selections"   gboolean              : Read / Write

Whether to highlight text selected by non-local users.

Default value: TRUE


The "user-table" property

  "user-table"               InfUserTable*         : Read / Write / Construct Only

The user table containing the users of the session shown in the view.


The "view" property

  "view"                     GtkTextView*          : Read / Write / Construct Only

The underlying GtkTextView.

See Also

InfTextGtkBuffer, InfTextGtkViewport