[balsa] Improve the Mac OS X integration for a native "Carbon" build



commit f55c0e2184353df1245299cc2b236a8d0b10ba1f
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Aug 29 19:43:57 2009 -0400

    Improve the Mac OS X integration for a native "Carbon" build

 ChangeLog                         |   43 ++++++++++++++++++++++
 libbalsa/Makefile.am              |    2 +
 libbalsa/identity.c               |   14 +++++++
 libbalsa/macosx-helpers.c         |   73 +++++++++++++++++++++++++++++++++++++
 libbalsa/macosx-helpers.h         |   40 ++++++++++++++++++++
 libbalsa/rfc3156.c                |   16 ++++++++
 libbalsa/smtp-server.c            |    7 ++++
 libbalsa/source-viewer.c          |   13 +++++--
 src/ab-main.c                     |    2 +-
 src/address-book-config.c         |   13 +++++++
 src/balsa-app.c                   |    7 ++++
 src/balsa-icons.c                 |    1 +
 src/balsa-index.c                 |    7 ++++
 src/balsa-mblist.c                |    7 ++++
 src/balsa-message.c               |   10 +++++
 src/balsa-mime-widget-callbacks.c |   10 +++++
 src/filter-edit-callbacks.c       |    7 ++++
 src/folder-conf.c                 |   19 ++++++++++
 src/information-dialog.c          |   10 +++++
 src/mailbox-conf.c                |   13 +++++++
 src/main-window.c                 |   49 +++++++++++++++++--------
 src/message-window.c              |    8 ++++
 src/pref-manager.c                |    7 ++++
 src/sendmsg-window.c              |   43 ++++++++++++++++++----
 src/store-address.c               |    7 ++++
 src/threads.h                     |    3 ++
 src/toolbar-prefs.c               |    7 ++++
 27 files changed, 410 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 766f75f..1f9c183 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2009-08-29  Albrecht DreÃ?
+
+	Improve the Mac OS X integration for a native "Carbon" build
+
+	* libbalsa/Makefile.am:
+	* libbalsa/identity.c (libbalsa_identity_select_dialog),
+	(delete_ident_cb), (libbalsa_identity_config_dialog):
+	* libbalsa/rfc3156.c (check_gpg_child), (select_key_from_list),
+	(accept_low_trust_key), (get_passphrase_real):
+	* libbalsa/smtp-server.c (libbalsa_smtp_server_dialog):
+	* libbalsa/source-viewer.c (libbalsa_show_message_source):
+	* src/ab-main.c:
+	* src/address-book-config.c (create_local_dialog),
+	(create_generic_dialog), (bad_path):
+	* src/balsa-app.c (ask_password_real):
+	* src/balsa-icons.c (register_balsa_pixmaps):
+	* src/balsa-index.c (balsa_index_pipe):
+	* src/balsa-mblist.c (bmbl_mru_show_tree):
+	* src/balsa-message.c (part_context_dump_all_cb),
+	(create_mdn_dialog):
+	* src/balsa-mime-widget-callbacks.c
+	(balsa_mime_widget_ctx_menu_save):
+	* src/filter-edit-callbacks.c (fe_edit_condition):
+	* src/folder-conf.c (folder_conf_imap_node), (browse_button_cb),
+	(subfolder_conf_clicked_ok), (folder_conf_imap_sub_node),
+	(folder_conf_delete):
+	* src/information-dialog.c (balsa_information_dialog),
+	(balsa_information_list):
+	* src/mailbox-conf.c (mailbox_conf_delete),
+	(create_local_mailbox_dialog), (create_generic_dialog):
+	* src/main-window.c:
+	* src/message-window.c (message_window_new):
+	* src/pref-manager.c (open_preferences_manager):
+	* src/sendmsg-window.c (delete_handler), (change_attach_mode),
+	(sw_get_user_codeset), (sw_attach_dialog),
+	(quote_parts_select_dlg), (sendmsg_window_new),
+	(sendmsg_window_set_field), (include_file_cb),
+	(check_suggest_encryption), (send_message_handler),
+	(bsmsg_check_format_compatibility):
+	* src/store-address.c (store_address_dialog):
+	* src/threads.h:
+	* src/toolbar-prefs.c (customize_dialog_cb):
+
 2006-08-27  Pawel Salek
 
 	* libbalsa/imap/imap-handle.c: namespace queries need to encode
diff --git a/libbalsa/Makefile.am b/libbalsa/Makefile.am
index 0a1c03a..35e1982 100644
--- a/libbalsa/Makefile.am
+++ b/libbalsa/Makefile.am
@@ -88,6 +88,8 @@ libbalsa_a_SOURCES = 		\
 	libbalsa-conf.h		\
 	libbalsa-marshal.c	\
 	libbalsa-marshal.h	\
+	macosx-helpers.c	\
+	macosx-helpers.h	\
 	missing.h		\
 	missing_time.c		\
 	libbalsa.c		\
diff --git a/libbalsa/identity.c b/libbalsa/identity.c
index 334a276..9b86462 100644
--- a/libbalsa/identity.c
+++ b/libbalsa/identity.c
@@ -33,6 +33,10 @@
 #include <glib/gi18n.h>
 #include "misc.h"
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 #if ENABLE_ESMTP
 #include <string.h>
 #include "smtp-server.h"
@@ -486,6 +490,10 @@ libbalsa_identity_select_dialog(GtkWindow * parent,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_OK, GTK_RESPONSE_OK,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, parent);
+#endif
+ 
     g_signal_connect(dialog, "response",
                      G_CALLBACK(sd_response_cb), sdi);
     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
@@ -1634,6 +1642,9 @@ delete_ident_cb(GtkTreeView * tree, GtkWidget * dialog)
                                      GTK_BUTTONS_OK_CANCEL,
                                      _("Do you really want to delete"
                                        " the selected identity?"));
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(confirm, GTK_WINDOW(dialog));
+#endif
     di = g_new(IdentityDeleteInfo, 1);
     di->tree = tree;
     di->dialog = dialog;
@@ -1720,6 +1731,9 @@ libbalsa_identity_config_dialog(GtkWindow *parent, GList **identities,
                                     GTK_STOCK_REMOVE, IDENTITY_RESPONSE_REMOVE,
                                     GTK_STOCK_CLOSE, IDENTITY_RESPONSE_CLOSE,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, parent);
+#endif
 
     frame = libbalsa_identity_config_frame(identities, default_id, dialog,
                                            changed_cb, parent);
diff --git a/libbalsa/macosx-helpers.c b/libbalsa/macosx-helpers.c
new file mode 100644
index 0000000..969f348
--- /dev/null
+++ b/libbalsa/macosx-helpers.c
@@ -0,0 +1,73 @@
+/*
+ * macosx-helpers.h
+ *  
+ * Helper functions for managing the IGE Mac Integration stuff
+ *
+ * Copyright (C) 2004 Albrecht Dreß <albrecht dress arcor de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option) 
+ * any later version.
+ *  
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
+ * GNU General Public License for more details.
+ *  
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
+ * 02111-1307, USA.
+ */
+ 
+#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
+# include "config.h"
+#endif                          /* HAVE_CONFIG_H */
+
+#if HAVE_MACOSX_DESKTOP
+
+#include <gtk/gtk.h>
+#include <ige-mac-integration.h>
+#include "macosx-helpers.h"
+
+
+static gboolean update_osx_menubar(GtkWidget *widget, GdkEventFocus *event, GtkWindow *window);
+
+
+void
+libbalsa_macosx_menu(GtkWidget *window, GtkMenuShell *menubar)
+{
+    g_object_set_data(G_OBJECT(window), "osx-menubar", menubar);
+    g_signal_connect(G_OBJECT(window), "focus-in-event",
+		     G_CALLBACK(update_osx_menubar), window);
+}
+
+
+void
+libbalsa_macosx_menu_for_parent(GtkWidget *window, GtkWindow *parent)
+{
+    if(parent)
+	g_signal_connect(G_OBJECT(window), "focus-in-event",
+			 G_CALLBACK(update_osx_menubar), parent);
+    else
+	g_message("called %s for widget %p with NULL parent", __func__, window);
+}
+
+
+/* window "focus-in-event" callback for a window
+ * get the "osx-menubar" from the user data object, and set it as OS X main menu
+ */
+static gboolean
+update_osx_menubar(GtkWidget *widget,  GdkEventFocus *event, GtkWindow *window)
+{
+    GtkMenuShell *menubar;
+    
+    g_return_val_if_fail(window != NULL, FALSE);
+    menubar = GTK_MENU_SHELL(g_object_get_data(G_OBJECT(window), "osx-menubar"));
+    g_return_val_if_fail(menubar != NULL, FALSE);
+    ige_mac_menu_set_menu_bar(menubar);
+    return FALSE;
+}
+
+#endif  /* HAVE_MACOSX_DESKTOP */
diff --git a/libbalsa/macosx-helpers.h b/libbalsa/macosx-helpers.h
new file mode 100644
index 0000000..4a0a937
--- /dev/null
+++ b/libbalsa/macosx-helpers.h
@@ -0,0 +1,40 @@
+/*
+ * macosx-helpers.h
+ *  
+ * Helper functions for managing the IGE Mac Integration stuff
+ *
+ * Copyright (C) 2004 Albrecht Dreß <albrecht dress arcor de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option) 
+ * any later version.
+ *  
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
+ * GNU General Public License for more details.
+ *  
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
+ * 02111-1307, USA.
+ */
+ 
+#ifndef __MACOSX_HELPERS__
+#define __MACOSX_HELPERS__
+ 
+#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
+# include "config.h"
+#endif                          /* HAVE_CONFIG_H */
+
+#if HAVE_MACOSX_DESKTOP
+
+#include <gtk/gtk.h>
+
+void libbalsa_macosx_menu(GtkWidget * window, GtkMenuShell *menubar);
+void libbalsa_macosx_menu_for_parent(GtkWidget *window, GtkWindow *parent);
+
+#endif  /* HAVE_MACOSX_DESKTOP */
+
+#endif  /* __MACOSX_HELPERS__ */
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index 2ead376..9f26a39 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -48,6 +48,10 @@
 #  include "misc.h"
 #endif
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 #include "padlock-keyhole.xpm"
 #include <glib/gi18n.h>
 
@@ -1226,6 +1230,9 @@ check_gpg_child(gpointer data)
 				   GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
 				   _("Running %s successful:\n%s"),
 				   GPG_PATH, gpg_message);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, spawned_gpg->parent);
+#endif
     g_free(gpg_message);
     g_string_free(spawned_gpg->stderr_buf, TRUE);
     g_free(spawned_gpg);
@@ -1371,6 +1378,9 @@ select_key_from_list(const gchar * name, gboolean is_secret,
 					 GTK_STOCK_OK, GTK_RESPONSE_OK,
 					 GTK_STOCK_CANCEL,
 					 GTK_RESPONSE_CANCEL, NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, parent);
+#endif
     vbox = gtk_vbox_new(FALSE, 12);
     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox);
     gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
@@ -1525,6 +1535,9 @@ accept_low_trust_key(const gchar * name, gpgme_user_id_t uid,
 					   message1,
 					   message2,
 					   _("Use this key anyway?"));
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, parent);
+#endif
 			      
     /* ask the user */
     result = gtk_dialog_run(GTK_DIALOG(dialog));
@@ -1554,6 +1567,9 @@ get_passphrase_real(GMimeGpgmeContext * ctx, const gchar * uid_hint,
 					 GTK_STOCK_OK, GTK_RESPONSE_OK,
 					 GTK_STOCK_CANCEL,
 					 GTK_RESPONSE_CANCEL, NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, parent);
+#endif
     hbox = gtk_hbox_new(FALSE, 12);
     gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
diff --git a/libbalsa/smtp-server.c b/libbalsa/smtp-server.c
index bb8edc6..8d6b150 100644
--- a/libbalsa/smtp-server.c
+++ b/libbalsa/smtp-server.c
@@ -37,6 +37,10 @@
 #include "misc.h"
 #include <glib/gi18n.h>
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 static LibBalsaServerClass *parent_class = NULL;
 
 struct _LibBalsaSmtpServer {
@@ -538,6 +542,9 @@ libbalsa_smtp_server_dialog(LibBalsaSmtpServer * smtp_server,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_HELP, GTK_RESPONSE_HELP,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, parent);
+#endif
     g_object_weak_ref(G_OBJECT(dialog),
 		    (GWeakNotify) smtp_server_weak_notify, sdi);
     g_signal_connect(G_OBJECT(dialog), "response",
diff --git a/libbalsa/source-viewer.c b/libbalsa/source-viewer.c
index 9f8d5e4..3c29aa6 100644
--- a/libbalsa/source-viewer.c
+++ b/libbalsa/source-viewer.c
@@ -32,6 +32,7 @@
 #include "libbalsa.h"
 #include "libbalsa_private.h"
 #include "misc.h"
+#include "macosx-helpers.h"
 #include <glib/gi18n.h>
 
 static void close_cb(GtkAction * action, gpointer data);
@@ -253,6 +254,7 @@ libbalsa_show_message_source(LibBalsaMessage* msg, const gchar * font,
     GtkWidget *window;
     GtkAction *escape_action = NULL;
     LibBalsaSourceViewerInfo *lsvi;
+    GtkWidget *menubar;
 
     g_return_if_fail(msg);
     g_return_if_fail(MAILBOX_OPEN(msg->mailbox));
@@ -279,9 +281,14 @@ libbalsa_show_message_source(LibBalsaMessage* msg, const gchar * font,
     gtk_window_set_wmclass(GTK_WINDOW(window), "message-source", "Balsa");
     gtk_window_set_default_size(GTK_WINDOW(window), *width, *height);
     vbox = gtk_vbox_new(FALSE, 1);
-    gtk_box_pack_start(GTK_BOX(vbox), 
-                       lbsv_app_set_menus(GTK_WINDOW(window),
-                                          &escape_action), FALSE, TRUE, 1);
+    menubar = lbsv_app_set_menus(GTK_WINDOW(window), &escape_action);
+    
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu(window, GTK_MENU_SHELL(menubar));
+#else
+    gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 1);
+#endif
+    
     gtk_box_pack_start(GTK_BOX(vbox), interior, TRUE, TRUE, 0);
     gtk_container_add(GTK_CONTAINER(window), vbox);
 
diff --git a/src/ab-main.c b/src/ab-main.c
index efb27f3..d62a9d0 100644
--- a/src/ab-main.c
+++ b/src/ab-main.c
@@ -40,7 +40,7 @@
 #endif
 
 #if HAVE_MACOSX_DESKTOP
-#include <ige-mac-integration.h>
+#  include <ige-mac-integration.h>
 #endif
 
 #include "address-book.h"
diff --git a/src/address-book-config.c b/src/address-book-config.c
index 569140e..3103978 100644
--- a/src/address-book-config.c
+++ b/src/address-book-config.c
@@ -29,6 +29,10 @@
 #include "balsa-app.h"
 #include <glib/gi18n.h>
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 typedef struct _AddressBookConfig AddressBookConfig;
 struct _AddressBookConfig {
     GtkWidget *window;
@@ -236,6 +240,9 @@ create_local_dialog(AddressBookConfig * abc)
                                     action, GTK_RESPONSE_APPLY,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, abc->parent);
+#endif
     size_group = libbalsa_create_size_group(dialog);
 
     table = libbalsa_create_table(5, 2);
@@ -334,6 +341,9 @@ create_generic_dialog(AddressBookConfig * abc)
                                     action, GTK_RESPONSE_APPLY,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, abc->parent);
+#endif
     gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
     gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),
                                    12);
@@ -596,6 +606,9 @@ bad_path(gchar * path, GtkWindow * window, gint type)
                                  GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
                                  _("No path found.  "
 				   "Do you want to give one?"));
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(ask, window);
+#endif
     gtk_dialog_set_default_response(GTK_DIALOG(ask), GTK_RESPONSE_YES);
     clicked_button = gtk_dialog_run(GTK_DIALOG(ask));
     gtk_widget_destroy(ask);
diff --git a/src/balsa-app.c b/src/balsa-app.c
index cdd9b9e..e849f00 100644
--- a/src/balsa-app.c
+++ b/src/balsa-app.c
@@ -41,6 +41,10 @@
 #include "smtp-server.h"
 #include "save-restore.h"
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 #include <glib/gi18n.h>	/* Must come after balsa-app.h. */
 
 /* Global application structure */
@@ -94,6 +98,9 @@ ask_password_real(LibBalsaServer * server, LibBalsaMailbox * mbox)
                                          GTK_STOCK_OK, GTK_RESPONSE_OK,
                                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                          NULL); 
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(balsa_app.main_window));
+#endif
     gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), HIG_PADDING);
     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),
                       gtk_label_new_with_mnemonic(prompt));
diff --git a/src/balsa-icons.c b/src/balsa-icons.c
index 66eff2a..54be173 100644
--- a/src/balsa-icons.c
+++ b/src/balsa-icons.c
@@ -294,6 +294,7 @@ register_balsa_pixmaps(void)
     balsa_icon_table =
         g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
     gtk_icon_factory_add_default(factory);
+    gtk_icon_theme_append_search_path(icon_theme, BALSA_STD_PREFIX "/share/icons");
     gtk_icon_theme_append_search_path(icon_theme, BALSA_DATA_PREFIX);
 
     for (i = 0; i < ELEMENTS(balsa_icons); i++)
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 4cfd576..b302df6 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -52,6 +52,10 @@
 #include "misc.h"
 #include <glib/gi18n.h>
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 /* TREE_VIEW_FIXED_HEIGHT enables hight-performance mode of GtkTreeView
  * very useful for large mailboxes (#msg >5000)  */
 #define TREE_VIEW_FIXED_HEIGHT 1
@@ -2693,6 +2697,9 @@ balsa_index_pipe(BalsaIndex * index)
                                     _("_Run"), GTK_RESPONSE_OK,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(balsa_app.main_window));
+#endif
     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
     gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
 
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index eee1dc6..6f05269 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -35,6 +35,10 @@
 #include "mailbox-node.h"
 #include "main-window.h"
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 /* Column numbers (used for sort_column_id): */
 typedef enum {
     BMBL_TREE_COLUMN_NAME = 1,
@@ -1826,6 +1830,9 @@ bmbl_mru_show_tree(GtkWidget * widget, gpointer data)
         gtk_tree_view_get_selection(GTK_TREE_VIEW(mblist));
     GtkRequisition req;
 
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, mru->window);
+#endif
     scroll = gtk_scrolled_window_new(NULL, NULL);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
                                    GTK_POLICY_AUTOMATIC,
diff --git a/src/balsa-message.c b/src/balsa-message.c
index b65db21..afda17d 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -51,6 +51,10 @@
 #include "sendmsg-window.h"
 #include "libbalsa-vfs.h"
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 #ifdef HAVE_GPGME
 #  include "gmime-part-rfc2440.h"
 #endif
@@ -1667,6 +1671,9 @@ part_context_dump_all_cb(GtkWidget * menu_item, GList * info_list)
                                     GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dump_dialog, balsa_get_parent_window(menu_item));
+#endif
     gtk_dialog_set_default_response(GTK_DIALOG(dump_dialog),
                                     GTK_RESPONSE_CANCEL);
     gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dump_dialog),
@@ -2504,6 +2511,9 @@ create_mdn_dialog(GtkWindow *parent, gchar * sender, gchar * mdn_to_address,
                                  "Do you want to send "
                                  "this notification?"),
                                sender, mdn_to_address);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(mdn_dialog, parent);
+#endif
     gtk_window_set_title(GTK_WINDOW(mdn_dialog), _("Reply to MDN?"));
     g_object_set_data(G_OBJECT(mdn_dialog), "balsa-send-msg", send_msg);
     g_object_set_data(G_OBJECT(mdn_dialog), "mdn-ident",
diff --git a/src/balsa-mime-widget-callbacks.c b/src/balsa-mime-widget-callbacks.c
index 675bad5..8c677f1 100644
--- a/src/balsa-mime-widget-callbacks.c
+++ b/src/balsa-mime-widget-callbacks.c
@@ -33,6 +33,10 @@
 
 #include <gdk/gdkkeysyms.h>
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 
 void
 balsa_mime_widget_ctx_menu_cb(GtkWidget * menu_item,
@@ -82,6 +86,9 @@ balsa_mime_widget_ctx_menu_save(GtkWidget * parent_widget,
 				    GTK_FILE_CHOOSER_ACTION_SAVE,
 				    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 				    GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(save_dialog, balsa_get_parent_window(parent_widget));
+#endif
     gtk_dialog_set_default_response(GTK_DIALOG(save_dialog),
 				    GTK_RESPONSE_OK);
     g_free(title);
@@ -133,6 +140,9 @@ balsa_mime_widget_ctx_menu_save(GtkWidget * parent_widget,
 					 GTK_MESSAGE_QUESTION,
 					 GTK_BUTTONS_YES_NO,
 					 _("File already exists. Overwrite?"));
+#if HAVE_MACOSX_DESKTOP
+	libbalsa_macosx_menu_for_parent(confirm, GTK_WINDOW(balsa_app.main_window));
+#endif
 	do_save =
 	    (gtk_dialog_run(GTK_DIALOG(confirm)) == GTK_RESPONSE_YES);
 	gtk_widget_destroy(confirm);
diff --git a/src/filter-edit-callbacks.c b/src/filter-edit-callbacks.c
index 573d81c..38678bc 100644
--- a/src/filter-edit-callbacks.c
+++ b/src/filter-edit-callbacks.c
@@ -45,6 +45,10 @@
 #include "libbalsa-conf.h"
 #include "missing.h"
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 /* Defined in filter-edit-dialog.c*/
 extern option_list fe_search_type[4];
 extern GList * fe_user_headers_list;
@@ -1237,6 +1241,9 @@ fe_edit_condition(GtkWidget * throwaway,gpointer is_new_cnd)
                                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                         GTK_STOCK_HELP, GTK_RESPONSE_HELP,
                                         NULL);
+#if HAVE_MACOSX_DESKTOP
+	libbalsa_macosx_menu_for_parent(condition_dialog, GTK_WINDOW(fe_window));
+#endif
         g_object_add_weak_pointer(G_OBJECT(condition_dialog),
                                   (gpointer) &condition_dialog);
 
diff --git a/src/folder-conf.c b/src/folder-conf.c
index fc46073..b1e1f45 100644
--- a/src/folder-conf.c
+++ b/src/folder-conf.c
@@ -34,6 +34,10 @@
 #include "imap-server.h"
 #include <glib/gi18n.h>
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 typedef struct _CommonDialogData CommonDialogData;
 typedef struct _FolderDialogData FolderDialogData;
 typedef struct _SubfolderDialogData SubfolderDialogData;
@@ -297,6 +301,9 @@ folder_conf_imap_node(BalsaMailboxNode *mn)
                     mn ? _("_Update") : _("C_reate"), GTK_RESPONSE_OK,
                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                     GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL));
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(GTK_WIDGET(fcw->dialog), GTK_WINDOW(balsa_app.main_window));
+#endif
     g_object_add_weak_pointer(G_OBJECT(fcw->dialog),
                               (gpointer) &fcw->dialog);
     gtk_window_set_wmclass(GTK_WINDOW(fcw->dialog), 
@@ -552,6 +559,9 @@ browse_button_cb(GtkWidget * widget, SubfolderDialogData * sdd)
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_OK, GTK_RESPONSE_OK,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(sdd->dialog));
+#endif
     
     scroll = gtk_scrolled_window_new(NULL, NULL);
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scroll,
@@ -636,6 +646,9 @@ folder, parent);
                                                              _("Cancel"),
                                                              GTK_RESPONSE_CANCEL,
                                                              NULL);
+#if HAVE_MACOSX_DESKTOP
+		libbalsa_macosx_menu_for_parent(ask, GTK_WINDOW(sdd->dialog));
+#endif
                 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(ask)->vbox),
                                   gtk_label_new(msg));
                 g_free(msg);
@@ -768,6 +781,9 @@ folder_conf_imap_sub_node(BalsaMailboxNode * mn)
                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 
                     GTK_STOCK_HELP,   GTK_RESPONSE_HELP,
                     NULL));
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(GTK_WIDGET(sdd->dialog), GTK_WINDOW(balsa_app.main_window));
+#endif
     g_object_add_weak_pointer(G_OBJECT(sdd->dialog),
                               (gpointer) &sdd->dialog);
     /* `Enter' key => Create: */
@@ -857,6 +873,9 @@ folder_conf_delete(BalsaMailboxNode* mbnode)
                                    "You may use \"New IMAP Folder\" "
                                    "later to add this folder again.\n"),
                                  mbnode->name);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(ask, GTK_WINDOW(balsa_app.main_window));
+#endif
     gtk_window_set_title(GTK_WINDOW(ask), _("Confirm"));
 
     response = gtk_dialog_run(GTK_DIALOG(ask));
diff --git a/src/information-dialog.c b/src/information-dialog.c
index 607585b..7072f0e 100644
--- a/src/information-dialog.c
+++ b/src/information-dialog.c
@@ -34,6 +34,10 @@
 #include <glib/gi18n.h>
 #include "balsa-app.h"
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 static void balsa_information_bar(GtkWindow *parent,
                                   LibBalsaInformationType type,
                                   const char *msg);
@@ -180,6 +184,9 @@ balsa_information_dialog(GtkWindow *parent, LibBalsaInformationType type,
                                GTK_DIALOG_DESTROY_WITH_PARENT,
                                message_type, GTK_BUTTONS_CLOSE,
                                "%s", msg);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(messagebox, GTK_WINDOW(parent));
+#endif
 
     gtk_dialog_run(GTK_DIALOG(messagebox));
     gtk_widget_destroy(messagebox);
@@ -228,6 +235,9 @@ balsa_information_list(GtkWindow *parent, LibBalsaInformationType type,
                                         GTK_STOCK_CLEAR, GTK_RESPONSE_APPLY,
                                         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                         NULL);
+#if HAVE_MACOSX_DESKTOP
+	libbalsa_macosx_menu_for_parent(information_dialog, parent);
+#endif
 	/* Default is to close */
 	gtk_dialog_set_default_response(GTK_DIALOG(information_dialog), 
                                         GTK_RESPONSE_CLOSE);
diff --git a/src/mailbox-conf.c b/src/mailbox-conf.c
index 9e108d8..e1617e6 100644
--- a/src/mailbox-conf.c
+++ b/src/mailbox-conf.c
@@ -59,6 +59,10 @@
 #include "libbalsa-conf.h"
 #include <glib/gi18n.h>
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 struct _BalsaMailboxConfView {
     GtkWindow *window;
     GtkWidget *identity_combo_box;
@@ -439,6 +443,9 @@ mailbox_conf_delete(BalsaMailboxNode * mbnode)
                                NULL);
     }
     
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(ask, GTK_WINDOW(balsa_app.main_window));
+#endif
     button = gtk_dialog_run(GTK_DIALOG(ask));
     gtk_widget_destroy(ask);
 
@@ -1103,6 +1110,9 @@ create_local_mailbox_dialog(MailboxConfWindow *mcw)
                                     mcw->ok_button_name, MCW_RESPONSE,
                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(balsa_app.main_window));
+#endif
 
     size_group = libbalsa_create_size_group(dialog);
     if (label)
@@ -1136,6 +1146,9 @@ create_generic_dialog(MailboxConfWindow * mcw)
                                     mcw->ok_button_name, MCW_RESPONSE,
                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(balsa_app.main_window));
+#endif
     return dialog;
 }
 
diff --git a/src/main-window.c b/src/main-window.c
index ed26a5d..f5e61be 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -41,7 +41,8 @@
 #include <glib/gi18n.h>
  
 #if HAVE_MACOSX_DESKTOP
-#include <ige-mac-integration.h>
+#  include <ige-mac-integration.h>
+#  include "macosx-helpers.h"
 #endif
 
 #include "ab-window.h"
@@ -311,6 +312,12 @@ bw_quit_nicely(GtkAction * action, gpointer data)
    proponents of GNOME2 dumbify approach (OK, I am bit unfair here).
 */
 
+#if HAVE_MACOSX_DESKTOP
+#define MAC_MODIFIER    "<alt>"
+#else
+#define MAC_MODIFIER
+#endif
+
 /* Actions that are always sensitive: */
 static const GtkActionEntry entries[] = {
     /* Menus */
@@ -338,7 +345,7 @@ static const GtkActionEntry entries[] = {
     /* File menu items */
     /* Not in the touchpad menu, but still available as a toolbar
      * button: */
-    {"Continue", BALSA_PIXMAP_CONTINUE, N_("_Continue"), "C",
+    {"Continue", BALSA_PIXMAP_CONTINUE, N_("_Continue"), MAC_MODIFIER "C",
      N_("Continue editing current message"),
      G_CALLBACK(bw_continue_message_cb)},
     {"GetNewMail", BALSA_PIXMAP_RECEIVE, N_("_Get New Mail"), "<control>M",
@@ -352,12 +359,12 @@ static const GtkActionEntry entries[] = {
      G_CALLBACK(bw_send_receive_messages_cb)},
     {"PageSetup", NULL, N_("Page _Setup"), NULL,
      N_("Set up page for printing"), G_CALLBACK(bw_page_setup_cb)},
-    {"AddressBook", BALSA_PIXMAP_BOOK_RED, N_("_Address Book..."), "B",
+    {"AddressBook", BALSA_PIXMAP_BOOK_RED, N_("_Address Book..."), MAC_MODIFIER "B",
      N_("Open the address book"), G_CALLBACK(bw_address_book_cb)},
     {"Quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", N_("Quit Balsa"),
      G_CALLBACK(bw_quit_nicely)},
     /* File:New submenu items */
-    {"NewMessage", BALSA_PIXMAP_COMPOSE, N_("_Message..."), "M",
+    {"NewMessage", BALSA_PIXMAP_COMPOSE, N_("_Message..."), MAC_MODIFIER "M",
      N_("Compose a new message"), G_CALLBACK(bw_new_message_cb)},
 #if !defined(ENABLE_TOUCH_UI)
     {"NewMbox", GTK_STOCK_ADD, N_("Local mbox mailbox..."), NULL,
@@ -439,9 +446,9 @@ static const GtkActionEntry mailbox_entries[] = {
     {"FindNext", GTK_STOCK_FIND, N_("Find Ne_xt"), "<control>G", NULL,
      G_CALLBACK(bw_find_again_cb)},
     /* Mailbox menu items */
-    {"NextMessage", BALSA_PIXMAP_NEXT, N_("Next Message"), "N",
+    {"NextMessage", BALSA_PIXMAP_NEXT, N_("Next Message"), MAC_MODIFIER "N",
      N_("Next Message"), G_CALLBACK(bw_next_message_cb)},
-    {"PreviousMessage", BALSA_PIXMAP_PREVIOUS, N_("Previous Message"), "P",
+    {"PreviousMessage", BALSA_PIXMAP_PREVIOUS, N_("Previous Message"), MAC_MODIFIER "P",
      N_("Previous Message"), G_CALLBACK(bw_previous_message_cb)},
     {"NextFlagged", BALSA_PIXMAP_NEXT_FLAGGED, N_("Next Flagged Message"),
      "<control><alt>F", N_("Next Flagged Message"),
@@ -481,14 +488,14 @@ static const GtkActionEntry mailbox_entries[] = {
  * selected: */
 static const GtkActionEntry message_entries[] = { 
     /* Message menu items */
-    {"Reply", BALSA_PIXMAP_REPLY, N_("_Reply..."), "R",
+    {"Reply", BALSA_PIXMAP_REPLY, N_("_Reply..."), MAC_MODIFIER "R",
      N_("Reply to the current message"), G_CALLBACK(bw_replyto_message_cb)},
-    {"ReplyAll", BALSA_PIXMAP_REPLY_ALL, N_("Reply to _All..."), "A",
+    {"ReplyAll", BALSA_PIXMAP_REPLY_ALL, N_("Reply to _All..."), MAC_MODIFIER "A",
      N_("Reply to all recipients of the current message"),
      G_CALLBACK(bw_replytoall_message_cb)},
-    {"ReplyGroup", BALSA_PIXMAP_REPLY_GROUP, N_("Reply to _Group..."), "G",
+    {"ReplyGroup", BALSA_PIXMAP_REPLY_GROUP, N_("Reply to _Group..."), MAC_MODIFIER "G",
      N_("Reply to mailing list"), G_CALLBACK(bw_replytogroup_message_cb)},
-    {"StoreAddress", BALSA_PIXMAP_BOOK_RED, N_("_Store Address..."), "S",
+    {"StoreAddress", BALSA_PIXMAP_BOOK_RED, N_("_Store Address..."), MAC_MODIFIER "S",
      N_("Store address of sender in addressbook"),
      G_CALLBACK(bw_store_address_cb)},
     {"ViewSource", BALSA_PIXMAP_BOOK_OPEN, N_("_View Source..."),
@@ -498,11 +505,11 @@ static const GtkActionEntry message_entries[] = {
      * stock_id; the first in this list defines the action tied to the
      * toolbar's Forward button, so "ForwardDefault" must come before
      * the others. */
-    {"ForwardDefault", BALSA_PIXMAP_FORWARD, N_("_Forward..."), "F",
+    {"ForwardDefault", BALSA_PIXMAP_FORWARD, N_("_Forward..."), MAC_MODIFIER "F",
      N_("Forward the current message"),
      G_CALLBACK(bw_forward_message_default_cb)},
 #if !defined(ENABLE_TOUCH_UI)
-    {"ForwardAttached", BALSA_PIXMAP_FORWARD, N_("_Forward attached..."), "F",
+    {"ForwardAttached", BALSA_PIXMAP_FORWARD, N_("_Forward attached..."), MAC_MODIFIER "F",
      N_("Forward the current message as attachment"),
      G_CALLBACK(bw_forward_message_attached_cb)},
     {"ForwardInline", BALSA_PIXMAP_FORWARD, N_("Forward _inline..."), NULL,
@@ -535,7 +542,7 @@ static const GtkActionEntry current_message_entries[] = {
      N_("Copy message"), G_CALLBACK(bw_message_copy_cb)},
     {"SelectText", NULL, N_("_Select Text"), NULL,
      N_("Select entire mail"), G_CALLBACK(bw_message_select_all_cb)},
-    {"FindInMessage", NULL, N_("Find in _Message"), "slash",
+    {"FindInMessage", NULL, N_("Find in _Message"), MAC_MODIFIER "slash",
      N_("Find a string in this message"),
      G_CALLBACK(bw_find_in_message_cb)}
 #endif /* ENABLE_TOUCH_UI */
@@ -546,11 +553,11 @@ static const GtkActionEntry current_message_entries[] = {
 static const GtkActionEntry modify_message_entries[] = { 
     /* Message menu items */
 #if !defined(ENABLE_TOUCH_UI)
-    {"MoveToTrash", GTK_STOCK_DELETE, N_("_Move to Trash"), "D",
+    {"MoveToTrash", GTK_STOCK_DELETE, N_("_Move to Trash"), MAC_MODIFIER "D",
      N_("Move the current message to Trash mailbox"),
      G_CALLBACK(bw_trash_message_cb)},
 #else  /* ENABLE_TOUCH_UI */
-    {"MoveToTrash", GTK_STOCK_DELETE, N_("_Delete to Trash"), "D",
+    {"MoveToTrash", GTK_STOCK_DELETE, N_("_Delete to Trash"), MAC_MODIFIER "D",
      N_("Move the current message to Trash mailbox"),
      G_CALLBACK(bw_trash_message_cb)},
     {"ToolbarToggleNew", BALSA_PIXMAP_MARKED_NEW, N_("_New"), NULL,
@@ -558,7 +565,7 @@ static const GtkActionEntry modify_message_entries[] = {
 #endif /* ENABLE_TOUCH_UI */
     {"MessageToggleFlagMenu", NULL, N_("_Toggle Flag")},
     /* Message:toggle-flag submenu items */
-    {"ToggleFlagged", BALSA_PIXMAP_INFO_FLAGGED, N_("_Flagged"), "X",
+    {"ToggleFlagged", BALSA_PIXMAP_INFO_FLAGGED, N_("_Flagged"), MAC_MODIFIER "X",
      N_("Toggle flagged"), G_CALLBACK(bw_toggle_flagged_message_cb)},
     {"ToggleDeleted", GTK_STOCK_DELETE, N_("_Deleted"), "<control>D",
      N_("Toggle deleted flag"), G_CALLBACK(bw_toggle_deleted_message_cb)},
@@ -1641,6 +1648,7 @@ balsa_window_new()
     ige_mac_menu_add_app_menu_item(group,
                                   GTK_MENU_ITEM(gtk_ui_manager_get_widget(ui_manager, "/MainMenu/EditMenu/Preferences")), 
                                    NULL);
+    libbalsa_macosx_menu(GTK_WIDGET(window), GTK_MENU_SHELL(menubar));
 #else
     gtk_box_pack_start(GTK_BOX(window->vbox), menubar, FALSE, FALSE, 0);
 #endif
@@ -2750,6 +2758,9 @@ ensure_check_mail_dialog(BalsaWindow * window)
                                     GTK_DIALOG_DESTROY_WITH_PARENT,
                                     _("_Hide"), GTK_RESPONSE_CLOSE,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(progress_dialog, GTK_WINDOW(window));
+#endif
     gtk_window_set_wmclass(GTK_WINDOW(progress_dialog), 
 			   "progress_dialog", "Balsa");
         
@@ -3518,6 +3529,9 @@ balsa_window_next_unread(BalsaWindow * window)
                                GTK_BUTTONS_YES_NO,
                                _("The next unread message is in %s"),
                                mailbox->name);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(window));
+#endif
     gtk_message_dialog_format_secondary_text
         (GTK_MESSAGE_DIALOG(dialog),
          _("Do you want to switch to %s?"), mailbox->name);
@@ -4036,6 +4050,9 @@ bw_find_real(BalsaWindow * window, BalsaIndex * bindex, gboolean again)
         GtkToggleButton *matching_to, *matching_cc, *matching_subject;
 	gint ok;
 	
+#if HAVE_MACOSX_DESKTOP
+	libbalsa_macosx_menu_for_parent(dia, GTK_WINDOW(window));
+#endif
         vbox = GTK_DIALOG(dia)->vbox;
 
 	page=gtk_table_new(2, 1, FALSE);
diff --git a/src/message-window.c b/src/message-window.c
index 58615dd..86d1e90 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -36,6 +36,10 @@
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 /* callbacks */
 static void destroy_message_window(GtkWidget * widget, MessageWindow * mw);
 static void mw_expunged_cb(LibBalsaMailbox * mailbox, guint msgno,
@@ -567,7 +571,11 @@ message_window_new(LibBalsaMailbox * mailbox, guint msgno)
     }
 
     menubar = gtk_ui_manager_get_widget(ui_manager, "/MainMenu");
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu(window, GTK_MENU_SHELL(menubar));
+#else
     gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
+#endif
 
     toolbar = balsa_toolbar_new(model, ui_manager);
     gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
diff --git a/src/pref-manager.c b/src/pref-manager.c
index 0102eee..d52cb79 100644
--- a/src/pref-manager.c
+++ b/src/pref-manager.c
@@ -37,6 +37,10 @@
 #include "misc.h"
 #include "imap-server.h"
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 #if ENABLE_ESMTP
 #include <libesmtp.h>
 #include <string.h>
@@ -516,6 +520,9 @@ open_preferences_manager(GtkWidget * widget, gpointer data)
                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                     GTK_STOCK_HELP, GTK_RESPONSE_HELP,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(property_box, GTK_WINDOW(active_win));
+#endif
 
     hbox = gtk_hbox_new(FALSE, 12);
     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(property_box)->vbox), hbox);
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 85d8bc0..7ffa09a 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -51,11 +51,6 @@
 #include <unistd.h>
 #endif
 #include <errno.h>
- 
-#if HAVE_MACOSX_DESKTOP
-#include <ige-mac-integration.h>
-#endif
-
 #include "libbalsa.h"
 #include "misc.h"
 #include "send.h"
@@ -75,6 +70,8 @@
 #include "ab-window.h"
 #include "address-view.h"
 #include "print.h"
+#include "macosx-helpers.h"
+
 #if HAVE_GTKSPELL
 #include "gtkspell/gtkspell.h"
 #else                           /* HAVE_GTKSPELL */
@@ -913,6 +910,9 @@ delete_handler(BalsaSendmsg * bsmsg)
                                GTK_BUTTONS_YES_NO,
                                _("The message to '%s' is modified.\n"
                                  "Save message to Draftbox?"), tmp);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(d, GTK_WINDOW(bsmsg->window));
+#endif
     g_object_unref(list);
     gtk_dialog_set_default_response(GTK_DIALOG(d), GTK_RESPONSE_YES);
     gtk_dialog_add_button(GTK_DIALOG(d),
@@ -1742,6 +1742,9 @@ change_attach_mode(GtkWidget * menu_item, BalsaAttachInfo *info)
 				     "Do you really want to attach "
 				     "this file as reference?"),
 				   libbalsa_vfs_get_uri_utf8(info->file_uri));
+#if HAVE_MACOSX_DESKTOP
+	libbalsa_macosx_menu_for_parent(extbody_dialog, GTK_WINDOW(parent));
+#endif
 	gtk_window_set_title(GTK_WINDOW(extbody_dialog),
 			     _("Attach as Reference?"));
 	result = gtk_dialog_run(GTK_DIALOG(extbody_dialog));
@@ -1849,6 +1852,10 @@ sw_get_user_codeset(BalsaSendmsg * bsmsg, gboolean * change_type,
     GtkWidget *info = gtk_label_new(msg);
     GtkWidget *charset_button = libbalsa_charset_button_new();
 
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(bsmsg->window));
+#endif
+
     g_free(msg);
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), info,
                        FALSE, TRUE, 5);
@@ -2293,6 +2300,9 @@ sw_attach_dialog(BalsaSendmsg * bsmsg)
                                     GTK_FILE_CHOOSER_ACTION_OPEN,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(fsw, GTK_WINDOW(bsmsg->window));
+#endif
     gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(fsw),
                                     libbalsa_vfs_local_only());
     gtk_window_set_destroy_with_parent(GTK_WINDOW(fsw), TRUE);
@@ -3591,6 +3601,9 @@ quote_parts_select_dlg(GtkTreeStore *tree_store, GtkWindow * parent)
 					 GTK_DIALOG_DESTROY_WITH_PARENT,
 					 GTK_STOCK_OK, GTK_RESPONSE_OK,
 					 NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, parent);
+#endif
 
     label = gtk_label_new(_("Select the parts of the message which shall be quoted in the reply"));
     gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
@@ -4548,9 +4561,8 @@ sendmsg_window_new()
     }
 
     menubar = gtk_ui_manager_get_widget(ui_manager, "/MainMenu");
-#if 0 && HAVE_MACOSX_DESKTOP
-    /* FIXME - this call destroys the main balsa menu after closing the composer... */
-    ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(menubar));
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu(window, GTK_MENU_SHELL(menubar));
 #else
     gtk_box_pack_start(GTK_BOX(main_box), menubar, FALSE, FALSE, 0);
 #endif
@@ -5197,6 +5209,9 @@ sendmsg_window_set_field(BalsaSendmsg * bsmsg, const gchar * key,
                    "a \"Blind copy\" (Bcc) address.\n"
                    "Please check that the address\n"
                    "is appropriate."));
+#if HAVE_MACOSX_DESKTOP
+            libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(bsmsg->window));
+#endif
             g_object_set_data(G_OBJECT(bsmsg->window),
                               "balsa-sendmsg-window-url-bcc", dialog);
             g_signal_connect(G_OBJECT(dialog), "response",
@@ -5327,6 +5342,9 @@ include_file_cb(GtkAction * action, BalsaSendmsg * bsmsg)
                                     GTK_FILE_CHOOSER_ACTION_OPEN,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(file_selector, GTK_WINDOW(bsmsg->window));
+#endif
     gtk_window_set_destroy_with_parent(GTK_WINDOW(file_selector), TRUE);
     /* Use the same folder as for attachments. */
     if (balsa_app.attach_dir)
@@ -5760,6 +5778,9 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
                "to protect your privacy, the message could be %s encrypted."),
              gpgme_get_protocol_name(protocol),
              gpgme_get_protocol_name(protocol));
+#if HAVE_MACOSX_DESKTOP
+        libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(bsmsg->window));
+#endif
 
 	dialog_action_area = GTK_DIALOG(dialog)->action_area;
 	gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area), GTK_BUTTONBOX_END);
@@ -5869,6 +5890,9 @@ send_message_handler(BalsaSendmsg * bsmsg, gboolean queue_only)
                  GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
                  GTK_MESSAGE_QUESTION,
                  GTK_BUTTONS_OK_CANCEL, "%s", message->str);
+#if HAVE_MACOSX_DESKTOP
+	    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(bsmsg->window));
+#endif
             g_string_free(message, TRUE);
             choice = gtk_dialog_run(GTK_DIALOG(dialog));
             gtk_widget_destroy(dialog);
@@ -7009,6 +7033,9 @@ bsmsg_check_format_compatibility(GtkWindow *parent, const gchar *filename)
          GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT,
          GTK_STOCK_CANCEL,                   GTK_RESPONSE_CANCEL,
          "_Attach it in the current format", GTK_RESPONSE_OK, NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(GTK_WIDGET(dialog), parent);
+#endif
 
     gtk_dialog_set_default_response(dialog, GTK_RESPONSE_OK);
     str = g_strdup_printf
diff --git a/src/store-address.c b/src/store-address.c
index 1f1207f..15f17fb 100644
--- a/src/store-address.c
+++ b/src/store-address.c
@@ -27,6 +27,10 @@
 #include <string.h>
 #include <glib/gi18n.h>
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 #include "balsa-app.h"
 
 /* global data */
@@ -207,6 +211,9 @@ store_address_dialog(StoreAddressInfo * info)
     GtkWidget *vbox = GTK_DIALOG(dialog)->vbox;
     GtkWidget *frame, *label;
 
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(dialog, GTK_WINDOW(balsa_app.main_window));
+#endif
     frame = store_address_book_frame(info);
     if(g_list_length(balsa_app.address_book_list)>1)
         gtk_widget_show_all(frame);
diff --git a/src/threads.h b/src/threads.h
index da1d497..e13cbf3 100644
--- a/src/threads.h
+++ b/src/threads.h
@@ -21,6 +21,9 @@
 
 #ifndef __THREADS_H__
 #define __THREADS_H__
+
+#include <unistd.h>
+
 /* FIXME: mailbox_lock is really an internal libbalsa mutex. */
 extern pthread_mutex_t mailbox_lock;
 
diff --git a/src/toolbar-prefs.c b/src/toolbar-prefs.c
index de0f462..f942605 100644
--- a/src/toolbar-prefs.c
+++ b/src/toolbar-prefs.c
@@ -34,6 +34,10 @@
 #include "sendmsg-window.h"
 #include "toolbar-factory.h"
 
+#if HAVE_MACOSX_DESKTOP
+#  include "macosx-helpers.h"
+#endif
+
 #ifndef MAX
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 #endif
@@ -136,6 +140,9 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                     GTK_STOCK_HELP,  GTK_RESPONSE_HELP,
                                     NULL);
+#if HAVE_MACOSX_DESKTOP
+    libbalsa_macosx_menu_for_parent(customize_widget, GTK_WINDOW(active_window));
+#endif
     g_object_add_weak_pointer(G_OBJECT(customize_widget),
                               (gpointer) & customize_widget);
     g_signal_connect(G_OBJECT(customize_widget), "response",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]