X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkaccelmap.c;h=7154b404f86e6e60ebdda2322a5eb8feb05e4afc;hb=e1edc998a2e9c557030d207533932b3120e13fe5;hp=26577738f66f2c1baac4cfe039eaad016dc9ab1f;hpb=6d5cdad56ec7b637438fc2a98c000891dbacef52;p=~andy%2Fgtk diff --git a/gtk/gtkaccelmap.c b/gtk/gtkaccelmap.c index 26577738f..7154b404f 100644 --- a/gtk/gtkaccelmap.c +++ b/gtk/gtkaccelmap.c @@ -12,14 +12,12 @@ * 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 . */ #include "config.h" -#include "gtkaccelmap.h" +#include "gtkaccelmapprivate.h" #include "gtkmarshalers.h" #include "gtkwindowprivate.h" @@ -179,9 +177,8 @@ accel_path_lookup (const gchar *accel_path) void _gtk_accel_map_init (void) { - g_assert (accel_entry_ht == NULL); - - accel_entry_ht = g_hash_table_new (accel_entry_hash, accel_entry_equal); + if (accel_entry_ht == NULL) + accel_entry_ht = g_hash_table_new (accel_entry_hash, accel_entry_equal); } gboolean @@ -210,6 +207,9 @@ _gtk_accel_path_is_valid (const gchar *accel_path) * To change the accelerator during runtime programatically, use * gtk_accel_map_change_entry(). * + * Set @accel_key and @accel_mods to 0 to request a removal of + * the accelerator. + * * Note that @accel_path string will be stored in a #GQuark. Therefore, if you * pass a static string, you can save some memory by interning it first with * g_intern_static_string(). @@ -260,9 +260,10 @@ gtk_accel_map_add_entry (const gchar *accel_path, * gtk_accel_map_lookup_entry: * @accel_path: a valid accelerator path * @key: (allow-none) (out): the accelerator key to be filled in (optional) - * @returns: %TRUE if @accel_path is known, %FALSE otherwise * * Looks up the accelerator entry for @accel_path and fills in @key. + * + * Returns: %TRUE if @accel_path is known, %FALSE otherwise */ gboolean gtk_accel_map_lookup_entry (const gchar *accel_path, @@ -485,7 +486,6 @@ internal_change_entry (const gchar *accel_path, * @accel_key: the new accelerator key * @accel_mods: the new accelerator modifiers * @replace: %TRUE if other accelerators may be deleted upon conflicts - * @returns: %TRUE if the accelerator could be changed, %FALSE otherwise * * Changes the @accel_key and @accel_mods currently associated with @accel_path. * Due to conflicts with other accelerators, a change may not always be possible, @@ -493,10 +493,12 @@ internal_change_entry (const gchar *accel_path, * conflicts. A change will only occur if all conflicts could be resolved (which * might not be the case if conflicting accelerators are locked). Successful * changes are indicated by a %TRUE return value. - * + * * Note that @accel_path string will be stored in a #GQuark. Therefore, if you - * pass a static string, you can save some memory by interning it first with + * pass a static string, you can save some memory by interning it first with * g_intern_static_string(). + * + * Returns: %TRUE if the accelerator could be changed, %FALSE otherwise */ gboolean gtk_accel_map_change_entry (const gchar *accel_path, @@ -806,9 +808,9 @@ gtk_accel_map_save (const gchar *file_name) /** * gtk_accel_map_foreach: - * @data: data to be passed into @foreach_func - * @foreach_func: function to be executed for each accel map entry which - * is not filtered out + * @data: (allow-none): data to be passed into @foreach_func + * @foreach_func: (scope call): function to be executed for each accel + * map entry which is not filtered out * * Loops over the entries in the accelerator map whose accel path * doesn't match any of the filters added with gtk_accel_map_add_filter(), @@ -844,7 +846,8 @@ gtk_accel_map_foreach (gpointer data, /** * gtk_accel_map_foreach_unfiltered: * @data: data to be passed into @foreach_func - * @foreach_func: function to be executed for each accel map entry + * @foreach_func: (scope call): function to be executed for each accel + * map entry * * Loops over all entries in the accelerator map, and execute * @foreach_func on each. The signature of @foreach_func is that of @@ -952,7 +955,7 @@ _gtk_accel_map_remove_group (const gchar *accel_path, * * Note that locking of individual accelerator paths is independent from * locking the #GtkAccelGroup containing them. For runtime accelerator - * changes to be possible both the accelerator path and its #GtkAccelGroup + * changes to be possible, both the accelerator path and its #GtkAccelGroup * have to be unlocked. * * Since: 2.4 @@ -1064,3 +1067,20 @@ do_accel_map_changed (AccelEntry *entry) entry->accel_key, entry->accel_mods); } + +gchar * +_gtk_accel_path_for_action (const gchar *action_name, + GVariant *parameter) +{ + GString *s; + + s = g_string_new ("/"); + g_string_append (s, action_name); + if (parameter) + { + g_string_append_c (s, '/'); + g_variant_print_string (parameter, s, FALSE); + } + return g_string_free (s, FALSE); +} +