| | 49 | |
|---|
| | 50 | |
|---|
| | 51 | Solution for simple actions |
|---|
| | 52 | =========================== |
|---|
| | 53 | |
|---|
| | 54 | For an action to actually be useful a piece of menu xml is needed. |
|---|
| | 55 | |
|---|
| | 56 | Hence an interface IActionProvider has to be defined:: |
|---|
| | 57 | |
|---|
| | 58 | class IActionProvider(interface.Interface): |
|---|
| | 59 | menu_xml = interface.Attribute("The menu XML") |
|---|
| | 60 | action_group = interface.Attribute("The accompanying ActionGroup") |
|---|
| | 61 | def update(self)? |
|---|
| | 62 | |
|---|
| | 63 | Support for actions can be arranged by decorating actions with an @action |
|---|
| | 64 | decorator and let the class create an ActionGroup using some |
|---|
| | 65 | actionGroup factory function (no inheritance needed here). |
|---|
| | 66 | |
|---|
| | 67 | Note that ActionGroup is a GTK class and should technically only be used in the |
|---|
| | 68 | gaphor.ui package. |
|---|
| | 69 | |
|---|
| | 70 | Autonom controllers can be defined, which provide a piece of functionality. |
|---|
| | 71 | They can register handlers in order to update their state. |
|---|
| | 72 | |
|---|
| | 73 | Maybe it's nice to configure those through the egg-info system. I suppose |
|---|
| | 74 | gaphor.service will serve well (as they need to be initialized anyway) |
|---|
| | 75 | ==> also inherit IActionProvider from IService? |
|---|
| | 76 | |
|---|
| | 77 | [gaphor.services] |
|---|
| | 78 | xx = gaphor.actions.whatever:SomeActionProviderClass |
|---|
| | 79 | |
|---|
| | 80 | |
|---|
| | 81 | Solution for context sensitive menus |
|---|
| | 82 | ==================================== |
|---|
| | 83 | |
|---|
| | 84 | Context sensitive menus, such as popup menus, should be generated and switched |
|---|
| | 85 | on and off on demand. |
|---|
| | 86 | |
|---|
| | 87 | Technically they should be enabled through services/action-providers. |
|---|
| | 88 | |
|---|
| | 89 | It becomes even tougher when popup menu's should act on parts of a diagram item |
|---|
| | 90 | (such as association ends). This should be avoided. It may be a good idea to |
|---|
| | 91 | provide such functionality through a special layer on the canvas, by means of |
|---|
| | 92 | some easy clickable buttons around the "hot spot" (we already have something |
|---|
| | 93 | like that for text around association ends). |
|---|
| | 94 | |
|---|