Re-enable custom composer context menu, add WK text entry items to it.

* src/client/composer/composer-widget.vala
  (ComposerWidget::action_entries): Add an entry for the inspector so it
  can be loaded via the context model in the same way as other items.
  (ComposerWidget::context_menu_*): Keep track of a number of the context
  menu's sections, so we can selectively include them in the WK context
  menu.
  (ComposerWidget::on_context_menu): Re-implement to work wth the WK2
  context menu model, which annoyingly doesn't even extend any of the
  GtkMenu infrastrcuture.

* src/client/util/util-gtk.vala (menu_foreach): Pass the action
  target through to the loop's delegate, it's a bit more useful for
  dealing with the WK2 model.
  (add_g_menu_to_gtk_menu): Removed, WebKitContextMenu doesn't extend
  Gtk.Menu any longer so this is is no longer needed.

* ui/composer-menus.ui: Reoganise to use standard composer action
  prefix. Duplicate rich and plain text clipboard sections so they can
  just be selectively enabled. Include dummy sections for WK items to
  specify where they are located in the menu, and a section for the
  inspector.
This commit is contained in:
Michael James Gratton 2017-01-04 13:54:07 +11:00
parent 159e6c9bae
commit 20db6e57dd
3 changed files with 129 additions and 94 deletions

View file

@ -72,42 +72,60 @@
</menu>
<menu id="context_menu_model">
<section id="context_menu_webkit_spelling"/>
<section>
<item>
<attribute name="label" translatable="yes">_Undo</attribute>
<attribute name="action">cme.undo</attribute>
<attribute name="action">cmp.undo</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Redo</attribute>
<attribute name="action">cme.redo</attribute>
<attribute name="action">cmp.redo</attribute>
</item>
</section>
<section>
<section id="context_menu_rich_text">
<item>
<attribute name="label" translatable="yes">Cu_t</attribute>
<attribute name="action">cme.cut</attribute>
<attribute name="action">cmp.cut</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Copy</attribute>
<attribute name="action">cme.copy</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Copy _Link</attribute>
<attribute name="action">cme.copy-link</attribute>
<attribute name="action">cmp.copy</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Paste</attribute>
<attribute name="action">cme.paste</attribute>
<attribute name="action">cmp.paste</attribute>
</item>
<item>
<attribute name="label" translatable="yes" context="Clipboard paste with rich text">Paste _With Formatting</attribute>
<attribute name="action">cme.paste-with-formatting</attribute>
<attribute name="action">cmp.paste-with-formatting</attribute>
</item>
</section>
<section id="context_menu_plain_text">
<item>
<attribute name="label" translatable="yes">Cu_t</attribute>
<attribute name="action">cmp.cut</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Copy</attribute>
<attribute name="action">cmp.copy</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Paste</attribute>
<attribute name="action">cmp.paste</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Select _All</attribute>
<attribute name="action">cme.select-all</attribute>
<attribute name="action">cmp.select-all</attribute>
</item>
</section>
<section id="context_menu_webkit_text_entry"/>
<section id="context_menu_inspector">
<item>
<attribute name="label" translatable="yes">_Inspect…</attribute>
<attribute name="action">cmp.open_inspector</attribute>
</item>
</section>
</menu>