[nautilus-actions] Dynamically generate configurations schemas
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Dynamically generate configurations schemas
- Date: Wed, 17 Mar 2010 23:18:15 +0000 (UTC)
commit 0c3a47faeb4c04f26b713bc09461a7f6dc8a0800
Author: Pierre Wieser <pwieser trychlos org>
Date: Thu Mar 18 00:18:26 2010 +0100
Dynamically generate configurations schemas
ChangeLog | 17 +
TODO | 5 -
data/Makefile.am | 10 +-
data/nautilus-actions-prefs.schemas.in | 415 ++++++++++++++++++
data/nautilus-actions.schemas.in | 728 --------------------------------
po/POTFILES.in | 2 +-
po/POTFILES.skip | 1 +
src/core/na-icontextual-factory.c | 4 +-
src/core/na-object-action-factory.c | 2 +-
src/utils/nautilus-actions-schemas.c | 168 ++++++--
10 files changed, 571 insertions(+), 781 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3c35583..3f67335 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2009-03-17 Pierre Wieser <pwieser trychlos org>
+ * data/Makefile.am: Automatically generate configurations schemas.
+
+ * data/nautilus-actions.schemas.in:
+ Renamed as data/nautilus-actions-prefs.schemas.in.
+ Remove configurations schemas (now dynamically generated).
+
+ * po/POTFILES.in: Updated accordingly.
+
+ * src/core/na-icontextual-factory.c:
+ * src/core/na-object-action-factory.c: Fix typo.
+
+ * src/utils/nautilus-actions-schemas.c:
+ Output configurations schemas to stdout.
+
+ * po/POTFILES.skip:
+ New file: do not try to translate dynamically generated schema.
+
* Makefile.am:
Build data/ after src/ to bo take advantage of dynamic generation of schemas.
diff --git a/TODO b/TODO
index 54eab91..1320a9d 100644
--- a/TODO
+++ b/TODO
@@ -51,11 +51,6 @@
- undo manager (at least Ctrl-Z)
-- have a single place where a schema is written
- (see src/utils/nautilus-actions-schemas.c)
- more: have a single place where the schema is _described_
- so that we may generalize export, import, new, etc.
-
- IActionTab: check_label has became useless since validity is global
to the action - remove, or extend to each field which can led to
unvalidity
diff --git a/data/Makefile.am b/data/Makefile.am
index 743092a..2a226ef 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -26,10 +26,16 @@
# Pierre Wieser <pwieser trychlos org>
# ... and many others (see AUTHORS)
-schemas_in_files = nautilus-actions.schemas.in
+schemas_in_files = \
+ nautilus-actions-prefs.schemas.in \
+ nautilus-actions-confs.schemas.in \
+ $(NULL)
schemas_files = $(schemas_in_files:.schemas.in=.schemas)
+nautilus-actions-confs.schemas.in:
+ $(top_srcdir)/src/utils/nautilus-actions-schemas -s > $@
+
schemasdir = $(pkgdatadir)
schemas_DATA = $(schemas_files)
@@ -43,7 +49,7 @@ NA_INSTALL_SCHEMAS = no
endif
EXTRA_DIST = \
- $(schemas_in_files) \
+ $(schemas_in_files) \
$(NULL)
install-data-hook:
diff --git a/data/nautilus-actions-prefs.schemas.in b/data/nautilus-actions-prefs.schemas.in
new file mode 100644
index 0000000..611a0d0
--- /dev/null
+++ b/data/nautilus-actions-prefs.schemas.in
@@ -0,0 +1,415 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gconfschemafile>
+ <schemalist>
+
+ <!-- schemas for preferences -->
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/assistant-esc-confirm</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Ask for a confirmation when quitting by Esc</short>
+ <long>If TRUE, a confirmation will be requested when quitting an assistant by hitting the Esc key.</long>
+ </locale>
+ <default>true</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/assistant-esc-quit</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Whether the Esc key should close the assistants</short>
+ <long>If TRUE, assistant may be closed by hitting the Esc key.</long>
+ </locale>
+ <default>true</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/export-assistant</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the export assistant window</short>
+ <long>Position and size of the export assistant window ; default is set by the window manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/export-folder-uri</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Last selected folder</short>
+ <long>Last folder selected when choosing a folder where to export the actions.</long>
+ </locale>
+ <default>/tmp</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/export-format</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Preferred export format</short>
+ <long>This is the preferred export format, used as a default when exporting items, or dropping them outside of the application.
+Possible values are:
+- "GConfSchemaV1": this used to be the historical export format. The exported file may later be imported via Import assistant of the Nautilus Actions Configuration Tool, or via the gconftool-2 --import-schema-file command-line tool.
+- "GConfSchemaV2": a lighter while still compatible schema. The exported file may later be imported via Import assistant of the Nautilus Actions Configuration Tool, or via the gconftool-2 --import-schema-file command-line tool.
+- "GConfEntry": this should be the preferred format for newly exported actions. The exported file may later be imported via Import assistant of the Nautilus Actions Configuration Tool, or via the gconftool-2 --load command-line tool.
+- "Ask": the user will be asked at runtime for the format he wishes use.</long>
+ </locale>
+ <default>/tmp</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/icommand-command-chooser</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the command chooser window</short>
+ <long>Position and size of the command chooser window in the Command tab ; default is set by the window manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/icommand-folder-uri</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Last selected folder</short>
+ <long>Last folder selected when browsing for a command in the Command tab.</long>
+ </locale>
+ <default>/bin</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/icommand-legend-dialog</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the Legend dialog</short>
+ <long>Position and size of the Legend dialog ; default is set by the UI manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/ifolders-chooser</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the URI chooser window</short>
+ <long>Position and size of the URI chooser window in the Folders tab ; default is set by the window manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/ifolders-uri</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Last selected folder</short>
+ <long>Last folder selected when browsing for an URI in the Folders tab.</long>
+ </locale>
+ <default>/bin</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/import-ask-user</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the import assistant window</short>
+ <long>Position and size of the import assistant window ; default is set by the window manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/import-ask-user-last-mode</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Last import mode choosen by the user</short>
+ <long>Last import mode choosen by the user when he is asked for in import mode. Possible values are:
+- "NoImport": do not import an action whose UUID already exists,
+- "Renumber": allocate a new UUID if the imported UUID already exists,
+- "Override": override the existing action with the imported one.</long>
+ </locale>
+ <default>NoImport</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/import-assistant</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the interaction dialog at import time</short>
+ <long>Position and size of the interaction dialog at import time ; default is set by the window manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/import-folder-uri</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Last selected folder</short>
+ <long>Last folder selected when choosing a folder from where import new actions.</long>
+ </locale>
+ <default>/tmp</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/import-mode</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Import mode</short>
+ <long>Last import mode choosen in the Import assistant. Possible values are :
+- "NoImport": do not import an action whose UUID already exists,
+- "Renumber": allocate a new UUID if the imported UUID already exists,
+- "Override": override the existing action with the imported one,
+- "Ask": ask the user each time.</long>
+ </locale>
+ <default>NoImport</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/io-providers-order</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <locale name="C">
+ <short>I/O providers Write priority</short>
+ <long>The order in which I/O providers are tested when we need to write a new item down to a storage subsystem.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/iprefs-add-about-item</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Add an 'About' item in the Nautilus context menu</short>
+ <long>If TRUE, and if the user has defined a single root menu for its actions, then an 'About Nautilus Actions' will be displayed at end of the first submenu.</long>
+ </locale>
+ <default>true</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/iprefs-alphabetical-order</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Sort mode</short>
+ <long>This preference indicates the preferred sort mode. Possible values are :
+- "AscendingOrder": the actions are maintained in ascending alphabetical order (historical behavior).
+- "DescendingOrder": the actions are maintained in descending alphabetical order.
+- "ManualOrder": user is free to reorder them via Nautilus-Actions configuration tool.</long>
+ </locale>
+ <default>0</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/iprefs-create-root-menu</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Define a 'Nautilus Actions' root menu</short>
+ <long>If TRUE, then a 'Nautilus Actions' item will be defined in the Nautilus context menu, and will a root menu of all available actions.</long>
+ </locale>
+ <default>true</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/iprefs-level-zero</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <locale name="C">
+ <short>List of items at first level of the hierarchy</short>
+ <long>UUID of the items at the first level of the hierarchy. If this key is not found or empty, then all found items are considered as a flat list.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/iprefs-relabel-actions</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Whether actions should be relabeled when pasted or duplicated</short>
+ <long>Whether actions should be relabeled when pasted or duplicated.</long>
+ </locale>
+ <default>true</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/iprefs-relabel-menus</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Whether menus should be relabeled when pasted or duplicated</short>
+ <long>Whether menus should be relabeled when pasted or duplicated.</long>
+ </locale>
+ <default>true</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/iprefs-relabel-profiles</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Whether profiles should be relabeled when pasted or duplicated</short>
+ <long>Whether profiles should be relabeled when pasted or duplicated.</long>
+ </locale>
+ <default>true</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/main-edit-toolbar</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Display Edit toolbar</short>
+ <long>Whether to display or not the Edit toolbar in the main window.</long>
+ </locale>
+ <default>false</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/main-file-toolbar</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Display File toolbar</short>
+ <long>Whether to display or not the File toolbar in the main window.</long>
+ </locale>
+ <default>true</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/main-help-toolbar</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Display Help toolbar</short>
+ <long>Whether to display or not the Help toolbar in the main window.</long>
+ </locale>
+ <default>false</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/main-paned</key>
+ <owner>nautilus-actions</owner>
+ <type>int</type>
+ <locale name="C">
+ <short>Main pane position</short>
+ <long>Width of the main window pane ; default is set by the UI manager.</long>
+ </locale>
+ <default>100</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/main-tools-toolbar</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Display Tools toolbar</short>
+ <long>Whether to display or not the Tools toolbar in the main window.</long>
+ </locale>
+ <default>false</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/main-window</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the main window</short>
+ <long>Position and size of the main window ; default is set by the window manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/preferences-editor</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the preferences dialog</short>
+ <long>Position and size of the preferences dialog ; default is set by the window manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/schemes</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <locale name="C">
+ <short>List of default schemes</short>
+ <long>The list of schemes proposed by default on each new profile.
+A default default list is harcoded in nautilus-actions-config-tool, which may be updated by the user.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <!-- sysadmin reserved keys -->
+ <!-- these keys are thought to be set as mandatory keys -->
+ <!-- each I/O provider has its own key, identified by the I/O provider internal id. -->
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/mandatory/all/locked</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Whether the whole configuration is locked</short>
+ <long>The whole configuration must be understood here as the global set and order of menus and actions.
+When this configuration is locked, then the user is no more able to modify nor create or delete any menu or action. All items are read-only.
+As the order of items is also locked, the level zero itself cannot be modified, and the user is unable to reorder the items.</long>
+ </locale>
+ <default>false</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/mandatory/na-gconf/locked</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Whether the GConf I/O provider is locked</short>
+ <long>When set to true (most probably as a mandatory key), this prevents all items, menus and actions, readen from GConf to being modified in NACT.</long>
+ </locale>
+ <default>false</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/mandatory/na-desktop/locked</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Whether the Desktop I/O provider is locked</short>
+ <long>When set to true (most probably as a mandatory key), this prevents all items, menus and actions, readen from .desktop files to being modified in NACT.</long>
+ </locale>
+ <default>false</default>
+ </schema>
+
+ </schemalist>
+</gconfschemafile>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6aa80d2..0ac9ca9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,4 +1,4 @@
-data/nautilus-actions.schemas.in
+data/nautilus-actions-prefs.schemas.in
src/core/na-exporter.c
src/core/na-iabout.c
src/core/na-icontextual-factory.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
new file mode 100644
index 0000000..39dd707
--- /dev/null
+++ b/po/POTFILES.skip
@@ -0,0 +1 @@
+data/nautilus-actions-confs.schemas.in
diff --git a/src/core/na-icontextual-factory.c b/src/core/na-icontextual-factory.c
index cfbbdfb..0e4cdc0 100644
--- a/src/core/na-icontextual-factory.c
+++ b/src/core/na-icontextual-factory.c
@@ -240,7 +240,7 @@ NADataDef data_def_conditions [] = {
N_( "List of folders" ),
N_( "Defines the list of valid paths to be matched against the current folder.\n " \
"All folders 'under' the specified path are considered valid.\n" \
- "This is only used when there is no selection.\n" \
+ "This is only used when there is no selection, or the selection only contains directories.\n" \
"Defaults to '/'." ),
NAFD_TYPE_STRING_LIST,
"[/]",
@@ -253,7 +253,7 @@ NADataDef data_def_conditions [] = {
"folder",
0,
G_OPTION_ARG_STRING,
- N_( "The path of a directory for which the item will be displayed. " \
+ N_( "The path of a (parent) directory for which the item will be displayed. " \
"You must set one option for each folder you need" ),
N_( "<PATH>" ) },
diff --git a/src/core/na-object-action-factory.c b/src/core/na-object-action-factory.c
index 08a9bb4..2c9820c 100644
--- a/src/core/na-object-action-factory.c
+++ b/src/core/na-object-action-factory.c
@@ -122,7 +122,7 @@ static NADataDef data_def_action [] = {
TRUE,
N_( "Targets the toolbar" ),
N_( "Whether the action is candidate to be displayed in file manager toolbar.\n" \
- "Note, that as of Nautilus 2.26, menus can not be candidate to toolbar display." ),
+ "Note, that as of Nautilus 2.26, menus cannot be candidate to toolbar display." ),
NAFD_TYPE_BOOLEAN,
"false",
TRUE,
diff --git a/src/utils/nautilus-actions-schemas.c b/src/utils/nautilus-actions-schemas.c
index 19a7706..45287fc 100644
--- a/src/utils/nautilus-actions-schemas.c
+++ b/src/utils/nautilus-actions-schemas.c
@@ -32,45 +32,69 @@
#include <config.h>
#endif
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.h>
#include <glib.h>
#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <libxml/tree.h>
#include <stdlib.h>
#include <api/na-core-utils.h>
+#include <api/na-data-types.h>
+#include <api/na-ifactory-object-data.h>
-#include <core/na-iprefs.h>
-#if 0
-#include <core/na-xml-names.h>
-#include <core/na-xml-writer.h>
-#endif
+#include <io-gconf/nagp-keys.h>
+
+#include <io-xml/naxml-keys.h>
#include "console-utils.h"
-/*static gchar *output_fname = NULL;
-static gboolean output_gconf = FALSE;*/
+typedef struct {
+ NADataGroup *group;
+ gchar *group_name;
+ gchar *data_name;
+}
+ SchemaFromDataDef;
+
+extern NADataGroup action_data_groups[]; /* defined in na-object-action-factory.c */
+extern NADataGroup profile_data_groups[]; /* defined in na-object-profile-factory.c */
+
+static const SchemaFromDataDef st_schema_from_data_def[] = {
+ { action_data_groups, NA_FACTORY_OBJECT_ITEM_GROUP, NAFO_DATA_LABEL },
+ { action_data_groups, NA_FACTORY_OBJECT_ITEM_GROUP, NAFO_DATA_TOOLTIP },
+ { action_data_groups, NA_FACTORY_OBJECT_ITEM_GROUP, NAFO_DATA_ICON },
+ { action_data_groups, NA_FACTORY_OBJECT_ITEM_GROUP, NAFO_DATA_ENABLED },
+ { action_data_groups, NA_FACTORY_OBJECT_ACTION_GROUP, NAFO_DATA_TARGET_SELECTION },
+ { action_data_groups, NA_FACTORY_OBJECT_ACTION_GROUP, NAFO_DATA_TARGET_TOOLBAR },
+ { action_data_groups, NA_FACTORY_OBJECT_ACTION_GROUP, NAFO_DATA_TOOLBAR_LABEL },
+ { profile_data_groups, NA_FACTORY_OBJECT_PROFILE_GROUP, NAFO_DATA_PATH },
+ { profile_data_groups, NA_FACTORY_OBJECT_PROFILE_GROUP, NAFO_DATA_PARAMETERS },
+ { profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_BASENAMES },
+ { profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_MATCHCASE },
+ { profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_MIMETYPES },
+ { profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_ISFILE },
+ { profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_ISDIR },
+ { profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_MULTIPLE },
+ { profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_SCHEMES },
+ { profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_FOLDERS },
+ { NULL }
+};
+
static gboolean output_stdout = FALSE;
static gboolean version = FALSE;
static GOptionEntry entries[] = {
-
- /*{ "output-gconf" , 'g', 0, G_OPTION_ARG_NONE , &output_gconf , N_("Writes the Nautilus Actions schema in GConf"), NULL },
- { "output-filename" , 'o', 0, G_OPTION_ARG_FILENAME, &output_fname , N_("The file where to write the GConf schema ('-' for stdout)"), N_("FILENAME") },*/
- { "stdout", 's', 0, G_OPTION_ARG_NONE, &output_stdout, N_("Output the schema on stdout"), NULL },
+ { "stdout" , 's', 0, G_OPTION_ARG_NONE, &output_stdout, N_("Output the schema on stdout"), NULL },
{ NULL }
};
static GOptionEntry misc_entries[] = {
-
- { "version" , 'v', 0, G_OPTION_ARG_NONE , &version,
- N_("Output the version number"), NULL },
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &version, N_("Output the version number"), NULL },
{ NULL }
};
static GOptionContext *init_options( void );
-/*static gboolean write_to_gconf( gchar **msg );
-static gboolean write_schema( GConfClient *gconf, const gchar *prefix, GConfValueType type, const gchar *entry, const gchar *dshort, const gchar *dlong, const gchar *default_value, gchar **msg );*/
+static int output_to_stdout( GSList **msgs );
+static void attach_schema_node( xmlDocPtr doc, xmlNodePtr list_node, const NADataDef *data_def );
static void exit_with_usage( void );
int
@@ -80,7 +104,7 @@ main( int argc, char** argv )
GOptionContext *context;
gchar *help;
GError *error = NULL;
- GSList *msg = NULL;
+ GSList *msgs = NULL;
GSList *im;
g_type_init();
@@ -107,29 +131,15 @@ main( int argc, char** argv )
exit( status );
}
- /*if( output_gconf && output_fname ){
- g_printerr( _( "Error: only one output option may be specified." ));
- exit_with_usage();
- }*/
-
- /*if( output_gconf ){
- if( write_to_gconf( &msg )){
- g_print( _( "Nautilus Actions schema succesfully written to GConf.\n" ));
- }
+ if( output_stdout ){
+ status = output_to_stdout( &msgs );
+ }
- } else {
- na_xml_writer_export( NULL, NULL, IPREFS_EXPORT_FORMAT_GCONF_SCHEMA, &msg );
- if( !msg ){
- g_print( _( "Nautilus Actions schema succesfully written to %s.\n" ), output_fname );
- g_free( output_fname );
- }*/
- /*}*/
-
- if( msg ){
- for( im = msg ; im ; im = im->next ){
+ if( msgs ){
+ for( im = msgs ; im ; im = im->next ){
g_printerr( "%s\n", ( gchar * ) im->data );
}
- na_core_utils_slist_free( msg );
+ na_core_utils_slist_free( msgs );
status = EXIT_FAILURE;
}
@@ -149,9 +159,6 @@ init_options( void )
GOptionGroup *misc_group;
context = g_option_context_new( _( "Output the Nautilus Actions GConf schema on stdout." ));
- /*" The schema can be written to stdout.\n"
- " It can also be written to an output file, in a file later suitable for an installation via gconftool-2.\n"
- " Or you may choose to directly write the schema into the GConf configuration." ));*/
#ifdef ENABLE_NLS
bindtextdomain( GETTEXT_PACKAGE, GNOMELOCALEDIR );
@@ -275,6 +282,83 @@ write_schema( GConfClient *gconf, const gchar *prefix, GConfValueType type, cons
return( ret );
}*/
+static int
+output_to_stdout( GSList **msgs )
+{
+ static const gchar *thisfn = "nautilus_actions_schemas_output_to_stdout";
+ xmlDocPtr doc;
+ xmlNodePtr root_node;
+ xmlNodePtr list_node;
+ xmlChar *text;
+ int textlen;
+ SchemaFromDataDef *isch;
+ const NADataDef *data_def;
+
+ doc = xmlNewDoc( BAD_CAST( "1.0" ));
+
+ root_node = xmlNewNode( NULL, BAD_CAST( NAXML_KEY_SCHEMA_ROOT ));
+ xmlDocSetRootElement( doc, root_node );
+
+ list_node = xmlNewChild( root_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_LIST ), NULL );
+
+ isch = ( SchemaFromDataDef * ) st_schema_from_data_def;
+ while( isch->group ){
+ data_def = na_data_def_get_data_def( isch->group, isch->group_name, isch->data_name );
+
+ if( data_def ){
+ attach_schema_node( doc, list_node, data_def );
+
+ } else {
+ g_warning( "%s: group=%s, name=%s: unable to find NADataDef structure", thisfn, isch->group_name, isch->data_name );
+ }
+
+ isch++;
+ }
+ xmlDocDumpFormatMemoryEnc( doc, &text, &textlen, "UTF-8", 1 );
+ g_printf( "%s\n", ( const char * ) text );
+
+ xmlFree( text );
+ xmlFreeDoc (doc);
+ xmlCleanupParser();
+
+ return( EXIT_SUCCESS );
+}
+
+static void
+attach_schema_node( xmlDocPtr doc, xmlNodePtr list_node, const NADataDef *def )
+{
+ xmlNodePtr schema_node;
+ xmlChar *content;
+ xmlNodePtr parent_value_node;
+ xmlNodePtr locale_node;
+
+ schema_node = xmlNewChild( list_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE ), NULL );
+
+ content = BAD_CAST( g_build_path( "/", NAGP_SCHEMAS_PATH, def->gconf_entry, NULL ));
+ xmlNewChild( schema_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE_KEY ), content );
+ xmlFree( content );
+
+ xmlNewChild( schema_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE_OWNER ), BAD_CAST( PACKAGE_TARNAME ));
+
+ xmlNewChild( schema_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE_TYPE ), BAD_CAST( na_data_types_get_gconf_dump_key( def->type )));
+ if( def->type == NAFD_TYPE_STRING_LIST ){
+ xmlNewChild( schema_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE_LISTTYPE ), BAD_CAST( "string" ));
+ }
+
+ locale_node = xmlNewChild( schema_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE_LOCALE ), NULL );
+ xmlNewProp( locale_node, BAD_CAST( "name" ), BAD_CAST( "C" ));
+
+ xmlNewChild( locale_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE_LOCALE_SHORT ), BAD_CAST( def->short_label ));
+
+ xmlNewChild( locale_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE_LOCALE_LONG ), BAD_CAST( def->long_label ));
+
+ parent_value_node = def->localizable ? locale_node : schema_node;
+
+ content = xmlEncodeSpecialChars( doc, BAD_CAST( def->default_value ));
+ xmlNewChild( parent_value_node, NULL, BAD_CAST( NAXML_KEY_SCHEMA_NODE_DEFAULT ), content );
+ xmlFree( content );
+}
+
/*
* print a help message and exit with failure
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]