Skip to content

Commit 6ed8c7f

Browse files
committed
fix progress bar, again
1 parent 523a969 commit 6ed8c7f

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

src/imagewindow.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ image_window_bestfit( ImageWindow *win )
262262
}
263263
}
264264

265+
static void
266+
image_window_preeval( VipsImage *image,
267+
VipsProgress *progress, ImageWindow *win )
268+
{
269+
gtk_action_bar_set_revealed( GTK_ACTION_BAR( win->progress_bar ),
270+
TRUE );
271+
}
272+
265273
typedef struct _EvalUpdate {
266274
ImageWindow *win;
267275
int eta;
@@ -277,11 +285,6 @@ image_window_eval_idle( void *user_data )
277285
char str[256];
278286
VipsBuf buf = VIPS_BUF_STATIC( str );
279287

280-
// you'd think we could do this in preeval, but it doesn't always seem to
281-
// fire for some reason
282-
gtk_action_bar_set_revealed( GTK_ACTION_BAR( win->progress_bar ),
283-
TRUE );
284-
285288
vips_buf_appendf( &buf, "%d%% complete, %d seconds to go",
286289
update->percent, update->eta );
287290
gtk_progress_bar_set_text( GTK_PROGRESS_BAR( win->progress ),
@@ -1462,6 +1465,8 @@ image_window_set_tile_source( ImageWindow *win, TileSource *tile_source )
14621465
"tile-cache", win->tile_cache,
14631466
NULL );
14641467

1468+
g_signal_connect_object( win->tile_source, "preeval",
1469+
G_CALLBACK( image_window_preeval ), win, 0 );
14651470
g_signal_connect_object( win->tile_source, "eval",
14661471
G_CALLBACK( image_window_eval ), win, 0 );
14671472
g_signal_connect_object( win->tile_source, "posteval",
@@ -1509,6 +1514,10 @@ image_window_set_tile_source( ImageWindow *win, TileSource *tile_source )
15091514
tile_source->active =
15101515
g_settings_get_boolean( win->settings, "control" );
15111516

1517+
/* Everything is set up ... start loading the image.
1518+
*/
1519+
tile_source_background_load( tile_source );
1520+
15121521
image_window_changed( win );
15131522
}
15141523

src/tilesource.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,12 +1037,12 @@ tile_source_background_load_done_idle( void *user_data )
10371037
/* This runs for the background load threadpool.
10381038
*/
10391039
static void
1040-
tile_source_background_load( void *data, void *user_data )
1040+
tile_source_background_load_worker( void *data, void *user_data )
10411041
{
10421042
TileSource *tile_source = (TileSource *) data;
10431043

10441044
#ifdef DEBUG
1045-
printf( "tile_source_background_load: starting ..\n" );
1045+
printf( "tile_source_background_load_worker: starting ..\n" );
10461046
#endif /*DEBUG*/
10471047

10481048
g_assert( tile_source->image_region );
@@ -1052,7 +1052,7 @@ tile_source_background_load( void *data, void *user_data )
10521052
g_idle_add( tile_source_background_load_done_idle, tile_source );
10531053

10541054
#ifdef DEBUG
1055-
printf( "tile_source_background_load: .. done\n" );
1055+
printf( "tile_source_background_load_worker: .. done\n" );
10561056
#endif /*DEBUG*/
10571057
}
10581058

@@ -1185,7 +1185,7 @@ tile_source_class_init( TileSourceClass *class )
11851185

11861186
g_assert( !tile_source_background_load_pool );
11871187
tile_source_background_load_pool = g_thread_pool_new(
1188-
tile_source_background_load,
1188+
tile_source_background_load_worker,
11891189
NULL, -1, FALSE, NULL );
11901190

11911191
}
@@ -1746,9 +1746,6 @@ tile_source_new_from_source( VipsSource *source )
17461746

17471747
tile_source_attach_progress( tile_source );
17481748

1749-
g_thread_pool_push( tile_source_background_load_pool,
1750-
tile_source, NULL );
1751-
17521749
return( tile_source );
17531750
}
17541751

@@ -1811,6 +1808,17 @@ tile_source_new_from_file( GFile *file )
18111808
return( tile_source );
18121809
}
18131810

1811+
/* Call this some time after tile_source_new_from_file() or
1812+
* tile_source_new_from_source(), and once all callbacks have been
1813+
* attached, to trigger a bg load.
1814+
*/
1815+
void
1816+
tile_source_background_load( TileSource *tile_source )
1817+
{
1818+
g_thread_pool_push( tile_source_background_load_pool,
1819+
tile_source, NULL );
1820+
}
1821+
18141822
int
18151823
tile_source_fill_tile( TileSource *tile_source, Tile *tile )
18161824
{

src/tilesource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ GType tile_source_get_type( void );
220220
TileSource *tile_source_new_from_source( VipsSource *source );
221221
TileSource *tile_source_new_from_file( GFile *file );
222222

223+
void tile_source_background_load( TileSource *tile_source );
224+
223225
int tile_source_fill_tile( TileSource *tile_source, Tile *tile );
224226

225227
const char *tile_source_get_path( TileSource *tile_source );

0 commit comments

Comments
 (0)