GTK window winthout main iterator

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

GTK window winthout main iterator

Gtk+ - Apps Dev mailing list
I'm trying to create a GUI using gtk.... I already have a loop that runs my
logic. I was using cairo to draw to a png and flush to /dev/fb0 but now I
want to instantiate a Gtk::Window to draw on it.

I don't want to run Gtk::Main because just want to trigger new drawings
when my logic trigger it..
The app is real only there aren't going to be any interactions from the app
ui, only from the internal logic I want to draw.

Any idea where to look to implement that approach. I was thinking on using
Gtk::main_iteration_do with Gtk::Queue_draw. But I'm not getting it work.

Do I need to ask for a cairo context on every on_draw signal call?
Do I need to "draw" on the "draw" signal?

thanks
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: GTK window winthout main iterator

Reuben Rissler
Forgive me for second guessing you, but are you definite that that your
loop is better/easier to maintain than a Gtk main loop?

So far, if I was tempted to implement my own main loop, it wasn't
because the Gtk main loop was inferior, but because I was looking at it
the wrong way. Definitely check out glib_idle_add(), glib_timeout_add()
and family.

I would love to be proved wrong, though.

Yours,
Reuben



On 09/04/2018 06:09 PM, Juan Ignacio Donoso via gtk-app-devel-list wrote:

> I'm trying to create a GUI using gtk.... I already have a loop that runs my
> logic. I was using cairo to draw to a png and flush to /dev/fb0 but now I
> want to instantiate a Gtk::Window to draw on it.
>
> I don't want to run Gtk::Main because just want to trigger new drawings
> when my logic trigger it..
> The app is real only there aren't going to be any interactions from the app
> ui, only from the internal logic I want to draw.
>
> Any idea where to look to implement that approach. I was thinking on using
> Gtk::main_iteration_do with Gtk::Queue_draw. But I'm not getting it work.
>
> Do I need to ask for a cairo context on every on_draw signal call?
> Do I need to "draw" on the "draw" signal?
>
> thanks
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: GTK window winthout main iterator

James Cameron-2
In reply to this post by Gtk+ - Apps Dev mailing list
Add your logic to a function given to glib_idle_add(), and to trigger
new drawings call queue_draw and then return from your function.  GTK+
will call your draw signal handler.  As soon as GTK+ is idle again,
your function will be called again.

It isn't the usual way of doing things, but it will work.

On Tue, Sep 04, 2018 at 07:09:13PM -0300, Juan Ignacio Donoso via gtk-app-devel-list wrote:

> I'm trying to create a GUI using gtk.... I already have a loop that runs my
> logic. I was using cairo to draw to a png and flush to /dev/fb0 but now I
> want to instantiate a Gtk::Window to draw on it.
>
> I don't want to run Gtk::Main because just want to trigger new drawings
> when my logic trigger it..
> The app is real only there aren't going to be any interactions from the app
> ui, only from the internal logic I want to draw.
>
> Any idea where to look to implement that approach. I was thinking on using
> Gtk::main_iteration_do with Gtk::Queue_draw. But I'm not getting it work.
>
> Do I need to ask for a cairo context on every on_draw signal call?
> Do I need to "draw" on the "draw" signal?
>
> thanks
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

--
James Cameron
http://quozl.netrek.org/
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list