summaryrefslogtreecommitdiff
path: root/docs/reference
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2003-09-17 23:58:28 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2003-09-17 23:58:28 +0000
commit0ceb0db081e18718f7df81092fbc64788f22b9e3 (patch)
tree93b8695504be9469a33c086ef35beded26b34062 /docs/reference
parenta7ad2a46634aa17687521d055bf2f47e1c9738f8 (diff)
downloadgtk+-0ceb0db081e18718f7df81092fbc64788f22b9e3.tar.gz
Install accelerators on actions, not on proxies, support accelerator-only
2003-09-18 Matthias Clasen <maclas@gmx.de> Install accelerators on actions, not on proxies, support accelerator-only actions: * gtk/gtkmenu.c (get_accel_path): New function to get the accel path and its lock status either via _gtk_widget_get_accel_path() or by looking at the accel_path stored in the menu item itself and determining its lock status by peeking into the contained accel label. This was already (accidentally) committed a week ago. * gtk/gtkaction.h (gtk_action_set_accel_group): (gtk_action_[dis]connect_accelerator): New functions. * gtk/gtkaction.c (struct _GtkActionPrivate): Add accel_group, accel_closure and accel_count. We must have a reference to the accel_group, since we need it in connect_proxy. The count is necessary to ensure that the accelerator isn't removed before the last proxy requesting it has been unmerged. (connect_proxy): Connect the accelerator to the action now, only set the accel_path on the menuitem. (remove_proxy): Disconnect the accelerator from the action, not from the menuitem. (gtk_action_set_accel_group): Set the accel group. (gtk_action_[dis]connect_accelerator): Count the number of times this functions have been called and install/remove the accelerator if the count leaves/reaches zero. * gtk/gtkuimanager.h (GtkUIManagerItemType): Add GTK_UI_MANAGER_ACCELERATOR. * gtk/gtkuimanager.c (NodeType): Add NODE_TYPE_ACCELERATOR. (start_element_handler): Create NODE_TYPE_ACCELERATOR nodes from <accelerator> elements. (gtk_ui_manager_add_ui): Create NODE_TYPE_ACCELERATOR nodes when type is GTK_UI_MANAGER_ACCELERATOR. (update_node): Set the accel group on actions before creating their proxies. Don't set the accel group on created menus. For NODE_TYPE_ACCELERATOR nodes, [dis]connect the actions' accelerator. (print_node): Also emit <accelerator> elements. * tests/testmerge.c (dump_accels): Add a "Dump Accels" button.
Diffstat (limited to 'docs/reference')
-rw-r--r--docs/reference/ChangeLog5
-rw-r--r--docs/reference/gtk/gtk-sections.txt3
-rw-r--r--docs/reference/gtk/tmpl/gtkuimanager.sgml20
3 files changed, 26 insertions, 2 deletions
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index 06819cedc4..90e865517c 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,3 +1,8 @@
+2003-09-18 Matthias Clasen <maclas@gmx.de>
+
+ * gtk/gtk-sections.txt:
+ * gtk/tmpl/gtkuimanager.sgml: Updates for accelerator-only actions.
+
2003-09-16 Matthias Clasen <maclas@gmx.de>
* gtk/tmpl/gtkaction.sgml:
diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt
index 5c9cf15a3f..6b396f55e2 100644
--- a/docs/reference/gtk/gtk-sections.txt
+++ b/docs/reference/gtk/gtk-sections.txt
@@ -110,9 +110,12 @@ gtk_action_create_tool_item
gtk_action_connect_proxy
gtk_action_disconnect_proxy
gtk_action_get_proxies
+gtk_action_connect_accelerator
+gtk_action_disconnect_accelerator
gtk_action_block_activate_from
gtk_action_unblock_activate_from
gtk_action_set_accel_path
+gtk_action_set_accel_group
<SUBSECTION Standard>
GTK_TYPE_ACTION
GTK_ACTION
diff --git a/docs/reference/gtk/tmpl/gtkuimanager.sgml b/docs/reference/gtk/tmpl/gtkuimanager.sgml
index c649055d29..69aaec51ad 100644
--- a/docs/reference/gtk/tmpl/gtkuimanager.sgml
+++ b/docs/reference/gtk/tmpl/gtkuimanager.sgml
@@ -15,7 +15,7 @@ action groups.
The UI definitions are specified in an XML format which can be
roughly described by the following DTD.
<programlisting>
-&lt;!ELEMENT ui (menubar|toolbar|popup)* &gt;
+&lt;!ELEMENT ui (menubar|toolbar|popup|accelerator)* &gt;
&lt;!ELEMENT menubar (menuitem|separator|placeholder|menu)* &gt;
&lt;!ELEMENT menu (menuitem|separator|placeholder|menu)* &gt;
&lt;!ELEMENT popup (menuitem|separator|placeholder|menu)* &gt;
@@ -24,6 +24,7 @@ roughly described by the following DTD.
&lt;!ELEMENT menuitem EMPTY &gt;
&lt;!ELEMENT toolitem EMPTY &gt;
&lt;!ELEMENT separator EMPTY &gt;
+&lt;!ELEMENT accelerator EMPTY &gt;
&lt;!ATTLIST menubar name &num;IMPLIED &gt;
&lt;!ATTLIST toolbar name &num;IMPLIED &gt;
&lt;!ATTLIST popup name &num;IMPLIED &gt;
@@ -37,6 +38,8 @@ roughly described by the following DTD.
&lt;!ATTLIST toolitem name &num;IMPLIED
action &num;REQUIRED
position (top|bot) &num;IMPLIED &gt;
+&lt;!ATTLIST accelerator name &num;IMPLIED
+ action &num;REQUIRED &gt;
</programlisting>
There are some additional restrictions beyond those specified in the
DTD, e.g. every toolitem must have a toolbar in its anchestry and
@@ -105,6 +108,9 @@ action</para></listitem>
<listitem><para>a #GtkSeparatorMenuItem or
#GtkSeparatorToolItem</para></listitem>
</varlistentry>
+<varlistentry><term>accelerator</term>
+<listitem><para>a keyboard accelerator</para></listitem>
+</varlistentry>
</variablelist>
</para>
<para>
@@ -127,6 +133,16 @@ has the path <literal>/ui/menubar/JustifyMenu/Left</literal> and the
toolitem with the same name has path
<literal>/ui/toolbar1/JustifyToolItems/Left</literal>.
</para>
+</refsect2>
+<refsect2>
+<title>Accelerators</title>
+<para>
+Every action has an accelerator path. Accelerators are installed together with
+menuitem proxies, but they can also be explicitly added with &lt;accelerator&gt;
+elements in the UI definition. This makes it possible to have accelerators for
+actions even if they have no visible proxies.
+</para>
+</refsect2>
<refsect2 id="Smart-Separators">
<title>Smart Separators</title>
<para>
@@ -138,7 +154,6 @@ from multiple sources can make it hard or impossible to determine in advance whe
separator will end up in such an unfortunate position.
</para>
</refsect2>
-</refsect2>
<!-- ##### SECTION See_Also ##### -->
<para>
@@ -282,6 +297,7 @@ what UI element to create.
@GTK_UI_MANAGER_MENUITEM: Create a menuitem.
@GTK_UI_MANAGER_TOOLITEM: Create a toolitem.
@GTK_UI_MANAGER_SEPARATOR: Create a separator.
+@GTK_UI_MANAGER_ACCELERATOR: Install an accelerator.
<!-- ##### FUNCTION gtk_ui_manager_add_ui ##### -->
<para>