本文整理汇总了C++中GTK_SOURCE_VIEW函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_SOURCE_VIEW函数的具体用法?C++ GTK_SOURCE_VIEW怎么用?C++ GTK_SOURCE_VIEW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GTK_SOURCE_VIEW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gb_view_source_tab_size_activate
static void
gb_view_source_tab_size_activate (GtkMenuItem *menu_item,
GbViewSource *source)
{
GbViewSourcePrivate *priv;
const gchar *label;
gint size;
ENTRY;
g_return_if_fail(GTK_IS_MENU_ITEM(menu_item));
g_return_if_fail(GB_IS_VIEW_SOURCE(source));
priv = source->priv;
label = gtk_menu_item_get_label(menu_item);
size = g_ascii_strtoll(label, NULL, 10);
if (size > 0) {
gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(priv->source1), size);
if (priv->source2) {
gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(priv->source2), size);
}
g_object_set(priv->size_combo,
"label", label,
NULL);
}
EXIT;
}
示例2: enable_bookmarks
static void
enable_bookmarks (GeditView *view,
GeditPlugin *plugin)
{
GdkPixbuf *pixbuf;
pixbuf = get_bookmark_pixbuf (plugin);
/* Make sure the category pixbuf is set */
if (pixbuf)
{
InsertData *data;
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
update_background_color (view);
gtk_source_view_set_mark_category_icon_from_pixbuf (GTK_SOURCE_VIEW (view),
BOOKMARK_CATEGORY,
pixbuf);
g_object_unref (pixbuf);
gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW (view), TRUE);
g_signal_connect (buffer,
"notify::style-scheme",
G_CALLBACK (on_style_scheme_notify),
view);
g_signal_connect_after (buffer,
"delete-range",
G_CALLBACK (on_delete_range),
NULL);
data = g_slice_new0 (InsertData);
g_object_set_data_full (G_OBJECT (buffer),
INSERT_DATA_KEY,
data,
(GDestroyNotify) free_insert_data);
g_signal_connect (buffer,
"insert-text",
G_CALLBACK (on_insert_text_before),
data);
g_signal_connect (buffer,
"begin-user-action",
G_CALLBACK (on_begin_user_action),
data);
g_signal_connect (buffer,
"end-user-action",
G_CALLBACK (on_end_user_action),
data);
}
else
{
g_warning ("Could not set bookmark icon!");
}
}
示例3: gbp_retab_editor_page_addin_action
static void
gbp_retab_editor_page_addin_action (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
GbpRetabEditorPageAddin *self = user_data;
IdeSourceView *source_view;
GtkTextBuffer *buffer;
IdeCompletion *completion;
guint tab_width;
gint start_line;
gint end_line;
gint indent;
GtkTextIter begin;
GtkTextIter end;
gboolean editable;
gboolean to_spaces;
g_assert (GBP_IS_RETAB_EDITOR_PAGE_ADDIN (self));
g_assert (G_IS_SIMPLE_ACTION (action));
buffer = GTK_TEXT_BUFFER (ide_editor_page_get_buffer (self->editor_view));
source_view = ide_editor_page_get_view (self->editor_view);
g_assert (IDE_IS_SOURCE_VIEW (source_view));
editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (source_view));
completion = ide_source_view_get_completion (IDE_SOURCE_VIEW (source_view));
tab_width = gtk_source_view_get_tab_width(GTK_SOURCE_VIEW (source_view));
to_spaces = gtk_source_view_get_insert_spaces_instead_of_tabs(GTK_SOURCE_VIEW (source_view));
if (!editable)
return;
gtk_text_buffer_get_selection_bounds (buffer, &begin, &end);
gtk_text_iter_order (&begin, &end);
if (!gtk_text_iter_equal (&begin, &end) && gtk_text_iter_starts_line (&end))
gtk_text_iter_backward_char (&end);
start_line = gtk_text_iter_get_line (&begin);
end_line = gtk_text_iter_get_line (&end);
ide_completion_block_interactive (completion);
gtk_text_buffer_begin_user_action (buffer);
for (gint line = start_line; line <= end_line; ++line)
{
indent = get_buffer_range_indent (buffer, line, to_spaces);
if (indent > 0)
gbp_retab_editor_page_addin_retab (buffer, line, tab_width, indent, to_spaces);
}
gtk_text_buffer_end_user_action (buffer);
ide_completion_unblock_interactive (completion);
}
示例4: ide_xml_indenter_format
static gchar *
ide_xml_indenter_format (IdeIndenter *indenter,
GtkTextView *view,
GtkTextIter *begin,
GtkTextIter *end,
gint *cursor_offset,
GdkEventKey *trigger)
{
IdeXmlIndenter *xml = (IdeXmlIndenter *)indenter;
guint tab_width = 2;
gint indent_width = -1;
g_return_val_if_fail (IDE_IS_XML_INDENTER (xml), NULL);
*cursor_offset = 0;
if (GTK_SOURCE_IS_VIEW (view))
{
tab_width = gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (view));
indent_width = gtk_source_view_get_indent_width (GTK_SOURCE_VIEW (view));
if (indent_width != -1)
tab_width = indent_width;
}
xml->tab_width = tab_width;
xml->use_tabs = !gtk_source_view_get_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (view));
if (indent_width <= 0)
xml->indent_width = tab_width;
else
xml->indent_width = indent_width;
/* do nothing if we are in a cdata section */
if (text_iter_in_cdata (begin))
return NULL;
switch (trigger->keyval)
{
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
if ((trigger->state & GDK_SHIFT_MASK) == 0)
return ide_xml_indenter_indent (xml, begin, end, cursor_offset);
return NULL;
case GDK_KEY_slash:
return ide_xml_indenter_maybe_unindent (xml, begin, end);
case GDK_KEY_greater:
return ide_xml_indenter_maybe_add_closing (xml, begin, end, cursor_offset);
default:
g_return_val_if_reached (NULL);
}
return NULL;
}
示例5: set_display_line_number
//行数表示の設定を変える
void set_display_line_number(void)
{
if (state & line_mask) {
gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(view), FALSE);
} else {
gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(view), TRUE);
}
state ^= line_mask;
}
示例6: set_insert_space
//タブを用いるかどうかの設定を変える
void set_insert_space(void)
{
if (state & space_mask) {
gtk_source_view_set_insert_spaces_instead_of_tabs(GTK_SOURCE_VIEW(view), FALSE);
} else {
gtk_source_view_set_insert_spaces_instead_of_tabs(GTK_SOURCE_VIEW(view), TRUE);
}
state ^= space_mask;
}
示例7: set_highlight_line
//行のハイライトの設定を変える
void set_highlight_line(void)
{
if (state & highlight_mask) {
gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW(view), FALSE);
} else {
gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW(view), TRUE);
}
state ^= highlight_mask;
}
示例8: pluma_prefs_manager_tabs_size_changed
static void
pluma_prefs_manager_tabs_size_changed (GSettings *settings,
gchar *key,
gpointer user_data)
{
pluma_debug (DEBUG_PREFS);
if (strcmp (key, GPM_TABS_SIZE) == 0)
{
gint tab_width;
GList *views;
GList *l;
tab_width = g_settings_get_int (settings, key);
tab_width = CLAMP (tab_width, 1, 24);
views = pluma_app_get_views (pluma_app_get_default ());
l = views;
while (l != NULL)
{
gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (l->data),
tab_width);
l = l->next;
}
g_list_free (views);
}
else if (strcmp (key, GPM_INSERT_SPACES) == 0)
{
gboolean enable;
GList *views;
GList *l;
enable = g_settings_get_boolean (settings, key);
views = pluma_app_get_views (pluma_app_get_default ());
l = views;
while (l != NULL)
{
gtk_source_view_set_insert_spaces_instead_of_tabs (
GTK_SOURCE_VIEW (l->data),
enable);
l = l->next;
}
g_list_free (views);
}
}
示例9: pluma_prefs_manager_right_margin_changed
static void
pluma_prefs_manager_right_margin_changed (GSettings *settings,
gchar *key,
gpointer user_data)
{
pluma_debug (DEBUG_PREFS);
if (strcmp (key, GPM_RIGHT_MARGIN_POSITION) == 0)
{
gint pos;
GList *views;
GList *l;
pos = g_settings_get_int (settings, key);
pos = CLAMP (pos, 1, 160);
views = pluma_app_get_views (pluma_app_get_default ());
l = views;
while (l != NULL)
{
gtk_source_view_set_right_margin_position (GTK_SOURCE_VIEW (l->data),
pos);
l = l->next;
}
g_list_free (views);
}
else if (strcmp (key, GPM_DISPLAY_RIGHT_MARGIN) == 0)
{
gboolean display;
GList *views;
GList *l;
display = g_settings_get_boolean (settings, key);
views = pluma_app_get_views (pluma_app_get_default ());
l = views;
while (l != NULL)
{
gtk_source_view_set_show_right_margin (GTK_SOURCE_VIEW (l->data),
display);
l = l->next;
}
g_list_free (views);
}
}
示例10: GlobalRegistry
SourceView::SourceView (const std::string& language, bool readOnly)
{
// Set the search path to the language and style files
gchar* directories[2];
std::string langFilesDir = GlobalRegistry().get(RKEY_APP_PATH) + "sourceviewer/";
directories[0] = const_cast<gchar*> (langFilesDir.c_str()); // stupid GtkSourceLanguageManager is expecting non-const gchar* pointer...
directories[1] = NULL;
GtkSourceStyleSchemeManager* styleSchemeManager = gtk_source_style_scheme_manager_get_default();
gtk_source_style_scheme_manager_set_search_path(styleSchemeManager, directories);
gtk_source_style_scheme_manager_force_rescan(styleSchemeManager);
_langManager = gtk_source_language_manager_new();
gtk_source_language_manager_set_search_path(_langManager, directories);
GtkSourceLanguage* lang = gtk_source_language_manager_get_language(_langManager, language.c_str());
if (lang == NULL) {
gtkutil::errorDialog(_("Cannot find language for source viewer"));
g_error("SourceView: Cannot find language %s\n", language.c_str());
throw std::runtime_error("SourceView: Cannot find language");
}
// Remember the pointers to the textbuffers
_buffer = gtk_source_buffer_new_with_language(lang);
gtk_source_buffer_set_highlight_syntax(_buffer, TRUE);
_view = GTK_SOURCE_VIEW(gtk_source_view_new_with_buffer(_buffer));
gtk_widget_set_size_request(GTK_WIDGET(_view), 0, -1); // allow shrinking
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(_view), GTK_WRAP_NONE);
gtk_text_view_set_editable(GTK_TEXT_VIEW(_view), readOnly ? FALSE : TRUE);
gtk_source_view_set_show_line_numbers(_view, TRUE);
gtk_source_view_set_auto_indent(_view, TRUE);
// Use a fixed width font
PangoFontDescription* fontDesc = pango_font_description_from_string("Monospace");
if (fontDesc != NULL) {
gtk_widget_modify_font(GTK_WIDGET(_view), fontDesc);
}
// Use a tab size of 4
gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(_view), 4);
g_signal_connect(G_OBJECT(_view), "key_press_event", G_CALLBACK(escape_clear_focus_widget), 0);
_widget = gtkutil::ScrolledFrame(GTK_WIDGET(_view));
}
示例11: impl_activate
static void
impl_activate (GeditPlugin *plugin,
GeditWindow *window)
{
WindowData *data;
GList *views, *l;
gedit_debug (DEBUG_PLUGINS);
data = g_slice_new (WindowData);
data->provider = gtk_source_completion_words_new (_("Document Words"),
NULL);
views = gedit_window_get_views (window);
for (l = views; l != NULL; l = g_list_next (l))
{
add_view (data, GTK_SOURCE_VIEW (l->data));
}
g_object_set_data_full (G_OBJECT (window),
WINDOW_DATA_KEY,
data,
(GDestroyNotify) free_window_data);
data->tab_added_id =
g_signal_connect (window, "tab-added",
G_CALLBACK (tab_added_cb),
NULL);
data->tab_removed_id =
g_signal_connect (window, "tab-removed",
G_CALLBACK (tab_removed_cb),
NULL);
}
示例12: gtk_source_gutter_set_property
static void
gtk_source_gutter_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkSourceGutter *self = GTK_SOURCE_GUTTER (object);
switch (prop_id)
{
case PROP_VIEW:
set_view (self, GTK_SOURCE_VIEW (g_value_get_object (value)));
break;
case PROP_WINDOW_TYPE:
self->priv->window_type = g_value_get_enum (value);
break;
case PROP_XPAD:
set_xpad (self, g_value_get_int (value), TRUE);
break;
case PROP_YPAD:
set_ypad (self, g_value_get_int (value), TRUE);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
示例13: message_get_view_iter
static void
message_get_view_iter (PlumaWindow *window,
PlumaMessage *message,
GtkSourceView **view,
GtkTextIter *iter)
{
if (pluma_message_has_key (message, "view"))
{
pluma_message_get (message, "view", view, NULL);
}
else
{
*view = GTK_SOURCE_VIEW (pluma_window_get_active_view (window));
}
if (!*view)
{
return;
}
if (pluma_message_has_key (message, "iter"))
{
pluma_message_get (message, "iter", iter, NULL);
}
else
{
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (*view));
gtk_text_buffer_get_iter_at_mark (buffer,
iter,
gtk_text_buffer_get_insert (buffer));
}
}
示例14: disable_bookmarks
static void
disable_bookmarks (PlumaView *view)
{
GtkTextIter start;
GtkTextIter end;
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gpointer data;
gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW (view), FALSE);
gtk_text_buffer_get_bounds (buffer, &start, &end);
gtk_source_buffer_remove_source_marks (GTK_SOURCE_BUFFER (buffer),
&start,
&end,
BOOKMARK_CATEGORY);
g_signal_handlers_disconnect_by_func (buffer, on_style_scheme_notify, view);
g_signal_handlers_disconnect_by_func (buffer, on_delete_range, NULL);
data = g_object_get_data (G_OBJECT (buffer), INSERT_DATA_KEY);
g_signal_handlers_disconnect_by_func (buffer, on_insert_text_before, data);
g_signal_handlers_disconnect_by_func (buffer, on_begin_user_action, data);
g_signal_handlers_disconnect_by_func (buffer, on_end_user_action, data);
g_object_set_data (G_OBJECT (buffer), INSERT_DATA_KEY, NULL);
}
示例15: pluma_prefs_manager_smart_home_end_changed
static void
pluma_prefs_manager_smart_home_end_changed (GSettings *settings,
gchar *key,
gpointer user_data)
{
pluma_debug (DEBUG_PREFS);
if (strcmp (key, GPM_SMART_HOME_END) == 0)
{
GtkSourceSmartHomeEndType smart_he;
GList *views;
GList *l;
smart_he = get_smart_home_end_from_string (g_settings_get_string (settings, key));
views = pluma_app_get_views (pluma_app_get_default ());
l = views;
while (l != NULL)
{
gtk_source_view_set_smart_home_end (GTK_SOURCE_VIEW (l->data),
smart_he);
l = l->next;
}
g_list_free (views);
}
}