[PATCH] Tighten threading code
- From: Peter Bloomfield <PeterBloomfield MindSpring com>
- To: Balsa list <balsa-list gnome org>
- Subject: [PATCH] Tighten threading code
- Date: Tue, 16 Jul 2002 15:53:03 -0400
Minor tightening of the threading code:
src/balsa-index-threading.c: eliminate some duplicate gtk_ctree_move()
calls.
src/main-window.c: replace three callbacks with one.
Peter
Index: src/balsa-index-threading.c
===================================================================
RCS file: /cvs/gnome/balsa/src/balsa-index-threading.c,v
retrieving revision 1.16
diff -u -r1.16 balsa-index-threading.c
--- src/balsa-index-threading.c 18 May 2002 08:08:34 -0000 1.16
+++ src/balsa-index-threading.c 16 Jul 2002 19:47:44 -0000
@@ -512,31 +512,14 @@
static gboolean
construct(GNode *node, GtkCTree *ctree)
{
- GtkCTreeNode *ctreenode=NULL;
- GtkCTreeNode *ctreeparent=NULL;
- GtkCTreeNode *sibling=NULL;
+ GtkCTreeNode *ctreenode;
+ GtkCTreeNode *ctreeparent;
- if(node->parent!=NULL && node->parent->data!=NULL) {
+ if (node->parent != NULL && node->parent->data != NULL
+ && node->data != NULL) {
ctreeparent=GTK_CTREE_NODE(node->parent->data);
- }
-
- if(node->data!=NULL) {
ctreenode = GTK_CTREE_NODE(node->data);
gtk_ctree_move(ctree, ctreenode, ctreeparent, NULL);
- }
-
- if(node->next!=NULL) {
- sibling = GTK_CTREE_NODE(node->next->data);
- gtk_ctree_move(ctree, sibling, ctreeparent, ctreenode);
- }
-
- if(node->children!=NULL) {
- GNode *children;
- for(children=node->children; children; children=children->next) {
- GtkCTreeNode *foo = GTK_CTREE_NODE(children->data);
- if(foo)
- gtk_ctree_move(ctree, foo, ctreenode, NULL);
- }
}
return FALSE;
Index: src/main-window.c
===================================================================
RCS file: /cvs/gnome/balsa/src/main-window.c,v
retrieving revision 1.457
diff -u -r1.457 main-window.c
--- src/main-window.c 23 Jun 2002 19:41:55 -0000 1.457
+++ src/main-window.c 16 Jul 2002 19:47:45 -0000
@@ -186,9 +186,7 @@
static void reset_show_all_headers(void);
static void show_preview_pane_cb(GtkWidget * widget, gpointer data);
-static void threading_flat_cb(GtkWidget * widget, gpointer data);
-static void threading_simple_cb(GtkWidget * widget, gpointer data);
-static void threading_jwz_cb(GtkWidget * widget, gpointer data);
+static void threading_change_cb(GtkWidget * widget, gpointer data);
static void expand_all_cb(GtkWidget * widget, gpointer data);
static void collapse_all_cb(GtkWidget * widget, gpointer data);
@@ -382,16 +380,23 @@
static GnomeUIInfo threading_menu[] = {
#define MENU_THREADING_FLAT_POS 0
- GNOMEUIINFO_RADIOITEM(N_("_Flat index"), N_("No threading at all"),
- threading_flat_cb, NULL),
+ GNOMEUIINFO_RADIOITEM_DATA(N_("_Flat index"),
+ N_("No threading at all"),
+ threading_change_cb,
+ GINT_TO_POINTER(BALSA_INDEX_THREADING_FLAT),
+ NULL),
#define MENU_THREADING_SIMPLE_POS 1
- GNOMEUIINFO_RADIOITEM(N_("S_imple threading"),
- N_("Simple threading algorithm"),
- threading_simple_cb, NULL),
+ GNOMEUIINFO_RADIOITEM_DATA(N_("S_imple threading"),
+ N_("Simple threading algorithm"),
+ threading_change_cb,
+ GINT_TO_POINTER(BALSA_INDEX_THREADING_SIMPLE),
+ NULL),
#define MENU_THREADING_JWZ_POS 2
- GNOMEUIINFO_RADIOITEM(N_("_JWZ threading"),
- N_("Elaborate JWZ threading"),
- threading_jwz_cb, NULL),
+ GNOMEUIINFO_RADIOITEM_DATA(N_("_JWZ threading"),
+ N_("Elaborate JWZ threading"),
+ threading_change_cb,
+ GINT_TO_POINTER(BALSA_INDEX_THREADING_JWZ),
+ NULL),
GNOMEUIINFO_END
};
@@ -2423,57 +2428,25 @@
}
static void
-threading_flat_cb(GtkWidget * widget, gpointer data)
+threading_change_cb(GtkWidget * widget, gpointer data)
{
+ BalsaIndexThreadingType type;
GtkWidget *index;
GNode *gnode;
if(!GTK_CHECK_MENU_ITEM(widget)->active) return;
- index = balsa_window_find_current_index(balsa_app.main_window);
- g_return_if_fail(index);
- gnode = balsa_find_mailbox(balsa_app.mailbox_nodes,
- BALSA_INDEX(index)->mailbox_node->mailbox);
- g_return_if_fail(gnode);
- BALSA_MAILBOX_NODE(gnode->data)->threading_type =
- BALSA_INDEX_THREADING_FLAT;
- balsa_index_set_threading_type(BALSA_INDEX(index),
- BALSA_INDEX_THREADING_FLAT);
-}
-
-static void
-threading_simple_cb(GtkWidget * widget, gpointer data)
-{
- GtkWidget *index;
- GNode *gnode;
- if(!GTK_CHECK_MENU_ITEM(widget)->active) return;
index = balsa_window_find_current_index(balsa_app.main_window);
g_return_if_fail(index);
- gnode = balsa_find_mailbox(balsa_app.mailbox_nodes,
- BALSA_INDEX(index)->mailbox_node->mailbox);
- g_return_if_fail(gnode);
- BALSA_MAILBOX_NODE(gnode->data)->threading_type =
- BALSA_INDEX_THREADING_SIMPLE;
- balsa_index_set_threading_type(BALSA_INDEX(index),
- BALSA_INDEX_THREADING_SIMPLE);
-}
-static void
-threading_jwz_cb(GtkWidget * widget, gpointer data)
-{
- GtkWidget *index;
- GNode *gnode;
-
- if(!GTK_CHECK_MENU_ITEM(widget)->active) return;
- index = balsa_window_find_current_index(balsa_app.main_window);
- g_return_if_fail(index);
gnode = balsa_find_mailbox(balsa_app.mailbox_nodes,
- BALSA_INDEX(index)->mailbox_node->mailbox);
+ BALSA_INDEX(index)->mailbox_node->mailbox);
g_return_if_fail(gnode);
- BALSA_MAILBOX_NODE(gnode->data)->threading_type =
- BALSA_INDEX_THREADING_JWZ;
- balsa_index_set_threading_type(BALSA_INDEX(index),
- BALSA_INDEX_THREADING_JWZ);
+
+ type = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget),
+ GNOMEUIINFO_KEY_UIDATA));
+ BALSA_MAILBOX_NODE(gnode->data)->threading_type = type;
+ balsa_index_set_threading_type(BALSA_INDEX(index), type);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]