Re: PATCH: Compose Coordinates



On 2001.08.18 19:21:05 +0200 Ali Akcaagac wrote:
> wordcount, whitespacecount, linescount, charinfo when the
> cursor is over it (tell us what ascii value it is) and the

oki here is a new version *still only for testing purposes*
of the statusbar patch, someone please figure out if the
event choosen by me is the correct one since the info thrown
out in the statusbar is sometimes some chars behind or before
i am not 100% sure but this may be because of a wrong event.
i placed this one in a key_press_event temporarely only for
testing purposes but i think that this event is wrong.

anyways here the patch for testing, look at the picture how
it looks if you are in the compose window. note its not 100%

any comments, hints, info about this ?

btw: christophe barbe now you can apply it as you recommend.

-- 
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

status.jpg

--- /mnt/private/temp/cvstree/balsa/src/sendmsg-window.c	Sat Aug 18 18:17:35 2001
+++ balsa/src/sendmsg-window.c	Sun Aug 19 01:45:20 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);
+
+    /* FIXME: i am not sure if this signal is the right one for this */
+    /*        kind of implementation. another event could be better. */
+    gtk_signal_connect(GTK_OBJECT(msg->text), "key_press_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,111 @@
     return table;
 }
 
+static gint
+balsa_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+    gchar *message = NULL;
+    gchar *symbol = NULL;
+    gchar *statustext = NULL;
+
+    gint x = 0;
+    gint y = 0;
+
+    int point = 0;
+    int size = 0;
+
+    int count = 0;
+    int lines = 0;
+    int words = 0;
+    int hexval = 0;
+
+    int wordflag = 0;
+
+    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 current x/y origin of the textcursor */
+    x = GTK_TEXT(((BalsaSendmsg *) data)->text)->cursor_pos_x / 7 +
+	GTK_TEXT(((BalsaSendmsg *) data)->text)->cursor_virtual_x / 7;
+    y = GTK_TEXT(((BalsaSendmsg *) data)->text)->cursor_pos_y / 15;
+
+    /* get the current cursor point within the text */
+    point = gtk_text_get_point(GTK_TEXT(((BalsaSendmsg *) data)->text));
+
+    /* get the complete size of the text */
+    size = gtk_text_get_length(GTK_TEXT(((BalsaSendmsg *) data)->text));
+
+    /* get the message body */
+    message = gtk_editable_get_chars(GTK_EDITABLE(((BalsaSendmsg *) data)->text), 0, -1);
+
+    /* lines: get the total lines of the message */
+    /* words: get the total words of the message */
+    while (message[count++] != '\0') {
+	if (message[count] == '\n')
+	    lines++;
+	if (message[count] == '\n' || message[count] == '\t'|| message[count] == ' ')
+	    wordflag = 0;
+	else if (wordflag == 0) {
+	    wordflag = 1;
+	    words++;
+	}
+    }
+
+    lines++;
+
+    /* get the symbol within the text and the hexval*/
+    hexval = message[point];
+    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, Point: %ld, X: %ld, Y: %ld Char: 0x%x => '%s'."), size, lines, words, point, 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 +1638,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]