]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkaccelmap.c
filechooserbutton: whitespace fixes
[~andy/gtk] / gtk / gtkaccelmap.c
index de3745e2ce5f03225b45162a9cb49dc59643df13..7154b404f86e6e60ebdda2322a5eb8feb05e4afc 100644 (file)
  * 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 "config.h"
 
-#include "gtkaccelmap.h"
+#include "gtkaccelmapprivate.h"
 
 #include "gtkmarshalers.h"
-#include "gtkwindow.h"  /* in lack of GtkAcceleratable */
+#include "gtkwindowprivate.h"
 #include "gtkintl.h"
 
 #include <glib/gstdio.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,
@@ -669,7 +671,7 @@ gtk_accel_map_load_fd (gint fd)
 
 /**
  * gtk_accel_map_load:
- * @file_name: a file containing accelerator specifications,
+ * @file_name: (type filename): a file containing accelerator specifications,
  *   in the GLib file name encoding
  *
  * Parses a file previously saved with gtk_accel_map_save() for
@@ -780,8 +782,8 @@ gtk_accel_map_save_fd (gint fd)
 
 /**
  * gtk_accel_map_save:
- * @file_name: the name of the file to contain accelerator specifications,
- *   in the GLib file name encoding
+ * @file_name: (type filename): the name of the file to contain
+ *   accelerator specifications, in the GLib file name encoding
  *
  * Saves current accelerator specifications (accelerator path, key
  * and modifiers) to @file_name.
@@ -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 ("<GAction>/");
+  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);
+}
+