~jordunn/meenix/Master

« back to all changes in this revision

Viewing changes to src/gtk/ascii.c

  • Committer: Jordan Dunn
  • Date: 2011-05-01 22:42:27 UTC
  • Revision ID: git-v1:1ba1788f6af88891278ff2926d536c40144bc581
MovingĀ filesĀ around

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* X-Chat
 
2
 * Copyright (C) 1998 Peter Zelezny.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
17
 */
 
18
 
 
19
#include <stdio.h>
 
20
#include <stdlib.h>
 
21
#include <string.h>
 
22
 
 
23
#include "fe-gtk.h"
 
24
 
 
25
#include <gtk/gtkeditable.h>
 
26
#include <gtk/gtkframe.h>
 
27
#include <gtk/gtkhbox.h>
 
28
#include <gtk/gtklabel.h>
 
29
#include <gtk/gtkbutton.h>
 
30
 
 
31
#include "../common/xchat.h"
 
32
#include "../common/xchatc.h"
 
33
#include "gtkutil.h"
 
34
#include "ascii.h"
 
35
#include "maingui.h"
 
36
 
 
37
static const unsigned char table[]=
 
38
{
 
39
/* Line 1 */ '\n', 
 
40
0xc2,0xa1,0xc2,0xbf,0xc2,0xa2,0xc2,0xa3,0xe2,0x82,0xac,0xc2,0xa5,0xc2,0xa6,0xc2,
 
41
0xa7,0xc2,0xa8,0xc2,0xa9,0xc2,0xae,0xc2,0xaa,0xc2,0xab,0xc2,0xbb,0xc2,0xac,0xc2,
 
42
0xad,0xc2,0xaf,0xe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8,0xd0,0xb9,0xd0,0xba,0xd0,0xbb,0xd0,0xbc,0xd0,0xbd,0xd0,0xbe,
 
84
0xd0,0xbf,0xd1,0x80,
 
85
/* Line 13 */ '\n', 
 
86
0xd0,0xa1,0xd0,0xa2,0xd0,0xa3,0xd0,0xa4,0xd0,0xa5,0xd0,0xa6,0xd0,0xa7,0xd0,0xa8,
 
87
0xd0,0xa9,0xd0,0xaa,0xd0,0xab,0xd0,0xac,0xd0,0xad,0xd0,0xae,0xd0,0xaf,
 
88
/* Line 14 */ '\n', 
 
89
0xd1,0x81,0xd1,0x82,0xd1,0x83,0xd1,0x84,0xd1,0x85,0xd1,0x86,0xd1,0x87,0xd1,0x88,
 
90
0xd1,0x89,0xd1,0x8a,0xd1,0x8b,0xd1,0x8c,0xd1,0x8d,0xd1,0x8e,0xd1,0x8f,0
 
91
};
 
92
 
 
93
 
 
94
static gboolean
 
95
ascii_enter (GtkWidget * wid, GdkEventCrossing *event, GtkWidget *label)
 
96
{
 
97
        char buf[64];
 
98
        const char *text;
 
99
        gunichar u;
 
100
 
 
101
        text = gtk_button_get_label (GTK_BUTTON (wid));
 
102
        u = g_utf8_get_char (text);
 
103
        sprintf (buf, "%s U+%04X", text, u);
 
104
        gtk_label_set_text (GTK_LABEL (label), buf);
 
105
 
 
106
        return FALSE;
 
107
}
 
108
 
 
109
static void
 
110
ascii_click (GtkWidget * wid, gpointer userdata)
 
111
{
 
112
        int tmp_pos;
 
113
        const char *text;
 
114
 
 
115
        if (current_sess)
 
116
        {
 
117
                text = gtk_button_get_label (GTK_BUTTON (wid));
 
118
                wid = current_sess->gui->input_box;
 
119
                tmp_pos = SPELL_ENTRY_GET_POS (wid);
 
120
                SPELL_ENTRY_INSERT (wid, text, -1, &tmp_pos);
 
121
                SPELL_ENTRY_SET_POS (wid, tmp_pos);
 
122
        }
 
123
}
 
124
 
 
125
void
 
126
ascii_open (void)
 
127
{
 
128
        int i, len;
 
129
        const unsigned char *table_pos;
 
130
        char name[8];
 
131
        GtkWidget *frame, *label, *but, *hbox = NULL, *vbox, *win;
 
132
 
 
133
        win = mg_create_generic_tab ("charmap", _("Character Chart"), TRUE, TRUE,
 
134
                                                                                  NULL, NULL, 0, 0, &vbox, NULL);
 
135
        gtk_container_set_border_width (GTK_CONTAINER (win), 5);
 
136
 
 
137
        label = gtk_label_new (NULL);
 
138
 
 
139
        table_pos = table;
 
140
        i = 0;
 
141
        while (table_pos[0] != 0)
 
142
        {
 
143
                if (table_pos[0] == '\n' || i == 0)
 
144
                {
 
145
                        table_pos++;
 
146
                        hbox = gtk_hbox_new (0, 0);
 
147
                        gtk_container_add (GTK_CONTAINER (vbox), hbox);
 
148
                        gtk_widget_show (hbox);
 
149
                        i++;
 
150
                        continue;
 
151
                }
 
152
 
 
153
                i++;
 
154
                len = g_utf8_skip[table_pos[0]];
 
155
                memcpy (name, table_pos, len);
 
156
                name[len] = 0;
 
157
 
 
158
                but = gtk_button_new_with_label (name);
 
159
                gtk_widget_set_size_request (but, 28, -1);
 
160
                g_signal_connect (G_OBJECT (but), "clicked",
 
161
                                                                G_CALLBACK (ascii_click), NULL);
 
162
                g_signal_connect (G_OBJECT (but), "enter_notify_event",
 
163
                                                                G_CALLBACK (ascii_enter), label);
 
164
                gtk_box_pack_start (GTK_BOX (hbox), but, 0, 0, 0);
 
165
                gtk_widget_show (but);
 
166
 
 
167
                table_pos += len;
 
168
        }
 
169
 
 
170
        frame = gtk_frame_new ("");
 
171
        gtk_container_add (GTK_CONTAINER (hbox), frame);
 
172
        gtk_container_add (GTK_CONTAINER (frame), label);
 
173
        gtk_widget_show (label);
 
174
        gtk_widget_show (frame);
 
175
 
 
176
        gtk_widget_show (win);
 
177
}