GtkSourceCompletion API Proposal
- From: Perriman <chuchiperriman gmail com>
- To: gedit-list <gedit-list gnome org>
- Cc: devtools list <gnome-devtools gnome org>
- Subject: GtkSourceCompletion API Proposal
- Date: Sat, 3 May 2008 13:36:10 +0200
Hi all,
I have changed the GtkSourceCompletion API to use standar namespace,
use GtkSourceCompletionProposal like a GObject with some improvements.
I attach the new API to discuss about it.
I'm not a native english and I could have some language errors, please,
take a look at this!
I will wait for your opinion.
Regards,
Perriman
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
* gtksourcecompletion.h
*
* Copyright (C) 2007 - Chuchiperriman <chuchiperriman gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _GTK_SOURCE_COMPLETION_H_
#define _GTK_SOURCE_COMPLETION_H_
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
G_BEGIN_DECLS
#define GTK_TYPE_SOURCE_COMPLETION (gtk_source_completion_get_type ())
#define GTK_SOURCE_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOURCE_COMPLETION, GtkSourceCompletion))
#define GTK_SOURCE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SOURCE_COMPLETION, GtkSourceCompletionClass))
#define GTK_IS_SOURCE_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SOURCE_COMPLETION))
#define GTK_IS_SOURCE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SOURCE_COMPLETION))
#define GTK_SOURCE_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SOURCE_COMPLETION, GtkSourceCompletionClass))
typedef struct _GtkSourceCompletionPrivate GtkSourceCompletionPrivate;
typedef struct _GtkSourceCompletionClass GtkSourceCompletionClass;
typedef struct _GtkSourceCompletion GtkSourceCompletion;
#include "gtksourcecompletion-provider.h"
#include "gtksourcecompletion-trigger.h"
struct _GtkSourceCompletionClass
{
GObjectClass parent_class;
};
struct _GtkSourceCompletion
{
GObject parent_instance;
GtkSourceCompletionPrivate *priv;
};
GType
gtk_source_completion_get_type (void) G_GNUC_CONST;
/********************* Control functions **********************/
/*
* This function must disapear. We use this for store a list of
* GtkTextView-GtkSourceCompletion relation but if we add the
* completion into GtkSourceView, this relation will be into the GtkSourceView.
*/
/**
* gtk_source_completion_get_from_view:
* @view: the GtkSourceView
*
* Returns NULL if the GtkTextView haven't got an associated GtkSourceCompletion
* or the GtkSourceCompletion of this GtkTextView
*
**/
GtkSourceCompletion*
gtk_source_completion_get_from_view(GtkTextView *view);
/**************************************************************/
/**
* gtk_source_completion_new:
* @view: a #GtkSourceView.
*
* Creates a new #GtkSourceCompletion asociated to a GtkSourceView
*
* Returns: value: A new #GtkSourceCompletion
**/
GtkSourceCompletion*
gtk_source_completion_new (GtkTextView *view);
/**
* gtk_source_completion_get_view:
* @completion: the #GtkSourceCompletion
*
* Returns: The internal #GtkTextView of this completion.
*
**/
GtkTextView*
gtk_source_completion_get_view(GtkSourceCompletion *completion);
/**
* gtk_source_completion_is_visible:
* @completion: The #GtkSourceCompletion
*
* Returns TRUE if the completion popup is visible.
*
*/
gboolean
gtk_source_completion_is_visible(GtkSourceCompletion *completion);
/**
* gtk_source_completion_register_trigger:
* @completion: The #GtkSourceCompletion
* @trigger: The trigger to register
*
* This function register a completion trigger. If the completion is actived
* then this method activate the trigger. This function reference the trigger
* object
*/
void
gtk_source_completion_register_trigger(GtkSourceCompletion *completion,
GtkSourceCompletionTrigger *trigger);
/**
* gtk_source_completion_unregister_trigger:
* @completion: The #GtkSourceCompletion
* @trigger: The trigger to unregister
*
* This function unregister a completion trigger. If the completion is actived
* then this method deactivate the trigger. This function reference the trigger
* object
*/
void
gtk_source_completion_unregister_trigger(GtkSourceCompletion *completion,
GtkSourceCompletionTrigger *trigger);
/**
* gtk_source_completion_get_trigger:
* @completion: The #GtkSourceCompletion
* @trigger_name: The trigger name to get
*
* This function return the trigger with this name.
*
* Returns The trigger or NULL if not exists
*
*/
GtkSourceCompletionTrigger*
gtk_source_completion_get_trigger(GtkSourceCompletion *completion,
const gchar* trigger_name);
/**
* gtk_source_completion_get_active_trigger_name:
* @completion: The #GtkSourceCompletion
*
* 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.
*
* Returns The trigger or NULL if completion is not active
*
*/
const GtkSourceCompletionTrigger*
gtk_source_completion_get_active_trigger(GtkSourceCompletion *completion);
/**
* gtk_source_completion_register_provider:
* @completion: the #GtkSourceCompletion
* @provider: The #GtkSourceCompletionProvider.
* @trigger_name: The trigger name what you want to register this provider
*
* 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
* selects a proposal, it call the provider to tell it this action and the provider do
* that it want (normally inserts some text)
*
* Returns TRUE if it was registered or FALSE if not (because it has been already registered,
* or the trigger don't exists)
*
**/
gboolean
gtk_source_completion_register_provider(GtkSourceCompletion *completion,
GtkSourceCompletionProvider *provider,
const gchar *trigger_name);
/**
* gtk_source_completion_unregister_provider:
* @completion: the #GtkSourceCompletion
* @provider: The #GtkSourceCompletionProvider.
* @trigger_name: The trigger name what you want to unregister this provider
*
* This function unregister the provider.
*
* Returns TRUE if it was unregistered or FALSE if not (because it doesn't exists,
* or the trigger don't exists)
*
**/
gboolean
gtk_source_completion_unregister_provider(GtkSourceCompletion *completion,
GtkSourceCompletionProvider *provider,
const gchar *trigger_name);
/**
* gtk_source_completion_get_provider:
* @completion: The #GtkSourceCompletion
* @provider_name: Provider's name that you are looking for.
*
* Returns The provider if the completion has this provider registered or
* NULL if not.
*
*/
GtkSourceCompletionProvider*
gtk_source_completion_get_provider(GtkSourceCompletion *completion,
const gchar* provider_name);
/**
* gtk_source_completion_activate:
* @completion: The #GtkSourceCompletion
*
* This function activate the completion mechanism. The completion connects
* all signals and activate all registered triggers.
*/
void
gtk_source_completion_activate(GtkSourceCompletion *completion);
/**
* gtk_source_completion_deactivate:
* @completion: The #GtkSourceCompletion
*
* This function deactivate the completion mechanism. The completion disconnect
* all signals and deactivate all registered triggers.
*/
void
gtk_source_completion_deactivate(GtkSourceCompletion *completion);
/**
* gtk_source_completion_trigger_event:
* @completion: the #GtkSourceCompletion
* @trigger_name: The event name to raise
* @event_data: This object will be passed to the providers to give them some special information of the event
*
* Calling this function, the completion call to all providers to get data and, if
* they return data, it shows the completion to the user.
*
**/
void
gtk_source_completion_trigger_event(GtkSourceCompletion *completion,
const gchar *trigger_name,
gpointer event_data);
/**
* gtk_source_completion_finish_completion:
* @completion: The #GtkSourceCompletion
*
* This function finish the completion if it is active (visible).
*/
void
gtk_source_completion_finish(GtkSourceCompletion *completion);
G_END_DECLS
#endif /* _GTK_SOURCE_COMPLETION_H_ */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
* gtk_source-completion-popup.h
*
* Copyright (C) 2007 - Chuchiperriman <chuchiperriman gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef GTK_SOURCE_COMPLETION_POPUP_H
#define GTK_SOURCE_COMPLETION_POPUP_H
#include <gtk/gtk.h>
#include "gtksourcecompletion-proposal.h"
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define GTK_TYPE_SOURCE_COMPLETION_POPUP (gtk_source_completion_popup_get_type())
#define GTK_SOURCE_COMPLETION_POPUP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_SOURCE_COMPLETION_POPUP, GtkSourceCompletionPopup))
#define GTK_SOURCE_COMPLETION_POPUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_SOURCE_COMPLETION_POPUP, GtkSourceCompletionPopupClass))
#define GTK_IS_SOURCE_COMPLETION_POPUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_SOURCE_COMPLETION_POPUP))
#define GTK_IS_SOURCE_COMPLETION_POPUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SOURCE_COMPLETION_POPUP))
#define GTK_SOURCE_COMPLETION_POPUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_SOURCE_COMPLETION_POPUP, GtkSourceCompletionPopupClass))
#define DEFAULT_PAGE "Default"
typedef struct _GtkSourceCompletionPopupPriv GtkSourceCompletionPopupPriv;
typedef struct _GtkSourceCompletionPopup GtkSourceCompletionPopup;
typedef struct _GtkSourceCompletionPopupClass GtkSourceCompletionPopupClass;
struct _GtkSourceCompletionPopupClass
{
GtkWindowClass parent_class;
void (* proposal_selected)(GtkSourceCompletionPopup *popup,
GtkSourceCompletionProposal *proposal);
};
struct _GtkSourceCompletionPopup
{
GtkWindow parent;
GtkSourceCompletionPopupPriv *priv;
};
GType
gtk_source_completion_popup_get_type (void) G_GNUC_CONST;
/**
* gtk_source_completion_popup_select_first:
* @self: The #GtkSourceCompletionPopup
*
* See #gtk_source_completion_tree_select_first
*
* Returns
*/
gboolean
gtk_source_completion_popup_select_first(GtkSourceCompletionPopup *self);
/**
* gtk_source_completion_popup_select_last:
* @self: The #GtkSourceCompletionPopup
*
* See #gtk_source_completion_tree_select_last
*
* Returns
*/
gboolean
gtk_source_completion_popup_select_last(GtkSourceCompletionPopup *self);
/**
* gtk_source_completion_popup_select_previous:
* @self: The #GtkSourceCompletionPopup
*
* See #gtk_source_completion_tree_select_previous
*
* Returns
*/
gboolean
gtk_source_completion_popup_select_previous(GtkSourceCompletionPopup *self,
gint rows);
/**
* gtk_source_completion_popup_select_next:
* @self: The #GtkSourceCompletionPopup
*
* See #gtk_source_completion_tree_select_next
*
* Returns
*/
gboolean
gtk_source_completion_popup_select_next(GtkSourceCompletionPopup *self,
gint rows);
/**
* gtk_source_completion_popup_get_selected_proposal:
* @self: The #GtkSourceCompletionPopup
*
* See #gtk_source_completion_tree_select_proposal. Not free the proposal!
*
* Returns
*/
gboolean
gtk_source_completion_popup_get_selected_proposal(GtkSourceCompletionPopup *self,
GtkSourceCompletionProposal **proposal);
/**
* gtk_source_completion_popup_new:
* @view: The #GtkTextView where the popup gets and put the completion.
*
* Returns The new #GtkSourceCompletionPopup
*/
GtkWidget*
gtk_source_completion_popup_new (GtkTextView *view);
/**
* gtk_source_completion_popup_clear:
* @self: The #GtkSourceCompletionPopup
*
* Clear all proposals in all pages. It frees all completion proposals.
*
*/
void
gtk_source_completion_popup_clear(GtkSourceCompletionPopup *self);
/**
* gtk_source_completion_popup_add_proposal:
* @self: The #GtkSourceCompletionPopup
* @data: The #GtkSourceCompletionItem to add.
*
* The popup frees the proposal when it will be cleaned.
*
*/
void
gtk_source_completion_popup_add_proposal(GtkSourceCompletionPopup *self,
GtkSourceCompletionItem* proposal);
/**
* gtk_source_completion_popup_has_proposals:
* @self: The #GtkSourceCompletionPopup
*
* Returns TRUE if the popup has almost one element.
*/
gboolean
gtk_source_completion_popup_has_proposals(GtkSourceCompletionPopup *self);
/**
* gtk_source_completion_popup_toggle_proposal_info:
* @self: The #GtkSourceCompletionPopup
*
* This toggle the state of the info dialog. If the info is visible
* then it hide the info dialog. If the dialog is hidden then it
* shows the info dialog.
*
*/
void
gtk_source_completion_popup_toggle_proposal_info(GtkSourceCompletionPopup *self);
/**
* gtk_source_completion_popup_refresh:
* @self: The #GtkSourceCompletionPopup
*
* Really only show the completion by now.
*
*/
void
gtk_source_completion_popup_refresh(GtkSourceCompletionPopup *self);
/**
* gtk_source_completion_popup_page_next:
* @self: The #GtkSourceCompletionPopup
*
* Shows the next completion page. If it is the last page then
* shows the first one.
*
*/
void
gtk_source_completion_popup_page_next(GtkSourceCompletionPopup *self);
/**
* gtk_source_completion_popup_page_previous:
* @self: The #GtkSourceCompletionPopup
*
* Shows the previous completion page. If it is the first page then
* shows the last one.
*
*/
void
gtk_source_completion_popup_page_previous(GtkSourceCompletionPopup *self);
G_END_DECLS
#endif
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
* gtksourcecompletion-proposal.h
*
* Copyright (C) 2007 - Chuchiperriman <chuchiperriman gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef GTK_SOURCE_COMPLETION_ITEM_H
#define GTK_SOURCE_COMPLETION_ITEM_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
typedef struct _GtkSourceCompletionProposal GtkSourceCompletionProposal;
typedef void (*GtkSourceCompletionProposalApply) (GtkSourceCompletionProposal *proposal)
typedef gchar* (*GtkSourceCompletionProposalGenInfo) (GtkSourceCompletionProposal *proposal)
struct _GtkSourceCompletionProposal
{
GObject parent_instance;
GtkSourceCompletionProposalPrivate *priv;
};
#include "gtksourcecompletion-provider.h"
#define DEFAULT_PAGE "Default"
/**
* gtk_source_completion_proposal_new:
* @id: An id for identify this proposal. This can be used by the provider but the
* completion does not use this value
* @name: Item name that will be shown in the completion popup
* @icon: Item icon that will be shown in the completion popup
* @priority: The proposal priority. Items with high priority will be
* shown first in the completion popup
* @user_data: User data used by the providers
*
* This function creates a new proposal. When the user selects the proposal, the
* proposal name will be inserted into the GtkTextView. You can create the proposal
* using #gtk_source_completion_proposal_new_full to set a custom function.
*
* The proposal has not info by default.
*
* Returns The new GtkSourceCompletionProposal
*/
GtkSourceCompletionProposal*
gtk_source_completion_proposal_new(int id,
const gchar *name,
const GdkPixbuf *icon,
int priority,
gpointer user_data);
/**
* gtk_source_completion_proposal_new_full:
* @id: An id for identify this proposal
* @name: Item name that will be shown in the completion popup
* @icon: Item icon that will be shown in the completion popup
* @priority: The proposal priority. Items with high priority will be
* shown first in the completion popup
* @provider: The provider that creates the proposal
* @page_name: The page name of this proposal. If NULL, the proposal will be shown
* in the default page.
* @apply_func: This function will be called when the user selects the proposal
* @inf_func: This function will be called to get the proposal info markup
* @user_data: User data used by the providers
*
* Returns The new GtkSourceCompletionProposal
*/
GtkSourceCompletionProposal*
gtk_source_completion_proposal_new_full(int id,
const gchar *name,
const GdkPixbuf *icon,
int priority,
GtkSourceCompletionProvider *provider,
const gchar *page_name,
GtkSourceCompletionProposalApply apply_func,
GtkSourceCompletionProposalGenInfo info_func,
gpointer user_data);
/**
* gtk_source_completion_proposal_free:
* @proposal: The GtkSourceCompletionProposal
*
* Frees the completion proposal.
*
*/
void
gtk_source_completion_proposal_free(GtkSourceCompletionProposal *proposal);
/**
* gtk_source_completion_proposal_get_id:
* @proposal: The GtkSourceCompletionProposal
*
* Returns current proposal id
*
*/
int
gtk_source_completion_proposal_get_id(GtkSourceCompletionProposal *proposal);
/**
* gtk_source_completion_proposal_get_name:
* @proposal: The GtkSourceCompletionProposal
*
* Returns The proposal name
*/
const gchar*
gtk_source_completion_proposal_get_name(GtkSourceCompletionProposal *proposal);
/**
* gtk_source_completion_proposal_get_icon:
* @proposal: The GtkSourceCompletionProposal
*
* Returns the icon of this proposal
*/
const GdkPixbuf*
gtk_source_completion_proposal_get_icon(GtkSourceCompletionProposal *proposal);
/**
* gtk_source_completion_proposal_get_user_data:
* @proposal: The GtkSourceCompletionProposal
*
* Returns the user data of this proposal
*/
gpointer
gtk_source_completion_proposal_get_user_data(GtkSourceCompletionProposal *proposal);
/**
* gtk_source_completion_proposal_get_page_name:
* @proposal: The GtkSourceCompletionProposal
*
* Returns the page name where the proposal will be placed.
*/
const gchar*
gtk_source_completion_proposal_get_page_name(GtkSourceCompletionProposal *proposal);
/**
* gtk_source_completion_proposal_selected:
* @proposal: The GtkSourceCompletionProposal
*
* The completion calls this function when the user selects the proposal. This
* function will call to the #GtkSourceCompletionProposalApply setted on the creation.
*
*/
void
gtk_source_completion_proposal_selected(GtkSourceCompletionProposal *proposal);
/**
* gtk_source_completion_proposal_get_info_markup:
* @proposal: The GtkSourceCompletionProposal
*
* The completion calls this function to get the proposal info to be shown into
* the info window. This info must to be a markup. You can use #g_markup_escape_text
*
* Returns The proposal info markup (new allocated).
*
*/
gchar*
gtk_source_completion_proposal_get_info_markup(GtkSourceCompletionProposal *proposal);
G_END_DECLS
#endif
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
* gtksourcecompletion-provider.h
*
* Copyright (C) 2007 - Chuchiperriman <chuchiperriman gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __GTK_SOURCE_COMPLETION_PROVIDER_H__
#define __GTK_SOURCE_COMPLETION_PROVIDER_H__
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GTK_SOURCE_COMPLETION_TYPE_PROVIDER (gtk_source_completion_provider_get_type ())
#define GTK_SOURCE_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_SOURCE_COMPLETION_TYPE_PROVIDER, GtkSourceCompletionProvider))
#define GTK_SOURCE_COMPLETION_IS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_SOURCE_COMPLETION_TYPE_PROVIDER))
#define GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_SOURCE_COMPLETION_TYPE_PROVIDER, GtkSourceCompletionProviderIface))
typedef struct _GtkSourceCompletionProvider GtkSourceCompletionProvider;
typedef struct _GtkSourceCompletionProviderIface GtkSourceCompletionProviderIface;
#include "gtksourcecompletion.h"
#include "gtksourcecompletion-trigger.h"
#include "gtksourcecompletion-proposal.h"
struct _GtkSourceCompletionProviderIface {
GTypeInterface parent;
const gchar* (*get_name) (GtkSourceCompletionProvider *self);
GList* (*get_data) (GtkSourceCompletionProvider* self,
GtkSourceCompletion* completion,
GtkSourceCompletionTrigger *trigger);
void (*end_completion) (GtkSourceCompletionProvider* self,
GtkSourceCompletion* completion);
};
/**
* gtk_source_completion_provider_get_name:
* @self: the #GtkSourceCompletionProvider
*
* The provider name. By example: "Document word completion provider"
*
* Returns: The provider's name
*
**/
const gchar*
gtk_source_completion_provider_get_name(GtkSourceCompletionProvider* self);
/**
* gtk_source_completion_provider_get_data:
* @self: the #GtkSourceCompletionProvider
* @completion: The #GtkSourceCompletion.
* @trigger: The #GtkSourceCompletionTrigger that trigger the event
*
* The completion call this function when an event is raised.
* This function may return a list of #GtkSourceCompletionProposal to be shown
* in the popup to the user.
*
* Returns: a list of #GtkSourceCompletionProposal or NULL if there are no proposals
*
**/
GList*
gtk_source_completion_provider_get_proposals (GtkSourceCompletionProvider* self,
GtkSourceCompletion* completion,
GtkSourceCompletionTrigger *trigger);
/**
* gtk_source_completion_provider_finish:
* @self: the #GtkSourceCompletionProvider
* @view: The #GtkSourceCompletion.
*
* The completion call this function when it is goint to hide the popup and the
* completion perhaps needs to free some data.
*
**/
void
gtk_source_completion_provider_finish (GtkSourceCompletionProvider* self,
GtkSourceCompletion* completion);
GType
gtk_source_completion_provider_get_type ();
G_END_DECLS
#endif
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
* gtksourcecompletion-tree.h
*
* Copyright (C) 2007 - Chuchiperriman <chuchiperriman gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef GTK_SOURCE_COMPLETION_TREE_H
#define GTK_SOURCE_COMPLETION_TREE_H
#include <gtk/gtk.h>
#include "gtksourcecompletion-proposal.h"
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define GTK_TYPE_SOURCE_COMPLETION_TREE (gtk_source_completion_tree_get_type())
#define GTK_SOURCE_COMPLETION_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_SOURCE_COMPLETION_TREE, GtkSourceCompletionTree))
#define GTK_SOURCE_COMPLETION_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_SOURCE_COMPLETION_TREE, GtkSourceCompletionTreeClass))
#define GTK_IS_SOURCE_COMPLETION_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_SOURCE_COMPLETION_TREE))
#define GTK_IS_SOURCE_COMPLETION_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SOURCE_COMPLETION_TREE))
#define GTK_SOURCE_COMPLETION_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_SOURCE_COMPLETION_TREE, GtkSourceCompletionTreeClass))
typedef struct _GtkSourceCompletionTreePriv GtkSourceCompletionTreePriv;
typedef struct _GtkSourceCompletionTree GtkSourceCompletionTree;
typedef struct _GtkSourceCompletionTreeClass GtkSourceCompletionTreeClass;
struct _GtkSourceCompletionTreeClass
{
GtkScrolledWindowClass parent_class;
void (* proposal_selected)(GtkSourceCompletionTree *tree,
GtkSourceCompletionProposal *proposal);
void (* selection_changed)(GtkSourceCompletionTree *tree,
GtkSourceCompletionProposal *proposal);
};
struct _GtkSourceCompletionTree
{
GtkScrolledWindow parent;
GtkSourceCompletionTreePriv *priv;
};
GType
gtk_source_completion_tree_get_type (void) G_GNUC_CONST;
/**
* gtk_source_completion_tree_new:
*
* Create a new GtkSourceCompletionTree
*
* Returns the new #GtkSourceCompletionTree
*
*/
GtkWidget*
gtk_source_completion_tree_new();
/**
* gtk_source_completion_tree_get_selected_proposal:
* @self: The #GtkSourceCompletionTree
* @proposal: A reference of an proposal. This function sets the pointer to the selected proposal.
*
* @Returns TRUE if there is an proposal selected
*
*/
gboolean
gtk_source_completion_tree_get_selected_proposal(GtkSourceCompletionTree *self,
GtkSourceCompletionProposal **proposal);
/**
* gtk_source_completion_tree_select_first:
* @self: The #GtkSourceCompletionTree
*
* This functions selects the first proposal on the tree
*
* Returns TRUE if there is an proposal and it has been selected
*/
gboolean
gtk_source_completion_tree_select_first(GtkSourceCompletionTree *self);
/**
* gtk_source_completion_tree_select_last:
* @self: The #GtkSourceCompletionTree
*
* This functions selects the last proposal on the tree
*
* Returns TRUE if there is an proposal and it has been selected
*/
gboolean
gtk_source_completion_tree_select_last(GtkSourceCompletionTree *self);
/**
* gtk_source_completion_tree_select_previous:
* @self: The #GtkSourceCompletionTree
* @rows: the number of the previous proposals to select
*
* This functions selects the rows number of proposals before the current.
*
* Returns TRUE if there is an proposal and it has been selected. If rows=5 but the tree
* only have 3 proposals, it returns true too.
*/
gboolean
gtk_source_completion_tree_select_previous(GtkSourceCompletionTree *self,
gint rows);
/**
* gtk_source_completion_tree_select_next:
* @self: The #GtkSourceCompletionTree
* @rows: the number of the next proposals to select
*
* This functions selects the rows number of proposals after the current.
*
* Returns TRUE if there is an proposal and it has been selected. If rows=5 but the tree
* only have 3 proposals, it returns true too.
*/
gboolean
gtk_source_completion_tree_select_next(GtkSourceCompletionTree *self,
gint rows);
/**
* gtk_source_completion_tree_clear:
* @self: the #GtkSourceCompletionTree
*
* Clear the tree model and free the proposals
*/
void
gtk_source_completion_tree_clear(GtkSourceCompletionTree *self);
/**
* gtk_source_completion_tree_add_proposal:
* @self: The #GtkSourceCompletionTree
* @proposal: the proposal to add to the tree
*
* Adds a new proposal into the tree
*
*/
void
gtk_source_completion_tree_add_proposal(GtkSourceCompletionTree *self,
GtkSourceCompletionProposal* proposal);
/**
* gtk_source_completion_tree_has_proposals:
* @self: The #GtkSourceCompletionTree
*
* Returns TRUE if the tree has one or more proposals.
*/
gboolean
gtk_source_completion_tree_has_proposals(GtkSourceCompletionTree *self);
G_END_DECLS
#endif
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
* gtksourcecompletion-trigger.h
*
* Copyright (C) 2007 - Chuchiperriman <chuchiperriman gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __GTK_SOURCE_COMPLETION_TRIGGER_H__
#define __GTK_SOURCE_COMPLETION_TRIGGER_H__
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GTK_SOURCE_COMPLETION_TYPE_TRIGGER (gtk_source_completion_trigger_get_type ())
#define GTK_SOURCE_COMPLETION_TRIGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_SOURCE_COMPLETION_TYPE_TRIGGER, GtkSourceCompletionTrigger))
#define GTK_SOURCE_COMPLETION_IS_TRIGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_SOURCE_COMPLETION_TYPE_TRIGGER))
#define GTK_SOURCE_COMPLETION_TRIGGER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_SOURCE_COMPLETION_TYPE_TRIGGER, GtkSourceCompletionTriggerIface))
typedef struct _GtkSourceCompletionTrigger GtkSourceCompletionTrigger;
typedef struct _GtkSourceCompletionTriggerIface GtkSourceCompletionTriggerIface;
#include "gtksourcecompletion.h"
struct _GtkSourceCompletionTriggerIface {
GTypeInterface parent;
const gchar* (*get_name) (GtkSourceCompletionTrigger *self);
gboolean (*activate) (GtkSourceCompletionTrigger* self);
gboolean (*deactivate) (GtkSourceCompletionTrigger* self);
};
/**
* gtk_source_completion_trigger_get_name:
* @self: the #GtkSourceCompletionTrigger
*
* The trigger name. By example: "C autocompletion trigger"
*
* Returns: The trigger's name
*
**/
const gchar*
gtk_source_completion_trigger_get_name(GtkSourceCompletionTrigger* self);
/**
* gtk_source_completion_trigger_activate:
* @self: the #GtkSourceCompletionTrigger
*
* Activate the completion trigger.
*
* Returns: TRUE if activation is OK, FALSE if not.
*
**/
gboolean
gtk_source_completion_trigger_activate (GtkSourceCompletionTrigger* self);
/**
* gtk_source_completion_trigger_deactivate:
* @self: the #GtkSourceCompletionTrigger
*
* Deactive the completion trigger
*
* Returns: TRUE if activation is OK, FALSE if not.
*
**/
gboolean
gtk_source_completion_trigger_deactivate (GtkSourceCompletionTrigger* self);
GType
gtk_source_completion_trigger_get_type ();
G_END_DECLS
#endif
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]