Revision 2295 src/addressbook.c
| addressbook.c (revision 2295) | ||
|---|---|---|
| 1 | 1 |
/* |
| 2 | 2 |
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 |
* Copyright (C) 1999-2007 Hiroyuki Yamamoto
|
|
| 3 |
* Copyright (C) 1999-2009 Hiroyuki Yamamoto
|
|
| 4 | 4 |
* |
| 5 | 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 | 6 |
* it under the terms of the GNU General Public License as published by |
| ... | ... | |
| 78 | 78 |
|
| 79 | 79 |
typedef enum |
| 80 | 80 |
{
|
| 81 |
COL_NAME = 0,
|
|
| 82 |
COL_ADDRESS = 1,
|
|
| 83 |
COL_REMARKS = 2
|
|
| 84 |
} AddressBookColumnPos;
|
|
| 81 |
COL_FOLDER_NAME,
|
|
| 82 |
COL_OBJ,
|
|
| 83 |
COL_PIXBUF,
|
|
| 84 |
COL_PIXBUF_OPEN,
|
|
| 85 | 85 |
|
| 86 |
#define N_COLS 3 |
|
| 86 |
N_TREE_COLS |
|
| 87 |
} AddressBookTreeColumnPos; |
|
| 88 |
|
|
| 89 |
typedef enum |
|
| 90 |
{
|
|
| 91 |
COL_NAME, |
|
| 92 |
COL_ADDRESS, |
|
| 93 |
COL_REMARKS, |
|
| 94 |
|
|
| 95 |
N_LIST_COLS |
|
| 96 |
} AddressBookListColumnPos; |
|
| 97 |
|
|
| 87 | 98 |
#define COL_NAME_WIDTH 164 |
| 88 | 99 |
#define COL_ADDRESS_WIDTH 156 |
| 89 | 100 |
|
| ... | ... | |
| 91 | 102 |
|
| 92 | 103 |
#define ADDRESSBOOK_MSGBUF_SIZE 2048 |
| 93 | 104 |
|
| 105 |
static GdkPixbuf *folderpix; |
|
| 106 |
static GdkPixbuf *folderopenpix; |
|
| 107 |
static GdkPixbuf *grouppix; |
|
| 108 |
static GdkPixbuf *interfacepix; |
|
| 109 |
static GdkPixbuf *bookpix; |
|
| 110 |
static GdkPixbuf *addresspix; |
|
| 111 |
static GdkPixbuf *vcardpix; |
|
| 112 |
static GdkPixbuf *jpilotpix; |
|
| 113 |
static GdkPixbuf *categorypix; |
|
| 114 |
static GdkPixbuf *ldappix; |
|
| 115 |
|
|
| 94 | 116 |
static GdkPixmap *folderxpm; |
| 95 | 117 |
static GdkBitmap *folderxpmmask; |
| 96 | 118 |
static GdkPixmap *folderopenxpm; |
| ... | ... | |
| 113 | 135 |
static GdkBitmap *ldapxpmmask; |
| 114 | 136 |
|
| 115 | 137 |
/* Message buffer */ |
| 116 |
static gchar addressbook_msgbuf[ ADDRESSBOOK_MSGBUF_SIZE ];
|
|
| 138 |
static gchar addressbook_msgbuf[ADDRESSBOOK_MSGBUF_SIZE];
|
|
| 117 | 139 |
|
| 118 | 140 |
/* Address list selection */ |
| 119 | 141 |
static GList *_addressListSelection_ = NULL; |
| ... | ... | |
| 132 | 154 |
static GHashTable *_addressBookTypeHash_ = NULL; |
| 133 | 155 |
static GList *_addressBookTypeList_ = NULL; |
| 134 | 156 |
|
| 157 |
static void addressbook_refresh (void); |
|
| 158 |
static void addressbook_reopen (void); |
|
| 159 |
|
|
| 135 | 160 |
static void addressbook_create (void); |
| 136 | 161 |
static gint addressbook_close (void); |
| 137 | 162 |
|
| ... | ... | |
| 149 | 174 |
static void addressbook_close_clicked (GtkButton *button, |
| 150 | 175 |
gpointer data); |
| 151 | 176 |
|
| 152 |
static void addressbook_tree_selected (GtkCTree *ctree, |
|
| 153 |
GtkCTreeNode *node, |
|
| 154 |
gint column, |
|
| 155 |
gpointer data); |
|
| 177 |
static void addressbook_tree_selection_changed (GtkTreeSelection *selection, |
|
| 178 |
gpointer data); |
|
| 156 | 179 |
static void addressbook_list_selected (GtkCList *clist, |
| 157 | 180 |
gint row, |
| 158 | 181 |
gint column, |
| ... | ... | |
| 205 | 228 |
guint action, |
| 206 | 229 |
GtkWidget *widget); |
| 207 | 230 |
|
| 208 |
static void addressbook_change_node_name (GtkCTreeNode *node,
|
|
| 231 |
static void addressbook_change_node_name (GtkTreeIter *iter,
|
|
| 209 | 232 |
const gchar *name); |
| 210 | 233 |
|
| 211 | 234 |
static void addressbook_new_address_cb (gpointer data, |
| ... | ... | |
| 256 | 279 |
static void addressbook_load_tree (void); |
| 257 | 280 |
void addressbook_read_file (void); |
| 258 | 281 |
|
| 259 |
static GtkCTreeNode *addressbook_add_object (GtkCTreeNode *node, |
|
| 282 |
static gboolean addressbook_add_object (GtkTreeIter *iter, |
|
| 283 |
GtkTreeIter *new_iter, |
|
| 260 | 284 |
AddressObject *obj); |
| 261 | 285 |
static AddressDataSource *addressbook_find_datasource |
| 262 |
(GtkCTreeNode *node );
|
|
| 286 |
(GtkTreeIter *iter);
|
|
| 263 | 287 |
|
| 264 | 288 |
static AddressBookFile *addressbook_get_book_file(); |
| 265 | 289 |
|
| 266 |
static GtkCTreeNode *addressbook_node_add_folder |
|
| 267 |
(GtkCTreeNode *node, |
|
| 268 |
AddressDataSource *ds, |
|
| 269 |
ItemFolder *itemFolder, |
|
| 270 |
AddressObjectType otype); |
|
| 271 |
static GtkCTreeNode *addressbook_node_add_group (GtkCTreeNode *node, |
|
| 272 |
AddressDataSource *ds, |
|
| 273 |
ItemGroup *itemGroup); |
|
| 290 |
static gboolean addressbook_node_add_folder (GtkTreeIter *iter, |
|
| 291 |
AddressDataSource *ds, |
|
| 292 |
ItemFolder *itemFolder, |
|
| 293 |
AddressObjectType otype, |
|
| 294 |
GtkTreeIter *new_iter); |
|
| 295 |
static gboolean addressbook_node_add_group (GtkTreeIter *iter, |
|
| 296 |
AddressDataSource *ds, |
|
| 297 |
ItemGroup *itemGroup, |
|
| 298 |
GtkTreeIter *new_iter); |
|
| 274 | 299 |
/* static GtkCTreeNode *addressbook_node_add_category */ |
| 275 | 300 |
/* (GtkCTreeNode *node, */ |
| 276 | 301 |
/* AddressDataSource *ds, */ |
| 277 | 302 |
/* ItemFolder *itemFolder); */ |
| 278 |
static void addressbook_tree_remove_children (GtkCTree *ctree,
|
|
| 279 |
GtkCTreeNode *parent);
|
|
| 280 |
static void addressbook_move_nodes_up (GtkCTree *ctree,
|
|
| 281 |
GtkCTreeNode *node);
|
|
| 282 |
static GtkCTreeNode *addressbook_find_group_node (GtkCTreeNode *parent,
|
|
| 283 |
ItemGroup *group); |
|
| 303 |
static void addressbook_tree_remove_children (GtkTreeModel *model,
|
|
| 304 |
GtkTreeIter *parent);
|
|
| 305 |
static void addressbook_move_nodes_up (GtkTreeIter *iter);
|
|
| 306 |
static gboolean addressbook_find_group_node (GtkTreeIter *parent,
|
|
| 307 |
GtkTreeIter *iter,
|
|
| 308 |
ItemGroup *group);
|
|
| 284 | 309 |
|
| 285 | 310 |
/* static void addressbook_delete_object (AddressObject *obj); */ |
| 286 | 311 |
|
| ... | ... | |
| 291 | 316 |
GtkAllocation *allocation, |
| 292 | 317 |
gpointer data); |
| 293 | 318 |
|
| 319 |
static gint addressbook_list_compare (GtkTreeModel *model, |
|
| 320 |
GtkTreeIter *a, |
|
| 321 |
GtkTreeIter *b, |
|
| 322 |
gpointer data); |
|
| 294 | 323 |
static gint addressbook_list_compare_func (GtkCList *clist, |
| 295 | 324 |
gconstpointer ptr1, |
| 296 | 325 |
gconstpointer ptr2); |
| ... | ... | |
| 307 | 336 |
#endif |
| 308 | 337 |
|
| 309 | 338 |
/* LUT's and IF stuff */ |
| 310 |
static void addressbook_free_adapter (GtkCTreeNode *node);
|
|
| 311 |
static void addressbook_free_child_adapters (GtkCTreeNode *node);
|
|
| 339 |
static void addressbook_free_adapter (GtkTreeIter *iter);
|
|
| 340 |
static void addressbook_free_child_adapters (GtkTreeIter *iter);
|
|
| 312 | 341 |
AddressTypeControlItem *addrbookctl_lookup (gint ot); |
| 313 | 342 |
AddressTypeControlItem *addrbookctl_lookup_iface(AddressIfType ifType); |
| 314 | 343 |
|
| ... | ... | |
| 407 | 436 |
void addressbook_open(Compose *target) |
| 408 | 437 |
{
|
| 409 | 438 |
if (!addrbook.window) {
|
| 439 |
GtkTreeView *treeview; |
|
| 440 |
GtkTreeModel *model; |
|
| 441 |
GtkTreeIter iter; |
|
| 442 |
GtkTreePath *path; |
|
| 443 |
|
|
| 410 | 444 |
addressbook_read_file(); |
| 411 | 445 |
addressbook_create(); |
| 412 | 446 |
addressbook_load_tree(); |
| 413 |
gtk_ctree_select(GTK_CTREE(addrbook.ctree), |
|
| 414 |
GTK_CTREE_NODE(GTK_CLIST(addrbook.ctree)->row_list)); |
|
| 447 |
treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 448 |
model = gtk_tree_view_get_model(treeview); |
|
| 449 |
if (gtk_tree_model_get_iter_first(model, &iter)) {
|
|
| 450 |
path = gtk_tree_model_get_path(model, &iter); |
|
| 451 |
gtk_tree_view_set_cursor(treeview, path, NULL, FALSE); |
|
| 452 |
gtk_tree_path_free(path); |
|
| 453 |
} |
|
| 415 | 454 |
addressbook_menuitem_set_sensitive(); |
| 416 | 455 |
gtk_widget_show_all(addrbook.window); |
| 417 | 456 |
} |
| ... | ... | |
| 431 | 470 |
return addrbook.target_compose; |
| 432 | 471 |
} |
| 433 | 472 |
|
| 434 |
void addressbook_refresh(void) |
|
| 473 |
static void addressbook_refresh(void)
|
|
| 435 | 474 |
{
|
| 436 | 475 |
if (addrbook.window) {
|
| 437 |
if (addrbook.opened) {
|
|
| 438 |
addrbook.treeSelected = NULL; |
|
| 439 |
gtk_ctree_select(GTK_CTREE(addrbook.ctree), |
|
| 440 |
addrbook.opened); |
|
| 476 |
if (addrbook.tree_opened) {
|
|
| 477 |
addressbook_reopen(); |
|
| 441 | 478 |
} |
| 442 | 479 |
} |
| 443 | 480 |
addressbook_export_to_file(); |
| 444 | 481 |
} |
| 445 | 482 |
|
| 483 |
static void addressbook_reopen(void) |
|
| 484 |
{
|
|
| 485 |
GtkTreePath *path; |
|
| 486 |
|
|
| 487 |
if (addrbook.tree_selected) {
|
|
| 488 |
gtk_tree_row_reference_free(addrbook.tree_selected); |
|
| 489 |
addrbook.tree_selected = NULL; |
|
| 490 |
} |
|
| 491 |
if (addrbook.tree_opened) {
|
|
| 492 |
path = gtk_tree_row_reference_get_path(addrbook.tree_opened); |
|
| 493 |
gtk_tree_view_set_cursor(GTK_TREE_VIEW(addrbook.treeview), path, NULL, FALSE); |
|
| 494 |
gtk_tree_path_free(path); |
|
| 495 |
} |
|
| 496 |
} |
|
| 497 |
|
|
| 446 | 498 |
/* |
| 447 | 499 |
* Create the address book widgets. The address book contains two CTree widgets: the |
| 448 | 500 |
* address index tree on the left and the address list on the right. |
| ... | ... | |
| 465 | 517 |
GtkWidget *menubar; |
| 466 | 518 |
GtkWidget *spc_hbox; |
| 467 | 519 |
GtkWidget *vbox2; |
| 468 |
GtkWidget *ctree_swin; |
|
| 469 |
GtkWidget *ctree; |
|
| 520 |
GtkWidget *tree_swin; |
|
| 521 |
GtkWidget *treeview; |
|
| 522 |
GtkTreeStore *tree_store; |
|
| 523 |
GtkTreeSelection *selection; |
|
| 524 |
GtkTreeViewColumn *column; |
|
| 525 |
GtkCellRenderer *renderer; |
|
| 470 | 526 |
GtkWidget *clist_vbox; |
| 471 | 527 |
GtkWidget *clist_swin; |
| 472 | 528 |
GtkWidget *clist; |
| ... | ... | |
| 493 | 549 |
gint n_entries; |
| 494 | 550 |
GList *nodeIf; |
| 495 | 551 |
|
| 496 |
gchar *titles[N_COLS]; |
|
| 497 |
gchar *text; |
|
| 552 |
gchar *titles[N_LIST_COLS]; |
|
| 498 | 553 |
gint i; |
| 499 | 554 |
|
| 500 | 555 |
debug_print("Creating addressbook window...\n");
|
| ... | ... | |
| 540 | 595 |
vbox2 = gtk_vbox_new(FALSE, 4); |
| 541 | 596 |
gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0); |
| 542 | 597 |
|
| 543 |
ctree_swin = gtk_scrolled_window_new(NULL, NULL);
|
|
| 544 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ctree_swin),
|
|
| 598 |
tree_swin = gtk_scrolled_window_new(NULL, NULL); |
|
| 599 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tree_swin), |
|
| 545 | 600 |
GTK_POLICY_AUTOMATIC, |
| 546 | 601 |
GTK_POLICY_ALWAYS); |
| 547 |
gtk_widget_set_size_request(ctree_swin, COL_FOLDER_WIDTH + 40, -1);
|
|
| 602 |
gtk_widget_set_size_request(tree_swin, COL_FOLDER_WIDTH + 40, -1); |
|
| 548 | 603 |
|
| 549 | 604 |
/* Address index */ |
| 550 |
ctree = gtk_ctree_new(1, 0); |
|
| 551 |
gtk_container_add(GTK_CONTAINER(ctree_swin), ctree); |
|
| 552 |
gtk_clist_set_selection_mode(GTK_CLIST(ctree), GTK_SELECTION_BROWSE); |
|
| 553 |
gtk_clist_set_column_width(GTK_CLIST(ctree), 0, COL_FOLDER_WIDTH); |
|
| 554 |
gtk_ctree_set_line_style(GTK_CTREE(ctree), GTK_CTREE_LINES_DOTTED); |
|
| 555 |
gtk_ctree_set_expander_style(GTK_CTREE(ctree), |
|
| 556 |
GTK_CTREE_EXPANDER_SQUARE); |
|
| 557 |
gtk_ctree_set_indent(GTK_CTREE(ctree), CTREE_INDENT); |
|
| 558 |
gtk_clist_set_compare_func(GTK_CLIST(ctree), |
|
| 559 |
addressbook_list_compare_func); |
|
| 560 |
gtkut_clist_set_redraw(GTK_CLIST(ctree)); |
|
| 605 |
tree_store = gtk_tree_store_new(N_TREE_COLS, G_TYPE_STRING, |
|
| 606 |
G_TYPE_POINTER, GDK_TYPE_PIXBUF, |
|
| 607 |
GDK_TYPE_PIXBUF); |
|
| 608 |
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(tree_store), |
|
| 609 |
COL_FOLDER_NAME, |
|
| 610 |
addressbook_list_compare, |
|
| 611 |
NULL, NULL); |
|
| 561 | 612 |
|
| 562 |
g_signal_connect(G_OBJECT(ctree), "tree_select_row", |
|
| 563 |
G_CALLBACK(addressbook_tree_selected), NULL); |
|
| 564 |
g_signal_connect(G_OBJECT(ctree), "button_press_event", |
|
| 613 |
treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tree_store)); |
|
| 614 |
g_object_unref(G_OBJECT(tree_store)); |
|
| 615 |
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); |
|
| 616 |
gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); |
|
| 617 |
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); |
|
| 618 |
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), FALSE); |
|
| 619 |
gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), |
|
| 620 |
COL_FOLDER_NAME); |
|
| 621 |
gtk_tree_view_set_reorderable(GTK_TREE_VIEW(treeview), FALSE); |
|
| 622 |
|
|
| 623 |
gtk_container_add(GTK_CONTAINER(tree_swin), treeview); |
|
| 624 |
|
|
| 625 |
column = gtk_tree_view_column_new(); |
|
| 626 |
gtk_tree_view_column_set_spacing(column, 2); |
|
| 627 |
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
|
| 628 |
gtk_tree_view_column_set_fixed_width(column, COL_FOLDER_WIDTH); |
|
| 629 |
gtk_tree_view_column_set_resizable(column, TRUE); |
|
| 630 |
|
|
| 631 |
renderer = gtk_cell_renderer_pixbuf_new(); |
|
| 632 |
g_object_set(renderer, "ypad", 0, NULL); |
|
| 633 |
gtk_tree_view_column_pack_start(column, renderer, FALSE); |
|
| 634 |
gtk_tree_view_column_set_title(column, _("Folder"));
|
|
| 635 |
gtk_tree_view_column_set_attributes |
|
| 636 |
(column, renderer, "pixbuf", COL_PIXBUF, |
|
| 637 |
"pixbuf-expander-open", COL_PIXBUF_OPEN, |
|
| 638 |
"pixbuf-expander-closed", COL_PIXBUF, NULL); |
|
| 639 |
|
|
| 640 |
renderer = gtk_cell_renderer_text_new(); |
|
| 641 |
#if GTK_CHECK_VERSION(2, 6, 0) |
|
| 642 |
g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, "ypad", 0, |
|
| 643 |
NULL); |
|
| 644 |
#else |
|
| 645 |
g_object_set(renderer, "ypad", 0, NULL); |
|
| 646 |
#endif |
|
| 647 |
gtk_tree_view_column_pack_start(column, renderer, TRUE); |
|
| 648 |
gtk_tree_view_column_set_attributes(column, renderer, |
|
| 649 |
"text", COL_FOLDER_NAME, NULL); |
|
| 650 |
|
|
| 651 |
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); |
|
| 652 |
gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); |
|
| 653 |
|
|
| 654 |
g_signal_connect(G_OBJECT(selection), "changed", |
|
| 655 |
G_CALLBACK(addressbook_tree_selection_changed), NULL); |
|
| 656 |
g_signal_connect(G_OBJECT(treeview), "button_press_event", |
|
| 565 | 657 |
G_CALLBACK(addressbook_tree_button_pressed), |
| 566 | 658 |
NULL); |
| 567 |
g_signal_connect(G_OBJECT(ctree), "button_release_event",
|
|
| 659 |
g_signal_connect(G_OBJECT(treeview), "button_release_event",
|
|
| 568 | 660 |
G_CALLBACK(addressbook_tree_button_released), |
| 569 | 661 |
NULL); |
| 570 | 662 |
|
| ... | ... | |
| 577 | 669 |
gtk_box_pack_start(GTK_BOX(clist_vbox), clist_swin, TRUE, TRUE, 0); |
| 578 | 670 |
|
| 579 | 671 |
/* Address list */ |
| 580 |
clist = gtk_ctree_new_with_titles(N_COLS, 0, titles); |
|
| 672 |
clist = gtk_ctree_new_with_titles(N_LIST_COLS, 0, titles);
|
|
| 581 | 673 |
gtk_container_add(GTK_CONTAINER(clist_swin), clist); |
| 582 | 674 |
gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_EXTENDED); |
| 583 | 675 |
gtk_ctree_set_line_style(GTK_CTREE(clist), GTK_CTREE_LINES_NONE); |
| ... | ... | |
| 591 | 683 |
addressbook_list_compare_func); |
| 592 | 684 |
gtkut_clist_set_redraw(GTK_CLIST(clist)); |
| 593 | 685 |
|
| 594 |
for (i = 0; i < N_COLS; i++) |
|
| 686 |
for (i = 0; i < N_LIST_COLS; i++)
|
|
| 595 | 687 |
GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(clist)->column[i].button, |
| 596 | 688 |
GTK_CAN_FOCUS); |
| 597 | 689 |
|
| ... | ... | |
| 632 | 724 |
|
| 633 | 725 |
paned = gtk_hpaned_new(); |
| 634 | 726 |
gtk_box_pack_start(GTK_BOX(vbox2), paned, TRUE, TRUE, 0); |
| 635 |
gtk_paned_add1(GTK_PANED(paned), ctree_swin);
|
|
| 727 |
gtk_paned_add1(GTK_PANED(paned), tree_swin); |
|
| 636 | 728 |
gtk_paned_add2(GTK_PANED(paned), clist_vbox); |
| 637 | 729 |
|
| 638 | 730 |
/* Status bar */ |
| ... | ... | |
| 707 | 799 |
G_CALLBACK(addressbook_close_clicked), NULL); |
| 708 | 800 |
|
| 709 | 801 |
/* Build icons for interface */ |
| 710 |
stock_pixmap_gdk( window, STOCK_PIXMAP_INTERFACE,
|
|
| 711 |
&interfacexpm, &interfacexpmmask );
|
|
| 712 |
|
|
| 802 |
stock_pixbuf_gdk(window, STOCK_PIXMAP_INTERFACE, &interfacepix);
|
|
| 803 |
stock_pixmap_gdk(window, STOCK_PIXMAP_INTERFACE,
|
|
| 804 |
&interfacexpm, &interfacexpmmask); |
|
| 713 | 805 |
/* Build control tables */ |
| 714 | 806 |
addrbookctl_build_map(window); |
| 715 | 807 |
addrbookctl_build_iflist(); |
| ... | ... | |
| 720 | 812 |
while( nodeIf ) {
|
| 721 | 813 |
AdapterInterface *adapter = nodeIf->data; |
| 722 | 814 |
AddressInterface *iface = adapter->interface; |
| 815 |
|
|
| 723 | 816 |
nodeIf = g_list_next(nodeIf); |
| 724 | 817 |
|
| 725 | 818 |
if(iface->useInterface) {
|
| 726 | 819 |
AddressTypeControlItem *atci = adapter->atci; |
| 727 |
text = atci->displayName; |
|
| 728 |
adapter->treeNode = |
|
| 729 |
gtk_ctree_insert_node( GTK_CTREE(ctree), |
|
| 730 |
NULL, NULL, &text, FOLDER_SPACING, |
|
| 731 |
interfacexpm, interfacexpmmask, |
|
| 732 |
interfacexpm, interfacexpmmask, |
|
| 733 |
FALSE, FALSE ); |
|
| 734 |
gtk_ctree_node_set_row_data( GTK_CTREE(ctree), adapter->treeNode, adapter ); |
|
| 820 |
gchar *text = atci->displayName; |
|
| 821 |
GtkTreeIter iter; |
|
| 822 |
GtkTreePath *path; |
|
| 823 |
|
|
| 824 |
g_print("addressbook_create: text: %s\n", text);
|
|
| 825 |
gtk_tree_store_append(tree_store, &iter, NULL); |
|
| 826 |
gtk_tree_store_set(tree_store, &iter, |
|
| 827 |
COL_FOLDER_NAME, text, |
|
| 828 |
COL_OBJ, adapter, |
|
| 829 |
COL_PIXBUF, interfacepix, |
|
| 830 |
COL_PIXBUF_OPEN, interfacepix, -1); |
|
| 831 |
path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree_store), &iter); |
|
| 832 |
adapter->tree_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(tree_store), path); |
|
| 833 |
gtk_tree_path_free(path); |
|
| 735 | 834 |
} |
| 736 | 835 |
} |
| 737 | 836 |
|
| ... | ... | |
| 751 | 850 |
"<AddressBookList>", &list_factory, |
| 752 | 851 |
NULL); |
| 753 | 852 |
|
| 754 |
addrbook.window = window; |
|
| 755 |
addrbook.menubar = menubar; |
|
| 756 |
addrbook.ctree = ctree;
|
|
| 757 |
addrbook.clist = clist; |
|
| 758 |
addrbook.entry = entry; |
|
| 759 |
addrbook.statusbar = statusbar; |
|
| 760 |
addrbook.status_cid = gtk_statusbar_get_context_id( GTK_STATUSBAR(statusbar), "Address Book Window" );
|
|
| 853 |
addrbook.window = window;
|
|
| 854 |
addrbook.menubar = menubar;
|
|
| 855 |
addrbook.treeview = treeview;
|
|
| 856 |
addrbook.clist = clist;
|
|
| 857 |
addrbook.entry = entry;
|
|
| 858 |
addrbook.statusbar = statusbar;
|
|
| 859 |
addrbook.status_cid = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "Address Book Window");
|
|
| 761 | 860 |
|
| 762 | 861 |
addrbook.to_btn = to_btn; |
| 763 | 862 |
addrbook.cc_btn = cc_btn; |
| ... | ... | |
| 788 | 887 |
return TRUE; |
| 789 | 888 |
} |
| 790 | 889 |
|
| 791 |
static void addressbook_status_show( gchar *msg ) {
|
|
| 792 |
if( addrbook.statusbar != NULL ) {
|
|
| 793 |
gtk_statusbar_pop( GTK_STATUSBAR(addrbook.statusbar), addrbook.status_cid ); |
|
| 794 |
if( msg ) {
|
|
| 795 |
gtk_statusbar_push( GTK_STATUSBAR(addrbook.statusbar), addrbook.status_cid, msg ); |
|
| 890 |
static void addressbook_status_show(const gchar *msg) |
|
| 891 |
{
|
|
| 892 |
if (addrbook.statusbar != NULL) {
|
|
| 893 |
gtk_statusbar_pop(GTK_STATUSBAR(addrbook.statusbar), addrbook.status_cid); |
|
| 894 |
if (msg) {
|
|
| 895 |
gtk_statusbar_push(GTK_STATUSBAR(addrbook.statusbar), addrbook.status_cid, msg); |
|
| 796 | 896 |
} |
| 797 | 897 |
} |
| 798 | 898 |
} |
| 799 | 899 |
|
| 800 |
static void addressbook_ds_show_message( AddressDataSource *ds ) {
|
|
| 900 |
static void addressbook_ds_show_message(AddressDataSource *ds) |
|
| 901 |
{
|
|
| 801 | 902 |
gint retVal; |
| 802 | 903 |
gchar *name; |
| 904 |
|
|
| 803 | 905 |
*addressbook_msgbuf = '\0'; |
| 804 |
if( ds ) {
|
|
| 805 |
name = addrindex_ds_get_name( ds ); |
|
| 806 |
retVal = addrindex_ds_get_status_code( ds ); |
|
| 807 |
if( retVal == MGU_SUCCESS ) {
|
|
| 808 |
if( ds ) {
|
|
| 809 |
sprintf( addressbook_msgbuf, "%s", name ); |
|
| 906 |
|
|
| 907 |
if (ds) {
|
|
| 908 |
name = addrindex_ds_get_name(ds); |
|
| 909 |
retVal = addrindex_ds_get_status_code(ds); |
|
| 910 |
if (retVal == MGU_SUCCESS) {
|
|
| 911 |
if (ds) {
|
|
| 912 |
g_snprintf(addressbook_msgbuf, sizeof(addressbook_msgbuf), "%s", name); |
|
| 810 | 913 |
} |
| 811 |
} |
|
| 812 |
else {
|
|
| 813 |
if( ds == NULL ) {
|
|
| 814 |
sprintf( addressbook_msgbuf, "%s", mgu_error2string( retVal ) ); |
|
| 914 |
} else {
|
|
| 915 |
if (ds == NULL) {
|
|
| 916 |
g_snprintf(addressbook_msgbuf, sizeof(addressbook_msgbuf), "%s", mgu_error2string(retVal)); |
|
| 917 |
} else {
|
|
| 918 |
g_snprintf(addressbook_msgbuf, sizeof(addressbook_msgbuf), "%s: %s", name, mgu_error2string(retVal)); |
|
| 815 | 919 |
} |
| 816 |
else {
|
|
| 817 |
sprintf( addressbook_msgbuf, "%s: %s", name, mgu_error2string( retVal ) ); |
|
| 818 |
} |
|
| 819 | 920 |
} |
| 820 | 921 |
} |
| 821 |
addressbook_status_show( addressbook_msgbuf ); |
|
| 922 |
|
|
| 923 |
addressbook_status_show(addressbook_msgbuf); |
|
| 822 | 924 |
} |
| 823 | 925 |
|
| 824 | 926 |
/* |
| ... | ... | |
| 826 | 928 |
*/ |
| 827 | 929 |
static void addressbook_del_clicked(GtkButton *button, gpointer data) |
| 828 | 930 |
{
|
| 931 |
GtkTreeView *treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 932 |
GtkTreeSelection *selection; |
|
| 933 |
GtkTreeModel *model; |
|
| 934 |
GtkTreeIter iter; |
|
| 935 |
GtkTreePath *path; |
|
| 829 | 936 |
GtkCTree *clist = GTK_CTREE(addrbook.clist); |
| 830 |
GtkCTree *ctree = GTK_CTREE(addrbook.ctree);
|
|
| 831 |
AddressObject *pobj, *obj;
|
|
| 937 |
AddressObject *pobj = NULL;
|
|
| 938 |
AddressObject *obj = NULL;
|
|
| 832 | 939 |
AdapterDSource *ads = NULL; |
| 833 | 940 |
GtkCTreeNode *nodeList; |
| 834 | 941 |
gboolean procFlag; |
| ... | ... | |
| 836 | 943 |
AddressBookFile *abf = NULL; |
| 837 | 944 |
AddressDataSource *ds = NULL; |
| 838 | 945 |
|
| 839 |
pobj = gtk_ctree_node_get_row_data(ctree, addrbook.opened ); |
|
| 946 |
if (!addrbook.tree_opened) |
|
| 947 |
return; |
|
| 948 |
|
|
| 949 |
model = gtk_tree_view_get_model(treeview); |
|
| 950 |
selection = gtk_tree_view_get_selection(treeview); |
|
| 951 |
|
|
| 952 |
path = gtk_tree_row_reference_get_path(addrbook.tree_opened); |
|
| 953 |
gtk_tree_model_get_iter(model, &iter, path); |
|
| 954 |
gtk_tree_path_free(path); |
|
| 955 |
gtk_tree_model_get(model, &iter, COL_OBJ, &pobj, -1); |
|
| 840 | 956 |
g_return_if_fail(pobj != NULL); |
| 841 | 957 |
|
| 842 | 958 |
nodeList = addrbook.listSelected; |
| 843 |
obj = gtk_ctree_node_get_row_data( clist, nodeList ); |
|
| 844 |
if( obj == NULL) return; |
|
| 845 |
ds = addressbook_find_datasource( addrbook.treeSelected ); |
|
| 846 |
if( ds == NULL ) return; |
|
| 959 |
obj = gtk_ctree_node_get_row_data(clist, nodeList); |
|
| 960 |
if (obj == NULL) |
|
| 961 |
return; |
|
| 962 |
if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) |
|
| 963 |
return; |
|
| 964 |
ds = addressbook_find_datasource(&iter); |
|
| 965 |
if (ds == NULL) |
|
| 966 |
return; |
|
| 847 | 967 |
|
| 848 | 968 |
procFlag = FALSE; |
| 849 |
if( pobj->type == ADDR_DATASOURCE ) {
|
|
| 969 |
if (pobj->type == ADDR_DATASOURCE) {
|
|
| 850 | 970 |
ads = ADAPTER_DSOURCE(pobj); |
| 851 |
if( ads->subType == ADDR_BOOK ) procFlag = TRUE; |
|
| 971 |
if(ads->subType == ADDR_BOOK) |
|
| 972 |
procFlag = TRUE; |
|
| 852 | 973 |
} |
| 853 |
else if( pobj->type == ADDR_ITEM_FOLDER ) {
|
|
| 974 |
else if (pobj->type == ADDR_ITEM_FOLDER) {
|
|
| 854 | 975 |
procFlag = TRUE; |
| 855 |
} |
|
| 856 |
else if( pobj->type == ADDR_ITEM_GROUP ) {
|
|
| 976 |
} else if (pobj->type == ADDR_ITEM_GROUP) {
|
|
| 857 | 977 |
procFlag = TRUE; |
| 858 | 978 |
} |
| 859 |
if( ! procFlag ) return; |
|
| 979 |
if (!procFlag) |
|
| 980 |
return; |
|
| 860 | 981 |
abf = ds->rawDataSource; |
| 861 |
if( abf == NULL ) return; |
|
| 982 |
if (abf == NULL) |
|
| 983 |
return; |
|
| 862 | 984 |
|
| 863 | 985 |
/* Confirm deletion */ |
| 864 |
aval = alertpanel( _("Delete address(es)"),
|
|
| 865 |
_("Really delete the address(es)?"),
|
|
| 866 |
GTK_STOCK_YES, GTK_STOCK_NO, NULL ); |
|
| 867 |
if( aval != G_ALERTDEFAULT ) return; |
|
| 986 |
aval = alertpanel(_("Delete address(es)"),
|
|
| 987 |
_("Really delete the address(es)?"),
|
|
| 988 |
GTK_STOCK_YES, GTK_STOCK_NO, NULL); |
|
| 989 |
if (aval != G_ALERTDEFAULT) |
|
| 990 |
return; |
|
| 868 | 991 |
|
| 869 | 992 |
/* Process deletions */ |
| 870 |
if( pobj->type == ADDR_DATASOURCE || pobj->type == ADDR_ITEM_FOLDER ) {
|
|
| 993 |
if (pobj->type == ADDR_DATASOURCE || pobj->type == ADDR_ITEM_FOLDER) {
|
|
| 871 | 994 |
/* Items inside folders */ |
| 872 | 995 |
GList *node; |
| 996 |
|
|
| 873 | 997 |
node = _addressListSelection_; |
| 874 |
while( node ) {
|
|
| 998 |
while (node) {
|
|
| 875 | 999 |
AddrItemObject *aio = node->data; |
| 876 |
node = g_list_next( node );
|
|
| 877 |
if( aio->type == ADDR_ITEM_GROUP ) {
|
|
| 878 |
ItemGroup *item = ( ItemGroup * ) aio;
|
|
| 879 |
GtkCTreeNode *nd = NULL;
|
|
| 1000 |
node = g_list_next(node);
|
|
| 1001 |
if (aio->type == ADDR_ITEM_GROUP) {
|
|
| 1002 |
ItemGroup *item = (ItemGroup *)aio;
|
|
| 1003 |
GtkTreeIter giter;
|
|
| 880 | 1004 |
|
| 881 |
nd = addressbook_find_group_node( addrbook.opened, item );
|
|
| 882 |
item = addrbook_remove_group( abf, item );
|
|
| 883 |
if( item ) {
|
|
| 884 |
addritem_free_item_group( item );
|
|
| 1005 |
addressbook_find_group_node(&iter, &giter, item);
|
|
| 1006 |
item = addrbook_remove_group(abf, item);
|
|
| 1007 |
if (item) {
|
|
| 1008 |
addritem_free_item_group(item);
|
|
| 885 | 1009 |
item = NULL; |
| 886 | 1010 |
} |
| 887 | 1011 |
/* Remove group from parent node */ |
| 888 |
gtk_ctree_remove_node( ctree, nd );
|
|
| 889 |
} |
|
| 890 |
else if( aio->type == ADDR_ITEM_PERSON ) {
|
|
| 891 |
ItemPerson *item = ( ItemPerson * ) aio; |
|
| 892 |
if( _clipObjectList_ ) {
|
|
| 893 |
_clipObjectList_ = g_list_remove( _clipObjectList_, item );
|
|
| 1012 |
gtk_tree_store_remove(GTK_TREE_STORE(model), &giter);
|
|
| 1013 |
} else if (aio->type == ADDR_ITEM_PERSON) {
|
|
| 1014 |
ItemPerson *item = (ItemPerson *)aio;
|
|
| 1015 |
|
|
| 1016 |
if (_clipObjectList_) {
|
|
| 1017 |
_clipObjectList_ = g_list_remove(_clipObjectList_, item);
|
|
| 894 | 1018 |
} |
| 895 |
item = addrbook_remove_person( abf, item );
|
|
| 896 |
if( item ) {
|
|
| 897 |
addritem_free_item_person( item );
|
|
| 1019 |
item = addrbook_remove_person(abf, item);
|
|
| 1020 |
if (item) {
|
|
| 1021 |
addritem_free_item_person(item);
|
|
| 898 | 1022 |
item = NULL; |
| 899 | 1023 |
} |
| 900 |
} |
|
| 901 |
else if( aio->type == ADDR_ITEM_EMAIL ) {
|
|
| 902 |
ItemEMail *item = ( ItemEMail * ) aio;
|
|
| 903 |
ItemPerson *person = ( ItemPerson * ) ADDRITEM_PARENT(item); |
|
| 904 |
item = addrbook_person_remove_email( abf, person, item );
|
|
| 905 |
if( item ) {
|
|
| 906 |
addritem_free_item_email( item );
|
|
| 1024 |
} else if (aio->type == ADDR_ITEM_EMAIL) {
|
|
| 1025 |
ItemEMail *item = (ItemEMail *)aio;
|
|
| 1026 |
ItemPerson *person = (ItemPerson *)ADDRITEM_PARENT(item);
|
|
| 1027 |
|
|
| 1028 |
item = addrbook_person_remove_email(abf, person, item);
|
|
| 1029 |
if (item) {
|
|
| 1030 |
addritem_free_item_email(item);
|
|
| 907 | 1031 |
item = NULL; |
| 908 | 1032 |
} |
| 909 | 1033 |
} |
| 910 | 1034 |
} |
| 911 | 1035 |
addressbook_list_select_clear(); |
| 912 |
addrbook.treeSelected = NULL; |
|
| 913 |
gtk_ctree_select( ctree, addrbook.opened ); |
|
| 1036 |
addressbook_reopen(); |
|
| 914 | 1037 |
return; |
| 915 |
} |
|
| 916 |
else if( pobj->type == ADDR_ITEM_GROUP ) {
|
|
| 1038 |
} else if (pobj->type == ADDR_ITEM_GROUP) {
|
|
| 917 | 1039 |
/* Items inside groups */ |
| 918 | 1040 |
GList *node; |
| 919 | 1041 |
ItemGroup *group = ADAPTER_GROUP(pobj)->itemGroup; |
| 1042 |
|
|
| 920 | 1043 |
node = _addressListSelection_; |
| 921 |
while( node ) {
|
|
| 1044 |
while (node) {
|
|
| 922 | 1045 |
AddrItemObject *aio = node->data; |
| 923 |
node = g_list_next( node );
|
|
| 924 |
if( aio->type == ADDR_ITEM_EMAIL ) {
|
|
| 925 |
ItemEMail *item = ( ItemEMail * ) aio;
|
|
| 926 |
item = addrbook_group_remove_email( abf, group, item );
|
|
| 1046 |
node = g_list_next(node);
|
|
| 1047 |
if (aio->type == ADDR_ITEM_EMAIL) {
|
|
| 1048 |
ItemEMail *item = (ItemEMail *)aio;
|
|
| 1049 |
item = addrbook_group_remove_email(abf, group, item);
|
|
| 927 | 1050 |
} |
| 928 | 1051 |
} |
| 929 | 1052 |
addressbook_list_select_clear(); |
| 930 |
addrbook.treeSelected = NULL; |
|
| 931 |
gtk_ctree_select( ctree, addrbook.opened ); |
|
| 1053 |
addressbook_reopen(); |
|
| 932 | 1054 |
return; |
| 933 | 1055 |
} |
| 934 | 1056 |
|
| 935 |
gtk_ctree_node_set_row_data( clist, nodeList, NULL ); |
|
| 936 |
gtk_ctree_remove_node( clist, nodeList ); |
|
| 937 |
addressbook_list_select_remove( obj ); |
|
| 938 |
|
|
| 1057 |
gtk_ctree_node_set_row_data(clist, nodeList, NULL); |
|
| 1058 |
gtk_ctree_remove_node(clist, nodeList); |
|
| 1059 |
addressbook_list_select_remove(obj); |
|
| 939 | 1060 |
} |
| 940 | 1061 |
|
| 941 | 1062 |
static void addressbook_reg_clicked(GtkButton *button, gpointer data) |
| 942 | 1063 |
{
|
| 943 |
addressbook_new_address_cb( NULL, 0, NULL );
|
|
| 1064 |
addressbook_new_address_cb(NULL, 0, NULL);
|
|
| 944 | 1065 |
} |
| 945 | 1066 |
|
| 946 |
gchar *addressbook_format_address( AddressObject * obj ) {
|
|
| 1067 |
gchar *addressbook_format_address(AddressObject *obj) |
|
| 1068 |
{
|
|
| 947 | 1069 |
gchar *buf = NULL; |
| 948 | 1070 |
gchar *name = NULL; |
| 949 | 1071 |
gchar *address = NULL; |
| ... | ... | |
| 1029 | 1151 |
} |
| 1030 | 1152 |
} |
| 1031 | 1153 |
|
| 1032 |
static void addressbook_menuitem_set_sensitive(void) {
|
|
| 1154 |
static void addressbook_menuitem_set_sensitive(void) |
|
| 1155 |
{
|
|
| 1156 |
GtkTreeView *treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 1157 |
GtkTreeSelection *selection; |
|
| 1158 |
GtkTreeModel *model; |
|
| 1159 |
GtkTreeIter iter; |
|
| 1033 | 1160 |
gboolean canAdd = FALSE; |
| 1034 | 1161 |
gboolean canEditTree = TRUE; |
| 1035 | 1162 |
gboolean canEditAddress = FALSE; |
| ... | ... | |
| 1054 | 1181 |
menu_set_insensitive_all(GTK_MENU_SHELL(addrbook.tree_popup)); |
| 1055 | 1182 |
menu_set_insensitive_all( GTK_MENU_SHELL(addrbook.list_popup) ); |
| 1056 | 1183 |
|
| 1057 |
pobj = gtk_ctree_node_get_row_data( GTK_CTREE(addrbook.ctree), addrbook.treeSelected ); |
|
| 1058 |
if( pobj == NULL ) return; |
|
| 1184 |
selection = gtk_tree_view_get_selection(treeview); |
|
| 1185 |
if (!gtk_tree_selection_get_selected(selection, &model, &iter)) |
|
| 1186 |
return; |
|
| 1059 | 1187 |
|
| 1060 |
if( addrbook.listSelected ) |
|
| 1061 |
obj = gtk_ctree_node_get_row_data( GTK_CTREE(addrbook.clist), addrbook.listSelected ); |
|
| 1188 |
gtk_tree_model_get(model, &iter, COL_OBJ, &pobj, -1); |
|
| 1189 |
if (pobj == NULL) |
|
| 1190 |
return; |
|
| 1062 | 1191 |
|
| 1063 |
if( pobj->type == ADDR_INTERFACE ) {
|
|
| 1192 |
if (addrbook.listSelected) |
|
| 1193 |
obj = gtk_ctree_node_get_row_data(GTK_CTREE(addrbook.clist), addrbook.listSelected); |
|
| 1194 |
|
|
| 1195 |
if (pobj->type == ADDR_INTERFACE) {
|
|
| 1064 | 1196 |
AdapterInterface *adapter = ADAPTER_INTERFACE(pobj); |
| 1197 |
|
|
| 1065 | 1198 |
iface = adapter->interface; |
| 1066 |
if( iface ) {
|
|
| 1067 |
if( iface->haveLibrary ) {
|
|
| 1068 |
/* Enable appropriate File / New command */ |
|
| 1069 |
atci = adapter->atci; |
|
| 1070 |
menu_set_sensitive( addrbook.menu_factory, atci->menuCommand, TRUE ); |
|
| 1071 |
} |
|
| 1199 |
if (iface && iface->haveLibrary) {
|
|
| 1200 |
/* Enable appropriate File / New command */ |
|
| 1201 |
atci = adapter->atci; |
|
| 1202 |
menu_set_sensitive(addrbook.menu_factory, atci->menuCommand, TRUE); |
|
| 1072 | 1203 |
} |
| 1073 | 1204 |
canEditTree = FALSE; |
| 1074 |
} |
|
| 1075 |
else if( pobj->type == ADDR_DATASOURCE ) {
|
|
| 1205 |
} else if (pobj->type == ADDR_DATASOURCE) {
|
|
| 1076 | 1206 |
AdapterDSource *ads = ADAPTER_DSOURCE(pobj); |
| 1207 |
|
|
| 1077 | 1208 |
ds = ads->dataSource; |
| 1078 | 1209 |
iface = ds->interface; |
| 1079 |
if( ! iface->readOnly ) {
|
|
| 1210 |
if (!iface->readOnly) {
|
|
| 1080 | 1211 |
canAdd = canEditAddress = TRUE; |
| 1081 | 1212 |
} |
| 1082 |
if( ! iface->haveLibrary ) {
|
|
| 1213 |
if (!iface->haveLibrary) {
|
|
| 1083 | 1214 |
canAdd = canEditAddress = FALSE; |
| 1084 | 1215 |
} |
| 1085 | 1216 |
#ifdef USE_LDAP |
| 1086 |
if( ads->subType == ADDR_LDAP &&
|
|
| 1087 |
iface->haveLibrary && ds->rawDataSource ) {
|
|
| 1217 |
if (ads->subType == ADDR_LDAP &&
|
|
| 1218 |
iface->haveLibrary && ds->rawDataSource) {
|
|
| 1088 | 1219 |
canLookup = TRUE; |
| 1089 | 1220 |
} |
| 1090 | 1221 |
#endif |
| 1091 |
} |
|
| 1092 |
else if( pobj->type == ADDR_ITEM_FOLDER ) {
|
|
| 1093 |
ds = addressbook_find_datasource( addrbook.treeSelected ); |
|
| 1094 |
if( ds ) {
|
|
| 1222 |
} else if (pobj->type == ADDR_ITEM_FOLDER) {
|
|
| 1223 |
ds = addressbook_find_datasource(&iter); |
|
| 1224 |
if (ds) {
|
|
| 1095 | 1225 |
iface = ds->interface; |
| 1096 |
if( ! iface->readOnly ) {
|
|
| 1226 |
if (!iface->readOnly) {
|
|
| 1097 | 1227 |
canAdd = canEditAddress = TRUE; |
| 1098 | 1228 |
} |
| 1099 | 1229 |
} |
| 1100 |
} |
|
| 1101 |
else if( pobj->type == ADDR_ITEM_GROUP ) {
|
|
| 1102 |
ds = addressbook_find_datasource( addrbook.treeSelected ); |
|
| 1103 |
if( ds ) {
|
|
| 1230 |
} else if (pobj->type == ADDR_ITEM_GROUP) {
|
|
| 1231 |
ds = addressbook_find_datasource(&iter); |
|
| 1232 |
if (ds) {
|
|
| 1104 | 1233 |
iface = ds->interface; |
| 1105 |
if( ! iface->readOnly ) {
|
|
| 1234 |
if (!iface->readOnly) {
|
|
| 1106 | 1235 |
canEditAddress = TRUE; |
| 1107 | 1236 |
} |
| 1108 | 1237 |
} |
| 1109 | 1238 |
} |
| 1110 | 1239 |
|
| 1111 |
if( obj == NULL ) canEditAddress = FALSE; |
|
| 1240 |
if (obj == NULL) |
|
| 1241 |
canEditAddress = FALSE; |
|
| 1112 | 1242 |
canDelete = canEditAddress; |
| 1113 |
if( GTK_CLIST(addrbook.clist)->selection && |
|
| 1114 |
GTK_CLIST(addrbook.clist)->selection->next ) canEditAddress = FALSE; |
|
| 1115 |
if( _addressListSelection_ ) {
|
|
| 1243 |
if (GTK_CLIST(addrbook.clist)->selection && |
|
| 1244 |
GTK_CLIST(addrbook.clist)->selection->next) |
|
| 1245 |
canEditAddress = FALSE; |
|
| 1246 |
if (_addressListSelection_) {
|
|
| 1116 | 1247 |
GList *cur; |
| 1117 | 1248 |
AddressObject *item; |
| 1118 |
for( cur = _addressListSelection_; cur != NULL; cur = cur->next ) {
|
|
| 1249 |
|
|
| 1250 |
for (cur = _addressListSelection_; cur != NULL; cur = cur->next) {
|
|
| 1119 | 1251 |
item = cur->data; |
| 1120 |
if( item->type == ADDR_ITEM_PERSON ) {
|
|
| 1252 |
if (item->type == ADDR_ITEM_PERSON) {
|
|
| 1121 | 1253 |
canCopy = TRUE; |
| 1122 | 1254 |
break; |
| 1123 | 1255 |
} |
| 1124 | 1256 |
} |
| 1125 | 1257 |
} |
| 1126 |
if( _clipObjectList_ && canAdd ) canPaste = TRUE; |
|
| 1258 |
if (_clipObjectList_ && canAdd) |
|
| 1259 |
canPaste = TRUE; |
|
| 1127 | 1260 |
|
| 1128 | 1261 |
/* Enable add */ |
| 1129 | 1262 |
menu_set_sensitive( addrbook.menu_factory, "/Address/New Address", canAdd ); |
| ... | ... | |
| 1161 | 1294 |
gtk_widget_set_sensitive( addrbook.lup_btn, canLookup ); |
| 1162 | 1295 |
} |
| 1163 | 1296 |
|
| 1164 |
static void addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
|
|
| 1165 |
gint column, gpointer data)
|
|
| 1297 |
static void addressbook_tree_selection_changed(GtkTreeSelection *selection,
|
|
| 1298 |
gpointer data)
|
|
| 1166 | 1299 |
{
|
| 1300 |
GtkTreeModel *model; |
|
| 1301 |
GtkTreeIter iter; |
|
| 1302 |
GtkTreePath *path; |
|
| 1167 | 1303 |
AddressObject *obj = NULL; |
| 1168 | 1304 |
AdapterDSource *ads = NULL; |
| 1169 | 1305 |
AddressDataSource *ds = NULL; |
| 1170 | 1306 |
ItemFolder *rootFolder = NULL; |
| 1171 | 1307 |
|
| 1172 |
if( addrbook.treeSelected == node ) return; |
|
| 1173 |
addrbook.treeSelected = node; |
|
| 1308 |
debug_print("addressbook_tree_selection_changed\n");
|
|
| 1309 |
|
|
| 1310 |
if (!gtk_tree_selection_get_selected(selection, &model, &iter)) {
|
|
| 1311 |
debug_print("addressbook_tree_selection_changed: no selection\n");
|
|
| 1312 |
gtk_tree_row_reference_free(addrbook.tree_selected); |
|
| 1313 |
addrbook.tree_selected = NULL; |
|
| 1314 |
gtk_tree_row_reference_free(addrbook.tree_opened); |
|
| 1315 |
addrbook.tree_opened = NULL; |
|
| 1316 |
addressbook_status_show("");
|
|
| 1317 |
if (addrbook.entry) |
|
| 1318 |
gtk_entry_set_text(GTK_ENTRY(addrbook.entry), ""); |
|
| 1319 |
if (addrbook.clist) |
|
| 1320 |
gtk_clist_clear(GTK_CLIST(addrbook.clist)); |
|
| 1321 |
return; |
|
| 1322 |
} |
|
| 1323 |
|
|
| 1324 |
path = gtk_tree_model_get_path(model, &iter); |
|
| 1325 |
gtk_tree_row_reference_free(addrbook.tree_selected); |
|
| 1326 |
addrbook.tree_selected = gtk_tree_row_reference_new(model, path); |
|
| 1174 | 1327 |
addrbook.listSelected = NULL; |
| 1175 |
addressbook_status_show( "" ); |
|
| 1176 |
if( addrbook.entry != NULL ) gtk_entry_set_text(GTK_ENTRY(addrbook.entry), ""); |
|
| 1328 |
addressbook_status_show("");
|
|
| 1329 |
if (addrbook.entry) |
|
| 1330 |
gtk_entry_set_text(GTK_ENTRY(addrbook.entry), ""); |
|
| 1331 |
if (addrbook.clist) |
|
| 1332 |
gtk_clist_clear(GTK_CLIST(addrbook.clist)); |
|
| 1333 |
gtk_tree_model_get(model, &iter, COL_OBJ, &obj, -1); |
|
| 1334 |
if (obj == NULL) {
|
|
| 1335 |
gtk_tree_path_free(path); |
|
| 1336 |
return; |
|
| 1337 |
} |
|
| 1177 | 1338 |
|
| 1178 |
if( addrbook.clist ) gtk_clist_clear( GTK_CLIST(addrbook.clist) ); |
|
| 1179 |
if( node ) obj = gtk_ctree_node_get_row_data( ctree, node ); |
|
| 1180 |
if( obj == NULL ) return; |
|
| 1339 |
gtk_tree_row_reference_free(addrbook.tree_opened); |
|
| 1340 |
addrbook.tree_opened = gtk_tree_row_reference_new(model, path); |
|
| 1181 | 1341 |
|
| 1182 |
addrbook.opened = node; |
|
| 1183 |
|
|
| 1184 |
if( obj->type == ADDR_DATASOURCE ) {
|
|
| 1342 |
if (obj->type == ADDR_DATASOURCE) {
|
|
| 1185 | 1343 |
/* Read from file */ |
| 1186 | 1344 |
static gboolean tVal = TRUE; |
| 1187 | 1345 |
|
| 1188 | 1346 |
ads = ADAPTER_DSOURCE(obj); |
| 1189 |
if( ads == NULL ) return;
|
|
| 1347 |
if (ads == NULL) return;
|
|
| 1190 | 1348 |
ds = ads->dataSource; |
| 1191 |
if( ds == NULL ) return;
|
|
| 1349 |
if (ds == NULL) return;
|
|
| 1192 | 1350 |
|
| 1193 |
if( addrindex_ds_get_modify_flag( ds ) ) {
|
|
| 1194 |
addrindex_ds_read_data( ds );
|
|
| 1351 |
if (addrindex_ds_get_modify_flag(ds)) {
|
|
| 1352 |
addrindex_ds_read_data(ds);
|
|
| 1195 | 1353 |
} |
| 1196 | 1354 |
|
| 1197 |
if( ! addrindex_ds_get_read_flag( ds ) ) {
|
|
| 1198 |
addrindex_ds_read_data( ds );
|
|
| 1355 |
if (!addrindex_ds_get_read_flag(ds)) {
|
|
| 1356 |
addrindex_ds_read_data(ds);
|
|
| 1199 | 1357 |
} |
| 1200 |
addressbook_ds_show_message( ds );
|
|
| 1358 |
addressbook_ds_show_message(ds);
|
|
| 1201 | 1359 |
|
| 1202 |
if( ! addrindex_ds_get_access_flag( ds ) ) {
|
|
| 1360 |
if (!addrindex_ds_get_access_flag(ds)) {
|
|
| 1203 | 1361 |
/* Remove existing folders and groups */ |
| 1204 |
gtk_clist_freeze( GTK_CLIST(ctree) ); |
|
| 1205 |
addressbook_tree_remove_children( ctree, node ); |
|
| 1206 |
gtk_clist_thaw( GTK_CLIST(ctree) ); |
|
| 1362 |
addressbook_tree_remove_children(model, &iter); |
|
| 1207 | 1363 |
|
| 1208 | 1364 |
/* Load folders into the tree */ |
| 1209 |
rootFolder = addrindex_ds_get_root_folder( ds ); |
|
| 1210 |
if( ds->type == ADDR_IF_JPILOT ) {
|
|
| 1211 |
addressbook_node_add_folder( node, ds, rootFolder, ADDR_CATEGORY ); |
|
| 1365 |
rootFolder = addrindex_ds_get_root_folder(ds); |
|
| 1366 |
if (ds->type == ADDR_IF_JPILOT) {
|
|
| 1367 |
addressbook_node_add_folder(&iter, ds, rootFolder, ADDR_CATEGORY, NULL); |
|
| 1368 |
} else {
|
|
| 1369 |
addressbook_node_add_folder(&iter, ds, rootFolder, ADDR_ITEM_FOLDER, NULL); |
|
| 1212 | 1370 |
} |
| 1213 |
else {
|
|
| 1214 |
addressbook_node_add_folder( node, ds, rootFolder, ADDR_ITEM_FOLDER ); |
|
| 1215 |
} |
|
| 1216 |
addrindex_ds_set_access_flag( ds, &tVal ); |
|
| 1217 |
gtk_ctree_expand( ctree, node ); |
|
| 1371 |
addrindex_ds_set_access_flag(ds, &tVal); |
|
| 1372 |
gtk_tree_view_expand_row(GTK_TREE_VIEW(addrbook.treeview), path, TRUE); |
|
| 1218 | 1373 |
} |
| 1219 | 1374 |
} |
| 1220 | 1375 |
|
| 1376 |
gtk_tree_path_free(path); |
|
| 1377 |
|
|
| 1221 | 1378 |
/* Update address list */ |
| 1222 |
addressbook_set_clist( obj ); |
|
| 1223 |
|
|
| 1379 |
addressbook_set_clist(obj); |
|
| 1224 | 1380 |
addressbook_menuitem_set_sensitive(); |
| 1225 |
|
|
| 1226 | 1381 |
addressbook_list_select_clear(); |
| 1227 |
|
|
| 1228 | 1382 |
} |
| 1229 | 1383 |
|
| 1230 | 1384 |
static void addressbook_list_selected(GtkCList *clist, gint row, gint column, |
| ... | ... | |
| 1279 | 1433 |
} |
| 1280 | 1434 |
#endif |
| 1281 | 1435 |
|
| 1282 |
static void addressbook_list_select_clear() {
|
|
| 1283 |
if( _addressListSelection_ ) {
|
|
| 1284 |
g_list_free( _addressListSelection_ ); |
|
| 1436 |
static void addressbook_list_select_clear(void) |
|
| 1437 |
{
|
|
| 1438 |
if (_addressListSelection_) {
|
|
| 1439 |
g_list_free(_addressListSelection_); |
|
| 1285 | 1440 |
} |
| 1286 | 1441 |
_addressListSelection_ = NULL; |
| 1287 | 1442 |
} |
| 1288 | 1443 |
|
| 1289 |
static void addressbook_list_select_add( AddressObject *obj ) {
|
|
| 1290 |
if( obj ) {
|
|
| 1291 |
if( obj->type == ADDR_ITEM_PERSON || |
|
| 1292 |
obj->type == ADDR_ITEM_EMAIL || |
|
| 1293 |
obj->type == ADDR_ITEM_GROUP ) {
|
|
| 1294 |
if( ! g_list_find( _addressListSelection_, obj ) ) {
|
|
| 1295 |
_addressListSelection_ = g_list_append( _addressListSelection_, obj ); |
|
| 1444 |
static void addressbook_list_select_add(AddressObject *obj) |
|
| 1445 |
{
|
|
| 1446 |
if (obj) {
|
|
| 1447 |
if (obj->type == ADDR_ITEM_PERSON || |
|
| 1448 |
obj->type == ADDR_ITEM_EMAIL || |
|
| 1449 |
obj->type == ADDR_ITEM_GROUP) {
|
|
| 1450 |
if (!g_list_find(_addressListSelection_, obj)) {
|
|
| 1451 |
_addressListSelection_ = g_list_append(_addressListSelection_, obj); |
|
| 1296 | 1452 |
} |
| 1297 | 1453 |
} |
| 1298 | 1454 |
} |
| 1299 | 1455 |
/* addressbook_list_select_show(); */ |
| 1300 | 1456 |
} |
| 1301 | 1457 |
|
| 1302 |
static void addressbook_list_select_remove( AddressObject *obj ) {
|
|
| 1303 |
if( obj == NULL ) return; |
|
| 1304 |
if( _addressListSelection_ ) {
|
|
| 1305 |
_addressListSelection_ = g_list_remove( _addressListSelection_, obj ); |
|
| 1458 |
static void addressbook_list_select_remove(AddressObject *obj) |
|
| 1459 |
{
|
|
| 1460 |
if (obj == NULL) |
|
| 1461 |
return; |
|
| 1462 |
if (_addressListSelection_) {
|
|
| 1463 |
_addressListSelection_ = g_list_remove(_addressListSelection_, obj); |
|
| 1306 | 1464 |
} |
| 1307 | 1465 |
/* addressbook_list_select_show(); */ |
| 1308 | 1466 |
} |
| 1309 | 1467 |
|
| 1310 |
static void addressbook_list_row_selected( GtkCTree *clist, GtkCTreeNode *node, gint column, gpointer data ) {
|
|
| 1468 |
static void addressbook_list_row_selected(GtkCTree *clist, GtkCTreeNode *node, gint column, gpointer data) |
|
| 1469 |
{
|
|
| 1311 | 1470 |
GtkEntry *entry = GTK_ENTRY(addrbook.entry); |
| 1312 | 1471 |
AddressObject *obj = NULL; |
| 1313 | 1472 |
|
| 1314 |
gtk_entry_set_text( entry, "" );
|
|
| 1473 |
gtk_entry_set_text(entry, "");
|
|
| 1315 | 1474 |
addrbook.listSelected = node; |
| 1316 |
obj = gtk_ctree_node_get_row_data( clist, node );
|
|
| 1317 |
if( obj != NULL ) {
|
|
| 1318 |
addressbook_list_select_add( obj );
|
|
| 1475 |
obj = gtk_ctree_node_get_row_data(clist, node);
|
|
| 1476 |
if (obj != NULL) {
|
|
| 1477 |
addressbook_list_select_add(obj);
|
|
| 1319 | 1478 |
} |
| 1320 | 1479 |
|
| 1321 | 1480 |
addressbook_menuitem_set_sensitive(); |
| 1322 | 1481 |
} |
| 1323 | 1482 |
|
| 1324 |
static void addressbook_list_row_unselected( GtkCTree *ctree, GtkCTreeNode *node, gint column, gpointer data ) {
|
|
| 1483 |
static void addressbook_list_row_unselected(GtkCTree *clist, GtkCTreeNode *node, gint column, gpointer data) |
|
| 1484 |
{
|
|
| 1325 | 1485 |
AddressObject *obj; |
| 1326 | 1486 |
|
| 1327 |
obj = gtk_ctree_node_get_row_data( ctree, node );
|
|
| 1328 |
if( obj != NULL ) {
|
|
| 1329 |
addressbook_list_select_remove( obj );
|
|
| 1487 |
obj = gtk_ctree_node_get_row_data(clist, node);
|
|
| 1488 |
if (obj != NULL) {
|
|
| 1489 |
addressbook_list_select_remove(obj);
|
|
| 1330 | 1490 |
} |
| 1331 | 1491 |
|
| 1332 | 1492 |
addressbook_menuitem_set_sensitive(); |
| ... | ... | |
| 1336 | 1496 |
GdkEventButton *event, |
| 1337 | 1497 |
gpointer data) |
| 1338 | 1498 |
{
|
| 1339 |
if( ! event ) return FALSE; |
|
| 1499 |
if (!event) |
|
| 1500 |
return FALSE; |
|
| 1340 | 1501 |
|
| 1341 |
if( event->button == 3 ) {
|
|
| 1342 |
gtk_menu_popup( GTK_MENU(addrbook.list_popup), NULL, NULL, NULL, NULL, |
|
| 1343 |
event->button, event->time ); |
|
| 1502 |
if (event->button == 3) {
|
|
| 1503 |
gtk_menu_popup(GTK_MENU(addrbook.list_popup), NULL, NULL, NULL, NULL, event->button, event->time); |
|
| 1344 | 1504 |
} |
| 1345 | 1505 |
return FALSE; |
| 1346 | 1506 |
} |
| ... | ... | |
| 1352 | 1512 |
return FALSE; |
| 1353 | 1513 |
} |
| 1354 | 1514 |
|
| 1355 |
static gboolean addressbook_tree_button_pressed(GtkWidget *ctree,
|
|
| 1515 |
static gboolean addressbook_tree_button_pressed(GtkWidget *widget,
|
|
| 1356 | 1516 |
GdkEventButton *event, |
| 1357 | 1517 |
gpointer data) |
| 1358 | 1518 |
{
|
| 1359 |
GtkCList *clist = GTK_CLIST(ctree); |
|
| 1360 |
gint row, column; |
|
| 1519 |
GtkTreeView *treeview = GTK_TREE_VIEW(widget); |
|
| 1520 |
GtkTreeSelection *selection; |
|
| 1521 |
GtkTreePath *path; |
|
| 1361 | 1522 |
|
| 1362 |
if( ! event ) return FALSE; |
|
| 1363 |
/* */ |
|
| 1364 |
if( gtk_clist_get_selection_info( clist, event->x, event->y, &row, &column ) ) {
|
|
| 1365 |
gtk_clist_select_row( clist, row, column ); |
|
| 1366 |
gtkut_clist_set_focus_row(clist, row); |
|
| 1367 |
} |
|
| 1368 |
/* */ |
|
| 1523 |
if (!event) |
|
| 1524 |
return FALSE; |
|
| 1369 | 1525 |
|
| 1526 |
if (!gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, |
|
| 1527 |
&path, NULL, NULL, NULL)) |
|
| 1528 |
return TRUE; |
|
| 1529 |
selection = gtk_tree_view_get_selection(treeview); |
|
| 1530 |
|
|
| 1370 | 1531 |
addressbook_menuitem_set_sensitive(); |
| 1371 | 1532 |
|
| 1372 |
if( event->button == 3 ) {
|
|
| 1373 |
gtk_menu_popup(GTK_MENU(addrbook.tree_popup), NULL, NULL, NULL, NULL, |
|
| 1533 |
if (event->button == 3) {
|
|
| 1534 |
gtk_tree_selection_select_path(selection, path); |
|
| 1535 |
gtk_menu_popup(GTK_MENU(addrbook.tree_popup), |
|
| 1536 |
NULL, NULL, NULL, NULL, |
|
| 1374 | 1537 |
event->button, event->time); |
| 1375 | 1538 |
} |
| 1376 | 1539 |
|
| 1540 |
gtk_tree_path_free(path); |
|
| 1377 | 1541 |
return FALSE; |
| 1378 | 1542 |
} |
| 1379 | 1543 |
|
| 1380 |
static gboolean addressbook_tree_button_released(GtkWidget *ctree,
|
|
| 1544 |
static gboolean addressbook_tree_button_released(GtkWidget *widget,
|
|
| 1381 | 1545 |
GdkEventButton *event, |
| 1382 | 1546 |
gpointer data) |
| 1383 | 1547 |
{
|
| 1384 |
#if 0 |
|
| 1385 |
gtk_ctree_select(GTK_CTREE(addrbook.ctree), addrbook.opened); |
|
| 1386 |
gtkut_ctree_set_focus_row(GTK_CTREE(addrbook.ctree), addrbook.opened); |
|
| 1387 |
#endif |
|
| 1388 | 1548 |
return FALSE; |
| 1389 | 1549 |
} |
| 1390 | 1550 |
|
| 1391 | 1551 |
static void addressbook_popup_close(GtkMenuShell *menu_shell, gpointer data) |
| 1392 | 1552 |
{
|
| 1393 |
if (!addrbook.opened) return; |
|
| 1553 |
GtkTreeView *treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 1554 |
GtkTreeSelection *selection; |
|
| 1555 |
GtkTreePath *path; |
|
| 1394 | 1556 |
|
| 1395 |
gtk_ctree_select(GTK_CTREE(addrbook.ctree), addrbook.opened); |
|
| 1396 |
gtkut_ctree_set_focus_row(GTK_CTREE(addrbook.ctree), |
|
| 1397 |
addrbook.opened); |
|
| 1557 |
g_print("addressbook_popup_close\n");
|
|
| 1558 |
|
|
| 1559 |
if (!addrbook.tree_opened) |
|
| 1560 |
return; |
|
| 1561 |
|
|
| 1562 |
selection = gtk_tree_view_get_selection(treeview); |
|
| 1563 |
path = gtk_tree_row_reference_get_path(addrbook.tree_opened); |
|
| 1564 |
if (path) {
|
|
| 1565 |
gtk_tree_selection_select_path(selection, path); |
|
| 1566 |
gtk_tree_path_free(path); |
|
| 1567 |
} |
|
| 1398 | 1568 |
} |
| 1399 | 1569 |
|
| 1400 | 1570 |
static void addressbook_new_folder_cb(gpointer data, guint action, |
| 1401 | 1571 |
GtkWidget *widget) |
| 1402 | 1572 |
{
|
| 1403 |
GtkCTree *ctree = GTK_CTREE(addrbook.ctree); |
|
| 1573 |
GtkTreeView *treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 1574 |
GtkTreeSelection *selection; |
|
| 1575 |
GtkTreeModel *model; |
|
| 1576 |
GtkTreeIter iter; |
|
| 1404 | 1577 |
AddressObject *obj = NULL; |
| 1405 | 1578 |
AddressDataSource *ds = NULL; |
| 1406 | 1579 |
AddressBookFile *abf = NULL; |
| 1407 | 1580 |
ItemFolder *parentFolder = NULL; |
| 1408 | 1581 |
ItemFolder *folder = NULL; |
| 1409 | 1582 |
|
| 1410 |
if( ! addrbook.treeSelected ) return; |
|
| 1411 |
obj = gtk_ctree_node_get_row_data( ctree, addrbook.treeSelected ); |
|
| 1412 |
if( obj == NULL ) return; |
|
| 1413 |
ds = addressbook_find_datasource( addrbook.treeSelected ); |
|
| 1414 |
if( ds == NULL ) return; |
|
| 1583 |
selection = gtk_tree_view_get_selection(treeview); |
|
| 1584 |
if (!gtk_tree_selection_get_selected(selection, &model, &iter)) |
|
| 1585 |
return; |
|
| 1415 | 1586 |
|
| 1416 |
if( obj->type == ADDR_DATASOURCE ) {
|
|
| 1417 |
if( ADAPTER_DSOURCE(obj)->subType != ADDR_BOOK ) return; |
|
| 1418 |
} |
|
| 1419 |
else if( obj->type == ADDR_ITEM_FOLDER ) {
|
|
| 1587 |
gtk_tree_model_get(model, &iter, COL_OBJ, &obj, -1); |
|
| 1588 |
if (obj == NULL) |
|
| 1589 |
return; |
|
| 1590 |
ds = addressbook_find_datasource(&iter); |
|
| 1591 |
if (ds == NULL) |
|
| 1592 |
return; |
|
| 1593 |
|
|
| 1594 |
if (obj->type == ADDR_DATASOURCE) {
|
|
| 1595 |
if (ADAPTER_DSOURCE(obj)->subType != ADDR_BOOK) return; |
|
| 1596 |
} else if (obj->type == ADDR_ITEM_FOLDER) {
|
|
| 1420 | 1597 |
parentFolder = ADAPTER_FOLDER(obj)->itemFolder; |
| 1421 |
} |
|
| 1422 |
else {
|
|
| 1598 |
} else {
|
|
| 1423 | 1599 |
return; |
| 1424 | 1600 |
} |
| 1425 | 1601 |
|
| 1426 | 1602 |
abf = ds->rawDataSource; |
| 1427 |
if( abf == NULL ) return; |
|
| 1428 |
folder = addressbook_edit_folder( abf, parentFolder, NULL ); |
|
| 1429 |
if( folder ) {
|
|
| 1430 |
GtkCTreeNode *nn; |
|
| 1431 |
nn = addressbook_node_add_folder( addrbook.treeSelected, ds, folder, ADDR_ITEM_FOLDER ); |
|
| 1432 |
gtk_ctree_expand( ctree, addrbook.treeSelected ); |
|
| 1433 |
if( addrbook.treeSelected == addrbook.opened ) addressbook_set_clist(obj); |
|
| 1603 |
if (abf == NULL) return; |
|
| 1604 |
folder = addressbook_edit_folder(abf, parentFolder, NULL); |
|
| 1605 |
if (folder) {
|
|
| 1606 |
GtkTreeIter new_iter; |
|
| 1607 |
GtkTreePath *path; |
|
| 1608 |
addressbook_node_add_folder(&iter, ds, folder, ADDR_ITEM_FOLDER, &new_iter); |
|
| 1609 |
path = gtk_tree_model_get_path(model, &iter); |
|
| 1610 |
gtk_tree_view_expand_row(treeview, path, TRUE); |
|
| 1611 |
gtk_tree_path_free(path); |
|
| 1612 |
if (gtkut_tree_row_reference_equal(addrbook.tree_selected, addrbook.tree_opened)) |
|
| 1613 |
addressbook_set_clist(obj); |
|
| 1434 | 1614 |
} |
| 1435 | 1615 |
|
| 1436 | 1616 |
} |
| ... | ... | |
| 1438 | 1618 |
static void addressbook_new_group_cb(gpointer data, guint action, |
| 1439 | 1619 |
GtkWidget *widget) |
| 1440 | 1620 |
{
|
| 1441 |
GtkCTree *ctree = GTK_CTREE(addrbook.ctree); |
|
| 1621 |
GtkTreeView *treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 1622 |
GtkTreeSelection *selection; |
|
| 1623 |
GtkTreeModel *model; |
|
| 1624 |
GtkTreeIter iter; |
|
| 1442 | 1625 |
AddressObject *obj = NULL; |
| 1443 | 1626 |
AddressDataSource *ds = NULL; |
| 1444 | 1627 |
AddressBookFile *abf = NULL; |
| 1445 | 1628 |
ItemFolder *parentFolder = NULL; |
| 1446 | 1629 |
ItemGroup *group = NULL; |
| 1447 | 1630 |
|
| 1448 |
if( ! addrbook.treeSelected ) return; |
|
| 1449 |
obj = gtk_ctree_node_get_row_data(ctree, addrbook.treeSelected); |
|
| 1450 |
if( obj == NULL ) return; |
|
| 1451 |
ds = addressbook_find_datasource( addrbook.treeSelected ); |
|
| 1452 |
if( ds == NULL ) return; |
|
| 1631 |
selection = gtk_tree_view_get_selection(treeview); |
|
| 1632 |
if (!gtk_tree_selection_get_selected(selection, &model, &iter)) |
|
| 1633 |
return; |
|
| 1453 | 1634 |
|
| 1454 |
if( obj->type == ADDR_DATASOURCE ) {
|
|
| 1455 |
if( ADAPTER_DSOURCE(obj)->subType != ADDR_BOOK ) return; |
|
| 1456 |
} |
|
| 1457 |
else if( obj->type == ADDR_ITEM_FOLDER ) {
|
|
| 1635 |
gtk_tree_model_get(model, &iter, COL_OBJ, &obj, -1); |
|
| 1636 |
if (obj == NULL) |
|
| 1637 |
return; |
|
| 1638 |
ds = addressbook_find_datasource(&iter); |
|
| 1639 |
if (ds == NULL) |
|
| 1640 |
return; |
|
| 1641 |
|
|
| 1642 |
if (obj->type == ADDR_DATASOURCE) {
|
|
| 1643 |
if (ADAPTER_DSOURCE(obj)->subType != ADDR_BOOK) return; |
|
| 1644 |
} else if (obj->type == ADDR_ITEM_FOLDER) {
|
|
| 1458 | 1645 |
parentFolder = ADAPTER_FOLDER(obj)->itemFolder; |
| 1459 |
} |
|
| 1460 |
else {
|
|
| 1646 |
} else {
|
|
| 1461 | 1647 |
return; |
| 1462 | 1648 |
} |
| 1463 | 1649 |
|
| 1464 | 1650 |
abf = ds->rawDataSource; |
| 1465 |
if( abf == NULL ) return; |
|
| 1466 |
group = addressbook_edit_group( abf, parentFolder, NULL ); |
|
| 1467 |
if( group ) {
|
|
| 1468 |
GtkCTreeNode *nn; |
|
| 1469 |
nn = addressbook_node_add_group( addrbook.treeSelected, ds, group ); |
|
| 1470 |
gtk_ctree_expand( ctree, addrbook.treeSelected ); |
|
| 1471 |
if( addrbook.treeSelected == addrbook.opened ) addressbook_set_clist(obj); |
|
| 1651 |
if (abf == NULL) return; |
|
| 1652 |
group = addressbook_edit_group(abf, parentFolder, NULL); |
|
| 1653 |
if (group) {
|
|
| 1654 |
GtkTreeIter new_iter; |
|
| 1655 |
GtkTreePath *path; |
|
| 1656 |
addressbook_node_add_group(&iter, ds, group, &new_iter); |
|
| 1657 |
path = gtk_tree_model_get_path(model, &iter); |
|
| 1658 |
gtk_tree_view_expand_row(treeview, path, TRUE); |
|
| 1659 |
gtk_tree_path_free(path); |
|
| 1660 |
if (gtkut_tree_row_reference_equal(addrbook.tree_selected, addrbook.tree_opened)) |
|
| 1661 |
addressbook_set_clist(obj); |
|
| 1472 | 1662 |
} |
| 1473 | 1663 |
|
| 1474 | 1664 |
} |
| 1475 | 1665 |
|
| 1476 |
static void addressbook_change_node_name(GtkCTreeNode *node, const gchar *name)
|
|
| 1666 |
static void addressbook_change_node_name(GtkTreeIter *iter, const gchar *name)
|
|
| 1477 | 1667 |
{
|
| 1478 |
GtkCTree *ctree = GTK_CTREE(addrbook.ctree); |
|
| 1479 |
gchar *text[1]; |
|
| 1480 |
guint8 spacing; |
|
| 1481 |
GdkPixmap *pix_cl, *pix_op; |
|
| 1482 |
GdkBitmap *mask_cl, *mask_op; |
|
| 1483 |
gboolean is_leaf, expanded; |
|
| 1668 |
GtkTreeView *treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 1669 |
GtkTreeStore *store; |
|
| 1484 | 1670 |
|
| 1485 |
gtk_ctree_get_node_info(ctree, node, text, &spacing, |
|
| 1486 |
&pix_cl, &mask_cl, &pix_op, &mask_op, |
|
| 1487 |
&is_leaf, &expanded); |
|
| 1488 |
gtk_ctree_set_node_info(ctree, node, name, spacing, |
|
| 1489 |
pix_cl, mask_cl, pix_op, mask_op, |
|
| 1490 |
is_leaf, expanded); |
|
| 1671 |
g_print("addressbook_change_node_name: name: %s\n", name);
|
|
| 1672 |
store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview)); |
|
| 1673 |
gtk_tree_store_set(store, iter, COL_FOLDER_NAME, name, -1); |
|
| 1491 | 1674 |
} |
| 1492 | 1675 |
|
| 1493 | 1676 |
/* |
| ... | ... | |
| 1496 | 1679 |
* node Node in tree. |
| 1497 | 1680 |
* Return: New name of data source. |
| 1498 | 1681 |
*/ |
| 1499 |
static gchar *addressbook_edit_datasource( AddressObject *obj, GtkCTreeNode *node ) {
|
|
| 1682 |
static gchar *addressbook_edit_datasource(AddressObject *obj, GtkTreeIter *iter) |
|
| 1683 |
{
|
|
| 1500 | 1684 |
gchar *newName = NULL; |
| 1501 | 1685 |
AddressDataSource *ds = NULL; |
| 1502 | 1686 |
AddressInterface *iface = NULL; |
| 1503 | 1687 |
AdapterDSource *ads = NULL; |
| 1504 | 1688 |
|
| 1505 |
ds = addressbook_find_datasource( node ); |
|
| 1506 |
if( ds == NULL ) return NULL; |
|
| 1689 |
ds = addressbook_find_datasource(iter); |
|
| 1690 |
if (ds == NULL) |
|
| 1691 |
return NULL; |
|
| 1507 | 1692 |
iface = ds->interface; |
| 1508 |
if( ! iface->haveLibrary ) return NULL; |
|
| 1693 |
if (!iface->haveLibrary) |
|
| 1694 |
return NULL; |
|
| 1509 | 1695 |
|
| 1510 | 1696 |
/* Read data from data source */ |
| 1511 |
if( ! addrindex_ds_get_read_flag( ds ) ) {
|
|
| 1512 |
addrindex_ds_read_data( ds );
|
|
| 1697 |
if (!addrindex_ds_get_read_flag(ds)) {
|
|
| 1698 |
addrindex_ds_read_data(ds);
|
|
| 1513 | 1699 |
} |
| 1514 | 1700 |
|
| 1515 | 1701 |
/* Handle edit */ |
| 1516 | 1702 |
ads = ADAPTER_DSOURCE(obj); |
| 1517 |
if( ads->subType == ADDR_BOOK ) {
|
|
| 1518 |
if( addressbook_edit_book( _addressIndex_, ads ) == NULL ) return NULL;
|
|
| 1519 |
}
|
|
| 1520 |
else if( ads->subType == ADDR_VCARD ) {
|
|
| 1521 |
if( addressbook_edit_vcard( _addressIndex_, ads ) == NULL ) return NULL;
|
|
| 1522 |
}
|
|
| 1703 |
if (ads->subType == ADDR_BOOK) {
|
|
| 1704 |
if (addressbook_edit_book(_addressIndex_, ads) == NULL)
|
|
| 1705 |
return NULL;
|
|
| 1706 |
} else if (ads->subType == ADDR_VCARD) {
|
|
| 1707 |
if (addressbook_edit_vcard(_addressIndex_, ads) == NULL)
|
|
| 1708 |
return NULL;
|
|
| 1523 | 1709 |
#ifdef USE_JPILOT |
| 1524 |
else if( ads->subType == ADDR_JPILOT ) {
|
|
| 1525 |
if( addressbook_edit_jpilot( _addressIndex_, ads ) == NULL ) return NULL;
|
|
| 1526 |
}
|
|
| 1710 |
} else if (ads->subType == ADDR_JPILOT) {
|
|
| 1711 |
if (addressbook_edit_jpilot(_addressIndex_, ads) == NULL)
|
|
| 1712 |
return NULL;
|
|
| 1527 | 1713 |
#endif |
| 1528 | 1714 |
#ifdef USE_LDAP |
| 1529 |
else if( ads->subType == ADDR_LDAP ) {
|
|
| 1530 |
if( addressbook_edit_ldap( _addressIndex_, ads ) == NULL ) return NULL;
|
|
| 1531 |
}
|
|
| 1715 |
} else if (ads->subType == ADDR_LDAP) {
|
|
| 1716 |
if (addressbook_edit_ldap(_addressIndex_, ads) == NULL)
|
|
| 1717 |
return NULL;
|
|
| 1532 | 1718 |
#endif |
| 1533 |
else {
|
|
| 1719 |
} else {
|
|
| 1534 | 1720 |
return NULL; |
| 1535 | 1721 |
} |
| 1536 | 1722 |
newName = obj->name; |
| ... | ... | |
| 1541 | 1727 |
* Edit an object that is in the address tree area. |
| 1542 | 1728 |
*/ |
| 1543 | 1729 |
static void addressbook_treenode_edit_cb(gpointer data, guint action, |
| 1544 |
GtkWidget *widget)
|
|
| 1730 |
GtkWidget *widget)
|
|
| 1545 | 1731 |
{
|
| 1546 |
GtkCTree *ctree = GTK_CTREE(addrbook.ctree); |
|
| 1547 |
AddressObject *obj; |
|
| 1732 |
GtkTreeView *treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 1733 |
GtkTreeSelection *selection; |
|
| 1734 |
GtkTreeModel *model; |
|
| 1735 |
GtkTreeIter iter, parent; |
|
| 1736 |
AddressObject *obj = NULL; |
|
| 1548 | 1737 |
AddressDataSource *ds = NULL; |
| 1549 | 1738 |
AddressBookFile *abf = NULL; |
| 1550 |
GtkCTreeNode *node = NULL, *parentNode = NULL; |
|
| 1551 | 1739 |
gchar *name = NULL; |
| 1552 | 1740 |
|
| 1553 |
if( ! addrbook.treeSelected ) return; |
|
| 1554 |
node = addrbook.treeSelected; |
|
| 1555 |
if( GTK_CTREE_ROW(node)->level == 1 ) return; |
|
| 1556 |
obj = gtk_ctree_node_get_row_data( ctree, node ); |
|
| 1557 |
if( obj == NULL ) return; |
|
| 1558 |
parentNode = GTK_CTREE_ROW(node)->parent; |
|
| 1741 |
g_print("addressbook_treenode_edit_cb\n");
|
|
| 1559 | 1742 |
|
| 1560 |
ds = addressbook_find_datasource( node ); |
|
| 1561 |
if( ds == NULL ) return; |
|
| 1743 |
selection = gtk_tree_view_get_selection(treeview); |
|
| 1744 |
if (!gtk_tree_selection_get_selected(selection, &model, &iter)) |
|
| 1745 |
return; |
|
| 1562 | 1746 |
|
| 1563 |
if( obj->type == ADDR_DATASOURCE ) {
|
|
| 1564 |
name = addressbook_edit_datasource( obj, node ); |
|
| 1565 |
if( name == NULL ) return; |
|
| 1566 |
} |
|
| 1567 |
else {
|
|
| 1747 |
if (gtk_tree_store_iter_depth(GTK_TREE_STORE(model), &iter) == 0) |
|
| 1748 |
return; |
|
| 1749 |
gtk_tree_model_get(model, &iter, COL_OBJ, &obj, -1); |
|
| 1750 |
if (obj == NULL) |
|
| 1751 |
return; |
|
| 1752 |
if (!gtk_tree_model_iter_parent(model, &parent, &iter)) |
|
| 1753 |
return; |
|
| 1754 |
|
|
| 1755 |
ds = addressbook_find_datasource(&iter); |
|
| 1756 |
if (ds == NULL) |
|
| 1757 |
return; |
|
| 1758 |
|
|
| 1759 |
if (obj->type == ADDR_DATASOURCE) {
|
|
| 1760 |
name = addressbook_edit_datasource(obj, &iter); |
|
| 1761 |
if (name == NULL) |
|
| 1762 |
return; |
|
| 1763 |
} else {
|
|
| 1568 | 1764 |
abf = ds->rawDataSource; |
| 1569 |
if( abf == NULL ) return; |
|
| 1570 |
if( obj->type == ADDR_ITEM_FOLDER ) {
|
|
| 1765 |
if (abf == NULL) |
|
| 1766 |
return; |
|
| 1767 |
if (obj->type == ADDR_ITEM_FOLDER) {
|
|
| 1571 | 1768 |
AdapterFolder *adapter = ADAPTER_FOLDER(obj); |
| 1572 | 1769 |
ItemFolder *item = adapter->itemFolder; |
| 1573 | 1770 |
ItemFolder *parentFolder = NULL; |
| 1574 |
parentFolder = ( ItemFolder * ) ADDRITEM_PARENT(item); |
|
| 1575 |
if( addressbook_edit_folder( abf, parentFolder, item ) == NULL ) return; |
|
| 1771 |
parentFolder = (ItemFolder *)ADDRITEM_PARENT(item); |
|
| 1772 |
if (addressbook_edit_folder(abf, parentFolder, item) == NULL) |
|
| 1773 |
return; |
|
| 1576 | 1774 |
name = ADDRITEM_NAME(item); |
| 1577 |
} |
|
| 1578 |
else if( obj->type == ADDR_ITEM_GROUP ) {
|
|
| 1775 |
} else if (obj->type == ADDR_ITEM_GROUP) {
|
|
| 1579 | 1776 |
AdapterGroup *adapter = ADAPTER_GROUP(obj); |
| 1580 | 1777 |
ItemGroup *item = adapter->itemGroup; |
| 1581 | 1778 |
ItemFolder *parentFolder = NULL; |
| 1582 |
parentFolder = ( ItemFolder * ) ADDRITEM_PARENT(item); |
|
| 1583 |
if( addressbook_edit_group( abf, parentFolder, item ) == NULL ) return; |
|
| 1779 |
parentFolder = (ItemFolder *)ADDRITEM_PARENT(item); |
|
| 1780 |
if (addressbook_edit_group(abf, parentFolder, item) == NULL) |
|
| 1781 |
return; |
|
| 1584 | 1782 |
name = ADDRITEM_NAME(item); |
| 1585 | 1783 |
} |
| 1586 | 1784 |
} |
| 1587 |
if( name && parentNode ) {
|
|
| 1785 |
|
|
| 1786 |
if (name) {
|
|
| 1787 |
GtkTreePath *path; |
|
| 1788 |
|
|
| 1789 |
g_print("addressbook_treenode_edit_cb: update tree\n");
|
|
| 1588 | 1790 |
/* Update node in tree view */ |
| 1589 |
addressbook_change_node_name( node, name ); |
|
| 1590 |
gtk_ctree_sort_node(ctree, parentNode); |
|
| 1591 |
gtk_ctree_expand( ctree, node ); |
|
| 1592 |
addrbook.treeSelected = NULL; |
|
| 1593 |
gtk_ctree_select( ctree, node ); |
|
| 1791 |
addressbook_change_node_name(&iter, name); |
|
| 1792 |
//gtk_ctree_sort_node(ctree, parentNode); |
|
| 1793 |
path = gtk_tree_model_get_path(model, &iter); |
|
| 1794 |
gtk_tree_view_expand_row(treeview, path, TRUE); |
|
| 1795 |
gtk_tree_view_set_cursor(treeview, path, NULL, FALSE); |
|
| 1796 |
gtk_tree_path_free(path); |
|
| 1594 | 1797 |
} |
| 1595 | 1798 |
} |
| 1596 | 1799 |
|
| ... | ... | |
| 1600 | 1803 |
static void addressbook_treenode_delete_cb(gpointer data, guint action, |
| 1601 | 1804 |
GtkWidget *widget) |
| 1602 | 1805 |
{
|
| 1603 |
GtkCTree *ctree = GTK_CTREE(addrbook.ctree); |
|
| 1604 |
GtkCTreeNode *node = NULL; |
|
| 1806 |
GtkTreeView *treeview = GTK_TREE_VIEW(addrbook.treeview); |
|
| 1807 |
GtkTreeSelection *selection; |
|
| 1808 |
GtkTreeModel *model; |
|
| 1809 |
GtkTreeIter iter, parent; |
|
| 1605 | 1810 |
AddressObject *obj; |
| 1606 | 1811 |
gchar *message; |
| 1607 | 1812 |
AlertValue aval; |
| ... | ... | |
| 1611 | 1816 |
AddressDataSource *ds = NULL; |
| 1612 | 1817 |
gboolean remFlag = FALSE; |
| 1613 | 1818 |
|
| 1614 |
if( ! addrbook.treeSelected ) return; |
|
| 1615 |
node = addrbook.treeSelected; |
|
| 1616 |
if( GTK_CTREE_ROW(node)->level == 1 ) return; |
|
| 1819 |
g_print("addressbook_treenode_delete_cb\n");
|
|
| 1617 | 1820 |
|
| 1618 |
obj = gtk_ctree_node_get_row_data( ctree, node ); |
|
| 1821 |
selection = gtk_tree_view_get_selection(treeview); |
|
| 1822 |
if (!gtk_tree_selection_get_selected(selection, &model, &iter)) |
|
| 1823 |
return; |
|
| 1824 |
|
|
| 1825 |
if (gtk_tree_store_iter_depth(GTK_TREE_STORE(model), &iter) == 0) |
|
| 1826 |
return; |
|
Also available in: Unified diff