X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkaccelmap.c;h=8dcdc5b084a79cf2c83eb85be4d2d38ad834790f;hb=9bdc970f8dd16caed1a5b1c353394df575f8f22a;hp=32d8c796a22ff523da1fc8eed26cde4ca74ea8c1;hpb=d4add8cefa6fa5c29bdb50f18e31cbfbfb38cc2b;p=~andy%2Fgtk diff --git a/gtk/gtkaccelmap.c b/gtk/gtkaccelmap.c index 32d8c796a..8dcdc5b08 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,7 +808,7 @@ gtk_accel_map_save (const gchar *file_name) /** * gtk_accel_map_foreach: - * @data: data to be passed into @foreach_func + * @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 * @@ -1065,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); +} +