PATCH: Compose Coordinates *FINAL*
- From: Ali Akcaagac <ali akcaagac stud fh-wilhelmshaven de>
- To: balsa-list gnome org
- Subject: PATCH: Compose Coordinates *FINAL*
- Date: Sun, 19 Aug 2001 11:49:45 +0200
hello,
first of all, sorry for bombarding the mailinglist with my
compose window coordinates stuff but sometimes you are going
with some ideas... well ok.
now i am finished so far, everything works as it should and i
really would like to get some of you guys testing this.
please apply this patch to a recent balsa CVS, this version
works 100%, no crashes, no wrong coordinates or whatever.
here a feature list so far:
- output of textsize in bytes. if you type more text, the size
gets increased dynamically. in the statusbar you get this with
e.g. 'Size: 2345 bytes'
- outputs the amount of lines in your text. value gets changed
whenever you add or delete lines. statusbar show you this
e.g. 'Lines: 12'
- output of amount of words written in your text. only separated
by spaces, tabs or newlines. same stuff as written in ansi-c
by kerninghan & ritchie :) you get this in the statusbar
e.g. 'Words: 2012'
- output of index to the statusbar, showing you the real position
within the text itself.
e.g. 'Index: 1232'
- output of the coordinates. this one is selfexplainatory
X: 4, Y: 2
- output of the char infront of the cursor, you get the output
in hexadecimal value and the ascii value itself. sometimes
you work and see a certain char and want to know what value
it is, so you can reproduce it quickly. the best is you get
also the output of the < 0x20 chars, e.g. null, linefeed,
carriage return and whatever. specially fine if you include
windows related textfiles or you include textfiles with
special ansi sequences.
well, i worked really long on this patch, its nothing special
but figuring out GTK was a mess, since not everything was
explained everywhere, i needed to tweak in the gtk code itself.
so far. i would really like to get a reply. test it and reply,
if you detect some unbehaves.
--
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@stud.fh-wilhelmshaven.de
WWW.....: http://www.fh-wilhelmshaven.de/~akcaagaa
--- /mnt/private/temp/cvstree/balsa/src/sendmsg-window.c Sat Aug 18 18:17:35 2001
+++ balsa/src/sendmsg-window.c Sun Aug 19 11:36:37 2001
@@ -76,6 +76,8 @@
#define GNOME_MIME_BUG_WORKAROUND 1
+GnomeAppBar *appbar2;
+
static gchar *read_signature(BalsaSendmsg *msg);
static gint include_file_cb(GtkWidget *, BalsaSendmsg *);
static gint send_message_cb(GtkWidget *, BalsaSendmsg *);
@@ -118,6 +120,8 @@
static void sw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc);
+static gint balsa_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data);
+
/* Standard DnD types */
enum {
TARGET_URI_LIST,
@@ -1160,6 +1164,12 @@
GtkWidget *table;
msg->text = gtk_text_new(NULL, NULL);
+
+ gtk_signal_connect_after(GTK_OBJECT(msg->text), "key_press_event",
+ GTK_SIGNAL_FUNC(balsa_key_press_event_cb), msg);
+ gtk_signal_connect_after(GTK_OBJECT(msg->text), "map_event",
+ GTK_SIGNAL_FUNC(balsa_key_press_event_cb), msg);
+
gtk_text_set_editable(GTK_TEXT(msg->text), TRUE);
gtk_text_set_word_wrap(GTK_TEXT(msg->text), TRUE);
balsa_spell_check_set_text(BALSA_SPELL_CHECK(msg->spell_checker),
@@ -1176,6 +1186,99 @@
return table;
}
+static gint
+balsa_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+ gchar *message = NULL;
+ gchar *symbol = NULL;
+ gchar *statustext = NULL;
+
+ int x = 1;
+ int y = 1;
+
+ int lines = 1;
+ int rows = 1;
+
+ int index = 0;
+ int words = 0;
+ int size = 0;
+ int hexval = 0;
+
+ int wordflag = 0;
+
+ /* initialize the power-ascii-table for chars < 0x20 */
+ gchar *lowsymbols[] = {
+ N_("Null"), N_("Start of Heading"),
+ N_("Start of Text"), N_("End of Text"),
+ N_("End of Transmission"), N_("Enquiry"),
+ N_("Acknowledge"), N_("Bell"),
+ N_("Backspace"), N_("Horizontal Tabulation"),
+ N_("Line Feed"), N_("Vertical Tabulation"),
+ N_("Form Feed"), N_("Carriage Return"),
+ N_("Shift Out"), N_("Shift In"),
+ N_("Data Link Escape"), N_("Device Control 1"),
+ N_("Device Control 2"), N_("Device Control 3"),
+ N_("Device Control 4"), N_("Negative Acknowledge"),
+ N_("Synchronous Idle"), N_("End of Transmission Block"),
+ N_("Cancel"), N_("End of Medium"),
+ N_("Substitute"), N_("Escape"),
+ N_("File Separator"), N_("Group Separator"),
+ N_("Record Separator"), N_("Unit Separator")
+ };
+
+ g_return_if_fail(widget != NULL);
+
+ /* get the message body */
+ message = gtk_editable_get_chars(GTK_EDITABLE(GTK_TEXT(((BalsaSendmsg *) data)->text)), 0, -1);
+
+ /* get the index of the cursor */
+ index = gtk_editable_get_position(GTK_EDITABLE(GTK_TEXT(((BalsaSendmsg *) data)->text)));
+
+ /* lines: get the total lines of the message */
+ /* words: get the total words of the message */
+ /* size: get the total size of the message */
+ while (message[size] != '\0') {
+ if (message[size] == '\n') {
+ lines++;
+ rows = 1;
+ } else {
+ rows++;
+ }
+
+ if (message[size] == '\n' || message[size] == '\t'|| message[size] == ' ') {
+ wordflag = 0;
+ } else if (wordflag == 0) {
+ wordflag = 1;
+ words++;
+ }
+
+ if (size < index) {
+ x = rows;
+ y = lines;
+ }
+
+ size++;
+ }
+
+ /* get the symbol within the text and the hexval */
+ hexval = message[index];
+ symbol = g_strdup_printf("%c", hexval);
+
+ if (*symbol <= 0x1f && *symbol >= 0x00) {
+ g_free(symbol);
+ symbol = lowsymbols[hexval];
+ }
+
+ /* output the stuff to the appbar */
+ statustext = g_strdup_printf(_("Size: %ld bytes, Lines: %ld, Words: %ld, Index: %ld, X: %ld, Y: %ld, Char: 0x%x => '%s'."), size, lines, words, index, x, y, hexval, symbol);
+ gnome_appbar_set_default(appbar2, statustext);
+
+ g_free(message);
+ g_free(statustext);
+
+ return TRUE;
+}
+
/* continueBody ---------------------------------------------------------
a short-circuit procedure for the 'Continue action'
basically copies the text over to the entry field.
@@ -1523,6 +1626,10 @@
/* create text area for the message */
gtk_paned_add2(GTK_PANED(paned), create_text_area(msg));
+ /* FIXME: create statusbar, this is only temporarely and needs fix */
+ appbar2 = GNOME_APPBAR(gnome_appbar_new(TRUE, TRUE, GNOME_PREFERENCES_USER));
+ gnome_app_set_statusbar(GNOME_APP(window), GTK_WIDGET(appbar2));
+
/* fill in that info: */
/* To: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]