fix bug 4239, 'Preferences: Text Options Header Display modal is not modal' (sic)
[claws.git] / src / importmutt.c
index 49aea518f96e302e7cb999bac5b368c3727a0654..967b74ba466ed05adbb4e007c09726747e4973ca 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2007 Match Grun and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2001-2015 Match Grun and the Claws Mail team
  *
  * 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 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
  * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
@@ -23,6 +22,7 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include "defs.h"
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkbutton.h>
+#include <gtk/gtk.h>
 
 #include "addrbook.h"
 #include "addressbook.h"
@@ -66,7 +61,7 @@ static AddressIndex *_imp_addressIndex_;
 /*
 * Edit functions.
 */
-void imp_mutt_status_show( gchar *msg ) {
+static void imp_mutt_status_show( gchar *msg ) {
        if( impmutt_dlg.statusbar != NULL ) {
                gtk_statusbar_pop( GTK_STATUSBAR(impmutt_dlg.statusbar), impmutt_dlg.status_cid );
                if( msg ) {
@@ -104,6 +99,8 @@ static gboolean imp_mutt_import_file( gchar *sName, gchar *sFile ) {
                addrbook_free_book( abf );
        }
 
+       mutt_free(mdf);
+
        return retVal;
 }
 
@@ -114,11 +111,11 @@ static void imp_mutt_ok( GtkWidget *widget, gboolean *cancelled ) {
        gboolean errFlag = FALSE;
 
        sFile = gtk_editable_get_chars( GTK_EDITABLE(impmutt_dlg.file_entry), 0, -1 );
-       g_strchug( sFile ); g_strchomp( sFile );
+       g_strstrip( sFile );
        gtk_entry_set_text( GTK_ENTRY(impmutt_dlg.file_entry), sFile );
 
        sName = gtk_editable_get_chars( GTK_EDITABLE(impmutt_dlg.name_entry), 0, -1 );
-       g_strchug( sName ); g_strchomp( sName );
+       g_strstrip( sName );
        gtk_entry_set_text( GTK_ENTRY(impmutt_dlg.name_entry), sName );
 
        if( *sFile == '\0'|| strlen( sFile ) < 1 ) {
@@ -178,7 +175,7 @@ static gint imp_mutt_delete_event( GtkWidget *widget, GdkEventAny *event, gboole
 }
 
 static gboolean imp_mutt_key_pressed( GtkWidget *widget, GdkEventKey *event, gboolean *cancelled ) {
-       if (event && event->keyval == GDK_Escape) {
+       if (event && event->keyval == GDK_KEY_Escape) {
                *cancelled = TRUE;
                gtk_main_quit();
        }
@@ -200,12 +197,12 @@ static void imp_mutt_create( gboolean *cancelled ) {
        GtkWidget *hsbox;
        gint top;
 
-       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "importmutt");
        gtk_widget_set_size_request(window, 450, -1);
        gtk_container_set_border_width( GTK_CONTAINER(window), 0 );
        gtk_window_set_title( GTK_WINDOW(window), _("Import MUTT file into Address Book") );
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
-       gtk_window_set_modal(GTK_WINDOW(window), TRUE); 
+       gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(imp_mutt_delete_event), cancelled);
        g_signal_connect(G_OBJECT(window), "key_press_event",
@@ -287,6 +284,7 @@ AddressBookFile *addressbook_imp_mutt( AddressIndex *addrIndex ) {
        gtk_widget_grab_focus(impmutt_dlg.file_entry);
        gtk_widget_show(impmutt_dlg.window);
        manage_window_set_transient(GTK_WINDOW(impmutt_dlg.window));
+       gtk_window_set_modal(GTK_WINDOW(impmutt_dlg.window), TRUE);
 
        imp_mutt_status_show( _( "Please select a file to import." ) );
        muttFile = mutt_find_file();
@@ -297,6 +295,7 @@ AddressBookFile *addressbook_imp_mutt( AddressIndex *addrIndex ) {
 
        gtk_main();
        gtk_widget_hide(impmutt_dlg.window);
+       gtk_window_set_modal(GTK_WINDOW(impmutt_dlg.window), FALSE);
        _imp_addressIndex_ = NULL;
 
        if (cancelled == TRUE) return NULL;