finch/gntrequest.c

branch
release-2.x.y
changeset 39648
7be1ba1a81a8
parent 39646
5323594ddc26
child 39649
951399f32018
equal deleted inserted replaced
39647:50ac98a0ecb1 39648:7be1ba1a81a8
680 680
681 return window; 681 return window;
682 } 682 }
683 683
684 static void 684 static void
685 file_cancel_cb(gpointer fq, GntWidget *wid) 685 file_cancel_cb(GntWidget *wid, gpointer fq)
686 { 686 {
687 FinchFileRequest *data = fq; 687 FinchFileRequest *data = fq;
688 if (data->dialog == NULL) {
689 /* We've already handled this request, and are in the destroy handler. */
690 return;
691 }
692
688 if (data->cbs[1] != NULL) 693 if (data->cbs[1] != NULL)
689 ((PurpleRequestFileCb)data->cbs[1])(data->user_data, NULL); 694 ((PurpleRequestFileCb)data->cbs[1])(data->user_data, NULL);
690 695
691 purple_request_close(PURPLE_REQUEST_FILE, data->dialog); 696 purple_request_close(PURPLE_REQUEST_FILE, data->dialog);
692 } 697 data->dialog = NULL;
693 698 }
694 static void 699
695 file_ok_cb(gpointer fq, GntWidget *widget) 700 static void
701 file_ok_cb(GntWidget *widget, const char *path, const char *file, gpointer fq)
696 { 702 {
697 FinchFileRequest *data = fq; 703 FinchFileRequest *data = fq;
698 char *file = gnt_file_sel_get_selected_file(GNT_FILE_SEL(data->dialog)); 704 char *dir = g_path_get_dirname(path);
699 char *dir = g_path_get_dirname(file);
700 if (data->cbs[0] != NULL) 705 if (data->cbs[0] != NULL)
701 ((PurpleRequestFileCb)data->cbs[0])(data->user_data, file); 706 ((PurpleRequestFileCb)data->cbs[0])(data->user_data, file);
702 g_free(file);
703 purple_prefs_set_path(data->save ? "/finch/filelocations/last_save_folder" : 707 purple_prefs_set_path(data->save ? "/finch/filelocations/last_save_folder" :
704 "/finch/filelocations/last_open_folder", dir); 708 "/finch/filelocations/last_open_folder", dir);
705 g_free(dir); 709 g_free(dir);
706 710
707 purple_request_close(PURPLE_REQUEST_FILE, data->dialog); 711 purple_request_close(PURPLE_REQUEST_FILE, data->dialog);
712 data->dialog = NULL;
708 } 713 }
709 714
710 static void 715 static void
711 file_request_destroy(FinchFileRequest *data) 716 file_request_destroy(FinchFileRequest *data)
712 { 717 {
730 data->dialog = window; 735 data->dialog = window;
731 gnt_box_set_title(GNT_BOX(window), title); 736 gnt_box_set_title(GNT_BOX(window), title);
732 737
733 gnt_file_sel_set_current_location(sel, (path && *path) ? path : purple_home_dir()); 738 gnt_file_sel_set_current_location(sel, (path && *path) ? path : purple_home_dir());
734 739
735 g_signal_connect(G_OBJECT(sel->cancel), "activate", 740 g_signal_connect(G_OBJECT(sel), "destroy",
736 G_CALLBACK(action_performed), window);
737 g_signal_connect(G_OBJECT(sel->select), "activate",
738 G_CALLBACK(action_performed), window);
739 g_signal_connect_swapped(G_OBJECT(sel->cancel), "activate",
740 G_CALLBACK(file_cancel_cb), data); 741 G_CALLBACK(file_cancel_cb), data);
741 g_signal_connect_swapped(G_OBJECT(sel->select), "activate", 742 g_signal_connect(G_OBJECT(sel), "cancelled",
743 G_CALLBACK(file_cancel_cb), data);
744 g_signal_connect(G_OBJECT(sel), "file_selected",
742 G_CALLBACK(file_ok_cb), data); 745 G_CALLBACK(file_ok_cb), data);
743 746
744 setup_default_callback(window, file_cancel_cb, data);
745 g_object_set_data_full(G_OBJECT(window), "filerequestdata", data, 747 g_object_set_data_full(G_OBJECT(window), "filerequestdata", data,
746 (GDestroyNotify)file_request_destroy); 748 (GDestroyNotify)file_request_destroy);
747 749
748 return data; 750 return data;
749 } 751 }

mercurial