Sun, 09 Feb 2014 22:19:47 +0530
Merge gtkdoc-conversion
--- a/ChangeLog.API Sun Feb 09 06:42:23 2014 +0530 +++ b/ChangeLog.API Sun Feb 09 22:19:47 2014 +0530 @@ -588,8 +588,16 @@ Changed: * gntft.h file renamed to gntxfer.h + * gnt_append_menu_action renamed to finch_append_menu_action + * gnt_ui_init renamed to finch_ui_init + * gnt_ui_uninit renamed to finch_ui_uninit libgnt: + Changed: + * ENTRY_CHAR renamed to GNT_ENTRY_CHAR + * g_hash_table_duplicate renamed to gnt_hash_table_duplicate + * GDupFunc renamed to GntDuplicateFunc + Removed: * _GntFileType * _GntKeyPressMode
--- a/finch/finch.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/finch.c Sun Feb 09 22:19:47 2014 +0530 @@ -41,7 +41,7 @@ g_set_prgname("Finch"); g_set_application_name(_("Finch")); - if (gnt_start(&argc, &argv)) { + if (finch_start(&argc, &argv)) { gnt_main(); #ifdef STANDALONE
--- a/finch/finch.h Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/finch.h Sun Feb 09 22:19:47 2014 +0530 @@ -38,10 +38,10 @@ #define FINCH_SET_DATA(obj, data) (obj)->ui_data = data /** - * gnt_start: + * finch_start: * * Start finch with the given command line arguments. */ -gboolean gnt_start(int *argc, char ***argv); +gboolean finch_start(int *argc, char ***argv); #endif
--- a/finch/gntblist.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/gntblist.c Sun Feb 09 22:19:47 2014 +0530 @@ -1067,7 +1067,7 @@ if (!act) continue; purple_menu_action_set_data(act, node); - gnt_append_menu_action(menu, act, node); + finch_append_menu_action(menu, act, node); } } @@ -1076,7 +1076,7 @@ gpointer data) { PurpleMenuAction *action = purple_menu_action_new(label, callback, data, NULL); - gnt_append_menu_action(menu, action, NULL); + finch_append_menu_action(menu, action, NULL); } static void @@ -1314,7 +1314,7 @@ for (iter = purple_blist_node_get_extended_menu(node); iter; iter = g_list_delete_link(iter, iter)) { - gnt_append_menu_action(menu, iter->data, node); + finch_append_menu_action(menu, iter->data, node); } }
--- a/finch/gntconv.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/gntconv.c Sun Feb 09 22:19:47 2014 +0530 @@ -396,7 +396,7 @@ for (list = purple_conversation_get_extended_menu(ggc->active_conv); list; list = g_list_delete_link(list, list)) { - gnt_append_menu_action(GNT_MENU(sub), list->data, ggc->active_conv); + finch_append_menu_action(GNT_MENU(sub), list->data, ggc->active_conv); } }
--- a/finch/gntmenuutil.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/gntmenuutil.c Sun Feb 09 22:19:47 2014 +0530 @@ -43,7 +43,7 @@ } void -gnt_append_menu_action(GntMenu *menu, PurpleMenuAction *action, gpointer ctx) +finch_append_menu_action(GntMenu *menu, PurpleMenuAction *action, gpointer ctx) { GList *list; GntMenuItem *item; @@ -64,7 +64,7 @@ GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP); gnt_menuitem_set_submenu(item, GNT_MENU(sub)); for (; list; list = g_list_delete_link(list, list)) - gnt_append_menu_action(GNT_MENU(sub), list->data, action); + finch_append_menu_action(GNT_MENU(sub), list->data, action); purple_menu_action_set_children(action, NULL); }
--- a/finch/gntmenuutil.h Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/gntmenuutil.h Sun Feb 09 22:19:47 2014 +0530 @@ -36,7 +36,7 @@ ***************************************************************************/ /** - * gnt_append_menu_action: + * finch_append_menu_action: * @menu: the GntMenu to add to * @action: the PurpleMenuAction to add * @ctx: the callback context, passed as the first argument to @@ -44,6 +44,6 @@ * * Add a PurpleMenuAction to a GntMenu. */ -void gnt_append_menu_action(GntMenu *menu, PurpleMenuAction *action, gpointer ctx); +void finch_append_menu_action(GntMenu *menu, PurpleMenuAction *action, gpointer ctx); #endif
--- a/finch/gntui.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/gntui.c Sun Feb 09 22:19:47 2014 +0530 @@ -44,7 +44,7 @@ #include <prefs.h> -void gnt_ui_init() +void finch_ui_init() { #ifdef STANDALONE gnt_init(); @@ -112,7 +112,7 @@ #ifdef STANDALONE } -void gnt_ui_uninit() +void finch_ui_uninit() { purple_accounts_set_ui_ops(NULL); finch_accounts_uninit();
--- a/finch/gntui.h Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/gntui.h Sun Feb 09 22:19:47 2014 +0530 @@ -31,7 +31,7 @@ #include "gnt.h" -void gnt_ui_init(void); -void gnt_ui_uninit(void); +void finch_ui_init(void); +void finch_ui_uninit(void); #endif
--- a/finch/libfinch.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/libfinch.c Sun Feb 09 22:19:47 2014 +0530 @@ -113,7 +113,7 @@ static void finch_quit(void) { - gnt_ui_uninit(); + finch_ui_uninit(); if (ui_info) g_hash_table_destroy(ui_info); } @@ -122,7 +122,7 @@ { finch_prefs_init, debug_init, - gnt_ui_init, + finch_ui_init, finch_quit, finch_ui_get_info, @@ -409,7 +409,7 @@ return 1; } -gboolean gnt_start(int *argc, char ***argv) +gboolean finch_start(int *argc, char ***argv) { /* Initialize the libpurple stuff */ if (!init_libpurple(*argc, *argv))
--- a/finch/libgnt/gnt-skel.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/libgnt/gnt-skel.c Sun Feb 09 22:19:47 2014 +0530 @@ -72,9 +72,9 @@ parent_class->size_request = gnt_skel_size_request; parent_class->key_pressed = gnt_skel_key_pressed; - parent_class->actions = g_hash_table_duplicate(parent_class->actions, g_str_hash, + parent_class->actions = gnt_hash_table_duplicate(parent_class->actions, g_str_hash, g_str_equal, NULL, (GDestroyNotify)gnt_widget_action_free); - parent_class->bindings = g_hash_table_duplicate(parent_class->bindings, g_str_hash, + parent_class->bindings = gnt_hash_table_duplicate(parent_class->bindings, g_str_hash, g_str_equal, NULL, (GDestroyNotify)gnt_widget_action_param_free); gnt_widget_actions_read(G_OBJECT_CLASS_TYPE(klass), klass);
--- a/finch/libgnt/gntbindable.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/libgnt/gntbindable.c Sun Feb 09 22:19:47 2014 +0530 @@ -237,12 +237,12 @@ { /* Duplicate the bindings from parent class */ if (klass->actions) { - klass->actions = g_hash_table_duplicate(klass->actions, g_str_hash, + klass->actions = gnt_hash_table_duplicate(klass->actions, g_str_hash, g_str_equal, g_free, (GDestroyNotify)gnt_bindable_action_free, - (GDupFunc)g_strdup, (GDupFunc)bindable_clone); - klass->bindings = g_hash_table_duplicate(klass->bindings, g_str_hash, + (GntDuplicateFunc)g_strdup, (GntDuplicateFunc)bindable_clone); + klass->bindings = gnt_hash_table_duplicate(klass->bindings, g_str_hash, g_str_equal, g_free, (GDestroyNotify)gnt_bindable_action_param_free, - (GDupFunc)g_strdup, (GDupFunc)binding_clone); + (GntDuplicateFunc)g_strdup, (GntDuplicateFunc)binding_clone); } else { klass->actions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)gnt_bindable_action_free);
--- a/finch/libgnt/gntentry.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/libgnt/gntentry.c Sun Feb 09 22:19:47 2014 +0530 @@ -294,7 +294,7 @@ stop = gnt_util_onscreen_width(entry->scroll, entry->end); if (stop < widget->priv.width) - mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop); + mvwhline(widget->window, 0, stop, GNT_ENTRY_CHAR, widget->priv.width - stop); curpos = gnt_util_onscreen_width(entry->scroll, entry->cursor); if (focus)
--- a/finch/libgnt/gntentry.h Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/libgnt/gntentry.h Sun Feb 09 22:19:47 2014 +0530 @@ -45,7 +45,7 @@ #define GNT_ENTRY_SET_FLAGS(obj, flags) (GNT_ENTRY_FLAGS(obj) |= flags) #define GNT_ENTRY_UNSET_FLAGS(obj, flags) (GNT_ENTRY_FLAGS(obj) &= ~(flags)) -#define ENTRY_CHAR '_' /* The character to use to fill in the blank places */ +#define GNT_ENTRY_CHAR '_' /* The character to use to fill in the blank places */ typedef struct _GntEntry GntEntry; typedef struct _GntEntryPriv GntEntryPriv;
--- a/finch/libgnt/gntutils.c Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/libgnt/gntutils.c Sun Feb 09 22:19:47 2014 +0530 @@ -148,8 +148,8 @@ struct duplicate_fns { - GDupFunc key_dup; - GDupFunc value_dup; + GntDuplicateFunc key_dup; + GntDuplicateFunc value_dup; GHashTable *table; }; @@ -161,9 +161,9 @@ fns->value_dup ? fns->value_dup(value) : value); } -GHashTable *g_hash_table_duplicate(GHashTable *src, GHashFunc hash, +GHashTable *gnt_hash_table_duplicate(GHashTable *src, GHashFunc hash, GEqualFunc equal, GDestroyNotify key_d, GDestroyNotify value_d, - GDupFunc key_dup, GDupFunc value_dup) + GntDuplicateFunc key_dup, GntDuplicateFunc value_dup) { GHashTable *dest = g_hash_table_new_full(hash, equal, key_d, value_d); struct duplicate_fns fns = {key_dup, value_dup, dest};
--- a/finch/libgnt/gntutils.h Sun Feb 09 06:42:23 2014 +0530 +++ b/finch/libgnt/gntutils.h Sun Feb 09 22:19:47 2014 +0530 @@ -35,7 +35,7 @@ #include "gnttextview.h" #include "gntwidget.h" -typedef gpointer (*GDupFunc)(gconstpointer data); +typedef gpointer (*GntDuplicateFunc)(gconstpointer data); /** * gnt_util_get_text_bound: @@ -87,7 +87,7 @@ char * gnt_util_onscreen_fit_string(const char *string, int maxw); /** - * g_hash_table_duplicate: + * gnt_hash_table_duplicate: * @src: The source hashtable. * @hash: The hash-function to use. * @equal: The hash-equal function to use. @@ -100,7 +100,7 @@ * * Returns: The new hashtable. */ -GHashTable * g_hash_table_duplicate(GHashTable *src, GHashFunc hash, GEqualFunc equal, GDestroyNotify key_d, GDestroyNotify value_d, GDupFunc key_dup, GDupFunc value_dup); +GHashTable * gnt_hash_table_duplicate(GHashTable *src, GHashFunc hash, GEqualFunc equal, GDestroyNotify key_d, GDestroyNotify value_d, GntDuplicateFunc key_dup, GntDuplicateFunc value_dup); /** * gnt_boolean_handled_accumulator:
--- a/pidgin/Makefile.am Sun Feb 09 06:42:23 2014 +0530 +++ b/pidgin/Makefile.am Sun Feb 09 22:19:47 2014 +0530 @@ -77,9 +77,6 @@ gtksession.c \ gtksmiley.c \ gtksound.c \ - gtksourceiter.c \ - gtksourceundomanager.c \ - gtksourceview-marshal.c \ gtkstatus-icon-theme.c \ gtkstatusbox.c \ gtkthemes.c \ @@ -130,9 +127,6 @@ gtksession.h \ gtksmiley.h \ gtksound.h \ - gtksourceiter.h \ - gtksourceundomanager.h \ - gtksourceview-marshal.h \ gtkstatus-icon-theme.h \ gtkstatusbox.h \ pidginstock.h \
--- a/pidgin/Makefile.mingw Sun Feb 09 06:42:23 2014 +0530 +++ b/pidgin/Makefile.mingw Sun Feb 09 22:19:47 2014 +0530 @@ -92,8 +92,6 @@ gtkscrollbook.c \ gtksmiley.c \ gtksound.c \ - gtksourceiter.c \ - gtksourceundomanager.c \ gtkstatus-icon-theme.c \ gtkstatusbox.c \ gtkthemes.c \
--- a/pidgin/gtksourceiter.c Sun Feb 09 06:42:23 2014 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,766 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * gtksourceiter.c - * - * Pidgin is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * The following copyright notice applies to this file: - * - * Copyright (C) 2000 - 2005 Paolo Maggi - * Copyright (C) 2002, 2003 Jeroen Zwartepoorte - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. - */ - -/* - * Parts of this file are copied from the gedit and glimmer project. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include "gtksourceiter.h" - -#define GTK_TEXT_UNKNOWN_CHAR 0xFFFC - -/* this function acts like g_utf8_offset_to_pointer() except that if it finds a - * decomposable character it consumes the decomposition length from the given - * offset. So it's useful when the offset was calculated for the normalized - * version of str, but we need a pointer to str itself. */ -static const gchar * -pointer_from_offset_skipping_decomp (const gchar *str, gint offset) -{ - gchar *casefold, *normal; - const gchar *p, *q; - - p = str; - while (offset > 0) - { - q = g_utf8_next_char (p); - casefold = g_utf8_casefold (p, q - p); - normal = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - offset -= g_utf8_strlen (normal, -1); - g_free (casefold); - g_free (normal); - p = q; - } - return p; -} - -static const gchar * -g_utf8_strcasestr (const gchar *haystack, const gchar *needle) -{ - gsize needle_len; - gsize haystack_len; - const gchar *ret = NULL; - gchar *p; - gchar *casefold; - gchar *caseless_haystack; - gint i; - - g_return_val_if_fail (haystack != NULL, NULL); - g_return_val_if_fail (needle != NULL, NULL); - - casefold = g_utf8_casefold (haystack, -1); - caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - - needle_len = g_utf8_strlen (needle, -1); - haystack_len = g_utf8_strlen (caseless_haystack, -1); - - if (needle_len == 0) - { - ret = (gchar *)haystack; - goto finally_1; - } - - if (haystack_len < needle_len) - { - ret = NULL; - goto finally_1; - } - - p = (gchar*)caseless_haystack; - needle_len = strlen (needle); - i = 0; - - while (*p) - { - if ((strncmp (p, needle, needle_len) == 0)) - { - ret = pointer_from_offset_skipping_decomp (haystack, i); - goto finally_1; - } - - p = g_utf8_next_char (p); - i++; - } - -finally_1: - g_free (caseless_haystack); - - return ret; -} - -static const gchar * -g_utf8_strrcasestr (const gchar *haystack, const gchar *needle) -{ - gsize needle_len; - gsize haystack_len; - const gchar *ret = NULL; - gchar *p; - gchar *casefold; - gchar *caseless_haystack; - gint i; - - g_return_val_if_fail (haystack != NULL, NULL); - g_return_val_if_fail (needle != NULL, NULL); - - casefold = g_utf8_casefold (haystack, -1); - caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - - needle_len = g_utf8_strlen (needle, -1); - haystack_len = g_utf8_strlen (caseless_haystack, -1); - - if (needle_len == 0) - { - ret = (gchar *)haystack; - goto finally_1; - } - - if (haystack_len < needle_len) - { - ret = NULL; - goto finally_1; - } - - i = haystack_len - needle_len; - p = g_utf8_offset_to_pointer (caseless_haystack, i); - needle_len = strlen (needle); - - while (1) - { - if (strncmp (p, needle, needle_len) == 0) - { - ret = pointer_from_offset_skipping_decomp (haystack, i); - goto finally_1; - } - - if (p > caseless_haystack) - p = g_utf8_prev_char (p); - else - goto finally_1; - - i--; - } - -finally_1: - g_free (caseless_haystack); - - return ret; -} - -static gboolean -g_utf8_caselessnmatch (const char *s1, const char *s2, - gssize n1, gssize n2) -{ - gchar *casefold; - gchar *normalized_s1; - gchar *normalized_s2; - gint len_s1; - gint len_s2; - gboolean ret = FALSE; - - g_return_val_if_fail (s1 != NULL, FALSE); - g_return_val_if_fail (s2 != NULL, FALSE); - g_return_val_if_fail (n1 > 0, FALSE); - g_return_val_if_fail (n2 > 0, FALSE); - - casefold = g_utf8_casefold (s1, n1); - normalized_s1 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - - casefold = g_utf8_casefold (s2, n2); - normalized_s2 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - - len_s1 = strlen (normalized_s1); - len_s2 = strlen (normalized_s2); - - if (len_s1 < len_s2) - goto finally_2; - - ret = (strncmp (normalized_s1, normalized_s2, len_s2) == 0); - -finally_2: - g_free (normalized_s1); - g_free (normalized_s2); - - return ret; -} - -static void -forward_chars_with_skipping (GtkTextIter *iter, - gint count, - gboolean skip_invisible, - gboolean skip_nontext, - gboolean skip_decomp) -{ - gint i; - - g_return_if_fail (count >= 0); - - i = count; - - while (i > 0) - { - gboolean ignored = FALSE; - - /* minimal workaround to avoid the infinite loop of bug #168247. - * It doesn't fix the problemjust the symptom... - */ - if (gtk_text_iter_is_end (iter)) - return; - - if (skip_nontext && gtk_text_iter_get_char (iter) == GTK_TEXT_UNKNOWN_CHAR) - ignored = TRUE; - -#if 0 - if (!ignored && skip_invisible && - /* _gtk_text_btree_char_is_invisible (iter)*/ FALSE) - ignored = TRUE; -#endif - - if (!ignored && skip_decomp) - { - /* being UTF8 correct sucks; this accounts for extra - offsets coming from canonical decompositions of - UTF8 characters (e.g. accented characters) which - g_utf8_normalize() performs */ - gchar *normal; - gchar buffer[6]; - gint buffer_len; - - buffer_len = g_unichar_to_utf8 (gtk_text_iter_get_char (iter), buffer); - normal = g_utf8_normalize (buffer, buffer_len, G_NORMALIZE_NFD); - i -= (g_utf8_strlen (normal, -1) - 1); - g_free (normal); - } - - gtk_text_iter_forward_char (iter); - - if (!ignored) - --i; - } -} - -static gboolean -lines_match (const GtkTextIter *start, - const gchar **lines, - gboolean visible_only, - gboolean slice, - GtkTextIter *match_start, - GtkTextIter *match_end) -{ - GtkTextIter next; - gchar *line_text; - const gchar *found; - gint offset; - - if (*lines == NULL || **lines == '\0') - { - if (match_start) - *match_start = *start; - if (match_end) - *match_end = *start; - return TRUE; - } - - next = *start; - gtk_text_iter_forward_line (&next); - - /* No more text in buffer, but *lines is nonempty */ - if (gtk_text_iter_equal (start, &next)) - return FALSE; - - if (slice) - { - if (visible_only) - line_text = gtk_text_iter_get_visible_slice (start, &next); - else - line_text = gtk_text_iter_get_slice (start, &next); - } - else - { - if (visible_only) - line_text = gtk_text_iter_get_visible_text (start, &next); - else - line_text = gtk_text_iter_get_text (start, &next); - } - - if (match_start) /* if this is the first line we're matching */ - { - found = g_utf8_strcasestr (line_text, *lines); - } - else - { - /* If it's not the first line, we have to match from the - * start of the line. - */ - if (g_utf8_caselessnmatch (line_text, *lines, strlen (line_text), - strlen (*lines))) - found = line_text; - else - found = NULL; - } - - if (found == NULL) - { - g_free (line_text); - return FALSE; - } - - /* Get offset to start of search string */ - offset = g_utf8_strlen (line_text, found - line_text); - - next = *start; - - /* If match start needs to be returned, set it to the - * start of the search string. - */ - forward_chars_with_skipping (&next, offset, visible_only, !slice, FALSE); - if (match_start) - { - *match_start = next; - } - - /* Go to end of search string */ - forward_chars_with_skipping (&next, g_utf8_strlen (*lines, -1), visible_only, !slice, TRUE); - - g_free (line_text); - - ++lines; - - if (match_end) - *match_end = next; - - /* pass NULL for match_start, since we don't need to find the - * start again. - */ - return lines_match (&next, lines, visible_only, slice, NULL, match_end); -} - -static gboolean -backward_lines_match (const GtkTextIter *start, - const gchar **lines, - gboolean visible_only, - gboolean slice, - GtkTextIter *match_start, - GtkTextIter *match_end) -{ - GtkTextIter line, next; - gchar *line_text; - const gchar *found; - gint offset; - - if (*lines == NULL || **lines == '\0') - { - if (match_start) - *match_start = *start; - if (match_end) - *match_end = *start; - return TRUE; - } - - line = next = *start; - if (gtk_text_iter_get_line_offset (&next) == 0) - { - if (!gtk_text_iter_backward_line (&next)) - return FALSE; - } - else - gtk_text_iter_set_line_offset (&next, 0); - - if (slice) - { - if (visible_only) - line_text = gtk_text_iter_get_visible_slice (&next, &line); - else - line_text = gtk_text_iter_get_slice (&next, &line); - } - else - { - if (visible_only) - line_text = gtk_text_iter_get_visible_text (&next, &line); - else - line_text = gtk_text_iter_get_text (&next, &line); - } - - if (match_start) /* if this is the first line we're matching */ - { - found = g_utf8_strrcasestr (line_text, *lines); - } - else - { - /* If it's not the first line, we have to match from the - * start of the line. - */ - if (g_utf8_caselessnmatch (line_text, *lines, strlen (line_text), - strlen (*lines))) - found = line_text; - else - found = NULL; - } - - if (found == NULL) - { - g_free (line_text); - return FALSE; - } - - /* Get offset to start of search string */ - offset = g_utf8_strlen (line_text, found - line_text); - - forward_chars_with_skipping (&next, offset, visible_only, !slice, FALSE); - - /* If match start needs to be returned, set it to the - * start of the search string. - */ - if (match_start) - { - *match_start = next; - } - - /* Go to end of search string */ - forward_chars_with_skipping (&next, g_utf8_strlen (*lines, -1), visible_only, !slice, TRUE); - - g_free (line_text); - - ++lines; - - if (match_end) - *match_end = next; - - /* try to match the rest of the lines forward, passing NULL - * for match_start so lines_match will try to match the entire - * line */ - return lines_match (&next, lines, visible_only, - slice, NULL, match_end); -} - -/* strsplit () that retains the delimiter as part of the string. */ -static gchar ** -strbreakup (const char *string, - const char *delimiter, - gint max_tokens) -{ - GSList *string_list = NULL, *slist; - gchar **str_array, *s, *casefold, *new_string; - guint i, n = 1; - - g_return_val_if_fail (string != NULL, NULL); - g_return_val_if_fail (delimiter != NULL, NULL); - - if (max_tokens < 1) - max_tokens = G_MAXINT; - - s = strstr (string, delimiter); - if (s) - { - guint delimiter_len = strlen (delimiter); - - do - { - guint len; - - len = s - string + delimiter_len; - new_string = g_new (gchar, len + 1); - strncpy (new_string, string, len); - new_string[len] = 0; - casefold = g_utf8_casefold (new_string, -1); - g_free (new_string); - new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - string_list = g_slist_prepend (string_list, new_string); - n++; - string = s + delimiter_len; - s = strstr (string, delimiter); - } while (--max_tokens && s); - } - - if (*string) - { - n++; - casefold = g_utf8_casefold (string, -1); - new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - string_list = g_slist_prepend (string_list, new_string); - } - - str_array = g_new (gchar*, n); - - i = n - 1; - - str_array[i--] = NULL; - for (slist = string_list; slist; slist = slist->next) - str_array[i--] = slist->data; - - g_slist_free (string_list); - - return str_array; -} - -/** - * gtk_source_iter_forward_search: - * @iter: start of search. - * @str: a search string. - * @flags: flags affecting how the search is done. - * @match_start: return location for start of match, or %%NULL. - * @match_end: return location for end of match, or %%NULL. - * @limit: bound for the search, or %%NULL for the end of the buffer. - * - * Searches forward for @str. Any match is returned by setting - * @match_start to the first character of the match and @match_end to the - * first character after the match. The search will not continue past - * @limit. Note that a search is a linear or O(n) operation, so you - * may wish to use @limit to avoid locking up your UI on large - * buffers. - * - * If the #GTK_SOURCE_SEARCH_VISIBLE_ONLY flag is present, the match may - * have invisible text interspersed in @str. i.e. @str will be a - * possibly-noncontiguous subsequence of the matched range. similarly, - * if you specify #GTK_SOURCE_SEARCH_TEXT_ONLY, the match may have - * pixbufs or child widgets mixed inside the matched range. If these - * flags are not given, the match must be exact; the special 0xFFFC - * character in @str will match embedded pixbufs or child widgets. - * If you specify the #GTK_SOURCE_SEARCH_CASE_INSENSITIVE flag, the text will - * be matched regardless of what case it is in. - * - * Same as gtk_text_iter_forward_search(), but supports case insensitive - * searching. - * - * Return value: whether a match was found. - **/ -gboolean -gtk_source_iter_forward_search (const GtkTextIter *iter, - const gchar *str, - GtkSourceSearchFlags flags, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter *limit) -{ - gchar **lines = NULL; - GtkTextIter match; - gboolean retval = FALSE; - GtkTextIter search; - gboolean visible_only; - gboolean slice; - - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (str != NULL, FALSE); - - if ((flags & GTK_SOURCE_SEARCH_CASE_INSENSITIVE) == 0) { - return gtk_text_iter_forward_search (iter, str, - (GtkTextSearchFlags)flags, match_start, match_end, - limit); - } - - if (limit && gtk_text_iter_compare (iter, limit) >= 0) - return FALSE; - - if (*str == '\0') - { - /* If we can move one char, return the empty string there */ - match = *iter; - - if (gtk_text_iter_forward_char (&match)) - { - if (limit && gtk_text_iter_equal (&match, limit)) - return FALSE; - - if (match_start) - *match_start = match; - if (match_end) - *match_end = match; - return TRUE; - } - else - { - return FALSE; - } - } - - visible_only = (flags & GTK_SOURCE_SEARCH_VISIBLE_ONLY) != 0; - slice = (flags & GTK_SOURCE_SEARCH_TEXT_ONLY) == 0; - - /* locate all lines */ - lines = strbreakup (str, "\n", -1); - - search = *iter; - - do - { - /* This loop has an inefficient worst-case, where - * gtk_text_iter_get_text () is called repeatedly on - * a single line. - */ - GtkTextIter end; - - if (limit && gtk_text_iter_compare (&search, limit) >= 0) - break; - - if (lines_match (&search, (const gchar**)lines, - visible_only, slice, &match, &end)) - { - if (limit == NULL || - (limit && gtk_text_iter_compare (&end, limit) <= 0)) - { - retval = TRUE; - - if (match_start) - *match_start = match; - if (match_end) - *match_end = end; - } - break; - } - } while (gtk_text_iter_forward_line (&search)); - - g_strfreev ((gchar**)lines); - - return retval; -} - -/** - * gtk_source_iter_backward_search: - * @iter: a #GtkTextIter where the search begins. - * @str: search string. - * @flags: bitmask of flags affecting the search. - * @match_start: return location for start of match, or %%NULL. - * @match_end: return location for end of match, or %%NULL. - * @limit: location of last possible @match_start, or %%NULL for start of buffer. - * - * Same as gtk_text_iter_backward_search(), but supports case insensitive - * searching. - * - * Return value: whether a match was found. - **/ -gboolean -gtk_source_iter_backward_search (const GtkTextIter *iter, - const gchar *str, - GtkSourceSearchFlags flags, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter *limit) -{ - gchar **lines = NULL; - GtkTextIter match; - gboolean retval = FALSE; - GtkTextIter search; - gboolean visible_only; - gboolean slice; - - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (str != NULL, FALSE); - - if ((flags & GTK_SOURCE_SEARCH_CASE_INSENSITIVE) == 0) { - return gtk_text_iter_backward_search (iter, str, - (GtkTextSearchFlags)flags, match_start, match_end, - limit); - } - - if (limit && gtk_text_iter_compare (iter, limit) <= 0) - return FALSE; - - if (*str == '\0') - { - /* If we can move one char, return the empty string there */ - match = *iter; - - if (gtk_text_iter_backward_char (&match)) - { - if (limit && gtk_text_iter_equal (&match, limit)) - return FALSE; - - if (match_start) - *match_start = match; - if (match_end) - *match_end = match; - return TRUE; - } - else - { - return FALSE; - } - } - - visible_only = (flags & GTK_SOURCE_SEARCH_VISIBLE_ONLY) != 0; - slice = (flags & GTK_SOURCE_SEARCH_TEXT_ONLY) == 0; - - /* locate all lines */ - lines = strbreakup (str, "\n", -1); - - search = *iter; - - while (TRUE) - { - /* This loop has an inefficient worst-case, where - * gtk_text_iter_get_text () is called repeatedly on - * a single line. - */ - GtkTextIter end; - - if (limit && gtk_text_iter_compare (&search, limit) <= 0) - break; - - if (backward_lines_match (&search, (const gchar**)lines, - visible_only, slice, &match, &end)) - { - if (limit == NULL || (limit && - gtk_text_iter_compare (&end, limit) > 0)) - { - retval = TRUE; - - if (match_start) - *match_start = match; - if (match_end) - *match_end = end; - } - break; - } - - if (gtk_text_iter_get_line_offset (&search) == 0) - { - if (!gtk_text_iter_backward_line (&search)) - break; - } - else - { - gtk_text_iter_set_line_offset (&search, 0); - } - } - - g_strfreev ((gchar**)lines); - - return retval; -} - -/* - * gtk_source_iter_find_matching_bracket is implemented in gtksourcebuffer.c - */
--- a/pidgin/gtksourceiter.h Sun Feb 09 06:42:23 2014 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * gtksourceiter.h - * - * Pidgin is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * The following copyright notice applies to this file: - * - * Copyright (C) 2000 - 2005 Paolo Maggi - * Copyright (C) 2002, 2003 Jeroen Zwartepoorte - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. - */ - -#ifndef _PIDGINSOURCEITER_H_ -#define _PIDGINSOURCEITER_H_ -/** - * SECTION:gtksourceiter - * @section_id: pidgin-gtksourceiter - * @short_description: <filename>gtksourceiter.h</filename> - * @title: Source Iterator utilities - */ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -typedef enum -{ - GTK_SOURCE_SEARCH_VISIBLE_ONLY = 1 << 0, - GTK_SOURCE_SEARCH_TEXT_ONLY = 1 << 1, - GTK_SOURCE_SEARCH_CASE_INSENSITIVE = 1 << 2 - /* Possible future plans: SEARCH_REGEXP */ -} GtkSourceSearchFlags; - -gboolean gtk_source_iter_forward_search (const GtkTextIter *iter, - const gchar *str, - GtkSourceSearchFlags flags, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter *limit); - -gboolean gtk_source_iter_backward_search (const GtkTextIter *iter, - const gchar *str, - GtkSourceSearchFlags flags, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter *limit); - -gboolean gtk_source_iter_find_matching_bracket (GtkTextIter *iter); - -G_END_DECLS - -#endif /* _PIDGINSOURCEITER_H_ */
--- a/pidgin/gtksourceundomanager.c Sun Feb 09 06:42:23 2014 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1197 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gtksourceundomanager.c - * This file is part of GtkSourceView - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * Copyright (C) 2002-2005 Paolo Maggi - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <stdlib.h> -#include <string.h> - -#include "gtksourceundomanager.h" -#include "gtksourceview-marshal.h" - - -#define DEFAULT_MAX_UNDO_LEVELS 25 - - -typedef struct _GtkSourceUndoAction GtkSourceUndoAction; -typedef struct _GtkSourceUndoInsertAction GtkSourceUndoInsertAction; -typedef struct _GtkSourceUndoDeleteAction GtkSourceUndoDeleteAction; -typedef struct _GtkSourceUndoInsertAnchorAction GtkSourceUndoInsertAnchorAction; - -typedef enum { - GTK_SOURCE_UNDO_ACTION_INSERT, - GTK_SOURCE_UNDO_ACTION_DELETE, - GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR, -} GtkSourceUndoActionType; - -/* - * We use offsets instead of GtkTextIters because the last ones - * require to much memory in this context without giving us any advantage. - */ - -struct _GtkSourceUndoInsertAction -{ - gint pos; - gchar *text; - gint length; - gint chars; -}; - -struct _GtkSourceUndoDeleteAction -{ - gint start; - gint end; - gchar *text; - gboolean forward; -}; - -struct _GtkSourceUndoInsertAnchorAction -{ - gint pos; - GtkTextChildAnchor *anchor; -}; - -struct _GtkSourceUndoAction -{ - GtkSourceUndoActionType action_type; - - union { - GtkSourceUndoInsertAction insert; - GtkSourceUndoDeleteAction delete; - GtkSourceUndoInsertAnchorAction insert_anchor; - } action; - - gint order_in_group; - - /* It is TRUE whether the action can be merged with the following action. */ - guint mergeable : 1; - - /* It is TRUE whether the action is marked as "modified". - * An action is marked as "modified" if it changed the - * state of the buffer from "not modified" to "modified". Only the first - * action of a group can be marked as modified. - * There can be a single action marked as "modified" in the actions list. - */ - guint modified : 1; -}; - -struct _GtkSourceUndoManagerPrivate -{ - GtkTextBuffer *document; - - GList* actions; - gint next_redo; - - gint actions_in_current_group; - - gint running_not_undoable_actions; - - gint num_of_groups; - - gint max_undo_levels; - - guint can_undo : 1; - guint can_redo : 1; - - /* It is TRUE whether, while undoing an action of the current group (with order_in_group > 1), - * the state of the buffer changed from "not modified" to "modified". - */ - guint modified_undoing_group : 1; - - /* Pointer to the action (in the action list) marked as "modified". - * It is NULL when no action is marked as "modified". */ - GtkSourceUndoAction *modified_action; -}; - -enum { - CAN_UNDO, - CAN_REDO, - LAST_SIGNAL -}; - -static void gtk_source_undo_manager_class_init (GtkSourceUndoManagerClass *klass); -static void gtk_source_undo_manager_init (GtkSourceUndoManager *um); -static void gtk_source_undo_manager_finalize (GObject *object); - -static void gtk_source_undo_manager_insert_text_handler (GtkTextBuffer *buffer, - GtkTextIter *pos, - const gchar *text, - gint length, - GtkSourceUndoManager *um); -static void gtk_source_undo_manager_insert_anchor_handler (GtkTextBuffer *buffer, - GtkTextIter *pos, - GtkTextChildAnchor *anchor, - GtkSourceUndoManager *um); -static void gtk_source_undo_manager_delete_range_handler (GtkTextBuffer *buffer, - GtkTextIter *start, - GtkTextIter *end, - GtkSourceUndoManager *um); -static void gtk_source_undo_manager_begin_user_action_handler (GtkTextBuffer *buffer, - GtkSourceUndoManager *um); -static void gtk_source_undo_manager_modified_changed_handler (GtkTextBuffer *buffer, - GtkSourceUndoManager *um); - -static void gtk_source_undo_manager_free_action_list (GtkSourceUndoManager *um); - -static void gtk_source_undo_manager_add_action (GtkSourceUndoManager *um, - const GtkSourceUndoAction *undo_action); -static void gtk_source_undo_manager_free_first_n_actions (GtkSourceUndoManager *um, - gint n); -static void gtk_source_undo_manager_check_list_size (GtkSourceUndoManager *um); - -static gboolean gtk_source_undo_manager_merge_action (GtkSourceUndoManager *um, - const GtkSourceUndoAction *undo_action); - -static GObjectClass *parent_class = NULL; -static guint undo_manager_signals [LAST_SIGNAL] = { 0 }; - -GType -gtk_source_undo_manager_get_type (void) -{ - static GType undo_manager_type = 0; - - if (undo_manager_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GtkSourceUndoManagerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_source_undo_manager_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkSourceUndoManager), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_source_undo_manager_init, - NULL /* value_table */ - }; - - undo_manager_type = g_type_register_static (G_TYPE_OBJECT, - "GtkSourceUndoManager", - &our_info, - 0); - } - - return undo_manager_type; -} - -static void -gtk_source_undo_manager_class_init (GtkSourceUndoManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gtk_source_undo_manager_finalize; - - klass->can_undo = NULL; - klass->can_redo = NULL; - - undo_manager_signals[CAN_UNDO] = - g_signal_new ("can_undo", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkSourceUndoManagerClass, can_undo), - NULL, NULL, - gtksourceview_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); - - undo_manager_signals[CAN_REDO] = - g_signal_new ("can_redo", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkSourceUndoManagerClass, can_redo), - NULL, NULL, - gtksourceview_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); -} - -static void -gtk_source_undo_manager_init (GtkSourceUndoManager *um) -{ - um->priv = g_new0 (GtkSourceUndoManagerPrivate, 1); - - um->priv->actions = NULL; - um->priv->next_redo = 0; - - um->priv->can_undo = FALSE; - um->priv->can_redo = FALSE; - - um->priv->running_not_undoable_actions = 0; - - um->priv->num_of_groups = 0; - - um->priv->max_undo_levels = DEFAULT_MAX_UNDO_LEVELS; - - um->priv->modified_action = NULL; - - um->priv->modified_undoing_group = FALSE; -} - -static void -gtk_source_undo_manager_finalize (GObject *object) -{ - GtkSourceUndoManager *um; - - g_return_if_fail (object != NULL); - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (object)); - - um = GTK_SOURCE_UNDO_MANAGER (object); - - g_return_if_fail (um->priv != NULL); - - if (um->priv->actions != NULL) - { - gtk_source_undo_manager_free_action_list (um); - } - - g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document), - G_CALLBACK (gtk_source_undo_manager_delete_range_handler), - um); - - g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document), - G_CALLBACK (gtk_source_undo_manager_insert_text_handler), - um); - - g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document), - G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler), - um); - - g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document), - G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler), - um); - - g_free (um->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -GtkSourceUndoManager* -gtk_source_undo_manager_new (GtkTextBuffer* buffer) -{ - GtkSourceUndoManager *um; - - um = GTK_SOURCE_UNDO_MANAGER (g_object_new (GTK_SOURCE_TYPE_UNDO_MANAGER, NULL)); - - g_return_val_if_fail (um->priv != NULL, NULL); - um->priv->document = buffer; - - g_signal_connect (G_OBJECT (buffer), "insert_text", - G_CALLBACK (gtk_source_undo_manager_insert_text_handler), - um); - - g_signal_connect (G_OBJECT (buffer), "insert_child_anchor", - G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler), - um); - - g_signal_connect (G_OBJECT (buffer), "delete_range", - G_CALLBACK (gtk_source_undo_manager_delete_range_handler), - um); - - g_signal_connect (G_OBJECT (buffer), "begin_user_action", - G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler), - um); - - g_signal_connect (G_OBJECT (buffer), "modified_changed", - G_CALLBACK (gtk_source_undo_manager_modified_changed_handler), - um); - return um; -} - -void -gtk_source_undo_manager_begin_not_undoable_action (GtkSourceUndoManager *um) -{ - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - ++um->priv->running_not_undoable_actions; -} - -static void -gtk_source_undo_manager_end_not_undoable_action_internal (GtkSourceUndoManager *um) -{ - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - g_return_if_fail (um->priv->running_not_undoable_actions > 0); - - --um->priv->running_not_undoable_actions; -} - -void -gtk_source_undo_manager_end_not_undoable_action (GtkSourceUndoManager *um) -{ - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - gtk_source_undo_manager_end_not_undoable_action_internal (um); - - if (um->priv->running_not_undoable_actions == 0) - { - gtk_source_undo_manager_free_action_list (um); - - um->priv->next_redo = -1; - - if (um->priv->can_undo) - { - um->priv->can_undo = FALSE; - g_signal_emit (G_OBJECT (um), - undo_manager_signals [CAN_UNDO], - 0, - FALSE); - } - - if (um->priv->can_redo) - { - um->priv->can_redo = FALSE; - g_signal_emit (G_OBJECT (um), - undo_manager_signals [CAN_REDO], - 0, - FALSE); - } - } -} - -gboolean -gtk_source_undo_manager_can_undo (const GtkSourceUndoManager *um) -{ - g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), FALSE); - g_return_val_if_fail (um->priv != NULL, FALSE); - - return um->priv->can_undo; -} - -gboolean -gtk_source_undo_manager_can_redo (const GtkSourceUndoManager *um) -{ - g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), FALSE); - g_return_val_if_fail (um->priv != NULL, FALSE); - - return um->priv->can_redo; -} - -static void -set_cursor (GtkTextBuffer *buffer, gint cursor) -{ - GtkTextIter iter; - - /* Place the cursor at the requested position */ - gtk_text_buffer_get_iter_at_offset (buffer, &iter, cursor); - gtk_text_buffer_place_cursor (buffer, &iter); -} - -static void -insert_text (GtkTextBuffer *buffer, gint pos, const gchar *text, gint len) -{ - GtkTextIter iter; - - gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos); - gtk_text_buffer_insert (buffer, &iter, text, len); -} - -static void -insert_anchor (GtkTextBuffer *buffer, gint pos, GtkTextChildAnchor *anchor) -{ - GtkTextIter iter; - - gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos); - gtk_text_buffer_insert_child_anchor (buffer, &iter, anchor); -} - -static void -delete_text (GtkTextBuffer *buffer, gint start, gint end) -{ - GtkTextIter start_iter; - GtkTextIter end_iter; - - gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, start); - - if (end < 0) - gtk_text_buffer_get_end_iter (buffer, &end_iter); - else - gtk_text_buffer_get_iter_at_offset (buffer, &end_iter, end); - - gtk_text_buffer_delete (buffer, &start_iter, &end_iter); -} - -static gchar* -get_chars (GtkTextBuffer *buffer, gint start, gint end) -{ - GtkTextIter start_iter; - GtkTextIter end_iter; - - gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, start); - - if (end < 0) - gtk_text_buffer_get_end_iter (buffer, &end_iter); - else - gtk_text_buffer_get_iter_at_offset (buffer, &end_iter, end); - - return gtk_text_buffer_get_slice (buffer, &start_iter, &end_iter, TRUE); -} - -void -gtk_source_undo_manager_undo (GtkSourceUndoManager *um) -{ - GtkSourceUndoAction *undo_action; - gboolean modified = FALSE; - - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - g_return_if_fail (um->priv->can_undo); - - um->priv->modified_undoing_group = FALSE; - - gtk_source_undo_manager_begin_not_undoable_action (um); - - do - { - undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo + 1); - g_return_if_fail (undo_action != NULL); - - /* undo_action->modified can be TRUE only if undo_action->order_in_group <= 1 */ - g_return_if_fail ((undo_action->order_in_group <= 1) || - ((undo_action->order_in_group > 1) && !undo_action->modified)); - - if (undo_action->order_in_group <= 1) - { - /* Set modified to TRUE only if the buffer did not change its state from - * "not modified" to "modified" undoing an action (with order_in_group > 1) - * in current group. */ - modified = (undo_action->modified && !um->priv->modified_undoing_group); - } - - switch (undo_action->action_type) - { - case GTK_SOURCE_UNDO_ACTION_DELETE: - insert_text ( - um->priv->document, - undo_action->action.delete.start, - undo_action->action.delete.text, - strlen (undo_action->action.delete.text)); - - if (undo_action->action.delete.forward) - set_cursor ( - um->priv->document, - undo_action->action.delete.start); - else - set_cursor ( - um->priv->document, - undo_action->action.delete.end); - - break; - - case GTK_SOURCE_UNDO_ACTION_INSERT: - delete_text ( - um->priv->document, - undo_action->action.insert.pos, - undo_action->action.insert.pos + - undo_action->action.insert.chars); - - set_cursor ( - um->priv->document, - undo_action->action.insert.pos); - break; - - case GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR: - delete_text ( - um->priv->document, - undo_action->action.insert_anchor.pos, - undo_action->action.insert_anchor.pos + 1); -#if !GTK_CHECK_VERSION(3,0,0) - undo_action->action.insert_anchor.anchor->segment = NULL; /* XXX: This may be a bug in GTK+ */ -#endif - break; - default: - /* Unknown action type. */ - g_return_if_reached (); - } - - ++um->priv->next_redo; - - } while (undo_action->order_in_group > 1); - - if (modified) - { - --um->priv->next_redo; - gtk_text_buffer_set_modified (um->priv->document, FALSE); - ++um->priv->next_redo; - } - - gtk_source_undo_manager_end_not_undoable_action_internal (um); - - um->priv->modified_undoing_group = FALSE; - - if (!um->priv->can_redo) - { - um->priv->can_redo = TRUE; - g_signal_emit (G_OBJECT (um), - undo_manager_signals [CAN_REDO], - 0, - TRUE); - } - - if (um->priv->next_redo >= (gint)(g_list_length (um->priv->actions) - 1)) - { - um->priv->can_undo = FALSE; - g_signal_emit (G_OBJECT (um), - undo_manager_signals [CAN_UNDO], - 0, - FALSE); - } -} - -void -gtk_source_undo_manager_redo (GtkSourceUndoManager *um) -{ - GtkSourceUndoAction *undo_action; - gboolean modified = FALSE; - - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - g_return_if_fail (um->priv->can_redo); - - undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo); - g_return_if_fail (undo_action != NULL); - - gtk_source_undo_manager_begin_not_undoable_action (um); - - do - { - if (undo_action->modified) - { - g_return_if_fail (undo_action->order_in_group <= 1); - modified = TRUE; - } - - --um->priv->next_redo; - - switch (undo_action->action_type) - { - case GTK_SOURCE_UNDO_ACTION_DELETE: - delete_text ( - um->priv->document, - undo_action->action.delete.start, - undo_action->action.delete.end); - - set_cursor ( - um->priv->document, - undo_action->action.delete.start); - - break; - - case GTK_SOURCE_UNDO_ACTION_INSERT: - set_cursor ( - um->priv->document, - undo_action->action.insert.pos); - - insert_text ( - um->priv->document, - undo_action->action.insert.pos, - undo_action->action.insert.text, - undo_action->action.insert.length); - - break; - - case GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR: - set_cursor ( - um->priv->document, - undo_action->action.insert_anchor.pos); - - insert_anchor ( - um->priv->document, - undo_action->action.insert_anchor.pos, - undo_action->action.insert_anchor.anchor); - break; - - default: - /* Unknown action type */ - ++um->priv->next_redo; - g_return_if_reached (); - } - - if (um->priv->next_redo < 0) - undo_action = NULL; - else - undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo); - - } while ((undo_action != NULL) && (undo_action->order_in_group > 1)); - - if (modified) - { - ++um->priv->next_redo; - gtk_text_buffer_set_modified (um->priv->document, FALSE); - --um->priv->next_redo; - } - - gtk_source_undo_manager_end_not_undoable_action_internal (um); - - if (um->priv->next_redo < 0) - { - um->priv->can_redo = FALSE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, FALSE); - } - - if (!um->priv->can_undo) - { - um->priv->can_undo = TRUE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, TRUE); - } -} - -static void -gtk_source_undo_action_free (GtkSourceUndoAction *action) -{ - if (action == NULL) - return; - - if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT) - g_free (action->action.insert.text); - else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE) - g_free (action->action.delete.text); - else if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR) - g_object_unref(action->action.insert_anchor.anchor); - else { - g_free (action); - g_return_if_reached (); - } - - g_free (action); -} - -static void -gtk_source_undo_manager_free_action_list (GtkSourceUndoManager *um) -{ - GList *l; - - l = um->priv->actions; - - while (l != NULL) - { - GtkSourceUndoAction *action = l->data; - - if (action->order_in_group == 1) - --um->priv->num_of_groups; - - if (action->modified) - um->priv->modified_action = NULL; - - gtk_source_undo_action_free (action); - - l = g_list_next (l); - } - - g_list_free (um->priv->actions); - um->priv->actions = NULL; -} - -static void -gtk_source_undo_manager_insert_text_handler (GtkTextBuffer *buffer, - GtkTextIter *pos, - const gchar *text, - gint length, - GtkSourceUndoManager *um) -{ - GtkSourceUndoAction undo_action; - - if (um->priv->running_not_undoable_actions > 0) - return; - - undo_action.action_type = GTK_SOURCE_UNDO_ACTION_INSERT; - - undo_action.action.insert.pos = gtk_text_iter_get_offset (pos); - undo_action.action.insert.text = (gchar*) text; - undo_action.action.insert.length = length; - undo_action.action.insert.chars = g_utf8_strlen (text, length); - - if ((undo_action.action.insert.chars > 1) || (g_utf8_get_char (text) == '\n')) - - undo_action.mergeable = FALSE; - else - undo_action.mergeable = TRUE; - - undo_action.modified = FALSE; - - gtk_source_undo_manager_add_action (um, &undo_action); -} - -static void gtk_source_undo_manager_insert_anchor_handler (GtkTextBuffer *buffer, - GtkTextIter *pos, - GtkTextChildAnchor *anchor, - GtkSourceUndoManager *um) -{ - GtkSourceUndoAction undo_action; - - if (um->priv->running_not_undoable_actions > 0) - return; - - undo_action.action_type = GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR; - - undo_action.action.insert_anchor.pos = gtk_text_iter_get_offset (pos); - undo_action.action.insert_anchor.anchor = g_object_ref (anchor); - - undo_action.mergeable = FALSE; - undo_action.modified = FALSE; - - gtk_source_undo_manager_add_action (um, &undo_action); -} - -static void -gtk_source_undo_manager_delete_range_handler (GtkTextBuffer *buffer, - GtkTextIter *start, - GtkTextIter *end, - GtkSourceUndoManager *um) -{ - GtkSourceUndoAction undo_action; - GtkTextIter insert_iter; - - if (um->priv->running_not_undoable_actions > 0) - return; - - undo_action.action_type = GTK_SOURCE_UNDO_ACTION_DELETE; - - gtk_text_iter_order (start, end); - - undo_action.action.delete.start = gtk_text_iter_get_offset (start); - undo_action.action.delete.end = gtk_text_iter_get_offset (end); - - undo_action.action.delete.text = get_chars ( - buffer, - undo_action.action.delete.start, - undo_action.action.delete.end); - - /* figure out if the user used the Delete or the Backspace key */ - gtk_text_buffer_get_iter_at_mark (buffer, &insert_iter, - gtk_text_buffer_get_insert (buffer)); - if (gtk_text_iter_get_offset (&insert_iter) <= undo_action.action.delete.start) - undo_action.action.delete.forward = TRUE; - else - undo_action.action.delete.forward = FALSE; - - if (((undo_action.action.delete.end - undo_action.action.delete.start) > 1) || - (g_utf8_get_char (undo_action.action.delete.text ) == '\n')) - undo_action.mergeable = FALSE; - else - undo_action.mergeable = TRUE; - - undo_action.modified = FALSE; - - gtk_source_undo_manager_add_action (um, &undo_action); - - g_free (undo_action.action.delete.text); - -} - -static void -gtk_source_undo_manager_begin_user_action_handler (GtkTextBuffer *buffer, GtkSourceUndoManager *um) -{ - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - if (um->priv->running_not_undoable_actions > 0) - return; - - um->priv->actions_in_current_group = 0; -} - -static void -gtk_source_undo_manager_add_action (GtkSourceUndoManager *um, - const GtkSourceUndoAction *undo_action) -{ - GtkSourceUndoAction* action; - - if (um->priv->next_redo >= 0) - { - gtk_source_undo_manager_free_first_n_actions (um, um->priv->next_redo + 1); - } - - um->priv->next_redo = -1; - - if (!gtk_source_undo_manager_merge_action (um, undo_action)) - { - action = g_new (GtkSourceUndoAction, 1); - *action = *undo_action; - - if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT) - action->action.insert.text = g_strndup (undo_action->action.insert.text, undo_action->action.insert.length); - else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE) - action->action.delete.text = g_strdup (undo_action->action.delete.text); - else if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR) - { - /* Nothing needs to be done */ - } - else - { - g_free (action); - g_return_if_reached (); - } - - ++um->priv->actions_in_current_group; - action->order_in_group = um->priv->actions_in_current_group; - - if (action->order_in_group == 1) - ++um->priv->num_of_groups; - - um->priv->actions = g_list_prepend (um->priv->actions, action); - } - - gtk_source_undo_manager_check_list_size (um); - - if (!um->priv->can_undo) - { - um->priv->can_undo = TRUE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, TRUE); - } - - if (um->priv->can_redo) - { - um->priv->can_redo = FALSE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, FALSE); - } -} - -static void -gtk_source_undo_manager_free_first_n_actions (GtkSourceUndoManager *um, - gint n) -{ - gint i; - - if (um->priv->actions == NULL) - return; - - for (i = 0; i < n; i++) - { - GtkSourceUndoAction *action = g_list_first (um->priv->actions)->data; - - if (action->order_in_group == 1) - --um->priv->num_of_groups; - - if (action->modified) - um->priv->modified_action = NULL; - - gtk_source_undo_action_free (action); - - um->priv->actions = g_list_delete_link (um->priv->actions, - um->priv->actions); - - if (um->priv->actions == NULL) - return; - } -} - -static void -gtk_source_undo_manager_check_list_size (GtkSourceUndoManager *um) -{ - gint undo_levels; - - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - undo_levels = gtk_source_undo_manager_get_max_undo_levels (um); - - if (undo_levels < 1) - return; - - if (um->priv->num_of_groups > undo_levels) - { - GtkSourceUndoAction *undo_action; - GList *last; - - last = g_list_last (um->priv->actions); - undo_action = (GtkSourceUndoAction*) last->data; - - do - { - GList *tmp; - - if (undo_action->order_in_group == 1) - --um->priv->num_of_groups; - - if (undo_action->modified) - um->priv->modified_action = NULL; - - gtk_source_undo_action_free (undo_action); - - tmp = g_list_previous (last); - um->priv->actions = g_list_delete_link (um->priv->actions, last); - last = tmp; - g_return_if_fail (last != NULL); - - undo_action = (GtkSourceUndoAction*) last->data; - - } while ((undo_action->order_in_group > 1) || - (um->priv->num_of_groups > undo_levels)); - } -} - -/** - * gtk_source_undo_manager_merge_action: - * @um: a #GtkSourceUndoManager. - * @undo_action: a #GtkSourceUndoAction. - * - * This function tries to merge the undo action at the top of - * the stack with a new undo action. So when we undo for example - * typing, we can undo the whole word and not each letter by itself. - * - * Return Value: %TRUE is merge was successful, %FALSE otherwise. - **/ -static gboolean -gtk_source_undo_manager_merge_action (GtkSourceUndoManager *um, - const GtkSourceUndoAction *undo_action) -{ - GtkSourceUndoAction *last_action; - - g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), FALSE); - g_return_val_if_fail (um->priv != NULL, FALSE); - - if (um->priv->actions == NULL) - return FALSE; - - last_action = (GtkSourceUndoAction*) g_list_nth_data (um->priv->actions, 0); - - if (!last_action->mergeable) - return FALSE; - - if ((!undo_action->mergeable) || - (undo_action->action_type != last_action->action_type)) - { - last_action->mergeable = FALSE; - return FALSE; - } - - if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE) - { - if ((last_action->action.delete.forward != undo_action->action.delete.forward) || - ((last_action->action.delete.start != undo_action->action.delete.start) && - (last_action->action.delete.start != undo_action->action.delete.end))) - { - last_action->mergeable = FALSE; - return FALSE; - } - - if (last_action->action.delete.start == undo_action->action.delete.start) - { - gchar *str; - -#define L (last_action->action.delete.end - last_action->action.delete.start - 1) -#define g_utf8_get_char_at(p,i) g_utf8_get_char(g_utf8_offset_to_pointer((p),(i))) - - /* Deleted with the delete key */ - if ((g_utf8_get_char (undo_action->action.delete.text) != ' ') && - (g_utf8_get_char (undo_action->action.delete.text) != '\t') && - ((g_utf8_get_char_at (last_action->action.delete.text, L) == ' ') || - (g_utf8_get_char_at (last_action->action.delete.text, L) == '\t'))) - { - last_action->mergeable = FALSE; - return FALSE; - } - - str = g_strdup_printf ("%s%s", last_action->action.delete.text, - undo_action->action.delete.text); - - g_free (last_action->action.delete.text); - last_action->action.delete.end += (undo_action->action.delete.end - - undo_action->action.delete.start); - last_action->action.delete.text = str; - } - else - { - gchar *str; - - /* Deleted with the backspace key */ - if ((g_utf8_get_char (undo_action->action.delete.text) != ' ') && - (g_utf8_get_char (undo_action->action.delete.text) != '\t') && - ((g_utf8_get_char (last_action->action.delete.text) == ' ') || - (g_utf8_get_char (last_action->action.delete.text) == '\t'))) - { - last_action->mergeable = FALSE; - return FALSE; - } - - str = g_strdup_printf ("%s%s", undo_action->action.delete.text, - last_action->action.delete.text); - - g_free (last_action->action.delete.text); - last_action->action.delete.start = undo_action->action.delete.start; - last_action->action.delete.text = str; - } - } - else if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT) - { - gchar* str; - -#define I (last_action->action.insert.chars - 1) - - if ((undo_action->action.insert.pos != - (last_action->action.insert.pos + last_action->action.insert.chars)) || - ((g_utf8_get_char (undo_action->action.insert.text) != ' ') && - (g_utf8_get_char (undo_action->action.insert.text) != '\t') && - ((g_utf8_get_char_at (last_action->action.insert.text, I) == ' ') || - (g_utf8_get_char_at (last_action->action.insert.text, I) == '\t'))) - ) - { - last_action->mergeable = FALSE; - return FALSE; - } - - str = g_strdup_printf ("%s%s", last_action->action.insert.text, - undo_action->action.insert.text); - - g_free (last_action->action.insert.text); - last_action->action.insert.length += undo_action->action.insert.length; - last_action->action.insert.text = str; - last_action->action.insert.chars += undo_action->action.insert.chars; - - } - else if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR) - { - /* Nothing needs to be done */ - } - else - /* Unknown action inside undo merge encountered */ - g_return_val_if_reached (TRUE); - - return TRUE; -} - -gint -gtk_source_undo_manager_get_max_undo_levels (GtkSourceUndoManager *um) -{ - g_return_val_if_fail (um != NULL, 0); - g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), 0); - - return um->priv->max_undo_levels; -} - -void -gtk_source_undo_manager_set_max_undo_levels (GtkSourceUndoManager *um, - gint max_undo_levels) -{ - gint old_levels; - - g_return_if_fail (um != NULL); - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - - old_levels = um->priv->max_undo_levels; - um->priv->max_undo_levels = max_undo_levels; - - if (max_undo_levels < 1) - return; - - if (old_levels > max_undo_levels) - { - /* strip redo actions first */ - while (um->priv->next_redo >= 0 && (um->priv->num_of_groups > max_undo_levels)) - { - gtk_source_undo_manager_free_first_n_actions (um, 1); - um->priv->next_redo--; - } - - /* now remove undo actions if necessary */ - gtk_source_undo_manager_check_list_size (um); - - /* emit "can_undo" and/or "can_redo" if appropiate */ - if (um->priv->next_redo < 0 && um->priv->can_redo) - { - um->priv->can_redo = FALSE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, FALSE); - } - - if (um->priv->can_undo && - um->priv->next_redo >= (gint)(g_list_length (um->priv->actions) - 1)) - { - um->priv->can_undo = FALSE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, FALSE); - } - } -} - -static void -gtk_source_undo_manager_modified_changed_handler (GtkTextBuffer *buffer, - GtkSourceUndoManager *um) -{ - GtkSourceUndoAction *action; - GList *list; - - g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - if (um->priv->actions == NULL) - return; - - list = g_list_nth (um->priv->actions, um->priv->next_redo + 1); - - if (list != NULL) - action = (GtkSourceUndoAction*) list->data; - else - action = NULL; - - if (gtk_text_buffer_get_modified (buffer) == FALSE) - { - if (action != NULL) - action->mergeable = FALSE; - - if (um->priv->modified_action != NULL) - { - um->priv->modified_action->modified = FALSE; - um->priv->modified_action = NULL; - } - - return; - } - - if (action == NULL) - { - g_return_if_fail (um->priv->running_not_undoable_actions > 0); - - return; - } - - /* gtk_text_buffer_get_modified (buffer) == TRUE */ - - g_return_if_fail (um->priv->modified_action == NULL); - - if (action->order_in_group > 1) - um->priv->modified_undoing_group = TRUE; - - while (action->order_in_group > 1) - { - list = g_list_next (list); - g_return_if_fail (list != NULL); - - action = (GtkSourceUndoAction*) list->data; - g_return_if_fail (action != NULL); - } - - action->modified = TRUE; - um->priv->modified_action = action; -}
--- a/pidgin/gtksourceundomanager.h Sun Feb 09 06:42:23 2014 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gtksourceundomanager.h - * This file is part of GtkSourceView - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * Copyright (C) 2002, 2003 Paolo Maggi - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. * * - */ - -#ifndef __GTK_SOURCE_UNDO_MANAGER_H__ -#define __GTK_SOURCE_UNDO_MANAGER_H__ -/** - * SECTION:gtksourceundomanager - * @section_id: pidgin-gtksourceundomanager - * @short_description: <filename>gtksourceundomanager.h</filename> - * @title: Source Undo Manager - */ - -#include <gtk/gtk.h> - -#define GTK_SOURCE_TYPE_UNDO_MANAGER (gtk_source_undo_manager_get_type()) -#define GTK_SOURCE_UNDO_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManager)) -#define GTK_SOURCE_UNDO_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManagerClass)) -#define GTK_SOURCE_IS_UNDO_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_SOURCE_TYPE_UNDO_MANAGER)) -#define GTK_SOURCE_IS_UNDO_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_SOURCE_TYPE_UNDO_MANAGER)) -#define GTK_SOURCE_UNDO_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManagerClass)) - - -typedef struct _GtkSourceUndoManager GtkSourceUndoManager; -typedef struct _GtkSourceUndoManagerClass GtkSourceUndoManagerClass; - -typedef struct _GtkSourceUndoManagerPrivate GtkSourceUndoManagerPrivate; - -struct _GtkSourceUndoManager -{ - GObject base; - - GtkSourceUndoManagerPrivate *priv; -}; - -struct _GtkSourceUndoManagerClass -{ - GObjectClass parent_class; - - /* Signals */ - void (*can_undo) (GtkSourceUndoManager *um, gboolean can_undo); - void (*can_redo) (GtkSourceUndoManager *um, gboolean can_redo); -}; - -G_BEGIN_DECLS - -GType gtk_source_undo_manager_get_type (void) G_GNUC_CONST; - -GtkSourceUndoManager* gtk_source_undo_manager_new (GtkTextBuffer *buffer); - -gboolean gtk_source_undo_manager_can_undo (const GtkSourceUndoManager *um); -gboolean gtk_source_undo_manager_can_redo (const GtkSourceUndoManager *um); - -void gtk_source_undo_manager_undo (GtkSourceUndoManager *um); -void gtk_source_undo_manager_redo (GtkSourceUndoManager *um); - -void gtk_source_undo_manager_begin_not_undoable_action - (GtkSourceUndoManager *um); -void gtk_source_undo_manager_end_not_undoable_action - (GtkSourceUndoManager *um); - -gint gtk_source_undo_manager_get_max_undo_levels - (GtkSourceUndoManager *um); -void gtk_source_undo_manager_set_max_undo_levels - (GtkSourceUndoManager *um, - gint undo_levels); - -G_END_DECLS - -#endif /* __GTK_SOURCE_UNDO_MANAGER_H__ */ - -
--- a/pidgin/gtksourceview-marshal.c Sun Feb 09 06:42:23 2014 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -#include "gtksourceview-marshal.h" - -#include <glib-object.h> - - -#ifdef G_ENABLE_DEBUG -#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) -#define g_marshal_value_peek_char(v) g_value_get_char (v) -#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) -#define g_marshal_value_peek_int(v) g_value_get_int (v) -#define g_marshal_value_peek_uint(v) g_value_get_uint (v) -#define g_marshal_value_peek_long(v) g_value_get_long (v) -#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) -#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) -#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) -#define g_marshal_value_peek_enum(v) g_value_get_enum (v) -#define g_marshal_value_peek_flags(v) g_value_get_flags (v) -#define g_marshal_value_peek_float(v) g_value_get_float (v) -#define g_marshal_value_peek_double(v) g_value_get_double (v) -#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) -#define g_marshal_value_peek_param(v) g_value_get_param (v) -#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) -#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) -#define g_marshal_value_peek_object(v) g_value_get_object (v) -#else /* !G_ENABLE_DEBUG */ -/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. - * Do not access GValues directly in your code. Instead, use the - * g_value_get_*() functions - */ -#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int -#define g_marshal_value_peek_char(v) (v)->data[0].v_int -#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint -#define g_marshal_value_peek_int(v) (v)->data[0].v_int -#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint -#define g_marshal_value_peek_long(v) (v)->data[0].v_long -#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong -#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 -#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 -#define g_marshal_value_peek_enum(v) (v)->data[0].v_long -#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong -#define g_marshal_value_peek_float(v) (v)->data[0].v_float -#define g_marshal_value_peek_double(v) (v)->data[0].v_double -#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer -#endif /* !G_ENABLE_DEBUG */ - - -/* VOID:VOID (gtksourceview-marshal.list:1) */ - -/* VOID:BOOLEAN (gtksourceview-marshal.list:2) */ - -/* VOID:BOXED (gtksourceview-marshal.list:3) */ - -/* VOID:BOXED,BOXED (gtksourceview-marshal.list:4) */ -void -gtksourceview_marshal_VOID__BOXED_BOXED (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data) -{ - typedef void (*GMarshalFunc_VOID__BOXED_BOXED) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer data2); - register GMarshalFunc_VOID__BOXED_BOXED callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - - g_return_if_fail (n_param_values == 3); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_VOID__BOXED_BOXED) (marshal_data ? marshal_data : cc->callback); - - callback (data1, - g_marshal_value_peek_boxed (param_values + 1), - g_marshal_value_peek_boxed (param_values + 2), - data2); -} - -/* VOID:STRING (gtksourceview-marshal.list:5) */ -
--- a/pidgin/gtksourceview-marshal.h Sun Feb 09 06:42:23 2014 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ - -#ifndef __gtksourceview_marshal_MARSHAL_H__ -#define __gtksourceview_marshal_MARSHAL_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -/* VOID:VOID (gtksourceview-marshal.list:1) */ -#define gtksourceview_marshal_VOID__VOID g_cclosure_marshal_VOID__VOID - -/* VOID:BOOLEAN (gtksourceview-marshal.list:2) */ -#define gtksourceview_marshal_VOID__BOOLEAN g_cclosure_marshal_VOID__BOOLEAN - -/* VOID:BOXED (gtksourceview-marshal.list:3) */ -#define gtksourceview_marshal_VOID__BOXED g_cclosure_marshal_VOID__BOXED - -/* VOID:BOXED,BOXED (gtksourceview-marshal.list:4) */ -extern void gtksourceview_marshal_VOID__BOXED_BOXED (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -/* VOID:STRING (gtksourceview-marshal.list:5) */ -#define gtksourceview_marshal_VOID__STRING g_cclosure_marshal_VOID__STRING - -G_END_DECLS - -#endif /* __gtksourceview_marshal_MARSHAL_H__ */ -