PATCH: balsa-coordinates6b



hello,

the balsacode changed a bit so my previous patch can't be applied
easily anymore. here the new patch against current CVS. nothing new
added but i will overwork this one really soon..

besides: thanks to the person who included that crappy vim header at
the top of the source. want to let you know that the settings totally
confuses me :)

4space TABS are windows crap so are replacing tabstops with spaces.
hardcore vim programmers use real tabstops with a tabwidth of 8 as it
has to be.. following the code style of balsa == yes, messing up my
own settings == no.

-- 
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
--- balsa/src/sendmsg-window.c.orig	Thu Sep 27 12:55:05 2001
+++ balsa/src/sendmsg-window.c	Thu Sep 27 13:12:11 2001
@@ -76,6 +76,12 @@
 
 #define GNOME_MIME_BUG_WORKAROUND 1
 
+/* setup statusbar related things */
+GnomeAppBar *appbar2;
+
+GtkWidget *frame1, *frame2, *frame3, *frame4, *frame5, *frame6;
+GtkWidget *label1, *label2, *label3, *label4, *label5, *label6;
+
 static gchar *read_signature(BalsaSendmsg *msg);
 static gint include_file_cb(GtkWidget *, BalsaSendmsg *);
 static gint send_message_cb(GtkWidget *, BalsaSendmsg *);
@@ -119,6 +125,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,
@@ -1252,6 +1260,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);
+
     if (msg->flow)
         gtk_signal_connect(GTK_OBJECT(msg->text), "insert-text",
                            insert_text_cb, NULL);
@@ -1271,6 +1285,132 @@
     return table;
 }
 
+static gint
+balsa_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+    gchar *message = NULL;
+    gchar *symbol = NULL;
+    gchar *statustext = NULL;
+    gchar *charstext = NULL;
+    gchar *sizetext = NULL;
+    gchar *wordstext = NULL;
+    gchar *linestext = NULL;
+    gchar *indextext = NULL;
+    gchar *coordstext = NULL;
+
+    gint index = 0;
+
+    int lines = 1;
+    int rows = 1;
+    int words = 0;
+    int size = 0;
+    int x = 1;
+    int y = 1;
+
+    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")
+    };
+
+    /* 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 */
+    /* x/y: get the x/y origin within 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 < (int)index) {
+	    x = rows;
+	    y = lines;
+	}
+
+	size++;
+    }
+
+    /* get the symbol within the text and the hexval */
+    hexval = message[(int)index];
+    symbol = g_strdup_printf("%c", hexval);
+
+    if (hexval <= 0x1f && hexval >= 0x00) {
+	g_free(symbol);
+	symbol = lowsymbols[hexval];
+    }
+
+    /* output the stuff to the appbar */
+    if (hexval <= 0x1f && hexval >= 0x00) {
+	statustext = g_strdup_printf(_("%s"), symbol);
+	charstext = g_strdup_printf(_("Char: 0x%X"), hexval);
+    } else {
+	statustext = g_strdup("");
+	charstext = g_strdup_printf(_("Char: 0x%X => '%s'"), hexval, symbol);
+    }
+
+    gnome_appbar_set_default(appbar2, statustext);
+    gtk_label_set(GTK_LABEL(label1), charstext);
+
+    sizetext = g_strdup_printf(_("Size: %d bytes"), size);
+    gtk_label_set(GTK_LABEL(label2), sizetext);
+
+    wordstext = g_strdup_printf(_("Words: %d"), words);
+    gtk_label_set(GTK_LABEL(label3), wordstext);
+
+    linestext = g_strdup_printf(_("Lines: %d"), lines);
+    gtk_label_set(GTK_LABEL(label4), linestext);
+
+    indextext = g_strdup_printf(_("Index: %d"), (int)index);
+    gtk_label_set(GTK_LABEL(label5), indextext);
+
+    coordstext = g_strdup_printf(_("X/Y: %d/%d"), x, y);
+    gtk_label_set(GTK_LABEL(label6), coordstext);
+
+    g_free(message);
+    g_free(statustext);
+    g_free(charstext);
+    g_free(sizetext);
+    g_free(wordstext);
+    g_free(linestext);
+    g_free(indextext);
+    g_free(coordstext);
+
+    return TRUE;
+}
+
 /* continueBody ---------------------------------------------------------
    a short-circuit procedure for the 'Continue action'
    basically copies the first text/plain part over to the entry field.
@@ -1770,6 +1910,76 @@
     /* 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(FALSE, TRUE, GNOME_PREFERENCES_USER));
+    gnome_app_set_statusbar(GNOME_APP(window), GTK_WIDGET(appbar2));
+
+    /* FIXME: set a new statusbarcell */
+    frame1 = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame1), GTK_SHADOW_IN);
+    label1 = gtk_label_new("");
+    gtk_misc_set_alignment(GTK_MISC(label1), 0.5, 0.5);
+    gtk_widget_set_usize(GTK_WIDGET(label1), gdk_string_width(gtk_widget_get_style(GTK_WIDGET(label1))->font, "####################"), -1);
+    gtk_container_add(GTK_CONTAINER(frame1), GTK_WIDGET(label1));
+    gtk_box_pack_start(GTK_BOX(appbar2), GTK_WIDGET(frame1), FALSE, TRUE, 0);
+    gtk_widget_show(frame1);
+    gtk_widget_show(label1);
+
+    /* FIXME: set a new statusbarcell */
+    frame2 = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame2), GTK_SHADOW_IN);
+    label2 = gtk_label_new("");
+    gtk_misc_set_alignment(GTK_MISC(label2), 0.5, 0.5);
+    gtk_widget_set_usize(GTK_WIDGET(label2), gdk_string_width(gtk_widget_get_style(GTK_WIDGET(label2))->font, "####################"), -1);
+    gtk_container_add(GTK_CONTAINER(frame2), GTK_WIDGET(label2));
+    gtk_box_pack_start(GTK_BOX(appbar2), GTK_WIDGET(frame2), FALSE, TRUE, 0);
+    gtk_widget_show(frame2);
+    gtk_widget_show(label2);
+
+    /* FIXME: set a new statusbarcell */
+    frame3 = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame3), GTK_SHADOW_IN);
+    label3 = gtk_label_new("");
+    gtk_misc_set_alignment(GTK_MISC(label3), 0.5, 0.5);
+    gtk_widget_set_usize(GTK_WIDGET(label3), gdk_string_width(gtk_widget_get_style(GTK_WIDGET(label3))->font, "###############"), -1);
+    gtk_container_add(GTK_CONTAINER(frame3), GTK_WIDGET(label3));
+    gtk_box_pack_start(GTK_BOX(appbar2), GTK_WIDGET(frame3), FALSE, TRUE, 0);
+    gtk_widget_show(frame3);
+    gtk_widget_show(label3);
+
+    /* FIXME: set a new statusbarcell */
+    frame4 = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame4), GTK_SHADOW_IN);
+    label4 = gtk_label_new("");
+    gtk_misc_set_alignment(GTK_MISC(label4), 0.5, 0.5);
+    gtk_widget_set_usize(GTK_WIDGET(label4), gdk_string_width(gtk_widget_get_style(GTK_WIDGET(label4))->font, "###############"), -1);
+    gtk_container_add(GTK_CONTAINER(frame4), GTK_WIDGET(label4));
+    gtk_box_pack_start(GTK_BOX(appbar2), GTK_WIDGET(frame4), FALSE, TRUE, 0);
+    gtk_widget_show(frame4);
+    gtk_widget_show(label4);
+
+    /* FIXME: set a new statusbarcell */
+    frame5 = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame5), GTK_SHADOW_IN);
+    label5 = gtk_label_new("");
+    gtk_misc_set_alignment(GTK_MISC(label5), 0.5, 0.5);
+    gtk_widget_set_usize(GTK_WIDGET(label5), gdk_string_width(gtk_widget_get_style(GTK_WIDGET(label5))->font, "###############"), -1);
+    gtk_container_add(GTK_CONTAINER(frame5), GTK_WIDGET(label5));
+    gtk_box_pack_start(GTK_BOX(appbar2), GTK_WIDGET(frame5), FALSE, TRUE, 0);
+    gtk_widget_show(frame5);
+    gtk_widget_show(label5);
+
+    /* FIXME: set a new statusbarcell */
+    frame6 = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame6), GTK_SHADOW_IN);
+    label6 = gtk_label_new("");
+    gtk_misc_set_alignment(GTK_MISC(label6), 0.5, 0.5);
+    gtk_widget_set_usize(GTK_WIDGET(label6), gdk_string_width(gtk_widget_get_style(GTK_WIDGET(label6))->font, "###############"), -1);
+    gtk_container_add(GTK_CONTAINER(frame6), GTK_WIDGET(label6));
+    gtk_box_pack_start(GTK_BOX(appbar2), GTK_WIDGET(frame6), FALSE, TRUE, 0);
+    gtk_widget_show(frame6);
+    gtk_widget_show(label6);
+
     /* fill in that info: */
 
     /* To: */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]