Tutorial for writing widgets in Gtk3

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

Tutorial for writing widgets in Gtk3

Göran Hasse
Hello!

I try to write a custom widget in Gtk3. I study the source for other widgets but I find no totorial
for how to write a widget in Gtk3. (There was for Gtk2 - but they are not of any use anymore...).

Is there no interest in Gtk3 anymore? I find it very hard to find tutorials for Gtk3.

/gh

--
Göran Hasse
Raditex Control AB
Boo 229
715 91 ODENSBACKEN
http://www.rscada.se
OrgNr: 556611-8773
email: [hidden email]
tel: 019-450105
mob: 070-5530148
Lat:  59.18805083 Long: 15.50300449
URL: http://alturl.com/3e6hf
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Tutorial for writing widgets in Gtk3

Timm Bäder
On 2018-07-26 09:42, Göran Hasse wrote:
> Hello!
>
> I try to write a custom widget in Gtk3. I study the source for other
> widgets but I find no totorial
> for how to write a widget in Gtk3. (There was for Gtk2 - but they are
> not of any use anymore...).
>
> Is there no interest in Gtk3 anymore? I find it very hard to find
> tutorials for Gtk3.

There's https://wiki.gnome.org/HowDoI/CustomWidgets
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Tutorial for writing widgets in Gtk3

Göran Hasse
If you look in the widget_class->draw section

MyButton *button = MY_BUTTON(widget);

Why is this pointer to button created? It is not used!

And where is the cairo_t *cr comming from?

This is a turorial that is not so easy to understand...

/gh

Den 2018-07-26 kl. 08:39, skrev Timm Bäder:

> On 2018-07-26 09:42, Göran Hasse wrote:
>> Hello!
>>
>> I try to write a custom widget in Gtk3. I study the source for other
>> widgets but I find no totorial
>> for how to write a widget in Gtk3. (There was for Gtk2 - but they are
>> not of any use anymore...).
>>
>> Is there no interest in Gtk3 anymore? I find it very hard to find
>> tutorials for Gtk3.
>
> There's https://wiki.gnome.org/HowDoI/CustomWidgets
> _______________________________________________
> gtk-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-list

--
Göran Hasse
Raditex Control AB
Boo 229
715 91 ODENSBACKEN
http://www.rscada.se
OrgNr: 556611-8773
email: [hidden email]
tel: 019-450105
mob: 070-5530148
Lat:  59.18805083 Long: 15.50300449
URL: http://alturl.com/3e6hf
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Tutorial for writing widgets in Gtk3

Timm Bäder
That pointer is just not used because this is a minimal example that
doesn't
even do any custom drawing. If you don't use it, don't declare it.

The cairo_t gets passed to the draw implementation by GTK+, it's
a parameter to the my_button_draw function. See also the
documentation for gtk_widget_draw().


On 2018-07-26 10:00, Göran Hasse wrote:

> If you look in the widget_class->draw section
>
> MyButton *button = MY_BUTTON(widget);
>
> Why is this pointer to button created? It is not used!
>
> And where is the cairo_t *cr comming from?
>
> This is a turorial that is not so easy to understand...
>
> /gh
>
> Den 2018-07-26 kl. 08:39, skrev Timm Bäder:
>> On 2018-07-26 09:42, Göran Hasse wrote:
>>> Hello!
>>>
>>> I try to write a custom widget in Gtk3. I study the source for other
>>> widgets but I find no totorial
>>> for how to write a widget in Gtk3. (There was for Gtk2 - but they are
>>> not of any use anymore...).
>>>
>>> Is there no interest in Gtk3 anymore? I find it very hard to find
>>> tutorials for Gtk3.
>>
>> There's https://wiki.gnome.org/HowDoI/CustomWidgets
>> _______________________________________________
>> gtk-list mailing list
>> [hidden email]
>> https://mail.gnome.org/mailman/listinfo/gtk-list
>
> --
> Göran Hasse
> Raditex Control AB
> Boo 229
> 715 91 ODENSBACKEN
> http://www.rscada.se
> OrgNr: 556611-8773
> email: [hidden email]
> tel: 019-450105
> mob: 070-5530148
> Lat:  59.18805083 Long: 15.50300449
> URL: http://alturl.com/3e6hf
> _______________________________________________
> gtk-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-list
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Tutorial for writing widgets in Gtk3

Gtk+ - General mailing list
In reply to this post by Göran Hasse

Hi Göran,

There are a couple of widgets at

https://gitlab.com/cecashon/OrderedSetVelociRaptor/tree/master/Misc

that might be of help. They are widgets derived from a drawing area widget. There is a toggle, switch, gauge, multigraph, etc. If you click on the folder there are some pictures and also some instructions in some of the .c files(like multi_graph.c) for generating documentation and type libraries along with test code in python, perl and js.

Eric




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

Re: Tutorial for writing widgets in Gtk3

Gtk+ - General mailing list
In reply to this post by Timm Bäder
I’ll second this. Gtk is complex, with three layers (gtk, gdk, g). Then there are separate pieces like pango and Cairo. It’s not obvious how it all fits together and a slew of depreciation makes it hard to untangle.

What’s needed is a full blooded example. Start from main and show a pure gtk+3 app that takes button press, mouse moves, text entry and keystrokes, and uses them to update labels with different markup options. Throw in a clock display to show timers. Use multiple threads to show how to add idle functions. Use css.

It’s easier to grab a generic, fully featured example and cut it down than start with disjoint pieces. But I didn’t find one.

> On Jul 26, 2018, at 3:59 AM, Timm Bäder <[hidden email]> wrote:
>
> That pointer is just not used because this is a minimal example that doesn't
> even do any custom drawing. If you don't use it, don't declare it.
>
> The cairo_t gets passed to the draw implementation by GTK+, it's
> a parameter to the my_button_draw function. See also the
> documentation for gtk_widget_draw().
>
>
>> On 2018-07-26 10:00, Göran Hasse wrote:
>> If you look in the widget_class->draw section
>> MyButton *button = MY_BUTTON(widget);
>> Why is this pointer to button created? It is not used!
>> And where is the cairo_t *cr comming from?
>> This is a turorial that is not so easy to understand...
>> /gh
>>> Den 2018-07-26 kl. 08:39, skrev Timm Bäder:
>>>> On 2018-07-26 09:42, Göran Hasse wrote:
>>>> Hello!
>>>> I try to write a custom widget in Gtk3. I study the source for other
>>>> widgets but I find no totorial
>>>> for how to write a widget in Gtk3. (There was for Gtk2 - but they are
>>>> not of any use anymore...).
>>>> Is there no interest in Gtk3 anymore? I find it very hard to find
>>>> tutorials for Gtk3.
>>> There's https://wiki.gnome.org/HowDoI/CustomWidgets
>>> _______________________________________________
>>> gtk-list mailing list
>>> [hidden email]
>>> https://mail.gnome.org/mailman/listinfo/gtk-list
>> --
>> Göran Hasse
>> Raditex Control AB
>> Boo 229
>> 715 91 ODENSBACKEN
>> http://www.rscada.se
>> OrgNr: 556611-8773
>> email: [hidden email]
>> tel: 019-450105
>> mob: 070-5530148
>> Lat:  59.18805083 Long: 15.50300449
>> URL: http://alturl.com/3e6hf
>> _______________________________________________
>> gtk-list mailing list
>> [hidden email]
>> https://mail.gnome.org/mailman/listinfo/gtk-list
> _______________________________________________
> gtk-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-list

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

Re: Tutorial for writing widgets in Gtk3

Göran Hasse
Hello,

This is a common problem with todays "eco-systems". They tend to be so complex so that small firms
and singel programmers have problems to coop.

Instead of making it simple to create a "simple" program the environment tends to focus on "user experience"
and this demands extremly complex environments. The result is that there is no tutorials, no examples and
no simple template to start from.

The result is that the interest in the environment (eg Gtk3) is almoste gone. I have a hard time to find *anyone* programming
in Gtk3 this days.

I have some gtk2 widgets I want to port to gtk3 and there is virtually no help to get...

Talented programmers (eg developers of Gtk) should strive harder to help out. MAKE TUTORIALS THAT WORK!

/Göran Hasse


Den 2018-07-26 kl. 19:21, skrev Scott Mayo via gtk-list:

> I’ll second this. Gtk is complex, with three layers (gtk, gdk, g). Then there are separate pieces like pango and Cairo. It’s not obvious how it all fits together and a slew of depreciation makes it hard to untangle.
>
> What’s needed is a full blooded example. Start from main and show a pure gtk+3 app that takes button press, mouse moves, text entry and keystrokes, and uses them to update labels with different markup options. Throw in a clock display to show timers. Use multiple threads to show how to add idle functions. Use css.
>
> It’s easier to grab a generic, fully featured example and cut it down than start with disjoint pieces. But I didn’t find one.
>
>> On Jul 26, 2018, at 3:59 AM, Timm Bäder <[hidden email]> wrote:
>>
>> That pointer is just not used because this is a minimal example that doesn't
>> even do any custom drawing. If you don't use it, don't declare it.
>>
>> The cairo_t gets passed to the draw implementation by GTK+, it's
>> a parameter to the my_button_draw function. See also the
>> documentation for gtk_widget_draw().
>>
>>
>>> On 2018-07-26 10:00, Göran Hasse wrote:
>>> If you look in the widget_class->draw section
>>> MyButton *button = MY_BUTTON(widget);
>>> Why is this pointer to button created? It is not used!
>>> And where is the cairo_t *cr comming from?
>>> This is a turorial that is not so easy to understand...
>>> /gh
>>>> Den 2018-07-26 kl. 08:39, skrev Timm Bäder:
>>>>> On 2018-07-26 09:42, Göran Hasse wrote:
>>>>> Hello!
>>>>> I try to write a custom widget in Gtk3. I study the source for other
>>>>> widgets but I find no totorial
>>>>> for how to write a widget in Gtk3. (There was for Gtk2 - but they are
>>>>> not of any use anymore...).
>>>>> Is there no interest in Gtk3 anymore? I find it very hard to find
>>>>> tutorials for Gtk3.
>>>> There's https://wiki.gnome.org/HowDoI/CustomWidgets
>>>> _______________________________________________
>>>> gtk-list mailing list
>>>> [hidden email]
>>>> https://mail.gnome.org/mailman/listinfo/gtk-list
>>> --
>>> Göran Hasse
>>> Raditex Control AB
>>> Boo 229
>>> 715 91 ODENSBACKEN
>>> http://www.rscada.se
>>> OrgNr: 556611-8773
>>> email: [hidden email]
>>> tel: 019-450105
>>> mob: 070-5530148
>>> Lat:  59.18805083 Long: 15.50300449
>>> URL: http://alturl.com/3e6hf
>>> _______________________________________________
>>> gtk-list mailing list
>>> [hidden email]
>>> https://mail.gnome.org/mailman/listinfo/gtk-list
>> _______________________________________________
>> gtk-list mailing list
>> [hidden email]
>> https://mail.gnome.org/mailman/listinfo/gtk-list
>
> _______________________________________________
> gtk-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-list
>

--
Göran Hasse
Raditex Control AB
Boo 229
715 91 ODENSBACKEN
http://www.rscada.se
OrgNr: 556611-8773
email: [hidden email]
tel: 019-450105
mob: 070-5530148
Lat:  59.18805083 Long: 15.50300449
URL: http://alturl.com/3e6hf
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Tutorial for writing widgets in Gtk3

Rafal Luzynski
In reply to this post by Gtk+ - General mailing list
26.07.2018 20:21 Scott Mayo via gtk-list <[hidden email]> wrote:

>
> I’ll second this. Gtk is complex, with three layers (gtk, gdk, g). Then there
> are separate pieces like pango and Cairo. It’s not obvious how it all fits
> together and a slew of depreciation makes it hard to untangle.
>
> What’s needed is a full blooded example. Start from main and show a pure gtk+3
> app that takes button press, mouse moves, text entry and keystrokes, and uses
> them to update labels with different markup options. Throw in a clock display
> to show timers. Use multiple threads to show how to add idle functions. Use
> css.
> [...]

This sounds like a book rather than an example.

There's nothing wrong with a book, I'm just not sure anyone is going
to write one in a response to a mailing thread.

Regards,

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

Re: Tutorial for writing widgets in Gtk3

Nicola Fontana-3
In reply to this post by Göran Hasse
Il Thu, 26 Jul 2018 08:42:26 +0100 Göran Hasse <[hidden email]> scrisse:

> Hello!
>
> I try to write a custom widget in Gtk3. I study the source for other widgets but I find no totorial
> for how to write a widget in Gtk3. (There was for Gtk2 - but they are not of any use anymore...).

Hi,

in case you did not notice, the git repository (and maybe the
tarball) has some stand-alone examples you can check:

https://gitlab.gnome.org/GNOME/gtk/tree/master/examples

I just checked application1 and application10 and they are up to
date. Just read the README before:

https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/README

IMO this is more than enough to get you started.

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

Re: Tutorial for writing widgets in Gtk3

Göran Hasse
I have have those applications. But they just use stock widgets.

I don't find an example creating a new widget from scratch...

Eg how to write your own widget. I have my widget in the tarfile and this is what
I want to be running in Gtk3...

/gh


Den 2018-07-29 kl. 16:22, skrev Nicola Fontana:

> Il Thu, 26 Jul 2018 08:42:26 +0100 Göran Hasse <[hidden email]> scrisse:
>
>> Hello!
>>
>> I try to write a custom widget in Gtk3. I study the source for other widgets but I find no totorial
>> for how to write a widget in Gtk3. (There was for Gtk2 - but they are not of any use anymore...).
>
> Hi,
>
> in case you did not notice, the git repository (and maybe the
> tarball) has some stand-alone examples you can check:
>
> https://gitlab.gnome.org/GNOME/gtk/tree/master/examples
>
> I just checked application1 and application10 and they are up to
> date. Just read the README before:
>
> https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/README
>
> IMO this is more than enough to get you started.
>
> Ciao.
>
--
Göran Hasse
Raditex Control AB
Boo 229
715 91 ODENSBACKEN
http://www.rscada.se
OrgNr: 556611-8773
email: [hidden email]
tel: 019-450105
mob: 070-5530148
Lat:  59.18805083 Long: 15.50300449
URL: http://alturl.com/3e6hf

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list

gtkhhbar.tarfile (54K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Tutorial for writing widgets in Gtk3

Nicola Fontana-3
Il Sun, 29 Jul 2018 18:19:25 +0100 Göran Hasse <[hidden email]> scrisse:

> I have have those applications. But they just use stock widgets.
>
> I don't find an example creating a new widget from scratch...
>
> Eg how to write your own widget. I have my widget in the tarfile and this is what
> I want to be running in Gtk3...

Ah sorry. I was reading the whole thread and answering to Scott
Mayo question asking for full blooded examples of GTK+3 apps.

Ciao.
--
Nicola
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list