Initial commit
authorJulien Lavergne <julien.lavergne@gmail.com>
Fri, 18 Jun 2010 16:13:53 +0000 (18:13 +0200)
committerJulien Lavergne <julien.lavergne@gmail.com>
Fri, 18 Jun 2010 16:13:53 +0000 (18:13 +0200)
13 files changed:
Makefile.am [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
data/Makefile.am [new file with mode: 0644]
data/lxadmin.desktop.in [new file with mode: 0644]
data/ui/Makefile.am [new file with mode: 0644]
data/ui/about.glade.in [new file with mode: 0644]
po/LINGUAS [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
po/POTFILES.skip [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/lxadmin.c [new file with mode: 0644]
src/xml-purge.c [new file with mode: 0644]

diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..e5a3db4
--- /dev/null
@@ -0,0 +1,6 @@
+NULL=
+
+SUBDIRS=src po data
+
+EXTRA_DIST = \
+       $(NULL)
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..aaaed56
--- /dev/null
@@ -0,0 +1,29 @@
+#! /bin/sh
+AC_VERSION=
+
+AUTOMAKE=${AUTOMAKE:-automake}
+AM_INSTALLED_VERSION=$($AUTOMAKE --version | sed -e '2,$ d' -e 's/.* \([0-9]*\.[0-9]*\).*/\1/')
+
+if [ "$AM_INSTALLED_VERSION" != "1.10" \
+    -a "$AM_INSTALLED_VERSION" != "1.11" ];then
+       echo
+       echo "You must have automake > 1.10 or 1.11 installed to compile this program."
+       echo "Install the appropriate package for your distribution,"
+       echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
+       exit 1
+fi
+
+set -x
+
+if [ "x${ACLOCAL_DIR}" != "x" ]; then
+  ACLOCAL_ARG=-I ${ACLOCAL_DIR}
+fi
+
+${ACLOCAL:-aclocal$AM_VERSION} ${ACLOCAL_ARG}
+${AUTOHEADER:-autoheader$AC_VERSION} --force
+AUTOMAKE=$AUTOMAKE libtoolize -c --automake --force
+AUTOMAKE=$AUTOMAKE intltoolize -c --automake --force
+$AUTOMAKE --add-missing --copy --include-deps
+${AUTOCONF:-autoconf$AC_VERSION}
+
+rm -rf autom4te.cache
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..c0325de
--- /dev/null
@@ -0,0 +1,108 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+prog_name = lxadmin
+
+AC_PREREQ([2.63])
+AC_INIT([lxadmin], [0.1.0], [http://lxde.org/])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CC
+# AM_PROG_LIBTOOL
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_HEADER_STDC
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+
+# intltool
+IT_PROG_INTLTOOL([0.40.0])
+
+# PKG_CHECK_MODULES(XLIB, "x11")
+# AC_SUBST(XLIB_CFLAGS)
+# AC_SUBST(XLIB_LIBS)
+
+pkg_modules="gtk+-2.0 >= 2.12.0"
+PKG_CHECK_MODULES(GTK, [$pkg_modules])
+AC_SUBST(GTK_CFLAGS)
+AC_SUBST(GTK_LIBS)
+
+# gio_modules="gthread-2.0 gio-unix-2.0 glib-2.0 >= 2.18.0"
+# PKG_CHECK_MODULES(GIO, [$gio_modules])
+# AC_SUBST(GIO_CFLAGS)
+# AC_SUBST(GIO_LIBS)
+
+# menu_modules="libmenu-cache >= 0.3.2"
+# PKG_CHECK_MODULES(MENU_CACHE, [$menu_modules])
+# AC_SUBST(MENU_CACHE_CFLAGS)
+# AC_SUBST(MENU_CACHE_LIBS)
+
+AC_ARG_ENABLE(debug,
+       [AC_HELP_STRING([--enable-debug],
+               [build libfm with debug support @<:@default=no@:>@])],
+       [enable_debug="${enableval}"],
+       [enable_debug=no]
+)
+if test "$enable_debug" = "yes"; then
+    # turn on debug and disable optimization
+    CPPFLAGS="$CPPFLAGS -DG_ENABLE_DEBUG -O0 -g"
+else
+    # turn off glib debug checks
+    CPPFLAGS="$CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
+fi
+
+# Generate po/LINGUAS on the fly rather than relying on translators
+# to maintain it manually. This also overcome the problem that Transifex
+# cannot add a language to po/LINGUAS if a new po file is submitted.
+rm -f $srcdir/po/LINGUAS
+for po_file in `ls $srcdir/po/*.po | sort`;
+do
+    lang=`echo "$po_file" | sed "s|.*/po/\(.*\)\.po|\1|g"`
+    echo $lang >> $srcdir/po/LINGUAS
+done
+
+GETTEXT_PACKAGE=lxadmin
+AC_SUBST(GETTEXT_PACKAGE)
+AM_GLIB_GNU_GETTEXT
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
+
+AC_CONFIG_FILES([
+    Makefile
+    src/Makefile
+    data/Makefile
+    data/ui/Makefile
+    data/ui/about.glade
+    po/Makefile.in
+])
+
+AC_OUTPUT
+
+if test x"$sysconfdir" != x'/etc'; then
+    echo
+    echo
+    echo 'Error: sysconfdir is not /etc.'
+    echo 'Please consider passing --sysconfdir=/etc to configure.';
+    echo 'Otherwise default config files will be installed to wrong place.'
+    echo
+    echo
+else
+    echo
+    echo lxadmin....................... : Version $VERSION
+    echo
+    echo Enable debug....................: "$enable_debug"
+    echo Prefix..........................: $prefix
+    echo
+    echo The binary will be installed in $prefix/bin
+    echo
+    echo http://lxde.org/
+    echo
+    echo "Ready to make lxadmin. Type 'make' to continue."
+    echo
+fi
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644 (file)
index 0000000..119dce9
--- /dev/null
@@ -0,0 +1,16 @@
+NULL=
+
+SUBDIRS= \
+       ui \
+       $(NULL)
+
+desktopdir=$(datadir)/applications
+desktop_in_files = \
+       lxadmin.desktop.in \
+       $(NULL)
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+@INTLTOOL_DESKTOP_RULE@
+
+EXTRA_DIST= \
+       $(desktop_DATA) \
+       $(NULL)
diff --git a/data/lxadmin.desktop.in b/data/lxadmin.desktop.in
new file mode 100644 (file)
index 0000000..55db04d
--- /dev/null
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Type=Application
+_Name=LXAdmin
+_GenericName=LXAdmin
+_Comment=LXAdmin Description
+Icon=LXAdmin
+Exec=lxadmin
+StartupNotify=true
+Categories=GTK;
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
new file mode 100644 (file)
index 0000000..d13b02a
--- /dev/null
@@ -0,0 +1,21 @@
+NULL=
+
+# GtkBuilder UI definition files
+uidir=$(datadir)/lxadmin/ui
+ui_in_files= \
+       about.glade \
+       $(NULL)
+ui_DATA = $(ui_in_files:.glade=.ui)
+
+CLEANFILES = \
+       $(ui_DATA) \
+       $(NULL)
+
+# Purge GtkBuilder UI files
+%.ui: %.glade
+       cp $< $@
+       $(top_srcdir)/src/xml-purge $@
+
+EXTRA_DIST= \
+       $(ui_DATA) \
+       $(NULL)
diff --git a/data/ui/about.glade.in b/data/ui/about.glade.in
new file mode 100644 (file)
index 0000000..ef2184e
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="GtkAboutDialog" id="dlg">
+    <property name="border_width">5</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="type_hint">dialog</property>
+    <property name="has_separator">False</property>
+    <property name="program_name">LXAdmin</property>
+    <property name="version">@VERSION@</property>
+    <property name="copyright" translatable="yes">Copyright (C) 2010</property>
+    <property name="comments" translatable="yes">LXAdmin Description</property>
+    <property name="website">http://lxde.org/</property>
+    <property name="license">Copyright (C) 2010 LXDE Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.</property>
+    <property name="authors">LXDE Team</property>
+    <property name="translator_credits" translatable="yes" comments="Please replace this line with your own names, one name per line. ">translator-credits</property>
+    <property name="artists"></property>
+    <property name="wrap_license">True</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644 (file)
index 0000000..dad8857
--- /dev/null
@@ -0,0 +1 @@
+zh_TW
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..4c049b5
--- /dev/null
@@ -0,0 +1,5 @@
+# List of source files containing translatable strings.
+
+data/template.desktop.in
+data/ui/about.glade.in
+src/template.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
new file mode 100644 (file)
index 0000000..9686cfe
--- /dev/null
@@ -0,0 +1 @@
+# List of source files which should be skipped during translation
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..9d0e4ef
--- /dev/null
@@ -0,0 +1,30 @@
+NULL=
+
+AM_CPPFLAGS = \
+       -I$(srcdir) \
+       -DPACKAGE_DATA_DIR=\""$(datadir)/lxadmin"\" \
+       -DPACKAGE_UI_DIR=\""$(datadir)/lxadmin/ui"\" \
+       -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+       $(NULL)
+
+bin_PROGRAMS = lxadmin
+lxadmin_SOURCES = \
+       lxadmin.c \
+       $(NULL)
+
+lxadmin_CFLAGS = \
+       $(GTK_CFLAGS) \
+       -Werror-implicit-function-declaration \
+       $(NULL)
+
+lxadmin_LDADD = \
+       $(GTK_LIBS) \
+       $(INTLLIBS) \
+       $(NULL)
+
+
+# Little program to optimize size of xml files
+noinst_PROGRAMS=xml-purge
+xml_purge_SOURCES=$(top_srcdir)/src/xml-purge.c
+xml_purge_CFLAGS=$(GTK_CFLAGS)
+xml_purge_LDADD=$(GTK_LIBS)
diff --git a/src/lxadmin.c b/src/lxadmin.c
new file mode 100644 (file)
index 0000000..6e93421
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ *      lxadmin.c
+ *
+ *      Copyright 2010 PCMan <pcman.tw@gmail.com>
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+static GOptionEntry option_entries[] =
+{
+    { NULL }
+};
+
+int main(int argc, char** argv)
+{
+    GError* err = NULL;
+
+    /* gettext support */
+#ifdef ENABLE_NLS
+    bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR );
+    bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" );
+    textdomain ( GETTEXT_PACKAGE );
+#endif
+
+    /* init threading support */
+    /*
+    g_thread_init(NULL);
+    gdk_threads_init();
+    */
+
+    /* initialize GTK+ and parse the command line arguments */
+    if( G_UNLIKELY( ! gtk_init_with_args( &argc, &argv, "", option_entries, GETTEXT_PACKAGE, &err ) ) )
+    {
+        g_print( "Error: %s\n", err->message );
+        return 1;
+    }
+
+    /* TODO: create GUI here */
+
+    gtk_main();
+
+       return 0;
+}
diff --git a/src/xml-purge.c b/src/xml-purge.c
new file mode 100644 (file)
index 0000000..9fc8525
--- /dev/null
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#define IS_BLANK(ch)   strchr(" \t\n\r", ch)
+
+static void purge_file( const char* file )
+{
+       char* buf, *pbuf;
+       int in_tag = 0, in_quote = 0;
+       FILE* fo;
+
+    if(!g_file_get_contents(file, &buf, NULL, NULL))
+        exit(1);
+
+       fo = fopen( file, "w" );
+       if( ! fo )
+               goto error;
+
+       for( pbuf = buf; *pbuf; ++pbuf )
+       {
+               if( in_tag > 0 )
+               {
+                       if( in_quote )
+                       {
+                               if( *pbuf == '\"' )
+                                       in_quote = 0;
+                       }
+                       else
+                       {
+                               if( *pbuf == '\"' )
+                                       ++in_quote;
+                               if( ! in_quote && IS_BLANK(*pbuf) )     /* skip unnecessary blanks */
+                               {
+                                       do{
+                                               ++pbuf;
+                                       }while( IS_BLANK( *pbuf ) );
+
+                                       if( *pbuf != '>' )
+                                               fputc( ' ', fo );
+                                       --pbuf;
+                                       continue;
+                               }
+                       }
+                       if( *pbuf == '>' )
+                               --in_tag;
+                       fputc( *pbuf, fo );
+               }
+               else
+               {
+                       if( *pbuf == '<' )
+                       {
+                               if( 0 == strncmp( pbuf, "<!--", 4 ) )   /* skip comments */
+                               {
+                                       pbuf = strstr( pbuf, "-->" );
+                                       if( ! pbuf )
+                                               goto error;
+                                       pbuf += 2;
+                                       continue;
+                               }
+                               ++in_tag;
+                               fputc( '<', fo );
+                       }
+                       else
+                       {
+                               char* tmp = pbuf;
+                               while( *tmp && IS_BLANK( *tmp ) && *tmp != '<' )
+                                       ++tmp;
+                               if( *tmp == '<' )       /* all cdata are blank characters */
+                                       pbuf = tmp - 1;
+                               else /* not blank, keep the cdata */
+                               {
+                                       if( tmp == pbuf )
+                                               fputc( *pbuf, fo );
+                                       else
+                                       {
+                                               fwrite( pbuf, 1, tmp - pbuf, fo );
+                                               pbuf = tmp - 1;
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       fclose( fo );
+
+error:
+       free( buf );
+}
+
+int main( int argc, char** argv )
+{
+       int i;
+       if( argc < 2 )
+               return 1;
+
+       for( i = 1; i < argc; ++i )
+               purge_file( argv[ i] );
+
+       return 0;
+}