* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gtkbindingsprivate.h"
#include "gtkkeyhash.h"
+#include "gtkstylecontext.h"
#include "gtkwidget.h"
-#include "gtkrc.h"
#include "gtkintl.h"
/**
* SECTION:gtkbindings
- * @Title: GtkBindings
+ * @Title: Bindings
* @Short_description: Key bindings for individual widgets
- * @See_also: <link linkend="gtk-keyboard-accelerators">Keyboard Accelerators</link>, #GtkCssProvider
+ * @See_also: Keyboard Accelerators, Mnemonics, #GtkCssProvider
*
- * GtkBinding provides a mechanism for configuring GTK+ key bindings
+ * #GtkBindingSet provides a mechanism for configuring GTK+ key bindings
* through CSS files. This eases key binding adjustments for application
* developers as well as users and provides GTK+ users or administrators
* with high key binding configurability which requires no application
* statement to apply the binding set to specific widget types. Details
* on the matching mechanism are described under
* <link linkend="gtkcssprovider-selectors">Selectors</link>
- * in the #GtkCssProvider documentation. Inside the binding-set definition,
+ * in the #GtkCssProvider documentation. Inside the binding set definition,
* key combinations are bound to one or more specific signal emissions on
* the target widget. Key combinations are strings consisting of an optional
* #GdkModifierType name and <link linkend="gdk-Keyboard-Handling">key names</link>
* of a #GtkEntry widget to the #GtkEntry::move-cursor signal (so movement
* occurs in 3-character steps), the following binding can be used:
* <informalexample><programlisting>
- * @binding-set "MoveCursor3"
+ * @binding-set MoveCursor3
* {
* bind "<Control>Right" { "move-cursor" (visual-positions, 3, 0) };
* bind "<Control>Left" { "move-cursor" (visual-positions, -3, 0) };
* works as expected. The same mechanism can not be used to "unbind"
* existing bindings, however.
* <informalexample><programlisting>
- * @binding-set "MoveCursor3"
+ * @binding-set MoveCursor3
* {
* bind "<Control>Right" { };
* bind "<Control>Left" { };
* implement word movement. To keep GTK+ from activating its default
* bindings, the "unbind" keyword can be used like this:
* <informalexample><programlisting>
- * @binding-set "MoveCursor3"
+ * @binding-set MoveCursor3
* {
* unbind "<Control>Right";
* unbind "<Control>Left";
* </para>
* </refsect2>
*/
+
/* --- defines --- */
#define BINDING_MOD_MASK() (gtk_accelerator_get_default_mod_mask () | GDK_RELEASE_MASK)
valid = TRUE;
for (i = 1; i < query->n_params + 1 && valid; i++)
{
- GValue tmp_value = { 0, };
+ GValue tmp_value = G_VALUE_INIT;
g_value_init (params, *types);
GSignalQuery query;
guint signal_id;
GValue *params = NULL;
- GValue return_val = { 0, };
+ GValue return_val = G_VALUE_INIT;
gchar *accelerator = NULL;
signal_id = g_signal_lookup (sig->signal_name, G_OBJECT_TYPE (object));
return binding_set;
binding_set = gtk_binding_set_new (g_type_name (G_OBJECT_CLASS_TYPE (class)));
- gtk_binding_set_add_path (binding_set,
- GTK_PATH_CLASS,
- g_type_name (G_OBJECT_CLASS_TYPE (class)),
- GTK_PATH_PRIO_GTK);
g_dataset_id_set_data (class, key_id_class_binding_set, binding_set);
return binding_set;
}
+static GtkBindingSet*
+gtk_binding_set_find_interned (const gchar *set_name)
+{
+ GSList *slist;
+
+ for (slist = binding_set_list; slist; slist = slist->next)
+ {
+ GtkBindingSet *binding_set;
+
+ binding_set = slist->data;
+ if (binding_set->set_name == set_name)
+ return binding_set;
+ }
+
+ return NULL;
+}
+
/**
* gtk_binding_set_find:
* @set_name: unique binding set name
GtkBindingSet*
gtk_binding_set_find (const gchar *set_name)
{
- GSList *slist;
-
g_return_val_if_fail (set_name != NULL, NULL);
- for (slist = binding_set_list; slist; slist = slist->next)
- {
- GtkBindingSet *binding_set;
-
- binding_set = slist->data;
- if (g_str_equal (binding_set->set_name, (gpointer) set_name))
- return binding_set;
- }
- return NULL;
+ return gtk_binding_set_find_interned (g_intern_string (set_name));
}
/**
* @modifiers: key modifier of binding to install
* @signal_name: signal to execute upon activation
* @n_args: number of arguments to @signal_name
- * @Varargs: arguments to @signal_name
+ * @...: arguments to @signal_name
*
* Override or install a new key binding for @keyval with @modifiers on
* @binding_set. When the binding is activated, @signal_name will be
* Parses a signal description from @signal_desc and incorporates
* it into @binding_set.
*
- * signal descriptions may either bind a key combination to
+ * Signal descriptions may either bind a key combination to
* one or more signals:
* <informalexample><programlisting>
- * bind <replaceable>key</replaceable> {
- * <replaceable>signalname</replaceable> (<replaceable>param</replaceable>, ...)
+ * bind "key" {
+ * "signalname" (param, ...)
* ...
* }
* </programlisting></informalexample>
*
* Or they may also unbind a key combination:
* <informalexample><programlisting>
- * unbind <replaceable>key</replaceable>
+ * unbind "key"
* </programlisting></informalexample>
*
* Key combinations must be in a format that can be parsed by
* @path_pattern: the actual match pattern
* @priority: binding priority
*
- * This function is used internally by the GtkRC parsing mechanism to
- * assign match patterns to #GtkBindingSet structures.
+ * This function was used internally by the GtkRC parsing mechanism
+ * to assign match patterns to #GtkBindingSet structures.
+ *
+ * In GTK+ 3, these match patterns are unused.
*
* Deprecated: 3.0
*/
while (class_type && !handled)
{
- binding_set = gtk_binding_set_find (g_type_name (class_type));
+ binding_set = gtk_binding_set_find_interned (g_type_name (class_type));
class_type = g_type_parent (class_type);
if (!binding_set)