diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLog.ja | 7 | ||||
-rw-r--r-- | src/editjpilot.c | 77 | ||||
-rw-r--r-- | src/editvcard.c | 71 |
4 files changed, 59 insertions, 103 deletions
@@ -1,5 +1,12 @@ 2005-07-08 + * src/editjpilot.c + src/editvcard.c: fixed a crash when cancelling file selection dialog + by Escape key. Made non-ascii filename selectable. Use new file + chooser dialog. + +2005-07-08 + * src/compose.c src/procmsg.[ch]: put existing window in front when trying to reedit draft/queued messages which are already open. diff --git a/ChangeLog.ja b/ChangeLog.ja index 269b76ea..e238486d 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,12 @@ 2005-07-08 + * src/editjpilot.c + src/editvcard.c: ファイル選択ダイアログを Escape キーでキャンセル + したときのクラッシュを修正。非 ascii ファイル名を選択可能にした。 + 新しい file chooser ダイアログを使用。 + +2005-07-08 + * src/compose.c src/procmsg.[ch]: 既に開いている草稿/送信待ちメッセージを再編集 しようとした場合、存在するウィンドウを前面に出すようにした。 diff --git a/src/editjpilot.c b/src/editjpilot.c index eed03eef..1aad6abf 100644 --- a/src/editjpilot.c +++ b/src/editjpilot.c @@ -52,7 +52,9 @@ #include "addressitem.h" #include "jpilot.h" #include "mgutils.h" +#include "filesel.h" #include "gtkutils.h" +#include "codeconv.h" #include "manage_window.h" #define ADDRESSBOOK_GUESS_JPILOT "MyJPilot" @@ -71,8 +73,6 @@ static struct _JPilotEdit { gint status_cid; } jpilotedit; -static struct _AddressFileSelection jpilot_file_selector; - /* * Edit functions. */ @@ -164,16 +164,18 @@ static void edit_jpilot_read_check_box( JPilotFile *pilotFile ) { static void edit_jpilot_file_check( void ) { gint t = -1; gchar *sFile; + gchar *sFSFile; gchar *sMsg; gboolean flg; flg = FALSE; sFile = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.file_entry), 0, -1 ); if( sFile ) { - g_strchomp( sFile ); g_strchug( sFile ); - if( *sFile != '\0' ) { + sFSFile = conv_filename_from_utf8( sFile ); + if( sFSFile && *sFSFile != '\0' ) { /* Attempt to read file */ - JPilotFile *jpf = jpilot_create_path( sFile ); + JPilotFile *jpf; + jpf = jpilot_create_path( sFSFile ); t = jpilot_read_data( jpf ); if( t == MGU_SUCCESS ) { /* Set check boxes */ @@ -183,12 +185,13 @@ static void edit_jpilot_file_check( void ) { jpilot_free( jpf ); jpf = NULL; } + g_free( sFSFile ); + g_free( sFile ); } if( ! flg ) { /* Clear all check boxes */ edit_jpilot_fill_check_box_new(); } - g_free( sFile ); /* Display appropriate message */ if( t == MGU_SUCCESS ) { @@ -203,55 +206,19 @@ static void edit_jpilot_file_check( void ) { edit_jpilot_status_show( sMsg ); } -static void edit_jpilot_file_ok( GtkWidget *widget, gpointer data ) { - const gchar *sFile; - AddressFileSelection *afs; - GtkWidget *fileSel; - - afs = ( AddressFileSelection * ) data; - fileSel = afs->fileSelector; - sFile = gtk_file_selection_get_filename( GTK_FILE_SELECTION(fileSel) ); - - afs->cancelled = FALSE; - gtk_entry_set_text( GTK_ENTRY(jpilotedit.file_entry), sFile ); - gtk_widget_hide( afs->fileSelector ); - gtk_grab_remove( afs->fileSelector ); - edit_jpilot_file_check(); - gtk_widget_grab_focus( jpilotedit.file_entry ); -} - -static void edit_jpilot_file_cancel( GtkWidget *widget, gpointer data ) { - AddressFileSelection *afs = ( AddressFileSelection * ) data; - afs->cancelled = TRUE; - gtk_widget_hide( afs->fileSelector ); - gtk_grab_remove( afs->fileSelector ); - gtk_widget_grab_focus( jpilotedit.file_entry ); -} - -static void edit_jpilot_file_select_create( AddressFileSelection *afs ) { - GtkWidget *fileSelector; - - fileSelector = gtk_file_selection_new( _("Select JPilot File") ); - gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION(fileSelector) ); - g_signal_connect( G_OBJECT (GTK_FILE_SELECTION(fileSelector)->ok_button), - "clicked", G_CALLBACK (edit_jpilot_file_ok), ( gpointer ) afs ); - g_signal_connect( G_OBJECT (GTK_FILE_SELECTION(fileSelector)->cancel_button), - "clicked", G_CALLBACK (edit_jpilot_file_cancel), ( gpointer ) afs ); - afs->fileSelector = fileSelector; - afs->cancelled = TRUE; -} - static void edit_jpilot_file_select( void ) { gchar *sFile; + gchar *sUTF8File; - if (! jpilot_file_selector.fileSelector ) - edit_jpilot_file_select_create( & jpilot_file_selector ); + sFile = filesel_select_file( _("Select JPilot File"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN ); - sFile = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.file_entry), 0, -1 ); - gtk_file_selection_set_filename( GTK_FILE_SELECTION( jpilot_file_selector.fileSelector ), sFile ); - g_free( sFile ); - gtk_widget_show( jpilot_file_selector.fileSelector ); - gtk_grab_add( jpilot_file_selector.fileSelector ); + if( sFile ) { + sUTF8File = conv_filename_to_utf8( sFile ); + gtk_entry_set_text( GTK_ENTRY(jpilotedit.file_entry), sUTF8File ); + g_free( sUTF8File ); + g_free( sFile ); + edit_jpilot_file_check(); + } } static void addressbook_edit_jpilot_create( gboolean *cancelled ) { @@ -389,6 +356,7 @@ AdapterDSource *addressbook_edit_jpilot( AddressIndex *addrIndex, AdapterDSource static gboolean cancelled; gchar *sName; gchar *sFile; + gchar *sFSFile; AddressDataSource *ds = NULL; JPilotFile *jpf = NULL; gboolean fin; @@ -431,8 +399,10 @@ AdapterDSource *addressbook_edit_jpilot( AddressIndex *addrIndex, AdapterDSource fin = FALSE; sName = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.name_entry), 0, -1 ); sFile = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.file_entry), 0, -1 ); + sFSFile = conv_filename_from_utf8( sFile ); if( *sName == '\0' ) fin = TRUE; if( *sFile == '\0' ) fin = TRUE; + if( ! sFSFile || *sFSFile == '\0' ) fin = TRUE; if( ! fin ) { if( ! ads ) { @@ -442,11 +412,12 @@ AdapterDSource *addressbook_edit_jpilot( AddressIndex *addrIndex, AdapterDSource } addressbook_ads_set_name( ads, sName ); jpilot_set_name( jpf, sName ); - jpilot_set_file( jpf, sFile ); + jpilot_set_file( jpf, sFSFile ); edit_jpilot_read_check_box( jpf ); } - g_free( sName ); + g_free( sFSFile ); g_free( sFile ); + g_free( sName ); return ads; } diff --git a/src/editvcard.c b/src/editvcard.c index 851edac0..0ced1ce9 100644 --- a/src/editvcard.c +++ b/src/editvcard.c @@ -47,7 +47,9 @@ #include "addressitem.h" #include "vcard.h" #include "mgutils.h" +#include "filesel.h" #include "gtkutils.h" +#include "codeconv.h" #include "manage_window.h" #define ADDRESSBOOK_GUESS_VCARD "MyGnomeCard" @@ -63,8 +65,6 @@ static struct _VCardEdit { gint status_cid; } vcardedit; -static struct _AddressFileSelection vcard_file_selector; - /* * Edit functions. */ @@ -90,10 +90,13 @@ static void edit_vcard_cancel( GtkWidget *widget, gboolean *cancelled ) { static void edit_vcard_file_check( void ) { gint t; gchar *sFile; + gchar *sFSFile; gchar *sMsg; sFile = gtk_editable_get_chars( GTK_EDITABLE(vcardedit.file_entry), 0, -1 ); - t = vcard_test_read_file( sFile ); + sFSFile = conv_filename_from_utf8( sFile ); + t = vcard_test_read_file( sFSFile ); + g_free( sFSFile ); g_free( sFile ); if( t == MGU_SUCCESS ) { sMsg = ""; @@ -107,55 +110,19 @@ static void edit_vcard_file_check( void ) { edit_vcard_status_show( sMsg ); } -static void edit_vcard_file_ok( GtkWidget *widget, gpointer data ) { - const gchar *sFile; - AddressFileSelection *afs; - GtkWidget *fileSel; - - afs = ( AddressFileSelection * ) data; - fileSel = afs->fileSelector; - sFile = gtk_file_selection_get_filename( GTK_FILE_SELECTION(fileSel) ); - - afs->cancelled = FALSE; - gtk_entry_set_text( GTK_ENTRY(vcardedit.file_entry), sFile ); - gtk_widget_hide( afs->fileSelector ); - gtk_grab_remove( afs->fileSelector ); - edit_vcard_file_check(); - gtk_widget_grab_focus( vcardedit.file_entry ); -} - -static void edit_vcard_file_cancel( GtkWidget *widget, gpointer data ) { - AddressFileSelection *afs = ( AddressFileSelection * ) data; - afs->cancelled = TRUE; - gtk_widget_hide( afs->fileSelector ); - gtk_grab_remove( afs->fileSelector ); - gtk_widget_grab_focus( vcardedit.file_entry ); -} - -static void edit_vcard_file_select_create( AddressFileSelection *afs ) { - GtkWidget *fileSelector; - - fileSelector = gtk_file_selection_new( _("Select vCard File") ); - gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION(fileSelector) ); - g_signal_connect( G_OBJECT (GTK_FILE_SELECTION(fileSelector)->ok_button), - "clicked", G_CALLBACK (edit_vcard_file_ok), ( gpointer ) afs ); - g_signal_connect( G_OBJECT (GTK_FILE_SELECTION(fileSelector)->cancel_button), - "clicked", G_CALLBACK (edit_vcard_file_cancel), ( gpointer ) afs ); - afs->fileSelector = fileSelector; - afs->cancelled = TRUE; -} - static void edit_vcard_file_select( void ) { gchar *sFile; + gchar *sUTF8File; - if (! vcard_file_selector.fileSelector ) - edit_vcard_file_select_create( & vcard_file_selector ); + sFile = filesel_select_file( _("Select vCard File"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN ); - sFile = gtk_editable_get_chars( GTK_EDITABLE(vcardedit.file_entry), 0, -1 ); - gtk_file_selection_set_filename( GTK_FILE_SELECTION( vcard_file_selector.fileSelector ), sFile ); - g_free( sFile ); - gtk_widget_show( vcard_file_selector.fileSelector ); - gtk_grab_add( vcard_file_selector.fileSelector ); + if( sFile ) { + sUTF8File = conv_filename_to_utf8( sFile ); + gtk_entry_set_text( GTK_ENTRY(vcardedit.file_entry), sUTF8File ); + g_free( sUTF8File ); + g_free( sFile ); + edit_vcard_file_check(); + } } static gint edit_vcard_delete_event( GtkWidget *widget, GdkEventAny *event, gboolean *cancelled ) { @@ -278,6 +245,7 @@ AdapterDSource *addressbook_edit_vcard( AddressIndex *addrIndex, AdapterDSource static gboolean cancelled; gchar *sName; gchar *sFile; + gchar *sFSFile; AddressDataSource *ds = NULL; VCardFile *vcf = NULL; gboolean fin; @@ -314,8 +282,10 @@ AdapterDSource *addressbook_edit_vcard( AddressIndex *addrIndex, AdapterDSource fin = FALSE; sName = gtk_editable_get_chars( GTK_EDITABLE(vcardedit.name_entry), 0, -1 ); sFile = gtk_editable_get_chars( GTK_EDITABLE(vcardedit.file_entry), 0, -1 ); + sFSFile = conv_filename_from_utf8( sFile ); if( *sName == '\0' ) fin = TRUE; if( *sFile == '\0' ) fin = TRUE; + if( ! sFSFile || *sFSFile == '\0' ) fin = TRUE; if( ! fin ) { if( ! ads ) { @@ -325,10 +295,11 @@ AdapterDSource *addressbook_edit_vcard( AddressIndex *addrIndex, AdapterDSource } addressbook_ads_set_name( ads, sName ); vcard_set_name( vcf, sName ); - vcard_set_file( vcf, sFile ); + vcard_set_file( vcf, sFSFile ); } - g_free( sName ); + g_free( sFSFile ); g_free( sFile ); + g_free( sName ); return ads; } |