summaryrefslogtreecommitdiff
path: root/frontends/gtk/scaffolding.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-08-18 14:41:31 +0100
committerVincent Sanders <vince@kyllikki.org>2019-08-18 14:41:31 +0100
commitc0e27bd0da9c6804c788473b891bff6c0c98af66 (patch)
tree523d0eb4a97ee538801a556c340da907c4e245b0 /frontends/gtk/scaffolding.c
parent01f3879b647e69684ef8cbcc53f44b2c9b7b5df8 (diff)
downloadnetsurf-c0e27bd0da9c6804c788473b891bff6c0c98af66.tar.gz
netsurf-c0e27bd0da9c6804c788473b891bff6c0c98af66.tar.bz2
access gtk throbber frames through an interface
This changes the gtk throbber frames to be accessed through an API This removes teh nsgtk_throbber global and hides the implementation details from the rest of the code.
Diffstat (limited to 'frontends/gtk/scaffolding.c')
-rw-r--r--frontends/gtk/scaffolding.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index e39efc43f..ee08cc187 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -349,16 +349,20 @@ static void scaffolding_update_context(struct nsgtk_scaffolding *g)
*/
static void nsgtk_throb(void *p)
{
+ nserror res;
+ GdkPixbuf *pixbuf;
struct nsgtk_scaffolding *g = p;
- if (g->throb_frame >= (nsgtk_throbber->nframes - 1)) {
+ g->throb_frame++; /* advance to next frame */
+ res = nsgtk_throbber_get_frame(g->throb_frame, &pixbuf);
+ if (res == NSERROR_BAD_SIZE) {
g->throb_frame = 1;
- } else {
- g->throb_frame++;
+ res = nsgtk_throbber_get_frame(g->throb_frame, &pixbuf);
}
- gtk_image_set_from_pixbuf(g->throbber,
- nsgtk_throbber->framedata[g->throb_frame]);
+ if (res == NSERROR_OK) {
+ gtk_image_set_from_pixbuf(g->throbber, pixbuf);
+ }
nsgtk_schedule(100, nsgtk_throb, p);
}
@@ -2358,11 +2362,19 @@ void gui_window_start_throbber(struct gui_window* _g)
void gui_window_stop_throbber(struct gui_window* _g)
{
+ nserror res;
+ GdkPixbuf *pixbuf;
struct nsgtk_scaffolding *g = nsgtk_get_scaffold(_g);
- if (g == NULL)
+
+ if (g == NULL) {
return;
+ }
+
scaffolding_update_context(g);
nsgtk_schedule(-1, nsgtk_throb, g);
+
+ g->throb_frame = 0;
+
if (g->buttons[STOP_BUTTON] != NULL)
g->buttons[STOP_BUTTON]->sensitivity = false;
if (g->buttons[RELOAD_BUTTON] != NULL)
@@ -2370,11 +2382,11 @@ void gui_window_stop_throbber(struct gui_window* _g)
nsgtk_scaffolding_set_sensitivity(g);
- if ((g->throbber == NULL) || (nsgtk_throbber == NULL) ||
- (nsgtk_throbber->framedata == NULL) ||
- (nsgtk_throbber->framedata[0] == NULL))
- return;
- gtk_image_set_from_pixbuf(g->throbber, nsgtk_throbber->framedata[0]);
+ res = nsgtk_throbber_get_frame(g->throb_frame, &pixbuf);
+ if ((res == NSERROR_OK) &&
+ (g->throbber != NULL)) {
+ gtk_image_set_from_pixbuf(g->throbber, pixbuf);
+ }
}