2006-08-31 Esteban Sanchez <estebans@artica.es>
* Initial import. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@172 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
1
pandora_applet/AUTHORS
Normal file
@ -0,0 +1 @@
|
|||||||
|
Esteban Sanchez <estebans@artica.es>
|
1
pandora_applet/COPYING
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/usr/share/automake-1.4/COPYING
|
3
pandora_applet/ChangeLog
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
2006-08-31 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
|
* Initial import.
|
1
pandora_applet/INSTALL
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/usr/share/automake-1.4/INSTALL
|
2
pandora_applet/Makefile.am
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
SUBDIRS=src data
|
||||||
|
|
0
pandora_applet/NEWS
Normal file
0
pandora_applet/README
Normal file
94
pandora_applet/acinclude.m4
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
dnl @synopsis CHECK_MYSQL_DB
|
||||||
|
dnl
|
||||||
|
dnl This macro tries to find the headers and librariess for the
|
||||||
|
dnl MySQL database to build client applications.
|
||||||
|
dnl
|
||||||
|
dnl If includes are found, the variable MYSQL_INC will be set. If
|
||||||
|
dnl libraries are found, the variable MYSQL_LIB will be set. if no check
|
||||||
|
dnl was successful, the script exits with a error message.
|
||||||
|
dnl
|
||||||
|
dnl @category InstalledPackages
|
||||||
|
dnl @author Harald Welte <laforge@gnumonks.org>
|
||||||
|
dnl @version 2006-01-07
|
||||||
|
dnl @license AllPermissive
|
||||||
|
|
||||||
|
AC_DEFUN([CHECK_MYSQL_DB], [
|
||||||
|
|
||||||
|
AC_ARG_WITH(mysql,
|
||||||
|
[ --with-mysql=PREFIX Prefix of your MySQL installation],
|
||||||
|
[my_prefix=$withval], [my_prefix=])
|
||||||
|
AC_ARG_WITH(mysql-inc,
|
||||||
|
[ --with-mysql-inc=PATH Path to the include directory of MySQL],
|
||||||
|
[my_inc=$withval], [my_inc=])
|
||||||
|
AC_ARG_WITH(mysql-lib,
|
||||||
|
[ --with-mysql-lib=PATH Path to the libraries of MySQL],
|
||||||
|
[my_lib=$withval], [my_lib=])
|
||||||
|
|
||||||
|
|
||||||
|
AC_SUBST(MYSQL_INC)
|
||||||
|
AC_SUBST(MYSQL_LIB)
|
||||||
|
|
||||||
|
if test "$my_prefix" != "no"; then
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for MySQL mysql_config program])
|
||||||
|
for d in $my_prefix/bin /usr/bin /usr/local/bin /usr/local/mysql/bin /opt/mysql/bin /opt/packages/mysql/bin
|
||||||
|
do
|
||||||
|
if test -x $d/mysql_config
|
||||||
|
then
|
||||||
|
AC_MSG_RESULT(found mysql_config in $d)
|
||||||
|
MYSQL_INC=$($d/mysql_config --include)
|
||||||
|
MYSQL_LIB=$($d/mysql_config --libs)
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if test "$MYSQL_INC" = ""; then
|
||||||
|
AC_MSG_RESULT(mysql_config not found)
|
||||||
|
if test "$my_prefix" != ""; then
|
||||||
|
AC_MSG_CHECKING([for MySQL includes in $my_prefix/include])
|
||||||
|
if test -f "$my_prefix/include/mysql.h" ; then
|
||||||
|
MYSQL_INC="-I$my_prefix/include"
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR(mysql.h not found)
|
||||||
|
fi
|
||||||
|
AC_MSG_CHECKING([for MySQL libraries in $my_prefix/lib])
|
||||||
|
if test -f "$my_prefix/lib/libmysql.so" ; then
|
||||||
|
MYSQL_LIB="-L$my_prefix/lib -lmysqlclient"
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR(libmysqlclient.so not found)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if test "$my_inc" != ""; then
|
||||||
|
AC_MSG_CHECKING([for MySQL includes in $my_inc])
|
||||||
|
if test -f "$my_inc/mysql.h" ; then
|
||||||
|
MYSQL_INC="-I$my_inc"
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR(mysql.h not found)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "$my_lib" != ""; then
|
||||||
|
AC_MSG_CHECKING([for MySQL libraries in $my_lib])
|
||||||
|
if test -f "$my_lib/libmysqlclient.so" ; then
|
||||||
|
MYSQL_LIB="-L$my_lib -lmysqlclient"
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR(libmysqlclient.so not found)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$MYSQL_INC" = "" ; then
|
||||||
|
AC_CHECK_HEADER([mysql.h], [], AC_MSG_ERROR(mysql.h not found))
|
||||||
|
fi
|
||||||
|
if test "$MYSQL_LIB" = "" ; then
|
||||||
|
AC_CHECK_LIB(mysqlclient, mysql_close, [], AC_MSG_ERROR(libmysqlclient.so not found))
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
])
|
45
pandora_applet/autogen.sh
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# $Id: autogen.sh,v 1.4 2002/12/02 01:39:49 murrayc Exp $
|
||||||
|
#
|
||||||
|
# Copyright (c) 2002 Daniel Elstner <daniel.elstner@gmx.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License VERSION 2 as
|
||||||
|
# published by the Free Software Foundation. You are not allowed to
|
||||||
|
# use any other version of the license; unless you got the explicit
|
||||||
|
# permission from the author to do so.
|
||||||
|
#
|
||||||
|
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
dir=`echo "$0" | sed 's,[^/]*$,,'`
|
||||||
|
test "x${dir}" = "x" && dir='.'
|
||||||
|
|
||||||
|
if test "x`cd "${dir}" 2>/dev/null && pwd`" != "x`pwd`"
|
||||||
|
then
|
||||||
|
echo "This script must be executed directly from the source directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f config.cache acconfig.h
|
||||||
|
|
||||||
|
echo "- Running aclocal." && \
|
||||||
|
aclocal && \
|
||||||
|
echo "- Running autoconf." && \
|
||||||
|
autoconf && \
|
||||||
|
echo "- Running autoheader." && \
|
||||||
|
autoheader && \
|
||||||
|
echo "- Running automake." && \
|
||||||
|
automake --add-missing --gnu && \
|
||||||
|
echo && \
|
||||||
|
./configure "$@" && exit 0
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|
58
pandora_applet/configure.in
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
AC_PREREQ(2.59)
|
||||||
|
|
||||||
|
m4_define([pandoraapplet_major_version], [1])
|
||||||
|
m4_define([pandoraapplet_minor_version], [0])
|
||||||
|
m4_define([pandoraapplet_micro_version], [0])
|
||||||
|
m4_define([pandoraapplet_build_version], [])
|
||||||
|
m4_define([pandoraapplet_version], m4_format('%s.%s.%s%s', pandoraapplet_major_version, pandoraapplet_minor_version, pandoraapplet_micro_version, pandoraapplet_build_version))
|
||||||
|
|
||||||
|
AC_INIT([pandora-applet], [pandoraapplet_version], [http://sourceforge.net/], [pandora_applet])
|
||||||
|
AC_CONFIG_SRCDIR([src/main.c])
|
||||||
|
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
|
||||||
|
|
||||||
|
AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS")
|
||||||
|
|
||||||
|
AM_CONFIG_HEADER(config.h)
|
||||||
|
AM_MAINTAINER_MODE
|
||||||
|
|
||||||
|
AC_ISC_POSIX
|
||||||
|
AC_PROG_CC
|
||||||
|
AM_PROG_CC_STDC
|
||||||
|
AC_STDC_HEADERS
|
||||||
|
|
||||||
|
GLIB_REQUIRED=2.6.0
|
||||||
|
GTK_REQUIRED=2.8.0
|
||||||
|
|
||||||
|
PKG_CHECK_MODULES(PANDORA,
|
||||||
|
glib-2.0 >= $GLIB_REQUIRED
|
||||||
|
gtk+-2.0 >= $GTK_REQUIRED
|
||||||
|
gthread-2.0
|
||||||
|
libxml-2.0)
|
||||||
|
|
||||||
|
CHECK_MYSQL_DB
|
||||||
|
|
||||||
|
GETTEXT_PACKAGE=pandora-applet
|
||||||
|
AC_SUBST(GETTEXT_PACKAGE)
|
||||||
|
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The gettext package])
|
||||||
|
ALL_LINGUAS=""
|
||||||
|
AM_GLIB_GNU_GETTEXT
|
||||||
|
|
||||||
|
if test "x${prefix}" = "xNONE"; then
|
||||||
|
AC_DEFINE_UNQUOTED(PIXMAPS_DIR, "${ac_default_prefix}/$DATADIRNAME/${PACKAGE}/pixmaps", [Pixmaps directory])
|
||||||
|
pixmaps_dir="${ac_default_prefix}/$DATADIRNAME/${PACKAGE}/pixmaps"
|
||||||
|
else
|
||||||
|
AC_DEFINE_UNQUOTED(PIXMAPS_DIR, "${prefix}/$DATADIRNAME/${PACKAGE}/pixmaps", [Pixmaps directory])
|
||||||
|
pixmaps_dir="${prefix}/$DATADIRNAME/${PACKAGE}/pixmaps"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST(pixmaps_dir)
|
||||||
|
|
||||||
|
AC_SUBST(PANDORA_CFLAGS)
|
||||||
|
AC_SUBST(PANDORA_LIBS)
|
||||||
|
|
||||||
|
AC_CONFIG_FILES([
|
||||||
|
Makefile
|
||||||
|
src/Makefile
|
||||||
|
data/Makefile])
|
||||||
|
|
||||||
|
AC_OUTPUT
|
20
pandora_applet/data/Makefile.am
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
pixmapsdir = $(pixmaps_dir)
|
||||||
|
|
||||||
|
pixmaps_DATA = \
|
||||||
|
pandora-applet-bad.png \
|
||||||
|
pandora-applet-good.png \
|
||||||
|
pandora-applet-unknown.png \
|
||||||
|
pandora-alerts-bad.png \
|
||||||
|
pandora-alerts-ok.png \
|
||||||
|
pandora-alerts-unknown.png \
|
||||||
|
pandora-servers-bad.png \
|
||||||
|
pandora-servers-ok.png \
|
||||||
|
pandora-servers-unknown.png \
|
||||||
|
pandora-agents-bad.png \
|
||||||
|
pandora-agents-ok.png \
|
||||||
|
pandora-agents-unknown.png \
|
||||||
|
pandora.png
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
$(pixmaps_DATA)
|
||||||
|
|
116
pandora_applet/data/bubble-source.svg
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://web.resource.org/cc/"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="48px"
|
||||||
|
height="48px"
|
||||||
|
id="svg1800"
|
||||||
|
sodipodi:version="0.32"
|
||||||
|
inkscape:version="0.43"
|
||||||
|
sodipodi:docbase="/home/esteban/work/src/applet/data"
|
||||||
|
sodipodi:docname="bubble.svg"
|
||||||
|
inkscape:export-filename="/home/esteban/work/src/applet/data/bubble.png"
|
||||||
|
inkscape:export-xdpi="392"
|
||||||
|
inkscape:export-ydpi="392">
|
||||||
|
<defs
|
||||||
|
id="defs3" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
fill="#edd400"
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="0.20392157"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="8"
|
||||||
|
inkscape:cx="14.13602"
|
||||||
|
inkscape:cy="30.31033"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:grid-bbox="true"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:showpageshadow="false"
|
||||||
|
inkscape:window-width="1014"
|
||||||
|
inkscape:window-height="693"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="25" />
|
||||||
|
<metadata
|
||||||
|
id="metadata4">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<cc:license
|
||||||
|
rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
|
||||||
|
<dc:title>Emblem Important</dc:title>
|
||||||
|
<dc:creator>
|
||||||
|
<cc:Agent>
|
||||||
|
<dc:title>Jakub Steiner</dc:title>
|
||||||
|
</cc:Agent>
|
||||||
|
</dc:creator>
|
||||||
|
<dc:subject>
|
||||||
|
<rdf:Bag>
|
||||||
|
<rdf:li>emblem</rdf:li>
|
||||||
|
<rdf:li>photos</rdf:li>
|
||||||
|
<rdf:li>pictures</rdf:li>
|
||||||
|
<rdf:li>raw</rdf:li>
|
||||||
|
<rdf:li>jpeg</rdf:li>
|
||||||
|
</rdf:Bag>
|
||||||
|
</dc:subject>
|
||||||
|
</cc:Work>
|
||||||
|
<cc:License
|
||||||
|
rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://web.resource.org/cc/Reproduction" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://web.resource.org/cc/Distribution" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://web.resource.org/cc/Notice" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://web.resource.org/cc/Attribution" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://web.resource.org/cc/ShareAlike" />
|
||||||
|
</cc:License>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
id="layer1"
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="opacity:1.0000000;fill:#61f500;fill-opacity:1;fill-rule:nonzero;stroke:#22c900;stroke-width:1.55896229;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1"
|
||||||
|
id="path1650"
|
||||||
|
sodipodi:cx="24.130018"
|
||||||
|
sodipodi:cy="23.428040"
|
||||||
|
sodipodi:rx="22.008699"
|
||||||
|
sodipodi:ry="21.213203"
|
||||||
|
d="M 46.138718 23.428040 A 22.008699 21.213203 0 1 1 2.1213188,23.428040 A 22.008699 21.213203 0 1 1 46.138718 23.428040 z"
|
||||||
|
transform="matrix(0.944630,0.000000,0.000000,0.980053,1.504174,-1.556912)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="opacity:1.0000000;fill:none;fill-opacity:1.0000000;fill-rule:nonzero;stroke:#3efc61;stroke-width:0.98214942;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1"
|
||||||
|
id="path3392"
|
||||||
|
sodipodi:cx="24.130018"
|
||||||
|
sodipodi:cy="23.428040"
|
||||||
|
sodipodi:rx="22.008699"
|
||||||
|
sodipodi:ry="21.213203"
|
||||||
|
d="M 46.138718 23.428040 A 22.008699 21.213203 0 1 1 2.1213188,23.428040 A 22.008699 21.213203 0 1 1 46.138718 23.428040 z"
|
||||||
|
transform="matrix(0.914086,0.000000,0.000000,0.948364,2.380576,-0.905815)" />
|
||||||
|
<path
|
||||||
|
style="fill:#fffeff;fill-opacity:0.21390374;fill-rule:nonzero;stroke:none;stroke-width:1.0000000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000"
|
||||||
|
d="M 43.676426,20.476780 C 43.676426,31.307396 37.624257,16.170581 25.001688,20.863168 C 12.279172,25.592912 4.4350535,31.307396 4.4350535,20.476780 C 4.4350535,9.6461627 13.225120,0.85609769 24.055740,0.85609769 C 34.886359,0.85609769 43.676426,9.6461627 43.676426,20.476780 z "
|
||||||
|
id="path3068"
|
||||||
|
sodipodi:nodetypes="czssc" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.7 KiB |
213
pandora_applet/data/help-browser.svg
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://web.resource.org/cc/"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="48.000000px"
|
||||||
|
height="48.000000px"
|
||||||
|
id="svg6361"
|
||||||
|
sodipodi:version="0.32"
|
||||||
|
inkscape:version="0.43+devel"
|
||||||
|
sodipodi:docbase="/home/tigert/cvs/freedesktop.org/tango-icon-theme/scalable/apps"
|
||||||
|
sodipodi:docname="help-browser.svg"
|
||||||
|
inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||||
|
<defs
|
||||||
|
id="defs3">
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient2431">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ffffff;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop2433" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#b8b8b8;stop-opacity:1;"
|
||||||
|
offset="1"
|
||||||
|
id="stop2435" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
id="linearGradient21644">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop21646" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop21648" />
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient21644"
|
||||||
|
id="radialGradient21650"
|
||||||
|
cx="25.125"
|
||||||
|
cy="36.75"
|
||||||
|
fx="25.125"
|
||||||
|
fy="36.75"
|
||||||
|
r="15.75"
|
||||||
|
gradientTransform="matrix(1.000000,0.000000,0.000000,0.595238,3.369686e-16,14.87500)"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient2933">
|
||||||
|
<stop
|
||||||
|
id="stop2935"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#9cbcde;stop-opacity:1" />
|
||||||
|
<stop
|
||||||
|
id="stop2937"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#204a87" />
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient2933"
|
||||||
|
id="radialGradient2207"
|
||||||
|
cx="26.544321"
|
||||||
|
cy="28.458725"
|
||||||
|
fx="26.544321"
|
||||||
|
fy="28.458725"
|
||||||
|
r="22.376116"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="matrix(1.238342,5.954846e-3,-6.507762e-3,1.351272,-6.992513,-9.744842)" />
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient2431"
|
||||||
|
id="radialGradient2437"
|
||||||
|
cx="-19.515638"
|
||||||
|
cy="16.855663"
|
||||||
|
fx="-19.515638"
|
||||||
|
fy="16.855663"
|
||||||
|
r="8.7536434"
|
||||||
|
gradientTransform="matrix(4.445991,-8.852599e-16,1.367217e-15,6.8665,67.25071,-104.6679)"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
inkscape:guide-bbox="true"
|
||||||
|
showguides="true"
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="0.15294118"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="1"
|
||||||
|
inkscape:cx="25.160747"
|
||||||
|
inkscape:cy="22.523569"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:grid-bbox="true"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:window-width="1014"
|
||||||
|
inkscape:window-height="1122"
|
||||||
|
inkscape:window-x="178"
|
||||||
|
inkscape:window-y="25"
|
||||||
|
inkscape:showpageshadow="false"
|
||||||
|
fill="#deb887"
|
||||||
|
gridcolor="#7171cd"
|
||||||
|
gridopacity="0.12156863"
|
||||||
|
gridempcolor="#7b7bc3"
|
||||||
|
gridempopacity="0.5372549"
|
||||||
|
gridempspacing="10"
|
||||||
|
stroke="#204a87" />
|
||||||
|
<metadata
|
||||||
|
id="metadata4">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title>Help Browser</dc:title>
|
||||||
|
<dc:date>2005-11-06</dc:date>
|
||||||
|
<dc:creator>
|
||||||
|
<cc:Agent>
|
||||||
|
<dc:title>Tuomas Kuosmanen</dc:title>
|
||||||
|
</cc:Agent>
|
||||||
|
</dc:creator>
|
||||||
|
<dc:subject>
|
||||||
|
<rdf:Bag>
|
||||||
|
<rdf:li>help</rdf:li>
|
||||||
|
<rdf:li>browser</rdf:li>
|
||||||
|
<rdf:li>documentation</rdf:li>
|
||||||
|
<rdf:li>docs</rdf:li>
|
||||||
|
<rdf:li>man</rdf:li>
|
||||||
|
<rdf:li>info</rdf:li>
|
||||||
|
</rdf:Bag>
|
||||||
|
</dc:subject>
|
||||||
|
<cc:license
|
||||||
|
rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
|
||||||
|
<dc:contributor>
|
||||||
|
<cc:Agent>
|
||||||
|
<dc:title>Jakub Steiner, Andreas Nilsson</dc:title>
|
||||||
|
</cc:Agent>
|
||||||
|
</dc:contributor>
|
||||||
|
<dc:source>http://tigert.com</dc:source>
|
||||||
|
</cc:Work>
|
||||||
|
<cc:License
|
||||||
|
rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://web.resource.org/cc/Reproduction" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://web.resource.org/cc/Distribution" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://web.resource.org/cc/Notice" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://web.resource.org/cc/Attribution" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://web.resource.org/cc/ShareAlike" />
|
||||||
|
</cc:License>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
id="layer1"
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="opacity:0.63068181;color:#000000;fill:url(#radialGradient21650);fill-opacity:1.0000000;fill-rule:evenodd;stroke:none;stroke-width:1.0000000;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:inline;overflow:visible"
|
||||||
|
id="path21642"
|
||||||
|
sodipodi:cx="25.125000"
|
||||||
|
sodipodi:cy="36.750000"
|
||||||
|
sodipodi:rx="15.750000"
|
||||||
|
sodipodi:ry="9.3750000"
|
||||||
|
d="M 40.875000 36.750000 A 15.750000 9.3750000 0 1 1 9.3750000,36.750000 A 15.750000 9.3750000 0 1 1 40.875000 36.750000 z"
|
||||||
|
transform="matrix(1.173803,0.000000,0.000000,0.600000,-5.004403,20.32500)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:url(#radialGradient2207);fill-opacity:1.0000000;stroke:#204a87"
|
||||||
|
id="path2093"
|
||||||
|
sodipodi:cx="23.909048"
|
||||||
|
sodipodi:cy="23.825787"
|
||||||
|
sodipodi:rx="21.876116"
|
||||||
|
sodipodi:ry="21.876116"
|
||||||
|
d="M 45.785164 23.825787 A 21.876116 21.876116 0 1 1 2.0329323,23.825787 A 21.876116 21.876116 0 1 1 45.785164 23.825787 z"
|
||||||
|
transform="matrix(0.938442,0.000000,0.000000,0.938680,1.564075,1.633906)" />
|
||||||
|
<path
|
||||||
|
transform="matrix(0.855103,0.000000,0.000000,0.855213,3.555288,3.625019)"
|
||||||
|
d="M 45.785164 23.825787 A 21.876116 21.876116 0 1 1 2.0329323,23.825787 A 21.876116 21.876116 0 1 1 45.785164 23.825787 z"
|
||||||
|
sodipodi:ry="21.876116"
|
||||||
|
sodipodi:rx="21.876116"
|
||||||
|
sodipodi:cy="23.825787"
|
||||||
|
sodipodi:cx="23.909048"
|
||||||
|
id="path2209"
|
||||||
|
style="fill:none;fill-opacity:1.0000000;stroke:#ffffff;stroke-width:3.0307744;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-opacity:1.0000000;opacity:0.96022727"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="inkscape:offset"
|
||||||
|
inkscape:radius="0.13495015"
|
||||||
|
inkscape:original="M -20.25 6 C -21.298341 6.000026 -22.372769 6.1244771 -23.5 6.34375 C -24.627244 6.563073 -25.886043 6.8832479 -27.25 7.34375 L -27.25 12.5 C -26.100219 11.776335 -24.997109 11.236862 -23.9375 10.875 C -22.877902 10.502213 -21.881822 10.312521 -20.96875 10.3125 C -19.999334 10.312521 -19.259834 10.530174 -18.71875 10.96875 C -18.177686 11.396402 -17.906262 12.013726 -17.90625 12.78125 C -17.906261 13.285654 -18.039408 13.776881 -18.34375 14.28125 C -18.636843 14.785651 -19.107484 15.33609 -19.75 15.90625 L -20.84375 16.84375 C -22.038631 17.918325 -22.815518 18.829509 -23.1875 19.53125 C -23.559495 20.22205 -23.750005 21.007137 -23.75 21.90625 L -23.75 22.71875 L -17.65625 22.71875 L -17.65625 21.96875 C -17.656262 21.475338 -17.517981 21.030712 -17.28125 20.625 C -17.044542 20.208345 -16.547785 19.648586 -15.78125 18.96875 L -14.71875 18.03125 C -13.659161 17.055386 -12.908389 16.156813 -12.46875 15.3125 C -12.029144 14.457253 -11.781268 13.480828 -11.78125 12.40625 C -11.781268 10.311973 -12.525902 8.7417969 -13.96875 7.65625 C -15.41163 6.559783 -17.499549 6.0000261 -20.25 6 z M -23.75 25.15625 L -23.75 31 L -17.65625 31 L -17.65625 25.15625 L -23.75 25.15625 z "
|
||||||
|
xlink:href="#text2215"
|
||||||
|
style="font-size:34.15322876px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:url(#radialGradient2437);fill-opacity:1;stroke:#ffffff;stroke-width:1.09947276px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.78612713;font-family:Bitstream Vera Sans"
|
||||||
|
id="path1554"
|
||||||
|
d="M -20.25,5.875 C -21.309019,5.8750263 -22.397637,5.9982356 -23.53125,6.21875 C -24.664175,6.4391783 -25.911412,6.7562625 -27.28125,7.21875 C -27.291632,7.21754 -27.302118,7.21754 -27.3125,7.21875 C -27.324563,7.2273788 -27.335121,7.237937 -27.34375,7.25 C -27.355813,7.2586288 -27.366371,7.269187 -27.375,7.28125 C -27.37621,7.2916315 -27.37621,7.3021185 -27.375,7.3125 C -27.37621,7.3228815 -27.37621,7.3333685 -27.375,7.34375 L -27.375,12.5 C -27.37621,12.510382 -27.37621,12.520868 -27.375,12.53125 C -27.37621,12.541632 -27.37621,12.552118 -27.375,12.5625 C -27.366371,12.574563 -27.355813,12.585121 -27.34375,12.59375 C -27.335121,12.605813 -27.324563,12.616371 -27.3125,12.625 C -27.302118,12.62621 -27.291632,12.62621 -27.28125,12.625 C -27.270868,12.62621 -27.260382,12.62621 -27.25,12.625 C -27.239618,12.62621 -27.229132,12.62621 -27.21875,12.625 C -27.208368,12.62621 -27.197882,12.62621 -27.1875,12.625 C -26.045062,11.905957 -24.954148,11.357862 -23.90625,11 C -22.858109,10.631244 -21.863134,10.437521 -20.96875,10.4375 C -20.019532,10.437521 -19.323825,10.648045 -18.8125,11.0625 C -18.303777,11.46459 -18.031262,12.04554 -18.03125,12.78125 C -18.03126,13.261907 -18.175438,13.73266 -18.46875,14.21875 C -18.751741,14.705766 -19.209015,15.249245 -19.84375,15.8125 L -20.9375,16.75 C -22.138959,17.83049 -22.926743,18.741022 -23.3125,19.46875 C -23.695613,20.180196 -23.875005,20.988074 -23.875,21.90625 L -23.875,22.71875 C -23.87621,22.729132 -23.87621,22.739618 -23.875,22.75 C -23.87621,22.760382 -23.87621,22.770868 -23.875,22.78125 C -23.866371,22.793313 -23.855813,22.803871 -23.84375,22.8125 C -23.835121,22.824563 -23.824563,22.835121 -23.8125,22.84375 C -23.802118,22.84496 -23.791632,22.84496 -23.78125,22.84375 C -23.770868,22.84496 -23.760382,22.84496 -23.75,22.84375 L -17.65625,22.84375 C -17.645868,22.84496 -17.635382,22.84496 -17.625,22.84375 C -17.614618,22.84496 -17.604132,22.84496 -17.59375,22.84375 C -17.581687,22.835121 -17.571129,22.824563 -17.5625,22.8125 C -17.550437,22.803871 -17.539879,22.793313 -17.53125,22.78125 C -17.53004,22.770868 -17.53004,22.760382 -17.53125,22.75 C -17.53004,22.739618 -17.53004,22.729132 -17.53125,22.71875 L -17.53125,21.96875 C -17.531261,21.500554 -17.38288,21.075901 -17.15625,20.6875 C -16.933955,20.296216 -16.448177,19.737141 -15.6875,19.0625 L -14.625,18.125 C -13.558412,17.14269 -12.794341,16.240346 -12.34375,15.375 C -11.894481,14.500954 -11.656268,13.50158 -11.65625,12.40625 C -11.656268,10.279985 -12.400019,8.6722224 -13.875,7.5625 C -15.350197,6.4414748 -17.48124,5.8750263 -20.25,5.875 z M -23.8125,25.03125 C -23.824563,25.039879 -23.835121,25.050437 -23.84375,25.0625 C -23.855813,25.071129 -23.866371,25.081687 -23.875,25.09375 C -23.87621,25.104132 -23.87621,25.114618 -23.875,25.125 C -23.87621,25.135382 -23.87621,25.145868 -23.875,25.15625 L -23.875,31 C -23.87621,31.010382 -23.87621,31.020868 -23.875,31.03125 C -23.87621,31.041632 -23.87621,31.052118 -23.875,31.0625 C -23.866371,31.074563 -23.855813,31.085121 -23.84375,31.09375 C -23.835121,31.105813 -23.824563,31.116371 -23.8125,31.125 C -23.802118,31.12621 -23.791632,31.12621 -23.78125,31.125 C -23.770868,31.12621 -23.760382,31.12621 -23.75,31.125 L -17.65625,31.125 C -17.645868,31.12621 -17.635382,31.12621 -17.625,31.125 C -17.614618,31.12621 -17.604132,31.12621 -17.59375,31.125 C -17.581687,31.116371 -17.571129,31.105813 -17.5625,31.09375 C -17.550437,31.085121 -17.539879,31.074563 -17.53125,31.0625 C -17.53004,31.052118 -17.53004,31.041632 -17.53125,31.03125 C -17.53004,31.020868 -17.53004,31.010382 -17.53125,31 L -17.53125,25.15625 C -17.53004,25.145868 -17.53004,25.135382 -17.53125,25.125 C -17.53004,25.114618 -17.53004,25.104132 -17.53125,25.09375 C -17.539879,25.081687 -17.550437,25.071129 -17.5625,25.0625 C -17.571129,25.050437 -17.581687,25.039879 -17.59375,25.03125 C -17.604132,25.03004 -17.614618,25.03004 -17.625,25.03125 C -17.635382,25.03004 -17.645868,25.03004 -17.65625,25.03125 L -23.75,25.03125 C -23.760382,25.03004 -23.770868,25.03004 -23.78125,25.03125 C -23.791632,25.03004 -23.802118,25.03004 -23.8125,25.03125 z "
|
||||||
|
transform="matrix(0.849895,0,0,0.835205,41.72981,8.548327)" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 13 KiB |
1131
pandora_applet/data/lamp-source.svg
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
pandora_applet/data/pandora-agents-bad.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
pandora_applet/data/pandora-agents-ok.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
pandora_applet/data/pandora-agents-unknown.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
pandora_applet/data/pandora-alerts-bad.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
pandora_applet/data/pandora-alerts-ok.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
pandora_applet/data/pandora-alerts-unknown.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
pandora_applet/data/pandora-applet-bad.png
Normal file
After Width: | Height: | Size: 960 B |
BIN
pandora_applet/data/pandora-applet-good.png
Normal file
After Width: | Height: | Size: 968 B |
BIN
pandora_applet/data/pandora-applet-unknown.png
Normal file
After Width: | Height: | Size: 964 B |
BIN
pandora_applet/data/pandora-servers-bad.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
pandora_applet/data/pandora-servers-ok.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
pandora_applet/data/pandora-servers-unknown.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
pandora_applet/data/pandora.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
3095
pandora_applet/data/server-source.svg
Normal file
After Width: | Height: | Size: 113 KiB |
8
pandora_applet/po/POTFILES.in
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[encoding: UTF-8]
|
||||||
|
# List of source files containing translatable strings.
|
||||||
|
# Please keep this file sorted alphabetically.
|
||||||
|
|
||||||
|
src/main.c
|
||||||
|
src/pandora-applet.c
|
||||||
|
src/pandora-info-window.c
|
||||||
|
src/pandora-setup-dialog.c
|
20
pandora_applet/src/Makefile.am
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
INCLUDES = $(PANDORA_CFLAGS) \
|
||||||
|
$(MYSQL_INC) \
|
||||||
|
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
|
||||||
|
-DGLADEDIR=\""$(gladedir)"\"
|
||||||
|
|
||||||
|
bin_PROGRAMS = pandora-applet
|
||||||
|
|
||||||
|
pandora_applet_SOURCES = main.c \
|
||||||
|
pandora-applet.c pandora-applet.h \
|
||||||
|
pandora-setup.c pandora-setup.h \
|
||||||
|
pandora-status.c pandora-status.h \
|
||||||
|
pandora-status-checker.c pandora-status-checker.h \
|
||||||
|
pandora-info-window.c pandora-info-window.h \
|
||||||
|
pandora-setup-dialog.c pandora-setup-dialog.h \
|
||||||
|
eggtrayicon.c eggtrayicon.h
|
||||||
|
|
||||||
|
pandora_applet_LDADD = $(PANDORA_LIBS) \
|
||||||
|
$(MYSQL_LIB)
|
||||||
|
|
559
pandora_applet/src/eggtrayicon.c
Normal file
@ -0,0 +1,559 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||||
|
/* eggtrayicon.c
|
||||||
|
* Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <libintl.h>
|
||||||
|
|
||||||
|
#include "eggtrayicon.h"
|
||||||
|
|
||||||
|
#include <gdkconfig.h>
|
||||||
|
#if defined (GDK_WINDOWING_X11)
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#elif defined (GDK_WINDOWING_WIN32)
|
||||||
|
#include <gdk/gdkwin32.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EGG_COMPILATION
|
||||||
|
#ifndef _
|
||||||
|
#define _(x) dgettext (GETTEXT_PACKAGE, x)
|
||||||
|
#define N_(x) x
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define _(x) x
|
||||||
|
#define N_(x) x
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SYSTEM_TRAY_REQUEST_DOCK 0
|
||||||
|
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
|
||||||
|
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
|
||||||
|
|
||||||
|
#define SYSTEM_TRAY_ORIENTATION_HORZ 0
|
||||||
|
#define SYSTEM_TRAY_ORIENTATION_VERT 1
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_ORIENTATION
|
||||||
|
};
|
||||||
|
|
||||||
|
static GtkPlugClass *parent_class = NULL;
|
||||||
|
|
||||||
|
static void egg_tray_icon_init (EggTrayIcon *icon);
|
||||||
|
static void egg_tray_icon_class_init (EggTrayIconClass *klass);
|
||||||
|
|
||||||
|
static void egg_tray_icon_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
static void egg_tray_icon_realize (GtkWidget *widget);
|
||||||
|
static void egg_tray_icon_unrealize (GtkWidget *widget);
|
||||||
|
|
||||||
|
static void egg_tray_icon_add (GtkContainer *container,
|
||||||
|
GtkWidget *widget);
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
static void egg_tray_icon_update_manager_window (EggTrayIcon *icon,
|
||||||
|
gboolean dock_if_realized);
|
||||||
|
static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GType
|
||||||
|
egg_tray_icon_get_type (void)
|
||||||
|
{
|
||||||
|
static GType our_type = 0;
|
||||||
|
|
||||||
|
if (our_type == 0)
|
||||||
|
{
|
||||||
|
static const GTypeInfo our_info =
|
||||||
|
{
|
||||||
|
sizeof (EggTrayIconClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) egg_tray_icon_class_init,
|
||||||
|
NULL, /* class_finalize */
|
||||||
|
NULL, /* class_data */
|
||||||
|
sizeof (EggTrayIcon),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) egg_tray_icon_init
|
||||||
|
};
|
||||||
|
|
||||||
|
our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return our_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_init (EggTrayIcon *icon)
|
||||||
|
{
|
||||||
|
icon->stamp = 1;
|
||||||
|
icon->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||||
|
|
||||||
|
gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_class_init (EggTrayIconClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = (GObjectClass *)klass;
|
||||||
|
GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
|
||||||
|
GtkContainerClass *container_class = (GtkContainerClass *)klass;
|
||||||
|
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
|
gobject_class->get_property = egg_tray_icon_get_property;
|
||||||
|
|
||||||
|
widget_class->realize = egg_tray_icon_realize;
|
||||||
|
widget_class->unrealize = egg_tray_icon_unrealize;
|
||||||
|
|
||||||
|
container_class->add = egg_tray_icon_add;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ORIENTATION,
|
||||||
|
g_param_spec_enum ("orientation",
|
||||||
|
_("Orientation"),
|
||||||
|
_("The orientation of the tray."),
|
||||||
|
GTK_TYPE_ORIENTATION,
|
||||||
|
GTK_ORIENTATION_HORIZONTAL,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
#if defined (GDK_WINDOWING_X11)
|
||||||
|
/* Nothing */
|
||||||
|
#elif defined (GDK_WINDOWING_WIN32)
|
||||||
|
g_warning ("Port eggtrayicon to Win32");
|
||||||
|
#else
|
||||||
|
g_warning ("Port eggtrayicon to this GTK+ backend");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
EggTrayIcon *icon = EGG_TRAY_ICON (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_ORIENTATION:
|
||||||
|
g_value_set_enum (value, icon->orientation);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_get_orientation_property (EggTrayIcon *icon)
|
||||||
|
{
|
||||||
|
Display *xdisplay;
|
||||||
|
Atom type;
|
||||||
|
int format;
|
||||||
|
union {
|
||||||
|
gulong *prop;
|
||||||
|
guchar *prop_ch;
|
||||||
|
} prop = { NULL };
|
||||||
|
gulong nitems;
|
||||||
|
gulong bytes_after;
|
||||||
|
int error, result;
|
||||||
|
|
||||||
|
g_assert (icon->manager_window != None);
|
||||||
|
|
||||||
|
xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
||||||
|
|
||||||
|
gdk_error_trap_push ();
|
||||||
|
type = None;
|
||||||
|
result = XGetWindowProperty (xdisplay,
|
||||||
|
icon->manager_window,
|
||||||
|
icon->orientation_atom,
|
||||||
|
0, G_MAXLONG, FALSE,
|
||||||
|
XA_CARDINAL,
|
||||||
|
&type, &format, &nitems,
|
||||||
|
&bytes_after, &(prop.prop_ch));
|
||||||
|
error = gdk_error_trap_pop ();
|
||||||
|
|
||||||
|
if (error || result != Success)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (type == XA_CARDINAL)
|
||||||
|
{
|
||||||
|
GtkOrientation orientation;
|
||||||
|
|
||||||
|
orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
|
||||||
|
GTK_ORIENTATION_HORIZONTAL :
|
||||||
|
GTK_ORIENTATION_VERTICAL;
|
||||||
|
|
||||||
|
if (icon->orientation != orientation)
|
||||||
|
{
|
||||||
|
icon->orientation = orientation;
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (icon), "orientation");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop.prop)
|
||||||
|
XFree (prop.prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GdkFilterReturn
|
||||||
|
egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data)
|
||||||
|
{
|
||||||
|
EggTrayIcon *icon = user_data;
|
||||||
|
XEvent *xev = (XEvent *)xevent;
|
||||||
|
|
||||||
|
if (xev->xany.type == ClientMessage &&
|
||||||
|
xev->xclient.message_type == icon->manager_atom &&
|
||||||
|
xev->xclient.data.l[1] == icon->selection_atom)
|
||||||
|
{
|
||||||
|
egg_tray_icon_update_manager_window (icon, TRUE);
|
||||||
|
}
|
||||||
|
else if (xev->xany.window == icon->manager_window)
|
||||||
|
{
|
||||||
|
if (xev->xany.type == PropertyNotify &&
|
||||||
|
xev->xproperty.atom == icon->orientation_atom)
|
||||||
|
{
|
||||||
|
egg_tray_icon_get_orientation_property (icon);
|
||||||
|
}
|
||||||
|
if (xev->xany.type == DestroyNotify)
|
||||||
|
{
|
||||||
|
egg_tray_icon_manager_window_destroyed (icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GDK_FILTER_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_unrealize (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
EggTrayIcon *icon = EGG_TRAY_ICON (widget);
|
||||||
|
GdkWindow *root_window;
|
||||||
|
|
||||||
|
if (icon->manager_window != None)
|
||||||
|
{
|
||||||
|
GdkWindow *gdkwin;
|
||||||
|
|
||||||
|
gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
|
||||||
|
icon->manager_window);
|
||||||
|
|
||||||
|
gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
|
||||||
|
|
||||||
|
gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);
|
||||||
|
|
||||||
|
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
|
||||||
|
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_send_manager_message (EggTrayIcon *icon,
|
||||||
|
long message,
|
||||||
|
Window window,
|
||||||
|
long data1,
|
||||||
|
long data2,
|
||||||
|
long data3)
|
||||||
|
{
|
||||||
|
XClientMessageEvent ev;
|
||||||
|
Display *display;
|
||||||
|
|
||||||
|
ev.type = ClientMessage;
|
||||||
|
ev.window = window;
|
||||||
|
ev.message_type = icon->system_tray_opcode_atom;
|
||||||
|
ev.format = 32;
|
||||||
|
ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window);
|
||||||
|
ev.data.l[1] = message;
|
||||||
|
ev.data.l[2] = data1;
|
||||||
|
ev.data.l[3] = data2;
|
||||||
|
ev.data.l[4] = data3;
|
||||||
|
|
||||||
|
display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
||||||
|
|
||||||
|
gdk_error_trap_push ();
|
||||||
|
XSendEvent (display,
|
||||||
|
icon->manager_window, False, NoEventMask, (XEvent *)&ev);
|
||||||
|
XSync (display, False);
|
||||||
|
gdk_error_trap_pop ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_send_dock_request (EggTrayIcon *icon)
|
||||||
|
{
|
||||||
|
egg_tray_icon_send_manager_message (icon,
|
||||||
|
SYSTEM_TRAY_REQUEST_DOCK,
|
||||||
|
icon->manager_window,
|
||||||
|
gtk_plug_get_id (GTK_PLUG (icon)),
|
||||||
|
0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_update_manager_window (EggTrayIcon *icon,
|
||||||
|
gboolean dock_if_realized)
|
||||||
|
{
|
||||||
|
Display *xdisplay;
|
||||||
|
|
||||||
|
if (icon->manager_window != None)
|
||||||
|
return;
|
||||||
|
|
||||||
|
xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
||||||
|
|
||||||
|
XGrabServer (xdisplay);
|
||||||
|
|
||||||
|
icon->manager_window = XGetSelectionOwner (xdisplay,
|
||||||
|
icon->selection_atom);
|
||||||
|
|
||||||
|
if (icon->manager_window != None)
|
||||||
|
XSelectInput (xdisplay,
|
||||||
|
icon->manager_window, StructureNotifyMask|PropertyChangeMask);
|
||||||
|
|
||||||
|
XUngrabServer (xdisplay);
|
||||||
|
XFlush (xdisplay);
|
||||||
|
|
||||||
|
if (icon->manager_window != None)
|
||||||
|
{
|
||||||
|
GdkWindow *gdkwin;
|
||||||
|
|
||||||
|
gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
|
||||||
|
icon->manager_window);
|
||||||
|
|
||||||
|
gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);
|
||||||
|
|
||||||
|
if (dock_if_realized && GTK_WIDGET_REALIZED (icon))
|
||||||
|
egg_tray_icon_send_dock_request (icon);
|
||||||
|
|
||||||
|
egg_tray_icon_get_orientation_property (icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon)
|
||||||
|
{
|
||||||
|
GdkWindow *gdkwin;
|
||||||
|
|
||||||
|
g_return_if_fail (icon->manager_window != None);
|
||||||
|
|
||||||
|
gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
|
||||||
|
icon->manager_window);
|
||||||
|
|
||||||
|
gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
|
||||||
|
|
||||||
|
icon->manager_window = None;
|
||||||
|
|
||||||
|
egg_tray_icon_update_manager_window (icon, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
|
||||||
|
{
|
||||||
|
gdk_window_clear_area (widget->window, event->area.x, event->area.y,
|
||||||
|
event->area.width, event->area.height);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
make_transparent_again (GtkWidget *widget, GtkStyle *previous_style,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
make_transparent (GtkWidget *widget, gpointer user_data)
|
||||||
|
{
|
||||||
|
if (GTK_WIDGET_NO_WINDOW (widget) || GTK_WIDGET_APP_PAINTABLE (widget))
|
||||||
|
return;
|
||||||
|
|
||||||
|
gtk_widget_set_app_paintable (widget, TRUE);
|
||||||
|
gtk_widget_set_double_buffered (widget, FALSE);
|
||||||
|
gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
|
||||||
|
g_signal_connect (widget, "expose_event",
|
||||||
|
G_CALLBACK (transparent_expose_event), NULL);
|
||||||
|
g_signal_connect_after (widget, "style_set",
|
||||||
|
G_CALLBACK (make_transparent_again), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_realize (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
EggTrayIcon *icon = EGG_TRAY_ICON (widget);
|
||||||
|
GdkScreen *screen;
|
||||||
|
GdkDisplay *display;
|
||||||
|
Display *xdisplay;
|
||||||
|
char buffer[256];
|
||||||
|
GdkWindow *root_window;
|
||||||
|
|
||||||
|
if (GTK_WIDGET_CLASS (parent_class)->realize)
|
||||||
|
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
||||||
|
|
||||||
|
make_transparent (widget, NULL);
|
||||||
|
|
||||||
|
screen = gtk_widget_get_screen (widget);
|
||||||
|
display = gdk_screen_get_display (screen);
|
||||||
|
xdisplay = gdk_x11_display_get_xdisplay (display);
|
||||||
|
|
||||||
|
/* Now see if there's a manager window around */
|
||||||
|
g_snprintf (buffer, sizeof (buffer),
|
||||||
|
"_NET_SYSTEM_TRAY_S%d",
|
||||||
|
gdk_screen_get_number (screen));
|
||||||
|
|
||||||
|
icon->selection_atom = XInternAtom (xdisplay, buffer, False);
|
||||||
|
|
||||||
|
icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
|
||||||
|
|
||||||
|
icon->system_tray_opcode_atom = XInternAtom (xdisplay,
|
||||||
|
"_NET_SYSTEM_TRAY_OPCODE",
|
||||||
|
False);
|
||||||
|
|
||||||
|
icon->orientation_atom = XInternAtom (xdisplay,
|
||||||
|
"_NET_SYSTEM_TRAY_ORIENTATION",
|
||||||
|
False);
|
||||||
|
|
||||||
|
egg_tray_icon_update_manager_window (icon, FALSE);
|
||||||
|
egg_tray_icon_send_dock_request (icon);
|
||||||
|
|
||||||
|
root_window = gdk_screen_get_root_window (screen);
|
||||||
|
|
||||||
|
/* Add a root window filter so that we get changes on MANAGER */
|
||||||
|
gdk_window_add_filter (root_window,
|
||||||
|
egg_tray_icon_manager_filter, icon);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
egg_tray_icon_add (GtkContainer *container, GtkWidget *widget)
|
||||||
|
{
|
||||||
|
g_signal_connect (widget, "realize",
|
||||||
|
G_CALLBACK (make_transparent), NULL);
|
||||||
|
GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
EggTrayIcon *
|
||||||
|
egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
||||||
|
|
||||||
|
return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
EggTrayIcon*
|
||||||
|
egg_tray_icon_new (const gchar *name)
|
||||||
|
{
|
||||||
|
return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
egg_tray_icon_send_message (EggTrayIcon *icon,
|
||||||
|
gint timeout,
|
||||||
|
const gchar *message,
|
||||||
|
gint len)
|
||||||
|
{
|
||||||
|
guint stamp;
|
||||||
|
|
||||||
|
g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
|
||||||
|
g_return_val_if_fail (timeout >= 0, 0);
|
||||||
|
g_return_val_if_fail (message != NULL, 0);
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
if (icon->manager_window == None)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (len < 0)
|
||||||
|
len = strlen (message);
|
||||||
|
|
||||||
|
stamp = icon->stamp++;
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
/* Get ready to send the message */
|
||||||
|
egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
|
||||||
|
icon->manager_window,
|
||||||
|
timeout, len, stamp);
|
||||||
|
|
||||||
|
/* Now to send the actual message */
|
||||||
|
gdk_error_trap_push ();
|
||||||
|
while (len > 0)
|
||||||
|
{
|
||||||
|
XClientMessageEvent ev;
|
||||||
|
Display *xdisplay;
|
||||||
|
|
||||||
|
xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
||||||
|
|
||||||
|
ev.type = ClientMessage;
|
||||||
|
ev.window = icon->manager_window;
|
||||||
|
ev.format = 8;
|
||||||
|
ev.message_type = XInternAtom (xdisplay,
|
||||||
|
"_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
|
||||||
|
if (len > 20)
|
||||||
|
{
|
||||||
|
memcpy (&ev.data, message, 20);
|
||||||
|
len -= 20;
|
||||||
|
message += 20;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy (&ev.data, message, len);
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
XSendEvent (xdisplay,
|
||||||
|
icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
|
||||||
|
XSync (xdisplay, False);
|
||||||
|
}
|
||||||
|
gdk_error_trap_pop ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
egg_tray_icon_cancel_message (EggTrayIcon *icon,
|
||||||
|
guint id)
|
||||||
|
{
|
||||||
|
g_return_if_fail (EGG_IS_TRAY_ICON (icon));
|
||||||
|
g_return_if_fail (id > 0);
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
|
||||||
|
(Window)gtk_plug_get_id (GTK_PLUG (icon)),
|
||||||
|
id, 0, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkOrientation
|
||||||
|
egg_tray_icon_get_orientation (EggTrayIcon *icon)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL);
|
||||||
|
|
||||||
|
return icon->orientation;
|
||||||
|
}
|
80
pandora_applet/src/eggtrayicon.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||||
|
/* eggtrayicon.h
|
||||||
|
* Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __EGG_TRAY_ICON_H__
|
||||||
|
#define __EGG_TRAY_ICON_H__
|
||||||
|
|
||||||
|
#include <gtk/gtkplug.h>
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define EGG_TYPE_TRAY_ICON (egg_tray_icon_get_type ())
|
||||||
|
#define EGG_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon))
|
||||||
|
#define EGG_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass))
|
||||||
|
#define EGG_IS_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TRAY_ICON))
|
||||||
|
#define EGG_IS_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON))
|
||||||
|
#define EGG_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass))
|
||||||
|
|
||||||
|
typedef struct _EggTrayIcon EggTrayIcon;
|
||||||
|
typedef struct _EggTrayIconClass EggTrayIconClass;
|
||||||
|
|
||||||
|
struct _EggTrayIcon
|
||||||
|
{
|
||||||
|
GtkPlug parent_instance;
|
||||||
|
|
||||||
|
guint stamp;
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
Atom selection_atom;
|
||||||
|
Atom manager_atom;
|
||||||
|
Atom system_tray_opcode_atom;
|
||||||
|
Atom orientation_atom;
|
||||||
|
Window manager_window;
|
||||||
|
#endif
|
||||||
|
GtkOrientation orientation;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _EggTrayIconClass
|
||||||
|
{
|
||||||
|
GtkPlugClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType egg_tray_icon_get_type (void);
|
||||||
|
|
||||||
|
EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen *screen,
|
||||||
|
const gchar *name);
|
||||||
|
|
||||||
|
EggTrayIcon *egg_tray_icon_new (const gchar *name);
|
||||||
|
|
||||||
|
guint egg_tray_icon_send_message (EggTrayIcon *icon,
|
||||||
|
gint timeout,
|
||||||
|
const char *message,
|
||||||
|
gint len);
|
||||||
|
void egg_tray_icon_cancel_message (EggTrayIcon *icon,
|
||||||
|
guint id);
|
||||||
|
|
||||||
|
GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __EGG_TRAY_ICON_H__ */
|
64
pandora_applet/src/main.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "pandora-applet.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
exit_app ()
|
||||||
|
{
|
||||||
|
gtk_main_quit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
PandoraApplet *applet;
|
||||||
|
|
||||||
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
|
g_set_application_name (_("Pandora applet"));
|
||||||
|
|
||||||
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
||||||
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
|
/* Init threads */
|
||||||
|
if (!g_thread_supported ()) {
|
||||||
|
g_thread_init (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
applet = pandora_applet_new ();
|
||||||
|
|
||||||
|
if (!applet) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
513
pandora_applet/src/pandora-applet.c
Normal file
@ -0,0 +1,513 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
Based on NetworkManager Wireless Applet
|
||||||
|
GNOME Wireless Applet Authors:
|
||||||
|
* Eskil Heyn Olsen <eskil@eskil.dk>
|
||||||
|
* Bastien Nocera <hadess@hadess.net> (Gnome2 port)
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include "pandora-applet.h"
|
||||||
|
#include "pandora-info-window.h"
|
||||||
|
#include "pandora-status-checker.h"
|
||||||
|
#include "pandora-status.h"
|
||||||
|
#include "pandora-setup-dialog.h"
|
||||||
|
#include "pandora-setup.h"
|
||||||
|
|
||||||
|
struct _PandoraAppletPrivate {
|
||||||
|
GtkImage *image;
|
||||||
|
GdkPixbuf *icon_good;
|
||||||
|
GdkPixbuf *icon_bad;
|
||||||
|
GdkPixbuf *icon_unknown;
|
||||||
|
GtkWidget *event_box;
|
||||||
|
GtkWidget *context_menu;
|
||||||
|
|
||||||
|
gchar *userdir;
|
||||||
|
gchar *userfile;
|
||||||
|
|
||||||
|
PandoraInfoWindow *info_window;
|
||||||
|
PandoraSetupDialog *setup_dialog;
|
||||||
|
PandoraSetup *setup;
|
||||||
|
PandoraStatusChecker *checker;
|
||||||
|
PandoraStatus *status;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PANDORA_APPLET_GET_PRIVATE(object) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE ((object), PANDORA_TYPE_APPLET, PandoraAppletPrivate))
|
||||||
|
|
||||||
|
static gboolean pandora_applet_create_setup_file (PandoraApplet *applet);
|
||||||
|
static void pandora_applet_create_user_dir (PandoraApplet *applet);
|
||||||
|
static void pandora_applet_set_image_from_pixbuf (PandoraApplet *applet,
|
||||||
|
GdkPixbuf *icon);
|
||||||
|
static void pandora_applet_set_image_from_stock (PandoraApplet *applet,
|
||||||
|
gchar *stock_id);
|
||||||
|
static gboolean pandora_applet_toplevel_menu_button_press_cb (GtkWidget *widget,
|
||||||
|
GdkEventButton *event,
|
||||||
|
gpointer data);
|
||||||
|
static void pandora_applet_changed_status_cb (GObject *object,
|
||||||
|
gpointer *data);
|
||||||
|
static GtkWidget *pandora_applet_context_menu_create (PandoraApplet *applet);
|
||||||
|
|
||||||
|
static GObject *pandora_applet_constructor (GType type, guint n_props,
|
||||||
|
GObjectConstructParam *props);
|
||||||
|
static GtkWidget *pandora_applet_get_instance (PandoraApplet *applet);
|
||||||
|
static void pandora_applet_destroy (PandoraApplet *applet);
|
||||||
|
static GType pandora_applet_get_type (void); /* for G_DEFINE_TYPE */
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (PandoraApplet, pandora_applet, EGG_TYPE_TRAY_ICON)
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_init (PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
applet->priv = PANDORA_APPLET_GET_PRIVATE (applet);
|
||||||
|
|
||||||
|
applet->priv->icon_good = load_icon_from_disk ("pandora-applet-good.png");
|
||||||
|
applet->priv->icon_bad = load_icon_from_disk ("pandora-applet-bad.png");
|
||||||
|
applet->priv->icon_unknown = load_icon_from_disk ("pandora-applet-unknown.png");
|
||||||
|
|
||||||
|
applet->priv->userdir = g_build_filename (g_get_home_dir (), ".pandora", NULL);
|
||||||
|
applet->priv->userfile = g_build_filename (applet->priv->userdir, "config.xml",
|
||||||
|
NULL);
|
||||||
|
pandora_applet_create_user_dir (applet);
|
||||||
|
|
||||||
|
g_signal_connect (applet, "destroy", G_CALLBACK (pandora_applet_destroy), NULL);
|
||||||
|
|
||||||
|
/* Event box is the main applet widget */
|
||||||
|
applet->priv->event_box = gtk_event_box_new ();
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (applet->priv->event_box),
|
||||||
|
0);
|
||||||
|
|
||||||
|
applet->priv->image = GTK_IMAGE (gtk_image_new ());
|
||||||
|
gtk_container_add (GTK_CONTAINER (applet->priv->event_box),
|
||||||
|
GTK_WIDGET (applet->priv->image));
|
||||||
|
gtk_container_add (GTK_CONTAINER (applet), applet->priv->event_box);
|
||||||
|
|
||||||
|
g_signal_connect (applet->priv->event_box, "button_press_event",
|
||||||
|
G_CALLBACK (pandora_applet_toplevel_menu_button_press_cb),
|
||||||
|
applet);
|
||||||
|
|
||||||
|
pandora_applet_set_image_from_pixbuf (applet, applet->priv->icon_unknown);
|
||||||
|
|
||||||
|
applet->priv->context_menu = pandora_applet_context_menu_create (applet);
|
||||||
|
|
||||||
|
/* Init setup */
|
||||||
|
applet->priv->setup = pandora_setup_new (applet->priv->userfile);
|
||||||
|
|
||||||
|
/* Init windows and dialogs */
|
||||||
|
applet->priv->info_window = PANDORA_INFO_WINDOW (pandora_info_window_new ());
|
||||||
|
|
||||||
|
applet->priv->setup_dialog = PANDORA_SETUP_DIALOG (pandora_setup_dialog_new ());
|
||||||
|
pandora_setup_dialog_set_setup (applet->priv->setup_dialog,
|
||||||
|
applet->priv->setup);
|
||||||
|
|
||||||
|
/* Init status and checker */
|
||||||
|
applet->priv->status = PANDORA_STATUS (pandora_status_new ());
|
||||||
|
|
||||||
|
pandora_info_window_set_status (applet->priv->info_window,
|
||||||
|
applet->priv->status);
|
||||||
|
|
||||||
|
applet->priv->checker = pandora_status_checker_new (applet->priv->setup,
|
||||||
|
applet->priv->status);
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (applet));
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (applet->priv->status), "changed",
|
||||||
|
G_CALLBACK (pandora_applet_changed_status_cb),
|
||||||
|
(gpointer) applet);
|
||||||
|
|
||||||
|
pandora_status_checker_run (applet->priv->checker);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_class_init (PandoraAppletClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (PandoraAppletPrivate));
|
||||||
|
|
||||||
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
|
object_class->constructor = pandora_applet_constructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
pandora_applet_constructor (GType type, guint n_props,
|
||||||
|
GObjectConstructParam *props)
|
||||||
|
{
|
||||||
|
GObject *obj;
|
||||||
|
PandoraApplet *applet;
|
||||||
|
PandoraAppletClass *klass;
|
||||||
|
|
||||||
|
klass = PANDORA_APPLET_CLASS (g_type_class_peek (type));
|
||||||
|
obj = G_OBJECT_CLASS (pandora_applet_parent_class)->constructor (type,
|
||||||
|
n_props,
|
||||||
|
props);
|
||||||
|
applet = PANDORA_APPLET (obj);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
pandora_applet_get_instance (PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
gtk_widget_hide (GTK_WIDGET (applet));
|
||||||
|
|
||||||
|
|
||||||
|
return GTK_WIDGET (applet);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_destroy (PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
pandora_status_checker_stop (applet->priv->checker);
|
||||||
|
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (applet->priv->info_window));
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (applet->priv->setup_dialog));
|
||||||
|
|
||||||
|
exit_app ();
|
||||||
|
}
|
||||||
|
|
||||||
|
PandoraApplet *
|
||||||
|
pandora_applet_new ()
|
||||||
|
{
|
||||||
|
return g_object_new (PANDORA_TYPE_APPLET, "title", "Pandora", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_quit_cb (GtkMenuItem *mi, PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (applet));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_about_cb (GtkMenuItem *mi, PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
gchar *pixbuf_path;
|
||||||
|
static const gchar *authors[] =
|
||||||
|
{
|
||||||
|
"Artica Soluciones Tecnológicas:\n",
|
||||||
|
"Esteban Sánchez <estebans@artica.es>",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
static const gchar *artists[] =
|
||||||
|
{
|
||||||
|
"Esteban Sánchez <estebans@artica.es>"
|
||||||
|
"Icons from Tango Desktop Project <http://tango.freedesktop.org/>",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pixbuf_path = g_build_filename (PIXMAPS_DIR, "pandora.png", NULL);
|
||||||
|
pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL);
|
||||||
|
g_free (pixbuf_path);
|
||||||
|
|
||||||
|
gtk_show_about_dialog (NULL,
|
||||||
|
"name", _("Pandora Enterprise monitor applet"),
|
||||||
|
"version", VERSION,
|
||||||
|
"copyright", _("Copyright \xc2\xa9 2006 Artica ST.\n"),
|
||||||
|
"comments", _("Notification area applet for monitoring your Pandora system."),
|
||||||
|
"website", "http://pandora.sourceforge.net/",
|
||||||
|
"authors", authors,
|
||||||
|
"artists", artists,
|
||||||
|
"translator-credits", _("translator-credits"),
|
||||||
|
"logo", pixbuf,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (pixbuf) {
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_show_info_cb (GtkMenuItem *mi, PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
gtk_window_present (GTK_WINDOW (applet->priv->info_window));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_show_setup_cb (GtkMenuItem *mi, PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
gint result;
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (applet->priv->setup_dialog));
|
||||||
|
|
||||||
|
result = gtk_dialog_run (GTK_DIALOG (applet->priv->setup_dialog));
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case GTK_RESPONSE_ACCEPT:
|
||||||
|
pandora_setup_dialog_apply_changes (applet->priv->setup_dialog);
|
||||||
|
pandora_setup_save_to_disk (applet->priv->setup);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_hide (GTK_WIDGET (applet->priv->setup_dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_changed_status_cb (GObject *object,
|
||||||
|
gpointer *data)
|
||||||
|
{
|
||||||
|
PandoraApplet *applet = PANDORA_APPLET (data);
|
||||||
|
|
||||||
|
switch (pandora_status_get_alerts (PANDORA_STATUS (object))) {
|
||||||
|
case STATE_BAD:
|
||||||
|
pandora_applet_set_image_from_pixbuf (applet, applet->priv->icon_bad);
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case STATE_OK:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pandora_applet_set_image_from_pixbuf (applet, applet->priv->icon_unknown);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pandora_status_get_servers (PANDORA_STATUS (object))) {
|
||||||
|
case STATE_BAD:
|
||||||
|
pandora_applet_set_image_from_pixbuf (applet, applet->priv->icon_bad);
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case STATE_OK:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pandora_applet_set_image_from_pixbuf (applet, applet->priv->icon_unknown);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pandora_status_get_agents (PANDORA_STATUS (object))) {
|
||||||
|
case STATE_BAD:
|
||||||
|
pandora_applet_set_image_from_pixbuf (applet, applet->priv->icon_bad);
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case STATE_OK:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pandora_applet_set_image_from_pixbuf (applet, applet->priv->icon_unknown);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pandora_applet_set_image_from_pixbuf (applet, applet->priv->icon_good);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
pandora_applet_context_menu_create (PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
GtkWidget *menu;
|
||||||
|
GtkWidget *menu_item;
|
||||||
|
GtkWidget *image;
|
||||||
|
|
||||||
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
|
|
||||||
|
menu = gtk_menu_new ();
|
||||||
|
|
||||||
|
/* Show status item */
|
||||||
|
menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Show main window"));
|
||||||
|
g_signal_connect (G_OBJECT (menu_item), "activate",
|
||||||
|
G_CALLBACK (pandora_applet_show_info_cb), applet);
|
||||||
|
image = gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
|
||||||
|
image);
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||||
|
|
||||||
|
/* Preferences item */
|
||||||
|
menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
|
||||||
|
g_signal_connect (G_OBJECT (menu_item), "activate",
|
||||||
|
G_CALLBACK (pandora_applet_show_setup_cb), applet);
|
||||||
|
image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
|
||||||
|
image);
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||||
|
|
||||||
|
/* Separator */
|
||||||
|
menu_item = gtk_separator_menu_item_new ();
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||||
|
gtk_widget_show (menu_item);
|
||||||
|
|
||||||
|
/* About item */
|
||||||
|
menu_item = gtk_image_menu_item_new_with_mnemonic (_("_About"));
|
||||||
|
g_signal_connect (G_OBJECT (menu_item), "activate",
|
||||||
|
G_CALLBACK (pandora_applet_about_cb), applet);
|
||||||
|
image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||||
|
|
||||||
|
/* Quit item */
|
||||||
|
menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Quit"));
|
||||||
|
g_signal_connect (G_OBJECT (menu_item), "activate",
|
||||||
|
G_CALLBACK (pandora_applet_quit_cb), applet);
|
||||||
|
image = gtk_image_new_from_stock (GTK_STOCK_QUIT, GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||||
|
|
||||||
|
gtk_widget_show_all (menu);
|
||||||
|
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_menu_position_func (GtkMenu *menu G_GNUC_UNUSED,
|
||||||
|
int *x, int *y, gboolean *push_in,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
int screen_w, screen_h, button_x, button_y, panel_w, panel_h;
|
||||||
|
GtkRequisition requisition;
|
||||||
|
GdkScreen *screen;
|
||||||
|
PandoraApplet *applet = (PandoraApplet *)user_data;
|
||||||
|
|
||||||
|
screen = gtk_widget_get_screen (applet->priv->event_box);
|
||||||
|
screen_w = gdk_screen_get_width (screen);
|
||||||
|
screen_h = gdk_screen_get_height (screen);
|
||||||
|
|
||||||
|
gdk_window_get_origin (applet->priv->event_box->window, &button_x, &button_y);
|
||||||
|
gtk_window_get_size (GTK_WINDOW (gtk_widget_get_toplevel (applet->priv->event_box)),
|
||||||
|
&panel_w, &panel_h);
|
||||||
|
|
||||||
|
*x = button_x;
|
||||||
|
|
||||||
|
/* Check to see if we would be placing the menu off of the end of the screen. */
|
||||||
|
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
|
||||||
|
if (button_y + panel_h + requisition.height >= screen_h)
|
||||||
|
*y = button_y - requisition.height;
|
||||||
|
else
|
||||||
|
*y = button_y + panel_h;
|
||||||
|
|
||||||
|
*push_in = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
pandora_applet_toplevel_menu_button_press_cb (GtkWidget *widget,
|
||||||
|
GdkEventButton *event,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
|
||||||
|
PandoraApplet *applet;
|
||||||
|
|
||||||
|
applet = PANDORA_APPLET (data);
|
||||||
|
|
||||||
|
g_return_val_if_fail (applet != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (PANDORA_IS_APPLET (applet), FALSE);
|
||||||
|
|
||||||
|
switch (event->button) {
|
||||||
|
case 3:
|
||||||
|
gtk_menu_popup (GTK_MENU (applet->priv->context_menu),
|
||||||
|
NULL, NULL,
|
||||||
|
pandora_applet_menu_position_func,
|
||||||
|
applet, event->button, event->time);
|
||||||
|
return TRUE;
|
||||||
|
default:
|
||||||
|
g_signal_stop_emission_by_name (widget, "button_press_event");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_setup_widgets (PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_set_image_from_stock (PandoraApplet *applet,
|
||||||
|
gchar *stock_id)
|
||||||
|
{
|
||||||
|
gtk_image_set_from_stock (GTK_IMAGE (applet->priv->image),
|
||||||
|
stock_id, GTK_ICON_SIZE_MENU);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_set_image_from_pixbuf (PandoraApplet *applet, GdkPixbuf *icon)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PANDORA_IS_APPLET (applet));
|
||||||
|
g_return_if_fail (icon != NULL);
|
||||||
|
|
||||||
|
gtk_image_set_from_pixbuf (GTK_IMAGE (applet->priv->image), icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
GdkPixbuf *
|
||||||
|
load_icon_from_disk (gchar *icon_name)
|
||||||
|
{
|
||||||
|
GError *err = NULL;
|
||||||
|
gchar *icon_path;
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
|
icon_path = g_build_filename (PIXMAPS_DIR, icon_name, NULL);
|
||||||
|
pixbuf = gdk_pixbuf_new_from_file (icon_path, &err);
|
||||||
|
g_free (icon_path);
|
||||||
|
|
||||||
|
if (pixbuf == NULL) {
|
||||||
|
g_warning ("Icon %s missing: %s", icon_name, err->message);
|
||||||
|
g_error_free (err);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pixbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
pandora_applet_create_setup_file (PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
const gchar *contents = "<?xml version=\"1.0\"?>\n<config>\n</config>\n";
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(2,8,0)
|
||||||
|
return g_file_set_contents (applet->priv->userfile, contents, -1, NULL);
|
||||||
|
#else
|
||||||
|
gint fd;
|
||||||
|
|
||||||
|
if ((fd = open (applet->priv->userfile, O_CREAT | O_WRONLY, 0644)) < 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (write (fd, contents, strlen (contents)) < 0) {
|
||||||
|
close (fd);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (close (fd) < 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_applet_create_user_dir (PandoraApplet *applet)
|
||||||
|
{
|
||||||
|
if (!g_file_test (applet->priv->userdir, G_FILE_TEST_IS_DIR)) {
|
||||||
|
if (g_mkdir (applet->priv->userdir, 0755) != 0) {
|
||||||
|
g_error ("Cannot create user's directory");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_file_test (applet->priv->userfile, G_FILE_TEST_IS_REGULAR)) {
|
||||||
|
if (!pandora_applet_create_setup_file (applet)) {
|
||||||
|
g_error ("Cannot create user's configuration file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
pandora_applet/src/pandora-applet.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef APPLET_H
|
||||||
|
#define APPLET_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include "eggtrayicon.h"
|
||||||
|
|
||||||
|
#define PANDORA_TYPE_APPLET (pandora_applet_get_type())
|
||||||
|
#define PANDORA_APPLET(object) (G_TYPE_CHECK_INSTANCE_CAST((object), PANDORA_TYPE_APPLET, PandoraApplet))
|
||||||
|
#define PANDORA_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANDORA_TYPE_APPLET, PandoraAppletClass))
|
||||||
|
#define PANDORA_IS_APPLET(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), PANDORA_TYPE_APPLET))
|
||||||
|
#define PANDORA_IS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PANDORA_TYPE_APPLET))
|
||||||
|
#define PANDORA_APPLET_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), PANDORA_TYPE_APPLET, PandoraAppletClass))
|
||||||
|
|
||||||
|
typedef struct _PandoraAppletPrivate PandoraAppletPrivate;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
EggTrayIconClass parent_class;
|
||||||
|
} PandoraAppletClass;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Applet instance data
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
EggTrayIcon parent;
|
||||||
|
PandoraAppletPrivate *priv;
|
||||||
|
} PandoraApplet;
|
||||||
|
|
||||||
|
PandoraApplet *pandora_applet_new (void);
|
||||||
|
|
||||||
|
GdkPixbuf *load_icon_from_disk (gchar *icon_name);
|
||||||
|
|
||||||
|
#endif
|
414
pandora_applet/src/pandora-info-window.c
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "pandora-applet.h"
|
||||||
|
#include "pandora-info-window.h"
|
||||||
|
|
||||||
|
struct _PandoraInfoWindowPrivate {
|
||||||
|
GtkWidget *label_alerts;
|
||||||
|
GtkWidget *label_servers;
|
||||||
|
GtkWidget *label_agents;
|
||||||
|
|
||||||
|
GtkImage *image_alerts;
|
||||||
|
GtkImage *image_servers;
|
||||||
|
GtkImage *image_agents;
|
||||||
|
|
||||||
|
GdkPixbuf *pixbuf_alerts_ok;
|
||||||
|
GdkPixbuf *pixbuf_alerts_bad;
|
||||||
|
GdkPixbuf *pixbuf_alerts_unknown;
|
||||||
|
|
||||||
|
GdkPixbuf *pixbuf_servers_ok;
|
||||||
|
GdkPixbuf *pixbuf_servers_bad;
|
||||||
|
GdkPixbuf *pixbuf_servers_unknown;
|
||||||
|
|
||||||
|
GdkPixbuf *pixbuf_agents_ok;
|
||||||
|
GdkPixbuf *pixbuf_agents_bad;
|
||||||
|
GdkPixbuf *pixbuf_agents_unknown;
|
||||||
|
|
||||||
|
PandoraState state_alerts;
|
||||||
|
PandoraState state_servers;
|
||||||
|
PandoraState state_agents;
|
||||||
|
|
||||||
|
PandoraStatus *status;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PANDORA_INFO_WINDOW_GET_PRIVATE(object) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE ((object), PANDORA_INFO_WINDOW_TYPE, \
|
||||||
|
PandoraInfoWindowPrivate))
|
||||||
|
|
||||||
|
static void pandora_info_window_init (PandoraInfoWindow *window);
|
||||||
|
static void pandora_info_window_class_init (PandoraInfoWindowClass *klass);
|
||||||
|
static void pandora_info_window_finalize (GObject *object);
|
||||||
|
|
||||||
|
static gboolean pandora_info_window_delete_cb (GtkWidget *dialog,
|
||||||
|
GdkEvent *event,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
|
static gboolean pandora_info_window_close_cb (GtkWidget *widget,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
|
static void pandora_info_window_status_changed_cb (GObject *object,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
|
static void pandora_info_window_status_update (PandoraInfoWindow *window);
|
||||||
|
|
||||||
|
static void pandora_info_window_status_update_alerts (PandoraInfoWindow *window,
|
||||||
|
PandoraState state);
|
||||||
|
static void pandora_info_window_status_update_agents (PandoraInfoWindow *window,
|
||||||
|
PandoraState state);
|
||||||
|
static void pandora_info_window_status_update_servers (PandoraInfoWindow *window,
|
||||||
|
PandoraState state);
|
||||||
|
|
||||||
|
GType
|
||||||
|
pandora_info_window_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
|
static const GTypeInfo info = {
|
||||||
|
sizeof (PandoraInfoWindowClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) pandora_info_window_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (PandoraInfoWindow),
|
||||||
|
0,
|
||||||
|
(GInstanceInitFunc) pandora_info_window_init
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (GTK_TYPE_WINDOW, "PandoraInfoWindow",
|
||||||
|
&info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_info_window_init (PandoraInfoWindow *window)
|
||||||
|
{
|
||||||
|
GtkWidget *table;
|
||||||
|
GtkWidget *image;
|
||||||
|
GtkWidget *hbutton_box;
|
||||||
|
GtkWidget *button_close;
|
||||||
|
|
||||||
|
window->priv = PANDORA_INFO_WINDOW_GET_PRIVATE (window);
|
||||||
|
|
||||||
|
window->priv->status = NULL;
|
||||||
|
window->priv->state_alerts = STATE_INVALID;
|
||||||
|
window->priv->state_servers = STATE_INVALID;
|
||||||
|
window->priv->state_agents = STATE_INVALID;
|
||||||
|
|
||||||
|
window->priv->pixbuf_alerts_ok = load_icon_from_disk ("pandora-alerts-ok.png");
|
||||||
|
window->priv->pixbuf_alerts_bad = load_icon_from_disk ("pandora-alerts-bad.png");
|
||||||
|
window->priv->pixbuf_alerts_unknown = load_icon_from_disk ("pandora-alerts-unknown.png");
|
||||||
|
window->priv->image_alerts = GTK_IMAGE (gtk_image_new ());
|
||||||
|
|
||||||
|
window->priv->pixbuf_servers_ok = load_icon_from_disk ("pandora-servers-ok.png");
|
||||||
|
window->priv->pixbuf_servers_bad = load_icon_from_disk ("pandora-servers-bad.png");
|
||||||
|
window->priv->pixbuf_servers_unknown = load_icon_from_disk ("pandora-servers-unknown.png");
|
||||||
|
window->priv->image_servers = GTK_IMAGE (gtk_image_new ());
|
||||||
|
|
||||||
|
window->priv->pixbuf_agents_ok = load_icon_from_disk ("pandora-agents-ok.png");
|
||||||
|
window->priv->pixbuf_agents_bad = load_icon_from_disk ("pandora-agents-bad.png");
|
||||||
|
window->priv->pixbuf_agents_unknown = load_icon_from_disk ("pandora-agents-unknown.png");
|
||||||
|
window->priv->image_agents = GTK_IMAGE (gtk_image_new ());
|
||||||
|
|
||||||
|
gtk_window_set_title (GTK_WINDOW (window), _("Pandora status"));
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
|
||||||
|
gtk_window_set_icon_name (GTK_WINDOW (window),
|
||||||
|
GTK_STOCK_INFO);
|
||||||
|
|
||||||
|
table = gtk_table_new (4, 2, FALSE);
|
||||||
|
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
||||||
|
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
|
||||||
|
|
||||||
|
/* First row */
|
||||||
|
window->priv->label_alerts = gtk_label_new (_("Alerts status."));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (window->priv->label_alerts), 0, 0.5);
|
||||||
|
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_alerts,
|
||||||
|
window->priv->pixbuf_alerts_unknown);
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (window->priv->image_alerts),
|
||||||
|
0, 1, 0, 1, GTK_FILL , GTK_FILL, 0, 0);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), window->priv->label_alerts,
|
||||||
|
1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
|
||||||
|
/* Third row */
|
||||||
|
window->priv->label_agents = gtk_label_new (_("Agents status."));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (window->priv->label_agents), 0, 0.5);
|
||||||
|
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_agents,
|
||||||
|
window->priv->pixbuf_agents_unknown);
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (window->priv->image_agents),
|
||||||
|
0, 1, 1, 2, GTK_FILL , GTK_FILL, 0, 0);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), window->priv->label_agents,
|
||||||
|
1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
|
||||||
|
/* Second row */
|
||||||
|
window->priv->label_servers = gtk_label_new (_("Servers status."));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (window->priv->label_servers), 0, 0.5);
|
||||||
|
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_servers,
|
||||||
|
window->priv->pixbuf_servers_unknown);
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (window->priv->image_servers),
|
||||||
|
0, 1, 2, 3, GTK_FILL , GTK_FILL, 0, 0);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), window->priv->label_servers,
|
||||||
|
1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
|
||||||
|
/* Buttons at the bottom */
|
||||||
|
hbutton_box = gtk_hbutton_box_new ();
|
||||||
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbutton_box),
|
||||||
|
GTK_BUTTONBOX_END);
|
||||||
|
|
||||||
|
button_close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
|
||||||
|
g_signal_connect (G_OBJECT (button_close), "clicked",
|
||||||
|
G_CALLBACK (pandora_info_window_close_cb),
|
||||||
|
(gpointer) window);
|
||||||
|
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbutton_box), button_close,
|
||||||
|
FALSE, TRUE, 5);
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), hbutton_box,
|
||||||
|
0, 2, 3, 4, GTK_FILL, 0, 0, 0);
|
||||||
|
|
||||||
|
gtk_widget_show_all (table);
|
||||||
|
|
||||||
|
gtk_container_add (GTK_CONTAINER (window), table);
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (window), "delete-event",
|
||||||
|
G_CALLBACK (pandora_info_window_delete_cb), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_info_window_class_init (PandoraInfoWindowClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (PandoraInfoWindowPrivate));
|
||||||
|
|
||||||
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
|
object_class->finalize = pandora_info_window_finalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_info_window_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
PandoraInfoWindow *window = PANDORA_INFO_WINDOW (object);
|
||||||
|
|
||||||
|
if (window->priv->status) {
|
||||||
|
g_object_unref (window->priv->status);
|
||||||
|
window->priv->status = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->priv->pixbuf_alerts_ok) {
|
||||||
|
g_object_unref (window->priv->pixbuf_alerts_ok);
|
||||||
|
window->priv->pixbuf_alerts_ok = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->priv->pixbuf_servers_ok) {
|
||||||
|
g_object_unref (window->priv->pixbuf_servers_ok);
|
||||||
|
window->priv->pixbuf_servers_ok = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->priv->pixbuf_agents_ok) {
|
||||||
|
g_object_unref (window->priv->pixbuf_agents_ok);
|
||||||
|
window->priv->pixbuf_agents_ok = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
pandora_info_window_new (void)
|
||||||
|
{
|
||||||
|
GtkWidget *window;
|
||||||
|
|
||||||
|
window = GTK_WIDGET (g_object_new (PANDORA_INFO_WINDOW_TYPE,
|
||||||
|
"type", GTK_WINDOW_TOPLEVEL,
|
||||||
|
"default-width", 300,
|
||||||
|
"resizable", FALSE,
|
||||||
|
NULL));
|
||||||
|
|
||||||
|
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
pandora_info_window_close_cb (GtkWidget *widget, gpointer data)
|
||||||
|
{
|
||||||
|
GtkWidget *window;
|
||||||
|
|
||||||
|
if (data != NULL) {
|
||||||
|
window = GTK_WIDGET (data);
|
||||||
|
gtk_widget_hide (window);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
pandora_info_window_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||||
|
{
|
||||||
|
gtk_widget_hide (widget);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_info_window_set_status (PandoraInfoWindow *window,
|
||||||
|
PandoraStatus *status)
|
||||||
|
{
|
||||||
|
if (window->priv->status) {
|
||||||
|
g_object_unref (window->priv->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
window->priv->status = status;
|
||||||
|
|
||||||
|
g_signal_connect (status, "changed",
|
||||||
|
G_CALLBACK (pandora_info_window_status_changed_cb),
|
||||||
|
(gpointer) window);
|
||||||
|
|
||||||
|
pandora_info_window_status_update (window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_info_window_status_update_alerts (PandoraInfoWindow *window,
|
||||||
|
PandoraState state)
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case STATE_BAD:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_alerts,
|
||||||
|
window->priv->pixbuf_alerts_bad);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_alerts),
|
||||||
|
_("There are agents with alerts."));
|
||||||
|
|
||||||
|
break;
|
||||||
|
case STATE_OK:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_alerts,
|
||||||
|
window->priv->pixbuf_alerts_ok);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_alerts),
|
||||||
|
_("There are no alerts."));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_alerts,
|
||||||
|
window->priv->pixbuf_alerts_unknown);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_alerts),
|
||||||
|
_("Alerts status unknown."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_info_window_status_update_agents (PandoraInfoWindow *window,
|
||||||
|
PandoraState state)
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case STATE_BAD:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_agents,
|
||||||
|
window->priv->pixbuf_agents_bad);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_agents),
|
||||||
|
_("There are agents down."));
|
||||||
|
|
||||||
|
break;
|
||||||
|
case STATE_OK:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_agents,
|
||||||
|
window->priv->pixbuf_agents_ok);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_agents),
|
||||||
|
_("All the agents are running."));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_agents,
|
||||||
|
window->priv->pixbuf_agents_unknown);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_agents),
|
||||||
|
_("Agents status unknown."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_info_window_status_update_servers (PandoraInfoWindow *window,
|
||||||
|
PandoraState state)
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case STATE_BAD:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_servers,
|
||||||
|
window->priv->pixbuf_servers_bad);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_servers),
|
||||||
|
_("There are servers down."));
|
||||||
|
|
||||||
|
break;
|
||||||
|
case STATE_OK:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_servers,
|
||||||
|
window->priv->pixbuf_servers_ok);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_servers),
|
||||||
|
_("All the servers are running."));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gtk_image_set_from_pixbuf (window->priv->image_servers,
|
||||||
|
window->priv->pixbuf_servers_unknown);
|
||||||
|
gtk_label_set_text (GTK_LABEL (window->priv->label_servers),
|
||||||
|
_("Servers status unknown."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_info_window_status_update (PandoraInfoWindow *window)
|
||||||
|
{
|
||||||
|
PandoraStatus *status;
|
||||||
|
PandoraState state;
|
||||||
|
|
||||||
|
status = window->priv->status;
|
||||||
|
|
||||||
|
if (status == NULL) {
|
||||||
|
pandora_info_window_status_update_alerts (window, TRUE);
|
||||||
|
pandora_info_window_status_update_agents (window, TRUE);
|
||||||
|
pandora_info_window_status_update_servers (window, TRUE);
|
||||||
|
} else {
|
||||||
|
state = pandora_status_get_alerts (status);
|
||||||
|
pandora_info_window_status_update_alerts (window, state);
|
||||||
|
|
||||||
|
state = pandora_status_get_agents (status);
|
||||||
|
pandora_info_window_status_update_agents (window, state);
|
||||||
|
|
||||||
|
state = pandora_status_get_servers (status);
|
||||||
|
pandora_info_window_status_update_servers (window, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_info_window_status_changed_cb (GObject *object,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
PandoraInfoWindow *window = PANDORA_INFO_WINDOW (data);
|
||||||
|
|
||||||
|
pandora_info_window_status_update (window);
|
||||||
|
}
|
53
pandora_applet/src/pandora-info-window.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INFO_WINDOW_H
|
||||||
|
#define INFO_WINDOW_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "pandora-status.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#define PANDORA_INFO_WINDOW_TYPE (pandora_info_window_get_type())
|
||||||
|
#define PANDORA_INFO_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST((object), PANDORA_INFO_WINDOW_TYPE, PandoraInfoWindow))
|
||||||
|
#define PANDORA_INFO_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANDORA_INFO_WINDOW_TYPE, PandoraInfoWindowClass))
|
||||||
|
#define PANDORA_IS_INFO_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), PANDORA_INFO_WINDOW_TYPE))
|
||||||
|
#define PANDORA_IS_INFO_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PANDORA_INFO_WINDOW_TYPE))
|
||||||
|
#define PANDORA_INFO_WINDOW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), PANDORA_INFO_WINDOW_TYPE, PandoraInfoWindowClass))
|
||||||
|
|
||||||
|
typedef struct _PandoraInfoWindowPrivate PandoraInfoWindowPrivate;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GtkWindowClass parent_class;
|
||||||
|
} PandoraInfoWindowClass;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GtkWindow parent;
|
||||||
|
PandoraInfoWindowPrivate *priv;
|
||||||
|
} PandoraInfoWindow;
|
||||||
|
|
||||||
|
GtkWidget *pandora_info_window_new (void);
|
||||||
|
void pandora_info_window_set_status (PandoraInfoWindow *window,
|
||||||
|
PandoraStatus *status);
|
||||||
|
|
||||||
|
#endif
|
291
pandora_applet/src/pandora-setup-dialog.c
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "pandora-setup-dialog.h"
|
||||||
|
|
||||||
|
struct _PandoraSetupDialogPrivate {
|
||||||
|
GtkWidget *entry_host;
|
||||||
|
GtkWidget *entry_username;
|
||||||
|
GtkWidget *entry_password;
|
||||||
|
gchar *real_password;
|
||||||
|
GtkWidget *entry_dbname;
|
||||||
|
|
||||||
|
PandoraSetup *setup;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PANDORA_SETUP_DIALOG_GET_PRIVATE(object) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE ((object), PANDORA_SETUP_DIALOG_TYPE, \
|
||||||
|
PandoraSetupDialogPrivate))
|
||||||
|
|
||||||
|
static void pandora_setup_dialog_init (PandoraSetupDialog *dialog);
|
||||||
|
static void pandora_setup_dialog_class_init (PandoraSetupDialogClass *klass);
|
||||||
|
static void pandora_setup_dialog_finalize (GObject *object);
|
||||||
|
|
||||||
|
static gboolean pandora_setup_close_cb (GtkWidget *dialog, gpointer data);
|
||||||
|
|
||||||
|
GType
|
||||||
|
pandora_setup_dialog_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
|
static const GTypeInfo info = {
|
||||||
|
sizeof (PandoraSetupDialogClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) pandora_setup_dialog_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (PandoraSetupDialog),
|
||||||
|
0,
|
||||||
|
(GInstanceInitFunc) pandora_setup_dialog_init
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (GTK_TYPE_DIALOG, "PandoraSetupDialog",
|
||||||
|
&info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_dialog_init (PandoraSetupDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkWidget *table;
|
||||||
|
GtkWidget *hbutton_box;
|
||||||
|
GtkWidget *button_close;
|
||||||
|
GtkWidget *frame;
|
||||||
|
GtkWidget *label_title;
|
||||||
|
GtkWidget *label;
|
||||||
|
GtkWidget *alignment;
|
||||||
|
gchar *str;
|
||||||
|
|
||||||
|
dialog->priv = PANDORA_SETUP_DIALOG_GET_PRIVATE (dialog);
|
||||||
|
dialog->priv->setup = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
gtk_window_set_title (GTK_WINDOW (dialog), _("Preferences"));
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
||||||
|
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12);
|
||||||
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
|
||||||
|
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
|
||||||
|
|
||||||
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
||||||
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
|
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
||||||
|
NULL);
|
||||||
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
|
||||||
|
GTK_RESPONSE_CANCEL);
|
||||||
|
|
||||||
|
gtk_window_set_icon_name (GTK_WINDOW (dialog),
|
||||||
|
GTK_STOCK_PREFERENCES);
|
||||||
|
/* Frame */
|
||||||
|
str = g_strdup_printf ("<b>%s:</b>", _("Database connection"));
|
||||||
|
label_title = gtk_label_new (NULL);
|
||||||
|
gtk_label_set_markup (GTK_LABEL (label_title), str);
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label_title), 0, 0.5);
|
||||||
|
|
||||||
|
frame = gtk_frame_new (NULL);
|
||||||
|
gtk_frame_set_label_widget (GTK_FRAME (frame), label_title);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
|
||||||
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
|
||||||
|
|
||||||
|
/* Table inside frame */
|
||||||
|
table = gtk_table_new (4, 2, FALSE);
|
||||||
|
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
||||||
|
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
|
||||||
|
|
||||||
|
/* First row */
|
||||||
|
label = gtk_label_new (_("Host"));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||||
|
|
||||||
|
dialog->priv->entry_host = gtk_entry_new ();
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), label,
|
||||||
|
0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), dialog->priv->entry_host,
|
||||||
|
1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
|
||||||
|
/* Second row */
|
||||||
|
label = gtk_label_new (_("Username"));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||||
|
|
||||||
|
dialog->priv->entry_username = gtk_entry_new ();
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), label,
|
||||||
|
0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), dialog->priv->entry_username,
|
||||||
|
1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
|
||||||
|
/* Third row */
|
||||||
|
label = gtk_label_new (_("Password"));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||||
|
|
||||||
|
dialog->priv->entry_password = gtk_entry_new ();
|
||||||
|
gtk_entry_set_invisible_char (GTK_ENTRY (dialog->priv->entry_password),
|
||||||
|
'*');
|
||||||
|
gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->entry_password),
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), label,
|
||||||
|
0, 1, 2, 3, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), dialog->priv->entry_password,
|
||||||
|
1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
|
||||||
|
/* Fourth row */
|
||||||
|
label = gtk_label_new (_("Database name"));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||||
|
|
||||||
|
dialog->priv->entry_dbname = gtk_entry_new ();
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), label,
|
||||||
|
0, 1, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), dialog->priv->entry_dbname,
|
||||||
|
1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||||
|
|
||||||
|
alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
|
||||||
|
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
|
||||||
|
gtk_container_add (GTK_CONTAINER (alignment), table);
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||||
|
|
||||||
|
gtk_widget_show_all (frame);
|
||||||
|
|
||||||
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), frame, FALSE, FALSE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_dialog_class_init (PandoraSetupDialogClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (PandoraSetupDialogPrivate));
|
||||||
|
|
||||||
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
|
object_class->finalize = pandora_setup_dialog_finalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_dialog_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
PandoraSetupDialog *dialog;
|
||||||
|
|
||||||
|
dialog = PANDORA_SETUP_DIALOG (object);
|
||||||
|
|
||||||
|
if (dialog->priv->setup) {
|
||||||
|
g_object_unref (dialog->priv->setup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
pandora_setup_dialog_new (void)
|
||||||
|
{
|
||||||
|
GtkWidget *dialog;
|
||||||
|
|
||||||
|
dialog = GTK_WIDGET (g_object_new (PANDORA_SETUP_DIALOG_TYPE,
|
||||||
|
NULL));
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_setup_dialog_set_setup (PandoraSetupDialog *dialog,
|
||||||
|
PandoraSetup *setup)
|
||||||
|
{
|
||||||
|
gchar *value;
|
||||||
|
|
||||||
|
if (dialog->priv->setup) {
|
||||||
|
g_object_unref (dialog->priv->setup);
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog->priv->setup = setup;
|
||||||
|
g_object_ref (G_OBJECT (setup));
|
||||||
|
|
||||||
|
value = pandora_setup_get_host (setup);
|
||||||
|
if (value) {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry_host),
|
||||||
|
value);
|
||||||
|
g_free (value);
|
||||||
|
value = NULL;
|
||||||
|
} else {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry_host),
|
||||||
|
"");
|
||||||
|
}
|
||||||
|
|
||||||
|
value = pandora_setup_get_username (setup);
|
||||||
|
if (value) {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry_username),
|
||||||
|
value);
|
||||||
|
g_free (value);
|
||||||
|
} else {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry_username),
|
||||||
|
"");
|
||||||
|
}
|
||||||
|
|
||||||
|
value = pandora_setup_get_password (setup);
|
||||||
|
if (value) {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry_password),
|
||||||
|
NOT_SHOWN_PASSWORD);
|
||||||
|
g_free (value);
|
||||||
|
} else {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry_password),
|
||||||
|
"");
|
||||||
|
}
|
||||||
|
|
||||||
|
value = pandora_setup_get_dbname (setup);
|
||||||
|
if (value) {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry_dbname),
|
||||||
|
value);
|
||||||
|
g_free (value);
|
||||||
|
} else {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry_dbname),
|
||||||
|
"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_setup_dialog_apply_changes (PandoraSetupDialog *dialog)
|
||||||
|
{
|
||||||
|
const gchar *host;
|
||||||
|
const gchar *username;
|
||||||
|
const gchar *password;
|
||||||
|
const gchar *dbname;
|
||||||
|
|
||||||
|
host = gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry_host));
|
||||||
|
username = gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry_username));
|
||||||
|
password = gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry_password));
|
||||||
|
dbname = gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry_dbname));
|
||||||
|
|
||||||
|
g_object_set (G_OBJECT (dialog->priv->setup),
|
||||||
|
"host", host,
|
||||||
|
"username", username,
|
||||||
|
"dbname", dbname,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (g_ascii_strcasecmp (password, NOT_SHOWN_PASSWORD) != 0) {
|
||||||
|
pandora_setup_set_password (dialog->priv->setup, password);
|
||||||
|
}
|
||||||
|
}
|
57
pandora_applet/src/pandora-setup-dialog.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SETUP_DIALOG_H
|
||||||
|
#define SETUP_DIALOG_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "pandora-setup.h"
|
||||||
|
|
||||||
|
#define NOT_SHOWN_PASSWORD "nonenonenone"
|
||||||
|
|
||||||
|
#define PANDORA_SETUP_DIALOG_TYPE (pandora_setup_dialog_get_type())
|
||||||
|
#define PANDORA_SETUP_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST((object), PANDORA_SETUP_DIALOG_TYPE, PandoraSetupDialog))
|
||||||
|
#define PANDORA_SETUP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANDORA_SETUP_DIALOG_TYPE, PandoraSetupDialogClass))
|
||||||
|
#define PANDORA_IS_SETUP_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), PANDORA_SETUP_DIALOG_TYPE))
|
||||||
|
#define PANDORA_IS_SETUP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PANDORA_SETUP_DIALOG_TYPE))
|
||||||
|
#define PANDORA_SETUP_DIALOG_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), PANDORA_SETUP_DIALOG_TYPE, PandoraSetupDialogClass))
|
||||||
|
|
||||||
|
typedef struct _PandoraSetupDialogPrivate PandoraSetupDialogPrivate;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GtkDialogClass parent_class;
|
||||||
|
} PandoraSetupDialogClass;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GtkDialog parent;
|
||||||
|
PandoraSetupDialogPrivate *priv;
|
||||||
|
} PandoraSetupDialog;
|
||||||
|
|
||||||
|
GtkWidget *pandora_setup_dialog_new (void);
|
||||||
|
|
||||||
|
void pandora_setup_dialog_set_setup (PandoraSetupDialog *dialog,
|
||||||
|
PandoraSetup *setup);
|
||||||
|
void pandora_setup_dialog_apply_changes (PandoraSetupDialog *dialog);
|
||||||
|
|
||||||
|
#endif
|
417
pandora_applet/src/pandora-setup.c
Normal file
@ -0,0 +1,417 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pandora-setup.h"
|
||||||
|
|
||||||
|
#include <libxml/tree.h>
|
||||||
|
#include <libxml/encoding.h>
|
||||||
|
#include <libxml/xmlwriter.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_HOST,
|
||||||
|
PROP_USERNAME,
|
||||||
|
PROP_PASSWORD,
|
||||||
|
PROP_DBNAME
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _PandoraSetupPrivate {
|
||||||
|
gchar *config_file;
|
||||||
|
|
||||||
|
gchar *host;
|
||||||
|
gchar *username;
|
||||||
|
gchar *password;
|
||||||
|
gchar *dbname;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PANDORA_SETUP_GET_PRIVATE(object) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE ((object), PANDORA_TYPE_SETUP, \
|
||||||
|
PandoraSetupPrivate))
|
||||||
|
|
||||||
|
static GObjectClass *parent_class = NULL;
|
||||||
|
|
||||||
|
static void pandora_setup_read_config_file (PandoraSetup *setup, gchar *file);
|
||||||
|
static void pandora_setup_init (PandoraSetup *pandora_setup);
|
||||||
|
static void pandora_setup_class_init (PandoraSetupClass *klass);
|
||||||
|
static void pandora_setup_finalize (GObject *object);
|
||||||
|
static void pandora_setup_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
static void pandora_setup_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
GType
|
||||||
|
pandora_setup_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
|
static const GTypeInfo info = {
|
||||||
|
sizeof (PandoraSetupClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) pandora_setup_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (PandoraSetup),
|
||||||
|
0,
|
||||||
|
(GInstanceInitFunc) pandora_setup_init
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (G_TYPE_OBJECT, "PandoraSetup",
|
||||||
|
&info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_init (PandoraSetup *setup)
|
||||||
|
{
|
||||||
|
setup->priv = PANDORA_SETUP_GET_PRIVATE (setup);
|
||||||
|
|
||||||
|
setup->priv->host = NULL;
|
||||||
|
setup->priv->username = NULL;
|
||||||
|
setup->priv->password = NULL;
|
||||||
|
setup->priv->dbname = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_class_init (PandoraSetupClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (PandoraSetupPrivate));
|
||||||
|
|
||||||
|
object_class->set_property = pandora_setup_set_property;
|
||||||
|
object_class->get_property = pandora_setup_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_HOST,
|
||||||
|
g_param_spec_string ("host",
|
||||||
|
"Host",
|
||||||
|
"Host to connect to",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_USERNAME,
|
||||||
|
g_param_spec_string ("username",
|
||||||
|
"Username",
|
||||||
|
"Username to use in the connection",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_PASSWORD,
|
||||||
|
g_param_spec_string ("password",
|
||||||
|
"Password",
|
||||||
|
"Password to use in the connection",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_DBNAME,
|
||||||
|
g_param_spec_string ("dbname",
|
||||||
|
"Database name",
|
||||||
|
"Database name to connect to",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
object_class->finalize = pandora_setup_finalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
PandoraSetup *setup = PANDORA_SETUP (object);
|
||||||
|
|
||||||
|
/* Make persistent */
|
||||||
|
pandora_setup_save_to_disk (setup);
|
||||||
|
|
||||||
|
if (setup->priv->config_file) {
|
||||||
|
g_free (setup->priv->config_file);
|
||||||
|
setup->priv->config_file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setup->priv->host) {
|
||||||
|
g_free (setup->priv->host);
|
||||||
|
setup->priv->host = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setup->priv->username) {
|
||||||
|
g_free (setup->priv->username);
|
||||||
|
setup->priv->username = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setup->priv->password) {
|
||||||
|
g_free (setup->priv->password);
|
||||||
|
setup->priv->password = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setup->priv->dbname) {
|
||||||
|
g_free (setup->priv->dbname);
|
||||||
|
setup->priv->dbname = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (G_OBJECT_CLASS (parent_class)->finalize)
|
||||||
|
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
PandoraSetup *setup = PANDORA_SETUP (object);
|
||||||
|
GDate *date;
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_HOST:
|
||||||
|
g_free (setup->priv->host);
|
||||||
|
setup->priv->host = g_value_dup_string (value);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PROP_USERNAME:
|
||||||
|
g_free (setup->priv->username);
|
||||||
|
setup->priv->username = g_value_dup_string (value);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PROP_PASSWORD:
|
||||||
|
g_free (setup->priv->password);
|
||||||
|
setup->priv->password = g_value_dup_string (value);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PROP_DBNAME:
|
||||||
|
g_free (setup->priv->dbname);
|
||||||
|
setup->priv->dbname = g_value_dup_string (value);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
PandoraSetup *setup = PANDORA_SETUP (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_HOST:
|
||||||
|
g_value_set_string (value, setup->priv->host);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PROP_USERNAME:
|
||||||
|
g_value_set_string (value, setup->priv->username);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PROP_PASSWORD:
|
||||||
|
g_value_set_string (value, setup->priv->password);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PROP_DBNAME:
|
||||||
|
g_value_set_string (value, setup->priv->dbname);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
pandora_setup_get_host (PandoraSetup *setup)
|
||||||
|
{
|
||||||
|
gchar *host = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PANDORA_IS_SETUP (setup), NULL);
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (setup), "host", &host, NULL);
|
||||||
|
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
pandora_setup_get_username (PandoraSetup *setup)
|
||||||
|
{
|
||||||
|
gchar *username = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PANDORA_IS_SETUP (setup), NULL);
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (setup), "username", &username, NULL);
|
||||||
|
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
pandora_setup_get_password (PandoraSetup *setup)
|
||||||
|
{
|
||||||
|
gchar *password = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PANDORA_IS_SETUP (setup), NULL);
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (setup), "password", &password, NULL);
|
||||||
|
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
pandora_setup_get_dbname (PandoraSetup *setup)
|
||||||
|
{
|
||||||
|
gchar *dbname = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PANDORA_IS_SETUP (setup), NULL);
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (setup), "dbname", &dbname, NULL);
|
||||||
|
|
||||||
|
return dbname;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_setup_set_host (PandoraSetup *setup, const gchar *host)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PANDORA_IS_SETUP (setup));
|
||||||
|
g_return_if_fail (host != NULL);
|
||||||
|
|
||||||
|
g_object_set (G_OBJECT (setup), "host", host, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_setup_set_username (PandoraSetup *setup, const gchar *username)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PANDORA_IS_SETUP (setup));
|
||||||
|
g_return_if_fail (username != NULL);
|
||||||
|
|
||||||
|
g_object_set (G_OBJECT (setup), "username", username, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_setup_set_password (PandoraSetup *setup, const gchar *password)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PANDORA_IS_SETUP (setup));
|
||||||
|
g_return_if_fail (password != NULL);
|
||||||
|
|
||||||
|
g_object_set (G_OBJECT (setup), "password", password, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_setup_set_dbname (PandoraSetup *setup, const gchar *dbname)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PANDORA_IS_SETUP (setup));
|
||||||
|
g_return_if_fail (dbname != NULL);
|
||||||
|
|
||||||
|
g_object_set (G_OBJECT (setup), "dbname", dbname, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_setup_read_config_file (PandoraSetup *setup, gchar *file)
|
||||||
|
{
|
||||||
|
xmlDocPtr doc;
|
||||||
|
xmlNodePtr root;
|
||||||
|
gchar *host;
|
||||||
|
gchar *username;
|
||||||
|
gchar *password;
|
||||||
|
gchar *dbname;
|
||||||
|
|
||||||
|
doc = xmlParseFile (file);
|
||||||
|
|
||||||
|
if (!doc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
root = xmlDocGetRootElement (doc);
|
||||||
|
|
||||||
|
if (!root) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_ascii_strcasecmp ((const gchar*) root->name, "config") == 0) {
|
||||||
|
host = (gchar *) xmlGetProp (root, (xmlChar *) "host");
|
||||||
|
username = (gchar *) xmlGetProp (root, (xmlChar *) "username");
|
||||||
|
password = (gchar *) xmlGetProp (root, (xmlChar *) "password");
|
||||||
|
dbname = (gchar *) xmlGetProp (root, (xmlChar *) "dbname");
|
||||||
|
|
||||||
|
g_object_set (setup,
|
||||||
|
"host", host,
|
||||||
|
"username", username,
|
||||||
|
"password", password,
|
||||||
|
"dbname", dbname,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_free (host);
|
||||||
|
g_free (username);
|
||||||
|
g_free (password);
|
||||||
|
g_free (dbname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_setup_save_to_disk (PandoraSetup *setup)
|
||||||
|
{
|
||||||
|
xmlTextWriterPtr writer;
|
||||||
|
|
||||||
|
writer = xmlNewTextWriterFilename (setup->priv->config_file, 0);
|
||||||
|
|
||||||
|
xmlTextWriterStartDocument (writer, NULL, NULL, NULL);
|
||||||
|
xmlTextWriterStartElement (writer, BAD_CAST "config");
|
||||||
|
|
||||||
|
xmlTextWriterWriteAttribute (writer,
|
||||||
|
BAD_CAST "host",
|
||||||
|
BAD_CAST setup->priv->host);
|
||||||
|
xmlTextWriterWriteAttribute (writer,
|
||||||
|
BAD_CAST "username",
|
||||||
|
BAD_CAST setup->priv->username);
|
||||||
|
xmlTextWriterWriteAttribute (writer,
|
||||||
|
BAD_CAST "password",
|
||||||
|
BAD_CAST setup->priv->password);
|
||||||
|
xmlTextWriterWriteAttribute (writer,
|
||||||
|
BAD_CAST "dbname",
|
||||||
|
BAD_CAST setup->priv->dbname);
|
||||||
|
|
||||||
|
xmlTextWriterEndElement (writer);
|
||||||
|
xmlTextWriterEndDocument (writer);
|
||||||
|
xmlFreeTextWriter (writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PandoraSetup *
|
||||||
|
pandora_setup_new (gchar *config_file)
|
||||||
|
{
|
||||||
|
PandoraSetup *setup;
|
||||||
|
|
||||||
|
setup = PANDORA_SETUP (g_object_new (PANDORA_TYPE_SETUP, NULL));
|
||||||
|
|
||||||
|
setup->priv->config_file = g_strdup (config_file);
|
||||||
|
|
||||||
|
pandora_setup_read_config_file (setup, config_file);
|
||||||
|
|
||||||
|
return setup;
|
||||||
|
}
|
||||||
|
|
65
pandora_applet/src/pandora-setup.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SETUP_H
|
||||||
|
#define SETUP_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#define PANDORA_TYPE_SETUP (pandora_setup_get_type())
|
||||||
|
#define PANDORA_SETUP(object) (G_TYPE_CHECK_INSTANCE_CAST((object), PANDORA_TYPE_SETUP, PandoraSetup))
|
||||||
|
#define PANDORA_SETUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANDORA_TYPE_SETUP, PandoraSetupClass))
|
||||||
|
#define PANDORA_IS_SETUP(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), PANDORA_TYPE_SETUP))
|
||||||
|
#define PANDORA_IS_SETUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PANDORA_TYPE_SETUP))
|
||||||
|
#define PANDORA_SETUP_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), PANDORA_TYPE_SETUP, PandoraSetupClass))
|
||||||
|
|
||||||
|
typedef struct _PandoraSetupPrivate PandoraSetupPrivate;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
} PandoraSetupClass;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup instance data
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
GObject parent;
|
||||||
|
PandoraSetupPrivate *priv;
|
||||||
|
} PandoraSetup;
|
||||||
|
|
||||||
|
PandoraSetup *pandora_setup_new (gchar *config_file);
|
||||||
|
|
||||||
|
gchar *pandora_setup_get_host (PandoraSetup *setup);
|
||||||
|
gchar *pandora_setup_get_username (PandoraSetup *setup);
|
||||||
|
gchar *pandora_setup_get_password (PandoraSetup *setup);
|
||||||
|
gchar *pandora_setup_get_dbname (PandoraSetup *setup);
|
||||||
|
|
||||||
|
void pandora_setup_set_host (PandoraSetup *setup, const gchar *host);
|
||||||
|
void pandora_setup_set_username (PandoraSetup *setup, const gchar *username);
|
||||||
|
void pandora_setup_set_password (PandoraSetup *setup, const gchar *password);
|
||||||
|
void pandora_setup_set_dbname (PandoraSetup *setup, const gchar *dbname);
|
||||||
|
|
||||||
|
void pandora_setup_save_to_disk (PandoraSetup *setup);
|
||||||
|
|
||||||
|
#endif
|
402
pandora_applet/src/pandora-status-checker.c
Normal file
@ -0,0 +1,402 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <mysql.h>
|
||||||
|
|
||||||
|
#include "pandora-status-checker.h"
|
||||||
|
|
||||||
|
struct _PandoraStatusCheckerPrivate {
|
||||||
|
GThread *thread;
|
||||||
|
GMutex *state_mutex;
|
||||||
|
|
||||||
|
gint state;
|
||||||
|
|
||||||
|
PandoraStatus *status;
|
||||||
|
PandoraSetup *setup;
|
||||||
|
|
||||||
|
MYSQL *connection;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PANDORA_STATUS_CHECKER_GET_PRIVATE(object) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE ((object), PANDORA_STATUS_CHECKER_TYPE, \
|
||||||
|
PandoraStatusCheckerPrivate))
|
||||||
|
|
||||||
|
static gboolean pandora_status_checker_connect (PandoraStatusChecker *checker);
|
||||||
|
static gboolean pandora_status_checker_disconnect (PandoraStatusChecker *checker);
|
||||||
|
|
||||||
|
static PandoraState pandora_status_checker_check_alerts (PandoraStatusChecker *checker);
|
||||||
|
static PandoraState pandora_status_checker_check_servers (PandoraStatusChecker *checker);
|
||||||
|
static PandoraState pandora_status_checker_check_agents (PandoraStatusChecker *checker);
|
||||||
|
|
||||||
|
static void pandora_status_checker_init (PandoraStatusChecker *checker);
|
||||||
|
static void pandora_status_checker_class_init (PandoraStatusCheckerClass *klass);
|
||||||
|
static void pandora_status_checker_finalize (GObject *object);
|
||||||
|
|
||||||
|
static gpointer pandora_status_checker_run_thread (gpointer data);
|
||||||
|
|
||||||
|
GType
|
||||||
|
pandora_status_checker_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
|
static const GTypeInfo info = {
|
||||||
|
sizeof (PandoraStatusCheckerClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) pandora_status_checker_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (PandoraStatusChecker),
|
||||||
|
0,
|
||||||
|
(GInstanceInitFunc) pandora_status_checker_init
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (G_TYPE_OBJECT, "PandoraStatusChecker",
|
||||||
|
&info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_status_checker_init (PandoraStatusChecker *checker)
|
||||||
|
{
|
||||||
|
checker->priv = PANDORA_STATUS_CHECKER_GET_PRIVATE (checker);
|
||||||
|
|
||||||
|
checker->priv->connection = NULL;
|
||||||
|
|
||||||
|
checker->priv->state_mutex = g_mutex_new ();
|
||||||
|
|
||||||
|
checker->priv->state = CHECKER_STATE_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_status_checker_class_init (PandoraStatusCheckerClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (PandoraStatusCheckerPrivate));
|
||||||
|
|
||||||
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
|
object_class->finalize = pandora_status_checker_finalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_status_checker_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
PandoraStatusChecker *checker;
|
||||||
|
|
||||||
|
checker = PANDORA_STATUS_CHECKER (object);
|
||||||
|
|
||||||
|
switch (checker->priv->state) {
|
||||||
|
case CHECKER_STATE_RUNNING:
|
||||||
|
pandora_status_checker_stop (checker);
|
||||||
|
/* Do not break! */
|
||||||
|
case CHECKER_STATE_STOPPING:
|
||||||
|
g_thread_join (checker->priv->thread);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checker->priv->status) {
|
||||||
|
g_object_unref (checker->priv->status);
|
||||||
|
checker->priv->status = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (checker->priv->state_mutex) {
|
||||||
|
g_mutex_free (checker->priv->state_mutex);
|
||||||
|
checker->priv->state_mutex = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checker->priv->setup) {
|
||||||
|
g_object_unref (checker->priv->setup);
|
||||||
|
checker->priv->setup = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checker->priv->connection) {
|
||||||
|
mysql_close (checker->priv->connection);
|
||||||
|
checker->priv->connection = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PandoraStatusChecker *
|
||||||
|
pandora_status_checker_new (PandoraSetup *setup, PandoraStatus *status)
|
||||||
|
{
|
||||||
|
PandoraStatusChecker *checker;
|
||||||
|
|
||||||
|
checker = PANDORA_STATUS_CHECKER (g_object_new (PANDORA_STATUS_CHECKER_TYPE,
|
||||||
|
NULL));
|
||||||
|
checker->priv->setup = setup;
|
||||||
|
g_object_ref (setup);
|
||||||
|
|
||||||
|
checker->priv->status = status;
|
||||||
|
g_object_ref (status);
|
||||||
|
|
||||||
|
return checker;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
pandora_status_checker_connect (PandoraStatusChecker *checker)
|
||||||
|
{
|
||||||
|
MYSQL *connection;
|
||||||
|
PandoraSetup *setup;
|
||||||
|
gchar *host, *username, *password, *dbname;
|
||||||
|
gboolean retval = TRUE;
|
||||||
|
|
||||||
|
connection = checker->priv->connection;
|
||||||
|
setup = checker->priv->setup;
|
||||||
|
|
||||||
|
if (connection) {
|
||||||
|
mysql_close (connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
connection = mysql_init (NULL);
|
||||||
|
|
||||||
|
if (connection == NULL) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (setup), "host", &host, "username", &username,
|
||||||
|
"password", &password, "dbname", &dbname, NULL);
|
||||||
|
|
||||||
|
if (mysql_real_connect (connection, host, username,
|
||||||
|
password, dbname, 3306, NULL, 0) == NULL)
|
||||||
|
{
|
||||||
|
|
||||||
|
g_print ("mysql_real_connect() failed. %s\n",
|
||||||
|
mysql_error (connection));
|
||||||
|
mysql_close (connection);
|
||||||
|
|
||||||
|
retval = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
checker->priv->connection = connection;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
pandora_status_checker_disconnect (PandoraStatusChecker *checker)
|
||||||
|
{
|
||||||
|
if (checker->priv->connection) {
|
||||||
|
mysql_close (checker->priv->connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
checker->priv->connection = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PandoraState
|
||||||
|
pandora_status_checker_check_agents (PandoraStatusChecker *checker)
|
||||||
|
{
|
||||||
|
MYSQL *connection = NULL;
|
||||||
|
MYSQL_RES *result;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
const gchar const *query_time = "SELECT * FROM tagente "
|
||||||
|
"WHERE UNIX_TIMESTAMP(ultimo_contacto_remoto)"
|
||||||
|
"- intervalo > UNIX_TIMESTAMP(NOW())" ;
|
||||||
|
const gchar const *query_status = "SELECT * FROM tagente_estado "
|
||||||
|
"LEFT JOIN tagente "
|
||||||
|
"ON tagente_estado.id_agente = tagente.id_agente "
|
||||||
|
"WHERE estado != 100 and datos = 0.0";
|
||||||
|
connection = checker->priv->connection;
|
||||||
|
g_return_val_if_fail (connection != NULL, FALSE);
|
||||||
|
|
||||||
|
if (mysql_query (connection, query_time) != 0) {
|
||||||
|
return STATE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = mysql_store_result (connection);
|
||||||
|
|
||||||
|
if (mysql_num_rows (result) > 0) {
|
||||||
|
return STATE_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_free_result (result);
|
||||||
|
|
||||||
|
if (mysql_query (connection, query_status) != 0) {
|
||||||
|
return STATE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = mysql_store_result (connection);
|
||||||
|
|
||||||
|
if (mysql_num_rows (result) > 0) {
|
||||||
|
return STATE_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_free_result (result);
|
||||||
|
return STATE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PandoraState
|
||||||
|
pandora_status_checker_check_servers (PandoraStatusChecker *checker)
|
||||||
|
{
|
||||||
|
MYSQL *connection = NULL;
|
||||||
|
MYSQL_RES *result;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
const gchar const *query = "SELECT * FROM tserver "
|
||||||
|
"WHERE status = 0";
|
||||||
|
|
||||||
|
connection = checker->priv->connection;
|
||||||
|
g_return_val_if_fail (connection != NULL, FALSE);
|
||||||
|
|
||||||
|
if (mysql_query (connection, query) != 0) {
|
||||||
|
return STATE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = mysql_store_result (connection);
|
||||||
|
|
||||||
|
if (mysql_num_rows (result) > 0)
|
||||||
|
return STATE_BAD;
|
||||||
|
|
||||||
|
mysql_free_result (result);
|
||||||
|
return STATE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PandoraState
|
||||||
|
pandora_status_checker_check_alerts (PandoraStatusChecker *checker)
|
||||||
|
{
|
||||||
|
MYSQL *connection = NULL;
|
||||||
|
MYSQL_RES *result1 = NULL, *result2 = NULL, *result3 = NULL;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
const gchar const *query_all_agents = "SELECT * FROM tagente "
|
||||||
|
"WHERE disabled = 0";
|
||||||
|
const gchar const *query_agent_state = "SELECT * FROM tagente_estado "
|
||||||
|
"WHERE id_agente = %s";
|
||||||
|
const gchar const *query_agent_alert = "SELECT * FROM talerta_agente_modulo "
|
||||||
|
"WHERE id_agente_modulo = %s "
|
||||||
|
"AND times_fired > 0";
|
||||||
|
gchar *query;
|
||||||
|
|
||||||
|
connection = checker->priv->connection;
|
||||||
|
g_return_val_if_fail (connection != NULL, FALSE);
|
||||||
|
|
||||||
|
if (mysql_query (connection, query_all_agents) != 0) {
|
||||||
|
return STATE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
result1 = mysql_store_result (connection);
|
||||||
|
if (result1 == NULL)
|
||||||
|
return STATE_UNKNOWN;
|
||||||
|
|
||||||
|
if (mysql_num_rows (result1) == 0)
|
||||||
|
return STATE_UNKNOWN;
|
||||||
|
|
||||||
|
while (row = mysql_fetch_row (result1)) {
|
||||||
|
query = g_strdup_printf (query_agent_state, row[0]);
|
||||||
|
|
||||||
|
if (mysql_query (connection, query) == 0) {
|
||||||
|
result2 = mysql_store_result (connection);
|
||||||
|
|
||||||
|
if (mysql_num_rows (result2) > 0) {
|
||||||
|
|
||||||
|
while (row = mysql_fetch_row (result2)) {
|
||||||
|
|
||||||
|
g_free (query);
|
||||||
|
query = g_strdup_printf (query_agent_alert,
|
||||||
|
row[1]);
|
||||||
|
|
||||||
|
if (mysql_query (connection, query) == 0) {
|
||||||
|
result3 = mysql_store_result (connection);
|
||||||
|
|
||||||
|
if (mysql_num_rows (result3) > 0) {
|
||||||
|
mysql_free_result (result1);
|
||||||
|
mysql_free_result (result2);
|
||||||
|
mysql_free_result (result3);
|
||||||
|
|
||||||
|
g_free (query);
|
||||||
|
|
||||||
|
return STATE_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_free_result (result3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_free_result (result2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (query);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mysql_num_rows (result1) > 0)
|
||||||
|
mysql_free_result (result1);
|
||||||
|
|
||||||
|
return STATE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
pandora_status_checker_run_thread (gpointer data)
|
||||||
|
{
|
||||||
|
PandoraStatusChecker *checker = PANDORA_STATUS_CHECKER (data);
|
||||||
|
PandoraState alerts, servers, agents;
|
||||||
|
|
||||||
|
g_mutex_lock (checker->priv->state_mutex);
|
||||||
|
checker->priv->state = CHECKER_STATE_RUNNING;
|
||||||
|
|
||||||
|
while (checker->priv->state == CHECKER_STATE_RUNNING) {
|
||||||
|
g_mutex_unlock (checker->priv->state_mutex);
|
||||||
|
|
||||||
|
if (!pandora_status_checker_connect (checker)) {
|
||||||
|
pandora_status_checker_stop (checker);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
alerts = pandora_status_checker_check_alerts (checker);
|
||||||
|
servers = pandora_status_checker_check_servers (checker);
|
||||||
|
agents = pandora_status_checker_check_agents (checker);
|
||||||
|
|
||||||
|
pandora_status_set_alerts (checker->priv->status, alerts);
|
||||||
|
pandora_status_set_servers (checker->priv->status, servers);
|
||||||
|
pandora_status_set_agents (checker->priv->status, agents);
|
||||||
|
|
||||||
|
pandora_status_checker_disconnect (checker);
|
||||||
|
|
||||||
|
g_usleep (G_USEC_PER_SEC * 10);
|
||||||
|
|
||||||
|
g_mutex_lock (checker->priv->state_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_mutex_unlock (checker->priv->state_mutex);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_status_checker_run (PandoraStatusChecker *checker)
|
||||||
|
{
|
||||||
|
checker->priv->thread = g_thread_create (pandora_status_checker_run_thread,
|
||||||
|
(gpointer) checker, TRUE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_status_checker_stop (PandoraStatusChecker *checker)
|
||||||
|
{
|
||||||
|
g_mutex_lock (checker->priv->state_mutex);
|
||||||
|
checker->priv->state = CHECKER_STATE_RUNNING;
|
||||||
|
g_mutex_unlock (checker->priv->state_mutex);
|
||||||
|
}
|
65
pandora_applet/src/pandora-status-checker.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STATUS_CHECKER_H
|
||||||
|
#define STATUS_CHECKER_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "pandora-setup.h"
|
||||||
|
#include "pandora-status.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CHECKER_STATE_READY,
|
||||||
|
CHECKER_STATE_RUNNING,
|
||||||
|
CHECKER_STATE_FINISHED,
|
||||||
|
CHECKER_STATE_STOPPING,
|
||||||
|
CHECKER_STATE_FAILED
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PANDORA_STATUS_CHECKER_TYPE (pandora_status_checker_get_type())
|
||||||
|
#define PANDORA_STATUS_CHECKER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), PANDORA_STATUS_CHECKER_TYPE, PandoraStatusChecker))
|
||||||
|
#define PANDORA_STATUS_CHECKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANDORA_STATUS_CHECKER_TYPE, PandoraStatusCheckerClass))
|
||||||
|
#define PANDORA_IS_STATUS_CHECKER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), PANDORA_STATUS_CHECKER_TYPE))
|
||||||
|
#define PANDORA_IS_STATUS_CHECKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PANDORA_STATUS_CHECKER_TYPE))
|
||||||
|
#define PANDORA_STATUS_CHECKER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), PANDORA_STATUS_CHECKER_TYPE, PandoraStatusCheckerClass))
|
||||||
|
|
||||||
|
typedef struct _PandoraStatusCheckerPrivate PandoraStatusCheckerPrivate;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
} PandoraStatusCheckerClass;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
|
PandoraStatusCheckerPrivate *priv;
|
||||||
|
} PandoraStatusChecker;
|
||||||
|
|
||||||
|
PandoraStatusChecker *pandora_status_checker_new (PandoraSetup *setup,
|
||||||
|
PandoraStatus *status);
|
||||||
|
|
||||||
|
void pandora_status_checker_run (PandoraStatusChecker *checker);
|
||||||
|
void pandora_status_checker_stop (PandoraStatusChecker *checker);
|
||||||
|
|
||||||
|
#endif
|
218
pandora_applet/src/pandora-status.c
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include "pandora-status.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CHANGED,
|
||||||
|
N_SIGNALS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _PandoraStatusPrivate {
|
||||||
|
PandoraState alerts;
|
||||||
|
PandoraState agents;
|
||||||
|
PandoraState servers;
|
||||||
|
|
||||||
|
GMutex *mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint pandora_status_signals[N_SIGNALS];
|
||||||
|
|
||||||
|
#define PANDORA_STATUS_GET_PRIVATE(object) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE ((object), PANDORA_STATUS_TYPE, \
|
||||||
|
PandoraStatusPrivate))
|
||||||
|
|
||||||
|
static void pandora_status_init (PandoraStatus *status);
|
||||||
|
static void pandora_status_class_init (PandoraStatusClass *klass);
|
||||||
|
static void pandora_status_finalize (GObject *object);
|
||||||
|
|
||||||
|
GType
|
||||||
|
pandora_status_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
|
static const GTypeInfo info = {
|
||||||
|
sizeof (PandoraStatusClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) pandora_status_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (PandoraStatus),
|
||||||
|
0,
|
||||||
|
(GInstanceInitFunc) pandora_status_init
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (G_TYPE_OBJECT, "PandoraStatus",
|
||||||
|
&info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_status_init (PandoraStatus *status)
|
||||||
|
{
|
||||||
|
status->priv = PANDORA_STATUS_GET_PRIVATE (status);
|
||||||
|
status->priv->alerts = FALSE;
|
||||||
|
status->priv->agents = FALSE;
|
||||||
|
status->priv->servers = FALSE;
|
||||||
|
|
||||||
|
status->priv->mutex = g_mutex_new ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_status_class_init (PandoraStatusClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (PandoraStatusPrivate));
|
||||||
|
|
||||||
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
|
object_class->finalize = pandora_status_finalize;
|
||||||
|
|
||||||
|
pandora_status_signals[CHANGED] =
|
||||||
|
g_signal_new ("changed",
|
||||||
|
G_TYPE_FROM_CLASS (object_class),
|
||||||
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||||
|
G_STRUCT_OFFSET (PandoraStatusClass, changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pandora_status_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
PandoraStatus *status;
|
||||||
|
|
||||||
|
status = PANDORA_STATUS (object);
|
||||||
|
|
||||||
|
if (status->priv->mutex) {
|
||||||
|
g_mutex_free (status->priv->mutex);
|
||||||
|
status->priv->mutex = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PandoraStatus *
|
||||||
|
pandora_status_new (void)
|
||||||
|
{
|
||||||
|
PandoraStatus *status;
|
||||||
|
|
||||||
|
status = PANDORA_STATUS (g_object_new (PANDORA_STATUS_TYPE,
|
||||||
|
NULL));
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_status_set_alerts (PandoraStatus *status, PandoraState value)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PANDORA_IS_STATUS (status));
|
||||||
|
|
||||||
|
g_mutex_lock (status->priv->mutex);
|
||||||
|
|
||||||
|
if (status->priv->alerts != value) {
|
||||||
|
status->priv->alerts = value;
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
|
||||||
|
g_signal_emit (status, pandora_status_signals[CHANGED], 0);
|
||||||
|
} else {
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_status_set_agents (PandoraStatus *status, PandoraState value)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PANDORA_IS_STATUS (status));
|
||||||
|
|
||||||
|
g_mutex_lock (status->priv->mutex);
|
||||||
|
|
||||||
|
if (status->priv->agents != value) {
|
||||||
|
status->priv->agents = value;
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
|
||||||
|
g_signal_emit (status, pandora_status_signals[CHANGED], 0);
|
||||||
|
} else {
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pandora_status_set_servers (PandoraStatus *status, PandoraState value)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PANDORA_IS_STATUS (status));
|
||||||
|
|
||||||
|
g_mutex_lock (status->priv->mutex);
|
||||||
|
|
||||||
|
if (status->priv->servers != value) {
|
||||||
|
status->priv->servers = value;
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
|
||||||
|
g_signal_emit (status, pandora_status_signals[CHANGED], 0);
|
||||||
|
} else {
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PandoraState
|
||||||
|
pandora_status_get_alerts (PandoraStatus *status)
|
||||||
|
{
|
||||||
|
PandoraState value;
|
||||||
|
|
||||||
|
g_mutex_lock (status->priv->mutex);
|
||||||
|
value = status->priv->alerts;
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PandoraState
|
||||||
|
pandora_status_get_agents (PandoraStatus *status)
|
||||||
|
{
|
||||||
|
PandoraState value;
|
||||||
|
|
||||||
|
g_mutex_lock (status->priv->mutex);
|
||||||
|
value = status->priv->agents;
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PandoraState
|
||||||
|
pandora_status_get_servers (PandoraStatus *status)
|
||||||
|
{
|
||||||
|
PandoraState value;
|
||||||
|
|
||||||
|
g_mutex_lock (status->priv->mutex);
|
||||||
|
value = status->priv->servers;
|
||||||
|
g_mutex_unlock (status->priv->mutex);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
67
pandora_applet/src/pandora-status.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2006 Artica ST.
|
||||||
|
Written by Esteban Sanchez.
|
||||||
|
|
||||||
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STATUS_H
|
||||||
|
#define STATUS_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
STATE_INVALID,
|
||||||
|
STATE_UNKNOWN,
|
||||||
|
STATE_OK,
|
||||||
|
STATE_BAD
|
||||||
|
} PandoraState;
|
||||||
|
|
||||||
|
#define PANDORA_STATUS_TYPE (pandora_status_get_type())
|
||||||
|
#define PANDORA_STATUS(object) (G_TYPE_CHECK_INSTANCE_CAST((object), PANDORA_STATUS_TYPE, PandoraStatus))
|
||||||
|
#define PANDORA_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANDORA_STATUS_TYPE, PandoraStatusClass))
|
||||||
|
#define PANDORA_IS_STATUS(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), PANDORA_STATUS_TYPE))
|
||||||
|
#define PANDORA_IS_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PANDORA_STATUS_TYPE))
|
||||||
|
#define PANDORA_STATUS_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), PANDORA_STATUS_TYPE, PandoraStatusClass))
|
||||||
|
|
||||||
|
typedef struct _PandoraStatusPrivate PandoraStatusPrivate;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
|
PandoraStatusPrivate *priv;
|
||||||
|
} PandoraStatus;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
void (* changed) (PandoraStatus *view);
|
||||||
|
} PandoraStatusClass;
|
||||||
|
|
||||||
|
PandoraStatus *pandora_status_new (void);
|
||||||
|
void pandora_status_set_alerts (PandoraStatus *status, PandoraState value);
|
||||||
|
void pandora_status_set_agents (PandoraStatus *status, PandoraState value);
|
||||||
|
void pandora_status_set_servers (PandoraStatus *status, PandoraState value);
|
||||||
|
|
||||||
|
PandoraState pandora_status_get_alerts (PandoraStatus *status);
|
||||||
|
PandoraState pandora_status_get_agents (PandoraStatus *status);
|
||||||
|
PandoraState pandora_status_get_servers (PandoraStatus *status);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|