diff options
-rw-r--r-- | Makefile.am | 82 | ||||
-rwxr-xr-x | autogen.sh | 27 | ||||
-rw-r--r-- | configure.ac | 159 | ||||
-rw-r--r-- | data/indicator-power.service.in | 3 | ||||
-rw-r--r-- | po/POTFILES.in | 0 | ||||
-rw-r--r-- | src/indicator-power.c | 45 | ||||
-rw-r--r-- | src/power-service.c | 50 |
7 files changed, 366 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..044881e --- /dev/null +++ b/Makefile.am @@ -0,0 +1,82 @@ +ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} + +SUBDIRS = po + +############################################################ + +# DBus service file +dbus_servicesdir = $(DBUSSERVICEDIR) +dbus_services_DATA = indicator-power.service + +# Rule to make the service file with libexecdir expanded +%.service: %.service.in + sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ + +############################################################ + +libexec_PROGRAMS = indicator-power-service + +################### +# Indicator Stuff +################### + +powerlibdir = $(INDICATORDIR) +powerlib_LTLIBRARIES = libpower.la +libpower_la_SOURCES = \ + indicator-power.c +libpower_la_CFLAGS = \ + $(INDICATOR_CFLAGS) \ + -Wall -Werror \ + -DG_LOG_DOMAIN=\"Indicator-Power\" +libpower_la_LIBADD = \ + $(INDICATOR_LIBS) +libpower_la_LDFLAGS = \ + -module \ + -avoid-version + +################ +# Status Stuff +################ + +indicator_power_service_SOURCES = \ + power-service.c +indicator_power_service_CFLAGS = \ + $(POWERSERVICE_CFLAGS) \ + -Wall -Werror \ + -DG_LOG_DOMAIN=\"Power-Me\" +indicator_power_service_LDADD = \ + $(POWERSERVICE_LIBS) + +############################################################ + +EXTRA_DIST = autogen.sh + +DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall + +############################################################ + +dist-hook: + @if test -d "$(top_srcdir)/.bzr"; \ + then \ + echo Creating ChangeLog && \ + ( cd "$(top_srcdir)" && \ + echo '# Generated by Makefile. Do not edit.'; echo; \ + $(top_srcdir)/missing --run bzr log --gnu-changelog ) > ChangeLog.tmp \ + && mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \ + || (rm -f ChangeLog.tmp; \ + echo Failed to generate ChangeLog >&2 ); \ + else \ + echo Failed to generate ChangeLog: not a branch >&2; \ + fi + @if test -d "$(top_srcdir)/.bzr"; \ + then \ + echo Creating AUTHORS && \ + ( cd "$(top_srcdir)" && \ + echo '# Generated by Makefile. Do not edit.'; echo; \ + $(top_srcdir)/missing --run bzr log --long --levels=0 | grep -e "^\s*author:" -e "^\s*committer:" | cut -d ":" -f 2 | cut -d "<" -f 1 | sort -u) > AUTHORS.tmp \ + && mv -f AUTHORS.tmp $(top_distdir)/AUTHORS \ + || (rm -f AUTHORS.tmp; \ + echo Failed to generate AUTHORS >&2 ); \ + else \ + echo Failed to generate AUTHORS: not a branch >&2; \ + fi diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..1912c87 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +test -n "$srcdir" || srcdir=`dirname "$0"` +test -n "$srcdir" || srcdir=. + +olddir=`pwd` +cd $srcdir + +AUTORECONF=`which autoreconf` +if test -z $AUTORECONF; then + echo "*** No autoreconf found, please intall it ***" + exit 1 +fi + +INTLTOOLIZE=`which intltoolize` +if test -z $INTLTOOLIZE; then + echo "*** No intltoolize found, please install the intltool package ***" + exit 1 +fi + +mkdir -p build-aux + +autopoint --force +AUTOPOINT='intltoolize --automake --copy' autoreconf --force --install --verbose + +cd $olddir +test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..69c79f8 --- /dev/null +++ b/configure.ac @@ -0,0 +1,159 @@ +AC_INIT([indicator-power], + [0.0.1], + [http://bugs.launchpad.net/indicator-power], + [indicator-power], + [http://launchpad.net/indicator-power]) + +AC_PREREQ([2.64]) + +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_SRCDIR([configure.ac]) +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_AUX_DIR([build-aux]) + +AM_INIT_AUTOMAKE([1.11 -Wall foreign subdir-objects no-dist-gzip dist-xz]) +AM_MAINTAINER_MODE([enable]) + +AM_SILENT_RULES([yes]) + +# Check for programs +AC_PROG_CC +AM_PROG_CC_C_O +AM_PROG_VALAC([0.12]) + +# Initialize libtool +LT_PREREQ([2.2.6]) +LT_INIT + + +########################### +# Dependencies +########################### + +GLIB_REQUIRED_VERSION=2.28 +GIO_UNIX_REQUIRED_VERSION=2.28 +GTK_REQUIRED_VERSION=2.24 +GTK3_REQUIRED_VERSION=3.0 +INDICATOR_DISPLAY_OBJECTS=0.2 +INDICATOR_REQUIRED_VERSION=0.3.0 +DBUSMENUGLIB_REQUIRED_VERSION=0.4 +DBUSMENUGTK_REQUIRED_VERSION=0.4 + +PKG_CHECK_MODULES([POWERSERVICE],[ + dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION + indicator3 >= $INDICATOR_REQUIRED_VERSION + gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION +]) + +AC_ARG_WITH([gtk], + [AS_HELP_STRING([--with-gtk], + [Which version of gtk to use for the indicator @<:@default=3@:>@])], + [], + [with_gtk=3]) + +AS_IF([test "x$with_gtk" = x3], + [PKG_CHECK_MODULES([INDICATOR],[ + gtk+-3.0 >= $GTK3_REQUIRED_VERSION + indicator3 >= $INDICATOR_REQUIRED_VERSION + libido3-0.1 >= $INDICATOR_DISPLAY_OBJECTS + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION])], + [test "x$with_gtk" = x2], + [PKG_CHECK_MODULES([INDICATOR],[ + gtk+-2.0 >= $GTK_REQUIRED_VERSION + indicator >= $INDICATOR_REQUIRED_VERSION + libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION])], + [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])] +) +AC_SUBST(INDICATOR_CFLAGS) +AC_SUBST(INDICATOR_LIBS) + +########################### +# Check to see if we're local +########################### + +with_localinstall="no" +AC_ARG_ENABLE([localinstall], + [AS_HELP_STRING([--enable-localinstall], + [install all of the files localy instead of system directories (for distcheck)])], + [with_localinstall=$enableval], + [with_localinstall=no]) + +########################### +# Indicator Info +########################### + +if test "x$with_localinstall" = "xyes"; then + INDICATORDIR="${libdir}/indicators/3/" + INDICATORICONSDIR="${datadir}/indicator-applet/icons/" +elif test "x$with_gtk" = x2; then + INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator` + INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator` +else + INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator3` + INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator3` +fi +AC_SUBST(INDICATORDIR) +AC_SUBST(INDICATORICONSDIR) + +########################### +# DBus Service Info +########################### + +if test "x$with_localinstall" = "xyes"; then + DBUSSERVICEDIR="${datadir}/dbus-1/services/" +else + DBUSSERVICEDIR=`$PKG_CONFIG --variable=session_bus_services_dir dbus-1` +fi +AC_SUBST(DBUSSERVICEDIR) + +############################## +# Custom Junk +############################## + +AC_DEFUN([AC_DEFINE_PATH], [ + test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + ac_define_path=`eval echo [$]$2` + ac_define_path=`eval echo [$]ac_define_path` + $1="$ac_define_path" + AC_SUBST($1) + ifelse($3, , + AC_DEFINE_UNQUOTED($1, "$ac_define_path"), + AC_DEFINE_UNQUOTED($1, "$ac_define_path", $3)) +]) + +########################### +# Internationalization +########################### + +IT_PROG_INTLTOOL([0.41.0]) + +AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.17]) + +AC_SUBST([GETTEXT_PACKAGE],[PACKAGE_TARNAME]) +AC_DEFINE([GETTEXT_PACKAGE],[PACKAGE_TARNAME],[Define to the gettext package name.]) + +########################### +# Files +########################### + +AC_CONFIG_FILES([ +Makefile +po/Makefile.in +]) +AC_OUTPUT + +########################### +# Results +########################### + +AC_MSG_NOTICE([ + +Me Indicator Configuration: + + Prefix: $prefix + GTK: $with_gtk +]) diff --git a/data/indicator-power.service.in b/data/indicator-power.service.in new file mode 100644 index 0000000..c59c69e --- /dev/null +++ b/data/indicator-power.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=com.canonical.indicator.power +Exec=@libexecdir@/indicator-power-service diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/po/POTFILES.in diff --git a/src/indicator-power.c b/src/indicator-power.c new file mode 100644 index 0000000..2d18827 --- /dev/null +++ b/src/indicator-power.c @@ -0,0 +1,45 @@ +/* +An indicator to power related information in the menubar. + +Copyright 2010 Codethink Ltd. + +Authors: + Javier Jardon <javier.jardon@codethink.co.uk> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* GStuff */ +#include <glib.h> +#include <glib-object.h> +#include <glib/gi18n-lib.h> +#include <gio/gio.h> + +/* Indicator Stuff */ +#include <libindicator/indicator.h> +#include <libindicator/indicator-object.h> +#include <libindicator/indicator-service-manager.h> + +/* DBusMenu */ +#include <libido/libido.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menu.h> +#include <libdbusmenu-gtk3/menuitem.h> +#else +#include <libdbusmenu-gtk/menu.h> +#include <libdbusmenu-gtk/menuitem.h> +#endif diff --git a/src/power-service.c b/src/power-service.c new file mode 100644 index 0000000..909b29b --- /dev/null +++ b/src/power-service.c @@ -0,0 +1,50 @@ +/* +An indicator to power related information in the menubar. + +Copyright 2011 Codethink Ltd. + +Authors: + Javier Jardon <javier.jardon@codethink.co.uk> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <glib.h> +#include <glib/gi18n.h> +#include <gtk/gtk.h> +#include <gio/gio.h> + +#include <libdbusmenu-gtk/menuitem.h> +#include <libdbusmenu-glib/server.h> +#include <libdbusmenu-glib/client.h> +#include <libdbusmenu-glib/menuitem.h> + +#include <libindicator/indicator-service.h> + +gint +main (gint argc, + gchar **argv) +{ + g_type_init(); + + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + setlocale (LC_ALL, ""); + + return 0; +} |