PATCH: Compose Coordinates



hi,

here a *pre* version of the composer coordinates and size output. how does this work.

- apply this patch, shouldnt cause any segfaults, well its still in early stages.
- now open the compose window and you get a statusbar and your coordinates of the
  textcursor printed also the size of the email is beeing shown, so you know how
  much you have typed.

affected source:
- src/sendmsg-window.c

plans:
- more accuracy (after i figured out whats up)
- more stuff in the statusline e.g.

wordcount, whitespacecount, linescount, charinfo when the cursor is over it (tell us
what ascii value it is) and the key_press_event will do more in the future, noticed
that unbehave when you cut a long number of lines out of a composed text ? then the
last few lines gets cluttered. i will take care about 'cuts and pastes' soon so the
compose window contents get refreshed.

btw: this patch works perfectly, no segfaults or crashes or whatever, no prefs will
be added and nothing on your system will be harmed, but this patch is still not ready
for CVS i want only to show it to you guys and have it tested (if there is one or
the other volunteer) i appreciate tipps, hints, comments and if you know why something
behaves strangely then let me know.

patch -p0 < balsa-coordinates.patch

-- 
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
+++ src/sendmsg-window.c	Sat Aug 18 10:35:40 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,10 @@
     GtkWidget *table;
 
     msg->text = gtk_text_new(NULL, NULL);
+
+    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 +1184,30 @@
     return table;
 }
 
+static gint
+balsa_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+    gchar *statustext = NULL;
+
+    gint x = 0;
+    gint y = 0;
+    guint size = 0;
+
+    g_return_if_fail(widget != NULL);
+
+    size = gtk_text_get_length(GTK_TEXT(((BalsaSendmsg *) data)->text));
+
+    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;
+
+    statustext = g_strdup_printf(_("x: %ld - y: %ld - size: %ld bytes."), x, y, size);
+    gnome_appbar_set_default(appbar2, statustext);
+    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 +1555,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]