fix bug 4239, 'Preferences: Text Options Header Display modal is not modal' (sic)
[claws.git] / src / sourcewindow.c
index ecf0041f07cba6c2c5c62f9ca7d7909a3771fcfb..f188c0fb69a3599d2d87b6ac1151314b5a932728 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto 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
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktext.h>
-#include <gtk/gtkstyle.h>
+#include <gtk/gtk.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -35,6 +30,7 @@
 #include "utils.h"
 #include "gtkutils.h"
 #include "prefs_common.h"
+#include "file-utils.h"
 
 static void source_window_size_alloc_cb        (GtkWidget      *widget,
                                         GtkAllocation  *allocation);
@@ -68,6 +64,7 @@ SourceWindow *source_window_create(void)
        window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "sourcewindow");
        gtk_window_set_title(GTK_WINDOW(window), _("Source of the message"));
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
+       gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
        gtk_widget_set_size_request(window, prefs_common.sourcewin_width,
                                    prefs_common.sourcewin_height);
        
@@ -139,7 +136,7 @@ void source_window_show_msg(SourceWindow *sourcewin, MsgInfo *msginfo)
        FILE *fp;
        gchar buf[BUFFSIZE];
 
-       g_return_if_fail(msginfo != NULL);
+       cm_return_if_fail(msginfo != NULL);
 
        sourcewin->updating = TRUE;
        file = procmsg_get_message_file(msginfo);
@@ -151,10 +148,10 @@ void source_window_show_msg(SourceWindow *sourcewin, MsgInfo *msginfo)
                return;
        }
 
-       g_return_if_fail(file != NULL);
+       cm_return_if_fail(file != NULL);
 
-       if ((fp = g_fopen(file, "rb")) == NULL) {
-               FILE_OP_ERROR(file, "fopen");
+       if ((fp = claws_fopen(file, "rb")) == NULL) {
+               FILE_OP_ERROR(file, "claws_fopen");
                g_free(file);
                return;
        }
@@ -166,10 +163,10 @@ void source_window_show_msg(SourceWindow *sourcewin, MsgInfo *msginfo)
        g_free(title);
        g_free(file);
 
-       while (fgets(buf, sizeof(buf), fp) != NULL)
+       while (claws_fgets(buf, sizeof(buf), fp) != NULL)
                source_window_append(sourcewin, buf);
 
-       fclose(fp);
+       claws_fclose(fp);
 }
 
 static void source_window_append(SourceWindow *sourcewin, const gchar *str)
@@ -191,7 +188,7 @@ static void source_window_append(SourceWindow *sourcewin, const gchar *str)
 static void source_window_size_alloc_cb(GtkWidget *widget,
                                        GtkAllocation *allocation)
 {
-       g_return_if_fail(allocation != NULL);
+       cm_return_if_fail(allocation != NULL);
 
        prefs_common.sourcewin_width  = allocation->width;
        prefs_common.sourcewin_height = allocation->height;
@@ -207,21 +204,15 @@ static gint source_window_delete_cb(GtkWidget *widget, GdkEventAny *event,
 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
                            SourceWindow *sourcewin)
 {
-
        if (!event || !sourcewin) return FALSE;
-       
+
        switch (event->keyval) {
-       case GDK_A:
-       case GDK_a:
-               if ((event->state & GDK_CONTROL_MASK) != 0)
-                       gtk_editable_select_region(GTK_EDITABLE(sourcewin->text), 0, -1);
-               break;
-       case GDK_W:
-       case GDK_w:
+       case GDK_KEY_W:
+       case GDK_KEY_w:
                if ((event->state & GDK_CONTROL_MASK) != 0)
                        gtk_widget_destroy(sourcewin->window);
                break;
-       case GDK_Escape:
+       case GDK_KEY_Escape:
                source_window_destroy(sourcewin);
                return TRUE;
                break;