diff options
author | Perberos <[email protected]> | 2011-12-01 22:49:12 -0300 |
---|---|---|
committer | Perberos <[email protected]> | 2011-12-01 22:49:12 -0300 |
commit | 781b0ff3f74abd6f5353b6d08763bbba93f2f21c (patch) | |
tree | 20c130b413586219356ec360efb5918a498cee69 /src | |
download | mate-notification-daemon-781b0ff3f74abd6f5353b6d08763bbba93f2f21c.tar.bz2 mate-notification-daemon-781b0ff3f74abd6f5353b6d08763bbba93f2f21c.tar.xz |
moving from https://github.com/perberos/mate-desktop-environment
Diffstat (limited to 'src')
26 files changed, 9240 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..98f554e --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = daemon themes capplet + +-include $(top_srcdir)/git.mk diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..089cc2e --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,616 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/macros/intltool.m4 \ + $(top_srcdir)/macros/libtool.m4 \ + $(top_srcdir)/macros/ltoptions.m4 \ + $(top_srcdir)/macros/ltsugar.m4 \ + $(top_srcdir)/macros/ltversion.m4 \ + $(top_srcdir)/macros/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDK_CFLAGS = @GDK_CFLAGS@ +GDK_LIBS = @GDK_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDIR = @LIBDIR@ +LIBEXECDIR = @LIBEXECDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOTIFICATION_CAPPLET_CFLAGS = @NOTIFICATION_CAPPLET_CFLAGS@ +NOTIFICATION_CAPPLET_LIBS = @NOTIFICATION_CAPPLET_LIBS@ +NOTIFICATION_DAEMON_CFLAGS = @NOTIFICATION_DAEMON_CFLAGS@ +NOTIFICATION_DAEMON_LIBS = @NOTIFICATION_DAEMON_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +THEME_CFLAGS = @THEME_CFLAGS@ +THEME_LIBS = @THEME_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ +XGETTEXT = @XGETTEXT@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = daemon themes capplet +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ + install-am install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic clean-libtool \ + ctags ctags-recursive distclean distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am + + +-include $(top_srcdir)/git.mk + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/capplet/Makefile.am b/src/capplet/Makefile.am new file mode 100644 index 0000000..c053d80 --- /dev/null +++ b/src/capplet/Makefile.am @@ -0,0 +1,26 @@ +bin_PROGRAMS = mate-notification-properties + +@INTLTOOL_DESKTOP_RULE@ + +mate_notification_properties_LDADD = $(NOTIFICATION_CAPPLET_LIBS) +mate_notification_properties_SOURCES = mate-notification-properties.c + +uidir = $(datadir)/mate-notification-daemon +ui_DATA = mate-notification-properties.ui + +desktopdir = $(datadir)/applications +desktop_in_files = mate-notification-properties.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src/daemon \ + $(NOTIFICATION_CAPPLET_CFLAGS) \ + -DENGINES_DIR=\"$(libdir)/mate-notification-daemon/engines\" \ + -DNOTIFICATION_LOCALEDIR=\"$(datadir)/locale\" \ + -DNOTIFICATION_UIDIR=\"$(datadir)/mate-notification-daemon\" + +CLEANFILES = $(desktop_DATA) +EXTRA_DIST = $(ui_DATA) $(pixmap_DATA) $(desktop_in_files) + +-include $(top_srcdir)/git.mk diff --git a/src/capplet/Makefile.in b/src/capplet/Makefile.in new file mode 100644 index 0000000..6f77c4c --- /dev/null +++ b/src/capplet/Makefile.in @@ -0,0 +1,669 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = mate-notification-properties$(EXEEXT) +subdir = src/capplet +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/macros/intltool.m4 \ + $(top_srcdir)/macros/libtool.m4 \ + $(top_srcdir)/macros/ltoptions.m4 \ + $(top_srcdir)/macros/ltsugar.m4 \ + $(top_srcdir)/macros/ltversion.m4 \ + $(top_srcdir)/macros/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(desktopdir)" \ + "$(DESTDIR)$(uidir)" +PROGRAMS = $(bin_PROGRAMS) +am_mate_notification_properties_OBJECTS = \ + mate-notification-properties.$(OBJEXT) +mate_notification_properties_OBJECTS = \ + $(am_mate_notification_properties_OBJECTS) +am__DEPENDENCIES_1 = +mate_notification_properties_DEPENDENCIES = $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(mate_notification_properties_SOURCES) +DIST_SOURCES = $(mate_notification_properties_SOURCES) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +DATA = $(desktop_DATA) $(ui_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDK_CFLAGS = @GDK_CFLAGS@ +GDK_LIBS = @GDK_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDIR = @LIBDIR@ +LIBEXECDIR = @LIBEXECDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOTIFICATION_CAPPLET_CFLAGS = @NOTIFICATION_CAPPLET_CFLAGS@ +NOTIFICATION_CAPPLET_LIBS = @NOTIFICATION_CAPPLET_LIBS@ +NOTIFICATION_DAEMON_CFLAGS = @NOTIFICATION_DAEMON_CFLAGS@ +NOTIFICATION_DAEMON_LIBS = @NOTIFICATION_DAEMON_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +THEME_CFLAGS = @THEME_CFLAGS@ +THEME_LIBS = @THEME_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ +XGETTEXT = @XGETTEXT@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +mate_notification_properties_LDADD = $(NOTIFICATION_CAPPLET_LIBS) +mate_notification_properties_SOURCES = mate-notification-properties.c +uidir = $(datadir)/mate-notification-daemon +ui_DATA = mate-notification-properties.ui +desktopdir = $(datadir)/applications +desktop_in_files = mate-notification-properties.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src/daemon \ + $(NOTIFICATION_CAPPLET_CFLAGS) \ + -DENGINES_DIR=\"$(libdir)/mate-notification-daemon/engines\" \ + -DNOTIFICATION_LOCALEDIR=\"$(datadir)/locale\" \ + -DNOTIFICATION_UIDIR=\"$(datadir)/mate-notification-daemon\" + +CLEANFILES = $(desktop_DATA) +EXTRA_DIST = $(ui_DATA) $(pixmap_DATA) $(desktop_in_files) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/capplet/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/capplet/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +mate-notification-properties$(EXEEXT): $(mate_notification_properties_OBJECTS) $(mate_notification_properties_DEPENDENCIES) + @rm -f mate-notification-properties$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(mate_notification_properties_OBJECTS) $(mate_notification_properties_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mate-notification-properties.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-desktopDATA: $(desktop_DATA) + @$(NORMAL_INSTALL) + test -z "$(desktopdir)" || $(MKDIR_P) "$(DESTDIR)$(desktopdir)" + @list='$(desktop_DATA)'; test -n "$(desktopdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(desktopdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(desktopdir)" || exit $$?; \ + done + +uninstall-desktopDATA: + @$(NORMAL_UNINSTALL) + @list='$(desktop_DATA)'; test -n "$(desktopdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(desktopdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(desktopdir)" && rm -f $$files +install-uiDATA: $(ui_DATA) + @$(NORMAL_INSTALL) + test -z "$(uidir)" || $(MKDIR_P) "$(DESTDIR)$(uidir)" + @list='$(ui_DATA)'; test -n "$(uidir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(uidir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(uidir)" || exit $$?; \ + done + +uninstall-uiDATA: + @$(NORMAL_UNINSTALL) + @list='$(ui_DATA)'; test -n "$(uidir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(uidir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(uidir)" && rm -f $$files + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(desktopdir)" "$(DESTDIR)$(uidir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-desktopDATA install-uiDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-desktopDATA \ + uninstall-uiDATA + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am \ + install-desktopDATA install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip install-uiDATA \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-desktopDATA uninstall-uiDATA + + +@INTLTOOL_DESKTOP_RULE@ + +-include $(top_srcdir)/git.mk + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c new file mode 100644 index 0000000..006fdf2 --- /dev/null +++ b/src/capplet/mate-notification-properties.c @@ -0,0 +1,477 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2007 Jonh Wendell <[email protected]> + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 "config.h" + +#include <glib/gi18n.h> +#include <glib.h> +#include <gtk/gtk.h> +#include <mateconf/mateconf-client.h> +#include <string.h> +#include <libmatenotify/notify.h> + +#include "stack.h" + +#define MATECONF_KEY_DAEMON "/apps/mate-notification-daemon" +#define MATECONF_KEY_THEME MATECONF_KEY_DAEMON "/theme" +#define MATECONF_KEY_POPUP_LOCATION MATECONF_KEY_DAEMON "/popup_location" + +#define N_LISTENERS 2 + +#define NOTIFICATION_UI_FILE "mate-notification-properties.ui" + +typedef struct { + MateConfClient* client; + + GtkWidget* dialog; + GtkWidget* position_combo; + GtkWidget* theme_combo; + GtkWidget* preview_button; + + NotifyNotification* preview; + + guint listeners[N_LISTENERS]; + int n_listeners; + int expected_listeners; +} NotificationAppletDialog; + +enum { + NOTIFY_POSITION_LABEL, + NOTIFY_POSITION_NAME, + N_COLUMNS_POSITION +}; + +enum { + NOTIFY_THEME_LABEL, + NOTIFY_THEME_NAME, + NOTIFY_THEME_FILENAME, + N_COLUMNS_THEME +}; + +static void notification_properties_location_notify(MateConfClient* client, guint cnx_id, MateConfEntry* entry, NotificationAppletDialog* dialog) +{ + GtkTreeModel* model; + GtkTreeIter iter; + const char* location; + gboolean valid; + + if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) + { + return; + } + + location = mateconf_value_get_string(entry->value); + + model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo)); + valid = gtk_tree_model_get_iter_first(model, &iter); + + for (valid = gtk_tree_model_get_iter_first(model, &iter); valid; valid = gtk_tree_model_iter_next(model, &iter)) + { + gchar* key; + + gtk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &key, -1); + + if (g_str_equal(key, location)) + { + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dialog->position_combo), &iter); + g_free(key); + break; + } + + g_free(key); + } +} + +static void notification_properties_location_changed(GtkComboBox* widget, NotificationAppletDialog* dialog) +{ + char* location; + GtkTreeIter iter; + + GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo)); + + if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(dialog->position_combo), &iter)) + { + return; + } + + gtk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &location, -1); + + mateconf_client_set_string(dialog->client, MATECONF_KEY_POPUP_LOCATION, location, NULL); + g_free(location); +} + +static void notification_properties_dialog_setup_positions(NotificationAppletDialog* dialog) +{ + char* location; + gboolean valid; + GtkTreeModel* model; + GtkTreeIter iter; + + model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo)); + g_signal_connect(dialog->position_combo, "changed", G_CALLBACK(notification_properties_location_changed), dialog); + + location = mateconf_client_get_string(dialog->client, MATECONF_KEY_POPUP_LOCATION, NULL); + + for (valid = gtk_tree_model_get_iter_first(model, &iter); valid; valid = gtk_tree_model_iter_next(model, &iter)) + { + gchar* key; + + gtk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &key, -1); + + if (g_str_equal(key, location)) + { + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dialog->position_combo), &iter); + g_free(key); + break; + } + + g_free(key); + } + + dialog->listeners[dialog->n_listeners] = mateconf_client_notify_add(dialog->client, MATECONF_KEY_POPUP_LOCATION, (MateConfClientNotifyFunc) notification_properties_location_notify, dialog, NULL, NULL); + dialog->n_listeners++; + g_free(location); +} + +static void notification_properties_theme_notify(MateConfClient* client, guint cnx_id, MateConfEntry* entry, NotificationAppletDialog* dialog) +{ + if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) + { + return; + } + + const char* theme = mateconf_value_get_string(entry->value); + + GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->theme_combo)); + + GtkTreeIter iter; + gboolean valid; + + for (valid = gtk_tree_model_get_iter_first(model, &iter); valid; valid = gtk_tree_model_iter_next(model, &iter)) + { + gchar* theme_name; + + gtk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme_name, -1); + + if (g_str_equal(theme_name, theme)) + { + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dialog->theme_combo), &iter); + g_free(theme_name); + break; + } + + g_free(theme_name); + } +} + +static void notification_properties_theme_changed(GtkComboBox* widget, NotificationAppletDialog* dialog) +{ + char* theme; + GtkTreeIter iter; + + GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->theme_combo)); + + if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(dialog->theme_combo), &iter)) + { + return; + } + + gtk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme, -1); + mateconf_client_set_string(dialog->client, MATECONF_KEY_THEME, theme, NULL); + g_free(theme); +} + +static gchar* get_theme_name(const gchar* filename) +{ + /* TODO: Remove magic numbers. Strip "lib" and ".so" */ + gchar* result = g_strdup(filename + 3); + result[strlen(result) - 3] = '\0'; + return result; +} + +static void notification_properties_dialog_setup_themes(NotificationAppletDialog* dialog) +{ + GDir* dir; + const gchar* filename; + char* theme; + char* theme_name; + char* theme_label; + gboolean valid; + GtkListStore* store; + GtkTreeIter iter; + + store = gtk_list_store_new(N_COLUMNS_THEME, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + + gtk_combo_box_set_model(GTK_COMBO_BOX(dialog->theme_combo), GTK_TREE_MODEL(store)); + g_signal_connect(dialog->theme_combo, "changed", G_CALLBACK(notification_properties_theme_changed), dialog); + + if ((dir = g_dir_open(ENGINES_DIR, 0, NULL))) + { + while ((filename = g_dir_read_name(dir))) + { + if (g_str_has_prefix(filename, "lib") && g_str_has_suffix(filename, ".so")) + { + theme_name = get_theme_name(filename); + + /* FIXME: other solution than hardcode? */ + if (g_str_equal(theme_name, "slider")) + { + theme_label = g_strdup(_("Slider")); + } + else if (g_str_equal(theme_name, "standard")) + { + theme_label = g_strdup(_("Standard theme")); + } + else + { + theme_label = g_strdup(theme_name); + } + + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, NOTIFY_THEME_LABEL, theme_label, NOTIFY_THEME_NAME, theme_name, NOTIFY_THEME_FILENAME, filename, -1); + g_free(theme_name); + g_free(theme_label); + } + } + + g_dir_close(dir); + } + else + { + g_warning("Error opening themes dir"); + } + + + theme = mateconf_client_get_string(dialog->client, MATECONF_KEY_THEME, NULL); + + for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); valid; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)) + { + gchar* key; + + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, NOTIFY_THEME_NAME, &key, -1); + + if (g_str_equal(key, theme)) + { + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dialog->theme_combo), &iter); + g_free(key); + break; + } + + g_free(key); + } + + dialog->listeners[dialog->n_listeners] = mateconf_client_notify_add(dialog->client, MATECONF_KEY_THEME, (MateConfClientNotifyFunc) notification_properties_theme_notify, dialog, NULL, NULL); + dialog->n_listeners++; + g_free(theme); +} + +static void notification_properties_dialog_help(void) +{ + /* Do nothing */ +} + +static void show_message(NotificationAppletDialog* dialog, const gchar* message) +{ + GtkWidget* d = gtk_message_dialog_new(GTK_WINDOW(dialog->dialog), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message); + gtk_dialog_run(GTK_DIALOG(d)); + gtk_widget_destroy(d); +} + +static void notification_properties_dialog_preview_closed(NotifyNotification* preview, NotificationAppletDialog* dialog) +{ + if (preview == dialog->preview) + { + dialog->preview = NULL; + } + + g_object_unref(preview); +} + +static void notification_properties_dialog_preview(NotificationAppletDialog* dialog) +{ + if (!notify_is_initted() && !notify_init("n-d")) + { + show_message(dialog, _("Error initializing libmatenotify")); + return; + } + + GError* error = NULL; + + if (dialog->preview) + { + notify_notification_close(dialog->preview, NULL); + g_object_unref(dialog->preview); + dialog->preview = NULL; + } + + dialog->preview = notify_notification_new(_("Notification Test"), _("Just a test"), "mate-util", NULL); + + if (!notify_notification_show(dialog->preview, &error)) + { + char* message = g_strdup_printf(_("Error while displaying notification: %s"), error->message); + show_message(dialog, message); + g_error_free(error); + g_free(message); + } + + g_signal_connect(dialog->preview, "closed", G_CALLBACK(notification_properties_dialog_preview_closed), dialog); +} + +static void notification_properties_dialog_response(GtkWidget* widget, int response, NotificationAppletDialog* dialog) +{ + switch (response) + { + case GTK_RESPONSE_HELP: + notification_properties_dialog_help(); + break; + + case GTK_RESPONSE_ACCEPT: + notification_properties_dialog_preview(dialog); + break; + + case GTK_RESPONSE_CLOSE: + default: + gtk_widget_destroy(widget); + break; + } +} + +static void notification_properties_dialog_destroyed(GtkWidget* widget, NotificationAppletDialog* dialog) +{ + dialog->dialog = NULL; + + gtk_main_quit(); +} + +static gboolean notification_properties_dialog_init(NotificationAppletDialog* dialog) +{ + const char* ui_file; + + if (g_file_test(NOTIFICATION_UI_FILE, G_FILE_TEST_EXISTS)) + { + ui_file = NOTIFICATION_UI_FILE; + } + else + { + ui_file = NOTIFICATION_UIDIR "/" NOTIFICATION_UI_FILE; + } + + GtkBuilder* builder = gtk_builder_new(); + GError* error = NULL; + + gtk_builder_add_from_file(builder, ui_file, &error); + + if (error != NULL) + { + g_warning(_("Could not load user interface file: %s"), error->message); + g_error_free(error); + return FALSE; + } + + dialog->dialog = GTK_WIDGET(gtk_builder_get_object(builder, "dialog")); + g_assert(dialog->dialog != NULL); + + dialog->position_combo = GTK_WIDGET(gtk_builder_get_object(builder, "position_combo")); + g_assert(dialog->position_combo != NULL); + + dialog->theme_combo = GTK_WIDGET(gtk_builder_get_object(builder, "theme_combo")); + g_assert(dialog->theme_combo != NULL); + + g_object_unref(builder); + + g_signal_connect(dialog->dialog, "response", G_CALLBACK(notification_properties_dialog_response), dialog); + g_signal_connect(dialog->dialog, "destroy", G_CALLBACK(notification_properties_dialog_destroyed), dialog); + + dialog->client = mateconf_client_get_default(); + mateconf_client_add_dir(dialog->client, MATECONF_KEY_DAEMON, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + dialog->expected_listeners = N_LISTENERS; + dialog->n_listeners = 0; + + notification_properties_dialog_setup_themes(dialog); + notification_properties_dialog_setup_positions(dialog); + + g_assert(dialog->n_listeners == dialog->expected_listeners); + gtk_widget_show(dialog->dialog); + + dialog->preview = NULL; + + return TRUE; +} + +static void notification_properties_dialog_finalize(NotificationAppletDialog* dialog) +{ + if (dialog->dialog != NULL) + { + gtk_widget_destroy(dialog->dialog); + dialog->dialog = NULL; + } + + if (dialog->client != NULL) + { + int i; + + for (i = 0; i < dialog->n_listeners; i++) + { + if (dialog->listeners[i]) + { + mateconf_client_notify_remove(dialog->client, dialog->listeners[i]); + dialog->listeners[i] = 0; + } + } + + dialog->n_listeners = 0; + mateconf_client_remove_dir(dialog->client, MATECONF_KEY_DAEMON, NULL); + g_object_unref(dialog->client); + dialog->client = NULL; + } + + if (dialog->preview) + { + notify_notification_close(dialog->preview, NULL); + dialog->preview = NULL; + } +} + +int main(int argc, char** argv) +{ + NotificationAppletDialog dialog = {NULL, }; /* <- ? */ + + bindtextdomain(GETTEXT_PACKAGE, NOTIFICATION_LOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + + gtk_init(&argc, &argv); + + notify_init("mate-notification-properties"); + + if (!notification_properties_dialog_init(&dialog)) + { + notification_properties_dialog_finalize(&dialog); + return 1; + } + + gtk_main(); + + notification_properties_dialog_finalize(&dialog); + + return 0; +} diff --git a/src/capplet/mate-notification-properties.desktop.in b/src/capplet/mate-notification-properties.desktop.in new file mode 100644 index 0000000..4694c99 --- /dev/null +++ b/src/capplet/mate-notification-properties.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +_Name=Pop-Up Notifications +_Comment=Set your pop-up notification preferences +Exec=mate-notification-properties +Icon=mate-notification-properties +Terminal=false +Type=Application +StartupNotify=true +Categories=MATE;GTK;Settings;DesktopSettings; +OnlyShowIn=MATE; + diff --git a/src/capplet/mate-notification-properties.ui b/src/capplet/mate-notification-properties.ui new file mode 100644 index 0000000..8d56f21 --- /dev/null +++ b/src/capplet/mate-notification-properties.ui @@ -0,0 +1,261 @@ +<?xml version="1.0"?> +<interface> + <!-- interface-requires gtk+ 2.12 --> + <!-- interface-naming-policy toplevel-contextual --> + <object class="GtkDialog" id="dialog"> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="border_width">5</property> + <property name="title" translatable="yes">Notification Settings</property> + <property name="resizable">False</property> + <property name="window_position">center-on-parent</property> + <property name="icon_name">mate-notification-properties</property> + <property name="type_hint">dialog</property> + <property name="has_separator">False</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child> + <object class="GtkVBox" id="vbox4"> + <property name="visible">True</property> + <property name="border_width">5</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>General Options</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <child> + <object class="GtkLabel" id="label10"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkTable" id="table3"> + <property name="visible">True</property> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <property name="column_spacing">12</property> + <property name="row_spacing">6</property> + <child> + <object class="GtkComboBox" id="theme_combo"> + <property name="visible">True</property> + <child> + <object class="GtkCellRendererText" id="theme_cellrenderertext"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="position_combo"> + <property name="visible">True</property> + <property name="model">position_liststore</property> + <child> + <object class="GtkCellRendererText" id="position_cellrenderertext"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">P_osition:</property> + <property name="use_markup">True</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">position_combo</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Theme:</property> + <property name="use_markup">True</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">theme_combo</property> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button3"> + <property name="label">gtk-help</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_stock">True</property> + <property name="focus_on_click">False</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button4"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <child> + <object class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <child> + <object class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <property name="spacing">2</property> + <child> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="icon_name">mate-notification-properties</property> + <property name="icon-size">3</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label12"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Preview</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button5"> + <property name="label">gtk-close</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="receives_default">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-11">button3</action-widget> + <action-widget response="-3">button4</action-widget> + <action-widget response="-7">button5</action-widget> + </action-widgets> + </object> + <object class="GtkListStore" id="position_liststore"> + <columns> + <!-- column-name label --> + <column type="gchararray"/> + <!-- column-name name --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">Top Left</col> + <col id="1">top_left</col> + </row> + <row> + <col id="0" translatable="yes">Top Right</col> + <col id="1">top_right</col> + </row> + <row> + <col id="0" translatable="yes">Bottom Left</col> + <col id="1">bottom_left</col> + </row> + <row> + <col id="0" translatable="yes">Bottom Right</col> + <col id="1">bottom_right</col> + </row> + </data> + </object> +</interface> diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am new file mode 100644 index 0000000..4f9471c --- /dev/null +++ b/src/daemon/Makefile.am @@ -0,0 +1,30 @@ +libexec_PROGRAMS = mate-notification-daemon + +mate_notification_daemon_SOURCES = \ + daemon.c \ + daemon.h \ + engines.c \ + engines.h \ + stack.c \ + stack.h \ + sound.c \ + sound.h + +mate_notification_daemon_LDADD = $(NOTIFICATION_DAEMON_LIBS) + +BUILT_SOURCES = notificationdaemon-dbus-glue.h + +notificationdaemon-dbus-glue.h: notificationdaemon.xml + dbus-binding-tool --mode=glib-server --prefix=notification_daemon \ + $(srcdir)/notificationdaemon.xml > notificationdaemon-dbus-glue.h + +INCLUDES = \ + -I$(top_srcdir) \ + $(NOTIFICATION_DAEMON_CFLAGS) \ + -DENGINES_DIR=\"$(libdir)/mate-notification-daemon/engines\" + +EXTRA_DIST = notificationdaemon.xml +DISTCLEANFILES = \ + notificationdaemon-dbus-glue.h + +-include $(top_srcdir)/git.mk diff --git a/src/daemon/Makefile.in b/src/daemon/Makefile.in new file mode 100644 index 0000000..8978c97 --- /dev/null +++ b/src/daemon/Makefile.in @@ -0,0 +1,617 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +libexec_PROGRAMS = mate-notification-daemon$(EXEEXT) +subdir = src/daemon +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/macros/intltool.m4 \ + $(top_srcdir)/macros/libtool.m4 \ + $(top_srcdir)/macros/ltoptions.m4 \ + $(top_srcdir)/macros/ltsugar.m4 \ + $(top_srcdir)/macros/ltversion.m4 \ + $(top_srcdir)/macros/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(libexecdir)" +PROGRAMS = $(libexec_PROGRAMS) +am_mate_notification_daemon_OBJECTS = daemon.$(OBJEXT) \ + engines.$(OBJEXT) stack.$(OBJEXT) sound.$(OBJEXT) +mate_notification_daemon_OBJECTS = \ + $(am_mate_notification_daemon_OBJECTS) +am__DEPENDENCIES_1 = +mate_notification_daemon_DEPENDENCIES = $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(mate_notification_daemon_SOURCES) +DIST_SOURCES = $(mate_notification_daemon_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDK_CFLAGS = @GDK_CFLAGS@ +GDK_LIBS = @GDK_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDIR = @LIBDIR@ +LIBEXECDIR = @LIBEXECDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOTIFICATION_CAPPLET_CFLAGS = @NOTIFICATION_CAPPLET_CFLAGS@ +NOTIFICATION_CAPPLET_LIBS = @NOTIFICATION_CAPPLET_LIBS@ +NOTIFICATION_DAEMON_CFLAGS = @NOTIFICATION_DAEMON_CFLAGS@ +NOTIFICATION_DAEMON_LIBS = @NOTIFICATION_DAEMON_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +THEME_CFLAGS = @THEME_CFLAGS@ +THEME_LIBS = @THEME_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ +XGETTEXT = @XGETTEXT@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +mate_notification_daemon_SOURCES = \ + daemon.c \ + daemon.h \ + engines.c \ + engines.h \ + stack.c \ + stack.h \ + sound.c \ + sound.h + +mate_notification_daemon_LDADD = $(NOTIFICATION_DAEMON_LIBS) +BUILT_SOURCES = notificationdaemon-dbus-glue.h +INCLUDES = \ + -I$(top_srcdir) \ + $(NOTIFICATION_DAEMON_CFLAGS) \ + -DENGINES_DIR=\"$(libdir)/mate-notification-daemon/engines\" + +EXTRA_DIST = notificationdaemon.xml +DISTCLEANFILES = \ + notificationdaemon-dbus-glue.h + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/daemon/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/daemon/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(libexecdir)" || $(MKDIR_P) "$(DESTDIR)$(libexecdir)" + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libexecdir)" && rm -f $$files + +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +mate-notification-daemon$(EXEEXT): $(mate_notification_daemon_OBJECTS) $(mate_notification_daemon_DEPENDENCIES) + @rm -f mate-notification-daemon$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(mate_notification_daemon_OBJECTS) $(mate_notification_daemon_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/daemon.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/engines.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(libexecdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libexecPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libexecPROGRAMS + +.MAKE: all check install install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libexecPROGRAMS clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ + install-libexecPROGRAMS install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-libexecPROGRAMS + + +notificationdaemon-dbus-glue.h: notificationdaemon.xml + dbus-binding-tool --mode=glib-server --prefix=notification_daemon \ + $(srcdir)/notificationdaemon.xml > notificationdaemon-dbus-glue.h + +-include $(top_srcdir)/git.mk + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c new file mode 100644 index 0000000..8241c6d --- /dev/null +++ b/src/daemon/daemon.c @@ -0,0 +1,1650 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2006 Christian Hammond <[email protected]> + * Copyright (C) 2005 John (J5) Palmieri <[email protected]> + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 "config.h" + +#include <stdlib.h> +#include <errno.h> +#include <string.h> +#include <stdio.h> + +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> +#include <glib/gi18n.h> +#include <glib.h> +#include <glib-object.h> +#include <gtk/gtk.h> + +#include <X11/Xproto.h> + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xatom.h> +#include <gdk/gdkx.h> + +#define WNCK_I_KNOW_THIS_IS_UNSTABLE +#include <libwnck/libwnck.h> + +#include "daemon.h" +#include "engines.h" +#include "stack.h" +#include "sound.h" +#include "notificationdaemon-dbus-glue.h" + +#define MAX_NOTIFICATIONS 20 + +#define IMAGE_SIZE 48 +#define IDLE_SECONDS 30 +#define NOTIFICATION_BUS_NAME "org.freedesktop.Notifications" +#define NOTIFICATION_BUS_PATH "/org/freedesktop/Notifications" + +#define NW_GET_NOTIFY_ID(nw) \ + (GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id"))) +#define NW_GET_NOTIFY_SENDER(nw) \ + (g_object_get_data(G_OBJECT(nw), "_notify_sender")) +#define NW_GET_DAEMON(nw) \ + (g_object_get_data(G_OBJECT(nw), "_notify_daemon")) + +typedef struct { + NotifyStackLocation type; + const char* identifier; +} PopupNotifyStackLocation; + +const PopupNotifyStackLocation popup_stack_locations[] = { + {NOTIFY_STACK_LOCATION_TOP_LEFT, "top_left"}, + {NOTIFY_STACK_LOCATION_TOP_RIGHT, "top_right"}, + {NOTIFY_STACK_LOCATION_BOTTOM_LEFT, "bottom_left"}, + {NOTIFY_STACK_LOCATION_BOTTOM_RIGHT, "bottom_right"}, + {NOTIFY_STACK_LOCATION_UNKNOWN, NULL} +}; + +#define POPUP_STACK_DEFAULT_INDEX 3 /* XXX Hack! */ + +typedef struct { + NotifyDaemon* daemon; + GTimeVal expiration; + GTimeVal paused_diff; + guint id; + GtkWindow* nw; + Window src_window_xid; + guint has_timeout: 1; + guint paused: 1; +} NotifyTimeout; + +typedef struct { + NotifyStack** stacks; + int n_stacks; + Atom workarea_atom; +} NotifyScreen; + +struct _NotifyDaemonPrivate { + guint next_id; + guint timeout_source; + guint exit_timeout_source; + GHashTable* idle_reposition_notify_ids; + GHashTable* monitored_window_hash; + GHashTable* notification_hash; + gboolean url_clicked_lock; + + guint mateconf_cnxn; + + NotifyStackLocation stack_location; + NotifyScreen** screens; + int n_screens; +}; + +typedef struct { + guint id; + NotifyDaemon* daemon; +} _NotifyPendingClose; + +static DBusConnection* dbus_conn = NULL; + +static void notify_daemon_finalize(GObject* object); +static void _notification_destroyed_cb(GtkWindow* nw, NotifyDaemon* daemon); +static void _close_notification(NotifyDaemon* daemon, guint id, gboolean hide_notification, NotifydClosedReason reason); +static GdkFilterReturn _notify_x11_filter(GdkXEvent* xevent, GdkEvent* event, NotifyDaemon* daemon); +static void _emit_closed_signal(GtkWindow* nw, NotifydClosedReason reason); +static void _action_invoked_cb(GtkWindow* nw, const char* key); +static NotifyStackLocation get_stack_location_from_string(const char* slocation); +static void sync_notification_position(NotifyDaemon* daemon, GtkWindow* nw, Window source); +static void monitor_notification_source_windows(NotifyDaemon* daemon, NotifyTimeout* nt, Window source); + +G_DEFINE_TYPE(NotifyDaemon, notify_daemon, G_TYPE_OBJECT); + +static void notify_daemon_class_init(NotifyDaemonClass* daemon_class) +{ + GObjectClass* object_class = G_OBJECT_CLASS(daemon_class); + + object_class->finalize = notify_daemon_finalize; + + g_type_class_add_private(daemon_class, sizeof(NotifyDaemonPrivate)); +} + +static void _notify_timeout_destroy(NotifyTimeout* nt) +{ + /* + * Disconnect the destroy handler to avoid a loop since the id + * won't be removed from the hash table before the widget is + * destroyed. + */ + g_signal_handlers_disconnect_by_func(nt->nw, _notification_destroyed_cb, nt->daemon); + gtk_widget_destroy(GTK_WIDGET(nt->nw)); + g_free(nt); +} + +static gboolean do_exit(gpointer user_data) +{ + //g_debug("Exiting due to inactivity"); + exit(1); + + return FALSE; +} + +static void add_exit_timeout(NotifyDaemon* daemon) +{ + if (daemon->priv->exit_timeout_source > 0) + { + return; + } + + daemon->priv->exit_timeout_source = g_timeout_add_seconds(IDLE_SECONDS, do_exit, NULL); +} + +static void remove_exit_timeout(NotifyDaemon* daemon) +{ + if (daemon->priv->exit_timeout_source == 0) + { + return; + } + + g_source_remove(daemon->priv->exit_timeout_source); + daemon->priv->exit_timeout_source = 0; +} + +static void create_stack_for_monitor(NotifyDaemon* daemon, GdkScreen* screen, int monitor_num) +{ + int screen_num = gdk_screen_get_number(screen); + NotifyScreen* nscreen = daemon->priv->screens[screen_num]; + + nscreen->stacks[monitor_num] = notify_stack_new(daemon, screen, monitor_num, daemon->priv->stack_location); +} + +static void on_screen_monitors_changed(GdkScreen* screen, NotifyDaemon* daemon) +{ + NotifyScreen* nscreen; + int screen_num; + int n_monitors; + int i; + + screen_num = gdk_screen_get_number(screen); + nscreen = daemon->priv->screens[screen_num]; + + n_monitors = gdk_screen_get_n_monitors(screen); + + if (n_monitors > nscreen->n_stacks) + { + /* grow */ + nscreen->stacks = g_renew(NotifyStack *, nscreen->stacks, n_monitors); + + /* add more stacks */ + for (i = nscreen->n_stacks; i < n_monitors; i++) + { + create_stack_for_monitor(daemon, screen, i); + } + + nscreen->n_stacks = n_monitors; + } + else if (n_monitors < nscreen->n_stacks) + { + NotifyStack* last_stack; + + last_stack = nscreen->stacks[n_monitors - 1]; + + /* transfer items before removing stacks */ + for (i = n_monitors; i < nscreen->n_stacks; i++) + { + NotifyStack* stack = nscreen->stacks[i]; + GList* windows = g_list_copy(notify_stack_get_windows(stack)); + GList* l; + + for (l = windows; l != NULL; l = l->next) + { + /* skip removing the window from the old stack since it will try + * to unrealize the window. + * And the stack is going away anyhow. */ + notify_stack_add_window(last_stack, l->data, TRUE); + } + + g_list_free(windows); + notify_stack_destroy(stack); + nscreen->stacks[i] = NULL; + } + + /* remove the extra stacks */ + nscreen->stacks = g_renew(NotifyStack*, nscreen->stacks, n_monitors); + nscreen->n_stacks = n_monitors; + } +} + +static void create_stacks_for_screen(NotifyDaemon* daemon, GdkScreen *screen) +{ + NotifyScreen* nscreen; + int screen_num; + int i; + + screen_num = gdk_screen_get_number(screen); + nscreen = daemon->priv->screens[screen_num]; + + nscreen->n_stacks = gdk_screen_get_n_monitors(screen); + + nscreen->stacks = g_renew(NotifyStack*, nscreen->stacks, nscreen->n_stacks); + + for (i = 0; i < nscreen->n_stacks; i++) + { + create_stack_for_monitor(daemon, screen, i); + } +} + +static GdkFilterReturn screen_xevent_filter(GdkXEvent* xevent, GdkEvent* event, NotifyScreen* nscreen) +{ + XEvent* xev = (XEvent*) xevent; + + if (xev->type == PropertyNotify && xev->xproperty.atom == nscreen->workarea_atom) + { + int i; + + for (i = 0; i < nscreen->n_stacks; i++) + { + notify_stack_queue_update_position(nscreen->stacks[i]); + } + } + + return GDK_FILTER_CONTINUE; +} + +static void create_screens(NotifyDaemon* daemon) +{ + GdkDisplay* display; + int i; + + g_assert(daemon->priv->screens == NULL); + + display = gdk_display_get_default(); + daemon->priv->n_screens = gdk_display_get_n_screens(display); + + daemon->priv->screens = g_new0(NotifyScreen *, daemon->priv->n_screens); + + for (i = 0; i < daemon->priv->n_screens; i++) + { + GdkScreen* screen; + GdkWindow* gdkwindow; + + screen = gdk_display_get_screen(display, i); + g_signal_connect(screen, "monitors-changed", G_CALLBACK(on_screen_monitors_changed), daemon); + + daemon->priv->screens[i] = g_new0(NotifyScreen, 1); + + #if GTK_CHECK_VERSION(3, 0, 0) + daemon->priv->screens[i]->workarea_atom = XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_WORKAREA", True); + #else + daemon->priv->screens[i]->workarea_atom = XInternAtom(GDK_DISPLAY(), "_NET_WORKAREA", True); + #endif + + gdkwindow = gdk_screen_get_root_window(screen); + gdk_window_add_filter(gdkwindow, (GdkFilterFunc) screen_xevent_filter, daemon->priv->screens[i]); + gdk_window_set_events(gdkwindow, gdk_window_get_events(gdkwindow) | GDK_PROPERTY_CHANGE_MASK); + + create_stacks_for_screen(daemon, gdk_display_get_screen(display, i)); + } +} + +static void on_popup_location_changed(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, NotifyDaemon* daemon) +{ + NotifyStackLocation stack_location; + const char* slocation; + MateConfValue* value; + int i; + + value = mateconf_entry_get_value(entry); + slocation = (value != NULL ? mateconf_value_get_string(value) : NULL); + + if (slocation != NULL && *slocation != '\0') + { + stack_location = get_stack_location_from_string(slocation); + } + else + { + mateconf_client_set_string(client, MATECONF_KEY_POPUP_LOCATION, popup_stack_locations[POPUP_STACK_DEFAULT_INDEX].identifier, NULL); + + stack_location = NOTIFY_STACK_LOCATION_DEFAULT; + } + + daemon->priv->stack_location = stack_location; + + for (i = 0; i < daemon->priv->n_screens; i++) + { + int j; + + for (j = 0; j < daemon->priv->n_screens; j++) + { + NotifyStack* stack; + stack = daemon->priv->screens[i]->stacks[j]; + notify_stack_set_location(stack, stack_location); + } + } +} + +static void notify_daemon_init(NotifyDaemon* daemon) +{ + MateConfClient* client; + char* location; + + daemon->priv = G_TYPE_INSTANCE_GET_PRIVATE(daemon, NOTIFY_TYPE_DAEMON, NotifyDaemonPrivate); + + daemon->priv->next_id = 1; + daemon->priv->timeout_source = 0; + + add_exit_timeout(daemon); + + client = mateconf_client_get_default(); + mateconf_client_add_dir(client, MATECONF_KEY_DAEMON, MATECONF_CLIENT_PRELOAD_NONE, NULL); + + location = mateconf_client_get_string(client, MATECONF_KEY_POPUP_LOCATION, NULL); + daemon->priv->stack_location = get_stack_location_from_string(location); + g_free(location); + + daemon->priv->mateconf_cnxn = mateconf_client_notify_add(client, MATECONF_KEY_POPUP_LOCATION, (MateConfClientNotifyFunc) on_popup_location_changed, daemon, NULL, NULL); + g_object_unref(client); + + daemon->priv->n_screens = 0; + daemon->priv->screens = NULL; + + create_screens(daemon); + + daemon->priv->idle_reposition_notify_ids = g_hash_table_new(NULL, NULL); + daemon->priv->monitored_window_hash = g_hash_table_new(NULL, NULL); + daemon->priv->notification_hash = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, (GDestroyNotify) _notify_timeout_destroy); +} + +static void destroy_screens(NotifyDaemon* daemon) +{ + GdkDisplay* display; + int i; + int j; + + display = gdk_display_get_default(); + + for (i = 0; i < daemon->priv->n_screens; i++) + { + GdkScreen* screen; + GdkWindow* gdkwindow; + + screen = gdk_display_get_screen(display, i); + g_signal_handlers_disconnect_by_func(screen, G_CALLBACK(on_screen_monitors_changed), daemon); + + gdkwindow = gdk_screen_get_root_window(screen); + gdk_window_remove_filter(gdkwindow, (GdkFilterFunc) screen_xevent_filter, daemon->priv->screens[i]); + + for (j = 0; i < daemon->priv->screens[i]->n_stacks; j++) + { + notify_stack_destroy(daemon->priv->screens[i]->stacks[j]); + daemon->priv->screens[i]->stacks[j] = NULL; + } + + g_free(daemon->priv->screens[i]->stacks); + } + + g_free(daemon->priv->screens); + daemon->priv->screens = NULL; +} + +static void notify_daemon_finalize(GObject* object) +{ + NotifyDaemon* daemon; + MateConfClient* client; + + daemon = NOTIFY_DAEMON(object); + + client = mateconf_client_get_default(); + mateconf_client_notify_remove(client, daemon->priv->mateconf_cnxn); + g_object_unref(client); + + if (g_hash_table_size(daemon->priv->monitored_window_hash) > 0) + { + gdk_window_remove_filter(NULL, (GdkFilterFunc) _notify_x11_filter, daemon); + } + + remove_exit_timeout(daemon); + + g_hash_table_destroy(daemon->priv->monitored_window_hash); + g_hash_table_destroy(daemon->priv->idle_reposition_notify_ids); + g_hash_table_destroy(daemon->priv->notification_hash); + + destroy_screens(daemon); + + g_free(daemon->priv); + + G_OBJECT_CLASS(notify_daemon_parent_class)->finalize(object); +} + +static NotifyStackLocation get_stack_location_from_string(const char* slocation) +{ + NotifyStackLocation stack_location = NOTIFY_STACK_LOCATION_DEFAULT; + + if (slocation == NULL || *slocation == '\0') + { + return NOTIFY_STACK_LOCATION_DEFAULT; + } + else + { + const PopupNotifyStackLocation* l; + + for (l = popup_stack_locations; l->type != NOTIFY_STACK_LOCATION_UNKNOWN; l++) + { + if (!strcmp(slocation, l->identifier)) + { + stack_location = l->type; + } + } + } + + return stack_location; +} + +static DBusMessage* create_signal(GtkWindow* nw, const char* signal_name) +{ + guint id; + char* dest; + DBusMessage* message; + + id = NW_GET_NOTIFY_ID(nw); + dest = NW_GET_NOTIFY_SENDER(nw); + + g_assert(dest != NULL); + + message = dbus_message_new_signal(NOTIFICATION_BUS_PATH, NOTIFICATION_BUS_NAME, signal_name); + + dbus_message_set_destination(message, dest); + dbus_message_append_args(message, DBUS_TYPE_UINT32, &id, DBUS_TYPE_INVALID); + + return message; +} + +static void _action_invoked_cb(GtkWindow* nw, const char *key) +{ + NotifyDaemon* daemon; + guint id; + DBusMessage* message; + + daemon = NW_GET_DAEMON(nw); + id = NW_GET_NOTIFY_ID(nw); + + message = create_signal(nw, "ActionInvoked"); + dbus_message_append_args(message, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID); + + dbus_connection_send(dbus_conn, message, NULL); + dbus_message_unref(message); + + _close_notification(daemon, id, TRUE, NOTIFYD_CLOSED_USER); +} + +static void _emit_closed_signal(GtkWindow* nw, NotifydClosedReason reason) +{ + DBusMessage* message = create_signal(nw, "NotificationClosed"); + dbus_message_append_args(message, DBUS_TYPE_UINT32, &reason, DBUS_TYPE_INVALID); + dbus_connection_send(dbus_conn, message, NULL); + dbus_message_unref(message); +} + +static void _close_notification(NotifyDaemon* daemon, guint id, gboolean hide_notification, NotifydClosedReason reason) +{ + NotifyDaemonPrivate* priv = daemon->priv; + NotifyTimeout* nt; + + nt = (NotifyTimeout*) g_hash_table_lookup(priv->notification_hash, &id); + + if (nt != NULL) + { + _emit_closed_signal(nt->nw, reason); + + if (hide_notification) + { + theme_hide_notification(nt->nw); + } + + g_hash_table_remove(priv->notification_hash, &id); + + if (g_hash_table_size(daemon->priv->notification_hash) == 0) + { + add_exit_timeout(daemon); + } + } +} + +static gboolean _close_notification_not_shown(_NotifyPendingClose* data) +{ + _close_notification(data->daemon, data->id, TRUE, NOTIFYD_CLOSED_RESERVED); + g_object_unref(data->daemon); + g_free(data); + + return FALSE; +} + +static void _notification_destroyed_cb(GtkWindow* nw, NotifyDaemon* daemon) +{ + /* + * This usually won't happen, but can if notification-daemon dies before + * all notifications are closed. Mark them as expired. + */ + _close_notification(daemon, NW_GET_NOTIFY_ID(nw), FALSE, NOTIFYD_CLOSED_EXPIRED); +} + +typedef struct { + NotifyDaemon* daemon; + gint id; +} IdleRepositionData; + +static gboolean idle_reposition_notification(IdleRepositionData* data) +{ + NotifyDaemon* daemon; + NotifyTimeout* nt; + gint notify_id; + + daemon = data->daemon; + notify_id = data->id; + + /* Look up the timeout, if it's completed we don't need to do anything */ + nt = (NotifyTimeout*) g_hash_table_lookup(daemon->priv->notification_hash, ¬ify_id); + + if (nt != NULL) + { + sync_notification_position(daemon, nt->nw, nt->src_window_xid); + } + + g_hash_table_remove(daemon->priv->idle_reposition_notify_ids, GINT_TO_POINTER(notify_id)); + g_object_unref(daemon); + g_free(data); + + return FALSE; +} + +static void _queue_idle_reposition_notification(NotifyDaemon* daemon, gint notify_id) +{ + IdleRepositionData* data; + gpointer orig_key; + gpointer value; + guint idle_id; + + /* Do we already have an idle update pending? */ + if (g_hash_table_lookup_extended(daemon->priv->idle_reposition_notify_ids, GINT_TO_POINTER(notify_id), &orig_key, &value)) + { + return; + } + + data = g_new0(IdleRepositionData, 1); + data->daemon = g_object_ref(daemon); + data->id = notify_id; + + /* We do this as a short timeout to avoid repositioning spam */ + idle_id = g_timeout_add_full(G_PRIORITY_LOW, 50, (GSourceFunc) idle_reposition_notification, data, NULL); + g_hash_table_insert(daemon->priv->idle_reposition_notify_ids, GINT_TO_POINTER(notify_id), GUINT_TO_POINTER(idle_id)); +} + +static GdkFilterReturn _notify_x11_filter(GdkXEvent* xevent, GdkEvent* event, NotifyDaemon* daemon) +{ + XEvent* xev; + gpointer orig_key; + gpointer value; + gint notify_id; + NotifyTimeout* nt; + + xev = (XEvent*) xevent; + + if (xev->xany.type == DestroyNotify) + { + g_hash_table_remove(daemon->priv->monitored_window_hash, GUINT_TO_POINTER(xev->xany.window)); + + if (g_hash_table_size(daemon->priv->monitored_window_hash) == 0) + { + gdk_window_remove_filter(NULL, (GdkFilterFunc) _notify_x11_filter, daemon); + } + + return GDK_FILTER_CONTINUE; + } + + if (!g_hash_table_lookup_extended(daemon->priv->monitored_window_hash, GUINT_TO_POINTER(xev->xany.window), &orig_key, &value)) + { + return GDK_FILTER_CONTINUE; + } + + notify_id = GPOINTER_TO_INT(value); + + if (xev->xany.type == ConfigureNotify || xev->xany.type == MapNotify) + { + _queue_idle_reposition_notification(daemon, notify_id); + } + else if (xev->xany.type == ReparentNotify) + { + nt = (NotifyTimeout *) g_hash_table_lookup(daemon->priv->notification_hash, ¬ify_id); + + if (nt == NULL) + { + return GDK_FILTER_CONTINUE; + } + + /* + * If the window got reparented, we need to start monitoring the + * new parents. + */ + monitor_notification_source_windows(daemon, nt, nt->src_window_xid); + sync_notification_position(daemon, nt->nw, nt->src_window_xid); + } + + return GDK_FILTER_CONTINUE; +} + +static void _mouse_entered_cb(GtkWindow* nw, GdkEventCrossing* event, NotifyDaemon* daemon) +{ + NotifyTimeout* nt; + guint id; + GTimeVal now; + + if (event->detail == GDK_NOTIFY_INFERIOR) + { + return; + } + + id = NW_GET_NOTIFY_ID(nw); + nt = (NotifyTimeout*) g_hash_table_lookup(daemon->priv->notification_hash, &id); + + nt->paused = TRUE; + g_get_current_time(&now); + + nt->paused_diff.tv_usec = nt->expiration.tv_usec - now.tv_usec; + nt->paused_diff.tv_sec = nt->expiration.tv_sec - now.tv_sec; + + if (nt->paused_diff.tv_usec < 0) + { + nt->paused_diff.tv_usec += G_USEC_PER_SEC; + nt->paused_diff.tv_sec--; + } +} + +static void _mouse_exitted_cb(GtkWindow* nw, GdkEventCrossing* event, NotifyDaemon* daemon) +{ + if (event->detail == GDK_NOTIFY_INFERIOR) + { + return; + } + + guint id = NW_GET_NOTIFY_ID(nw); + NotifyTimeout* nt = (NotifyTimeout*) g_hash_table_lookup(daemon->priv->notification_hash, &id); + + nt->paused = FALSE; +} + +static gboolean _is_expired(gpointer key, NotifyTimeout* nt, gboolean* phas_more_timeouts) +{ + time_t now_time; + time_t expiration_time; + GTimeVal now; + + if (!nt->has_timeout) + { + return FALSE; + } + + g_get_current_time(&now); + + expiration_time = (nt->expiration.tv_sec * 1000) + (nt->expiration.tv_usec / 1000); + now_time = (now.tv_sec * 1000) + (now.tv_usec / 1000); + + if (now_time > expiration_time) + { + theme_notification_tick(nt->nw, 0); + _emit_closed_signal(nt->nw, NOTIFYD_CLOSED_EXPIRED); + return TRUE; + } + else if (nt->paused) + { + nt->expiration.tv_usec = nt->paused_diff.tv_usec + now.tv_usec; + nt->expiration.tv_sec = nt->paused_diff.tv_sec + now.tv_sec; + + if (nt->expiration.tv_usec >= G_USEC_PER_SEC) + { + nt->expiration.tv_usec -= G_USEC_PER_SEC; + nt->expiration.tv_sec++; + } + } + else + { + theme_notification_tick(nt->nw, expiration_time - now_time); + } + + *phas_more_timeouts = TRUE; + + return FALSE; +} + +static gboolean _check_expiration(NotifyDaemon* daemon) +{ + gboolean has_more_timeouts = FALSE; + + g_hash_table_foreach_remove(daemon->priv->notification_hash, (GHRFunc) _is_expired, (gpointer) &has_more_timeouts); + + if (!has_more_timeouts) + { + daemon->priv->timeout_source = 0; + + if (g_hash_table_size (daemon->priv->notification_hash) == 0) + { + add_exit_timeout(daemon); + } + } + + return has_more_timeouts; +} + +static void _calculate_timeout(NotifyDaemon* daemon, NotifyTimeout* nt, int timeout) +{ + if (timeout == 0) + { + nt->has_timeout = FALSE; + } + else + { + nt->has_timeout = TRUE; + + if (timeout == -1) + { + timeout = NOTIFY_DAEMON_DEFAULT_TIMEOUT; + } + + theme_set_notification_timeout(nt->nw, timeout); + + glong usec = timeout * 1000; /* convert from msec to usec */ + + /* + * If it's less than 0, wrap around back to MAXLONG. + * g_time_val_add() requires a glong, and anything larger than + * MAXLONG will be treated as a negative value. + */ + if (usec < 0) + { + usec = G_MAXLONG; + } + + g_get_current_time(&nt->expiration); + g_time_val_add(&nt->expiration, usec); + + if (daemon->priv->timeout_source == 0) + { + daemon->priv->timeout_source = g_timeout_add(100, (GSourceFunc) _check_expiration, daemon); + } + } +} + +static NotifyTimeout* _store_notification(NotifyDaemon* daemon, GtkWindow* nw, int timeout) +{ + NotifyDaemonPrivate* priv = daemon->priv; + NotifyTimeout* nt; + guint id = 0; + + do { + id = priv->next_id; + + if (id != UINT_MAX) + { + priv->next_id++; + } + else + { + priv->next_id = 1; + } + + if (g_hash_table_lookup (priv->notification_hash, &id) != NULL) + { + id = 0; + } + + } while (id == 0); + + nt = g_new0(NotifyTimeout, 1); + nt->id = id; + nt->nw = nw; + nt->daemon = daemon; + + _calculate_timeout(daemon, nt, timeout); + + g_hash_table_insert(priv->notification_hash, g_memdup(&id, sizeof(guint)), nt); + remove_exit_timeout(daemon); + + return nt; +} + +static GdkPixbuf* _notify_daemon_pixbuf_from_data_hint(GValue* icon_data) +{ + const guchar* data = NULL; + gboolean has_alpha; + int bits_per_sample; + int width; + int height; + int rowstride; + int n_channels; + gsize expected_len; + GdkPixbuf* pixbuf; + GValueArray* image_struct; + GValue* value; + GArray* tmp_array; + GType struct_type; + + struct_type = dbus_g_type_get_struct("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_INT, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), G_TYPE_INVALID); + + if (!G_VALUE_HOLDS (icon_data, struct_type)) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected a GValue of type GValueArray"); + return NULL; + } + + image_struct = (GValueArray *) g_value_get_boxed (icon_data); + value = g_value_array_get_nth (image_struct, 0); + + if (value == NULL) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 0 of the GValueArray to exist"); + return NULL; + } + + if (!G_VALUE_HOLDS (value, G_TYPE_INT)) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 0 of the GValueArray to be of type int"); + return NULL; + } + + width = g_value_get_int (value); + value = g_value_array_get_nth (image_struct, 1); + + if (value == NULL) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 1 of the GValueArray to exist"); + return NULL; + } + + if (!G_VALUE_HOLDS (value, G_TYPE_INT)) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 1 of the GValueArray to be of type int"); + return NULL; + } + + height = g_value_get_int (value); + value = g_value_array_get_nth (image_struct, 2); + + if (value == NULL) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 2 of the GValueArray to exist"); + return NULL; + } + + if (!G_VALUE_HOLDS (value, G_TYPE_INT)) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 2 of the GValueArray to be of type int"); + return NULL; + } + + rowstride = g_value_get_int (value); + value = g_value_array_get_nth (image_struct, 3); + + if (value == NULL) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 3 of the GValueArray to exist"); + return NULL; + } + + if (!G_VALUE_HOLDS (value, G_TYPE_BOOLEAN)) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 3 of the GValueArray to be of type gboolean"); + return NULL; + } + + has_alpha = g_value_get_boolean (value); + value = g_value_array_get_nth (image_struct, 4); + + if (value == NULL) { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 4 of the GValueArray to exist"); + return NULL; + } + + if (!G_VALUE_HOLDS (value, G_TYPE_INT)) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 4 of the GValueArray to be of type int"); + return NULL; + } + + bits_per_sample = g_value_get_int (value); + value = g_value_array_get_nth (image_struct, 5); + + if (value == NULL) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 5 of the GValueArray to exist"); + return NULL; + } + + if (!G_VALUE_HOLDS (value, G_TYPE_INT)) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 5 of the GValueArray to be of type int"); + return NULL; + } + + n_channels = g_value_get_int (value); + value = g_value_array_get_nth (image_struct, 6); + + if (value == NULL) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 6 of the GValueArray to exist"); + return NULL; + } + + if (!G_VALUE_HOLDS (value, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR))) + { + g_warning ("_notify_daemon_pixbuf_from_data_hint expected position 6 of the GValueArray to be of type GArray"); + return NULL; + } + + tmp_array = (GArray*) g_value_get_boxed(value); + expected_len = (height - 1) * rowstride + width * ((n_channels * bits_per_sample + 7) / 8); + + if (expected_len != tmp_array->len) + { + g_warning("_notify_daemon_pixbuf_from_data_hint expected image data to be of length %" G_GSIZE_FORMAT " but got a " "length of %u", expected_len, tmp_array->len); + return NULL; + } + + data = (guchar *) g_memdup(tmp_array->data, tmp_array->len); + pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, has_alpha, bits_per_sample, width, height, rowstride, (GdkPixbufDestroyNotify) g_free, NULL); + + return pixbuf; +} + +static GdkPixbuf* _notify_daemon_pixbuf_from_path(const char* path) +{ + GdkPixbuf* pixbuf = NULL; + + if (!strncmp (path, "file://", 7) || *path == '/') + { + if (!strncmp (path, "file://", 7)) + { + path += 7; + } + + /* Load file */ + pixbuf = gdk_pixbuf_new_from_file (path, NULL); + } + else + { + /* Load icon theme icon */ + GtkIconTheme *theme; + GtkIconInfo *icon_info; + + theme = gtk_icon_theme_get_default (); + icon_info = gtk_icon_theme_lookup_icon (theme, path, IMAGE_SIZE, GTK_ICON_LOOKUP_USE_BUILTIN); + + if (icon_info != NULL) + { + gint icon_size; + + icon_size = MIN (IMAGE_SIZE, gtk_icon_info_get_base_size (icon_info)); + + if (icon_size == 0) + { + icon_size = IMAGE_SIZE; + } + + pixbuf = gtk_icon_theme_load_icon (theme, path, icon_size, GTK_ICON_LOOKUP_USE_BUILTIN, NULL); + + gtk_icon_info_free (icon_info); + } + + if (pixbuf == NULL) + { + /* Well... maybe this is a file afterall. */ + pixbuf = gdk_pixbuf_new_from_file (path, NULL); + } + } + + return pixbuf; +} + +static void window_clicked_cb(GtkWindow* nw, GdkEventButton* button, NotifyDaemon* daemon) +{ + if (daemon->priv->url_clicked_lock) + { + daemon->priv->url_clicked_lock = FALSE; + return; + } + + _action_invoked_cb (nw, "default"); + _close_notification (daemon, NW_GET_NOTIFY_ID (nw), TRUE, NOTIFYD_CLOSED_USER); +} + +static void url_clicked_cb(GtkWindow* nw, const char *url) +{ + NotifyDaemon* daemon; + char* escaped_url; + char* cmd = NULL; + + daemon = NW_GET_DAEMON(nw); + + /* Somewhat of a hack.. */ + daemon->priv->url_clicked_lock = TRUE; + + escaped_url = g_shell_quote (url); + + if (g_find_program_in_path ("gvfs-open") != NULL) + { + cmd = g_strdup_printf ("gvfs-open %s", escaped_url); + } + else if (g_find_program_in_path ("xdg-open") != NULL) + { + cmd = g_strdup_printf ("xdg-open %s", escaped_url); + } + else if (g_find_program_in_path ("firefox") != NULL) + { + cmd = g_strdup_printf ("firefox %s", escaped_url); + } + else + { + g_warning ("Unable to find a browser."); + } + + g_free (escaped_url); + + if (cmd != NULL) + { + g_spawn_command_line_async (cmd, NULL); + g_free (cmd); + } +} + +static gboolean screensaver_active(GtkWidget* nw) +{ + GError* error = NULL; + gboolean active = FALSE; + + DBusGConnection* connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + + if (connection == NULL) + { + //g_warning("Failed to get dbus connection: %s", error->message); + g_error_free(error); + goto out; + } + + DBusGProxy* gs_proxy = dbus_g_proxy_new_for_name(connection, "org.mate.ScreenSaver", "/", "org.mate.ScreenSaver"); + + if (!dbus_g_proxy_call(gs_proxy, "GetActive", &error, G_TYPE_INVALID, G_TYPE_BOOLEAN, &active, G_TYPE_INVALID)) + { + //g_warning("Failed to call mate-screensaver: %s", error->message); + g_error_free(error); + } + + g_object_unref(gs_proxy); + + out: + + return active; +} + +static gboolean fullscreen_window_exists(GtkWidget* nw) +{ + WnckScreen* wnck_screen; + WnckWorkspace* wnck_workspace; + GList* l; + + #if (GDK_PIXBUF_MAJOR == 2) && (DK_PIXBUF_MINOR < 22) + wnck_screen = wnck_screen_get(GDK_SCREEN_XNUMBER(gdk_window_get_screen(gtk_widget_get_window(nw)))); + #else + wnck_screen = wnck_screen_get(GDK_SCREEN_XNUMBER(gdk_drawable_get_screen(GDK_DRAWABLE(GTK_WIDGET(nw)->window)))); + #endif + + wnck_screen_force_update (wnck_screen); + + wnck_workspace = wnck_screen_get_active_workspace (wnck_screen); + + for (l = wnck_screen_get_windows_stacked (wnck_screen); l != NULL; l = l->next) + { + WnckWindow *wnck_win = (WnckWindow *) l->data; + + if (wnck_window_is_on_workspace (wnck_win, wnck_workspace) && wnck_window_is_fullscreen (wnck_win) && wnck_window_is_active (wnck_win)) + { + /* + * Sanity check if the window is _really_ fullscreen to + * work around a bug in libwnck that doesn't get all + * unfullscreen events. + */ + int sw = wnck_screen_get_width (wnck_screen); + int sh = wnck_screen_get_height (wnck_screen); + int x, y, w, h; + + wnck_window_get_geometry (wnck_win, &x, &y, &w, &h); + + if (sw == w && sh == h) + { + return TRUE; + } + } + } + + return FALSE; +} + +static Window get_window_parent(Display* display, Window window, Window* root) +{ + Window parent; + Window* children = NULL; + guint nchildren; + gboolean result; + + gdk_error_trap_push(); + result = XQueryTree(display, window, root, &parent, &children, &nchildren); + + if (gdk_error_trap_pop() || !result) + { + return None; + } + + if (children) + { + XFree(children); + } + + return parent; +} + +/* + * Recurse over X Window and parents, up to root, and start watching them + * for position changes. + */ +static void monitor_notification_source_windows(NotifyDaemon *daemon, NotifyTimeout *nt, Window source) +{ + Display* display; + Window root = None; + Window parent; + + display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); + + /* Start monitoring events if necessary. We don't want to + filter events unless we absolutely have to. */ + if (g_hash_table_size (daemon->priv->monitored_window_hash) == 0) + { + gdk_window_add_filter (NULL, (GdkFilterFunc) _notify_x11_filter, daemon); + } + + /* Store the window in the timeout */ + g_assert (nt != NULL); + nt->src_window_xid = source; + + for (parent = get_window_parent (display, source, &root); parent != None && root != parent; parent = get_window_parent (display, parent, &root)) + { + XSelectInput (display, parent, StructureNotifyMask); + + g_hash_table_insert(daemon->priv->monitored_window_hash, GUINT_TO_POINTER (parent), GINT_TO_POINTER (nt->id)); + } +} + +/* Use a source X Window ID to reposition a notification. */ +static void sync_notification_position(NotifyDaemon* daemon, GtkWindow* nw, Window source) +{ + Display* display; + Status result; + Window root; + Window child; + int x, y; + unsigned int width, height; + unsigned int border_width, depth; + + display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default ()); + + gdk_error_trap_push(); + + /* Get the root for this window */ + result = XGetGeometry(display, source, &root, &x, &y, &width, &height, &border_width, &depth); + + if (gdk_error_trap_pop () || !result) + { + return; + } + + /* + * Now calculate the offset coordinates for the source window from + * the root. + */ + gdk_error_trap_push (); + result = XTranslateCoordinates (display, source, root, 0, 0, &x, &y, &child); + if (gdk_error_trap_pop () || !result) + { + return; + } + + x += width / 2; + y += height / 2; + + theme_set_notification_arrow (nw, TRUE, x, y); + theme_move_notification (nw, x, y); + theme_show_notification (nw); + + /* + * We need to manually queue a draw here as the default theme recalculates + * its position in the draw handler and moves the window (which seems + * fairly broken), so just calling move/show above isn't enough to cause + * its position to be calculated. + */ + gtk_widget_queue_draw (GTK_WIDGET (nw)); +} + +GQuark notify_daemon_error_quark(void) +{ + static GQuark q = 0; + + if (q == 0) + { + q = g_quark_from_static_string ("notification-daemon-error-quark"); + } + + return q; +} + +gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const char* app_name, guint id, const char* icon, const char* summary, const char* body, char** actions, GHashTable* hints, int timeout, DBusGMethodInvocation* context) +{ + NotifyDaemonPrivate *priv = daemon->priv; + NotifyTimeout* nt = NULL; + GtkWindow* nw = NULL; + GValue* data; + gboolean use_pos_data = FALSE; + gboolean new_notification = FALSE; + gint x = 0; + gint y = 0; + Window window_xid = None; + guint return_id; + char* sender; + char* sound_file = NULL; + gboolean sound_enabled; + gint i; + GdkPixbuf* pixbuf; + MateConfClient* mateconf_client; + + if (g_hash_table_size (priv->notification_hash) > MAX_NOTIFICATIONS) + { + GError *error; + + error = g_error_new (notify_daemon_error_quark (), 1, _("Exceeded maximum number of notifications")); + dbus_g_method_return_error (context, error); + g_error_free (error); + + return TRUE; + } + + if (id > 0) + { + nt = (NotifyTimeout *) g_hash_table_lookup (priv->notification_hash, &id); + + if (nt != NULL) + { + nw = nt->nw; + } + else + { + id = 0; + } + } + + if (nw == NULL) + { + nw = theme_create_notification (url_clicked_cb); + g_object_set_data (G_OBJECT (nw), "_notify_daemon", daemon); + gtk_widget_realize (GTK_WIDGET (nw)); + new_notification = TRUE; + + g_signal_connect (G_OBJECT (nw), "button-release-event", G_CALLBACK (window_clicked_cb), daemon); + g_signal_connect (G_OBJECT (nw), "destroy", G_CALLBACK (_notification_destroyed_cb), daemon); + g_signal_connect (G_OBJECT (nw), "enter-notify-event", G_CALLBACK (_mouse_entered_cb), daemon); + g_signal_connect (G_OBJECT (nw), "leave-notify-event", G_CALLBACK (_mouse_exitted_cb), daemon); + } + else + { + theme_clear_notification_actions (nw); + } + + theme_set_notification_text (nw, summary, body); + theme_set_notification_hints (nw, hints); + + /* + *XXX This needs to handle file URIs and all that. + */ + + + if ((data = (GValue *) g_hash_table_lookup (hints, "window-xid")) != NULL) + { + window_xid = (Window) g_value_get_uint (data); + } + /* deal with x, and y hints */ + else if ((data = (GValue *) g_hash_table_lookup (hints, "x")) != NULL) + { + x = g_value_get_int (data); + + if ((data = (GValue *) g_hash_table_lookup (hints, "y")) != NULL) + { + y = g_value_get_int (data); + use_pos_data = TRUE; + } + } + + /* Deal with sound hints */ + mateconf_client = mateconf_client_get_default (); + sound_enabled = mateconf_client_get_bool (mateconf_client, MATECONF_KEY_SOUND_ENABLED, NULL); + g_object_unref (mateconf_client); + + data = (GValue *) g_hash_table_lookup (hints, "suppress-sound"); + + if (data != NULL) + { + if (G_VALUE_HOLDS_BOOLEAN (data)) + { + sound_enabled = !g_value_get_boolean (data); + } + else if (G_VALUE_HOLDS_INT (data)) + { + sound_enabled = (g_value_get_int (data) != 0); + } + else + { + g_warning ("suppress-sound is of type %s (expected bool or int)\n", g_type_name (G_VALUE_TYPE (data))); + } + } + + if (sound_enabled) + { + data = (GValue *) g_hash_table_lookup (hints, "sound-file"); + + if (data != NULL) + { + sound_file = g_value_dup_string (data); + + if (*sound_file == '\0' || !g_file_test (sound_file, G_FILE_TEST_EXISTS)) + { + g_free (sound_file); + sound_file = NULL; + } + } + } + + /* set up action buttons */ + for (i = 0; actions[i] != NULL; i += 2) + { + char* l = actions[i + 1]; + + if (l == NULL) + { + g_warning ("Label not found for action %s. The protocol specifies that a label must follow an action in the actions array", actions[i]); + + break; + } + + if (strcasecmp (actions[i], "default")) + { + theme_add_notification_action (nw, l, actions[i], G_CALLBACK (_action_invoked_cb)); + } + } + + pixbuf = NULL; + + if ((data = (GValue *) g_hash_table_lookup (hints, "image_data"))) + { + pixbuf = _notify_daemon_pixbuf_from_data_hint (data); + } + else if ((data = (GValue *) g_hash_table_lookup (hints, "image_path"))) + { + if (G_VALUE_HOLDS_STRING (data)) + { + const char *path = g_value_get_string (data); + pixbuf = _notify_daemon_pixbuf_from_path (path); + } + else + { + g_warning ("notify_daemon_notify_handler expected image_path hint to be of type string"); + } + } + else if (*icon != '\0') + { + pixbuf = _notify_daemon_pixbuf_from_path (icon); + } + else if ((data = (GValue *) g_hash_table_lookup (hints, "icon_data"))) + { + g_warning("\"icon_data\" hint is deprecated, please use \"image_data\" instead"); + pixbuf = _notify_daemon_pixbuf_from_data_hint (data); + } + + if (pixbuf != NULL) + { + theme_set_notification_icon (nw, pixbuf); + g_object_unref (G_OBJECT (pixbuf)); + } + + if (window_xid != None && !theme_get_always_stack (nw)) + { + /* + * Do nothing here if we were passed an XID; we'll call + * sync_notification_position later. + */ + } + else if (use_pos_data && !theme_get_always_stack (nw)) + { + /* + * Typically, the theme engine will set its own position based on + * the arrow X, Y hints. However, in case, move the notification to + * that position. + */ + theme_set_notification_arrow (nw, TRUE, x, y); + theme_move_notification (nw, x, y); + } + else + { + int monitor_num; + int screen_num; + GdkScreen* screen; + gint x, y; + + theme_set_notification_arrow (nw, FALSE, 0, 0); + + gdk_display_get_pointer (gdk_display_get_default (), &screen, &x, &y, NULL); + screen_num = gdk_screen_get_number (screen); + monitor_num = gdk_screen_get_monitor_at_point (screen, x, y); + + if (monitor_num >= priv->screens[screen_num]->n_stacks) + { + /* screw it - dump it on the last one we'll get + a monitors-changed signal soon enough*/ + monitor_num = priv->screens[screen_num]->n_stacks - 1; + } + + notify_stack_add_window (priv->screens[screen_num]->stacks[monitor_num], nw, new_notification); + } + + if (id == 0) + { + nt = _store_notification (daemon, nw, timeout); + return_id = nt->id; + } + else + { + return_id = id; + } + + /* + * If we have a source Window XID, start monitoring the tree + * for changes, and reposition the window based on the source + * window. We need to do this after return_id is calculated. + */ + if (window_xid != None && !theme_get_always_stack (nw)) + { + monitor_notification_source_windows (daemon, nt, window_xid); + sync_notification_position (daemon, nw, window_xid); + } + + if (!screensaver_active (GTK_WIDGET (nw)) && !fullscreen_window_exists (GTK_WIDGET (nw))) + { + theme_show_notification (nw); + + if (sound_file != NULL) + { + sound_play_file (GTK_WIDGET (nw), sound_file); + } + } + else + { + _NotifyPendingClose* data; + + /* The notification was not shown, so queue up a close + * for it */ + data = g_new0 (_NotifyPendingClose, 1); + data->id = id; + data->daemon = g_object_ref (daemon); + g_idle_add ((GSourceFunc) _close_notification_not_shown, data); + } + + g_free (sound_file); + + sender = dbus_g_method_get_sender (context); + + g_object_set_data (G_OBJECT (nw), "_notify_id", GUINT_TO_POINTER (return_id)); + g_object_set_data_full (G_OBJECT (nw), "_notify_sender", sender, (GDestroyNotify) g_free); + + if (nt) + { + _calculate_timeout (daemon, nt, timeout); + } + + dbus_g_method_return (context, return_id); + + return TRUE; +} + +gboolean notify_daemon_close_notification_handler(NotifyDaemon* daemon, guint id, GError** error) +{ + if (id == 0) + { + g_set_error (error, notify_daemon_error_quark (), 100, _("%u is not a valid notification ID"), id); + return FALSE; + } + else + { + _close_notification (daemon, id, TRUE, NOTIFYD_CLOSED_API); + return TRUE; + } +} + +gboolean notify_daemon_get_capabilities(NotifyDaemon* daemon, char*** caps) +{ + GPtrArray* a = g_ptr_array_new (); + g_ptr_array_add (a, g_strdup ("actions")); + g_ptr_array_add (a, g_strdup ("body")); + g_ptr_array_add (a, g_strdup ("body-hyperlinks")); + g_ptr_array_add (a, g_strdup ("body-markup")); + g_ptr_array_add (a, g_strdup ("icon-static")); + g_ptr_array_add (a, g_strdup ("sound")); + g_ptr_array_add (a, NULL); + char** _caps = (char**) g_ptr_array_free (a, FALSE); + + *caps = _caps; + + return TRUE; +} + +gboolean notify_daemon_get_server_information(NotifyDaemon *daemon, char** out_name, char** out_vendor, char** out_version, char** out_spec_ver) +{ + *out_name = g_strdup("Notification Daemon"); + *out_vendor = g_strdup("MATE"); + *out_version = g_strdup(PACKAGE_VERSION); + *out_spec_ver = g_strdup("1.1"); + + return TRUE; +} + +int main(int argc, char** argv) +{ + NotifyDaemon* daemon; + DBusGConnection* connection; + DBusGProxy* bus_proxy; + GError* error; + gboolean res; + guint request_name_result; + + g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL); + + gtk_init(&argc, &argv); + + error = NULL; + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + + if (connection == NULL) + { + g_printerr("Failed to open connection to bus: %s\n", error->message); + g_error_free(error); + exit(1); + } + + dbus_conn = dbus_g_connection_get_connection(connection); + + dbus_g_object_type_install_info(NOTIFY_TYPE_DAEMON, &dbus_glib_notification_daemon_object_info); + + bus_proxy = dbus_g_proxy_new_for_name(connection, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus"); + + res = dbus_g_proxy_call(bus_proxy, "RequestName", &error, G_TYPE_STRING, NOTIFICATION_BUS_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &request_name_result, G_TYPE_INVALID); + + if (! res || request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) + { + if (error != NULL) + { + g_warning("Failed to acquire name %s: %s", NOTIFICATION_BUS_NAME, error->message); + g_error_free(error); + } + else + { + g_warning("Failed to acquire name %s", NOTIFICATION_BUS_NAME); + } + + goto out; + } + + daemon = g_object_new(NOTIFY_TYPE_DAEMON, NULL); + + dbus_g_connection_register_g_object(connection, "/org/freedesktop/Notifications", G_OBJECT(daemon)); + + gtk_main(); + + g_object_unref(daemon); + + out: + + return 0; +} diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h new file mode 100644 index 0000000..7f815c7 --- /dev/null +++ b/src/daemon/daemon.h @@ -0,0 +1,103 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2006 Christian Hammond <[email protected]> + * Copyright (C) 2005 John (J5) Palmieri <[email protected]> + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 NOTIFY_DAEMON_H +#define NOTIFY_DAEMON_H + +#include <mateconf/mateconf-client.h> +#include <glib.h> +#include <glib-object.h> + +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +#define MATECONF_KEY_DAEMON "/apps/mate-notification-daemon" +#define MATECONF_KEY_THEME MATECONF_KEY_DAEMON "/theme" +#define MATECONF_KEY_POPUP_LOCATION MATECONF_KEY_DAEMON "/popup_location" +#define MATECONF_KEY_SOUND_ENABLED MATECONF_KEY_DAEMON "/sound_enabled" +#define MATECONF_KEY_DEFAULT_SOUND MATECONF_KEY_DAEMON "/default_sound" + +#define NOTIFY_TYPE_DAEMON (notify_daemon_get_type()) +#define NOTIFY_DAEMON(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOTIFY_TYPE_DAEMON, NotifyDaemon)) +#define NOTIFY_DAEMON_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), NOTIFY_TYPE_DAEMON, NotifyDaemonClass)) +#define NOTIFY_IS_DAEMON(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOTIFY_TYPE_DAEMON)) +#define NOTIFY_IS_DAEMON_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), NOTIFY_TYPE_DAEMON)) +#define NOTIFY_DAEMON_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NOTIFY_TYPE_DAEMON, NotifyDaemonClass)) + +#define NOTIFY_DAEMON_DEFAULT_TIMEOUT 7000 + +enum { + URGENCY_LOW, + URGENCY_NORMAL, + URGENCY_CRITICAL +}; + +typedef enum { + NOTIFYD_CLOSED_EXPIRED = 1, + NOTIFYD_CLOSED_USER = 2, + NOTIFYD_CLOSED_API = 3, + NOTIFYD_CLOSED_RESERVED = 4 +} NotifydClosedReason; + +typedef struct _NotifyDaemon NotifyDaemon; +typedef struct _NotifyDaemonClass NotifyDaemonClass; +typedef struct _NotifyDaemonPrivate NotifyDaemonPrivate; + +struct _NotifyDaemon { + GObject parent; + + /*< private > */ + NotifyDaemonPrivate* priv; +}; + +struct _NotifyDaemonClass { + GObjectClass parent_class; +}; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +GType notify_daemon_get_type(void); + +GQuark notify_daemon_error_quark(void); + +gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const gchar* app_name, guint id, const gchar* icon, const gchar* summary, const gchar* body, gchar** actions, GHashTable* hints, int timeout, DBusGMethodInvocation* context); + +gboolean notify_daemon_close_notification_handler(NotifyDaemon* daemon, guint id, GError** error); + +gboolean notify_daemon_get_capabilities(NotifyDaemon* daemon, char*** out_caps); + +gboolean notify_daemon_get_server_information(NotifyDaemon* daemon, char** out_name, char** out_vendor, char** out_version, char** out_spec_ver); + +MateConfClient* get_mateconf_client(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* NOTIFY_DAEMON_H */ diff --git a/src/daemon/engines.c b/src/daemon/engines.c new file mode 100644 index 0000000..4426275 --- /dev/null +++ b/src/daemon/engines.c @@ -0,0 +1,338 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2006 Christian Hammond <[email protected]> + * Copyright (C) 2005 John (J5) Palmieri <[email protected]> + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 "config.h" + +#include <mateconf/mateconf-client.h> +#include "daemon.h" +#include "engines.h" + +typedef struct { + GModule* module; + guint ref_count; + + /* callbacks */ + gboolean (*theme_check_init) (unsigned int major_ver, unsigned int minor_ver, unsigned int micro_ver); + void (*get_theme_info) (char** theme_name, char** theme_ver, char** author, char** homepage); + GtkWindow* (*create_notification) (UrlClickedCb url_clicked_cb); + void (*destroy_notification) (GtkWindow* nw); + void (*show_notification) (GtkWindow* nw); + void (*hide_notification) (GtkWindow* nw); + void (*set_notification_hints) (GtkWindow* nw, GHashTable* hints); + void (*set_notification_text) (GtkWindow* nw, const char* summary, const char* body); + void (*set_notification_icon) (GtkWindow* nw, GdkPixbuf* pixbuf); + void (*set_notification_arrow) (GtkWindow* nw, gboolean visible, int x, int y); + void (*add_notification_action) (GtkWindow* nw, const char* label, const char* key, GCallback cb); + void (*clear_notification_actions) (GtkWindow* nw); + void (*move_notification) (GtkWindow* nw, int x, int y); + void (*set_notification_timeout) (GtkWindow* nw, glong timeout); + void (*notification_tick) (GtkWindow* nw, glong timeout); + gboolean (*get_always_stack) (GtkWindow* nw); + +} ThemeEngine; + +static guint theme_prop_notify_id = 0; +static ThemeEngine* active_engine = NULL; + +static ThemeEngine* load_theme_engine(const char *name) +{ + ThemeEngine* engine; + char* filename; + char* path; + + filename = g_strdup_printf("lib%s.so", name); + path = g_build_filename(ENGINES_DIR, filename, NULL); + g_free (filename); + + engine = g_new0(ThemeEngine, 1); + engine->ref_count = 1; + engine->module = g_module_open(path, G_MODULE_BIND_LAZY); + + g_free(path); + + if (engine->module == NULL) + goto error; + + #define BIND_REQUIRED_FUNC(name) \ + if (!g_module_symbol(engine->module, #name, (gpointer*) &engine->name)) \ + { \ + /* Too harsh! Fall back to default. */ \ + g_warning("Theme doesn't provide the required function '%s'", #name); \ + goto error; \ + } + + #define BIND_OPTIONAL_FUNC(name) \ + g_module_symbol(engine->module, #name, (gpointer*) &engine->name); + + BIND_REQUIRED_FUNC(theme_check_init); + BIND_REQUIRED_FUNC(get_theme_info); + BIND_REQUIRED_FUNC(create_notification); + BIND_REQUIRED_FUNC(set_notification_text); + BIND_REQUIRED_FUNC(set_notification_icon); + BIND_REQUIRED_FUNC(set_notification_arrow); + BIND_REQUIRED_FUNC(add_notification_action); + BIND_REQUIRED_FUNC(clear_notification_actions); + BIND_REQUIRED_FUNC(move_notification); + + BIND_OPTIONAL_FUNC(destroy_notification); + BIND_OPTIONAL_FUNC(show_notification); + BIND_OPTIONAL_FUNC(hide_notification); + BIND_OPTIONAL_FUNC(set_notification_timeout); + BIND_OPTIONAL_FUNC(set_notification_hints); + BIND_OPTIONAL_FUNC(notification_tick); + BIND_OPTIONAL_FUNC(get_always_stack); + + if (!engine->theme_check_init(NOTIFICATION_DAEMON_MAJOR_VERSION, NOTIFICATION_DAEMON_MINOR_VERSION, NOTIFICATION_DAEMON_MICRO_VERSION)) + { + g_warning ("Theme doesn't work with this version of mate-notification-daemon"); + goto error; + } + + return engine; + + error: + + if (engine->module != NULL && !g_module_close (engine->module)) + { + g_warning("%s: %s", filename, g_module_error()); + } + + g_free(engine); + return NULL; +} + +static void destroy_engine(ThemeEngine* engine) +{ + g_assert(engine->ref_count == 0); + + if (active_engine == engine) + active_engine = NULL; + + g_module_close(engine->module); + g_free(engine); +} + +static gboolean theme_engine_destroy(ThemeEngine* engine) +{ + destroy_engine(engine); + return FALSE; +} + +static void theme_engine_unref(ThemeEngine* engine) +{ + engine->ref_count--; + + if (engine->ref_count == 0) + { + /* + * Destroy the engine in an idle loop since the last reference + * might have been the one of a notification which is being + * destroyed and that still has references to the engine + * module. This way, we're sure the notification is completely + * destroyed before the engine is. + */ + g_idle_add((GSourceFunc) theme_engine_destroy, engine); + } +} + +static void theme_changed_cb(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, gpointer user_data) +{ + if (active_engine == NULL) + { + return; + } + + theme_engine_unref(active_engine); + + /* This is no longer the true active engine, so reset this. */ + active_engine = NULL; +} + +static ThemeEngine* get_theme_engine(void) +{ + if (active_engine == NULL) + { + MateConfClient* client = mateconf_client_get_default(); + char* enginename = mateconf_client_get_string(client, MATECONF_KEY_THEME, NULL); + + if (theme_prop_notify_id == 0) + { + theme_prop_notify_id = mateconf_client_notify_add(client, MATECONF_KEY_THEME, theme_changed_cb, NULL, NULL, NULL); + } + + g_object_unref(client); + + if (enginename == NULL) + { + active_engine = load_theme_engine("standard"); + g_assert(active_engine != NULL); + } + else + { + active_engine = load_theme_engine(enginename); + + if (active_engine == NULL) + { + g_warning("Unable to load theme engine '%s'", enginename); + active_engine = load_theme_engine("standard"); + } + + g_free(enginename); + + g_assert(active_engine != NULL); + } + } + + return active_engine; +} + +GtkWindow* theme_create_notification(UrlClickedCb url_clicked_cb) +{ + ThemeEngine* engine = get_theme_engine(); + GtkWindow* nw = engine->create_notification(url_clicked_cb); + g_object_set_data_full(G_OBJECT(nw), "_theme_engine", engine, (GDestroyNotify) theme_engine_unref); + engine->ref_count++; + return nw; +} + +void theme_destroy_notification(GtkWindow* nw) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + + if (engine->destroy_notification != NULL) + { + engine->destroy_notification(nw); + } + else + { + gtk_widget_destroy(GTK_WIDGET(nw)); + } +} + +void theme_show_notification(GtkWindow* nw) +{ + ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + + if (engine->show_notification != NULL) + { + engine->show_notification(nw); + } + else + { + gtk_widget_show(GTK_WIDGET(nw)); + } +} + +void theme_hide_notification(GtkWindow* nw) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + + if (engine->hide_notification != NULL) + { + engine->hide_notification(nw); + } + else + { + gtk_widget_hide(GTK_WIDGET(nw)); + } +} + +void theme_set_notification_hints(GtkWindow* nw, GHashTable* hints) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + + if (engine->set_notification_hints != NULL) + { + engine->set_notification_hints(nw, hints); + } +} + +void theme_set_notification_timeout(GtkWindow* nw, glong timeout) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + + if (engine->set_notification_timeout != NULL) + { + engine->set_notification_timeout(nw, timeout); + } +} + +void theme_notification_tick(GtkWindow* nw, glong remaining) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + + if (engine->notification_tick != NULL) + { + engine->notification_tick(nw, remaining); + } +} + +void theme_set_notification_text(GtkWindow* nw, const char* summary, const char* body) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT (nw), "_theme_engine"); + engine->set_notification_text (nw, summary, body); +} + +void theme_set_notification_icon(GtkWindow* nw, GdkPixbuf* pixbuf) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT (nw), "_theme_engine"); + engine->set_notification_icon(nw, pixbuf); +} + +void theme_set_notification_arrow(GtkWindow* nw, gboolean visible, int x, int y) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT (nw), "_theme_engine"); + engine->set_notification_arrow(nw, visible, x, y); +} + +void theme_add_notification_action(GtkWindow* nw, const char* label, const char* key, GCallback cb) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + engine->add_notification_action(nw, label, key, cb); +} + +void theme_clear_notification_actions(GtkWindow* nw) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + engine->clear_notification_actions(nw); +} + +void theme_move_notification(GtkWindow* nw, int x, int y) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + engine->move_notification(nw, x, y); +} + +gboolean theme_get_always_stack(GtkWindow* nw) +{ + ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); + + if (engine->get_always_stack != NULL) + { + return engine->get_always_stack(nw); + } + else + { + return FALSE; + } +} diff --git a/src/daemon/engines.h b/src/daemon/engines.h new file mode 100644 index 0000000..e5ffa49 --- /dev/null +++ b/src/daemon/engines.h @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2006 Christian Hammond <[email protected]> + * Copyright (C) 2005 John (J5) Palmieri <[email protected]> + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 _ENGINES_H_ +#define _ENGINES_H_ + +#include <gtk/gtk.h> + +typedef void (*UrlClickedCb) (GtkWindow * nw, const char *url); + +GtkWindow *theme_create_notification (UrlClickedCb url_clicked_cb); +void theme_destroy_notification (GtkWindow *nw); +void theme_show_notification (GtkWindow *nw); +void theme_hide_notification (GtkWindow *nw); +void theme_set_notification_hints (GtkWindow *nw, + GHashTable *hints); +void theme_set_notification_timeout (GtkWindow *nw, + glong timeout); +void theme_notification_tick (GtkWindow *nw, + glong remaining); +void theme_set_notification_text (GtkWindow *nw, + const char *summary, + const char *body); +void theme_set_notification_icon (GtkWindow *nw, + GdkPixbuf *pixbuf); +void theme_set_notification_arrow (GtkWindow *nw, + gboolean visible, + int x, + int y); +void theme_add_notification_action (GtkWindow *nw, + const char *label, + const char *key, + GCallback cb); +void theme_clear_notification_actions (GtkWindow *nw); +void theme_move_notification (GtkWindow *nw, + int x, + int y); +gboolean theme_get_always_stack (GtkWindow *nw); + +#endif /* _ENGINES_H_ */ diff --git a/src/daemon/notificationdaemon.xml b/src/daemon/notificationdaemon.xml new file mode 100644 index 0000000..e16979f --- /dev/null +++ b/src/daemon/notificationdaemon.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/org/freedesktop/Notifications"> + + <interface name="org.freedesktop.Notifications"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="NotifyDaemon"/> + <method name="Notify"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="notify_daemon_notify_handler"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg type="s" name="app_name" direction="in" /> + <arg type="u" name="id" direction="in" /> + <arg type="s" name="icon" direction="in" /> + <arg type="s" name="summary" direction="in" /> + <arg type="s" name="body" direction="in" /> + <arg type="as" name="actions" direction="in" /> + <arg type="a{sv}" name="hints" direction="in" /> + <arg type="i" name="timeout" direction="in" /> + <arg type="u" name="return_id" direction="out" /> + </method> + + <method name="CloseNotification"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="notify_daemon_close_notification_handler"/> + <arg type="u" name="id" direction="in" /> + </method> + + <method name="GetCapabilities"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="notify_daemon_get_capabilities"/> + <arg type="as" name="return_caps" direction="out"/> + </method> + + <method name="GetServerInformation"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="notify_daemon_get_server_information"/> + <arg type="s" name="return_name" direction="out"/> + <arg type="s" name="return_vendor" direction="out"/> + <arg type="s" name="return_version" direction="out"/> + <arg type="s" name="return_spec_version" direction="out"/> + </method> + + </interface> +</node> diff --git a/src/daemon/sound.c b/src/daemon/sound.c new file mode 100644 index 0000000..6dbf30f --- /dev/null +++ b/src/daemon/sound.c @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2007 Jim Ramsay <[email protected]> + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 "config.h" + +#include "sound.h" + +#include <glib/gi18n.h> +#include <canberra-gtk.h> + +void +sound_play_file (GtkWidget *widget, + const char *filename) +{ + ca_gtk_play_for_widget (widget, 0, + CA_PROP_MEDIA_ROLE, "event", + CA_PROP_MEDIA_FILENAME, filename, + CA_PROP_EVENT_DESCRIPTION, _("Notification"), + NULL); +} + diff --git a/src/daemon/sound.h b/src/daemon/sound.h new file mode 100644 index 0000000..1642382 --- /dev/null +++ b/src/daemon/sound.h @@ -0,0 +1,29 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2007 Jim Ramsay <[email protected]> + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 _SOUND_H +#define _SOUND_H + +#include <gtk/gtk.h> + +void sound_play_file(GtkWidget* widget, const char* filename); + +#endif /* _SOUND_H */ diff --git a/src/daemon/stack.c b/src/daemon/stack.c new file mode 100644 index 0000000..95b50da --- /dev/null +++ b/src/daemon/stack.c @@ -0,0 +1,409 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2006 Christian Hammond <[email protected]> + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 "config.h" +#include "engines.h" +#include "stack.h" + +#include <X11/Xproto.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xatom.h> +#include <gdk/gdkx.h> + +#define NOTIFY_STACK_SPACING 2 +#define WORKAREA_PADDING 6 + +struct _NotifyStack { + NotifyDaemon* daemon; + GdkScreen* screen; + guint monitor; + NotifyStackLocation location; + GList* windows; + guint update_id; +}; + +GList* notify_stack_get_windows(NotifyStack *stack) +{ + return stack->windows; +} + +static gboolean +get_work_area (NotifyStack *stack, + GdkRectangle *rect) +{ + Atom workarea; + Atom type; + Window win; + int format; + gulong num; + gulong leftovers; + gulong max_len = 4 * 32; + guchar *ret_workarea; + long *workareas; + int result; + int disp_screen; + + #if GTK_CHECK_VERSION(3, 0, 0) + workarea = XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_WORKAREA", True); + #else + workarea = XInternAtom(GDK_DISPLAY(), "_NET_WORKAREA", True); + #endif + + + disp_screen = GDK_SCREEN_XNUMBER (stack->screen); + + /* Defaults in case of error */ + rect->x = 0; + rect->y = 0; + rect->width = gdk_screen_get_width (stack->screen); + rect->height = gdk_screen_get_height (stack->screen); + + if (workarea == None) + return FALSE; + + + #if GTK_CHECK_VERSION(3, 0, 0) + + win = XRootWindow(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), disp_screen); + + result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), + win, + workarea, + 0, + max_len, + False, + AnyPropertyType, + &type, + &format, + &num, + &leftovers, + &ret_workarea); + #else + + win = XRootWindow(GDK_DISPLAY(), disp_screen); + + result = XGetWindowProperty(GDK_DISPLAY(), + win, + workarea, + 0, + max_len, + False, + AnyPropertyType, + &type, + &format, + &num, + &leftovers, + &ret_workarea); + #endif + + if (result != Success + || type == None + || format == 0 + || leftovers + || num % 4) { + return FALSE; + } + + workareas = (long *) ret_workarea; + rect->x = workareas[disp_screen * 4]; + rect->y = workareas[disp_screen * 4 + 1]; + rect->width = workareas[disp_screen * 4 + 2]; + rect->height = workareas[disp_screen * 4 + 3]; + + XFree (ret_workarea); + + return TRUE; +} + +static void +get_origin_coordinates (NotifyStackLocation stack_location, + GdkRectangle *workarea, + gint *x, + gint *y, + gint *shiftx, + gint *shifty, + gint width, + gint height) +{ + switch (stack_location) { + case NOTIFY_STACK_LOCATION_TOP_LEFT: + *x = workarea->x; + *y = workarea->y; + *shifty = height; + break; + + case NOTIFY_STACK_LOCATION_TOP_RIGHT: + *x = workarea->x + workarea->width - width; + *y = workarea->y; + *shifty = height; + break; + + case NOTIFY_STACK_LOCATION_BOTTOM_LEFT: + *x = workarea->x; + *y = workarea->y + workarea->height - height; + break; + + case NOTIFY_STACK_LOCATION_BOTTOM_RIGHT: + *x = workarea->x + workarea->width - width; + *y = workarea->y + workarea->height - height; + break; + + default: + g_assert_not_reached (); + } +} + +static void +translate_coordinates (NotifyStackLocation stack_location, + GdkRectangle *workarea, + gint *x, + gint *y, + gint *shiftx, + gint *shifty, + gint width, + gint height) +{ + switch (stack_location) { + case NOTIFY_STACK_LOCATION_TOP_LEFT: + *x = workarea->x; + *y += *shifty; + *shifty = height; + break; + + case NOTIFY_STACK_LOCATION_TOP_RIGHT: + *x = workarea->x + workarea->width - width; + *y += *shifty; + *shifty = height; + break; + + case NOTIFY_STACK_LOCATION_BOTTOM_LEFT: + *x = workarea->x; + *y -= height; + break; + + case NOTIFY_STACK_LOCATION_BOTTOM_RIGHT: + *x = workarea->x + workarea->width - width; + *y -= height; + break; + + default: + g_assert_not_reached (); + } +} + +NotifyStack * +notify_stack_new (NotifyDaemon *daemon, + GdkScreen *screen, + guint monitor, + NotifyStackLocation location) +{ + NotifyStack *stack; + + g_assert (daemon != NULL); + g_assert (screen != NULL && GDK_IS_SCREEN (screen)); + g_assert (monitor < (guint)gdk_screen_get_n_monitors (screen)); + g_assert (location != NOTIFY_STACK_LOCATION_UNKNOWN); + + stack = g_new0 (NotifyStack, 1); + stack->daemon = daemon; + stack->screen = screen; + stack->monitor = monitor; + stack->location = location; + + return stack; +} + +void +notify_stack_destroy (NotifyStack *stack) +{ + g_assert (stack != NULL); + + if (stack->update_id != 0) { + g_source_remove (stack->update_id); + } + + g_list_free (stack->windows); + g_free (stack); +} + +void +notify_stack_set_location (NotifyStack *stack, + NotifyStackLocation location) +{ + stack->location = location; +} + +static void +add_padding_to_rect (GdkRectangle *rect) +{ + rect->x += WORKAREA_PADDING; + rect->y += WORKAREA_PADDING; + rect->width -= WORKAREA_PADDING * 2; + rect->height -= WORKAREA_PADDING * 2; + + if (rect->width < 0) + rect->width = 0; + if (rect->height < 0) + rect->height = 0; +} + +static void +notify_stack_shift_notifications (NotifyStack *stack, + GtkWindow *nw, + GList **nw_l, + gint init_width, + gint init_height, + gint *nw_x, + gint *nw_y) +{ + GdkRectangle workarea; + GdkRectangle monitor; + GdkRectangle *positions; + GList *l; + gint x, y; + gint shiftx = 0; + gint shifty = 0; + int i; + int n_wins; + + get_work_area (stack, &workarea); + gdk_screen_get_monitor_geometry (stack->screen, + stack->monitor, + &monitor); + gdk_rectangle_intersect (&monitor, &workarea, &workarea); + + add_padding_to_rect (&workarea); + + n_wins = g_list_length (stack->windows); + positions = g_new0 (GdkRectangle, n_wins); + + get_origin_coordinates (stack->location, + &workarea, + &x, &y, + &shiftx, + &shifty, + init_width, + init_height); + + if (nw_x != NULL) + *nw_x = x; + + if (nw_y != NULL) + *nw_y = y; + + for (i = 0, l = stack->windows; l != NULL; i++, l = l->next) { + GtkWindow *nw2 = GTK_WINDOW (l->data); + GtkRequisition req; + + if (nw == NULL || nw2 != nw) { + gtk_widget_size_request (GTK_WIDGET (nw2), &req); + + translate_coordinates (stack->location, + &workarea, + &x, + &y, + &shiftx, + &shifty, + req.width, + req.height + NOTIFY_STACK_SPACING); + positions[i].x = x; + positions[i].y = y; + } else if (nw_l != NULL) { + *nw_l = l; + positions[i].x = -1; + positions[i].y = -1; + } + } + + /* move bubbles at the bottom of the stack first + to avoid overlapping */ + for (i = n_wins - 1, l = g_list_last (stack->windows); l != NULL; i--, l = l->prev) { + GtkWindow *nw2 = GTK_WINDOW (l->data); + + if (nw == NULL || nw2 != nw) { + theme_move_notification (nw2, positions[i].x, positions[i].y); + } + } + + g_free (positions); +} + +static void update_position(NotifyStack* stack) +{ + /* notify_stack_shift_notifications(stack, window, list pointer, init width, init height, out window x, out window y) */ + notify_stack_shift_notifications (stack, NULL, NULL, 0, 0, NULL, NULL); +} + +static gboolean update_position_idle(NotifyStack* stack) +{ + update_position(stack); + + stack->update_id = 0; + return FALSE; +} + +void notify_stack_queue_update_position(NotifyStack* stack) +{ + if (stack->update_id != 0) + { + return; + } + + stack->update_id = g_idle_add((GSourceFunc) update_position_idle, stack); +} + +void notify_stack_add_window(NotifyStack* stack, GtkWindow* nw, gboolean new_notification) +{ + GtkRequisition req; + gint x, y; + + gtk_widget_size_request(GTK_WIDGET(nw), &req); + notify_stack_shift_notifications(stack, nw, NULL, req.width, req.height + NOTIFY_STACK_SPACING, &x, &y); + theme_move_notification(nw, x, y); + + if (new_notification) + { + g_signal_connect_swapped(G_OBJECT(nw), "destroy", G_CALLBACK(notify_stack_remove_window), stack); + stack->windows = g_list_prepend(stack->windows, nw); + } +} + +void notify_stack_remove_window(NotifyStack* stack, GtkWindow* nw) +{ + GList* remove_l = NULL; + + notify_stack_shift_notifications(stack, nw, &remove_l, 0, 0, NULL, NULL); + + if (remove_l != NULL) + { + stack->windows = g_list_delete_link(stack->windows, remove_l); + } + + #if GTK_CHECK_VERSION(2, 20, 0) + if (gtk_widget_get_realized(GTK_WIDGET(nw))) + gtk_widget_unrealize(GTK_WIDGET(nw)); + #else + if (GTK_WIDGET_REALIZED(GTK_WIDGET(nw))) + gtk_widget_unrealize(GTK_WIDGET(nw)); + #endif +} diff --git a/src/daemon/stack.h b/src/daemon/stack.h new file mode 100644 index 0000000..b2daafe --- /dev/null +++ b/src/daemon/stack.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2006 Christian Hammond <[email protected]> + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 _NOTIFY_STACK_H_ +#define _NOTIFY_STACK_H_ + +#include <gtk/gtk.h> + +#include "daemon.h" + +typedef enum { + NOTIFY_STACK_LOCATION_UNKNOWN = -1, + NOTIFY_STACK_LOCATION_TOP_LEFT, + NOTIFY_STACK_LOCATION_TOP_RIGHT, + NOTIFY_STACK_LOCATION_BOTTOM_LEFT, + NOTIFY_STACK_LOCATION_BOTTOM_RIGHT, + NOTIFY_STACK_LOCATION_DEFAULT = NOTIFY_STACK_LOCATION_BOTTOM_RIGHT +} NotifyStackLocation; + +typedef struct _NotifyStack NotifyStack; + +NotifyStack* notify_stack_new(NotifyDaemon* daemon, GdkScreen* screen, guint monitor, NotifyStackLocation stack_location); +void notify_stack_destroy(NotifyStack* stack); + +void notify_stack_set_location(NotifyStack* stack, NotifyStackLocation location); +void notify_stack_add_window(NotifyStack* stack, GtkWindow* nw, gboolean new_notification); +void notify_stack_remove_window(NotifyStack* stack, GtkWindow* nw); +GList* notify_stack_get_windows(NotifyStack* stack); +void notify_stack_queue_update_position(NotifyStack* stack); + +#endif /* _NOTIFY_STACK_H_ */ diff --git a/src/themes/Makefile.am b/src/themes/Makefile.am new file mode 100644 index 0000000..90d95d1 --- /dev/null +++ b/src/themes/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = slider standard + +-include $(top_srcdir)/git.mk diff --git a/src/themes/Makefile.in b/src/themes/Makefile.in new file mode 100644 index 0000000..fdd8b25 --- /dev/null +++ b/src/themes/Makefile.in @@ -0,0 +1,616 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/themes +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/macros/intltool.m4 \ + $(top_srcdir)/macros/libtool.m4 \ + $(top_srcdir)/macros/ltoptions.m4 \ + $(top_srcdir)/macros/ltsugar.m4 \ + $(top_srcdir)/macros/ltversion.m4 \ + $(top_srcdir)/macros/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDK_CFLAGS = @GDK_CFLAGS@ +GDK_LIBS = @GDK_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDIR = @LIBDIR@ +LIBEXECDIR = @LIBEXECDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOTIFICATION_CAPPLET_CFLAGS = @NOTIFICATION_CAPPLET_CFLAGS@ +NOTIFICATION_CAPPLET_LIBS = @NOTIFICATION_CAPPLET_LIBS@ +NOTIFICATION_DAEMON_CFLAGS = @NOTIFICATION_DAEMON_CFLAGS@ +NOTIFICATION_DAEMON_LIBS = @NOTIFICATION_DAEMON_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +THEME_CFLAGS = @THEME_CFLAGS@ +THEME_LIBS = @THEME_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ +XGETTEXT = @XGETTEXT@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = slider standard +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/themes/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/themes/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ + install-am install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic clean-libtool \ + ctags ctags-recursive distclean distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am + + +-include $(top_srcdir)/git.mk + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/themes/slider/Makefile.am b/src/themes/slider/Makefile.am new file mode 100644 index 0000000..a94ceaa --- /dev/null +++ b/src/themes/slider/Makefile.am @@ -0,0 +1,15 @@ +NULL = + +enginedir = $(libdir)/mate-notification-daemon/engines +engine_LTLIBRARIES = libslider.la + +AM_CPPFLAGS = $(THEME_CFLAGS) + +libslider_la_SOURCES = theme.c + +libslider_la_LDFLAGS = -module -avoid-version +libslider_la_LIBADD = \ + $(THEME_LIBS) \ + $(NULL) + +-include $(top_srcdir)/git.mk diff --git a/src/themes/slider/Makefile.in b/src/themes/slider/Makefile.in new file mode 100644 index 0000000..bf685a1 --- /dev/null +++ b/src/themes/slider/Makefile.in @@ -0,0 +1,604 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/themes/slider +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/macros/intltool.m4 \ + $(top_srcdir)/macros/libtool.m4 \ + $(top_srcdir)/macros/ltoptions.m4 \ + $(top_srcdir)/macros/ltsugar.m4 \ + $(top_srcdir)/macros/ltversion.m4 \ + $(top_srcdir)/macros/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(enginedir)" +LTLIBRARIES = $(engine_LTLIBRARIES) +am__DEPENDENCIES_1 = +libslider_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_libslider_la_OBJECTS = theme.lo +libslider_la_OBJECTS = $(am_libslider_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +libslider_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libslider_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libslider_la_SOURCES) +DIST_SOURCES = $(libslider_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDK_CFLAGS = @GDK_CFLAGS@ +GDK_LIBS = @GDK_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDIR = @LIBDIR@ +LIBEXECDIR = @LIBEXECDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOTIFICATION_CAPPLET_CFLAGS = @NOTIFICATION_CAPPLET_CFLAGS@ +NOTIFICATION_CAPPLET_LIBS = @NOTIFICATION_CAPPLET_LIBS@ +NOTIFICATION_DAEMON_CFLAGS = @NOTIFICATION_DAEMON_CFLAGS@ +NOTIFICATION_DAEMON_LIBS = @NOTIFICATION_DAEMON_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +THEME_CFLAGS = @THEME_CFLAGS@ +THEME_LIBS = @THEME_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ +XGETTEXT = @XGETTEXT@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +NULL = +enginedir = $(libdir)/mate-notification-daemon/engines +engine_LTLIBRARIES = libslider.la +AM_CPPFLAGS = $(THEME_CFLAGS) +libslider_la_SOURCES = theme.c +libslider_la_LDFLAGS = -module -avoid-version +libslider_la_LIBADD = \ + $(THEME_LIBS) \ + $(NULL) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/themes/slider/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/themes/slider/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-engineLTLIBRARIES: $(engine_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(enginedir)" || $(MKDIR_P) "$(DESTDIR)$(enginedir)" + @list='$(engine_LTLIBRARIES)'; test -n "$(enginedir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(enginedir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(enginedir)"; \ + } + +uninstall-engineLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(engine_LTLIBRARIES)'; test -n "$(enginedir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(enginedir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(enginedir)/$$f"; \ + done + +clean-engineLTLIBRARIES: + -test -z "$(engine_LTLIBRARIES)" || rm -f $(engine_LTLIBRARIES) + @list='$(engine_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libslider.la: $(libslider_la_OBJECTS) $(libslider_la_DEPENDENCIES) + $(AM_V_CCLD)$(libslider_la_LINK) -rpath $(enginedir) $(libslider_la_OBJECTS) $(libslider_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/theme.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(enginedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-engineLTLIBRARIES clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-engineLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-engineLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-engineLTLIBRARIES clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am \ + install-engineLTLIBRARIES install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-engineLTLIBRARIES + + +-include $(top_srcdir)/git.mk + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/themes/slider/theme.c b/src/themes/slider/theme.c new file mode 100644 index 0000000..b147134 --- /dev/null +++ b/src/themes/slider/theme.c @@ -0,0 +1,914 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2006-2007 Christian Hammond <[email protected]> + * Copyright (C) 2009 Red Hat, Inc. + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 "config.h" + +#include <gtk/gtk.h> + +typedef void (*ActionInvokedCb) (GtkWindow* nw, const char* key); +typedef void (*UrlClickedCb) (GtkWindow* nw, const char* url); + +typedef struct { + GtkWidget* win; + GtkWidget* main_hbox; + GtkWidget* iconbox; + GtkWidget* icon; + GtkWidget* content_hbox; + GtkWidget* summary_label; + GtkWidget* close_button; + GtkWidget* body_label; + GtkWidget* actions_box; + GtkWidget* last_sep; + GtkWidget* pie_countdown; + + gboolean has_arrow; + gboolean composited; + + int width; + int height; + int last_width; + int last_height; + + guchar urgency; + glong timeout; + glong remaining; + + UrlClickedCb url_clicked; +} WindowData; + +enum { + URGENCY_LOW, + URGENCY_NORMAL, + URGENCY_CRITICAL +}; + +#define WIDTH 400 +#define DEFAULT_X0 0 +#define DEFAULT_Y0 0 +#define DEFAULT_RADIUS 8 +#define IMAGE_SIZE 48 +#define PIE_RADIUS 8 +#define PIE_WIDTH (2 * PIE_RADIUS) +#define PIE_HEIGHT (2 * PIE_RADIUS) +#define BODY_X_OFFSET (IMAGE_SIZE + 4) +#define BACKGROUND_ALPHA 0.90 + +#define MAX_ICON_SIZE IMAGE_SIZE + +#define USE_COMPOSITE + +static void draw_round_rect(cairo_t* cr, gdouble aspect, gdouble x, gdouble y, gdouble corner_radius, gdouble width, gdouble height) +{ + gdouble radius = corner_radius / aspect; + + cairo_move_to(cr, x + radius, y); + + // top-right, left of the corner + cairo_line_to(cr, x + width - radius, y); + + // top-right, below the corner + cairo_arc(cr, x + width - radius, y + radius, radius, -90.0f * G_PI / 180.0f, 0.0f * G_PI / 180.0f); + + // bottom-right, above the corner + cairo_line_to(cr, x + width, y + height - radius); + + // bottom-right, left of the corner + cairo_arc(cr, x + width - radius, y + height - radius, radius, 0.0f * G_PI / 180.0f, 90.0f * G_PI / 180.0f); + + // bottom-left, right of the corner + cairo_line_to(cr, x + radius, y + height); + + // bottom-left, above the corner + cairo_arc(cr, x + radius, y + height - radius, radius, 90.0f * G_PI / 180.0f, 180.0f * G_PI / 180.0f); + + // top-left, below the corner + cairo_line_to(cr, x, y + radius); + + // top-left, right of the corner + cairo_arc(cr, x + radius, y + radius, radius, 180.0f * G_PI / 180.0f, 270.0f * G_PI / 180.0f); +} + +static void fill_background(GtkWidget* widget, WindowData* windata, cairo_t* cr) +{ + GdkColor color; + double r, g, b; + + #if GTK_CHECK_VERSION(3, 0, 0) + + GtkAllocation allocation; + + gtk_widget_get_allocation(widget, &allocation); + + draw_round_rect(cr, 1.0f, DEFAULT_X0 + 1, DEFAULT_Y0 + 1, DEFAULT_RADIUS, allocation.width - 2, allocation.height - 2); + + //GdkRGBA color; + + //gtk_style_context_get_background_color(); + color = widget->style->bg[GTK_STATE_NORMAL]; + r = (float) color.red / 65535.0; + g = (float) color.green / 65535.0; + b = (float) color.blue / 65535.0; + cairo_set_source_rgba(cr, r, g, b, BACKGROUND_ALPHA); + cairo_fill_preserve(cr); + + /* Should we show urgency somehow? Probably doesn't + * have any meaningful value to the user... */ + + color = widget->style->text_aa[GTK_STATE_NORMAL]; + r = (float) color.red / 65535.0; + g = (float) color.green / 65535.0; + b = (float) color.blue / 65535.0; + cairo_set_source_rgba(cr, r, g, b, BACKGROUND_ALPHA / 2); + cairo_set_line_width(cr, 1); + cairo_stroke(cr); + + #else + + draw_round_rect(cr, 1.0f, DEFAULT_X0 + 1, DEFAULT_Y0 + 1, DEFAULT_RADIUS, widget->allocation.width - 2, widget->allocation.height - 2); + + color = widget->style->bg[GTK_STATE_NORMAL]; + r = (float) color.red / 65535.0; + g = (float) color.green / 65535.0; + b = (float) color.blue / 65535.0; + cairo_set_source_rgba(cr, r, g, b, BACKGROUND_ALPHA); + cairo_fill_preserve(cr); + + /* Should we show urgency somehow? Probably doesn't + * have any meaningful value to the user... */ + + color = widget->style->text_aa[GTK_STATE_NORMAL]; + r = (float) color.red / 65535.0; + g = (float) color.green / 65535.0; + b = (float) color.blue / 65535.0; + cairo_set_source_rgba(cr, r, g, b, BACKGROUND_ALPHA / 2); + cairo_set_line_width(cr, 1); + cairo_stroke(cr); + #endif +} + +static void update_shape(WindowData* windata) +{ + GdkBitmap* mask; + cairo_t* cr; + + if (windata->width == windata->last_width && windata->height == windata->last_height) + { + return; + } + + if (windata->width == 0 || windata->height == 0) + { + #if GTK_CHECK_VERSION(3, 0, 0) + + GtkAllocation allocation; + + gtk_widget_get_allocation(windata->win, &allocation); + + windata->width = MAX(allocation.width, 1); + windata->height = MAX(allocation.height, 1); + #else + windata->width = MAX(windata->win->allocation.width, 1); + windata->height = MAX(windata->win->allocation.height, 1); + #endif + } + + if (windata->composited) + { + gtk_widget_shape_combine_mask(windata->win, NULL, 0, 0); + return; + } + + windata->last_width = windata->width; + windata->last_height = windata->height; + mask = (GdkBitmap*) gdk_pixmap_new(NULL, windata->width, windata->height, 1); + + if (mask == NULL) + { + return; + } + + cr = gdk_cairo_create(mask); + + if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) + { + cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); + cairo_paint(cr); + + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgb(cr, 1.0f, 1.0f, 1.0f); + draw_round_rect(cr, 1.0f, DEFAULT_X0, DEFAULT_Y0, DEFAULT_RADIUS, windata->width, windata->height); + cairo_fill(cr); + + gtk_widget_shape_combine_mask(windata->win, mask, 0, 0); + } + cairo_destroy(cr); + + g_object_unref(mask); +} + +static void paint_window(GtkWidget* widget, WindowData* windata) +{ + cairo_t* context; + cairo_surface_t* surface; + cairo_t* cr; + + if (windata->width == 0 || windata->height == 0) + { + #if GTK_CHECK_VERSION(3, 0, 0) + + GtkAllocation allocation; + + gtk_widget_get_allocation(windata->win, &allocation); + + windata->width = MAX(allocation.width, 1); + windata->height = MAX(allocation.height, 1); + #else + windata->width = MAX(windata->win->allocation.width, 1); + windata->height = MAX(windata->win->allocation.height, 1); + #endif + } + + context = gdk_cairo_create(widget->window); + + cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); + + + #if GTK_CHECK_VERSION(3, 0, 0) + + GtkAllocation allocation; + + gtk_widget_get_allocation(widget, &allocation); + + surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height); + #else + + surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, widget->allocation.width, widget->allocation.height); + #endif + + cr = cairo_create(surface); + + fill_background(widget, windata, cr); + + cairo_destroy(cr); + cairo_set_source_surface(context, surface, 0, 0); + cairo_paint(context); + cairo_surface_destroy(surface); + cairo_destroy(context); + + update_shape(windata); +} + +static gboolean on_window_map(GtkWidget* widget, GdkEvent* event, WindowData* windata) +{ + return FALSE; +} + +static gboolean on_window_expose(GtkWidget* widget, GdkEventExpose* event, WindowData* windata) +{ + paint_window(widget, windata); + + return FALSE; +} + +static void destroy_windata(WindowData* windata) +{ + g_free(windata); +} + +static void update_content_hbox_visibility(WindowData* windata) +{ + if (GTK_WIDGET_VISIBLE(windata->icon) || GTK_WIDGET_VISIBLE(windata->body_label) || GTK_WIDGET_VISIBLE(windata->actions_box)) + { + gtk_widget_show(windata->content_hbox); + } + else + { + gtk_widget_hide(windata->content_hbox); + } +} + +static gboolean on_configure_event(GtkWidget* widget, GdkEventConfigure* event, WindowData* windata) +{ + windata->width = event->width; + windata->height = event->height; + + gtk_widget_queue_draw(widget); + + return FALSE; +} + +static void on_window_realize(GtkWidget* widget, WindowData* windata) +{ + /* Nothing */ +} + +static void color_reverse(const GdkColor* a, GdkColor* b) +{ + gdouble red; + gdouble green; + gdouble blue; + gdouble h; + gdouble s; + gdouble v; + + red = (gdouble) a->red / 65535.0; + green = (gdouble) a->green / 65535.0; + blue = (gdouble) a->blue / 65535.0; + + gtk_rgb_to_hsv(red, green, blue, &h, &s, &v); + + /* pivot brightness around the center */ + v = 0.5 + (0.5 - v); + + if (v > 1.0) + { + v = 1.0; + } + else if (v < 0.0) + { + v = 0.0; + } + + /* reduce saturation by 50% */ + s *= 0.5; + + gtk_hsv_to_rgb(h, s, v, &red, &green, &blue); + + b->red = red * 65535.0; + b->green = green * 65535.0; + b->blue = blue * 65535.0; +} + +static void override_style(GtkWidget* widget, GtkStyle* previous_style) +{ + GtkStateType state; + GtkStyle* style; + GdkColor fg; + GdkColor bg; + + style = gtk_style_copy(widget->style); + + if (previous_style == NULL || (previous_style != NULL && (previous_style->bg[GTK_STATE_NORMAL].red != style->bg[GTK_STATE_NORMAL].red || previous_style->bg[GTK_STATE_NORMAL].green != style->bg[GTK_STATE_NORMAL].green || previous_style->bg[GTK_STATE_NORMAL].blue != style->bg[GTK_STATE_NORMAL].blue))) + { + state = (GtkStateType) 0; + + while (state < (GtkStateType) G_N_ELEMENTS(widget->style->bg)) + { + color_reverse(&style->bg[state], &bg); + gtk_widget_modify_bg(widget, state, &bg); + state++; + } + } + + if (previous_style == NULL || (previous_style != NULL && (previous_style->fg[GTK_STATE_NORMAL].red != style->fg[GTK_STATE_NORMAL].red || previous_style->fg[GTK_STATE_NORMAL].green != style->fg[GTK_STATE_NORMAL].green || previous_style->fg[GTK_STATE_NORMAL].blue != style->fg[GTK_STATE_NORMAL].blue))) + { + state = (GtkStateType) 0; + + while (state < (GtkStateType) G_N_ELEMENTS(widget->style->fg)) + { + color_reverse(&style->fg[state], &fg); + gtk_widget_modify_fg(widget, state, &fg); + state++; + } + } + + g_object_unref(style); +} + +static void on_style_set(GtkWidget* widget, GtkStyle* previous_style, WindowData* windata) +{ + g_signal_handlers_block_by_func(G_OBJECT(widget), on_style_set, windata); + override_style(widget, previous_style); + + gtk_widget_queue_draw(widget); + + g_signal_handlers_unblock_by_func(G_OBJECT(widget), on_style_set, windata); +} + +static void on_composited_changed(GtkWidget* window, WindowData* windata) +{ + windata->composited = gdk_screen_is_composited(gtk_widget_get_screen(window)); + update_shape(windata); +} + +GtkWindow* create_notification(UrlClickedCb url_clicked) +{ + GtkWidget* win; + GtkWidget* main_vbox; + GtkWidget* vbox; + GtkWidget* close_button; + GtkWidget* image; + GtkWidget* alignment; + AtkObject* atkobj; + GtkRcStyle* rcstyle; + WindowData* windata; + #ifdef USE_COMPOSITE + GdkColormap* colormap; + GdkScreen* screen; + #endif + + windata = g_new0(WindowData, 1); + windata->urgency = URGENCY_NORMAL; + windata->url_clicked = url_clicked; + + win = gtk_window_new(GTK_WINDOW_POPUP); + gtk_window_set_resizable(GTK_WINDOW(win), FALSE); + gtk_widget_set_app_paintable(win, TRUE); + g_signal_connect(G_OBJECT(win), "style-set", G_CALLBACK(on_style_set), windata); + g_signal_connect(G_OBJECT(win), "map-event", G_CALLBACK(on_window_map), windata); + g_signal_connect(G_OBJECT(win), "expose-event", G_CALLBACK(on_window_expose), windata); + g_signal_connect(G_OBJECT(win), "realize", G_CALLBACK(on_window_realize), windata); + + windata->win = win; + + windata->composited = FALSE; + + #ifdef USE_COMPOSITE + screen = gtk_window_get_screen(GTK_WINDOW(win)); + colormap = gdk_screen_get_rgba_colormap(screen); + + if (colormap != NULL) + { + gtk_widget_set_colormap(win, colormap); + + if (gdk_screen_is_composited(screen)) + { + windata->composited = TRUE; + } + } + + g_signal_connect(win, "composited-changed", G_CALLBACK(on_composited_changed), windata); + #endif + + gtk_window_set_title(GTK_WINDOW(win), "Notification"); + gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_NOTIFICATION); + gtk_widget_add_events(win, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); + + g_object_set_data_full(G_OBJECT(win), "windata", windata, (GDestroyNotify) destroy_windata); + atk_object_set_role(gtk_widget_get_accessible(win), ATK_ROLE_ALERT); + + g_signal_connect(G_OBJECT(win), "configure-event", G_CALLBACK(on_configure_event), windata); + + main_vbox = gtk_vbox_new(FALSE, 0); + g_signal_connect(G_OBJECT(main_vbox), "style-set", G_CALLBACK(on_style_set), windata); + gtk_widget_show(main_vbox); + gtk_container_add(GTK_CONTAINER(win), main_vbox); + gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 12); + + windata->main_hbox = gtk_hbox_new(FALSE, 0); + gtk_widget_show(windata->main_hbox); + gtk_box_pack_start(GTK_BOX(main_vbox), windata->main_hbox, FALSE, FALSE, 0); + + /* First row (icon, vbox, close) */ + windata->iconbox = gtk_alignment_new(0.5, 0, 0, 0); + gtk_widget_show(windata->iconbox); + gtk_alignment_set_padding(GTK_ALIGNMENT(windata->iconbox), 5, 0, 0, 0); + gtk_box_pack_start(GTK_BOX(windata->main_hbox), windata->iconbox, FALSE, FALSE, 0); + gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1); + + windata->icon = gtk_image_new(); + gtk_widget_show(windata->icon); + gtk_container_add(GTK_CONTAINER(windata->iconbox), windata->icon); + + vbox = gtk_vbox_new(FALSE, 6); + gtk_widget_show(vbox); + gtk_box_pack_start(GTK_BOX(windata->main_hbox), vbox, TRUE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); + + /* Add the close button */ + alignment = gtk_alignment_new(0.5, 0, 0, 0); + gtk_widget_show(alignment); + gtk_box_pack_start(GTK_BOX(windata->main_hbox), alignment, FALSE, FALSE, 0); + + close_button = gtk_button_new(); + g_signal_connect(G_OBJECT(close_button), "style-set", G_CALLBACK(on_style_set), windata); + gtk_widget_show(close_button); + windata->close_button = close_button; + gtk_container_add(GTK_CONTAINER(alignment), close_button); + gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); + gtk_container_set_border_width(GTK_CONTAINER(close_button), 0); + g_signal_connect_swapped(G_OBJECT(close_button), "clicked", G_CALLBACK(gtk_widget_destroy), win); + + rcstyle = gtk_rc_style_new(); + rcstyle->xthickness = rcstyle->ythickness = 0; + gtk_widget_modify_style(close_button, rcstyle); + g_object_unref(rcstyle); + + atkobj = gtk_widget_get_accessible(close_button); + atk_action_set_description(ATK_ACTION(atkobj), 0, "Closes the notification."); + atk_object_set_name(atkobj, ""); + atk_object_set_description(atkobj, "Closes the notification."); + + image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); + gtk_widget_show(image); + gtk_container_add(GTK_CONTAINER(close_button), image); + + /* center vbox */ + windata->summary_label = gtk_label_new(NULL); + g_signal_connect(G_OBJECT(windata->summary_label), "style-set", G_CALLBACK(on_style_set), windata); + gtk_widget_show(windata->summary_label); + gtk_box_pack_start(GTK_BOX(vbox), windata->summary_label, TRUE, TRUE, 0); + gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0); + gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE); + + atkobj = gtk_widget_get_accessible(windata->summary_label); + atk_object_set_description(atkobj, "Notification summary text."); + + windata->content_hbox = gtk_hbox_new(FALSE, 6); + gtk_widget_show(windata->content_hbox); + gtk_box_pack_start(GTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0); + + + vbox = gtk_vbox_new(FALSE, 6); + gtk_widget_show(vbox); + gtk_box_pack_start(GTK_BOX(windata->content_hbox), vbox, TRUE, TRUE, 0); + + windata->body_label = gtk_label_new(NULL); + g_signal_connect(G_OBJECT(windata->body_label), "style-set", G_CALLBACK(on_style_set), windata); + gtk_widget_show(windata->body_label); + gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0); + gtk_misc_set_alignment(GTK_MISC(windata->body_label), 0, 0); + gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE); + g_signal_connect_swapped(G_OBJECT(windata->body_label), "activate-link", G_CALLBACK(windata->url_clicked), win); + + atkobj = gtk_widget_get_accessible(windata->body_label); + atk_object_set_description(atkobj, "Notification body text."); + + alignment = gtk_alignment_new(1, 0.5, 0, 0); + gtk_widget_show(alignment); + gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0); + + windata->actions_box = gtk_hbox_new(FALSE, 6); + gtk_widget_show(windata->actions_box); + gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box); + + return GTK_WINDOW(win); +} + +void set_notification_hints(GtkWindow* nw, GHashTable* hints) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + GValue* value = (GValue*) g_hash_table_lookup(hints, "urgency"); + + if (value != NULL && G_VALUE_HOLDS_UCHAR(value)) + { + windata->urgency = g_value_get_uchar(value); + + if (windata->urgency == URGENCY_CRITICAL) + { + gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification"); + } + else + { + gtk_window_set_title(GTK_WINDOW(nw), "Notification"); + } + } +} + +void set_notification_timeout(GtkWindow *nw, glong timeout) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + windata->timeout = timeout; +} + +void notification_tick(GtkWindow* nw, glong remaining) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + windata->remaining = remaining; + + if (windata->pie_countdown != NULL) + { + gtk_widget_queue_draw_area(windata->pie_countdown, 0, 0, PIE_WIDTH, PIE_HEIGHT); + } +} + +void set_notification_text(GtkWindow* nw, const char* summary, const char* body) +{ + char* str; + char* quoted; + GtkRequisition req; + WindowData* windata; + int summary_width; + + windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + quoted = g_markup_escape_text(summary, -1); + str = g_strdup_printf("<b><big>%s</big></b>", quoted); + g_free(quoted); + + gtk_label_set_markup(GTK_LABEL(windata->summary_label), str); + g_free(str); + + gtk_label_set_markup(GTK_LABEL(windata->body_label), body); + + if (body == NULL || *body == '\0') + { + gtk_widget_hide(windata->body_label); + } + else + { + gtk_widget_show(windata->body_label); + } + + update_content_hbox_visibility(windata); + + gtk_widget_size_request(windata->close_button, &req); + /* -1: main_vbox border width + -10: vbox border width + -6: spacing for hbox */ + summary_width = WIDTH - (1 * 2) - (10 * 2) - BODY_X_OFFSET - req.width - (6 * 2); + + if (body != NULL && *body != '\0') + { + gtk_widget_set_size_request(windata->body_label, summary_width, -1); + } + + gtk_widget_set_size_request(windata->summary_label, summary_width, -1); +} + +static GdkPixbuf* scale_pixbuf(GdkPixbuf* pixbuf, int max_width, int max_height, gboolean no_stretch_hint) +{ + float scale_factor_x = 1.0; + float scale_factor_y = 1.0; + float scale_factor = 1.0; + + int pw = gdk_pixbuf_get_width(pixbuf); + int ph = gdk_pixbuf_get_height(pixbuf); + + /* Determine which dimension requires the smallest scale. */ + scale_factor_x = (float) max_width / (float) pw; + scale_factor_y = (float) max_height / (float) ph; + + if (scale_factor_x > scale_factor_y) + { + scale_factor = scale_factor_y; + } + else + { + scale_factor = scale_factor_x; + } + + /* always scale down, allow to disable scaling up */ + if (scale_factor < 1.0 || !no_stretch_hint) + { + int scale_x; + int scale_y; + + scale_x = (int) (pw * scale_factor); + scale_y = (int) (ph * scale_factor); + + return gdk_pixbuf_scale_simple(pixbuf, scale_x, scale_y, GDK_INTERP_BILINEAR); + } + else + { + return g_object_ref(pixbuf); + } +} + +void set_notification_icon(GtkWindow* nw, GdkPixbuf* pixbuf) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + GdkPixbuf* scaled = NULL; + + if (pixbuf != NULL) + { + scaled = scale_pixbuf(pixbuf, MAX_ICON_SIZE, MAX_ICON_SIZE, TRUE); + } + + gtk_image_set_from_pixbuf(GTK_IMAGE(windata->icon), scaled); + + if (scaled != NULL) + { + int pixbuf_width = gdk_pixbuf_get_width(scaled); + + gtk_widget_show(windata->icon); + gtk_widget_set_size_request(windata->iconbox, MAX(BODY_X_OFFSET, pixbuf_width), -1); + g_object_unref(scaled); + } + else + { + gtk_widget_hide(windata->icon); + + gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1); + } + + update_content_hbox_visibility(windata); +} + +void set_notification_arrow(GtkWidget* nw, gboolean visible, int x, int y) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); +} + +static gboolean on_countdown_expose(GtkWidget* pie, GdkEventExpose* event, WindowData* windata) +{ + GtkStyle* style; + cairo_t* context; + cairo_surface_t* surface; + cairo_t* cr; + GdkColor color; + double r, g, b; + + style = gtk_widget_get_style(windata->win); + + #if GTK_CHECK_VERSION(3, 0, 0) + context = gdk_cairo_create(GDK_WINDOW(windata->pie_countdown->window)); + #else + context = gdk_cairo_create(GDK_DRAWABLE(windata->pie_countdown->window)); + #endif + + cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); + + + #if GTK_CHECK_VERSION(3, 0, 0) + + GtkAllocation allocation; + + gtk_widget_get_allocation(pie, &allocation); + + surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height); + + #else + + surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, pie->allocation.width, pie->allocation.height); + + #endif + + cr = cairo_create(surface); + + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + color = windata->win->style->bg[GTK_STATE_NORMAL]; + r = (float) color.red / 65535.0; + g = (float) color.green / 65535.0; + b = (float) color.blue / 65535.0; + cairo_set_source_rgba(cr, r, g, b, BACKGROUND_ALPHA); + cairo_paint(cr); + + if (windata->timeout > 0) + { + gdouble pct = (gdouble) windata->remaining / (gdouble) windata->timeout; + + gdk_cairo_set_source_color(cr, &style->fg[GTK_STATE_NORMAL]); + + cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS); + cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS, -G_PI_2, -(pct * G_PI * 2) - G_PI_2); + cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS); + cairo_fill(cr); + } + + cairo_destroy(cr); + cairo_set_source_surface(context, surface, 0, 0); + cairo_paint(context); + cairo_surface_destroy(surface); + cairo_destroy(context); + + return TRUE; +} + +static void on_action_clicked(GtkWidget* w, GdkEventButton *event, ActionInvokedCb action_cb) +{ + GtkWindow* nw = g_object_get_data(G_OBJECT(w), "_nw"); + const char* key = g_object_get_data(G_OBJECT(w), "_action_key"); + + action_cb(nw, key); +} + +void add_notification_action(GtkWindow* nw, const char* text, const char* key, ActionInvokedCb cb) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + GtkWidget* label; + GtkWidget* button; + GtkWidget* hbox; + GdkPixbuf* pixbuf; + char* buf; + + g_assert(windata != NULL); + + if (!GTK_WIDGET_VISIBLE(windata->actions_box)) + { + GtkWidget* alignment; + + gtk_widget_show(windata->actions_box); + update_content_hbox_visibility(windata); + + alignment = gtk_alignment_new(1, 0.5, 0, 0); + gtk_widget_show(alignment); + gtk_box_pack_end(GTK_BOX(windata->actions_box), alignment, FALSE, TRUE, 0); + + windata->pie_countdown = gtk_drawing_area_new(); + g_signal_connect(G_OBJECT(windata->pie_countdown), "style-set", G_CALLBACK(on_style_set), windata); + + gtk_widget_show(windata->pie_countdown); + gtk_container_add(GTK_CONTAINER(alignment), windata->pie_countdown); + gtk_widget_set_size_request(windata->pie_countdown, PIE_WIDTH, PIE_HEIGHT); + g_signal_connect(G_OBJECT(windata->pie_countdown), "expose_event", G_CALLBACK(on_countdown_expose), windata); + } + + button = gtk_button_new(); + g_signal_connect(G_OBJECT(button), "style-set", G_CALLBACK(on_style_set), windata); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(windata->actions_box), button, FALSE, FALSE, 0); + gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_container_set_border_width(GTK_CONTAINER(button), 0); + + hbox = gtk_hbox_new(FALSE, 6); + gtk_widget_show(hbox); + gtk_container_add(GTK_CONTAINER(button), hbox); + + /* Try to be smart and find a suitable icon. */ + buf = g_strdup_printf("stock_%s", key); + pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_for_screen(gdk_drawable_get_screen(GTK_WIDGET(nw)->window)), buf, 16, GTK_ICON_LOOKUP_USE_BUILTIN, NULL); + g_free(buf); + + if (pixbuf != NULL) + { + GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf); + g_signal_connect(G_OBJECT(image), "style-set", G_CALLBACK(on_style_set), windata); + gtk_widget_show(image); + gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); + gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.5); + } + + label = gtk_label_new(NULL); + g_signal_connect(G_OBJECT(label), "style-set", G_CALLBACK(on_style_set), windata); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + buf = g_strdup_printf("<small>%s</small>", text); + gtk_label_set_markup(GTK_LABEL(label), buf); + g_free(buf); + + g_object_set_data(G_OBJECT(button), "_nw", nw); + g_object_set_data_full(G_OBJECT(button), "_action_key", g_strdup(key), g_free); + g_signal_connect(G_OBJECT(button), "button-release-event", G_CALLBACK(on_action_clicked), cb); +} + +void clear_notification_actions(GtkWindow* nw) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + windata->pie_countdown = NULL; + + gtk_widget_hide(windata->actions_box); + gtk_container_foreach(GTK_CONTAINER(windata->actions_box), (GtkCallback) gtk_object_destroy, NULL); +} + +void move_notification(GtkWidget* widget, int x, int y) +{ + WindowData* windata = g_object_get_data(G_OBJECT(widget), "windata"); + + g_assert(windata != NULL); + + gtk_window_move(GTK_WINDOW(windata->win), x, y); +} + +void get_theme_info(char** theme_name, char** theme_ver, char** author, char** homepage) +{ + *theme_name = g_strdup("Slider"); + *theme_ver = g_strdup_printf("%d.%d.%d", NOTIFICATION_DAEMON_MAJOR_VERSION, NOTIFICATION_DAEMON_MINOR_VERSION, NOTIFICATION_DAEMON_MICRO_VERSION); + *author = g_strdup("William Jon McCann"); + *homepage = g_strdup("http://www.gnome.org/"); +} + +gboolean get_always_stack(GtkWidget* nw) +{ + return TRUE; +} + +gboolean theme_check_init(unsigned int major_ver, unsigned int minor_ver, unsigned int micro_ver) +{ + return major_ver == 0 && (minor_ver > 3 || (minor_ver == 3 && micro_ver >= 2)); +} diff --git a/src/themes/standard/Makefile.am b/src/themes/standard/Makefile.am new file mode 100644 index 0000000..9d6a6ae --- /dev/null +++ b/src/themes/standard/Makefile.am @@ -0,0 +1,11 @@ +enginedir = $(libdir)/mate-notification-daemon/engines + +engine_LTLIBRARIES = libstandard.la + +libstandard_la_SOURCES = theme.c +libstandard_la_LDFLAGS = -module -avoid-version +libstandard_la_LIBADD = $(NOTIFICATION_DAEMON_LIBS) + +INCLUDES = $(NOTIFICATION_DAEMON_CFLAGS) + +-include $(top_srcdir)/git.mk diff --git a/src/themes/standard/Makefile.in b/src/themes/standard/Makefile.in new file mode 100644 index 0000000..5a61b32 --- /dev/null +++ b/src/themes/standard/Makefile.in @@ -0,0 +1,600 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/themes/standard +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/macros/intltool.m4 \ + $(top_srcdir)/macros/libtool.m4 \ + $(top_srcdir)/macros/ltoptions.m4 \ + $(top_srcdir)/macros/ltsugar.m4 \ + $(top_srcdir)/macros/ltversion.m4 \ + $(top_srcdir)/macros/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(enginedir)" +LTLIBRARIES = $(engine_LTLIBRARIES) +am__DEPENDENCIES_1 = +libstandard_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_libstandard_la_OBJECTS = theme.lo +libstandard_la_OBJECTS = $(am_libstandard_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +libstandard_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(libstandard_la_LDFLAGS) $(LDFLAGS) -o \ + $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libstandard_la_SOURCES) +DIST_SOURCES = $(libstandard_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDK_CFLAGS = @GDK_CFLAGS@ +GDK_LIBS = @GDK_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDIR = @LIBDIR@ +LIBEXECDIR = @LIBEXECDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOTIFICATION_CAPPLET_CFLAGS = @NOTIFICATION_CAPPLET_CFLAGS@ +NOTIFICATION_CAPPLET_LIBS = @NOTIFICATION_CAPPLET_LIBS@ +NOTIFICATION_DAEMON_CFLAGS = @NOTIFICATION_DAEMON_CFLAGS@ +NOTIFICATION_DAEMON_LIBS = @NOTIFICATION_DAEMON_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +THEME_CFLAGS = @THEME_CFLAGS@ +THEME_LIBS = @THEME_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ +XGETTEXT = @XGETTEXT@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +enginedir = $(libdir)/mate-notification-daemon/engines +engine_LTLIBRARIES = libstandard.la +libstandard_la_SOURCES = theme.c +libstandard_la_LDFLAGS = -module -avoid-version +libstandard_la_LIBADD = $(NOTIFICATION_DAEMON_LIBS) +INCLUDES = $(NOTIFICATION_DAEMON_CFLAGS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/themes/standard/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/themes/standard/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-engineLTLIBRARIES: $(engine_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(enginedir)" || $(MKDIR_P) "$(DESTDIR)$(enginedir)" + @list='$(engine_LTLIBRARIES)'; test -n "$(enginedir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(enginedir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(enginedir)"; \ + } + +uninstall-engineLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(engine_LTLIBRARIES)'; test -n "$(enginedir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(enginedir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(enginedir)/$$f"; \ + done + +clean-engineLTLIBRARIES: + -test -z "$(engine_LTLIBRARIES)" || rm -f $(engine_LTLIBRARIES) + @list='$(engine_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libstandard.la: $(libstandard_la_OBJECTS) $(libstandard_la_DEPENDENCIES) + $(AM_V_CCLD)$(libstandard_la_LINK) -rpath $(enginedir) $(libstandard_la_OBJECTS) $(libstandard_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/theme.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(enginedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-engineLTLIBRARIES clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-engineLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-engineLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-engineLTLIBRARIES clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am \ + install-engineLTLIBRARIES install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-engineLTLIBRARIES + + +-include $(top_srcdir)/git.mk + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/themes/standard/theme.c b/src/themes/standard/theme.c new file mode 100644 index 0000000..522cb80 --- /dev/null +++ b/src/themes/standard/theme.c @@ -0,0 +1,1049 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2006-2007 Christian Hammond <[email protected]> + * Copyright (C) 2009 Red Hat, Inc. + * Copyright (C) 2011 Perberos <[email protected]> + * + * 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 "config.h" + +#include <gtk/gtk.h> + +typedef void (*ActionInvokedCb) (GtkWindow* nw, const char* key); +typedef void (*UrlClickedCb) (GtkWindow* nw, const char* url); + +typedef struct { + GtkWidget* win; + GtkWidget* top_spacer; + GtkWidget* bottom_spacer; + GtkWidget* main_hbox; + GtkWidget* iconbox; + GtkWidget* icon; + GtkWidget* content_hbox; + GtkWidget* summary_label; + GtkWidget* close_button; + GtkWidget* body_label; + GtkWidget* actions_box; + GtkWidget* last_sep; + GtkWidget* stripe_spacer; + GtkWidget* pie_countdown; + + gboolean has_arrow; + gboolean enable_transparency; + + int point_x; + int point_y; + + int drawn_arrow_begin_x; + int drawn_arrow_begin_y; + int drawn_arrow_middle_x; + int drawn_arrow_middle_y; + int drawn_arrow_end_x; + int drawn_arrow_end_y; + + int width; + int height; + + GdkGC* gc; + GdkPoint* border_points; + size_t num_border_points; + GdkRegion* window_region; + + guchar urgency; + glong timeout; + glong remaining; + + UrlClickedCb url_clicked; + +} WindowData; + +enum { + URGENCY_LOW, + URGENCY_NORMAL, + URGENCY_CRITICAL +}; + +//#define ENABLE_GRADIENT_LOOK + +#ifdef ENABLE_GRADIENT_LOOK + #define STRIPE_WIDTH 45 +#else + #define STRIPE_WIDTH 30 +#endif + +#define WIDTH 400 +#define IMAGE_SIZE 32 +#define IMAGE_PADDING 10 +#define SPACER_LEFT 30 +#define PIE_RADIUS 12 +#define PIE_WIDTH (2 * PIE_RADIUS) +#define PIE_HEIGHT (2 * PIE_RADIUS) +#define BODY_X_OFFSET (IMAGE_SIZE + 8) +#define DEFAULT_ARROW_OFFSET (SPACER_LEFT + 2) +#define DEFAULT_ARROW_HEIGHT 14 +#define DEFAULT_ARROW_WIDTH 28 +#define BACKGROUND_OPACITY 0.92 +#define BOTTOM_GRADIENT_HEIGHT 30 + +#define USE_COMPOSITE + +static void fill_background(GtkWidget* widget, WindowData* windata, cairo_t* cr) +{ + GtkStyle* style; + GdkColor* background_color; + + #if GTK_CHECK_VERSION(3, 0, 0) + GtkAllocation allocation; + + gtk_widget_get_allocation(widget, &allocation); + #endif + + #ifdef ENABLE_GRADIENT_LOOK + + cairo_pattern_t *gradient; + int gradient_y; + + #if GTK_CHECK_VERSION(3, 0, 0) + gradient_y = allocation.height - BOTTOM_GRADIENT_HEIGHT; + #else + gradient_y = widget->allocation.height - BOTTOM_GRADIENT_HEIGHT; + #endif + + #endif + + style = gtk_widget_get_style(widget); + background_color = &style->base[GTK_STATE_NORMAL]; + + if (windata->enable_transparency) + { + cairo_set_source_rgba(cr, background_color->red / 65535.0, background_color->green / 65535.0, background_color->blue / 65535.0, BACKGROUND_OPACITY); + } + else + { + gdk_cairo_set_source_color(cr, background_color); + } + + #if GTK_CHECK_VERSION(3, 0, 0) + cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); + #else + cairo_rectangle(cr, 0, 0, widget->allocation.width, widget->allocation.height); + #endif + + cairo_fill(cr); + + #ifdef ENABLE_GRADIENT_LOOK + /* Add a very subtle gradient to the bottom of the notification */ + #if GTK_CHECK_VERSION(3, 0, 0) + gradient = cairo_pattern_create_linear(0, gradient_y, 0, allocation.height); + cairo_pattern_add_color_stop_rgba(gradient, 0, 0, 0, 0, 0); + cairo_pattern_add_color_stop_rgba(gradient, 1, 0, 0, 0, 0.15); + cairo_rectangle(cr, 0, gradient_y, allocation.width, BOTTOM_GRADIENT_HEIGHT); + #else + gradient = cairo_pattern_create_linear(0, gradient_y, 0, widget->allocation.height); + cairo_pattern_add_color_stop_rgba(gradient, 0, 0, 0, 0, 0); + cairo_pattern_add_color_stop_rgba(gradient, 1, 0, 0, 0, 0.15); + cairo_rectangle(cr, 0, gradient_y, widget->allocation.width, BOTTOM_GRADIENT_HEIGHT); + #endif + + cairo_set_source(cr, gradient); + cairo_fill(cr); + cairo_pattern_destroy(gradient); + #endif +} + +static void draw_stripe(GtkWidget* widget, WindowData* windata, cairo_t* cr) +{ + GtkStyle* style; + GdkColor color; + int stripe_x; + int stripe_y; + int stripe_height; + #ifdef ENABLE_GRADIENT_LOOK + cairo_pattern_t* gradient; + double r, g, b; + #endif + + style = gtk_widget_get_style(widget); + stripe_x = windata->main_hbox->allocation.x + 1; + + if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL) + { + stripe_x = windata->width - STRIPE_WIDTH - stripe_x; + } + + stripe_y = windata->main_hbox->allocation.y + 1; + stripe_height = windata->main_hbox->allocation.height - 2; + + switch (windata->urgency) + { + case URGENCY_LOW: // LOW + color = style->bg[GTK_STATE_NORMAL]; + break; + + case URGENCY_CRITICAL: // CRITICAL + gdk_color_parse("#CC0000", &color); + break; + + case URGENCY_NORMAL: // NORMAL + default: + color = style->bg[GTK_STATE_SELECTED]; + break; + } + + cairo_rectangle(cr, stripe_x, stripe_y, STRIPE_WIDTH, stripe_height); + + #ifdef ENABLE_GRADIENT_LOOK + r = color.red / 65535.0; + g = color.green / 65535.0; + b = color.blue / 65535.0; + + gradient = cairo_pattern_create_linear(stripe_x, 0, STRIPE_WIDTH, 0); + cairo_pattern_add_color_stop_rgba(gradient, 0, r, g, b, 1); + cairo_pattern_add_color_stop_rgba(gradient, 1, r, g, b, 0); + cairo_set_source(cr, gradient); + cairo_fill(cr); + cairo_pattern_destroy(gradient); + #else + gdk_cairo_set_source_color(cr, &color); + cairo_fill(cr); + #endif +} + +static GtkArrowType get_notification_arrow_type(GtkWidget* nw) +{ + WindowData* windata; + GdkScreen* screen; + GdkRectangle monitor_geometry; + int monitor; + + windata = g_object_get_data(G_OBJECT(nw), "windata"); + + screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window)); + monitor = gdk_screen_get_monitor_at_point(screen, windata->point_x, windata->point_y); + gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry); + + if (windata->point_y - monitor_geometry.y + windata->height + DEFAULT_ARROW_HEIGHT > monitor_geometry.height) + { + return GTK_ARROW_DOWN; + } + else + { + return GTK_ARROW_UP; + } +} + +#define ADD_POINT(_x, _y, shapeoffset_x, shapeoffset_y) \ + G_STMT_START { \ + windata->border_points[i].x = (_x); \ + windata->border_points[i].y = (_y); \ + shape_points[i].x = (_x) + (shapeoffset_x); \ + shape_points[i].y = (_y) + (shapeoffset_y); \ + i++;\ + } G_STMT_END + +static void create_border_with_arrow(GtkWidget* nw, WindowData* windata) +{ + int width; + int height; + int y; + int norm_point_x; + int norm_point_y; + GtkArrowType arrow_type; + GdkScreen* screen; + int arrow_side1_width = DEFAULT_ARROW_WIDTH / 2; + int arrow_side2_width = DEFAULT_ARROW_WIDTH / 2; + int arrow_offset = DEFAULT_ARROW_OFFSET; + GdkPoint* shape_points = NULL; + int i = 0; + int monitor; + GdkRectangle monitor_geometry; + + width = windata->width; + height = windata->height; + + screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window)); + monitor = gdk_screen_get_monitor_at_point(screen, windata->point_x, windata->point_y); + gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry); + + windata->num_border_points = 5; + + arrow_type = get_notification_arrow_type(windata->win); + + norm_point_x = windata->point_x - monitor_geometry.x; + norm_point_y = windata->point_y - monitor_geometry.y; + + /* Handle the offset and such */ + switch (arrow_type) + { + case GTK_ARROW_UP: + case GTK_ARROW_DOWN: + + if (norm_point_x < arrow_side1_width) + { + arrow_side1_width = 0; + arrow_offset = 0; + } + else if (norm_point_x > monitor_geometry.width - arrow_side2_width) + { + arrow_side2_width = 0; + arrow_offset = width - arrow_side1_width; + } + else + { + if (norm_point_x - arrow_side2_width + width >= monitor_geometry.width) + { + arrow_offset = width - monitor_geometry.width + norm_point_x; + } + else + { + arrow_offset = MIN(norm_point_x - arrow_side1_width, DEFAULT_ARROW_OFFSET); + } + + if (arrow_offset == 0 || arrow_offset == width - arrow_side1_width) + { + windata->num_border_points++; + } + else + { + windata->num_border_points += 2; + } + } + + /* + * Why risk this for official builds? If it's somehow off the + * screen, it won't horribly impact the user. Definitely less + * than an assertion would... + */ + #if 0 + g_assert(arrow_offset + arrow_side1_width >= 0); + g_assert(arrow_offset + arrow_side1_width + arrow_side2_width <= width); + #endif + + windata->border_points = g_new0(GdkPoint, windata->num_border_points); + shape_points = g_new0(GdkPoint, windata->num_border_points); + + windata->drawn_arrow_begin_x = arrow_offset; + windata->drawn_arrow_middle_x = arrow_offset + arrow_side1_width; + windata->drawn_arrow_end_x = arrow_offset + arrow_side1_width + arrow_side2_width; + + if (arrow_type == GTK_ARROW_UP) + { + windata->drawn_arrow_begin_y = DEFAULT_ARROW_HEIGHT; + windata->drawn_arrow_middle_y = 0; + windata->drawn_arrow_end_y = DEFAULT_ARROW_HEIGHT; + + if (arrow_side1_width == 0) + { + ADD_POINT(0, 0, 0, 0); + } + else + { + ADD_POINT(0, DEFAULT_ARROW_HEIGHT, 0, 0); + + if (arrow_offset > 0) + { + ADD_POINT(arrow_offset - (arrow_side2_width > 0 ? 0 : 1), DEFAULT_ARROW_HEIGHT, 0, 0); + } + + ADD_POINT(arrow_offset + arrow_side1_width - (arrow_side2_width > 0 ? 0 : 1), 0, 0, 0); + } + + if (arrow_side2_width > 0) + { + ADD_POINT(windata->drawn_arrow_end_x, windata->drawn_arrow_end_y, 1, 0); + ADD_POINT(width - 1, DEFAULT_ARROW_HEIGHT, 1, 0); + } + + ADD_POINT(width - 1, height - 1, 1, 1); + ADD_POINT(0, height - 1, 0, 1); + + y = windata->point_y; + } + else + { + windata->drawn_arrow_begin_y = height - DEFAULT_ARROW_HEIGHT; + windata->drawn_arrow_middle_y = height; + windata->drawn_arrow_end_y = height - DEFAULT_ARROW_HEIGHT; + + ADD_POINT(0, 0, 0, 0); + ADD_POINT(width - 1, 0, 1, 0); + + if (arrow_side2_width == 0) + { + ADD_POINT(width - 1, height, (arrow_side1_width > 0 ? 0 : 1), 0); + } + else + { + ADD_POINT(width - 1, height - DEFAULT_ARROW_HEIGHT, 1, 1); + + if (arrow_offset < width - arrow_side1_width) + { + ADD_POINT(arrow_offset + arrow_side1_width + arrow_side2_width, height - DEFAULT_ARROW_HEIGHT, 0, 1); + } + + ADD_POINT(arrow_offset + arrow_side1_width, height, 0, 1); + } + + if (arrow_side1_width > 0) + { + ADD_POINT(windata->drawn_arrow_begin_x - (arrow_side2_width > 0 ? 0 : 1), windata->drawn_arrow_begin_y, 0, 0); + ADD_POINT(0, height - DEFAULT_ARROW_HEIGHT, 0, 1); + } + + y = windata->point_y - height; + } + + #if 0 + g_assert(i == windata->num_border_points); + g_assert(windata->point_x - arrow_offset - arrow_side1_width >= 0); + #endif + + gtk_window_move(GTK_WINDOW(windata->win), windata->point_x - arrow_offset - arrow_side1_width, y); + + break; + + case GTK_ARROW_LEFT: + case GTK_ARROW_RIGHT: + + if (norm_point_y < arrow_side1_width) + { + arrow_side1_width = 0; + arrow_offset = norm_point_y; + } + else if (norm_point_y > monitor_geometry.height - arrow_side2_width) + { + arrow_side2_width = 0; + arrow_offset = norm_point_y - arrow_side1_width; + } + break; + + default: + g_assert_not_reached(); + } + + g_assert(shape_points != NULL); + + windata->window_region = gdk_region_polygon(shape_points, windata->num_border_points, GDK_EVEN_ODD_RULE); + g_free(shape_points); +} + +static void draw_border(GtkWidget* widget, WindowData *windata, cairo_t* cr) +{ + cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); + cairo_set_line_width(cr, 1.0); + + if (windata->has_arrow) + { + int i; + + create_border_with_arrow(windata->win, windata); + + cairo_move_to(cr, windata->border_points[0].x + 0.5, windata->border_points[0].y + 0.5); + + for (i = 1; i < windata->num_border_points; i++) + { + cairo_line_to(cr, windata->border_points[i].x + 0.5, windata->border_points[i].y + 0.5); + } + + cairo_close_path(cr); + gdk_window_shape_combine_region(windata->win->window, windata->window_region, 0, 0); + g_free(windata->border_points); + windata->border_points = NULL; + } + else + { + cairo_rectangle(cr, 0.5, 0.5, windata->width - 0.5, windata->height - 0.5); + } + + cairo_stroke(cr); +} + +static gboolean paint_window(GtkWidget* widget, GdkEventExpose* event, WindowData* windata) +{ + cairo_t* context; + cairo_surface_t* surface; + cairo_t* cr; + + #if GTK_CHECK_VERSION(3, 0, 0) + GtkAllocation allocation; + + gtk_widget_get_allocation(windata->win, &allocation); + #endif + + if (windata->width == 0) + { + #if GTK_CHECK_VERSION(3, 0, 0) + windata->width = allocation.width; + windata->height = allocation.height; + #else + windata->width = windata->win->allocation.width; + windata->height = windata->win->allocation.height; + #endif + } + + context = gdk_cairo_create(widget->window); + + cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); + + #if GTK_CHECK_VERSION(3, 0, 0) + gtk_widget_get_allocation(widget, &allocation); + + surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height); + #else + surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, widget->allocation.width, widget->allocation.height); + #endif + + cr = cairo_create(surface); + + fill_background(widget, windata, cr); + draw_border(widget, windata, cr); + draw_stripe(widget, windata, cr); + + cairo_destroy(cr); + cairo_set_source_surface(context, surface, 0, 0); + cairo_paint(context); + cairo_surface_destroy(surface); + cairo_destroy(context); + + return FALSE; +} + +static void destroy_windata(WindowData* windata) +{ + if (windata->gc != NULL) + { + g_object_unref(G_OBJECT(windata->gc)); + } + + if (windata->window_region != NULL) + { + gdk_region_destroy(windata->window_region); + } + + g_free(windata); +} + +static void update_spacers(GtkWidget* nw) +{ + WindowData* windata; + + windata = g_object_get_data(G_OBJECT(nw), "windata"); + + if (windata->has_arrow) + { + switch (get_notification_arrow_type(GTK_WIDGET(nw))) + { + case GTK_ARROW_UP: + gtk_widget_show(windata->top_spacer); + gtk_widget_hide(windata->bottom_spacer); + break; + + case GTK_ARROW_DOWN: + gtk_widget_hide(windata->top_spacer); + gtk_widget_show(windata->bottom_spacer); + break; + + default: + g_assert_not_reached(); + } + } + else + { + gtk_widget_hide(windata->top_spacer); + gtk_widget_hide(windata->bottom_spacer); + } +} + +static void update_content_hbox_visibility(WindowData* windata) +{ + /* + * This is all a hack, but until we have a libview-style ContentBox, + * it'll just have to do. + */ + if (GTK_WIDGET_VISIBLE(windata->icon) || GTK_WIDGET_VISIBLE(windata->body_label) || GTK_WIDGET_VISIBLE(windata->actions_box)) + { + gtk_widget_show(windata->content_hbox); + } + else + { + gtk_widget_hide(windata->content_hbox); + } +} + +static gboolean configure_event_cb(GtkWidget* nw, GdkEventConfigure* event, WindowData* windata) +{ + windata->width = event->width; + windata->height = event->height; + + update_spacers(nw); + gtk_widget_queue_draw(nw); + + return FALSE; +} + +static gboolean activate_link(GtkLabel* label, const char* url, WindowData* windata) +{ + windata->url_clicked(GTK_WINDOW(windata->win), url); + + return TRUE; +} + +GtkWindow* create_notification(UrlClickedCb url_clicked) +{ + GtkWidget* spacer; + GtkWidget* win; + GtkWidget* drawbox; + GtkWidget* main_vbox; + GtkWidget* hbox; + GtkWidget* vbox; + GtkWidget* close_button; + GtkWidget* image; + GtkWidget* alignment; + AtkObject* atkobj; + GtkRcStyle* rcstyle; + WindowData* windata; + + #ifdef USE_COMPOSITE + GdkColormap* colormap; + GdkScreen* screen; + #endif + + windata = g_new0(WindowData, 1); + windata->urgency = URGENCY_NORMAL; + windata->url_clicked = url_clicked; + + win = gtk_window_new(GTK_WINDOW_POPUP); + windata->win = win; + + windata->enable_transparency = FALSE; + + #ifdef USE_COMPOSITE + + screen = gtk_window_get_screen(GTK_WINDOW(win)); + colormap = gdk_screen_get_rgba_colormap(screen); + + if (colormap != NULL && gdk_screen_is_composited(screen)) + { + gtk_widget_set_colormap(win, colormap); + windata->enable_transparency = TRUE; + } + + #endif + + gtk_window_set_title(GTK_WINDOW(win), "Notification"); + gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_NOTIFICATION); + gtk_widget_add_events(win, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); + gtk_widget_realize(win); + gtk_widget_set_size_request(win, WIDTH, -1); + + g_object_set_data_full(G_OBJECT(win), "windata", windata, (GDestroyNotify) destroy_windata); + atk_object_set_role(gtk_widget_get_accessible(win), ATK_ROLE_ALERT); + + g_signal_connect(G_OBJECT(win), "configure_event", G_CALLBACK(configure_event_cb), windata); + + /* + * For some reason, there are occasionally graphics glitches when + * repainting the window. Despite filling the window with a background + * color, parts of the other windows on the screen or the shadows around + * notifications will appear on the notification. Somehow, adding this + * eventbox makes that problem just go away. Whatever works for now. + */ + drawbox = gtk_event_box_new(); + gtk_widget_show(drawbox); + gtk_container_add(GTK_CONTAINER(win), drawbox); + + main_vbox = gtk_vbox_new(FALSE, 0); + gtk_widget_show(main_vbox); + gtk_container_add(GTK_CONTAINER(drawbox), main_vbox); + gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1); + + g_signal_connect(G_OBJECT(main_vbox), "expose_event", G_CALLBACK(paint_window), windata); + + windata->top_spacer = gtk_image_new(); + gtk_box_pack_start(GTK_BOX(main_vbox), windata->top_spacer, FALSE, FALSE, 0); + gtk_widget_set_size_request(windata->top_spacer, -1, DEFAULT_ARROW_HEIGHT); + + windata->main_hbox = gtk_hbox_new(FALSE, 0); + gtk_widget_show(windata->main_hbox); + gtk_box_pack_start(GTK_BOX(main_vbox), windata->main_hbox, FALSE, FALSE, 0); + + windata->bottom_spacer = gtk_image_new(); + gtk_box_pack_start(GTK_BOX(main_vbox), windata->bottom_spacer, FALSE, FALSE, 0); + gtk_widget_set_size_request(windata->bottom_spacer, -1, DEFAULT_ARROW_HEIGHT); + + vbox = gtk_vbox_new(FALSE, 6); + gtk_widget_show(vbox); + gtk_box_pack_start(GTK_BOX(windata->main_hbox), vbox, TRUE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); + + hbox = gtk_hbox_new(FALSE, 6); + gtk_widget_show(hbox); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + spacer = gtk_image_new(); + gtk_widget_show(spacer); + gtk_box_pack_start(GTK_BOX(hbox), spacer, FALSE, FALSE, 0); + gtk_widget_set_size_request(spacer, SPACER_LEFT, -1); + + windata->summary_label = gtk_label_new(NULL); + gtk_widget_show(windata->summary_label); + gtk_box_pack_start(GTK_BOX(hbox), windata->summary_label, TRUE, TRUE, 0); + gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0); + gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE); + + atkobj = gtk_widget_get_accessible(windata->summary_label); + atk_object_set_description(atkobj, "Notification summary text."); + + /* Add the close button */ + alignment = gtk_alignment_new(1, 0, 0, 0); + gtk_widget_show(alignment); + gtk_box_pack_start(GTK_BOX(hbox), alignment, FALSE, FALSE, 0); + + close_button = gtk_button_new(); + windata->close_button = close_button; + gtk_widget_show(close_button); + gtk_container_add(GTK_CONTAINER(alignment), close_button); + gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); + gtk_container_set_border_width(GTK_CONTAINER(close_button), 0); + //gtk_widget_set_size_request(close_button, 20, 20); + g_signal_connect_swapped(G_OBJECT(close_button), "clicked", G_CALLBACK(gtk_widget_destroy), win); + + rcstyle = gtk_rc_style_new(); + rcstyle->xthickness = rcstyle->ythickness = 0; + gtk_widget_modify_style(close_button, rcstyle); + g_object_unref(rcstyle); + + atkobj = gtk_widget_get_accessible(close_button); + atk_action_set_description(ATK_ACTION(atkobj), 0, "Closes the notification."); + atk_object_set_name(atkobj, ""); + atk_object_set_description(atkobj, "Closes the notification."); + + image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); + gtk_widget_show(image); + gtk_container_add(GTK_CONTAINER(close_button), image); + + windata->content_hbox = gtk_hbox_new(FALSE, 6); + gtk_box_pack_start(GTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0); + + windata->iconbox = gtk_hbox_new(FALSE, 0); + gtk_widget_show(windata->iconbox); + gtk_box_pack_start(GTK_BOX(windata->content_hbox), windata->iconbox, FALSE, FALSE, 0); + gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1); + + windata->icon = gtk_image_new(); + gtk_box_pack_start(GTK_BOX(windata->iconbox), windata->icon, TRUE, TRUE, 0); + gtk_misc_set_alignment(GTK_MISC(windata->icon), 0.5, 0.0); + + vbox = gtk_vbox_new(FALSE, 6); + gtk_widget_show(vbox); + gtk_box_pack_start(GTK_BOX(windata->content_hbox), vbox, TRUE, TRUE, 0); + + windata->body_label = gtk_label_new(NULL); + gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0); + gtk_misc_set_alignment(GTK_MISC(windata->body_label), 0, 0); + gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE); + g_signal_connect(G_OBJECT(windata->body_label), "activate-link", G_CALLBACK(activate_link), windata); + + atkobj = gtk_widget_get_accessible(windata->body_label); + atk_object_set_description(atkobj, "Notification body text."); + + alignment = gtk_alignment_new(1, 0.5, 0, 0); + gtk_widget_show(alignment); + gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0); + + windata->actions_box = gtk_hbox_new(FALSE, 6); + gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box); + + return GTK_WINDOW(win); +} + +void set_notification_hints(GtkWindow* nw, GHashTable* hints) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + GValue* value = (GValue*) g_hash_table_lookup(hints, "urgency"); + + if (value != NULL && G_VALUE_HOLDS_UCHAR(value)) + { + windata->urgency = g_value_get_uchar(value); + + if (windata->urgency == URGENCY_CRITICAL) + { + gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification"); + } + else + { + gtk_window_set_title(GTK_WINDOW(nw), "Notification"); + } + } +} + +void set_notification_timeout(GtkWindow* nw, glong timeout) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + windata->timeout = timeout; +} + +void notification_tick(GtkWindow* nw, glong remaining) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + windata->remaining = remaining; + + if (windata->pie_countdown != NULL) + { + gtk_widget_queue_draw_area(windata->pie_countdown, 0, 0, PIE_WIDTH, PIE_HEIGHT); + } +} + +void set_notification_text(GtkWindow* nw, const char* summary, const char* body) +{ + char* str; + char* quoted; + GtkRequisition req; + WindowData* windata; + + windata = g_object_get_data(G_OBJECT(nw), "windata"); + g_assert(windata != NULL); + + quoted = g_markup_escape_text(summary, -1); + str = g_strdup_printf("<b><big>%s</big></b>", quoted); + g_free(quoted); + + gtk_label_set_markup(GTK_LABEL(windata->summary_label), str); + g_free(str); + + gtk_label_set_markup(GTK_LABEL(windata->body_label), body); + + if (body == NULL || *body == '\0') + { + gtk_widget_hide(windata->body_label); + } + else + { + gtk_widget_show(windata->body_label); + } + + update_content_hbox_visibility(windata); + + if (body != NULL && *body != '\0') + { + gtk_widget_size_request(windata->iconbox, &req); + /* -1: border width for + * -6: spacing for hbox */ + gtk_widget_set_size_request(windata->body_label, WIDTH - (1 * 2) - (10 * 2) - req.width - 6, -1); + } + + gtk_widget_size_request(windata->close_button, &req); + /* -1: main_vbox border width + * -10: vbox border width + * -6: spacing for hbox */ + gtk_widget_set_size_request(windata->summary_label, WIDTH - (1 * 2) - (10 * 2) - SPACER_LEFT - req.width - (6 * 2), -1); +} + +void set_notification_icon(GtkWindow* nw, GdkPixbuf* pixbuf) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + gtk_image_set_from_pixbuf(GTK_IMAGE(windata->icon), pixbuf); + + if (pixbuf != NULL) + { + int pixbuf_width = gdk_pixbuf_get_width(pixbuf); + + gtk_widget_show(windata->icon); + gtk_widget_set_size_request(windata->iconbox, MAX(BODY_X_OFFSET, pixbuf_width), -1); + } + else + { + gtk_widget_hide(windata->icon); + gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1); + } + + update_content_hbox_visibility(windata); +} + +void set_notification_arrow(GtkWidget* nw, gboolean visible, int x, int y) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + windata->has_arrow = visible; + windata->point_x = x; + windata->point_y = y; + + update_spacers(nw); +} + +static gboolean countdown_expose_cb(GtkWidget* pie, GdkEventExpose* event, WindowData* windata) +{ + GtkStyle* style; + cairo_t* context; + cairo_surface_t* surface; + cairo_t* cr; + + style = gtk_widget_get_style(windata->win); + context = gdk_cairo_create(GDK_DRAWABLE(windata->pie_countdown->window)); + cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); + surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, pie->allocation.width, pie->allocation.height); + cr = cairo_create(surface); + + fill_background(pie, windata, cr); + + if (windata->timeout > 0) + { + gdouble pct = (gdouble) windata->remaining / (gdouble) windata->timeout; + + gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_ACTIVE]); + + cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS); + cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS, -G_PI_2, -(pct * G_PI * 2) - G_PI_2); + cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS); + cairo_fill(cr); + } + + cairo_destroy(cr); + cairo_set_source_surface(context, surface, 0, 0); + cairo_paint(context); + cairo_surface_destroy(surface); + cairo_destroy(context); + + return TRUE; +} + +static void action_clicked_cb(GtkWidget* w, GdkEventButton* event, ActionInvokedCb action_cb) +{ + GtkWindow* nw; + const char* key; + nw = g_object_get_data(G_OBJECT(w), "_nw"); + key = g_object_get_data(G_OBJECT(w), "_action_key"); + action_cb(nw, key); +} + +void add_notification_action(GtkWindow* nw, const char* text, const char* key, ActionInvokedCb cb) +{ + WindowData* windata; + GtkWidget* label; + GtkWidget* button; + GtkWidget* hbox; + GdkPixbuf* pixbuf; + char* buf; + + windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + if (!GTK_WIDGET_VISIBLE(windata->actions_box)) + { + GtkWidget* alignment; + + gtk_widget_show(windata->actions_box); + update_content_hbox_visibility(windata); + + alignment = gtk_alignment_new(1, 0.5, 0, 0); + gtk_widget_show(alignment); + gtk_box_pack_end(GTK_BOX(windata->actions_box), alignment, FALSE, TRUE, 0); + + windata->pie_countdown = gtk_drawing_area_new(); + gtk_widget_show(windata->pie_countdown); + gtk_container_add(GTK_CONTAINER(alignment), windata->pie_countdown); + gtk_widget_set_size_request(windata->pie_countdown, PIE_WIDTH, PIE_HEIGHT); + g_signal_connect(G_OBJECT(windata->pie_countdown), "expose_event", G_CALLBACK(countdown_expose_cb), windata); + } + + button = gtk_button_new(); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(windata->actions_box), button, FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE, 6); + gtk_widget_show(hbox); + gtk_container_add(GTK_CONTAINER(button), hbox); + + /* Try to be smart and find a suitable icon. */ + buf = g_strdup_printf("stock_%s", key); + pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_for_screen(gdk_drawable_get_screen(GTK_WIDGET(nw)->window)), buf, 16, GTK_ICON_LOOKUP_USE_BUILTIN, NULL); + g_free(buf); + + if (pixbuf != NULL) + { + GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf); + gtk_widget_show(image); + gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); + gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.5); + } + + label = gtk_label_new(NULL); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + buf = g_strdup_printf("<small>%s</small>", text); + gtk_label_set_markup(GTK_LABEL(label), buf); + g_free(buf); + + g_object_set_data(G_OBJECT(button), "_nw", nw); + g_object_set_data_full(G_OBJECT(button), "_action_key", g_strdup(key), g_free); + g_signal_connect(G_OBJECT(button), "button-release-event", G_CALLBACK(action_clicked_cb), cb); +} + +void clear_notification_actions(GtkWindow* nw) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + windata->pie_countdown = NULL; + + gtk_widget_hide(windata->actions_box); + gtk_container_foreach(GTK_CONTAINER(windata->actions_box), (GtkCallback) gtk_object_destroy, NULL); +} + +void move_notification(GtkWidget* nw, int x, int y) +{ + WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); + + g_assert(windata != NULL); + + if (windata->has_arrow) + { + gtk_widget_queue_resize(nw); + } + else + { + gtk_window_move(GTK_WINDOW(nw), x, y); + } +} + +void get_theme_info(char** theme_name, char** theme_ver, char** author, char** homepage) +{ + *theme_name = g_strdup("Standard"); + + /* If they are constants, maybe we can remove printf and use G_STRINGIFY() */ + *theme_ver = g_strdup_printf("%d.%d.%d", NOTIFICATION_DAEMON_MAJOR_VERSION, NOTIFICATION_DAEMON_MINOR_VERSION, NOTIFICATION_DAEMON_MICRO_VERSION); + *author = g_strdup("Christian Hammond"); + *homepage = g_strdup("http://www.galago-project.org/"); +} + +gboolean theme_check_init(unsigned int major_ver, unsigned int minor_ver, unsigned int micro_ver) +{ + return major_ver == NOTIFICATION_DAEMON_MAJOR_VERSION && minor_ver == NOTIFICATION_DAEMON_MINOR_VERSION && micro_ver == NOTIFICATION_DAEMON_MICRO_VERSION; +} |