Add more good defaults to .gitignore
[tilda-gobject.git] / tilda-controller.c
index cf0c23c..613bedb 100644 (file)
@@ -110,6 +110,36 @@ tilda_controller_remove_window (TildaController *self, gint window_number)
        return FALSE;
 }
 
+/**
+ * Check if a key is used in one of our windows.
+ *
+ * This is needed because the tomboy_keybinder_bind() function allows
+ * more than one callback to be registered for the same key.
+ */
+gboolean
+tilda_controller_global_key_in_use (const TildaController *self, const gchar *keystr)
+{
+       gint i;
+       TildaWindow *tw;
+
+       guint key1, key2;
+       GdkModifierType mod1, mod2;
+
+       gtk_accelerator_parse (keystr, &key1, &mod1);
+
+       for (i=0; i<self->windows->len; ++i)
+       {
+               tw = g_ptr_array_index (self->windows, i);
+               gtk_accelerator_parse (tw->key, &key2, &mod2);
+
+               if (key1 == key2 && mod1 == mod2)
+                       return TRUE;
+       }
+
+       /* No identical keys found, we're ok */
+       return FALSE;
+}
+
 gboolean
 tilda_controller_quit (TildaController *self, GError **error)
 {