Skip to content

Commit 0c8ed95

Browse files
committed
better ^Q behaviour
see #27 thanks MvGulik
1 parent 2de6e48 commit 0c8ed95

File tree

5 files changed

+41
-13
lines changed

5 files changed

+41
-13
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
started 7.36.1 7/10/13
2+
- better ^Q behaviour, thanks MvGulik
3+
14
started 7.36.0 3/10/13
25

36
started 7.35.0 9/8/13

src/filemodel.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ filemodel_inter_close_cb( iWindow *iwnd, void *client,
829829
{
830830
Filemodel *filemodel = FILEMODEL( client );
831831

832-
IDESTROY( filemodel );
832+
iwindow_kill( filemodel_get_window_hint( filemodel ) );
833833

834834
nfn( sys, IWINDOW_YES );
835835
}
@@ -933,17 +933,35 @@ filemodel_inter_replace( iWindow *parent, Filemodel *filemodel )
933933
/* Close all registered filemodels.
934934
*/
935935

936+
/* The first registered, modified filemodel the user hasn't said "ok!!! ffs"
937+
* to.
938+
*/
939+
static Filemodel *
940+
filemodel_inter_close_get_filemodel( void )
941+
{
942+
GSList *p;
943+
944+
for( p = filemodel_registered; p; p = p->next ) {
945+
Filemodel *filemodel = FILEMODEL( p->data );
946+
947+
if( filemodel->modified )
948+
return( filemodel );
949+
}
950+
951+
return( NULL );
952+
}
953+
936954
void
937955
filemodel_inter_close_registered_cb( iWindow *iwnd, void *client,
938956
iWindowNotifyFn nfn, void *sys )
939957
{
940-
if( filemodel_registered ) {
941-
Filemodel *filemodel = FILEMODEL( filemodel_registered->data );
958+
Filemodel *filemodel;
959+
960+
if( (filemodel = filemodel_inter_close_get_filemodel()) ) {
942961
iWindowSusp *susp = iwindow_susp_new(
943962
filemodel_inter_close_registered_cb,
944963
iwnd, client, nfn, sys );
945964

946-
filemodel_unregister( filemodel );
947965
filemodel_inter_savenclose_cb(
948966
filemodel_get_window_hint( filemodel ), filemodel,
949967
iwindow_susp_comp, susp );

src/filesel.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,12 @@ filesel_refresh( Filesel *filesel )
10521052
{
10531053
char *dir;
10541054

1055-
dir = gtk_file_chooser_get_current_folder(
1056-
GTK_FILE_CHOOSER( filesel->chooser ) );
1057-
gtk_file_chooser_set_current_folder(
1058-
GTK_FILE_CHOOSER( filesel->chooser ), dir );
1059-
g_free( dir );
1055+
if( (dir = gtk_file_chooser_get_current_folder(
1056+
GTK_FILE_CHOOSER( filesel->chooser ) )) ) {
1057+
gtk_file_chooser_set_current_folder(
1058+
GTK_FILE_CHOOSER( filesel->chooser ), dir );
1059+
g_free( dir );
1060+
}
10601061

10611062
return( NULL );
10621063
}

src/iwindow.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,13 @@ iwindow_susp_return( void *sys, iWindowResult result )
435435
im_free( susp );
436436
}
437437

438+
void
439+
iwindow_susp_trigger( iWindowSusp *susp )
440+
{
441+
susp->fn( susp->iwnd, susp->client, susp->nfn, susp->sys );
442+
im_free( susp );
443+
}
444+
438445
/* Compose two iWindowFns ... if this one succeeded, trigger the next in turn.
439446
* Otherwise bail out.
440447
*/
@@ -443,10 +450,8 @@ iwindow_susp_comp( void *sys, iWindowResult result )
443450
{
444451
iWindowSusp *susp = IWINDOW_SUSP( sys );
445452

446-
if( result == IWINDOW_YES ) {
447-
susp->fn( susp->iwnd, susp->client, susp->nfn, susp->sys );
448-
im_free( susp );
449-
}
453+
if( result == IWINDOW_YES )
454+
iwindow_susp_trigger( susp );
450455
else
451456
iwindow_susp_return( sys, result );
452457
}

src/iwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ void iwindow_cursor_context_destroy( iWindowCursorContext *cntxt );
216216

217217
iWindowSusp *iwindow_susp_new( iWindowFn,
218218
iWindow *, void *, iWindowNotifyFn, void * );
219+
void iwindow_susp_trigger( iWindowSusp * );
219220
void iwindow_susp_return( void *, iWindowResult );
220221
void iwindow_susp_comp( void *, iWindowResult );
221222

0 commit comments

Comments
 (0)