/* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2007 Holger Berndt <hb@claws-mail.org>
+ * Copyright (C) 2007-2012 Holger Berndt <hb@claws-mail.org>
* and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include <gdk/gdk.h>
static gboolean cb_finder_results_dialog_key_pressed(GtkWidget*, GdkEventKey*,
gpointer);
static void destroy_addr_hash_val(gpointer);
-static GSList* deep_copy_hash_val(GSList*);
+static AddrDupListEntry *copy_hash_val(AddrDupListEntry *);
static void fill_hash_table();
static gint collect_emails(ItemPerson*, AddressDataSource*);
static gboolean is_not_duplicate(gpointer, gpointer, gpointer);
val = alertpanel_full(_("Find address book email duplicates"),
_("Claws Mail will now search for duplicate email "
"addresses in the address book."),
- GTK_STOCK_CANCEL,GTK_STOCK_FIND,NULL, FALSE, vbox, ALERT_NOTICE,
- G_ALERTALTERNATE);
+ GTK_STOCK_CANCEL,GTK_STOCK_FIND, NULL,
+ ALERTFOCUS_SECOND, FALSE, vbox, ALERT_NOTICE);
if(val == G_ALERTALTERNATE) {
want_search = TRUE;
for(walk = list; walk; walk = walk->next) {
AddrDupListEntry *entry = (AddrDupListEntry*) walk->data;
- if(entry->book_path)
+ if(entry && entry->book_path)
g_free(entry->book_path);
if(entry)
g_free(entry);
g_slist_free(list);
}
-static GSList* deep_copy_hash_val(GSList *in)
+static AddrDupListEntry *copy_hash_val(AddrDupListEntry *entry)
{
- GSList *walk;
- GSList *out = NULL;
-
- out = g_slist_copy(in);
- for(walk = out; walk; walk = walk->next) {
- AddrDupListEntry *out_entry;
- AddrDupListEntry *in_entry = walk->data;
-
- out_entry = g_new0(AddrDupListEntry,1);
- out_entry->person = in_entry->person;
- out_entry->ds = in_entry->ds;
- out_entry->book_path = g_strdup(in_entry->book_path);
- walk->data = out_entry;
- }
+ AddrDupListEntry *new = g_new0(AddrDupListEntry, 1);
+ new->person = entry->person;
+ new->ds = entry->ds;
+ new->book_path = g_strdup(entry->book_path);
- return out;
+ return new;
}
static void fill_hash_table()
while(nodeM) {
ItemEMail *email = nodeM->data;
- addr = g_strdup(email->address);
- g_utf8_strdown(addr, -1);
+ addr = g_utf8_strdown(email->address, -1);
old_val = g_hash_table_lookup(addr_hash, addr);
if(old_val)
- new_val = deep_copy_hash_val(old_val);
+ new_val = slist_copy_deep(old_val, (GCopyFunc)copy_hash_val);
else
new_val = NULL;
(GCallback)detail_selection_changed, NULL);
dialog = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "address_dupes_finder");
+ gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_transient_for(GTK_WINDOW(dialog),parent);
gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
if(!geometry.min_height) {
return FALSE;
selected = gtk_tree_selection_get_selected_rows(sel_detail,&model);
- if(!selected)
- return FALSE;
+ cm_return_val_if_fail(selected, FALSE);
gtk_tree_model_get_iter(model, &iter, (GtkTreePath*)selected->data);
g_list_foreach(selected, (GFunc)gtk_tree_path_free, NULL);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(detail_view));
selected = gtk_tree_selection_get_selected_rows(selection,&model);
- g_return_if_fail(selected);
+ cm_return_if_fail(selected);
/* we are guaranteed to have exactly one row selected */
gtk_tree_view_row_activated(GTK_TREE_VIEW(detail_view),(GtkTreePath*)selected->data,
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(detail_view));
list = gtk_tree_selection_get_selected_rows(selection, &model);
-
- if(!list)
- return;
+ cm_return_if_fail(list);
aval = alertpanel(_("Delete address(es)"),
_("Really delete the address(es)?"),
- GTK_STOCK_CANCEL, "+"GTK_STOCK_DELETE, NULL);
+ GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL,
+ ALERTFOCUS_SECOND);
if(aval != G_ALERTALTERNATE)
return;
{
AddressBookFile *abf;
AddressInterface *iface;
-
+ if (!ds)
+ return FALSE;
/* Test for read only */
iface = ds->interface;
- if( iface->readOnly ) {
+ if( iface && iface->readOnly ) {
alertpanel( _("Delete address"),
_("This address data is readonly and cannot be deleted."),
- GTK_STOCK_CLOSE, NULL, NULL );
+ GTK_STOCK_CLOSE, NULL, NULL, ALERTFOCUS_FIRST );
return FALSE;
}
#endif
if(item) {
- gchar *filename = addritem_person_get_picture(item);
- if (filename && is_file_exist(filename))
- claws_unlink(filename);
- g_free(filename);
+ addritem_person_remove_picture(item);
addritem_free_item_person(item);
}
return TRUE;
gpointer data)
{
if(event) {
- if(event->keyval == GDK_Delete && detail_view_has_focus)
+ if(event->keyval == GDK_KEY_Delete && detail_view_has_focus)
cb_del_btn_clicked(NULL,NULL);
- else if(event->keyval == GDK_Escape)
+ else if(event->keyval == GDK_KEY_Escape)
gtk_widget_destroy(dialog);
}