GtkActions in toolbars

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

GtkActions in toolbars

Alex Valavanis-3
Hi All,

In preparation for the Hackfest, I'd like to start looking at ways to reduce (eventually eliminate!) our use of GtkAction.

One of the main uses we currently have for them is in toolbars, where the tool widgets (buttons, spinbuttons etc) are all some kind of subclass of GtkAction, which has been removed from Gtk+ 4.  This means that when the user clicks on the button, it triggers an "activate" signal, which is handled by a callback function.

My question is basically, "what's the point?"  Is there any reason why we can't just use a plain old button in most cases, and just connect up the "clicked" signal instead?

If it really needs to be some kind of Action, we could migrate to the GAction API, but this may be much more difficult.

Best wishes,


Alex

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Tavmjong Bah
On Wed, 2018-03-14 at 20:05 +0000, Alex Valavanis wrote:
Hi All,

In preparation for the Hackfest, I'd like to start looking at ways to reduce (eventually eliminate!) our use of GtkAction.

One of the main uses we currently have for them is in toolbars, where the tool widgets (buttons, spinbuttons etc) are all some kind of subclass of GtkAction, which has been removed from Gtk+ 4.  This means that when the user clicks on the button, it triggers an "activate" signal, which is handled by a callback function.

GtkActions have two modes: toolbar and menu. When a toolbar is too short it automatically switches to menu mode, accessed by the triangle at the left of the toolbar.

My question is basically, "what's the point?"  Is there any reason why we can't just use a plain old button in most cases, and just connect up the "clicked" signal instead?

If it really needs to be some kind of Action, we could migrate to the GAction API, but this may be much more difficult.

I've done quite a bit of investigation of GActions. I think they are a much more useful than GtkActions. They are not bound to GUI elements like GtkActions. The are more akin to our verbs but with an easy way to attach them to different GUI elements solely by an XML file. (They can be triggered directly by code and they even have a DBUS interface built in.) Replacing GtkActions by GActions is a lot of work but our code will be much simpler.

I have a toy program that uses GActions that I plan on presenting at the Hackfest. I can make it available ahead of time.

Tav

Best wishes,


Alex

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Jabier Arraiza
Thanks both!

-----Original Message-----
From: Tavmjong Bah <[hidden email]>
To: Alex Valavanis <[hidden email]>, Inkscape Devel List <inks
[hidden email]>
Subject: Re: [Inkscape-devel] GtkActions in toolbars
Date: Thu, 15 Mar 2018 09:10:07 +0100

On Wed, 2018-03-14 at 20:05 +0000, Alex Valavanis wrote:
> Hi All,
> In preparation for the Hackfest, I'd like to start looking at ways to
> reduce (eventually eliminate!) our use of GtkAction.
>
> One of the main uses we currently have for them is in toolbars, where
> the tool widgets (buttons, spinbuttons etc) are all some kind of
> subclass of GtkAction, which has been removed from Gtk+ 4.  This
> means that when the user clicks on the button, it triggers an
> "activate" signal, which is handled by a callback function.

GtkActions have two modes: toolbar and menu. When a toolbar is too
short it automatically switches to menu mode, accessed by the triangle
at the left of the toolbar.

> My question is basically, "what's the point?"  Is there any reason
> why we can't just use a plain old button in most cases, and just
> connect up the "clicked" signal instead?
>
> If it really needs to be some kind of Action, we could migrate to the
> GAction API, but this may be much more difficult.

I've done quite a bit of investigation of GActions. I think they are a
much more useful than GtkActions. They are not bound to GUI elements
like GtkActions. The are more akin to our verbs but with an easy way to
attach them to different GUI elements solely by an XML file. (They can
be triggered directly by code and they even have a DBUS interface built
in.) Replacing GtkActions by GActions is a lot of work but our code
will be much simpler.

I have a toy program that uses GActions that I plan on presenting at
the Hackfest. I can make it available ahead of time.

Tav

> Best wishes,
>
>
> Alex

---------------------------------------------------------------------
---------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Alex Valavanis-3
Thanks Tav,

That makes sense.  It sounds, though, like any GtkToolItem can still show as an overflow menu item as long as a proxy menu item is created.  See the following:


If that's the only feature of GtkAction that we're trying to preserve here, we can just set the proxy menus on non-actionable widgets.  In that case, it should be possible to remove GtkActions as a toolbar dependency fairly easily.

For the GAction stuff, I guess ideally we should be moving to GtkApplication, so we can register actions with application scope.  As a starting point, though, I've had a play with registering GActions with Toolbar scope, and it seems to behave OK.  I just swapped a few things round in the Connectors toolbar if you want to take a look at the diff: https://gitlab.com/inkscape/inkscape/tree/gtk-actions-migration

This way, we could do the migration fairly incrementally, rather than needing a complete overhaul of the application.

If you could share your toy application, that would be great - I'm still trying to get my head round all the options!

AV



On 15 March 2018 at 08:57, Jabier Arraiza <[hidden email]> wrote:
Thanks both!

-----Original Message-----
From: Tavmjong Bah <[hidden email]>
To: Alex Valavanis <[hidden email]>, Inkscape Devel List <inks
[hidden email]>
Subject: Re: [Inkscape-devel] GtkActions in toolbars
Date: Thu, 15 Mar 2018 09:10:07 +0100

On Wed, 2018-03-14 at 20:05 +0000, Alex Valavanis wrote:
> Hi All,
> In preparation for the Hackfest, I'd like to start looking at ways to
> reduce (eventually eliminate!) our use of GtkAction.
>
> One of the main uses we currently have for them is in toolbars, where
> the tool widgets (buttons, spinbuttons etc) are all some kind of
> subclass of GtkAction, which has been removed from Gtk+ 4.  This
> means that when the user clicks on the button, it triggers an
> "activate" signal, which is handled by a callback function.

GtkActions have two modes: toolbar and menu. When a toolbar is too
short it automatically switches to menu mode, accessed by the triangle
at the left of the toolbar.

> My question is basically, "what's the point?"  Is there any reason
> why we can't just use a plain old button in most cases, and just
> connect up the "clicked" signal instead?
>
> If it really needs to be some kind of Action, we could migrate to the
> GAction API, but this may be much more difficult.

I've done quite a bit of investigation of GActions. I think they are a
much more useful than GtkActions. They are not bound to GUI elements
like GtkActions. The are more akin to our verbs but with an easy way to
attach them to different GUI elements solely by an XML file. (They can
be triggered directly by code and they even have a DBUS interface built
in.) Replacing GtkActions by GActions is a lot of work but our code
will be much simpler.

I have a toy program that uses GActions that I plan on presenting at
the Hackfest. I can make it available ahead of time.

Tav

> Best wishes,
>
>
> Alex

---------------------------------------------------------------------
---------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Tavmjong Bah
On Thu, 2018-03-15 at 10:42 +0000, Alex Valavanis wrote:
If you could share your toy application, that would be great - I'm still trying to get my head round all the options!

I've uploaded the code to GitLab:


Tav

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Alex Valavanis-3
Great! ...and thanks for the comments on my toolbar hacks.

From a quick look at your test, am I right in thinking that you haven't yet hooked up the spinbutton to an action?  I'm still not quite sure (a) how we'd handle spinbutton actions in our toolbars, and (b) whether we'd actually need to... I guess we can just use a callback to the "value-changed" signal?

AV


On 15 March 2018 at 18:49, Tavmjong Bah <[hidden email]> wrote:
On Thu, 2018-03-15 at 10:42 +0000, Alex Valavanis wrote:
If you could share your toy application, that would be great - I'm still trying to get my head round all the options!

I've uploaded the code to GitLab:


Tav


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Alex Valavanis-3
OK, some (probably) good news...

I've done some more digging in the toolbox code.  Basically, it was written so that auxilliary toolbars (the one under the main menu) could EITHER:

* be loaded from a UI Manager file, and have GtkActions hooked up by a "prep" function
OR
* be created from scratch using a "create" function

This, I think, makes our life *much* easier.  We can just define Gtk::Toolbar subclasses for each Inkscape tool. The "create" function would just run their constructor and return the underlying GObject pointer.

I've updated the code documentation a bit in my branch.  Next step (for the Hackfest?) is just to make the replacement C++ toolbars (without GtkAction!) and hook them up :).  We can use GtkBuilder for the UI widgets if we want, or just define them directly in C++.

In future, we'd also be able to assign application-scope GActions to these, so that the toolbars can more easily run actions like "app.exit" if we want.

AV

On 15 March 2018 at 21:47, Alex Valavanis <[hidden email]> wrote:
Great! ...and thanks for the comments on my toolbar hacks.

From a quick look at your test, am I right in thinking that you haven't yet hooked up the spinbutton to an action?  I'm still not quite sure (a) how we'd handle spinbutton actions in our toolbars, and (b) whether we'd actually need to... I guess we can just use a callback to the "value-changed" signal?

AV


On 15 March 2018 at 18:49, Tavmjong Bah <[hidden email]> wrote:
On Thu, 2018-03-15 at 10:42 +0000, Alex Valavanis wrote:
If you could share your toy application, that would be great - I'm still trying to get my head round all the options!

I've uploaded the code to GitLab:


Tav



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Mark Schafer

If there was a way this could be exposed to the extensions that would be nice.


On 3/17/2018 2:30 AM, Alex Valavanis wrote:
OK, some (probably) good news...

I've done some more digging in the toolbox code.  Basically, it was written so that auxilliary toolbars (the one under the main menu) could EITHER:

* be loaded from a UI Manager file, and have GtkActions hooked up by a "prep" function
OR
* be created from scratch using a "create" function

This, I think, makes our life *much* easier.  We can just define Gtk::Toolbar subclasses for each Inkscape tool. The "create" function would just run their constructor and return the underlying GObject pointer.

I've updated the code documentation a bit in my branch.  Next step (for the Hackfest?) is just to make the replacement C++ toolbars (without GtkAction!) and hook them up :).  We can use GtkBuilder for the UI widgets if we want, or just define them directly in C++.

In future, we'd also be able to assign application-scope GActions to these, so that the toolbars can more easily run actions like "app.exit" if we want.

AV

On 15 March 2018 at 21:47, Alex Valavanis <[hidden email]> wrote:
Great! ...and thanks for the comments on my toolbar hacks.

From a quick look at your test, am I right in thinking that you haven't yet hooked up the spinbutton to an action?  I'm still not quite sure (a) how we'd handle spinbutton actions in our toolbars, and (b) whether we'd actually need to... I guess we can just use a callback to the "value-changed" signal?

AV


On 15 March 2018 at 18:49, Tavmjong Bah <[hidden email]> wrote:
On Thu, 2018-03-15 at 10:42 +0000, Alex Valavanis wrote:
If you could share your toy application, that would be great - I'm still trying to get my head round all the options!

I've uploaded the code to GitLab:


Tav




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

doctormo
On Sat, 2018-03-17 at 08:48 +1300, Mark Schafer wrote:
> If there was a way this could be exposed to the extensions that would
> be nice.

Extensions (py) or extensions (c++)?

Martin,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Mark Schafer
python but I think extensions can also be written in several languages.


On 3/17/2018 8:59 AM, Martin Owens wrote:
> On Sat, 2018-03-17 at 08:48 +1300, Mark Schafer wrote:
>> If there was a way this could be exposed to the extensions that would
>> be nice.
> Extensions (py) or extensions (c++)?
>
> Martin,
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

Alex Valavanis-3
I've pushed a C++ migration of the Dropper toolbar (because it's the simplest!) to my branch.

Any feedback much appreciated :)

https://gitlab.com/inkscape/inkscape/tree/gtk-actions-migration

On 17 March 2018 at 09:49, Mark Schafer <[hidden email]> wrote:
python but I think extensions can also be written in several languages.



On 3/17/2018 8:59 AM, Martin Owens wrote:
On Sat, 2018-03-17 at 08:48 +1300, Mark Schafer wrote:
If there was a way this could be exposed to the extensions that would
be nice.
Extensions (py) or extensions (c++)?

Martin,



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: GtkActions in toolbars

doctormo
In reply to this post by Mark Schafer
On Sat, 2018-03-17 at 22:49 +1300, Mark Schafer wrote:
> python but I think extensions can also be written in several
> languages.

Ah then no. Extensions don't have any access beyond creating the simple
widgets dialog. I'd love it if we have a better extensions system, but
for the moment, there's no extra functionality for python extensions.

Best Regards, Martin Owens

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel