Customizing balsa (scrolling while selecting)




Hi there,

I am customizing balsa a little bit .. I want the preview window to scroll
down when I reached the end of the window while selecting. At this moment I
added a few signals so that when I am pressing and moving my mice over the
window->preview widget .. I get a message like :

You are pressing left mouse button and moving [139, 295] 
 or 
You are pressing right mouse button and moving [139, 295]

(It's in the patch that is attached).

Only thing I still need is to detect wheter I am at the bottom or top of
the preview widget with my mouse pointer and how to "move" the scrollbar of
the preview widget. Can somebody help me with that ? (check the attached
patch. Once patched -against current cvs- the motion callback function is 
at position 2868 called "preview_motion_cb").

*Note* that I am not trying to make an "official" patch so no flamewars 
about the feature that I am adding :). Unless ofcourse the balsa 
maintainers are intrested in the patch... but this one is at this
moment for my personal use. I have my reasons to fix this issue for
me .. ;) so again : no flaming.


-- 
Philip van Hoof aka freax (http://www.freax.eu.org)
irc: irc.openprojects.net mailto:freax @ linux.be 
--- balsa/src/main-window.c	Fri Nov  2 16:01:22 2001
+++ balsa-freax/src/main-window.c	Sat Nov  3 11:36:14 2001
@@ -150,7 +150,6 @@
 
 /* callbacks */
 static void send_outbox_messages_cb(GtkWidget *, gpointer data);
-static void send_receive_messages_cb(GtkWidget *, gpointer data);
 
 static void new_message_cb(GtkWidget * widget, gpointer data);
 static void replyto_message_cb(GtkWidget * widget, gpointer data);
@@ -198,6 +197,7 @@
 static void mark_all_cb(GtkWidget * widget, gpointer);
 
 static void select_part_cb(BalsaMessage * bm, gpointer data);
+static void preview_motion_cb(GtkWidget * widget, GdkEventMotion *event);
 
 #ifdef BALSA_SHOW_ALL
 static void filter_dlg_cb(GtkWidget * widget, gpointer data);
@@ -317,8 +317,7 @@
      BALSA_PIXMAP_MENU_SEND, 'T', GDK_CONTROL_MASK, NULL},
     GNOMEUIINFO_SEPARATOR,
 #define MENU_FILE_PRINT_POS 6
-    { GNOME_APP_UI_ITEM, N_("_Print..."), 
-      N_("Print currently selected messages"),
+    { GNOME_APP_UI_ITEM, N_("_Print..."), NULL,
       message_print_cb, NULL, NULL, GNOME_APP_PIXMAP_STOCK,
       BALSA_PIXMAP_MENU_PRINT, 'P', GDK_CONTROL_MASK, NULL},
     GNOMEUIINFO_SEPARATOR,
@@ -500,10 +499,20 @@
         GNOME_APP_UI_ITEM, N_("_View Source..."),
         N_("View source form of the message"),
         view_msg_source_cb, NULL, NULL, GNOME_APP_PIXMAP_STOCK,
-        GNOME_STOCK_MENU_BOOK_OPEN, 'v', GDK_CONTROL_MASK, NULL
+        BALSA_PIXMAP_MENU_SAVE, 'v', GDK_CONTROL_MASK, NULL
     },
+	GNOMEUIINFO_SEPARATOR,   
+#define MENU_MESSAGE_COPY_POS 11
+	GNOMEUIINFO_MENU_COPY_ITEM(copy_cb, NULL),
+#define MENU_MESSAGE_SELECT_ALL_POS 12
+	{
+		GNOME_APP_UI_ITEM, N_("_Select Text"),
+		N_("Select entire mail"),
+		select_all_cb, NULL, NULL, GNOME_APP_PIXMAP_NONE,
+		NULL, 'A', GDK_CONTROL_MASK, NULL
+    },  
     GNOMEUIINFO_SEPARATOR,
-#define MENU_MESSAGE_TRASH_POS 11
+#define MENU_MESSAGE_TRASH_POS 15
     /* D */
     {
         GNOME_APP_UI_ITEM, N_("_Move to Trash"), 
@@ -511,23 +520,23 @@
         trash_message_cb, NULL, NULL, GNOME_APP_PIXMAP_STOCK,
         GNOME_STOCK_MENU_TRASH, 'D', 0, NULL
     },
-#define MENU_MESSAGE_DELETE_POS 12
+#define MENU_MESSAGE_DELETE_POS 16
     { GNOME_APP_UI_ITEM, N_("_Delete"), 
       N_("Delete the current message"),
       delete_message_cb, NULL, NULL, GNOME_APP_PIXMAP_STOCK,
       GNOME_STOCK_MENU_TRASH, 'D', GDK_CONTROL_MASK, NULL },
-#define MENU_MESSAGE_UNDEL_POS 13
+#define MENU_MESSAGE_UNDEL_POS 17
     /* U */
     {
         GNOME_APP_UI_ITEM, N_("_Undelete"), N_("Undelete the message"),
         undelete_message_cb, NULL, NULL, GNOME_APP_PIXMAP_STOCK,
         GNOME_STOCK_MENU_UNDELETE, 'U', 0, NULL
     },
-#define MENU_MESSAGE_TOGGLE_POS 14
+#define MENU_MESSAGE_TOGGLE_POS 18
     /* ! */
     GNOMEUIINFO_SUBTREE(N_("_Toggle"), message_toggle_menu),
     GNOMEUIINFO_SEPARATOR,
-#define MENU_MESSAGE_STORE_ADDRESS_POS 16
+#define MENU_MESSAGE_STORE_ADDRESS_POS 19
     /* S */
     {
         GNOME_APP_UI_ITEM, N_("_Store Address..."),
@@ -737,7 +746,6 @@
         const char* icon_id;
         void (*callback)(GtkWidget *, gpointer);
     } callback_table[] = {
-        { BALSA_PIXMAP_SEND_RECEIVE,     send_receive_messages_cb },
         { BALSA_PIXMAP_RECEIVE,          check_new_messages_cb },
         { BALSA_PIXMAP_TRASH,            trash_message_cb },
         { BALSA_PIXMAP_NEW,              new_message_cb },
@@ -826,6 +834,10 @@
     gtk_signal_connect(GTK_OBJECT(window->preview), "select-part",
                        GTK_SIGNAL_FUNC(select_part_cb), window);
 
+	gtk_signal_connect (GTK_OBJECT (window->preview), "motion_notify_event",
+                       GTK_SIGNAL_FUNC (preview_motion_cb),
+                       window->preview);
+
     gtk_container_add(GTK_CONTAINER(scroll), window->preview);
     gtk_widget_show(scroll);
 
@@ -1077,6 +1089,12 @@
     gtk_widget_set_sensitive(edit_menu[MENU_EDIT_COPY_POS].widget, enable);
     gtk_widget_set_sensitive(edit_menu[MENU_EDIT_SELECT_ALL_POS].widget,
                              enable);
+
+	gtk_widget_set_sensitive(message_menu[MENU_MESSAGE_COPY_POS].widget, enable);
+    gtk_widget_set_sensitive(message_menu[MENU_MESSAGE_SELECT_ALL_POS].widget,
+                             enable);
+                             
+                             
 }
 
 /*
@@ -1743,21 +1761,6 @@
 #endif
 }
 
-static void
-send_receive_messages_cb(GtkWidget * widget, gpointer data)
-{
-#if ENABLE_ESMTP
-    libbalsa_process_queue(balsa_app.outbox, balsa_app.encoding_style,
-                           balsa_app.smtp_server, balsa_app.smtp_authctx,
-                           balsa_app.smtp_tls_mode,
-                           balsa_app.send_rfc2646_format_flowed);
-#else
-    libbalsa_process_queue(balsa_app.outbox, balsa_app.encoding_style,
-                           balsa_app.send_rfc2646_format_flowed);
-#endif
-    check_new_messages_real(widget, data, TYPE_CALLBACK);
-}
-
 void
 check_new_messages_cb(GtkWidget * widget, gpointer data)
 {
@@ -2864,6 +2867,27 @@
     enable_edit_menus (NULL);
 }
 
+static void preview_motion_cb(GtkWidget * widget, GdkEventMotion *event)
+{
+    int x, y;
+    GdkModifierType state;
+
+    if (event->is_hint) {
+        gdk_window_get_pointer(event->window, &x, &y, &state);
+    } else {
+        x = (int) event->x;  // warning cast
+        y = (int) event->y;  // warning cast
+        state = (GdkModifierType) event->state; // warning cast 
+    } 
+    if (state & GDK_BUTTON1_MASK) {
+        g_print ("You are pressing left mouse button and moving [%d, %d]\n", x, y);
+    }
+
+    if (state & GDK_BUTTON3_MASK) {
+         g_print ("You are pressing right mouse button and moving [%d, %d]\n", x, y);
+    }
+    
+}
 
 static void
 select_part_cb(BalsaMessage * bm, gpointer data)


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