GscCompletion

GscCompletion — Main Completion Object

Synopsis

#define             DEFAULT_PAGE
gboolean            (*GscCompletionFilterFunc)          (GscProposal *proposal,
                                                         gpointer user_data);
                    GscCompletionPriv;
                    GscCompletion;
                    GscCompletionClass;
GscCompletion *     gsc_completion_get_from_view        (GtkTextView *view);
GtkWidget *         gsc_completion_new                  (GtkTextView *view);
GtkTextView *       gsc_completion_get_view             (GscCompletion *self);
GscTrigger *        gsc_completion_get_trigger          (GscCompletion *self,
                                                         const gchar *trigger_name);
GscProvider *       gsc_completion_get_provider         (GscCompletion *self,
                                                         const gchar *prov_name);
gboolean            gsc_completion_register_provider    (GscCompletion *self,
                                                         GscProvider *provider,
                                                         GscTrigger *trigger);
gboolean            gsc_completion_unregister_provider  (GscCompletion *self,
                                                         GscProvider *provider,
                                                         GscTrigger *trigger);
gboolean            gsc_completion_register_trigger     (GscCompletion *self,
                                                         GscTrigger *trigger);
gboolean            gsc_completion_unregister_trigger   (GscCompletion *self,
                                                         GscTrigger *trigger);
GscTrigger *        gsc_completion_get_active_trigger   (GscCompletion *self);
gboolean            gsc_completion_trigger_event        (GscCompletion *self,
                                                         GscTrigger *trigger);
void                gsc_completion_finish_completion    (GscCompletion *self);
void                gsc_completion_filter_proposals     (GscCompletion *self,
                                                         GscCompletionFilterFunc func,
                                                         gpointer user_data);
void                gsc_completion_set_active           (GscCompletion *self,
                                                         gboolean active);
gboolean            gsc_completion_get_active           (GscCompletion *self);
GtkWidget *         gsc_completion_get_bottom_bar       (GscCompletion *self);
GscInfo *           gsc_completion_get_info_widget      (GscCompletion *self);
gint                gsc_completion_get_page_pos         (GscCompletion *self,
                                                         const gchar *page_name);
gint                gsc_completion_get_n_pages          (GscCompletion *self);
gboolean            gsc_completion_set_page_pos         (GscCompletion *self,
                                                         const gchar *page_name,
                                                         gint position);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GtkBin
                                 +----GtkWindow
                                       +----GscCompletion

Implemented Interfaces

GscCompletion implements AtkImplementorIface and GtkBuildable.

Properties

  "active"                   gboolean              : Read / Write
  "manage-completion-keys"   gboolean              : Read / Write
  "remember-info-visibility" gboolean              : Read / Write
  "select-on-show"           gboolean              : Read / Write

Signals

  "display-info"                                   : Run Last / Action
  "proposal-selected"                              : Run Last / Action

Description

This is the main completion object. It manages all providers (GscProvider) and triggers (GscTrigger) for a GtkTextView..

Details

DEFAULT_PAGE

#define DEFAULT_PAGE "Default"


GscCompletionFilterFunc ()

gboolean            (*GscCompletionFilterFunc)          (GscProposal *proposal,
                                                         gpointer user_data);

proposal :

user_data :

Returns :


GscCompletionPriv

typedef struct {
	/* Widget and popup variables*/
	GtkWidget *info_window;
	GtkWidget *info_button;
	GtkWidget *notebook;
	GtkWidget *tab_label;
	GtkWidget *next_page_button;
	GtkWidget *prev_page_button;
	GtkWidget *bottom_bar;
	
	GList *pages;
	GscCompletionPage *active_page;
	gboolean destroy_has_run;
	gboolean manage_keys;
	gboolean remember_info_visibility;
	gboolean info_visible;
	gboolean select_on_show;
	
	/* Completion management */
	GtkTextView *view;
	GList *triggers;
	GList *prov_trig;
	GscTrigger *active_trigger;
	
	/*TRUE if the completion mechanism is active*/
	gboolean active;
	gulong signals_ids[LAST_EXTERNAL_SIGNAL];
} GscCompletionPriv;


GscCompletion

typedef struct _GscCompletion GscCompletion;


GscCompletionClass

typedef struct {
	GtkWindowClass parent_class;

	gboolean (* proposal_selected)(GscCompletion *completion,
				       GscProposal *proposal);
	gboolean (* display_info)     (GscCompletion *completion,
				       GscProposal *proposal);
} GscCompletionClass;


gsc_completion_get_from_view ()

GscCompletion *     gsc_completion_get_from_view        (GtkTextView *view);

view :

The GtkTextView associated with a GscCompletion

Returns :

The GscCompletion associated with a view or NULL.

gsc_completion_new ()

GtkWidget *         gsc_completion_new                  (GtkTextView *view);

view :

Returns :

The new GscCompletion

gsc_completion_get_view ()

GtkTextView *       gsc_completion_get_view             (GscCompletion *self);

self :

The GscCompletion

Returns :

The view associated with this completion.

gsc_completion_get_trigger ()

GscTrigger *        gsc_completion_get_trigger          (GscCompletion *self,
                                                         const gchar *trigger_name);

self :

The GscCompletion

trigger_name :

The trigger name to find

Returns :

The GscTrigger registered with trigger_name, NULL if it cannot be found

gsc_completion_get_provider ()

GscProvider *       gsc_completion_get_provider         (GscCompletion *self,
                                                         const gchar *prov_name);

self :

The GscCompletion

prov_name :

The provider name to find

Returns :

The GscProvider registered with prov_name

gsc_completion_register_provider ()

gboolean            gsc_completion_register_provider    (GscCompletion *self,
                                                         GscProvider *provider,
                                                         GscTrigger *trigger);

This function register the provider into the completion and reference it. When an event is raised, completion call to the provider to get the data. When the user select a proposal, it call the provider to tell it this action and the provider do that it want (normally inserts some text)

self :

the GscCompletion

provider :

The GscProvider.

trigger :

Returns :

TRUE if it was registered or FALSE if not (because it has been already registered, or the trigger doesn't exists)

gsc_completion_unregister_provider ()

gboolean            gsc_completion_unregister_provider  (GscCompletion *self,
                                                         GscProvider *provider,
                                                         GscTrigger *trigger);

This function unregister the provider.

self :

the GscCompletion

provider :

The GscProvider.

trigger :

The trigger what you want to unregister this provider

Returns :

TRUE if it was unregistered or FALSE if not (because it doesn't exists, or the trigger don't exists)

gsc_completion_register_trigger ()

gboolean            gsc_completion_register_trigger     (GscCompletion *self,
                                                         GscTrigger *trigger);

This function register a completion trigger. If the completion is actived then this method activate the trigger. This function reference the trigger object

self :

The GscCompletion

trigger :

The trigger to register

Returns :

TRUE if the trigger has been registered

gsc_completion_unregister_trigger ()

gboolean            gsc_completion_unregister_trigger   (GscCompletion *self,
                                                         GscTrigger *trigger);

This function unregister a completion trigger. If the completion is actived then this method deactivate the trigger. This function unreference the trigger object

self :

The GscCompletion

trigger :

The trigger to unregister

Returns :

TRUE if the trigger has been unregistered or FALSE if not (because the trigger has not been registered)

gsc_completion_get_active_trigger ()

GscTrigger *        gsc_completion_get_active_trigger   (GscCompletion *self);

This function return the active trigger. The active trigger is the last trigger raised if the completion is active. If the completion is not visible then there is no an active trigger.

self :

The GscCompletion

Returns :

The trigger or NULL if completion is not active

gsc_completion_trigger_event ()

gboolean            gsc_completion_trigger_event        (GscCompletion *self,
                                                         GscTrigger *trigger);

Calling this function, the completion call to all providers to get data and, if they return data, it shows the completion to the user.

self :

the GscCompletion

trigger :

The trigger who trigger the event

Returns :

TRUE if the event has been triggered, FALSE if not

gsc_completion_finish_completion ()

void                gsc_completion_finish_completion    (GscCompletion *self);

This function finish the completion if it is active (visible).

self :

The GscCompletion

gsc_completion_filter_proposals ()

void                gsc_completion_filter_proposals     (GscCompletion *self,
                                                         GscCompletionFilterFunc func,
                                                         gpointer user_data);

This function call to func for all proposal of all pages. func must return TRUE if the proposal is visible or FALSE if the completion must to hide the proposal.

self :

the GscCompletion

func :

function to filter the proposals visibility

user_data :

user data to pass to func

gsc_completion_set_active ()

void                gsc_completion_set_active           (GscCompletion *self,
                                                         gboolean active);

This function activate/deactivate the completion mechanism. The completion connects/disconnect all signals and activate/deactivate all registered triggers.

self :

The GscCompletion

active :

TRUE if you want to activate the completion mechanism.

gsc_completion_get_active ()

gboolean            gsc_completion_get_active           (GscCompletion *self);

self :

The GscCompletion

Returns :

TRUE if the completion mechanism is active, FALSE if not.

gsc_completion_get_bottom_bar ()

GtkWidget *         gsc_completion_get_bottom_bar       (GscCompletion *self);

The bottom bar is the widgetwith the info button, the page name etc.

self :

The GscCompletion

Returns :

The bottom bar widget (it is a GtkBox by now)

gsc_completion_get_info_widget ()

GscInfo *           gsc_completion_get_info_widget      (GscCompletion *self);

The info widget is the window where the completion shows the proposal info or help. DO NOT USE IT (only to connect to some signal or set the content in a custom widget).

self :

The GscCompletion

Returns :

The internal GscInfo widget.

gsc_completion_get_page_pos ()

gint                gsc_completion_get_page_pos         (GscCompletion *self,
                                                         const gchar *page_name);

Search the page position with the given name

self :

The GscCompletion

page_name :

The page name to search

Returns :

the page position or -1 if it is not found

gsc_completion_get_n_pages ()

gint                gsc_completion_get_n_pages          (GscCompletion *self);

self :

The GscCompletion

Returns :

The number of pages

gsc_completion_set_page_pos ()

gboolean            gsc_completion_set_page_pos         (GscCompletion *self,
                                                         const gchar *page_name,
                                                         gint position);

self :

The GscCompletion

page_name :

The page name you want to set the position (stating by 1 because 0 is the default page)

position :

The new position of the page. If this is negative, or is larger than the number of elements in the list, the new element is added on to the end of the list

Returns :

TRUE if the position has been set.

Property Details

The "active" property

  "active"                   gboolean              : Read / Write

TRUE if the completion mechanism is active.

Default value: FALSE


The "manage-completion-keys" property

  "manage-completion-keys"   gboolean              : Read / Write

TRUE if this object must control the completion keys pressed into the GtkTextView associated (up next proposal, down previous proposal etc.)

Default value: TRUE


The "remember-info-visibility" property

  "remember-info-visibility" gboolean              : Read / Write

TRUE if the completion must remember the last info state (visible or hidden)

Default value: FALSE


The "select-on-show" property

  "select-on-show"           gboolean              : Read / Write

TRUE if the completion must to mark as selected the first proposal on show (and when the filter is updated)

Default value: FALSE

Signal Details

The "display-info" signal

gboolean            user_function                      (GscCompletion *completion,
                                                        gpointer       proposal,
                                                        gpointer       user_data)       : Run Last / Action

When the user want to see the information of a proposal

completion :

The GscCompletion who emits the signal

proposal :

The GscProposal the user wants to see the information

user_data :

user data set when the signal handler was connected.

The "proposal-selected" signal

gboolean            user_function                      (GscCompletion *completion,
                                                        gpointer       proposal,
                                                        gpointer       user_data)       : Run Last / Action

When the user selects a proposal

completion :

The GscCompletion who emits the signal

proposal :

The selected GscProposal

user_data :

user data set when the signal handler was connected.