metacity r3988 - in trunk: . src/core
- From: tthurman svn gnome org
- To: svn-commits-list gnome org
- Subject: metacity r3988 - in trunk: . src/core
- Date: Thu, 23 Oct 2008 04:01:15 +0000 (UTC)
Author: tthurman
Date: Thu Oct 23 04:01:14 2008
New Revision: 3988
URL: http://svn.gnome.org/viewvc/metacity?rev=3988&view=rev
Log:
2008-10-22 Thomas Thurman <tthurman gnome org>
* src/core/schema-bindings.c: support builds outside tree properly.
Modified:
trunk/ChangeLog
trunk/src/core/schema-bindings.c
Modified: trunk/src/core/schema-bindings.c
==============================================================================
--- trunk/src/core/schema-bindings.c (original)
+++ trunk/src/core/schema-bindings.c Thu Oct 23 04:01:14 2008
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <errno.h>
#include <glib.h>
@@ -44,6 +45,9 @@
char *about_keybindings, *about_reversible_keybindings;
+char *source_filename, *target_filename;
+FILE *source_file, *target_file;
+
const char* window_string = \
" <schema>\n" \
" <key>/schemas/apps/metacity/%s_keybindings/%s%s</key>\n" \
@@ -75,22 +79,22 @@
escaped_default_value = default_value==NULL? "disabled":
g_markup_escape_text (description, -1);
- printf (" <schema>\n");
- printf (" <key>/schemas/apps/metacity/%s_keybindings/%s</key>\n",
+ fprintf (target_file, " <schema>\n");
+ fprintf (target_file, " <key>/schemas/apps/metacity/%s_keybindings/%s</key>\n",
keybinding_type, name);
- printf (" <applyto>/apps/metacity/%s_keybindings/%s</applyto>\n",
+ fprintf (target_file, " <applyto>/apps/metacity/%s_keybindings/%s</applyto>\n",
keybinding_type, name);
- printf (" <owner>metacity</owner>\n");
- printf (" <type>string</type>\n");
- printf (" <default>%s</default>\n", escaped_default_value);
+ fprintf (target_file, " <owner>metacity</owner>\n");
+ fprintf (target_file, " <type>string</type>\n");
+ fprintf (target_file, " <default>%s</default>\n", escaped_default_value);
- printf (" <locale name=\"C\">\n");
- printf (" <short>%s</short>\n", description);
- printf (" <long>%s</long>\n",
+ fprintf (target_file, " <locale name=\"C\">\n");
+ fprintf (target_file, " <short>%s</short>\n", description);
+ fprintf (target_file, " <long>%s</long>\n",
can_reverse? about_reversible_keybindings:
about_keybindings);
- printf (" </locale>\n");
- printf (" </schema>\n\n");
+ fprintf (target_file, " </locale>\n");
+ fprintf (target_file, " </schema>\n\n");
g_free (escaped_description);
@@ -103,30 +107,38 @@
static void
produce_bindings ()
{
- FILE *metacity_schemas_in_in = fopen("metacity.schemas.in.in", "r");
+ source_file = fopen(source_filename, "r");
+
+ if (!source_file)
+ {
+ g_error ("Cannot compile without %s: %s\n",
+ source_filename, strerror (errno));
+ }
+
+ target_file = fopen(target_filename, "w");
- if (!metacity_schemas_in_in)
+ if (!target_file)
{
- g_error ("Cannot compile without metacity.schemas.in.in: %s\n",
- strerror (errno));
+ g_error ("Cannot create %s: %s\n",
+ target_filename, strerror (errno));
}
- while (!feof (metacity_schemas_in_in))
+ while (!feof (source_file))
{
/* 10240 is ridiculous overkill; we're writing the input file and
* the lines are always 80 chars or less.
*/
char buffer[10240];
- fgets (buffer, sizeof (buffer), metacity_schemas_in_in);
+ fgets (buffer, sizeof (buffer), source_file);
if (strstr (buffer, "<!-- GENERATED -->"))
break;
- printf ("%s", buffer);
+ fprintf (target_file, "%s", buffer);
}
- if (!feof (metacity_schemas_in_in))
+ if (!feof (source_file))
{
#define keybind(name, handler, param, flags, stroke, description) \
single_stanza ( \
@@ -140,21 +152,35 @@
#undef keybind
}
- while (!feof (metacity_schemas_in_in))
+ while (!feof (source_file))
{
char buffer[10240];
- fgets (buffer, sizeof (buffer), metacity_schemas_in_in);
+ fgets (buffer, sizeof (buffer), source_file);
- printf ("%s", buffer);
+ fprintf (target_file, "%s", buffer);
}
- fclose (metacity_schemas_in_in);
+ if (fclose (source_file)!=0)
+ g_error ("Cannot close %s: %s\n",
+ source_filename, strerror (errno));
+
+ if (fclose (target_file)!=0)
+ g_error ("Cannot close %s: %s\n",
+ target_filename, strerror (errno));
}
int
-main ()
+main (int argc, char **argv)
{
+ if (argc!=3)
+ {
+ g_error ("Syntax: %s <source.in.in> <target.in>\n", argv[0]);
+ }
+
+ source_filename = argv[1];
+ target_filename = argv[2];
+
/* Translators: Please don't translate "Control", "Shift", etc, since these
* are hardcoded (in gtk/gtkaccelgroup.c; it's not metacity's fault).
* "disabled" must also stay as it is.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]