#include "gtkmarshalers.h"
#include "gtkwindow.h" /* in lack of GtkAcceleratable */
+#include "gtkintl.h"
+#include "gtkalias.h"
+
+#include <glib/gstdio.h>
#include <string.h>
#include <errno.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
-#include <errno.h>
/* --- structures --- */
guint accel_mods;
guint std_accel_key;
guint std_accel_mods;
- guint changed : 1;
- guint lock_count;
+ guint changed : 1;
+ guint lock_count : 15;
GSList *groups;
} AccelEntry;
accel_path[1] == '<' || accel_path[1] == '>' || !accel_path[1])
return FALSE;
p = strchr (accel_path, '>');
- if (!p || p[1] != '/')
+ if (!p || (p[1] != 0 && p[1] != '/'))
return FALSE;
return TRUE;
}
}
else
{
- entry = g_new0 (AccelEntry, 1);
- entry->accel_path = g_quark_to_string (g_quark_from_string (accel_path));
+ entry = g_slice_new0 (AccelEntry);
+ entry->accel_path = g_intern_string (accel_path);
entry->std_accel_key = accel_key;
entry->std_accel_mods = accel_mods;
entry->accel_key = accel_key;
if (!removable)
goto break_loop_step5;
if (ag_entry[i].accel_path_quark)
- replace_list = g_slist_prepend (replace_list, GUINT_TO_POINTER (ag_entry->accel_path_quark));
+ replace_list = g_slist_prepend (replace_list, GUINT_TO_POINTER (ag_entry[i].accel_path_quark));
}
}
break_loop_step5:
if (change_accel && !simulate)
{
- guint old_accel_key, old_accel_mods;
-
/* ref accel groups */
for (slist = group_list; slist; slist = slist->next)
g_object_ref (slist->data);
internal_change_entry (g_quark_to_string (GPOINTER_TO_UINT (slist->data)), 0, 0, FALSE, FALSE);
/* 9) install new accelerator */
- old_accel_key = entry->accel_key;
- old_accel_mods = entry->accel_mods;
entry->accel_key = accel_key;
entry->accel_mods = accel_mods;
entry->changed = TRUE;
gchar *cpair_comment_single;
gpointer saved_symbol;
- g_return_if_fail (scanner != 0);
+ g_return_if_fail (scanner != NULL);
/* configure scanner */
skip_comment_single = scanner->config->skip_comment_single;
/**
* gtk_accel_map_load:
- * @file_name: a file containing accelerator specifications
+ * @file_name: a file containing accelerator specifications,
+ * in the GLib file name encoding
*
* Parses a file previously saved with gtk_accel_map_save() for
* accelerator specifications, and propagates them accordingly.
if (!g_file_test (file_name, G_FILE_TEST_IS_REGULAR))
return;
- fd = open (file_name, O_RDONLY);
+ fd = g_open (file_name, O_RDONLY, 0);
if (fd < 0)
return;
/**
* gtk_accel_map_save:
- * @file_name: the file to contain accelerator specifications
+ * @file_name: 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.
g_return_if_fail (file_name != NULL);
- fd = open (file_name, O_CREAT | O_TRUNC | O_WRONLY, 0644);
+ fd = g_open (file_name, O_CREAT | O_TRUNC | O_WRONLY, 0644);
if (fd < 0)
return;
entry->lock_count -= 1;
}
-G_DEFINE_TYPE (GtkAccelMap, gtk_accel_map, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GtkAccelMap, gtk_accel_map, G_TYPE_OBJECT)
static void
gtk_accel_map_class_init (GtkAccelMapClass *accel_map_class)
*
* Since: 2.4
*/
- accel_map_signals[CHANGED] = g_signal_new ("changed",
+ accel_map_signals[CHANGED] = g_signal_new (I_("changed"),
G_TYPE_FROM_CLASS (accel_map_class),
G_SIGNAL_DETAILED|G_SIGNAL_RUN_LAST,
0,
entry->accel_key,
entry->accel_mods);
}
+
+#ifdef G_OS_WIN32
+
+#undef gtk_accel_map_load
+
+void
+gtk_accel_map_load (const gchar *file_name)
+{
+ gchar *utf8_file_name = g_locale_to_utf8 (file_name, -1, NULL, NULL, NULL);
+
+ gtk_accel_map_load_utf8 (utf8_file_name);
+
+ g_free (utf8_file_name);
+}
+
+#undef gtk_accel_map_save
+
+void
+gtk_accel_map_save (const gchar *file_name)
+{
+ gchar *utf8_file_name = g_locale_to_utf8 (file_name, -1, NULL, NULL, NULL);
+
+ gtk_accel_map_save_utf8 (utf8_file_name);
+
+ g_free (utf8_file_name);
+}
+
+#endif
+
+#define __GTK_ACCEL_MAP_C__
+#include "gtkaliasdef.c"