mail-notification

Fork of Jean-Yves Lefort's mail-notification, a tray icon to notify of new mail
git clone https://code.djc.id.au/git/mail-notification/

src/mn-mailbox-properties-dialog.gob (20972B) - 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-dialog.h"
     22 #include "mn-mailbox.h"
     23 %}
     24 
     25 %privateheader{
     26 #include "mn-mailbox-properties.h"
     27 %}
     28 
     29 %{
     30 #include <glib/gi18n.h>
     31 #include "mn-autodetect-mailbox-properties.h"
     32 #if WITH_MBOX || WITH_MOZILLA || WITH_MH || WITH_MAILDIR || WITH_SYLPHEED
     33 #include "mn-system-vfs-mailbox-properties.h"
     34 #endif
     35 #if WITH_POP3
     36 #include "mn-pop3-mailbox-properties.h"
     37 #endif
     38 #if WITH_IMAP
     39 #include "mn-imap-mailbox-properties.h"
     40 #endif
     41 #if WITH_GMAIL
     42 #include "mn-gmail-mailbox-properties.h"
     43 #endif
     44 #if WITH_YAHOO
     45 #include "mn-yahoo-mailbox-properties.h"
     46 #endif
     47 #if WITH_HOTMAIL
     48 #include "mn-hotmail-mailbox-properties.h"
     49 #endif
     50 #if WITH_EVOLUTION
     51 #include "mn-evolution-mailbox-properties.h"
     52 #endif
     53 #include "mn-util.h"
     54 #include "mn-mailboxes.h"
     55 #include "mn-shell.h"
     56 #include "mn-non-linear-range.h"
     57 
     58 #define HELP_SECTION "mn-mailbox-properties-help-section"
     59 
     60 enum {
     61   COLUMN_PROPERTIES,
     62   COLUMN_STOCK_ID,
     63   COLUMN_LABEL,
     64   N_COLUMNS
     65 };
     66 
     67 static GType selected_type = 0;
     68 
     69 static const MNNonLinearRangeBlock delay_blocks[] = {
     70   { MN_SECS(10),	MN_SECS(60),	MN_SECS(10)	},
     71   { MN_MINS(2),		MN_MINS(10),	MN_MINS(1)	},
     72   { MN_MINS(15),	MN_MINS(60),	MN_MINS(5)	},
     73   { MN_HOURS(2),	MN_HOURS(24),	MN_HOURS(1)	}
     74 };
     75 %}
     76 
     77 class MN:Mailbox:Properties:Dialog from MN:Dialog
     78 {
     79   /* "parent" is a GtkWidget property, do not conflict with it */
     80   private GtkWindow *dialog_parent;
     81   property POINTER dialog_parent (link, flags = CONSTRUCT_ONLY, type = GtkWindow *);
     82 
     83   private MNMailbox *mailbox unrefwith g_object_unref;
     84   property OBJECT mailbox (flags = CONSTRUCT,
     85 			   object_type = MN:Mailbox,
     86 			   type = MNMailbox *,
     87 			   export)
     88     set
     89     {
     90       GObject *obj;
     91 
     92       if (selfp->mailbox)
     93 	{
     94 	  g_object_unref(selfp->mailbox);
     95 	  selfp->mailbox = NULL;
     96 	}
     97 
     98       obj = g_value_dup_object(VAL);
     99       if (obj)
    100 	{
    101 	  char *title;
    102 
    103 	  selfp->mailbox = MN_MAILBOX(obj);
    104 
    105 	  /* translators: header capitalization */
    106 	  title = g_strdup_printf(_("%s Properties"), selfp->mailbox->runtime_name);
    107 	  gtk_window_set_title(GTK_WINDOW(self), title);
    108 	  g_free(title);
    109 	}
    110     }
    111     get
    112     {
    113       g_value_set_object(VAL, selfp->mailbox);
    114     };
    115 
    116   private gboolean apply_used;
    117 
    118   /* only set in editing mode */
    119   private MNMailboxConfiguration *orig_mailbox_configuration destroywith mn_mailbox_configuration_free;
    120 
    121   protected GtkWidget *notebook;
    122   protected GtkWidget *general_vbox;
    123   private GtkWidget *type_label;
    124   private GtkWidget *type_combo;
    125   private GtkWidget *name_default_radio;
    126   private GtkWidget *name_default_label;
    127   private GtkWidget *name_other_radio;
    128   private GtkWidget *name_entry;
    129   private GtkWidget *delay_vbox;
    130   private GtkWidget *delay_default_radio;
    131   private GtkWidget *delay_default_label;
    132   private GtkWidget *delay_other_radio;
    133   private GtkWidget *delay_scale;
    134 
    135   private GtkWidget *apply_button;
    136   private GtkWidget *accept_button;
    137 
    138   private GtkListStore *store unrefwith g_object_unref;
    139 
    140   private MNMailboxProperties *active_properties unrefwith g_object_unref;
    141 
    142   private GtkSizeGroup *details_size_group = {gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL)} unrefwith g_object_unref;
    143 
    144   constructor (self)
    145   {
    146     GtkWidget *page;
    147     MNMailboxProperties *properties;
    148 
    149     mn_container_create_interface(GTK_CONTAINER(self),
    150 				  PKGDATADIR G_DIR_SEPARATOR_S "mailbox-properties-dialog.glade",
    151 				  "notebook",
    152 				  "mn_mailbox_properties_dialog_",
    153 				  "notebook", &self->notebook,
    154 				  "general_vbox", &self->general_vbox,
    155 				  "type_label", &selfp->type_label,
    156 				  "type_combo", &selfp->type_combo,
    157 				  "name_default_radio", &selfp->name_default_radio,
    158 				  "name_default_label", &selfp->name_default_label,
    159 				  "name_other_radio", &selfp->name_other_radio,
    160 				  "name_entry", &selfp->name_entry,
    161 				  "delay_vbox", &selfp->delay_vbox,
    162 				  "delay_default_radio", &selfp->delay_default_radio,
    163 				  "delay_default_label", &selfp->delay_default_label,
    164 				  "delay_other_radio", &selfp->delay_other_radio,
    165 				  "delay_scale", &selfp->delay_scale,
    166 				  NULL);
    167 
    168     gtk_window_set_resizable(GTK_WINDOW(self), FALSE);
    169 
    170     if (selfp->dialog_parent)
    171       gtk_window_set_transient_for(GTK_WINDOW(self), selfp->dialog_parent);
    172 
    173     page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(self->notebook), 0);
    174     self_set_help_section(page, "mailbox-properties-general");
    175 
    176     page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(self->notebook), 1);
    177     self_set_help_section(page, "mailbox-properties-details");
    178 
    179     self_setup_type_combo(self);
    180 
    181     mn_non_linear_range_setup_static(GTK_RANGE(selfp->delay_scale), delay_blocks, G_N_ELEMENTS(delay_blocks));
    182 
    183     /* set a good general default value */
    184     mn_non_linear_range_set_value(GTK_RANGE(selfp->delay_scale), MN_MINS(5));
    185 
    186     gtk_size_group_add_widget(selfp->details_size_group, selfp->name_default_radio);
    187     gtk_size_group_add_widget(selfp->details_size_group, selfp->name_other_radio);
    188 
    189     /* setup the dialog depending on the mode (edit or add) */
    190     gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_HELP, GTK_RESPONSE_HELP);
    191     if (selfp->mailbox)
    192       {
    193 	selfp->apply_button = gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
    194 	gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
    195 	selfp->accept_button = gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_OK, GTK_RESPONSE_OK);
    196 
    197 	properties = self_get_properties_by_type(self, MN_MAILBOX_GET_CLASS(selfp->mailbox)->type);
    198       }
    199     else
    200       {
    201 	gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
    202 	selfp->accept_button = gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT);
    203 
    204 	if (! selected_type)
    205 	  selected_type = MN_TYPE_AUTODETECT_MAILBOX_PROPERTIES;
    206 
    207 	properties = self_get_properties_by_g_type(self, selected_type);
    208 
    209 	/* translators: header capitalization */
    210 	gtk_window_set_title(GTK_WINDOW(self), _("Add a Mailbox"));
    211       }
    212 
    213     self_set_active_properties(self, properties);
    214 
    215     if (selfp->mailbox)
    216       {
    217 	selfp->orig_mailbox_configuration = mn_mailbox_get_configuration(selfp->mailbox);
    218 
    219 	mn_mailbox_properties_set_mailbox(properties, selfp->mailbox);
    220 
    221 	if (selfp->mailbox->name)
    222 	  {
    223 	    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(selfp->name_other_radio), TRUE);
    224 	    gtk_entry_set_text(GTK_ENTRY(selfp->name_entry), selfp->mailbox->name);
    225 	  }
    226 
    227 	if (selfp->mailbox->check_delay != -1)
    228 	  {
    229 	    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(selfp->delay_other_radio), TRUE);
    230 	    mn_non_linear_range_set_value(GTK_RANGE(selfp->delay_scale), selfp->mailbox->check_delay);
    231 	  }
    232       }
    233 
    234     g_object_unref(properties);
    235 
    236     gtk_widget_grab_default(selfp->accept_button);
    237 
    238     /*
    239      * HIG chapter 3:
    240      * "When opening a dialog, provide initial keyboard focus to the
    241      * component that you expect users to operate first. This focus is
    242      * especially important for users who must use a keyboard to
    243      * navigate your application."
    244      */
    245     gtk_widget_grab_focus(selfp->type_combo);
    246 
    247     self_update_name_sensitivity(self);
    248     self_update_delay_sensitivity(self);
    249 
    250     g_signal_connect(self, "response", G_CALLBACK(self_response_h), NULL);
    251   }
    252 
    253   private void
    254     setup_type_combo (self)
    255   {
    256     GtkCellRenderer *renderer;
    257 
    258     selfp->store = gtk_list_store_new(N_COLUMNS,
    259 				      MN_TYPE_MAILBOX_PROPERTIES,
    260 				      G_TYPE_STRING,
    261 				      G_TYPE_STRING);
    262 
    263     self_add_type(self, MN_TYPE_AUTODETECT_MAILBOX_PROPERTIES);
    264 #if WITH_MBOX || WITH_MOZILLA || WITH_MH || WITH_MAILDIR || WITH_SYLPHEED
    265     self_add_type(self, MN_TYPE_SYSTEM_VFS_MAILBOX_PROPERTIES);
    266 #endif
    267 #if WITH_POP3
    268     self_add_type(self, MN_TYPE_POP3_MAILBOX_PROPERTIES);
    269 #endif
    270 #if WITH_IMAP
    271     self_add_type(self, MN_TYPE_IMAP_MAILBOX_PROPERTIES);
    272 #endif
    273 #if WITH_GMAIL
    274     self_add_type(self, MN_TYPE_GMAIL_MAILBOX_PROPERTIES);
    275 #endif
    276 #if WITH_YAHOO
    277     self_add_type(self, MN_TYPE_YAHOO_MAILBOX_PROPERTIES);
    278 #endif
    279 #if WITH_HOTMAIL
    280     self_add_type(self, MN_TYPE_HOTMAIL_MAILBOX_PROPERTIES);
    281 #endif
    282 #if WITH_EVOLUTION
    283     self_add_type(self, MN_TYPE_EVOLUTION_MAILBOX_PROPERTIES);
    284 #endif
    285 
    286     gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(selfp->store), COLUMN_LABEL, GTK_SORT_ASCENDING);
    287 
    288     renderer = gtk_cell_renderer_pixbuf_new();
    289     g_object_set(renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);
    290     gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(selfp->type_combo), renderer, FALSE);
    291     gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(selfp->type_combo), renderer,
    292 				   "stock-id", COLUMN_STOCK_ID,
    293 				   NULL);
    294 
    295     renderer = gtk_cell_renderer_text_new();
    296     g_object_set(renderer, "xpad", 6, NULL);
    297     gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(selfp->type_combo), renderer, TRUE);
    298     gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(selfp->type_combo), renderer,
    299 				   "text", COLUMN_LABEL,
    300 				   NULL);
    301 
    302     gtk_combo_box_set_model(GTK_COMBO_BOX(selfp->type_combo), GTK_TREE_MODEL(selfp->store));
    303   }
    304 
    305   private void
    306     response_h (GtkDialog *dialog, int response, gpointer user_data)
    307   {
    308     Self *self = SELF(dialog);
    309 
    310     if (response == GTK_RESPONSE_HELP)
    311       {
    312 	int page_number;
    313 	GtkWidget *page;
    314 	const char *section;
    315 
    316 	page_number = gtk_notebook_get_current_page(GTK_NOTEBOOK(self->notebook));
    317 
    318 	page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(self->notebook), page_number);
    319 	g_assert(page != NULL);
    320 
    321 	section = g_object_get_data(G_OBJECT(page), HELP_SECTION);
    322 	g_assert(section != NULL);
    323 
    324 	mn_show_help(GTK_WINDOW(self), section);
    325       }
    326 
    327     /* other responses are handled by the client */
    328   }
    329 
    330   private void
    331     add_type (self, GType type (check != 0))
    332   {
    333     MNMailboxProperties *properties;
    334     MNMailboxPropertiesClass *p_class;
    335     GtkTreeIter iter;
    336     GSList *l;
    337 
    338     properties = g_object_new(type, MN_MAILBOX_PROPERTIES_PROP_DIALOG(GTK_WIDGET(self)), NULL);
    339 
    340     p_class = MN_MAILBOX_PROPERTIES_GET_CLASS(properties);
    341 
    342     gtk_list_store_append(selfp->store, &iter);
    343     gtk_list_store_set(selfp->store, &iter,
    344 		       COLUMN_PROPERTIES, properties,
    345 		       COLUMN_STOCK_ID, p_class->stock_id,
    346 		       COLUMN_LABEL, p_class->combo_label,
    347 		       -1);
    348 
    349     g_object_connect(properties,
    350 		     "swapped-signal::notify::complete", self_update_complete, self,
    351 		     "swapped-signal::notify::default-name", self_update_default_name, self,
    352 		     "swapped-signal::notify::default-check-delay", self_update_default_check_delay, self,
    353 		     NULL);
    354 
    355     MN_LIST_FOREACH(l, properties->entries)
    356       g_signal_connect_swapped(l->data, "activate", G_CALLBACK(self_entry_activate_h), self);
    357 
    358     g_object_unref(properties);	/* now it belongs to the store */
    359   }
    360 
    361   private void
    362     set_active_properties (self,
    363 			   MN:Mailbox:Properties *properties (check null type))
    364   {
    365     gboolean valid;
    366     GtkTreeIter iter;
    367 
    368     MN_TREE_MODEL_FOREACH(valid, &iter, GTK_TREE_MODEL(selfp->store))
    369       {
    370 	MNMailboxProperties *these_properties;
    371 
    372 	gtk_tree_model_get(GTK_TREE_MODEL(selfp->store), &iter, COLUMN_PROPERTIES, &these_properties, -1);
    373 	g_object_unref(these_properties);
    374 
    375 	if (these_properties == properties)
    376 	  {
    377 	    gtk_combo_box_set_active_iter(GTK_COMBO_BOX(selfp->type_combo), &iter);
    378 	    break;
    379 	  }
    380       }
    381   }
    382 
    383   private MNMailboxProperties *
    384     get_active_properties (self)
    385   {
    386     GtkTreeIter iter;
    387     MNMailboxProperties *properties = NULL;
    388 
    389     if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selfp->type_combo), &iter))
    390       gtk_tree_model_get(GTK_TREE_MODEL(selfp->store), &iter, COLUMN_PROPERTIES, &properties, -1);
    391 
    392     return properties;
    393   }
    394 
    395   private MNMailboxProperties *
    396     get_properties_by_type (self, const char *type (check null))
    397   {
    398     gboolean valid;
    399     GtkTreeIter iter;
    400 
    401     MN_TREE_MODEL_FOREACH(valid, &iter, GTK_TREE_MODEL(selfp->store))
    402       {
    403 	MNMailboxProperties *properties;
    404 	MNMailboxPropertiesClass *class;
    405 
    406 	gtk_tree_model_get(GTK_TREE_MODEL(selfp->store), &iter, COLUMN_PROPERTIES, &properties, -1);
    407 
    408 	class = MN_MAILBOX_PROPERTIES_GET_CLASS(properties);
    409 
    410 	if (class->type && ! strcmp(class->type, type))
    411 	  return properties;
    412 
    413 	g_object_unref(properties);
    414       }
    415 
    416     return NULL;
    417   }
    418 
    419   private MNMailboxProperties *
    420     get_properties_by_g_type (self, GType type (check != 0))
    421   {
    422     gboolean valid;
    423     GtkTreeIter iter;
    424 
    425     MN_TREE_MODEL_FOREACH(valid, &iter, GTK_TREE_MODEL(selfp->store))
    426       {
    427 	MNMailboxProperties *properties;
    428 
    429 	gtk_tree_model_get(GTK_TREE_MODEL(selfp->store), &iter, COLUMN_PROPERTIES, &properties, -1);
    430 
    431 	if (G_TYPE_CHECK_INSTANCE_TYPE(properties, type))
    432 	  return properties;
    433 
    434 	g_object_unref(properties);
    435       }
    436 
    437     return NULL;
    438   }
    439 
    440   public MNMailbox *
    441     get_current_mailbox (self)
    442   {
    443     MNMailboxProperties *properties;
    444     MNMailbox *mailbox;
    445 
    446     properties = self_get_active_properties(self);
    447     mailbox = mn_mailbox_properties_get_mailbox(properties);
    448     g_object_unref(properties);
    449 
    450     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selfp->name_other_radio)))
    451       g_object_set(G_OBJECT(mailbox), MN_MAILBOX_PROP_NAME((char *) gtk_entry_get_text(GTK_ENTRY(selfp->name_entry))), NULL);
    452 
    453     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selfp->delay_other_radio)))
    454       g_object_set(G_OBJECT(mailbox), MN_MAILBOX_PROP_CHECK_DELAY(mn_non_linear_range_get_value(GTK_RANGE(selfp->delay_scale))), NULL);
    455 
    456     return mailbox;
    457   }
    458 
    459   public void
    460     apply (self)
    461   {
    462     MNMailbox *new_mailbox;
    463 
    464     selfp->apply_used = TRUE;
    465 
    466     new_mailbox = self_get_current_mailbox(self);
    467     g_assert(MN_IS_MAILBOX(new_mailbox));
    468 
    469     mn_mailbox_seal(new_mailbox);
    470 
    471     mn_mailboxes_queue_remove(mn_shell->mailboxes, selfp->mailbox);
    472     mn_mailboxes_queue_add(mn_shell->mailboxes, new_mailbox);
    473 
    474     self_set_mailbox(self, new_mailbox);
    475     g_object_unref(new_mailbox);
    476   }
    477 
    478   public void
    479     cancel (self)
    480   {
    481     MNMailbox *orig_mailbox;
    482 
    483     if (! selfp->apply_used)
    484       return;
    485 
    486     orig_mailbox = mn_mailbox_new_from_configuration(selfp->orig_mailbox_configuration);
    487 
    488     mn_mailbox_seal(orig_mailbox);
    489 
    490     mn_mailboxes_queue_remove(mn_shell->mailboxes, selfp->mailbox);
    491     mn_mailboxes_queue_add(mn_shell->mailboxes, orig_mailbox);
    492 
    493     g_object_unref(orig_mailbox);
    494   }
    495 
    496   private void
    497     update_complete (self)
    498   {
    499     MNMailboxProperties *properties;
    500 
    501     properties = self_get_active_properties(self);
    502     if (properties)
    503       {
    504 	gboolean complete;
    505 
    506 	g_object_get(G_OBJECT(properties), MN_MAILBOX_PROPERTIES_GET_PROP_COMPLETE(&complete), NULL);
    507 	g_object_unref(properties);
    508 
    509 	if (selfp->apply_button)
    510 	  gtk_widget_set_sensitive(selfp->apply_button, complete);
    511 	gtk_widget_set_sensitive(selfp->accept_button, complete);
    512       }
    513   }
    514 
    515   private void
    516     update_name_sensitivity (self)
    517   {
    518     gtk_widget_set_sensitive(selfp->name_entry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selfp->name_other_radio)));
    519   }
    520 
    521   private void
    522     update_delay_sensitivity (self)
    523   {
    524     gtk_widget_set_sensitive(selfp->delay_scale, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selfp->delay_other_radio)));
    525   }
    526 
    527   private void
    528     update_delay_visibility (self)
    529   {
    530     MNMailboxProperties *properties;
    531     gboolean visible = TRUE;
    532 
    533     properties = self_get_active_properties(self);
    534     if (properties)
    535       {
    536 	visible = MN_MAILBOX_PROPERTIES_GET_CLASS(properties)->enable_check_delay;
    537 	g_object_unref(properties);
    538       }
    539 
    540     if (visible)
    541       {
    542 	if (! g_slist_find(gtk_size_group_get_widgets(selfp->details_size_group), selfp->delay_default_radio))
    543 	  gtk_size_group_add_widget(selfp->details_size_group, selfp->delay_default_radio);
    544 	if (! g_slist_find(gtk_size_group_get_widgets(selfp->details_size_group), selfp->delay_other_radio))
    545 	  gtk_size_group_add_widget(selfp->details_size_group, selfp->delay_other_radio);
    546 
    547 	gtk_widget_show(selfp->delay_vbox);
    548       }
    549     else
    550       {
    551 	if (g_slist_find(gtk_size_group_get_widgets(selfp->details_size_group), selfp->delay_default_radio))
    552 	  gtk_size_group_remove_widget(selfp->details_size_group, selfp->delay_default_radio);
    553 	if (g_slist_find(gtk_size_group_get_widgets(selfp->details_size_group), selfp->delay_other_radio))
    554 	  gtk_size_group_remove_widget(selfp->details_size_group, selfp->delay_other_radio);
    555 
    556 	gtk_widget_hide(selfp->delay_vbox);
    557       }
    558   }
    559 
    560   private void
    561     update_default_name (self)
    562   {
    563     MNMailboxProperties *properties;
    564     char *name = NULL;
    565     const char *radio_label;
    566 
    567     properties = self_get_active_properties(self);
    568     if (properties)
    569       {
    570 	gboolean complete;
    571 
    572 	g_object_get(G_OBJECT(properties),
    573 		     MN_MAILBOX_PROPERTIES_GET_PROP_COMPLETE(&complete),
    574 		     NULL);
    575 
    576 	if (complete)
    577 	  g_object_get(G_OBJECT(properties),
    578 		       MN_MAILBOX_PROPERTIES_GET_PROP_DEFAULT_NAME(&name),
    579 		       NULL);
    580 
    581 	g_object_unref(properties);
    582       }
    583 
    584     if (name)
    585       radio_label = _("_Default:");
    586     else
    587       radio_label = _("_Default");
    588 
    589     gtk_button_set_label(GTK_BUTTON(selfp->name_default_radio), radio_label);
    590     gtk_label_set_text(GTK_LABEL(selfp->name_default_label), name);
    591 
    592     g_free(name);
    593   }
    594 
    595   private void
    596     update_default_check_delay (self)
    597   {
    598     MNMailboxProperties *properties;
    599     int delay = -1;
    600     const char *radio_label;
    601     char *delay_str = NULL;
    602 
    603     properties = self_get_active_properties(self);
    604     if (properties)
    605       {
    606 	g_object_get(G_OBJECT(properties),
    607 		     MN_MAILBOX_PROPERTIES_GET_PROP_DEFAULT_CHECK_DELAY(&delay),
    608 		     NULL);
    609 	g_object_unref(properties);
    610       }
    611 
    612     if (delay != -1)
    613       {
    614 	radio_label = _("D_efault:");
    615 	delay_str = mn_format_seconds(delay);
    616       }
    617     else
    618       radio_label = _("D_efault");
    619 
    620     gtk_button_set_label(GTK_BUTTON(selfp->delay_default_radio), radio_label);
    621     gtk_label_set_text(GTK_LABEL(selfp->delay_default_label), delay_str);
    622 
    623     g_free(delay_str);
    624   }
    625 
    626   protected void
    627     set_help_section (Gtk:Widget *page (check null type),
    628 		      const char *section (check null))
    629   {
    630     g_object_set_data_full(G_OBJECT(page), HELP_SECTION, g_strdup(section), g_free);
    631   }
    632 
    633   public GtkWidget *
    634     new (GtkWindow *parent, MNMailbox *mailbox)
    635   {
    636     return GTK_WIDGET(GET_NEW_VARG(MN_MAILBOX_PROPERTIES_DIALOG_PROP_DIALOG_PARENT(parent),
    637 				   MN_MAILBOX_PROPERTIES_DIALOG_PROP_MAILBOX(mailbox),
    638 				   NULL));
    639   }
    640 
    641   /* libglade callbacks */
    642 
    643   protected void
    644     type_changed_h (self, GtkComboBox *combobox)
    645   {
    646     if (selfp->active_properties)
    647       {
    648 	mn_mailbox_properties_deactivate(selfp->active_properties);
    649 	gtk_size_group_remove_widget(selfp->active_properties->label_size_group, selfp->type_label);
    650 	g_object_unref(selfp->active_properties);
    651       }
    652 
    653     selfp->active_properties = self_get_active_properties(self);
    654     mn_mailbox_properties_activate(selfp->active_properties);
    655     gtk_size_group_add_widget(selfp->active_properties->label_size_group, selfp->type_label);
    656 
    657     if (! selfp->mailbox)	/* mode is add */
    658       selected_type = G_OBJECT_TYPE(selfp->active_properties);
    659 
    660     self_update_complete(self);
    661     self_update_delay_visibility(self);
    662     self_update_default_name(self);
    663     self_update_default_check_delay(self);
    664   }
    665 
    666   protected void
    667     name_toggled_h (self, GtkToggleButton *button)
    668   {
    669     self_update_name_sensitivity(self);
    670   }
    671 
    672   protected void
    673     delay_toggled_h (self, GtkToggleButton *button)
    674   {
    675     self_update_delay_sensitivity(self);
    676   }
    677 
    678   protected char *
    679     delay_format_value_h (self, double arg, GtkScale *scale)
    680   {
    681     return mn_format_seconds(mn_non_linear_range_get_value(GTK_RANGE(scale)));
    682   }
    683 
    684   protected void
    685     entry_activate_h (self, GtkEntry *entry)
    686   {
    687     if (GTK_WIDGET_IS_SENSITIVE(GTK_WINDOW(self)->default_widget))
    688       gtk_window_activate_default(GTK_WINDOW(self));
    689     else
    690       {
    691 	MNMailboxProperties *properties;
    692 	GtkWidget *next = NULL;
    693 	GSList *elem;
    694 
    695 	properties = self_get_active_properties(self);
    696 	g_assert(properties != NULL);
    697 
    698 	elem = g_slist_find(properties->entries, entry);
    699 	g_assert(elem != NULL);
    700 
    701 	do
    702 	  {
    703 	    elem = elem->next;
    704 	    if (! elem)
    705 	      elem = properties->entries;
    706 
    707 	    if (elem->data == entry)
    708 	      break;
    709 
    710 	    if (GTK_WIDGET_MAPPED(elem->data)
    711 		&& GTK_WIDGET_VISIBLE(elem->data)
    712 		&& GTK_WIDGET_SENSITIVE(elem->data))
    713 	      next = elem->data;
    714 	  }
    715 	while (! next);
    716 
    717 	if (next)
    718 	  gtk_widget_grab_focus(next);
    719 
    720 	g_object_unref(properties);
    721       }
    722   }
    723 }