src/mn-evolution-mailbox-properties.gob (4241B) - raw
1 /* 2 * Mail Notification 3 * Copyright (C) 2003-2008 Jean-Yves Lefort <jylefort@brutele.be> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 %headertop{ 21 #include "mn-mailbox-properties.h" 22 %} 23 24 %privateheader{ 25 #include "mn-evolution-client.h" 26 %} 27 28 %{ 29 #include <glib/gi18n.h> 30 #include "mn-evolution-mailbox.h" 31 #include "mn-stock.h" 32 #include "mn-mailbox-properties-private.h" 33 #include "mn-shell.h" 34 #include "mn-evolution-client-dbus.h" 35 #include "mn-util.h" 36 #include "mn-evolution-folder-tree-client.h" 37 %} 38 39 class MN:Evolution:Mailbox:Properties from MN:Mailbox:Properties 40 { 41 private GtkWidget *tree; 42 43 private char *name destroywith g_free; 44 45 property BOOLEAN complete (override) 46 get 47 { 48 MNEvolutionFolderTreeClient *tree = MN_EVOLUTION_FOLDER_TREE_CLIENT(selfp->tree); 49 g_value_set_boolean(VAL, mn_evolution_folder_tree_client_get_connected(tree) && tree->selected_uri != NULL); 50 }; 51 52 property STRING default_name (override) 53 get { g_value_set_string(VAL, selfp->name); }; 54 55 class_init (class) 56 { 57 MNMailboxPropertiesClass *p_class = MN_MAILBOX_PROPERTIES_CLASS(class); 58 59 p_class->type = "evolution"; 60 p_class->stock_id = MN_STOCK_EVOLUTION_MAILBOX; 61 p_class->combo_label = "Evolution"; 62 p_class->enable_check_delay = FALSE; 63 } 64 65 init (self) 66 { 67 MNMailboxProperties *properties = MN_MAILBOX_PROPERTIES(self); 68 GtkWidget *vbox; 69 70 /* translators: header capitalization */ 71 vbox = mn_mailbox_properties_add_general_section(properties, _("Folder")); 72 73 selfp->tree = mn_evolution_folder_tree_client_new(); 74 gtk_box_pack_start(GTK_BOX(vbox), selfp->tree, TRUE, TRUE, 0); 75 gtk_widget_show(selfp->tree); 76 77 g_object_connect(selfp->tree, 78 "swapped-signal::notify::connected", mn_mailbox_properties_notify_complete, self, 79 "signal::notify::selected-uri", self_notify_selected_uri_h, self, 80 "signal::folder-activated", self_folder_activated_h, self, 81 NULL); 82 } 83 84 private void 85 notify_selected_uri_h (GObject *object, GParamSpec *pspec, gpointer user_data) 86 { 87 Self *self = user_data; 88 MNEvolutionClient *client; 89 char *name = NULL; 90 91 client = mn_evolution_client_get(); 92 if (client->proxy) 93 org_gnome_MailNotification_Evolution_get_folder_name(client->proxy, MN_EVOLUTION_FOLDER_TREE_CLIENT(selfp->tree)->selected_uri, &name, NULL); 94 95 g_free(selfp->name); 96 selfp->name = name; 97 98 g_object_notify(G_OBJECT(self), "complete"); 99 g_object_notify(G_OBJECT(self), "default-name"); 100 } 101 102 private void 103 folder_activated_h (MNEvolutionFolderTreeClient *client, gpointer user_data) 104 { 105 Self *self = user_data; 106 107 gtk_window_activate_default(GTK_WINDOW(MN_MAILBOX_PROPERTIES(self)->dialog)); 108 } 109 110 override (MN:Mailbox:Properties) void 111 set_mailbox (MNMailboxProperties *properties, MNMailbox *mailbox) 112 { 113 Self *self = SELF(properties); 114 MNEvolutionMailbox *evolution_mailbox = MN_EVOLUTION_MAILBOX(mailbox); 115 116 mn_evolution_folder_tree_client_set_selected_uri(MN_EVOLUTION_FOLDER_TREE_CLIENT(selfp->tree), evolution_mailbox->uri); 117 118 g_free(selfp->name); 119 selfp->name = g_strdup(evolution_mailbox->folder_name); 120 } 121 122 override (MN:Mailbox:Properties) MNMailbox * 123 get_mailbox (MNMailboxProperties *properties) 124 { 125 Self *self = SELF(properties); 126 MNMailbox *mailbox; 127 128 mailbox = PARENT_HANDLER(properties); 129 130 g_object_set(mailbox, 131 MN_EVOLUTION_MAILBOX_PROP_URI(MN_EVOLUTION_FOLDER_TREE_CLIENT(selfp->tree)->selected_uri), 132 MN_EVOLUTION_MAILBOX_PROP_FOLDER_NAME(selfp->name), 133 NULL); 134 135 return mailbox; 136 } 137 }