|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
gtksourceview completion APIHi all,
I'm happy to be able to announce that we have just merged the gtksourcecompletion work, that has been going on since the beginning of april this year, to master. The completion API adds functionality to gtksourceview to invoke, show and interact with a completion popup as often featured in source code editors. Many thanks to Chuchi Perriman for initiating the work on gtksourcecompletion and providing us with comments and support throughout the development! To very briefly summarize the new functionality, each GtkSourceView now has a GtkSourceCompletion object associated to it, which handles the completions as needed. Providers (implementing GtkSourceCompletionProvider) can register themselves with the completion, and will subsequently be used for completion. On completion, providers can provide GtkSourceCompletionProposal's to be shown in the completion dialog. There is one provider implemented and distributed with gtksourceview: GtkSourceCompletionWords. This provider will provide completion for words in one or more GtkTextBuffer registered to it. To get an understanding how to implement such a provider, you can have a look at gtksourceview/completion-providers/words/. This provider is featured in a new test called 'test-completion' provided in the 'tests' directory of gtksourceview. Attached are the header files for the new API, any comments (or questions) on the new API are more than welcome (implementation details can be found in the relevant files on our master branch in git). With kind regards, Jesse van den Kieboom /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- * gtksourcecompletion.h * This file is part of gtksourcecompletion * * Copyright (C) 2007 - 2009 Jesús Barbero RodrÃguez <chuchiperriman@...> * Copyright (C) 2009 Jesse van den Kieboom <jessevdk@...> * * gtksourceview 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. * * gtksourceview 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GTK_SOURCE_COMPLETION_H__ #define __GTK_SOURCE_COMPLETION_H__ #include <gtk/gtk.h> #include <gtksourceview/gtksourcecompletioninfo.h> #include <gtksourceview/gtksourcecompletionprovider.h> #include <gtksourceview/gtksourcelanguage.h> G_BEGIN_DECLS /* * Type checking and casting macros */ #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)) #define GTK_SOURCE_COMPLETION_ERROR (gtk_source_completion_error_quark ()) typedef struct _GtkSourceCompletionPrivate GtkSourceCompletionPrivate; typedef struct _GtkSourceCompletion GtkSourceCompletion; typedef struct _GtkSourceCompletionClass GtkSourceCompletionClass; typedef enum { GTK_SOURCE_COMPLETION_ERROR_ALREADY_BOUND = 0, GTK_SOURCE_COMPLETION_ERROR_NOT_BOUND, } GtkSourceCompletionError; /* Forward declaration of GtkSourceView */ struct _GtkSourceView; struct _GtkSourceCompletion { GtkObject parent; GtkSourceCompletionPrivate *priv; }; struct _GtkSourceCompletionClass { GObjectClass parent_class; gboolean (* proposal_activated) (GtkSourceCompletion *completion, GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal); void (* show) (GtkSourceCompletion *completion); void (* hide) (GtkSourceCompletion *completion); void (* populate_context) (GtkSourceCompletion *completion, GtkSourceCompletionContext *context); /* Actions */ void (* move_cursor) (GtkSourceCompletion *completion, GtkScrollStep step, gint num); void (* move_page) (GtkSourceCompletion *completion, GtkScrollStep step, gint num); void (* activate_proposal) (GtkSourceCompletion *completion); }; GType gtk_source_completion_get_type (void) G_GNUC_CONST; GQuark gtk_source_completion_error_quark (void); gboolean gtk_source_completion_add_provider (GtkSourceCompletion *completion, GtkSourceCompletionProvider *provider, GError **error); gboolean gtk_source_completion_remove_provider (GtkSourceCompletion *completion, GtkSourceCompletionProvider *provider, GError **error); GList *gtk_source_completion_get_providers (GtkSourceCompletion *completion); gboolean gtk_source_completion_show (GtkSourceCompletion *completion, GList *providers, GtkSourceCompletionContext *context); void gtk_source_completion_hide (GtkSourceCompletion *completion); GtkSourceCompletionInfo * gtk_source_completion_get_info_window (GtkSourceCompletion *completion); struct _GtkSourceView * gtk_source_completion_get_view (GtkSourceCompletion *completion); GtkSourceCompletionContext * gtk_source_completion_create_context (GtkSourceCompletion *completion, GtkTextIter *position); void gtk_source_completion_move_window (GtkSourceCompletion *completion, GtkTextIter *iter); void _gtk_source_completion_add_proposals (GtkSourceCompletion *completion, GtkSourceCompletionContext *context, GtkSourceCompletionProvider *provider, GList *proposals, gboolean finished); G_END_DECLS #endif /* __GTK_SOURCE_COMPLETION_H__ */ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- * gtksourcecompletioncontext.h * This file is part of gtksourceview * * Copyright (C) 2009 - Jesse van den Kieboom * * gtksourceview 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. * * gtksourceview 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GTK_SOURCE_COMPLETION_CONTEXT_H__ #define __GTK_SOURCE_COMPLETION_CONTEXT_H__ #include <glib-object.h> #include <gtk/gtk.h> G_BEGIN_DECLS #define GTK_TYPE_SOURCE_COMPLETION_CONTEXT (gtk_source_completion_context_get_type ()) #define GTK_SOURCE_COMPLETION_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOURCE_COMPLETION_CONTEXT, GtkSourceCompletionContext)) #define GTK_SOURCE_COMPLETION_CONTEXT_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOURCE_COMPLETION_CONTEXT, GtkSourceCompletionContext const)) #define GTK_SOURCE_COMPLETION_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SOURCE_COMPLETION_CONTEXT, GtkSourceCompletionContextClass)) #define GTK_IS_SOURCE_COMPLETION_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SOURCE_COMPLETION_CONTEXT)) #define GTK_IS_SOURCE_COMPLETION_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SOURCE_COMPLETION_CONTEXT)) #define GTK_SOURCE_COMPLETION_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SOURCE_COMPLETION_CONTEXT, GtkSourceCompletionContextClass)) typedef struct _GtkSourceCompletionContext GtkSourceCompletionContext; typedef struct _GtkSourceCompletionContextClass GtkSourceCompletionContextClass; typedef struct _GtkSourceCompletionContextPrivate GtkSourceCompletionContextPrivate; /* Forward declaration */ struct _GtkSourceCompletionProvider; struct _GtkSourceCompletion; struct _GtkSourceView; struct _GtkSourceCompletionContext { GInitiallyUnowned parent; GtkSourceCompletionContextPrivate *priv; }; struct _GtkSourceCompletionContextClass { GInitiallyUnownedClass parent_class; void (*cancelled) (GtkSourceCompletionContext *context); /* Padding for future expansion */ void (*_gtk_source_reserved1) (void); void (*_gtk_source_reserved2) (void); void (*_gtk_source_reserved3) (void); }; GType gtk_source_completion_context_get_type (void) G_GNUC_CONST; void gtk_source_completion_context_add_proposals (GtkSourceCompletionContext *context, struct _GtkSourceCompletionProvider *provider, GList *proposals, gboolean finished); struct _GtkSourceView * gtk_source_completion_context_get_view (GtkSourceCompletionContext *context); void gtk_source_completion_context_get_iter (GtkSourceCompletionContext *context, GtkTextIter *iter); gboolean gtk_source_completion_context_get_interactive (GtkSourceCompletionContext *context); gboolean gtk_source_completion_context_get_default (GtkSourceCompletionContext *context); void _gtk_source_completion_context_cancel (GtkSourceCompletionContext *context); G_END_DECLS #endif /* __GTK_SOURCE_COMPLETION_CONTEXT_H__ */ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- * gtksourcecompletionitem.h * This file is part of gtksourcecompletion * * Copyright (C) 2009 - Jesse van den Kieboom * * gtksourceview 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. * * gtksourceview 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GTK_SOURCE_COMPLETION_ITEM_H__ #define __GTK_SOURCE_COMPLETION_ITEM_H__ #include <glib-object.h> #include <gtksourceview/gtksourcecompletionproposal.h> G_BEGIN_DECLS #define GTK_TYPE_SOURCE_COMPLETION_ITEM (gtk_source_completion_item_get_type ()) #define GTK_SOURCE_COMPLETION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOURCE_COMPLETION_ITEM, GtkSourceCompletionItem)) #define GTK_SOURCE_COMPLETION_ITEM_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOURCE_COMPLETION_ITEM, GtkSourceCompletionItem const)) #define GTK_SOURCE_COMPLETION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SOURCE_COMPLETION_ITEM, GtkSourceCompletionItemClass)) #define GTK_IS_SOURCE_COMPLETION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SOURCE_COMPLETION_ITEM)) #define GTK_IS_SOURCE_COMPLETION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SOURCE_COMPLETION_ITEM)) #define GTK_SOURCE_COMPLETION_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SOURCE_COMPLETION_ITEM, GtkSourceCompletionItemClass)) typedef struct _GtkSourceCompletionItem GtkSourceCompletionItem; typedef struct _GtkSourceCompletionItemClass GtkSourceCompletionItemClass; typedef struct _GtkSourceCompletionItemPrivate GtkSourceCompletionItemPrivate; struct _GtkSourceCompletionItem { GObject parent; GtkSourceCompletionItemPrivate *priv; }; struct _GtkSourceCompletionItemClass { GObjectClass parent_class; }; GType gtk_source_completion_item_get_type (void) G_GNUC_CONST; GtkSourceCompletionItem *gtk_source_completion_item_new (const gchar *label, const gchar *text, GdkPixbuf *icon, const gchar *info); GtkSourceCompletionItem *gtk_source_completion_item_new_with_markup (const gchar *markup, const gchar *text, GdkPixbuf *icon, const gchar *info); GtkSourceCompletionItem *gtk_source_completion_item_new_from_stock (const gchar *label, const gchar *text, const gchar *stock, const gchar *info); G_END_DECLS #endif /* __GTK_SOURCE_COMPLETION_ITEM_H__ */ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- * gtksourcecompletionproposal.h * This file is part of gtksourcecompletion * * Copyright (C) 2007 - 2009 Jesús Barbero RodrÃguez <chuchiperriman@...> * Copyright (C) 2009 Jesse van den Kieboom <jessevdk@...> * * gtksourceview 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. * * gtksourceview 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GTK_SOURCE_COMPLETION_PROPOSAL_H__ #define __GTK_SOURCE_COMPLETION_PROPOSAL_H__ #include <glib-object.h> #include <gdk-pixbuf/gdk-pixbuf.h> G_BEGIN_DECLS #define GTK_TYPE_SOURCE_COMPLETION_PROPOSAL (gtk_source_completion_proposal_get_type ()) #define GTK_SOURCE_COMPLETION_PROPOSAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOURCE_COMPLETION_PROPOSAL, GtkSourceCompletionProposal)) #define GTK_IS_SOURCE_COMPLETION_PROPOSAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SOURCE_COMPLETION_PROPOSAL)) #define GTK_SOURCE_COMPLETION_PROPOSAL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_SOURCE_COMPLETION_PROPOSAL, GtkSourceCompletionProposalIface)) typedef struct _GtkSourceCompletionProposal GtkSourceCompletionProposal; typedef struct _GtkSourceCompletionProposalIface GtkSourceCompletionProposalIface; struct _GtkSourceCompletionProposalIface { GTypeInterface parent; /* Interface functions */ const gchar *(*get_label) (GtkSourceCompletionProposal *proposal); const gchar *(*get_markup) (GtkSourceCompletionProposal *proposal); const gchar *(*get_text) (GtkSourceCompletionProposal *proposal); GdkPixbuf *(*get_icon) (GtkSourceCompletionProposal *proposal); const gchar *(*get_info) (GtkSourceCompletionProposal *proposal); guint (*hash) (GtkSourceCompletionProposal *proposal); gboolean (*equal) (GtkSourceCompletionProposal *proposal, GtkSourceCompletionProposal *other); /* Signals */ void (*changed) (GtkSourceCompletionProposal *proposal); }; GType gtk_source_completion_proposal_get_type (void) G_GNUC_CONST; const gchar *gtk_source_completion_proposal_get_label (GtkSourceCompletionProposal *proposal); const gchar *gtk_source_completion_proposal_get_markup (GtkSourceCompletionProposal *proposal); const gchar *gtk_source_completion_proposal_get_text (GtkSourceCompletionProposal *proposal); GdkPixbuf *gtk_source_completion_proposal_get_icon (GtkSourceCompletionProposal *proposal); const gchar *gtk_source_completion_proposal_get_info (GtkSourceCompletionProposal *proposal); void gtk_source_completion_proposal_changed (GtkSourceCompletionProposal *proposal); guint gtk_source_completion_proposal_hash (GtkSourceCompletionProposal *proposal); gboolean gtk_source_completion_proposal_equal (GtkSourceCompletionProposal *proposal, GtkSourceCompletionProposal *other); G_END_DECLS #endif /* __GTK_SOURCE_COMPLETION_PROPOSAL_H__ */ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- * gtksourcecompletionprovider.h * This file is part of gtksourcecompletion * * Copyright (C) 2007 - 2009 Jesús Barbero RodrÃguez <chuchiperriman@...> * Copyright (C) 2009 Jesse van den Kieboom <jessevdk@...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef __GTK_SOURCE_COMPLETION_PROVIDER_H__ #define __GTK_SOURCE_COMPLETION_PROVIDER_H__ #include <glib.h> #include <glib-object.h> #include <gtk/gtk.h> #include <gtksourceview/gtksourcecompletionproposal.h> #include <gtksourceview/gtksourcecompletioninfo.h> #include <gtksourceview/gtksourcelanguage.h> #include <gtksourceview/gtksourcecompletioncontext.h> G_BEGIN_DECLS #define GTK_TYPE_SOURCE_COMPLETION_PROVIDER (gtk_source_completion_provider_get_type ()) #define GTK_SOURCE_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOURCE_COMPLETION_PROVIDER, GtkSourceCompletionProvider)) #define GTK_IS_SOURCE_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SOURCE_COMPLETION_PROVIDER)) #define GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_SOURCE_COMPLETION_PROVIDER, GtkSourceCompletionProviderIface)) #define GTK_SOURCE_COMPLETION_CAPABILITY_INTERACTIVE "standard::interactive" #define GTK_SOURCE_COMPLETION_CAPABILITY_AUTOMATIC "standard::automatic" typedef struct _GtkSourceCompletionProvider GtkSourceCompletionProvider; typedef struct _GtkSourceCompletionProviderIface GtkSourceCompletionProviderIface; struct _GtkSourceCompletionProviderIface { GTypeInterface g_iface; const gchar *(*get_name) (GtkSourceCompletionProvider *provider); GdkPixbuf *(*get_icon) (GtkSourceCompletionProvider *provider); void (*populate) (GtkSourceCompletionProvider *provider, GtkSourceCompletionContext *context); gboolean (*match) (GtkSourceCompletionProvider *provider, GtkSourceCompletionContext *context); gboolean (*get_interactive) (GtkSourceCompletionProvider *provider); gboolean (*get_default) (GtkSourceCompletionProvider *provider); GtkWidget *(*get_info_widget) (GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal); void (*update_info) (GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal, GtkSourceCompletionInfo *info); gboolean (*get_start_iter) (GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal, GtkTextIter *iter); gboolean (*activate_proposal) (GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal, GtkTextIter *iter); }; GType gtk_source_completion_provider_get_type (void); const gchar *gtk_source_completion_provider_get_name (GtkSourceCompletionProvider *provider); GdkPixbuf *gtk_source_completion_provider_get_icon (GtkSourceCompletionProvider *provider); void gtk_source_completion_provider_populate (GtkSourceCompletionProvider *provider, GtkSourceCompletionContext *context); gboolean gtk_source_completion_provider_get_interactive (GtkSourceCompletionProvider *provider); gboolean gtk_source_completion_provider_get_default (GtkSourceCompletionProvider *provider); gboolean gtk_source_completion_provider_match (GtkSourceCompletionProvider *provider, GtkSourceCompletionContext *context); GtkWidget *gtk_source_completion_provider_get_info_widget (GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal); void gtk_source_completion_provider_update_info (GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal, GtkSourceCompletionInfo *info); gboolean gtk_source_completion_provider_get_start_iter (GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal, GtkTextIter *iter); gboolean gtk_source_completion_provider_activate_proposal (GtkSourceCompletionProvider *provider, GtkSourceCompletionProposal *proposal, GtkTextIter *iter); G_END_DECLS #endif /* __GTK_SOURCE_COMPLETION_PROVIDER_H__ */ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- * gtksourceview.h * * Copyright (C) 2001 - Mikael Hermansson <tyan@...> and * Chris Phelps <chicane@...> * * Copyright (C) 2003 - Gustavo Giráldez and Paolo Maggi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __GTK_SOURCE_VIEW_H__ #define __GTK_SOURCE_VIEW_H__ #include <gtk/gtk.h> #include <gtk/gtktextview.h> #include <gtksourceview/gtksourcebuffer.h> #include <gtksourceview/gtksourcecompletion.h> #include <gtksourceview/gtksourcegutter.h> G_BEGIN_DECLS #define GTK_TYPE_SOURCE_VIEW (gtk_source_view_get_type ()) #define GTK_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOURCE_VIEW, GtkSourceView)) #define GTK_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SOURCE_VIEW, GtkSourceViewClass)) #define GTK_IS_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SOURCE_VIEW)) #define GTK_IS_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SOURCE_VIEW)) #define GTK_SOURCE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SOURCE_VIEW, GtkSourceViewClass)) typedef enum { GTK_SOURCE_VIEW_GUTTER_POSITION_LINES = -30, GTK_SOURCE_VIEW_GUTTER_POSITION_MARKS = -20 } GtkSourceViewGutterPosition; typedef struct _GtkSourceView GtkSourceView; typedef struct _GtkSourceViewClass GtkSourceViewClass; typedef struct _GtkSourceViewPrivate GtkSourceViewPrivate; struct _GtkSourceView { GtkTextView parent; GtkSourceViewPrivate *priv; }; struct _GtkSourceViewClass { GtkTextViewClass parent_class; void (*undo) (GtkSourceView *view); void (*redo) (GtkSourceView *view); void (*line_mark_activated) (GtkSourceView *view, GtkTextIter *iter, GdkEvent *event); void (*show_completion) (GtkSourceView *view); /* Padding for future expansion */ void (*_gtk_source_reserved1) (void); void (*_gtk_source_reserved2) (void); }; /** * GtkSourceSmartHomeEndType: * @GTK_SOURCE_SMART_HOME_END_DISABLED: smart-home-end disabled. * @GTK_SOURCE_SMART_HOME_END_BEFORE: move to the first/last * non-whitespace character on the first press of the HOME/END keys and * to the beginning/end of the line on the second press. * @GTK_SOURCE_SMART_HOME_END_AFTER: move to the beginning/end of the * line on the first press of the HOME/END keys and to the first/last * non-whitespace character on the second press. * @GTK_SOURCE_SMART_HOME_END_ALWAYS: always move to the first/last * non-whitespace character when the HOME/END keys are pressed. **/ typedef enum { GTK_SOURCE_SMART_HOME_END_DISABLED, GTK_SOURCE_SMART_HOME_END_BEFORE, GTK_SOURCE_SMART_HOME_END_AFTER, GTK_SOURCE_SMART_HOME_END_ALWAYS } GtkSourceSmartHomeEndType; /** * GtkSourceDrawSpacesFlags: * @GTK_SOURCE_DRAW_SPACES_SPACE: whether the space character should be drawn. * @GTK_SOURCE_DRAW_SPACES_TAB: whether the tab character should be drawn. * @GTK_SOURCE_DRAW_SPACES_NEWLINE: whether the line breaks should be drawn. * @GTK_SOURCE_DRAW_SPACES_NBSP: whether the non-breaking whitespaces should be drawn. * @GTK_SOURCE_DRAW_SPACES_ALL: wheter all kind of spaces should be drawn. * * GtkSourceDrawSpacesFlags determine what kind of spaces whould be drawn. */ /* TODO: it would be nice to have flags to specify to draw * just leading/trailing whitespaces */ typedef enum { GTK_SOURCE_DRAW_SPACES_SPACE = 1 << 0, GTK_SOURCE_DRAW_SPACES_TAB = 1 << 1, GTK_SOURCE_DRAW_SPACES_NEWLINE = 1 << 2, GTK_SOURCE_DRAW_SPACES_NBSP = 1 << 3, GTK_SOURCE_DRAW_SPACES_ALL = (GTK_SOURCE_DRAW_SPACES_SPACE | \ GTK_SOURCE_DRAW_SPACES_TAB | \ GTK_SOURCE_DRAW_SPACES_NEWLINE | \ GTK_SOURCE_DRAW_SPACES_NBSP) } GtkSourceDrawSpacesFlags; GType gtk_source_view_get_type (void) G_GNUC_CONST; /* Constructors */ GtkWidget *gtk_source_view_new (void); GtkWidget *gtk_source_view_new_with_buffer (GtkSourceBuffer *buffer); /* Properties */ void gtk_source_view_set_show_line_numbers (GtkSourceView *view, gboolean show); gboolean gtk_source_view_get_show_line_numbers (GtkSourceView *view); void gtk_source_view_set_tab_width (GtkSourceView *view, guint width); guint gtk_source_view_get_tab_width (GtkSourceView *view); void gtk_source_view_set_indent_width (GtkSourceView *view, gint width); gint gtk_source_view_get_indent_width (GtkSourceView *view); void gtk_source_view_set_auto_indent (GtkSourceView *view, gboolean enable); gboolean gtk_source_view_get_auto_indent (GtkSourceView *view); void gtk_source_view_set_insert_spaces_instead_of_tabs (GtkSourceView *view, gboolean enable); gboolean gtk_source_view_get_insert_spaces_instead_of_tabs (GtkSourceView *view); void gtk_source_view_set_indent_on_tab (GtkSourceView *view, gboolean enable); gboolean gtk_source_view_get_indent_on_tab (GtkSourceView *view); void gtk_source_view_set_highlight_current_line (GtkSourceView *view, gboolean show); gboolean gtk_source_view_get_highlight_current_line (GtkSourceView *view); void gtk_source_view_set_show_right_margin (GtkSourceView *view, gboolean show); gboolean gtk_source_view_get_show_right_margin (GtkSourceView *view); void gtk_source_view_set_right_margin_position (GtkSourceView *view, guint pos); guint gtk_source_view_get_right_margin_position (GtkSourceView *view); void gtk_source_view_set_show_line_marks (GtkSourceView *view, gboolean show); gboolean gtk_source_view_get_show_line_marks (GtkSourceView *view); #ifndef GTKSOURCEVIEW_DISABLE_DEPRECATED void gtk_source_view_set_mark_category_pixbuf (GtkSourceView *view, const gchar *category, GdkPixbuf *pixbuf) G_GNUC_DEPRECATED; #endif void gtk_source_view_set_mark_category_icon_from_pixbuf (GtkSourceView *view, const gchar *category, GdkPixbuf *pixbuf); void gtk_source_view_set_mark_category_icon_from_stock (GtkSourceView *view, const gchar *category, const gchar *stock_id); void gtk_source_view_set_mark_category_icon_from_icon_name (GtkSourceView *view, const gchar *category, const gchar *name); #ifndef GTKSOURCEVIEW_DISABLE_DEPRECATED GdkPixbuf *gtk_source_view_get_mark_category_pixbuf (GtkSourceView *view, const gchar *category) G_GNUC_DEPRECATED; #endif void gtk_source_view_set_mark_category_background (GtkSourceView *view, const gchar *category, const GdkColor *color); gboolean gtk_source_view_get_mark_category_background (GtkSourceView *view, const gchar *category, GdkColor *dest); typedef gchar * (*GtkSourceViewMarkTooltipFunc) (GtkSourceMark *mark, gpointer user_data); void gtk_source_view_set_mark_category_tooltip_func (GtkSourceView *view, const gchar *category, GtkSourceViewMarkTooltipFunc func, gpointer user_data, GDestroyNotify user_data_notify); void gtk_source_view_set_mark_category_tooltip_markup_func (GtkSourceView *view, const gchar *category, GtkSourceViewMarkTooltipFunc markup_func, gpointer user_data, GDestroyNotify user_data_notify); void gtk_source_view_set_mark_category_priority (GtkSourceView *view, const gchar *category, gint priority); gint gtk_source_view_get_mark_category_priority (GtkSourceView *view, const gchar *category); void gtk_source_view_set_smart_home_end (GtkSourceView *view, GtkSourceSmartHomeEndType smart_he); GtkSourceSmartHomeEndType gtk_source_view_get_smart_home_end (GtkSourceView *view); void gtk_source_view_set_draw_spaces (GtkSourceView *view, GtkSourceDrawSpacesFlags flags); GtkSourceDrawSpacesFlags gtk_source_view_get_draw_spaces (GtkSourceView *view); GtkSourceCompletion * gtk_source_view_get_completion (GtkSourceView *view); GtkSourceGutter *gtk_source_view_get_gutter (GtkSourceView *view, GtkTextWindowType window_type); G_END_DECLS #endif /* end of SOURCE_VIEW_H__ */ _______________________________________________ gedit-list mailing list gedit-list@... http://mail.gnome.org/mailman/listinfo/gedit-list |
|
|
Re: gtksourceview completion APIHi all,
Thanks a lot to Nacho and Jesse for that amazing work!!! I love open source when all people can help to do it better! My next step will be "finish" my gedit plugins and then I'll try to implement the folding feature for gtksourceview because nacho is working in the smart indentation (tell me if you prefer I try to develop the smart indentation). If you can help me or give me some ideas to implement the folding, please make me know! Thanks again to all the gedit team!!! Perriman El lun, 28-09-2009 a las 22:54 +0200, Jesse van den Kieboom escribió: > Hi all, > > I'm happy to be able to announce that we have just merged the > gtksourcecompletion work, that has been going on since the beginning of > april this year, to master. The completion API adds functionality to > gtksourceview to invoke, show and interact with a completion popup as > often featured in source code editors. Many thanks to Chuchi Perriman > for initiating the work on gtksourcecompletion and providing us with > comments and support throughout the development! > > To very briefly summarize the new functionality, each GtkSourceView now > has a GtkSourceCompletion object associated to it, which handles the > completions as needed. Providers (implementing > GtkSourceCompletionProvider) can register themselves with the > completion, and will subsequently be used for completion. On completion, > providers can provide GtkSourceCompletionProposal's to be shown in the > completion dialog. > > There is one provider implemented and distributed with gtksourceview: > GtkSourceCompletionWords. This provider will provide completion for > words in one or more GtkTextBuffer registered to it. To get an > understanding how to implement such a provider, you can have a look at > gtksourceview/completion-providers/words/. This provider is featured in > a new test called 'test-completion' provided in the 'tests' directory of > gtksourceview. > > Attached are the header files for the new API, any comments (or > questions) on the new API are more than welcome (implementation details > can be found in the relevant files on our master branch in git). > > > With kind regards, > > > Jesse van den Kieboom > _______________________________________________ > gedit-list mailing list > gedit-list@... > http://mail.gnome.org/mailman/listinfo/gedit-list _______________________________________________ gedit-list mailing list gedit-list@... http://mail.gnome.org/mailman/listinfo/gedit-list |
|
|
Re: gtksourceview completion APIHi,
On Tue, Sep 29, 2009 at 1:12 AM, perriman <chuchiperriman@...> wrote: Hi all, Yeah, I think the next step should be the indentation, there is a branch about that and I think we should resurrect it.
_______________________________________________ gedit-list mailing list gedit-list@... http://mail.gnome.org/mailman/listinfo/gedit-list |
| Free embeddable forum powered by Nabble | Forum Help |