r40121 - in /packages/unstable/xchat-gnome/debian: changelog patches/02_bring_back_completion.patch patches/series
joss at users.alioth.debian.org
joss at users.alioth.debian.org
Sat Oct 26 19:26:39 UTC 2013
Author: joss
Date: Sat Oct 26 19:26:38 2013
New Revision: 40121
URL: http://svn.debian.org/wsvn/pkg-gnome/?sc=1&rev=40121
Log:
02_bring_back_completion.patch: reverts unwarranted upstream changes
that remove entirely tab completion.
Added:
packages/unstable/xchat-gnome/debian/patches/02_bring_back_completion.patch
Modified:
packages/unstable/xchat-gnome/debian/changelog
packages/unstable/xchat-gnome/debian/patches/series
Modified: packages/unstable/xchat-gnome/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-gnome/packages/unstable/xchat-gnome/debian/changelog?rev=40121&op=diff
==============================================================================
--- packages/unstable/xchat-gnome/debian/changelog [utf-8] (original)
+++ packages/unstable/xchat-gnome/debian/changelog [utf-8] Sat Oct 26 19:26:38 2013
@@ -2,6 +2,8 @@
* 01_finish_gtk3_port.patch: new patch. Imported from BZ#677043,
contains the missing pieces of the GTK3 port.
+ * 02_bring_back_completion.patch: reverts unwarranted upstream changes
+ that remove entirely tab completion.
-- Josselin Mouette <joss at debian.org> Sat, 26 Oct 2013 20:01:40 +0200
Added: packages/unstable/xchat-gnome/debian/patches/02_bring_back_completion.patch
URL: http://svn.debian.org/wsvn/pkg-gnome/packages/unstable/xchat-gnome/debian/patches/02_bring_back_completion.patch?rev=40121&op=file
==============================================================================
--- packages/unstable/xchat-gnome/debian/patches/02_bring_back_completion.patch (added)
+++ packages/unstable/xchat-gnome/debian/patches/02_bring_back_completion.patch [utf-8] Sat Oct 26 19:26:38 2013
@@ -0,0 +1,437 @@
+Index: xchat-gnome-0.30.0~git20131003.d20b8d/src/fe-gnome/text-entry.c
+===================================================================
+--- xchat-gnome-0.30.0~git20131003.d20b8d.orig/src/fe-gnome/text-entry.c 2013-10-26 21:17:44.062548522 +0200
++++ xchat-gnome-0.30.0~git20131003.d20b8d/src/fe-gnome/text-entry.c 2013-10-26 21:23:39.914512963 +0200
+@@ -41,9 +41,13 @@ static void text_entry_activate
+ gpointer data);
+ static void text_entry_history_up (GtkEntry *entry);
+ static void text_entry_history_down (GtkEntry *entry);
++static gboolean text_entry_tab_complete (GtkEntry *entry);
+ static void text_entry_populate_popup (GtkEntry *entry,
+ GtkMenu *menu,
+ gpointer data);
++static gboolean tab_complete_command (GtkEntry *entry);
++static gboolean tab_complete_nickname (GtkEntry *entry,
++ int start);
+ static GtkWidget *get_color_icon (int c,
+ GtkStyle *style);
+ static void color_code_activate (GtkMenuItem *item,
+@@ -54,6 +58,7 @@ G_DEFINE_TYPE (TextEntry, text_entry, GT
+
+ struct _TextEntryPriv
+ {
++ GCompletion *command_completion;
+ GHashTable *current_text;
+ struct session *session;
+ };
+@@ -69,15 +74,46 @@ text_entry_class_init (TextEntryClass *k
+ gobject_class->finalize = text_entry_finalize;
+ }
+
++/* copied from eel-glib-extensions.c */
++
++static GList *
++g_list_from_g_slist (GSList *slist)
++{
++ GList *list;
++ GSList *node;
++
++ list = NULL;
++ for (node = slist; node != NULL; node = node->next) {
++ list = g_list_prepend (list, node->data);
++ }
++ return g_list_reverse (list);
++}
++
+ static void
+ text_entry_init (TextEntry *entry)
+ {
++ GList *items = NULL;
++ int i;
++ GList *real_command_list;
++
+ g_signal_connect_after (G_OBJECT (entry), "key_press_event", G_CALLBACK (text_entry_key_press), NULL);
+ g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (text_entry_activate), NULL);
+ g_signal_connect (G_OBJECT (entry), "populate-popup", G_CALLBACK (text_entry_populate_popup), NULL);
+
+ entry->priv = g_new0 (TextEntryPriv, 1);
+
++ /* Initialize & populate a GCompletion for commands */
++ entry->priv->command_completion = g_completion_new (NULL);
++ real_command_list = g_list_from_g_slist (command_list);
++ g_completion_add_items (entry->priv->command_completion, real_command_list);
++ g_list_free (real_command_list);
++ for (i = 0; xc_cmds[i].name != NULL; i++) {
++ items = g_list_prepend (items, xc_cmds[i].name);
++ }
++ items = g_list_reverse (items);
++ g_completion_add_items (entry->priv->command_completion, items);
++ g_list_free (items);
++
+ /* Save the current input for each session */
+ entry->priv->current_text = g_hash_table_new (NULL, NULL);
+
+@@ -91,6 +127,9 @@ text_entry_finalize (GObject *object)
+
+ entry = TEXT_ENTRY (object);
+
++ if (entry->priv->command_completion) {
++ g_completion_free (entry->priv->command_completion);
++ }
+ if (entry->priv)
+ {
+ g_free (entry->priv);
+@@ -114,7 +153,7 @@ text_entry_key_press (GtkWidget *widget,
+ text_entry_history_up (GTK_ENTRY (widget));
+ return TRUE;
+ case GDK_KEY_Tab:
+- return TRUE;
++ return text_entry_tab_complete (GTK_ENTRY (widget));
+ default:
+ return FALSE;
+ }
+@@ -167,6 +206,58 @@ text_entry_history_down (GtkEntry *entry
+ }
+ }
+
++static gboolean
++text_entry_tab_complete (GtkEntry *entry)
++{
++ const char *text;
++ gint cursor_pos;
++ gchar *p;
++
++ text = gtk_entry_get_text (entry);
++ cursor_pos = gtk_editable_get_position (GTK_EDITABLE (entry));
++
++ if (cursor_pos == 0) {
++ return TRUE;
++ }
++
++ /* If we're directly after a space, we have nothing to tab complete */
++ p = g_utf8_offset_to_pointer (text, cursor_pos - 1);
++ if (p[0] == ' ') {
++ return TRUE;
++ }
++
++ /* search from cursor backwards to find /, #, ' ' or start */
++ p = g_utf8_offset_to_pointer (text, cursor_pos);
++ while ((p = g_utf8_find_prev_char (text, p))) {
++ /* check if we can match a channel */
++ /* FIXME: implement
++ if (p[0] == '#') {
++ if (text == p || g_ascii_strcasecmp (g_utf8_prev_char (p), " ") == 0) {
++ tab_complete_channel (entry, g_utf8_pointer_to_offset (text, p));
++ return;
++ }
++ }
++ */
++
++ /* check if we can match a command */
++ if (text == p && p[0] == '/') {
++ return tab_complete_command (entry);
++ }
++
++ /* check if we can match a nickname */
++ if (p[0] == ' ') {
++ return tab_complete_nickname (entry,
++ g_utf8_pointer_to_offset (text, p) + 1);
++ }
++ /* finally try nickname after all preceeding failed */
++ if (text == p) {
++ return tab_complete_nickname (entry, 0);
++ }
++ }
++
++ return TRUE;
++}
++
+ static void
+ text_entry_populate_popup (GtkEntry *entry, GtkMenu *menu, gpointer data)
+ {
+@@ -248,6 +339,183 @@ text_entry_populate_popup (GtkEntry *ent
+ gtk_widget_show_all (submenu);
+ }
+
++static gboolean
++tab_complete_command (GtkEntry *entry)
++{
++ TextEntry *text_entry;
++ int cursor, length, pos;
++ char *prefix, *new_prefix = NULL, *printtext, *npt = NULL;
++ const gchar *text;
++ GList *options, *list;
++
++ text_entry = TEXT_ENTRY (entry);
++
++ cursor = gtk_editable_get_position (GTK_EDITABLE (entry));
++ prefix = g_new0 (char, cursor);
++ text = gtk_entry_get_text (entry);
++ prefix = g_ascii_strup (&text[1], cursor - 1);
++ length = strlen (text);
++
++ options = g_completion_complete (text_entry->priv->command_completion, prefix, &new_prefix);
++
++ if (g_list_length (options) == 0) {
++ /* no matches */
++ g_free (prefix);
++ return TRUE;
++ }
++
++ if (g_list_length (options) == 1) {
++ /* one match */
++
++ if (length - cursor == 0) {
++ /* at the end of the entry, just insert */
++ npt = g_strdup_printf ("/%s ", (char *) options->data);
++ pos = strlen (npt);
++ } else {
++ npt = g_strdup_printf ("/%s %s", (char *) options->data, &text[cursor]);
++ pos = strlen ((char *) options->data) + 2;
++ }
++ gtk_entry_set_text (entry, npt);
++ gtk_editable_set_position (GTK_EDITABLE (entry), pos);
++ g_free (npt);
++ g_free (prefix);
++ g_free (new_prefix);
++ return TRUE;
++ } else {
++ /* more than one match - print a list of options
++ * to the window and update the prefix
++ */
++ list = options;
++ printtext = g_strdup ((char *) list->data);
++ for (list = g_list_next (list); list; list = g_list_next (list)) {
++ npt = g_strdup_printf ("%s %s", printtext, (char *) list->data);
++ g_free (printtext);
++ printtext = npt;
++ }
++ conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->session, printtext, TRUE, time (NULL));
++ g_free (printtext);
++
++ if (new_prefix && strcasecmp (prefix, new_prefix) != 0) {
++ /* insert the new prefix into the entry */
++ npt = g_strdup_printf ("/%s%s", new_prefix, &text[cursor]);
++ gtk_entry_set_text (entry, npt);
++ g_free (npt);
++ gtk_editable_set_position (GTK_EDITABLE (entry), strlen (new_prefix) + 1);
++ }
++ g_free (prefix);
++ g_free (new_prefix);
++ return TRUE;
++ }
++
++ return TRUE;
++}
++
++static gboolean
++tab_complete_nickname (GtkEntry *entry, gint start)
++ {
++ GCompletion *completion;
++ int cursor, length;
++ char *text, *at_cursor, *at_start;
++ GList *list;
++ char *printtext, *npt;
++ GList *options;
++ gchar *new_prefix;
++ gchar *prefix;
++ TextEntry *text_entry;
++
++ completion = userlist_get_completion (u, TEXT_ENTRY (entry)->priv->session);
++ g_completion_set_compare (completion, (GCompletionStrncmpFunc) strncasecmp);
++ text = g_strdup (gtk_entry_get_text (entry));
++ length = g_utf8_strlen (text, -1);
++ cursor = gtk_editable_get_position (GTK_EDITABLE (entry));
++ at_start = g_utf8_offset_to_pointer (text, start);
++ at_cursor = g_utf8_offset_to_pointer (text, cursor);
++
++ text_entry = TEXT_ENTRY (entry);
++
++ /* pointer arithmetic for byte size allocation */
++ prefix = g_new0 (char, at_cursor - at_start + 1);
++ g_utf8_strncpy (prefix, at_start, cursor - start);
++ options = g_completion_complete_utf8 (completion, prefix, &new_prefix);
++
++ if (g_list_length (options) == 0) {
++ /* no matches */
++ g_free (text);
++ g_free (prefix);
++ return TRUE;
++ }
++
++ if (g_list_length (options) == 1) {
++ int pos;
++
++ /* one match */
++ if (length - cursor == 0) {
++ /* at the end of the entry, just insert */
++
++ if (start != 0) {
++ gchar *p;
++ p = g_new0 (char, at_start - text + 1);
++ g_utf8_strncpy (p, text, start);
++ npt = g_strdup_printf ("%s%s", p, (char *) options->data);
++ g_free (p);
++ pos = g_utf8_strlen ((char *) options->data, -1) + start;
++ } else {
++ npt = g_strdup_printf ("%s%s ", (char *) options->data, prefs.nick_suffix);
++ pos = g_utf8_strlen ((char *) options->data, -1) + 2;
++ }
++ } else {
++ /* somewhere in the middle of the entry */
++
++ if (start != 0) {
++ gchar *p;
++ p = g_new0 (char, at_start - text + 1);
++ g_utf8_strncpy (p, text, start);
++ npt = g_strdup_printf ("%s%s%s", p, (char *) options->data, at_cursor);
++ g_free (p);
++ pos = g_utf8_strlen ((char *) options->data, -1) + start;
++ } else {
++ npt = g_strdup_printf ("%s%s %s", (char *) options->data, prefs.nick_suffix, at_cursor);
++ pos = g_utf8_strlen ((char *) options->data, -1) + 2;
++ }
++ }
++ gtk_entry_set_text (entry, npt);
++ gtk_editable_set_position (GTK_EDITABLE (entry), pos);
++ g_free (npt);
++ g_free (text);
++ g_free (prefix);
++ return TRUE;
++ } else {
++ /* more than one match - print a list of options
++ * to the window and update the prefix
++ */
++ list = options;
++ printtext = g_strdup ((char *) list->data);
++ for (list = g_list_next (list); list; list = g_list_next (list)) {
++ npt = g_strdup_printf ("%s %s", printtext, (char *) list->data);
++ g_free (printtext);
++ printtext = npt;
++ }
++ conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->session, printtext, TRUE, time (NULL));
++ g_free (printtext);
++
++ if (strcasecmp (prefix, new_prefix) != 0) {
++ /* insert the new prefix into the entry */
++ gchar *p;
++ p = g_new0 (char, at_start - text + 1);
++ g_utf8_strncpy (p, text, start);
++ npt = g_strdup_printf ("%s%s%s", p, new_prefix, at_cursor);
++ g_free (p);
++ gtk_entry_set_text (entry, npt);
++ g_free (npt);
++ gtk_editable_set_position (GTK_EDITABLE (entry), start + g_utf8_strlen (new_prefix, -1));
++ }
++ g_free (text);
++ g_free (prefix);
++ return TRUE;
++ }
++ return TRUE;
++}
++
+ static GtkWidget *
+ get_color_icon (int c, GtkStyle *style)
+ {
+Index: xchat-gnome-0.30.0~git20131003.d20b8d/src/fe-gnome/userlist.c
+===================================================================
+--- xchat-gnome-0.30.0~git20131003.d20b8d.orig/src/fe-gnome/userlist.c 2013-10-26 21:17:44.062548522 +0200
++++ xchat-gnome-0.30.0~git20131003.d20b8d/src/fe-gnome/userlist.c 2013-10-26 21:17:44.046549053 +0200
+@@ -37,6 +37,7 @@ static GObjectClass *parent_class = NULL
+ typedef struct
+ {
+ GtkListStore *liststore;
++ GCompletion *completion;
+ GList *completion_items;
+ } Store;
+
+@@ -84,6 +85,7 @@ static gboolean
+ destroy_store (session *session, Store *store, gpointer data)
+ {
+ g_object_unref (store->liststore);
++ g_completion_free (store->completion);
+ g_free (store);
+ return TRUE;
+ }
+@@ -118,6 +120,7 @@ create_userlist (Userlist *userlist, ses
+ Store *store = g_new (Store, 1);
+
+ store->liststore = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_COLOR);
++ store->completion = g_completion_new (NULL);
+ store->completion_items = NULL;
+
+ g_hash_table_insert (userlist->stores, sess, store);
+@@ -156,6 +159,7 @@ userlist_insert (Userlist *userlist, ses
+ gtk_list_store_set (store->liststore, &iter, 0, icon, 1, newuser->nick, 2, newuser, 3, newuser->away ? &colors[40] : NULL, -1);
+
+ item = g_list_append (NULL, newuser->nick);
++ g_completion_add_items (store->completion, item);
+ store->completion_items = g_list_concat (store->completion_items, item);
+
+ userlist_set_user_button (userlist, sess);
+@@ -197,6 +201,7 @@ userlist_remove_user (Userlist *userlist
+
+ item = g_list_find_custom (store->completion_items, user->nick, (GCompareFunc) strcmp);
+ store->completion_items = g_list_remove_link (store->completion_items, item);
++ g_completion_remove_items (store->completion, item);
+ g_list_free (item);
+
+ userlist_set_user_button (userlist, sess);
+@@ -219,11 +224,13 @@ userlist_update (Userlist *userlist, ses
+
+ item = g_list_find_custom (store->completion_items, nick, (GCompareFunc) strcmp);
+ store->completion_items = g_list_remove_link (store->completion_items, item);
++ g_completion_remove_items (store->completion, item);
+ g_list_free (item);
+
+ gtk_list_store_set (store->liststore, iter, 1, user->nick, 3, user->away ? &colors[40] : NULL, -1);
+
+ item = g_list_append (NULL, user->nick);
++ g_completion_add_items (store->completion, item);
+ store->completion_items = g_list_concat (store->completion_items, item);
+
+ g_free (nick);
+@@ -255,6 +262,7 @@ userlist_clear_all (Userlist *userlist,
+ store = create_userlist (userlist, sess);
+ }
+
++ g_completion_clear_items (store->completion);
+ gtk_list_store_clear (store->liststore);
+ }
+
+@@ -267,6 +275,7 @@ userlist_erase (Userlist *userlist, sess
+ }
+
+ g_object_unref (store->liststore);
++ g_completion_free (store->completion);
+ g_free (store);
+ g_hash_table_remove (userlist->stores, sess);
+ }
+@@ -281,12 +290,12 @@ userlist_get_store (Userlist *userlist,
+ return store->liststore;
+ }
+
+-GList*
++GCompletion*
+ userlist_get_completion (Userlist *userlist, session *sess)
+ {
+ Store *store = g_hash_table_lookup (userlist->stores, sess);
+ g_assert (store != NULL);
+- return store->completion_items;
++ return store->completion;
+ }
+
+ void
+Index: xchat-gnome-0.30.0~git20131003.d20b8d/src/fe-gnome/userlist.h
+===================================================================
+--- xchat-gnome-0.30.0~git20131003.d20b8d.orig/src/fe-gnome/userlist.h 2013-10-26 21:17:44.062548522 +0200
++++ xchat-gnome-0.30.0~git20131003.d20b8d/src/fe-gnome/userlist.h 2013-10-26 21:17:44.050548923 +0200
+@@ -59,7 +59,7 @@ void userlist_move (
+ void userlist_clear_all (Userlist *userlist, session *sess);
+ void userlist_erase (Userlist *userlist, session *sess);
+ GtkListStore* userlist_get_store (Userlist *userlist, session *sess);
+-GList* userlist_get_completion (Userlist *userlist, session *sess);
++GCompletion* userlist_get_completion (Userlist *userlist, session *sess);
+ void userlist_set_user_button (Userlist *userlist, session *sess);
+
+ G_END_DECLS
Modified: packages/unstable/xchat-gnome/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-gnome/packages/unstable/xchat-gnome/debian/patches/series?rev=40121&op=diff
==============================================================================
--- packages/unstable/xchat-gnome/debian/patches/series [utf-8] (original)
+++ packages/unstable/xchat-gnome/debian/patches/series [utf-8] Sat Oct 26 19:26:38 2013
@@ -1,3 +1,4 @@
01_finish_gtk3_port.patch
+02_bring_back_completion.patch
120-fix-clipboard-segfault.patch
define_functions_fix_build.patch
More information about the pkg-gnome-commits
mailing list