[gnome-commander/gcmd-1-3] XML config: write user actions bindings to XML::xstream
- From: Piotr Eljasiak <epiotr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-commander/gcmd-1-3] XML config: write user actions bindings to XML::xstream
- Date: Mon, 7 Sep 2009 16:08:32 +0000 (UTC)
commit 8341328e9fa33840993239ab13ae0b2b03907957
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Mon Sep 7 18:02:35 2009 +0200
XML config: write user actions bindings to XML::xstream
src/gnome-cmd-data.cc | 2 ++
src/gnome-cmd-user-actions.cc | 37 ++++++++++++++++++++++++++++++++++++-
src/gnome-cmd-user-actions.h | 3 +++
src/main.cc | 2 +-
4 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 8d1256a..c78ff51 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1770,6 +1770,8 @@ void GnomeCmdData::save()
xml << *i;
xml << XML::endtag("Selections");
+ xml << gcmd_user_actions;
+
xml << XML::endtag("GnomeCommander");
g_free (xml_cfg_path);
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 0d66c3a..ced8506 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -365,7 +365,7 @@ void GnomeCmdUserActions::init()
void GnomeCmdUserActions::shutdown()
{
- // don't write 'hardcoded' Fn actions to config file
+ // unregister Fn to avoid writing 'hardcoded' Fn actions to config file
unregister(GDK_F3);
unregister(GDK_F4);
@@ -551,6 +551,41 @@ gboolean GnomeCmdUserActions::handle_key_event(GnomeCmdMainWin *mw, GnomeCmdFile
return TRUE;
}
+XML::xstream &operator << (XML::xstream &xml, GnomeCmdUserActions &usr)
+{
+ xml << XML::tag("KeyBindings");
+ for (GnomeCmdUserActions::ACTIONS_COLL::const_iterator i=usr.action.begin(); i!=usr.action.end(); ++i)
+ if (!ascii_isupper (i->first)) // ignore lowercase keys as they duplicate uppercase ones
+ {
+ guint state = i->first.state;
+ guint key_val = i->first.keyval;
+
+ xml << XML::tag("Key") << XML::attr("name");
+ if (ascii_isalnum (key_val))
+ xml << (gchar) key_val;
+ else
+ xml << gdk_key_names[key_val];
+
+ if (state & GDK_SHIFT_MASK) xml << XML::attr("shift") << 1;
+ if (state & GDK_CONTROL_MASK) xml << XML::attr("control") << 1;
+ if (state & GDK_MOD1_MASK) xml << XML::attr("alt") << 1;
+#if GTK_CHECK_VERSION (2, 10, 0)
+ if (state & GDK_SUPER_MASK) xml << XML::attr("super") << 1;
+ if (state & GDK_HYPER_MASK) xml << XML::attr("hyper") << 1;
+ if (state & GDK_META_MASK) xml << XML::attr("meta") << 1;
+#else
+ if (state & GDK_MOD4_MASK) xml << XML::attr("super") << 1;
+#endif
+
+ xml << XML::attr("action") << usr.action_func[i->second.func];
+ if (!i->second.user_data.empty())
+ xml << XML::attr("options") << XML::escape(i->second.user_data);
+
+ xml << XML::endtag();
+ }
+ xml << XML::endtag();
+}
+
static int sort_by_description (const void *data1, const void *data2)
{
diff --git a/src/gnome-cmd-user-actions.h b/src/gnome-cmd-user-actions.h
index 81cb446..6c3efe9 100644
--- a/src/gnome-cmd-user-actions.h
+++ b/src/gnome-cmd-user-actions.h
@@ -30,6 +30,7 @@
#include "gnome-cmd-file-selector.h"
#include "gnome-cmd-data.h"
#include "gnome-cmd-main-win.h"
+#include "gnome-cmd-xml-config.h"
#include "dict.h"
#define GNOME_CMD_USER_ACTION(f) void f(GtkMenuItem *menuitem=NULL, gpointer user_data=NULL)
@@ -195,6 +196,8 @@ class GnomeCmdUserActions
const gchar *name(const std::string description) { return action_func[action_name[description]].c_str(); }
const gchar *description(const_iterator &i) { return action_name[i->second.func].c_str(); }
const gchar *options(const_iterator &i) { return i->second.user_data.c_str(); }
+
+ friend XML::xstream &operator << (XML::xstream &xml, GnomeCmdUserActions &usr);
};
diff --git a/src/main.cc b/src/main.cc
index d8be336..3552e41 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -151,8 +151,8 @@ int main (int argc, char *argv[])
#endif
plugin_manager_shutdown ();
gcmd_tags_shutdown ();
- gnome_cmd_data.save();
gcmd_user_actions.shutdown();
+ gnome_cmd_data.save();
gnome_vfs_shutdown ();
IMAGE_free ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]