Skip to content

Commit

Permalink
Initial start of indicator-sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmurray committed Apr 3, 2011
0 parents commit cd2ceaa
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 0 deletions.
Empty file added AUTHORS
Empty file.
Empty file added ChangeLog
Empty file.
1 change: 1 addition & 0 deletions Makefile.am
@@ -0,0 +1 @@
SUBDIRS = src pixmaps po
Empty file added NEWS
Empty file.
Empty file added README
Empty file.
21 changes: 21 additions & 0 deletions autogen.sh
@@ -0,0 +1,21 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.

srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.

PKG_NAME="indicator-sensors"

(test -f $srcdir/configure.ac) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level $PKG_NAME directory"
exit 1
}

which gnome-autogen.sh || {
echo -n "ERROR: gnome-autogen.sh not found in path: "
echo "Please install gnome-common before running this script"
exit 1
}

REQUIRED_AUTOMAKE_VERSION=1.7 USE_GNOME2_MACROS=1 . gnome-autogen.sh
141 changes: 141 additions & 0 deletions configure.ac
@@ -0,0 +1,141 @@
# ================= initialization =================== #

AC_INIT([Indicator Sensors], [0.1], [murray.alex@gmail.com],
[indicator-sensors])

AC_CONFIG_SRCDIR([src/indicator-sensors.c])
AM_CONFIG_HEADER([src/config.h])
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE

# ============== basic compiler settings ============= #
AC_PROG_CC
AC_HEADER_STDC

# =================== for plugins ==================== #
AC_PROG_LIBTOOL

# =========== take care of some localization ========= #
AH_TEMPLATE([GETTEXT_PACKAGE], [Package name for gettext])
GETTEXT_PACKAGE=indicator-sensors
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE")
AC_SUBST(GETTEXT_PACKAGE)
AM_GLIB_GNU_GETTEXT
AC_PROG_INTLTOOL

# ========== export compiler / linker options ======== #
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)

# ============== look for dependencies =============== #
# check for headers needed for standard interfaces
#AC_CHECK_HEADERS()

GLIB_REQUIRED=2.14.0
GTK_REQUIRED=2.14.0
APPINDICATOR_REQUIRED=0.0.7

PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)

PKG_CHECK_MODULES(APPINDICATOR, appindicator-0.1 >= $APPINDICATOR_REQUIRED)
AC_SUBST(APPINDICATOR_CFLAGS)
AC_SUBST(APPINDICATOR_LIBS)

AC_CHECK_HEADERS(regex.h)
AC_CHECK_HEADERS(sensors/sensors.h,
AC_CHECK_LIB(sensors, sensors_init,[
AC_DEFINE(HAVE_LIBSENSORS,1,[libsensors is available])
if test "x${SENSORS_DIR}" != "x"; then
LIBSENSORS_CFLAGS="-I${SENSORS_DIR}/include"
LIBSENSORS_LIBS="-L${SENSORS_DIR}/lib -lsensors"
else
LIBSENSORS_LIBS="-lsensors"
fi]))

AM_CONDITIONAL(LIBSENSORS, test -n "$LIBSENSORS_LIBS")

AC_SUBST(LIBSENSORS_CFLAGS)
AC_SUBST(LIBSENSORS_LIBS)

# do nvidia by default if available
AC_ARG_WITH(nvidia,
[ --with-nvidia[=DIR] use nvidia in DIR],[
if test "$withval" != "no" -a "$withval" != "yes"; then
NVIDIA_DIR=$withval
CFLAGS="${CFLAGS} -I${NVIDIA_DIR}/include"
LIBS="${LIBS} -L${NVIDIA_DIR}/lib"
fi
with_nvidia=$withval],[
with_nvidia="yes"
])

if test "$with_nvidia" = "no"; then
echo "Disabling nvidia support"
else
AC_ARG_WITH(x11,
[ --with-x11[=DIR] use x11 in DIR],[
if test "$withval" != "no" -a "$withval" != "yes"; then
X11_DIR=$withval
CFLAGS="${CFLAGS} -I${X11_DIR}/include"
LIBS="${LIBS} -L${X11_DIR}/lib"
fi
with_x11=$withval],[
with_x11="yes"
])

AC_CHECK_HEADERS(X11/Xlib.h,
AC_CHECK_LIB(X11, XOpenDisplay, [ HAVE_X11=true ]))
# can't embed next AC_CHECK_HEADERS in true case of AC_CHECK_LIB
if test "${HAVE_X11}" = "true"; then
LIBS="${LIBS} -lX11 -lXext"
# need to specifically include X11/Xlib header when
# doing checks for NVCtrl headers
AC_CHECK_HEADERS(NVCtrl/NVCtrl.h NVCtrl/NVCtrlLib.h, [ HAVE_NVIDIA=true ], [],
[
#include <X11/Xlib.h>
])
if test "${HAVE_NVIDIA}" = "true"; then
AC_CHECK_LIB(XNVCtrl, XNVCTRLQueryExtension, [
NVIDIA_LIBS="-lXNVCtrl"
AC_DEFINE(HAVE_NVIDIA,1,[nvidia sensors available])
])
fi
fi
fi
AM_CONDITIONAL(NVIDIA, test -n "$NVIDIA_LIBS")

AC_SUBST(NVIDIA_CFLAGS)
AC_SUBST(NVIDIA_LIBS)

AC_SUBST(CFLAGS)
# for help docs stuff
AC_PATH_PROG(XSLTPROC, xsltproc, no)
if test x"$XSLTPROC" = xno; then
AC_MSG_ERROR([xsltproc executable not found in your path - should be installed with libxslt])
fi

GNOME_COMPILE_WARNINGS(maximum)

# ================ gnome-doc-utils stuff ============= #
GNOME_DOC_INIT

# ==================== plugin stuff ================== #
PLUGIN_LIBTOOL_FLAGS="-module -avoid-version"
AC_SUBST(PLUGIN_LIBTOOL_FLAGS)

# ================= generate files =================== #
AC_CONFIG_FILES([
Makefile
src/Makefile
pixmaps/Makefile
po/Makefile.in
])
AC_OUTPUT
Empty file added pixmaps/Makefile.am
Empty file.
Empty file added po/POTFILES.in
Empty file.
16 changes: 16 additions & 0 deletions src/Makefile.am
@@ -0,0 +1,16 @@
## Process this file with automake to produce Makefile.in
INCLUDES = -DGNOMELOCALEDIR=\""$(datadir)/locale/"\" \
-DG_LOG_DOMAIN=\""Sensors Applet"\" \
-DPIXMAPS_DIR=\""$(datadir)/pixmaps/$(PACKAGE)/"\" \
-DDATADIR=\""$(datadir)"\" \
-DLIBDIR=\""$(libdir)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DPREFIX=\""$(prefix)"\" \
-I$(top_srcdir) \
$(GLIB_CFLAGS) $(GTK_CFLAGS) $(APPINDICATOR_CFLAGS)


LIBS = $(GLIB_LIBS) $(GTK_LIBS) $(APPINDICATOR_LIBS)

bin_PROGRAMS = indicator-sensors
indicator_sensors_SOURCES = indicator-sensors.c
60 changes: 60 additions & 0 deletions src/indicator-sensors.c
@@ -0,0 +1,60 @@
#include <gtk/gtk.h>
#include <libappindicator/app-indicator.h>

static void activate_action(GtkAction *action);

static GtkActionEntry entries[] = {
{ "Preferences", "application-preferences", "_Preferences", NULL,
"Preferences...", G_CALLBACK(activate_action) },
{ "Quit", "application-exit", "_Quit", "<control>Q",
"Exit indicator-sensors", G_CALLBACK(gtk_main_quit) },
};
static guint n_entries = G_N_ELEMENTS(entries);

static const gchar *ui_info =
"<ui>"
" <popup name='Indicator'>"
" <menuitem action='Preferences' />"
" </popup>"
"</ui>";

static void activate_action(GtkAction *action)
{
g_debug("activated action %s", gtk_action_get_name(action));
}

int main(int argc, char **argv)
{
AppIndicator *indicator;
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
GtkWidget *menu;
GError *error = NULL;

gtk_init(&argc, &argv);

indicator = app_indicator_new("indicator-sensors",
"indicator-sensors",
APP_INDICATOR_CATEGORY_HARDWARE);

action_group = gtk_action_group_new("AppActions");
gtk_action_group_add_actions(action_group,
entries, n_entries,
indicator);

ui_manager = gtk_ui_manager_new();
gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
if (!gtk_ui_manager_add_ui_from_string(ui_manager, ui_info, -1, &error)) {
g_error("Failed to build menus: %s\n", error->message);
}

menu = gtk_ui_manager_get_widget(ui_manager, "/ui/Indicator");

app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_attention_icon(indicator, "indicator-sensors");
app_indicator_set_label(indicator, "indicator-sensors", "indicator-sensors");
app_indicator_set_menu(indicator, GTK_MENU(menu));
gtk_main ();

return 0;
}

0 comments on commit cd2ceaa

Please sign in to comment.