fix bug 4239, 'Preferences: Text Options Header Display modal is not modal' (sic)
[claws.git] / src / editgroup.c
index 360c8fd824f07fb2506658fd481910b012c30e15..c1c96c36b5bb561b0e845a0592823f5815119357 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
@@ -19,6 +19,7 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include "defs.h"
@@ -114,7 +115,7 @@ static gint edit_group_delete_event(GtkWidget *widget, GdkEventAny *event, gbool
 }
 
 static gboolean edit_group_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();
        }
@@ -214,6 +215,7 @@ static void edit_group_to_avail( GtkWidget *widget, gpointer data ) {
 
 static gboolean edit_group_list_group_button( GtkCMCList *clist, GdkEventButton *event, gpointer data ) {
        if( ! event ) return FALSE;
+       if( event->window != clist->clist_window ) return FALSE;
 
        if( event->button == 1 ) {
                if( event->type == GDK_2BUTTON_PRESS ) {
@@ -225,6 +227,7 @@ static gboolean edit_group_list_group_button( GtkCMCList *clist, GdkEventButton
 
 static gboolean edit_group_list_avail_button( GtkCMCList *clist, GdkEventButton *event, gpointer data ) {
        if( ! event ) return FALSE;
+       if( event->window != clist->clist_window ) return FALSE;
 
        if( event->button == 1 ) {
                if( event->type == GDK_2BUTTON_PRESS ) {
@@ -248,7 +251,7 @@ static gint edit_group_list_compare_func( GtkCMCList *clist, gconstpointer ptr1,
 static void addressbook_edit_group_size_allocate_cb(GtkWidget *widget,
                                         GtkAllocation *allocation)
 {
-       g_return_if_fail(allocation != NULL);
+       cm_return_if_fail(allocation != NULL);
 
        prefs_common.addressbookeditgroupwin_width = allocation->width;
        prefs_common.addressbookeditgroupwin_height = allocation->height;
@@ -292,7 +295,7 @@ static void addressbook_edit_group_create( gboolean *cancelled ) {
        gtk_container_set_border_width(GTK_CONTAINER(window), 0);
        gtk_window_set_title(GTK_WINDOW(window), _("Edit Group Data"));
        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(edit_group_delete_event),
                         cancelled);
@@ -350,26 +353,19 @@ static void addressbook_edit_group_create( gboolean *cancelled ) {
                                       GTK_POLICY_AUTOMATIC,
                                       GTK_POLICY_AUTOMATIC);
 
-       clist_group = gtk_sctree_new_with_titles( GROUP_N_COLS, GROUP_N_COLS, titles );
+       clist_group = gtk_sctree_new_with_titles( GROUP_N_COLS, 0, titles );
        gtk_container_add( GTK_CONTAINER(clist_swin), clist_group );
-       if (prefs_common.enable_dotted_lines) {
-               gtk_cmctree_set_line_style(GTK_CMCTREE(clist_group), GTK_CMCTREE_LINES_DOTTED);
-               gtk_cmctree_set_expander_style(GTK_CMCTREE(clist_group),
-                                    GTK_CMCTREE_EXPANDER_SQUARE);
-       } else {
-               gtk_cmctree_set_line_style(GTK_CMCTREE(clist_group), GTK_CMCTREE_LINES_NONE);
-               gtk_cmctree_set_expander_style(GTK_CMCTREE(clist_group),
-                                    GTK_CMCTREE_EXPANDER_TRIANGLE);
-       }
+       gtk_cmctree_set_expander_style(GTK_CMCTREE(clist_group),
+                            GTK_CMCTREE_EXPANDER_TRIANGLE);
        gtk_sctree_set_stripes(GTK_SCTREE(clist_group), prefs_common.use_stripes_in_summaries);
-       gtk_cmclist_set_selection_mode( GTK_CMCLIST(clist_group), GTK_SELECTION_EXTENDED );
+       gtk_cmclist_set_selection_mode( GTK_CMCLIST(clist_group), GTK_SELECTION_MULTIPLE );
        gtk_cmclist_set_column_width( GTK_CMCLIST(clist_group), GROUP_COL_NAME, GROUP_COL_WIDTH_NAME );
        gtk_cmclist_set_column_width( GTK_CMCLIST(clist_group), GROUP_COL_EMAIL, GROUP_COL_WIDTH_EMAIL );
        gtk_cmclist_set_compare_func( GTK_CMCLIST(clist_group), edit_group_list_compare_func );
        gtk_cmclist_set_auto_sort( GTK_CMCLIST(clist_group), TRUE );
 
        for( i = 0; i < GROUP_N_COLS; i++ )
-               GTK_WIDGET_UNSET_FLAGS(GTK_CMCLIST(clist_group)->column[i].button, GTK_CAN_FOCUS);
+               gtk_widget_set_can_focus(GTK_CMCLIST(clist_group)->column[i].button, FALSE);
 
        /* Available list */
        vboxl = gtk_vbox_new( FALSE, 0 );
@@ -389,16 +385,18 @@ static void addressbook_edit_group_create( gboolean *cancelled ) {
                                       GTK_POLICY_AUTOMATIC,
                                       GTK_POLICY_AUTOMATIC);
 
-       clist_avail = gtk_sctree_new_with_titles( GROUP_N_COLS, GROUP_N_COLS, titles );
+       clist_avail = gtk_sctree_new_with_titles( GROUP_N_COLS, 0, titles );
        gtk_container_add( GTK_CONTAINER(clist_swin), clist_avail );
-       gtk_cmclist_set_selection_mode( GTK_CMCLIST(clist_avail), GTK_SELECTION_EXTENDED );
+       gtk_cmctree_set_expander_style(GTK_CMCTREE(clist_avail),
+                            GTK_CMCTREE_EXPANDER_TRIANGLE);
+       gtk_cmclist_set_selection_mode( GTK_CMCLIST(clist_avail), GTK_SELECTION_MULTIPLE );
        gtk_cmclist_set_column_width( GTK_CMCLIST(clist_avail), GROUP_COL_NAME, GROUP_COL_WIDTH_NAME );
        gtk_cmclist_set_column_width( GTK_CMCLIST(clist_avail), GROUP_COL_EMAIL, GROUP_COL_WIDTH_EMAIL );
        gtk_cmclist_set_compare_func( GTK_CMCLIST(clist_avail), edit_group_list_compare_func );
        gtk_cmclist_set_auto_sort( GTK_CMCLIST(clist_avail), TRUE );
 
        for( i = 0; i < GROUP_N_COLS; i++ )
-               GTK_WIDGET_UNSET_FLAGS(GTK_CMCLIST(clist_avail)->column[i].button, GTK_CAN_FOCUS);
+               gtk_widget_set_can_focus(GTK_CMCLIST(clist_avail)->column[i].button, FALSE);
 
        /* Status line */
        hsbox = gtk_hbox_new(FALSE, 0);
@@ -490,7 +488,7 @@ ItemGroup *addressbook_edit_group( AddressBookFile *abf, ItemFolder *parent, Ite
        gtk_widget_grab_focus(groupeditdlg.entry_name);
        gtk_widget_show(groupeditdlg.window);
        manage_window_set_transient(GTK_WINDOW(groupeditdlg.window));
-
+       gtk_window_set_modal(GTK_WINDOW(groupeditdlg.window), TRUE);
        /* Clear all fields */
        edit_group_status_show( "" );
        gtk_cmclist_clear( GTK_CMCLIST(groupeditdlg.clist_group) );
@@ -509,8 +507,7 @@ ItemGroup *addressbook_edit_group( AddressBookFile *abf, ItemFolder *parent, Ite
 
        listEMail = addrbook_get_available_email_list( abf, group );
        edit_group_load_clist( groupeditdlg.clist_avail, listEMail );
-       mgu_clear_list( listEMail );
-       listEMail = NULL;
+       g_list_free( listEMail );
        gtk_cmclist_select_row( groupeditdlg.clist_group, 0, 0 );
        gtk_cmclist_select_row( groupeditdlg.clist_avail, 0, 0 );
 
@@ -518,7 +515,7 @@ ItemGroup *addressbook_edit_group( AddressBookFile *abf, ItemFolder *parent, Ite
 
        gtk_main();
        gtk_widget_hide( groupeditdlg.window );
-
+       gtk_window_set_modal(GTK_WINDOW(groupeditdlg.window), FALSE);
        if( cancelled ) {
                return NULL;
        }