# HG changeset patch # User Luke Schierer # Date 1067904629 0 # Node ID 53c86d59f20b46db37a09c39868678e441b74a10 # Parent 82dfe392a773c76e4962597ad666a495b2c16987 [gaim-migrate @ 8022] (19:08:24) deryni: Paco-Paco can stop wanting to kill Sean for using ctrl-f in conversations, and all the rest of you can have fun making offline buddies take priority over online ones (I'm sure you'll figure it out =) and a change from free() to g_free() in yahoo from zuperdee, since g_free is theoretically doing more error checking committer: Tailor Script diff -r 82dfe392a773 -r 53c86d59f20b src/blist.c --- a/src/blist.c Mon Nov 03 16:42:32 2003 +0000 +++ b/src/blist.c Tue Nov 04 00:10:29 2003 +0000 @@ -114,32 +114,34 @@ static void gaim_contact_compute_priority_buddy(GaimContact *contact) { GaimBlistNode *bnode; contact->priority = NULL; + contact->score = INT_MAX; for(bnode = ((GaimBlistNode*)contact)->child; bnode; bnode = bnode->next) { GaimBuddy *buddy; + int score = 0; + if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) continue; buddy = (GaimBuddy*)bnode; if(!gaim_account_is_connected(buddy->account)) continue; - if(!contact->priority) { + if (!GAIM_BUDDY_IS_ONLINE(buddy)) + score += gaim_prefs_get_int("/core/contact/offline_score"); + if (buddy->uc & UC_UNAVAILABLE) + score += gaim_prefs_get_int("/core/contact/away_score"); + if (buddy->idle) + score += gaim_prefs_get_int("/core/contact/idle_score"); + + score += gaim_account_get_int(buddy->account, "score", 0); + + if (score < contact->score) { contact->priority = buddy; - } else if(GAIM_BUDDY_IS_ONLINE(buddy)) { - if(!GAIM_BUDDY_IS_ONLINE(contact->priority)) { - contact->priority = buddy; - } else if(!(buddy->uc & UC_UNAVAILABLE) && !buddy->idle && - (contact->priority->uc & UC_UNAVAILABLE || - contact->priority->idle)) { + contact->score = score; + } + if (gaim_prefs_get_bool("/core/contact/last_match")) + if (score == contact->score) contact->priority = buddy; - } else if(!buddy->idle && contact->priority->idle) { - contact->priority = buddy; - } else if(contact->priority->uc & UC_UNAVAILABLE && - contact->priority->idle && (!(buddy->uc & UC_UNAVAILABLE) || - !buddy->idle)) { - contact->priority = buddy; - } - } } } @@ -747,6 +749,7 @@ ((GaimBlistNode*)c)->type = GAIM_BLIST_CONTACT_NODE; c->totalsize = c->currentsize = c->online = 0; + c->score = INT_MAX; ops = gaim_blist_get_ui_ops(); if (ops != NULL && ops->new_node != NULL) diff -r 82dfe392a773 -r 53c86d59f20b src/blist.h --- a/src/blist.h Mon Nov 03 16:42:32 2003 +0000 +++ b/src/blist.h Tue Nov 04 00:10:29 2003 +0000 @@ -119,6 +119,7 @@ int currentsize; /**< The number of buddies in this contact corresponding to online accounts */ int online; /**< The number of buddies in this contact who are currently online */ GaimBuddy *priority; /**< The "top" buddy for this contact */ + int score; /**< The priority score. */ }; diff -r 82dfe392a773 -r 53c86d59f20b src/gtkconv.c --- a/src/gtkconv.c Mon Nov 03 16:42:32 2003 +0000 +++ b/src/gtkconv.c Tue Nov 04 00:10:29 2003 +0000 @@ -3026,6 +3026,8 @@ gtk_item_factory_create_items(gtkwin->menu.item_factory, menu_item_count, menu_items, win); + g_signal_connect(G_OBJECT(accel_group), "accel-changed", + G_CALLBACK(gaim_gtk_save_accels_cb), NULL); gtkwin->menu.menubar = diff -r 82dfe392a773 -r 53c86d59f20b src/gtkutils.c --- a/src/gtkutils.c Mon Nov 03 16:42:32 2003 +0000 +++ b/src/gtkutils.c Tue Nov 04 00:10:29 2003 +0000 @@ -49,6 +49,8 @@ #include "wspell.h" #endif +guint accels_save_timer = 0; + static void url_clicked_cb(GtkWidget *w, const char *uri) { @@ -1077,3 +1079,40 @@ gdk_pixbuf_loader_close(loader, NULL); } } + +void +gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, + GdkModifierType arg2, GClosure *arg3, + gpointer data) +{ + gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n"); + + if (!accels_save_timer) + accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, NULL); +} + +gboolean +gaim_gtk_save_accels(gpointer data) +{ + char *filename = NULL; + + filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, + "accels", NULL); + gaim_debug(GAIM_DEBUG_MISC, "accels", "saving accels to %s\n", filename); + gtk_accel_map_save(filename); + g_free(filename); + + accels_save_timer = 0; + return FALSE; +} + +void +gaim_gtk_load_accels(gpointer data) +{ + char *filename = NULL; + + filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, + "accels", NULL); + gtk_accel_map_load(filename); + g_free(filename); +} diff -r 82dfe392a773 -r 53c86d59f20b src/gtkutils.h --- a/src/gtkutils.h Mon Nov 03 16:42:32 2003 +0000 +++ b/src/gtkutils.h Tue Nov 04 00:10:29 2003 +0000 @@ -45,6 +45,8 @@ typedef gboolean (*GaimCheckAccountFunc)(GaimAccount *account); +extern guint accels_save_timer; + /** * Sets up a gtkimhtml widget, loads it with smileys, and sets the * default signal handlers. @@ -284,4 +286,21 @@ */ char *stylize(const gchar *text, int len); +/** + * Save menu accelerators callback + */ +void gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, + GdkModifierType arg2, GClosure *arg3, + gpointer data); + +/** + * Save menu accelerators + */ +gboolean gaim_gtk_save_accels(gpointer data); + +/** + * Load menu accelerators + */ +void gaim_gtk_load_accels(); + #endif /* _GAIM_GTK_UTILS_H_ */ diff -r 82dfe392a773 -r 53c86d59f20b src/prefs.c --- a/src/prefs.c Mon Nov 03 16:42:32 2003 +0000 +++ b/src/prefs.c Tue Nov 04 00:10:29 2003 +0000 @@ -120,6 +120,13 @@ /* Buddies */ gaim_prefs_add_none("/core/buddies"); gaim_prefs_add_bool("/core/buddies/use_server_alias", TRUE); + + /* Contact Priority Settings */ + gaim_prefs_add_none("/core/contact"); + gaim_prefs_add_bool("/core/contact/last_match", FALSE); + gaim_prefs_add_int("/core/contact/offline_score", 4); + gaim_prefs_add_int("/core/contact/away_score", 2); + gaim_prefs_add_int("/core/contact/idle_score", 1); } static char * diff -r 82dfe392a773 -r 53c86d59f20b src/protocols/yahoo/yahoo.c --- a/src/protocols/yahoo/yahoo.c Mon Nov 03 16:42:32 2003 +0000 +++ b/src/protocols/yahoo/yahoo.c Tue Nov 04 00:10:29 2003 +0000 @@ -1345,8 +1345,8 @@ yahoo_send_packet(yd, pack); yahoo_packet_free(pack); - free(password_hash); - free(crypt_hash); + g_free(password_hash); + g_free(crypt_hash); } static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt)