~ubuntu-branches/ubuntu/hardy/xchat-gnome/hardy-updates

« back to all changes in this revision

Viewing changes to src/fe-gnome/text-entry.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2006-07-20 10:46:11 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20060720104611-bo8b5e44s9b8cc9w
Tags: 1:0.13-0ubuntu1
* New upstream version, UVF granted by Colin Watson:
  - Add the ability to auto-join keyed channels (Ubuntu: #29856)
  - Add the red-line unread indicator (Ubuntu: #30642)
  - Lots and lots of major bug fixes
  - Fix a crash when saving transcript without current session
    (Ubuntu: #52692)
  - Fix crasher when using /server <servername> (Ubuntu: #45312)
* debian/control.in:
  - Build-Depends on libssl-dev instead of libssl0.9.8 (Ubuntu: #52746)
* debian/patches/03_autoconf.patch:
  - updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "userlist.h"
31
31
#include "../common/outbound.h"
32
32
 
33
 
static void       text_entry_class_init     (TextEntryClass *klass);
34
 
static void       text_entry_init           (TextEntry      *entry);
35
 
static void       text_entry_finalize       (GObject        *object);
36
 
static gboolean   text_entry_key_press      (GtkWidget      *widget,
37
 
                                             GdkEventKey    *event,
38
 
                                             gpointer        data);
 
33
static void       text_entry_class_init        (TextEntryClass *klass);
 
34
static void       text_entry_init              (TextEntry      *entry);
 
35
static void       text_entry_finalize          (GObject        *object);
 
36
static gboolean   text_entry_key_press         (GtkWidget      *widget,
 
37
                                                GdkEventKey    *event,
 
38
                                                gpointer        data);
39
39
#ifdef HAVE_LIBSEXY
40
 
static gboolean   text_entry_spell_check    (TextEntry      *entry,
41
 
                                             gchar          *text,
42
 
                                             gpointer        data);
43
 
static void       enable_spellcheck_changed (GConfClient *client,
44
 
                                             guint cnxn_id,
45
 
                                             GConfEntry *gconf_entry,
46
 
                                             TextEntry *entry);
47
 
/*
48
 
static void       languages_changed         (GConfClient *client,
49
 
                                             guint cnxn_id,
50
 
                                             GConfEntry *gconf_entry,
51
 
                                             TextEntry *entry);
52
 
*/
 
40
static gboolean   text_entry_spell_check       (TextEntry      *entry,
 
41
                                                gchar          *text,
 
42
                                                gpointer        data);
 
43
static void       enable_spellcheck_changed    (GConfClient    *client,
 
44
                                                guint           cnxn_id,
 
45
                                                GConfEntry     *gconf_entry,
 
46
                                                TextEntry      *entry);
53
47
#endif
54
 
static void       text_entry_activate       (GtkWidget      *widget,
55
 
                                             gpointer        data);
56
 
static void       text_entry_history_up     (GtkEntry       *entry);
57
 
static void       text_entry_history_down   (GtkEntry       *entry);
58
 
static gboolean   text_entry_tab_complete   (GtkEntry       *entry);
59
 
static void       text_entry_populate_popup (GtkEntry       *entry,
60
 
                                             GtkMenu        *menu,
61
 
                                             gpointer        data);
 
48
static void       text_entry_activate          (GtkWidget      *widget,
 
49
                                                gpointer        data);
 
50
static void       text_entry_history_up        (GtkEntry       *entry);
 
51
static void       text_entry_history_down      (GtkEntry       *entry);
 
52
static gboolean   text_entry_tab_complete      (GtkEntry       *entry);
 
53
static void       text_entry_populate_popup    (GtkEntry       *entry,
 
54
                                                GtkMenu        *menu,
 
55
                                                gpointer        data);
 
56
static void       text_entry_selection_changed (GObject        *obj,
 
57
                                                GParamSpec     *pspec,
 
58
                                                gpointer        data);
62
59
 
63
 
static gboolean   tab_complete_command      (GtkEntry       *entry);
64
 
static gboolean   tab_complete_nickname     (GtkEntry       *entry,
65
 
                                             int             start);
66
 
static GtkWidget *get_color_icon            (int             c,
67
 
                                             GtkStyle       *style);
68
 
static void       color_code_activate       (GtkMenuItem    *item,
69
 
                                             gpointer        data);
 
60
static gboolean   tab_complete_command         (GtkEntry       *entry);
 
61
static gboolean   tab_complete_nickname        (GtkEntry       *entry,
 
62
                                                int             start);
 
63
static GtkWidget *get_color_icon               (int             c,
 
64
                                                GtkStyle       *style);
 
65
static void       color_code_activate          (GtkMenuItem    *item,
 
66
                                                gpointer        data);
70
67
 
71
68
#ifdef HAVE_LIBSEXY
72
69
static SexySpellEntryClass *parent_class = NULL;
76
73
G_DEFINE_TYPE (TextEntry, text_entry, GTK_TYPE_ENTRY);
77
74
#endif
78
75
 
 
76
static gchar *selected_text = NULL;
 
77
 
79
78
struct _TextEntryPriv
80
79
{
81
80
        GCompletion    *command_completion;
108
107
        GError *err  = NULL;
109
108
#endif
110
109
 
111
 
        g_signal_connect_after (G_OBJECT (entry), "key_press_event", G_CALLBACK (text_entry_key_press),      NULL);
112
 
        g_signal_connect       (G_OBJECT (entry), "activate",        G_CALLBACK (text_entry_activate),       NULL);
113
 
        g_signal_connect       (G_OBJECT (entry), "populate-popup",  G_CALLBACK (text_entry_populate_popup), NULL);
 
110
        g_signal_connect_after (G_OBJECT (entry), "key_press_event",         G_CALLBACK (text_entry_key_press),         NULL);
 
111
        g_signal_connect       (G_OBJECT (entry), "activate",                G_CALLBACK (text_entry_activate),          NULL);
 
112
        g_signal_connect       (G_OBJECT (entry), "populate-popup",          G_CALLBACK (text_entry_populate_popup),    NULL);
 
113
        g_signal_connect       (G_OBJECT (entry), "notify::cursor-position", G_CALLBACK (text_entry_selection_changed), NULL);
 
114
        g_signal_connect       (G_OBJECT (entry), "notify::selection-bound", G_CALLBACK (text_entry_selection_changed), NULL);
114
115
#ifdef HAVE_LIBSEXY
115
 
        g_signal_connect_after (G_OBJECT (entry), "word-check",      G_CALLBACK (text_entry_spell_check),    NULL);
 
116
        g_signal_connect_after (G_OBJECT (entry), "word-check",              G_CALLBACK (text_entry_spell_check),       NULL);
116
117
#endif
117
118
 
118
119
        entry->priv = g_new0 (TextEntryPriv, 1);
165
166
 
166
167
        gconf_client_notify_add (client, "/apps/xchat/spellcheck/enabled",
167
168
                                 (GConfClientNotifyFunc) enable_spellcheck_changed, entry, NULL, NULL);
168
 
        /*
169
 
        gconf_client_notify_add (client, "/apps/xchat/spellcheck/languages",
170
 
                                 (GConfClientNotifyFunc) languages_changed, entry, NULL, NULL);
171
 
        */
172
169
 
173
170
        g_object_unref (client);
174
171
#endif
455
452
                gtk_editable_set_position (GTK_EDITABLE (entry), pos);
456
453
                g_free (npt);
457
454
                g_free (prefix);
 
455
                g_free (new_prefix);
458
456
                return TRUE;
459
457
        } else {
460
458
                /* more than one match - print a list of options
470
468
                conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->current, (guchar *) printtext, TRUE);
471
469
                g_free (printtext);
472
470
 
473
 
                npt = NULL;
474
471
                if (new_prefix && strcasecmp (prefix, new_prefix) != 0) {
475
472
                        /* insert the new prefix into the entry */
476
473
                        npt = g_strdup_printf ("/%s%s", new_prefix, &text[cursor]);
477
474
                        gtk_entry_set_text (entry, npt);
478
475
                        g_free (npt);
479
 
                        gtk_editable_set_position (GTK_EDITABLE (entry), strlen (new_prefix));
 
476
                        gtk_editable_set_position (GTK_EDITABLE (entry), strlen (new_prefix) + 1);
480
477
                }
481
478
                g_free (prefix);
482
 
                g_free (npt);
 
479
                g_free (new_prefix);
483
480
                return TRUE;
484
481
        }
485
482
 
652
649
                gtk_editable_set_position (GTK_EDITABLE (entry), -1);
653
650
        }
654
651
        entry->priv->current = sess;
 
652
 
 
653
        if (selected_text) {
 
654
                gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
 
655
                                        selected_text, strlen (selected_text));
 
656
        }
655
657
}
656
658
 
657
659
void
686
688
                g_slist_free (langs);
687
689
        }
688
690
}
 
691
#endif
689
692
 
690
 
/*
691
 
 * FIXME : This is done in preferences-page-spellcheck because if we have 2
692
 
 * notifications change on the same gonf key, the one from
693
 
 * preferences-page-spellcheck is called before this one and so it doesn't
694
 
 * work.  That's suck because we can only change languages using gconf if the
695
 
 * preference window is opened.
696
 
 */
697
 
#if 0
698
693
static void
699
 
languages_changed (GConfClient *client, guint cnxn_id, GConfEntry *gconf_entry, TextEntry *entry)
 
694
text_entry_selection_changed (GObject *obj, GParamSpec *pspec, gpointer data)
700
695
{
701
 
        GError *err = NULL;
702
 
        GSList *new_languages, *old_languages;
703
 
 
704
 
        new_languages = gconf_client_get_list (client, "/apps/xchat/spellcheck/languages", GCONF_VALUE_STRING, NULL);
705
 
 
706
 
        if (new_languages != NULL)
707
 
                sexy_spell_entry_set_active_languages (SEXY_SPELL_ENTRY (entry), new_languages, &err);
708
 
 
709
 
        if (err) {
710
 
                g_printerr (_("Error in spellchecking configuration: %s\n"), err->message);
711
 
                g_error_free (err);
712
 
 
713
 
                old_languages = sexy_spell_entry_get_active_languages (SEXY_SPELL_ENTRY (entry));
714
 
                if (old_languages != NULL) {
715
 
                        gconf_client_set_list (client, "/apps/xchat/spellcheck/languages",
716
 
                                               GCONF_VALUE_STRING, old_languages, NULL);
717
 
                        g_slist_foreach (old_languages, (GFunc) g_free, NULL);
718
 
                        g_slist_free (old_languages);
 
696
        GtkEditable *editable;
 
697
        gint start, end;
 
698
 
 
699
        editable = GTK_EDITABLE (obj);
 
700
        if (gtk_editable_get_selection_bounds (editable, &start, &end)) {
 
701
                if (start != end) {
 
702
                        if (selected_text)
 
703
                                g_free (selected_text);
 
704
                        selected_text = gtk_editable_get_chars (editable, start, end);
719
705
                }
720
706
        }
721
 
 
722
 
        g_slist_foreach (new_languages, (GFunc) g_free, NULL);
723
 
        g_slist_free (new_languages);
724
707
}
725
 
#endif
726
 
 
727
 
#endif