diff options
Diffstat (limited to 'mate-panel/libmate-panel-applet-private')
9 files changed, 2788 insertions, 0 deletions
diff --git a/mate-panel/libmate-panel-applet-private/Makefile.am b/mate-panel/libmate-panel-applet-private/Makefile.am new file mode 100644 index 00000000..9dd4b631 --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/Makefile.am @@ -0,0 +1,34 @@ +noinst_LTLIBRARIES = \ + libmate-panel-applet-private.la \ + libmate-panel-applet-private-mini.la + +AM_CPPFLAGS = \ + $(PANEL_CFLAGS) \ + -I. \ + -I$(srcdir) \ + -I$(top_srcdir)/mate-panel \ + -I$(top_builddir)/mate-panel \ + -I$(top_builddir)/mate-panel/libmate-panel-applets-private \ + -I$(top_builddir)/mate-panel/libpanel-util \ + -DDATADIR=\""$(datadir)"\" \ + -DMATE_PANEL_APPLETS_DIR=\"$(appletsdir)\" \ + $(DISABLE_DEPRECATED_CFLAGS) + +AM_CFLAGS = $(WARN_CFLAGS) + +libmate_panel_applet_private_la_SOURCES = \ + mate-panel-applets-manager-dbus.c \ + mate-panel-applets-manager-dbus.h \ + mate-panel-applet-container.c \ + mate-panel-applet-container.h \ + mate-panel-applet-frame-dbus.c \ + mate-panel-applet-frame-dbus.h + +libmate_panel_applet_private_mini_la_SOURCES =\ + mate-panel-applet-mini.c \ + mate-panel-applets-manager-dbus.c \ + mate-panel-applets-manager-dbus.h \ + mate-panel-applet-container.c \ + mate-panel-applet-container.h + +-include $(top_srcdir)/git.mk diff --git a/mate-panel/libmate-panel-applet-private/Makefile.in b/mate-panel/libmate-panel-applet-private/Makefile.in new file mode 100644 index 00000000..9c7e63bf --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/Makefile.in @@ -0,0 +1,644 @@ +# 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 = mate-panel/libmate-panel-applet-private +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/d-type.m4 \ + $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/intltool.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/mate-doc-utils.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 = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libmate_panel_applet_private_mini_la_LIBADD = +am_libmate_panel_applet_private_mini_la_OBJECTS = \ + mate-panel-applet-mini.lo mate-panel-applets-manager-dbus.lo \ + mate-panel-applet-container.lo +libmate_panel_applet_private_mini_la_OBJECTS = \ + $(am_libmate_panel_applet_private_mini_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +libmate_panel_applet_private_la_LIBADD = +am_libmate_panel_applet_private_la_OBJECTS = \ + mate-panel-applets-manager-dbus.lo \ + mate-panel-applet-container.lo mate-panel-applet-frame-dbus.lo +libmate_panel_applet_private_la_OBJECTS = \ + $(am_libmate_panel_applet_private_la_OBJECTS) +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 = $(libmate_panel_applet_private_mini_la_SOURCES) \ + $(libmate_panel_applet_private_la_SOURCES) +DIST_SOURCES = $(libmate_panel_applet_private_mini_la_SOURCES) \ + $(libmate_panel_applet_private_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CLOCK_CFLAGS = @CLOCK_CFLAGS@ +CLOCK_EDS_ICONDIR = @CLOCK_EDS_ICONDIR@ +CLOCK_LIBS = @CLOCK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DISABLE_DEPRECATED_CFLAGS = @DISABLE_DEPRECATED_CFLAGS@ +DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ +DLLTOOL = @DLLTOOL@ +DOC_USER_FORMATS = @DOC_USER_FORMATS@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGG_SMCLIENT_CFLAGS = @EGG_SMCLIENT_CFLAGS@ +EGG_SMCLIENT_LIBS = @EGG_SMCLIENT_LIBS@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FISH_CFLAGS = @FISH_CFLAGS@ +FISH_LIBS = @FISH_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GIO_QUERYMODULES = @GIO_QUERYMODULES@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HELP_DIR = @HELP_DIR@ +HTML_DIR = @HTML_DIR@ +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@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBMATE_PANEL_APPLET_CFLAGS = @LIBMATE_PANEL_APPLET_CFLAGS@ +LIBMATE_PANEL_APPLET_LIBS = @LIBMATE_PANEL_APPLET_LIBS@ +LIBMATE_PANEL_APPLET_MATECOMPONENT_CFLAGS = @LIBMATE_PANEL_APPLET_MATECOMPONENT_CFLAGS@ +LIBMATE_PANEL_APPLET_MATECOMPONENT_LIBS = @LIBMATE_PANEL_APPLET_MATECOMPONENT_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MATE_PANEL_APPLET_LT_VERSION = @LIB_MATE_PANEL_APPLET_LT_VERSION@ +LIB_MATE_PANEL_APPLET_MATECOMPONENT_LT_VERSION = @LIB_MATE_PANEL_APPLET_MATECOMPONENT_LT_VERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECOMPONENT_ACT_IDLDIR = @MATECOMPONENT_ACT_IDLDIR@ +MATECOMPONENT_CFLAGS = @MATECOMPONENT_CFLAGS@ +MATECOMPONENT_IDLDIR = @MATECOMPONENT_IDLDIR@ +MATECOMPONENT_LIBS = @MATECOMPONENT_LIBS@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MATECORBA_IDL = @MATECORBA_IDL@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NETWORK_MANAGER_CFLAGS = @NETWORK_MANAGER_CFLAGS@ +NETWORK_MANAGER_LIBS = @NETWORK_MANAGER_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOTIFICATION_AREA_CFLAGS = @NOTIFICATION_AREA_CFLAGS@ +NOTIFICATION_AREA_LIBS = @NOTIFICATION_AREA_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OMF_DIR = @OMF_DIR@ +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@ +PANEL_CFLAGS = @PANEL_CFLAGS@ +PANEL_INTLTOOL_MATE_PANEL_APPLET_RULE = @PANEL_INTLTOOL_MATE_PANEL_APPLET_RULE@ +PANEL_LIBS = @PANEL_LIBS@ +PANEL_MODULE_MATECOMPONENT_CFLAGS = @PANEL_MODULE_MATECOMPONENT_CFLAGS@ +PANEL_MODULE_MATECOMPONENT_LIBS = @PANEL_MODULE_MATECOMPONENT_LIBS@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +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@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +REBUILD = @REBUILD@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TZ_CFLAGS = @TZ_CFLAGS@ +TZ_LIBS = @TZ_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WNCKLET_CFLAGS = @WNCKLET_CFLAGS@ +WNCKLET_LIBS = @WNCKLET_LIBS@ +XGETTEXT = @XGETTEXT@ +XMKMF = @XMKMF@ +XRANDR_CFLAGS = @XRANDR_CFLAGS@ +XRANDR_LIBS = @XRANDR_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +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@ +appletsdir = @appletsdir@ +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@ +modulesdir = @modulesdir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +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@ +noinst_LTLIBRARIES = \ + libmate-panel-applet-private.la \ + libmate-panel-applet-private-mini.la + +AM_CPPFLAGS = \ + $(PANEL_CFLAGS) \ + -I. \ + -I$(srcdir) \ + -I$(top_srcdir)/mate-panel \ + -I$(top_builddir)/mate-panel \ + -I$(top_builddir)/mate-panel/libmate-panel-applets-private \ + -I$(top_builddir)/mate-panel/libpanel-util \ + -DDATADIR=\""$(datadir)"\" \ + -DMATE_PANEL_APPLETS_DIR=\"$(appletsdir)\" \ + $(DISABLE_DEPRECATED_CFLAGS) + +AM_CFLAGS = $(WARN_CFLAGS) +libmate_panel_applet_private_la_SOURCES = \ + mate-panel-applets-manager-dbus.c \ + mate-panel-applets-manager-dbus.h \ + mate-panel-applet-container.c \ + mate-panel-applet-container.h \ + mate-panel-applet-frame-dbus.c \ + mate-panel-applet-frame-dbus.h + +libmate_panel_applet_private_mini_la_SOURCES = \ + mate-panel-applet-mini.c \ + mate-panel-applets-manager-dbus.c \ + mate-panel-applets-manager-dbus.h \ + mate-panel-applet-container.c \ + mate-panel-applet-container.h + +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 mate-panel/libmate-panel-applet-private/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu mate-panel/libmate-panel-applet-private/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): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_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 +libmate-panel-applet-private-mini.la: $(libmate_panel_applet_private_mini_la_OBJECTS) $(libmate_panel_applet_private_mini_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libmate_panel_applet_private_mini_la_OBJECTS) $(libmate_panel_applet_private_mini_la_LIBADD) $(LIBS) +libmate-panel-applet-private.la: $(libmate_panel_applet_private_la_OBJECTS) $(libmate_panel_applet_private_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libmate_panel_applet_private_la_OBJECTS) $(libmate_panel_applet_private_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mate-panel-applet-container.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mate-panel-applet-frame-dbus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mate-panel-applet-mini.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mate-panel-applets-manager-dbus.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: +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-generic clean-libtool clean-noinstLTLIBRARIES \ + 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-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: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES 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-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 + + +-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/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c b/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c new file mode 100644 index 00000000..f2e39019 --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c @@ -0,0 +1,790 @@ +/* + * mate-panel-applet-container.c: a container for applets. + * + * Copyright (C) 2010 Carlos Garcia Campos <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include <string.h> +#include "mate-panel-applet-container.h" +#include "panel-marshal.h" + +struct _MatePanelAppletContainerPrivate { + GDBusProxy *applet_proxy; + + guint name_watcher_id; + gchar *bus_name; + + guint32 xid; + GtkWidget *socket; + + GHashTable *pending_ops; +}; + +enum { + APPLET_BROKEN, + APPLET_MOVE, + APPLET_REMOVE, + APPLET_LOCK, + CHILD_PROPERTY_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; + +typedef struct { + const gchar *name; + const gchar *dbus_name; +} AppletPropertyInfo; + +static const AppletPropertyInfo applet_properties [] = { + { "prefs-key", "PrefsKey" }, + { "orient", "Orient" }, + { "size", "Size" }, + { "size-hints", "SizeHints" }, + { "background", "Background" }, + { "flags", "Flags" }, + { "locked", "Locked" }, + { "locked-down", "LockedDown" } +}; + +#define MATE_PANEL_APPLET_CONTAINER_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_CONTAINER, MatePanelAppletContainerPrivate)) + +#define MATE_PANEL_APPLET_BUS_NAME "org.mate.panel.applet.%s" +#define MATE_PANEL_APPLET_FACTORY_INTERFACE "org.mate.panel.applet.AppletFactory" +#define MATE_PANEL_APPLET_FACTORY_OBJECT_PATH "/org/mate/panel/applet/%s" +#define MATE_PANEL_APPLET_INTERFACE "org.mate.panel.applet.Applet" + +static gboolean mate_panel_applet_container_plug_removed (MatePanelAppletContainer *container); + +G_DEFINE_TYPE (MatePanelAppletContainer, mate_panel_applet_container, GTK_TYPE_EVENT_BOX); + +GQuark mate_panel_applet_container_error_quark (void) +{ + return g_quark_from_static_string ("mate-panel-applet-container-error-quark"); +} + +static void mate_panel_applet_container_init(MatePanelAppletContainer* container) +{ + container->priv = MATE_PANEL_APPLET_CONTAINER_GET_PRIVATE (container); + + container->priv->socket = gtk_socket_new (); + g_signal_connect_swapped (container->priv->socket, "plug-removed", G_CALLBACK (mate_panel_applet_container_plug_removed), container); + + container->priv->pending_ops = g_hash_table_new_full (g_direct_hash, + g_direct_equal, + NULL, + (GDestroyNotify) g_object_unref); + + gtk_container_add (GTK_CONTAINER (container), + container->priv->socket); + gtk_widget_show (container->priv->socket); +} + +static void +mate_panel_applet_container_cancel_pending_operations (MatePanelAppletContainer *container) +{ + GList *keys, *l; + + if (!container->priv->pending_ops) + return; + + keys = g_hash_table_get_keys (container->priv->pending_ops); + for (l = keys; l; l = g_list_next (l)) { + GCancellable *cancellable; + + cancellable = G_CANCELLABLE (g_hash_table_lookup (container->priv->pending_ops, l->data)); + g_cancellable_cancel (cancellable); + } + g_list_free (keys); +} + +static void +mate_panel_applet_container_dispose (GObject *object) +{ + MatePanelAppletContainer *container = MATE_PANEL_APPLET_CONTAINER (object); + + if (container->priv->pending_ops) { + mate_panel_applet_container_cancel_pending_operations (container); + g_hash_table_destroy (container->priv->pending_ops); + container->priv->pending_ops = NULL; + } + + if (container->priv->bus_name) { + g_free (container->priv->bus_name); + container->priv->bus_name = NULL; + } + + if (container->priv->name_watcher_id > 0) { + g_bus_unwatch_name (container->priv->name_watcher_id); + container->priv->name_watcher_id = 0; + } + + if (container->priv->applet_proxy) { + g_object_unref (container->priv->applet_proxy); + container->priv->applet_proxy = NULL; + } + + G_OBJECT_CLASS (mate_panel_applet_container_parent_class)->dispose (object); +} + +static void +mate_panel_applet_container_class_init (MatePanelAppletContainerClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (MatePanelAppletContainerPrivate)); + + gobject_class->dispose = mate_panel_applet_container_dispose; + + signals[APPLET_BROKEN] = + g_signal_new ("applet-broken", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MatePanelAppletContainerClass, applet_broken), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals[APPLET_MOVE] = + g_signal_new ("applet-move", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MatePanelAppletContainerClass, applet_move), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals[APPLET_REMOVE] = + g_signal_new ("applet-remove", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MatePanelAppletContainerClass, applet_remove), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals[APPLET_LOCK] = + g_signal_new ("applet-lock", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MatePanelAppletContainerClass, applet_lock), + NULL, + NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, G_TYPE_BOOLEAN); + signals[CHILD_PROPERTY_CHANGED] = + g_signal_new ("child-property-changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | + G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS, + G_STRUCT_OFFSET (MatePanelAppletContainerClass, child_property_changed), + NULL, + NULL, + panel_marshal_VOID__STRING_POINTER, + G_TYPE_NONE, 2, + G_TYPE_STRING, + G_TYPE_POINTER); +} + +static const AppletPropertyInfo * +mate_panel_applet_container_child_property_get_info (const gchar *property_name) +{ + gint i; + + g_assert (property_name != NULL); + + for (i = 0; i < G_N_ELEMENTS (applet_properties); i++) { + if (g_ascii_strcasecmp (applet_properties[i].name, property_name) == 0) + return &applet_properties[i]; + } + + return NULL; +} + +GtkWidget * +mate_panel_applet_container_new (void) +{ + GtkWidget *container; + + container = GTK_WIDGET (g_object_new (PANEL_TYPE_APPLET_CONTAINER, NULL)); + + return container; +} + +static gboolean +mate_panel_applet_container_plug_removed (MatePanelAppletContainer *container) +{ + if (!container->priv->applet_proxy) + return FALSE; + + mate_panel_applet_container_cancel_pending_operations (container); + + if (container->priv->name_watcher_id > 0) { + g_bus_unwatch_name (container->priv->name_watcher_id); + container->priv->name_watcher_id = 0; + } + + g_object_unref (container->priv->applet_proxy); + container->priv->applet_proxy = NULL; + + g_signal_emit (container, signals[APPLET_BROKEN], 0); + + /* Continue destroying, in case of reloading + * a new frame widget is created + */ + return FALSE; +} + +static void +mate_panel_applet_container_child_signal (GDBusProxy *proxy, + gchar *sender_name, + gchar *signal_name, + GVariant *parameters, + MatePanelAppletContainer *container) +{ + if (g_strcmp0 (signal_name, "Move") == 0) { + g_signal_emit (container, signals[APPLET_MOVE], 0); + } else if (g_strcmp0 (signal_name, "RemoveFromPanel") == 0) { + g_signal_emit (container, signals[APPLET_REMOVE], 0); + } else if (g_strcmp0 (signal_name, "Lock") == 0) { + g_signal_emit (container, signals[APPLET_LOCK], 0, TRUE); + } else if (g_strcmp0 (signal_name, "Unlock") == 0) { + g_signal_emit (container, signals[APPLET_LOCK], 0, FALSE); + } +} + +static void +on_property_changed (GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + MatePanelAppletContainer *container) +{ + GVariant *props; + GVariantIter iter; + GVariant *value; + gchar *key; + + g_variant_get (parameters, "(s@a{sv}*)", NULL, &props, NULL); + + g_variant_iter_init (&iter, props); + while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) { + if (g_strcmp0 (key, "Flags") == 0) { + g_signal_emit (container, signals[CHILD_PROPERTY_CHANGED], + g_quark_from_string ("flags"), + "flags", value); + } else if (g_strcmp0 (key, "SizeHints") == 0) { + g_signal_emit (container, signals[CHILD_PROPERTY_CHANGED], + g_quark_from_string ("size-hints"), + "size-hints", value); + } + } + + g_variant_unref (props); +} + +static void +on_proxy_appeared (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); + MatePanelAppletContainer *container; + GDBusProxy *proxy; + GError *error = NULL; + + proxy = g_dbus_proxy_new_finish (res, &error); + if (!proxy) { + g_simple_async_result_set_from_error (result, error); + g_error_free (error); + g_simple_async_result_complete (result); + g_object_unref (result); + + return; + } + + container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result))); + + container->priv->applet_proxy = proxy; + g_signal_connect (container->priv->applet_proxy, "g-signal", + G_CALLBACK (mate_panel_applet_container_child_signal), + container); + g_dbus_connection_signal_subscribe (g_dbus_proxy_get_connection (proxy), + g_dbus_proxy_get_name (proxy), + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + g_dbus_proxy_get_object_path (proxy), + MATE_PANEL_APPLET_INTERFACE, + G_DBUS_SIGNAL_FLAGS_NONE, + (GDBusSignalCallback) on_property_changed, + container, NULL); + + g_simple_async_result_complete (result); + g_object_unref (result); + + if (container->priv->xid > 0) { + gtk_socket_add_id (GTK_SOCKET (container->priv->socket), + container->priv->xid); + } + + /* g_async_result_get_source_object returns new ref */ + g_object_unref (container); +} + +static void +get_applet_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GDBusConnection *connection = G_DBUS_CONNECTION (source_object); + GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); + MatePanelAppletContainer *container; + GVariant *retvals; + const gchar *applet_path; + GError *error = NULL; + + retvals = g_dbus_connection_call_finish (connection, res, &error); + if (!retvals) { + g_simple_async_result_set_from_error (result, error); + g_error_free (error); + g_simple_async_result_complete (result); + g_object_unref (result); + + return; + } + + container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result))); + g_variant_get (retvals, "(&ou)", &applet_path, &container->priv->xid); + + g_dbus_proxy_new (connection, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, + NULL, + container->priv->bus_name, + applet_path, + MATE_PANEL_APPLET_INTERFACE, + NULL, + (GAsyncReadyCallback) on_proxy_appeared, + result); + + g_variant_unref (retvals); + + /* g_async_result_get_source_object returns new ref */ + g_object_unref (container); +} + +typedef struct { + GSimpleAsyncResult *result; + gchar *factory_id; + GVariant *parameters; + GCancellable *cancellable; +} AppletFactoryData; + +static void +applet_factory_data_free (AppletFactoryData *data) +{ + g_free (data->factory_id); + if (data->cancellable) + g_object_unref (data->cancellable); + + g_free (data); +} + +static void +on_factory_appeared (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + AppletFactoryData *data) +{ + MatePanelAppletContainer *container; + gchar *object_path; + + container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (data->result))); + container->priv->bus_name = g_strdup (name_owner); + object_path = g_strdup_printf (MATE_PANEL_APPLET_FACTORY_OBJECT_PATH, data->factory_id); + g_dbus_connection_call (connection, + name_owner, + object_path, + MATE_PANEL_APPLET_FACTORY_INTERFACE, + "GetApplet", + data->parameters, + G_VARIANT_TYPE ("(ou)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + data->cancellable, + get_applet_cb, + data->result); + g_free (object_path); +} + +static void +mate_panel_applet_container_get_applet (MatePanelAppletContainer *container, + const gchar *iid, + GVariant *props, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + AppletFactoryData *data; + gint screen; + gchar *bus_name; + gchar *factory_id; + gchar *applet_id; + + result = g_simple_async_result_new (G_OBJECT (container), + callback, + user_data, + mate_panel_applet_container_get_applet); + + applet_id = g_strrstr (iid, "::"); + if (!applet_id) { + g_simple_async_result_set_error (result, + MATE_PANEL_APPLET_CONTAINER_ERROR, + MATE_PANEL_APPLET_CONTAINER_INVALID_APPLET, + "Invalid applet iid: %s", iid); + g_simple_async_result_complete (result); + g_object_unref (result); + + return; + } + + factory_id = g_strndup (iid, strlen (iid) - strlen (applet_id)); + applet_id += 2; + + screen = gdk_screen_get_number (gtk_widget_get_screen (container->priv->socket)); + + data = g_new (AppletFactoryData, 1); + data->result = result; + data->factory_id = factory_id; + data->parameters = g_variant_new ("(si*)", applet_id, screen, props); + data->cancellable = cancellable ? g_object_ref (cancellable) : NULL; + + bus_name = g_strdup_printf (MATE_PANEL_APPLET_BUS_NAME, factory_id); + + container->priv->name_watcher_id = + g_bus_watch_name (G_BUS_TYPE_SESSION, + bus_name, + G_BUS_NAME_WATCHER_FLAGS_AUTO_START, + (GBusNameAppearedCallback) on_factory_appeared, + NULL, + data, + (GDestroyNotify) applet_factory_data_free); + + g_free (bus_name); +} + +void +mate_panel_applet_container_add (MatePanelAppletContainer *container, + const gchar *iid, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data, + GVariant *properties) +{ + g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container)); + g_return_if_fail (iid != NULL); + + mate_panel_applet_container_cancel_pending_operations (container); + + mate_panel_applet_container_get_applet (container, iid, properties, + cancellable, callback, user_data); +} + +gboolean +mate_panel_applet_container_add_finish (MatePanelAppletContainer *container, + GAsyncResult *result, + GError **error) +{ + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == mate_panel_applet_container_get_applet); + + return !g_simple_async_result_propagate_error (simple, error); +} + +/* Child Properties */ +static void +set_applet_property_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GDBusConnection *connection = G_DBUS_CONNECTION (source_object); + GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); + MatePanelAppletContainer *container; + GVariant *retvals; + GError *error = NULL; + + retvals = g_dbus_connection_call_finish (connection, res, &error); + if (!retvals) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("Error setting property: %s\n", error->message); + g_simple_async_result_set_from_error (result, error); + g_error_free (error); + } else { + g_variant_unref (retvals); + } + + container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result))); + g_hash_table_remove (container->priv->pending_ops, result); + g_simple_async_result_complete (result); + g_object_unref (result); + + /* g_async_result_get_source_object returns new ref */ + g_object_unref (container); +} + +void +mate_panel_applet_container_child_set (MatePanelAppletContainer *container, + const gchar *property_name, + const GVariant *value, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GDBusProxy *proxy = container->priv->applet_proxy; + const AppletPropertyInfo *info; + GSimpleAsyncResult *result; + + if (!proxy) + return; + + info = mate_panel_applet_container_child_property_get_info (property_name); + if (!info) { + g_simple_async_report_error_in_idle (G_OBJECT (container), + callback, user_data, + MATE_PANEL_APPLET_CONTAINER_ERROR, + MATE_PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY, + "%s: Applet has no child property named `%s'", + G_STRLOC, property_name); + return; + } + + result = g_simple_async_result_new (G_OBJECT (container), + callback, + user_data, + mate_panel_applet_container_child_set); + + if (cancellable) + g_object_ref (cancellable); + else + cancellable = g_cancellable_new (); + g_hash_table_insert (container->priv->pending_ops, result, cancellable); + + g_dbus_connection_call (g_dbus_proxy_get_connection (proxy), + g_dbus_proxy_get_name (proxy), + g_dbus_proxy_get_object_path (proxy), + "org.freedesktop.DBus.Properties", + "Set", + g_variant_new ("(ssv)", + g_dbus_proxy_get_interface_name (proxy), + info->dbus_name, + value), + NULL, + G_DBUS_CALL_FLAGS_NO_AUTO_START, + -1, cancellable, + set_applet_property_cb, + result); +} + +gboolean +mate_panel_applet_container_child_set_finish (MatePanelAppletContainer *container, + GAsyncResult *result, + GError **error) +{ + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == mate_panel_applet_container_child_set); + + return !g_simple_async_result_propagate_error (simple, error); +} + +static void +get_applet_property_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GDBusConnection *connection = G_DBUS_CONNECTION (source_object); + GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); + MatePanelAppletContainer *container; + GVariant *retvals; + GError *error = NULL; + + retvals = g_dbus_connection_call_finish (connection, res, &error); + if (!retvals) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("Error getting property: %s\n", error->message); + g_simple_async_result_set_from_error (result, error); + g_error_free (error); + } else { + GVariant *value, *item; + + item = g_variant_get_child_value (retvals, 0); + value = g_variant_get_variant (item); + g_variant_unref (item); + g_simple_async_result_set_op_res_gpointer (result, value, + (GDestroyNotify) g_variant_unref); + g_variant_unref (retvals); + } + + container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result))); + g_hash_table_remove (container->priv->pending_ops, result); + g_simple_async_result_complete (result); + g_object_unref (result); + + /* g_async_result_get_source_object returns new ref */ + g_object_unref (container); +} + +void +mate_panel_applet_container_child_get (MatePanelAppletContainer *container, + const gchar *property_name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GDBusProxy *proxy = container->priv->applet_proxy; + const AppletPropertyInfo *info; + GSimpleAsyncResult *result; + + if (!proxy) + return; + + info = mate_panel_applet_container_child_property_get_info (property_name); + if (!info) { + g_simple_async_report_error_in_idle (G_OBJECT (container), + callback, user_data, + MATE_PANEL_APPLET_CONTAINER_ERROR, + MATE_PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY, + "%s: Applet has no child property named `%s'", + G_STRLOC, property_name); + return; + } + + result = g_simple_async_result_new (G_OBJECT (container), + callback, + user_data, + mate_panel_applet_container_child_get); + if (cancellable) + g_object_ref (cancellable); + else + cancellable = g_cancellable_new (); + g_hash_table_insert (container->priv->pending_ops, result, cancellable); + + g_dbus_connection_call (g_dbus_proxy_get_connection (proxy), + g_dbus_proxy_get_name (proxy), + g_dbus_proxy_get_object_path (proxy), + "org.freedesktop.DBus.Properties", + "Get", + g_variant_new ("(ss)", + g_dbus_proxy_get_interface_name (proxy), + info->dbus_name), + G_VARIANT_TYPE ("(v)"), + G_DBUS_CALL_FLAGS_NO_AUTO_START, + -1, cancellable, + get_applet_property_cb, + result); +} + +GVariant * +mate_panel_applet_container_child_get_finish (MatePanelAppletContainer *container, + GAsyncResult *result, + GError **error) +{ + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == mate_panel_applet_container_child_get); + + if (g_simple_async_result_propagate_error (simple, error)) + return NULL; + + return g_variant_ref (g_simple_async_result_get_op_res_gpointer (simple)); +} + +static void +child_popup_menu_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GDBusConnection *connection = G_DBUS_CONNECTION (source_object); + GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); + GVariant *retvals; + GError *error = NULL; + + retvals = g_dbus_connection_call_finish (connection, res, &error); + if (!retvals) { + g_simple_async_result_set_from_error (result, error); + g_error_free (error); + } else { + g_variant_unref (retvals); + } + + g_simple_async_result_complete (result); + g_object_unref (result); +} + +void +mate_panel_applet_container_child_popup_menu (MatePanelAppletContainer *container, + guint button, + guint32 timestamp, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + GDBusProxy *proxy = container->priv->applet_proxy; + + if (!proxy) + return; + + result = g_simple_async_result_new (G_OBJECT (container), + callback, + user_data, + mate_panel_applet_container_child_popup_menu); + + g_dbus_connection_call (g_dbus_proxy_get_connection (proxy), + g_dbus_proxy_get_name (proxy), + g_dbus_proxy_get_object_path (proxy), + MATE_PANEL_APPLET_INTERFACE, + "PopupMenu", + g_variant_new ("(uu)", button, timestamp), + NULL, + G_DBUS_CALL_FLAGS_NO_AUTO_START, + -1, cancellable, + child_popup_menu_cb, + result); +} + +gboolean +mate_panel_applet_container_child_popup_menu_finish (MatePanelAppletContainer *container, + GAsyncResult *result, + GError **error) +{ + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == mate_panel_applet_container_child_popup_menu); + + return !g_simple_async_result_propagate_error (simple, error); +} diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.h b/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.h new file mode 100644 index 00000000..4b1e316a --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.h @@ -0,0 +1,118 @@ +/* + * mate-panel-applet-container.c: a container for applets. + * + * Copyright (C) 2010 Carlos Garcia Campos <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef __MATE_PANEL_APPLET_CONTAINER_H__ +#define __MATE_PANEL_APPLET_CONTAINER_H__ + +#include <glib-object.h> +#include <gtk/gtk.h> +#include "panel.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define PANEL_TYPE_APPLET_CONTAINER (mate_panel_applet_container_get_type ()) +#define MATE_PANEL_APPLET_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLET_CONTAINER, MatePanelAppletContainer)) +#define MATE_PANEL_APPLET_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANEL_TYPE_APPLET_CONTAINER, MatePanelAppletContainerClass)) +#define PANEL_IS_APPLET_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLET_CONTAINER)) +#define PANEL_IS_APPLET_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLET_CONTAINER)) +#define MATE_PANEL_APPLET_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_APPLET_CONTAINER, MatePanelAppletContainerClass)) + +#define MATE_PANEL_APPLET_CONTAINER_ERROR (mate_panel_applet_container_error_quark()) + +typedef enum { + MATE_PANEL_APPLET_CONTAINER_INVALID_APPLET, + MATE_PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY +} MatePanelAppletContainerError; + +typedef struct _MatePanelAppletContainer MatePanelAppletContainer; +typedef struct _MatePanelAppletContainerClass MatePanelAppletContainerClass; +typedef struct _MatePanelAppletContainerPrivate MatePanelAppletContainerPrivate; + +struct _MatePanelAppletContainer { + GtkEventBox parent; + + MatePanelAppletContainerPrivate *priv; +}; + +struct _MatePanelAppletContainerClass { + GtkEventBoxClass parent_class; + + /* Signals */ + void (*applet_broken) (MatePanelAppletContainer *container); + void (*applet_move) (MatePanelAppletContainer *container); + void (*applet_remove) (MatePanelAppletContainer *container); + void (*applet_lock) (MatePanelAppletContainer *container, + gboolean locked); + void (*child_property_changed) (MatePanelAppletContainer *container, + const gchar *property_name, + GVariant *value); +}; + +GType mate_panel_applet_container_get_type (void) G_GNUC_CONST; +GQuark mate_panel_applet_container_error_quark (void) G_GNUC_CONST; +GtkWidget *mate_panel_applet_container_new (void); + + +void mate_panel_applet_container_add (MatePanelAppletContainer *container, + const gchar *iid, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data, + GVariant *properties); +gboolean mate_panel_applet_container_add_finish (MatePanelAppletContainer *container, + GAsyncResult *result, + GError **error); +void mate_panel_applet_container_child_popup_menu (MatePanelAppletContainer *container, + guint button, + guint32 timestamp, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mate_panel_applet_container_child_popup_menu_finish (MatePanelAppletContainer *container, + GAsyncResult *result, + GError **error); + +void mate_panel_applet_container_child_set (MatePanelAppletContainer *container, + const gchar *property_name, + const GVariant *value, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mate_panel_applet_container_child_set_finish (MatePanelAppletContainer *container, + GAsyncResult *result, + GError **error); +void mate_panel_applet_container_child_get (MatePanelAppletContainer *container, + const gchar *property_name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GVariant *mate_panel_applet_container_child_get_finish (MatePanelAppletContainer *container, + GAsyncResult *result, + GError **error); + +#ifdef __cplusplus +} +#endif + +#endif /* __MATE_PANEL_APPLET_CONTAINER_H__ */ diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.c b/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.c new file mode 100644 index 00000000..b2e90e73 --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.c @@ -0,0 +1,468 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * mate-panel-applet-frame-dbus.c: panel side container for applets + * + * Copyright (C) 2001 - 2003 Sun Microsystems, Inc. + * Copyright (C) 2010 Carlos Garcia Campos <[email protected]> + * Copyright (C) 2010 Vincent Untz <[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 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Authors: + * Mark McLoughlin <[email protected]> + */ + +#include <config.h> + +#include <string.h> + +#include <mate-panel-applet-frame.h> +#include <mate-panel-applets-manager.h> + +#include "mate-panel-applet-container.h" + +#include "mate-panel-applet-frame-dbus.h" + +G_DEFINE_TYPE (MatePanelAppletFrameDBus, + mate_panel_applet_frame_dbus, + PANEL_TYPE_APPLET_FRAME) + +struct _MatePanelAppletFrameDBusPrivate +{ + MatePanelAppletContainer *container; + GCancellable *bg_cancellable; +}; + +/* Keep in sync with mate-panel-applet.h. Uggh. */ +typedef enum { + APPLET_FLAGS_NONE = 0, + APPLET_EXPAND_MAJOR = 1 << 0, + APPLET_EXPAND_MINOR = 1 << 1, + APPLET_HAS_HANDLE = 1 << 2 +} MatePanelAppletFlags; + + +static guint +get_mate_panel_applet_orient (PanelOrientation orientation) +{ + /* For some reason libmate-panel-applet and panel use a different logic for + * orientation, so we need to convert it. We should fix this. */ + switch (orientation) { + case PANEL_ORIENTATION_TOP: + return 1; + case PANEL_ORIENTATION_BOTTOM: + return 0; + case PANEL_ORIENTATION_LEFT: + return 3; + case PANEL_ORIENTATION_RIGHT: + return 2; + default: + g_assert_not_reached (); + break; + } +} + +static void +mate_panel_applet_frame_dbus_update_flags (MatePanelAppletFrame *frame, + GVariant *value) +{ + guint32 flags; + gboolean major; + gboolean minor; + gboolean has_handle; + + flags = g_variant_get_uint32 (value); + + major = (flags & APPLET_EXPAND_MAJOR) != 0; + minor = (flags & APPLET_EXPAND_MINOR) != 0; + has_handle = (flags & APPLET_HAS_HANDLE) != 0; + + _mate_panel_applet_frame_update_flags (frame, major, minor, has_handle); +} + + +static void +mate_panel_applet_frame_dbus_get_flags_cb (MatePanelAppletContainer *container, + GAsyncResult *res, + MatePanelAppletFrame *frame) +{ + GVariant *value; + GError *error = NULL; + + value = mate_panel_applet_container_child_get_finish (container, res, &error); + if (!value) { + g_warning ("%s\n", error->message); + g_error_free (error); + return; + } + + mate_panel_applet_frame_dbus_update_flags (frame, value); + g_variant_unref (value); +} + +static void +mate_panel_applet_frame_dbus_get_size_hints_cb (MatePanelAppletContainer *container, + GAsyncResult *res, + MatePanelAppletFrame *frame) +{ + GVariant *value; + const gint *sz; + gint *size_hints = NULL; + gsize n_elements; + GError *error = NULL; + + value = mate_panel_applet_container_child_get_finish (container, res, &error); + if (!value) { + g_warning ("%s\n", error->message); + g_error_free (error); + return; + } + + sz = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32)); + if (n_elements > 0) { + size_hints = g_new (gint32, n_elements); + memcpy (size_hints, sz, n_elements * sizeof (gint32)); + } + + _mate_panel_applet_frame_update_size_hints (frame, size_hints, n_elements); + g_variant_unref (value); +} + +static void +mate_panel_applet_frame_dbus_init_properties (MatePanelAppletFrame *frame) +{ + MatePanelAppletFrameDBus *dbus_frame = MATE_PANEL_APPLET_FRAME_DBUS (frame); + + mate_panel_applet_container_child_get (dbus_frame->priv->container, "flags", NULL, + (GAsyncReadyCallback) mate_panel_applet_frame_dbus_get_flags_cb, + frame); + mate_panel_applet_container_child_get (dbus_frame->priv->container, "size-hints", NULL, + (GAsyncReadyCallback) mate_panel_applet_frame_dbus_get_size_hints_cb, + frame); +} + +static void +mate_panel_applet_frame_dbus_sync_menu_state (MatePanelAppletFrame *frame, + gboolean movable, + gboolean removable, + gboolean lockable, + gboolean locked, + gboolean locked_down) +{ + MatePanelAppletFrameDBus *dbus_frame = MATE_PANEL_APPLET_FRAME_DBUS (frame); + + mate_panel_applet_container_child_set (dbus_frame->priv->container, + "locked", g_variant_new_boolean (lockable && locked), + NULL, NULL, NULL); + mate_panel_applet_container_child_set (dbus_frame->priv->container, + "locked-down", g_variant_new_boolean (locked_down), + NULL, NULL, NULL); +} + +static void +mate_panel_applet_frame_dbus_popup_menu (MatePanelAppletFrame *frame, + guint button, + guint32 timestamp) +{ + MatePanelAppletFrameDBus *dbus_frame = MATE_PANEL_APPLET_FRAME_DBUS (frame); + + mate_panel_applet_container_child_popup_menu (dbus_frame->priv->container, + button, timestamp, + NULL, NULL, NULL); +} + +static void +change_orientation_cb (MatePanelAppletContainer *container, + GAsyncResult *res, + MatePanelAppletFrame *frame) +{ + GError *error = NULL; + + if (!mate_panel_applet_container_child_set_finish (container, res, &error)) { + g_warning ("%s\n", error->message); + g_error_free (error); + + return; + } + + gtk_widget_queue_resize (GTK_WIDGET (frame)); +} + +static void +mate_panel_applet_frame_dbus_change_orientation (MatePanelAppletFrame *frame, + PanelOrientation orientation) +{ + MatePanelAppletFrameDBus *dbus_frame = MATE_PANEL_APPLET_FRAME_DBUS (frame); + + mate_panel_applet_container_child_set (dbus_frame->priv->container, + "orient", + g_variant_new_uint32 (get_mate_panel_applet_orient (orientation)), + NULL, + (GAsyncReadyCallback)change_orientation_cb, + frame); +} + +static void +mate_panel_applet_frame_dbus_change_size (MatePanelAppletFrame *frame, + guint size) +{ + MatePanelAppletFrameDBus *dbus_frame = MATE_PANEL_APPLET_FRAME_DBUS (frame); + + mate_panel_applet_container_child_set (dbus_frame->priv->container, + "size", g_variant_new_uint32 (size), + NULL, NULL, NULL); +} + +static void +container_child_background_set (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + MatePanelAppletContainer *container = MATE_PANEL_APPLET_CONTAINER (source_object); + MatePanelAppletFrameDBus *frame = MATE_PANEL_APPLET_FRAME_DBUS (user_data); + + mate_panel_applet_container_child_set_finish (container, res, NULL); + + if (frame->priv->bg_cancellable) + g_object_unref (frame->priv->bg_cancellable); + frame->priv->bg_cancellable = NULL; +} + +static void +mate_panel_applet_frame_dbus_change_background (MatePanelAppletFrame *frame, + PanelBackgroundType type) +{ + MatePanelAppletFrameDBus *dbus_frame = MATE_PANEL_APPLET_FRAME_DBUS (frame); + char *bg_str; + + bg_str = _mate_panel_applet_frame_get_background_string ( + frame, PANEL_WIDGET (gtk_widget_get_parent (GTK_WIDGET (frame))), type); + + if (bg_str != NULL) { + if (dbus_frame->priv->bg_cancellable) + g_cancellable_cancel (dbus_frame->priv->bg_cancellable); + dbus_frame->priv->bg_cancellable = g_cancellable_new (); + + mate_panel_applet_container_child_set (dbus_frame->priv->container, + "background", + g_variant_new_string (bg_str), + dbus_frame->priv->bg_cancellable, + container_child_background_set, + dbus_frame); + g_free (bg_str); + } +} + +static void +mate_panel_applet_frame_dbus_flags_changed (MatePanelAppletContainer *container, + const gchar *prop_name, + GVariant *value, + MatePanelAppletFrame *frame) +{ + mate_panel_applet_frame_dbus_update_flags (frame, value); +} + +static void +mate_panel_applet_frame_dbus_size_hints_changed (MatePanelAppletContainer *container, + const gchar *prop_name, + GVariant *value, + MatePanelAppletFrame *frame) +{ + const gint *sz; + gint *size_hints = NULL; + gsize n_elements; + + sz = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32)); + if (n_elements > 0) { + size_hints = g_new (gint32, n_elements); + memcpy (size_hints, sz, n_elements * sizeof (gint32)); + } + + _mate_panel_applet_frame_update_size_hints (frame, size_hints, n_elements); +} + +static void +mate_panel_applet_frame_dbus_applet_broken (MatePanelAppletContainer *container, + MatePanelAppletFrame *frame) +{ + _mate_panel_applet_frame_applet_broken (frame); +} + +static void +mate_panel_applet_frame_dbus_applet_remove (MatePanelAppletContainer *container, + MatePanelAppletFrame *frame) +{ + _mate_panel_applet_frame_applet_remove (frame); +} + +static void +mate_panel_applet_frame_dbus_applet_move (MatePanelAppletContainer *container, + MatePanelAppletFrame *frame) +{ + _mate_panel_applet_frame_applet_move (frame); +} + +static void +mate_panel_applet_frame_dbus_applet_lock (MatePanelAppletContainer *container, + gboolean locked, + MatePanelAppletFrame *frame) +{ + _mate_panel_applet_frame_applet_lock (frame, locked); +} + +static void +mate_panel_applet_frame_dbus_finalize (GObject *object) +{ + MatePanelAppletFrameDBus *frame = MATE_PANEL_APPLET_FRAME_DBUS (object); + + if (frame->priv->bg_cancellable) + g_object_unref (frame->priv->bg_cancellable); + frame->priv->bg_cancellable = NULL; + + G_OBJECT_CLASS (mate_panel_applet_frame_dbus_parent_class)->finalize (object); +} + +static void +mate_panel_applet_frame_dbus_init (MatePanelAppletFrameDBus *frame) +{ + GtkWidget *container; + + frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame, + PANEL_TYPE_APPLET_FRAME_DBUS, + MatePanelAppletFrameDBusPrivate); + + container = mate_panel_applet_container_new (); + gtk_widget_show (container); + gtk_container_add (GTK_CONTAINER (frame), container); + frame->priv->container = MATE_PANEL_APPLET_CONTAINER (container); + + g_signal_connect (container, "child-property-changed::flags", + G_CALLBACK (mate_panel_applet_frame_dbus_flags_changed), + frame); + g_signal_connect (container, "child-property-changed::size-hints", + G_CALLBACK (mate_panel_applet_frame_dbus_size_hints_changed), + frame); + g_signal_connect (container, "applet-broken", + G_CALLBACK (mate_panel_applet_frame_dbus_applet_broken), + frame); + g_signal_connect (container, "applet-remove", + G_CALLBACK (mate_panel_applet_frame_dbus_applet_remove), + frame); + g_signal_connect (container, "applet-move", + G_CALLBACK (mate_panel_applet_frame_dbus_applet_move), + frame); + g_signal_connect (container, "applet-lock", + G_CALLBACK (mate_panel_applet_frame_dbus_applet_lock), + frame); +} + +static void +mate_panel_applet_frame_dbus_class_init (MatePanelAppletFrameDBusClass *class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + MatePanelAppletFrameClass *frame_class = MATE_PANEL_APPLET_FRAME_CLASS (class); + + gobject_class->finalize = mate_panel_applet_frame_dbus_finalize; + + frame_class->init_properties = mate_panel_applet_frame_dbus_init_properties; + frame_class->sync_menu_state = mate_panel_applet_frame_dbus_sync_menu_state; + frame_class->popup_menu = mate_panel_applet_frame_dbus_popup_menu; + frame_class->change_orientation = mate_panel_applet_frame_dbus_change_orientation; + frame_class->change_size = mate_panel_applet_frame_dbus_change_size; + frame_class->change_background = mate_panel_applet_frame_dbus_change_background; + + g_type_class_add_private (class, sizeof (MatePanelAppletFrameDBusPrivate)); +} + +static void +mate_panel_applet_frame_dbus_activated (MatePanelAppletContainer *container, + GAsyncResult *res, + MatePanelAppletFrame *frame) +{ + MatePanelAppletFrameActivating *frame_act; + GError *error = NULL; + + if (!mate_panel_applet_container_add_finish (container, res, &error)) + g_assert (error != NULL); + + frame_act = g_object_get_data (G_OBJECT (frame), "mate-panel-applet-frame-activating"); + g_object_set_data (G_OBJECT (frame), "mate-panel-applet-frame-activating", NULL); + + _mate_panel_applet_frame_activated (frame, frame_act, error); +} + +gboolean +mate_panel_applet_frame_dbus_load (const gchar *iid, + MatePanelAppletFrameActivating *frame_act) +{ + MatePanelAppletFrameDBus *dbus_frame; + MatePanelAppletFrame *frame; + GVariantBuilder builder; + gchar *conf_path; + gchar *background; + guint orient; + + g_return_val_if_fail (iid != NULL, FALSE); + g_return_val_if_fail (frame_act != NULL, FALSE); + + if (!mate_panel_applets_manager_factory_activate (iid)) + return FALSE; + + dbus_frame = g_object_new (PANEL_TYPE_APPLET_FRAME_DBUS, NULL); + frame = MATE_PANEL_APPLET_FRAME (dbus_frame); + _mate_panel_applet_frame_set_iid (frame, iid); + + orient = get_mate_panel_applet_orient (mate_panel_applet_frame_activating_get_orientation (frame_act)); + conf_path = mate_panel_applet_frame_activating_get_conf_path (frame_act); + /* we can't really get a background string at this point since we don't + * know the position of the applet */ + background = NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + g_variant_builder_add (&builder, "{sv}", + "prefs-key", + g_variant_new_string (conf_path)); + g_variant_builder_add (&builder, "{sv}", + "orient", + g_variant_new_uint32 (orient)); + g_variant_builder_add (&builder, "{sv}", + "size", + g_variant_new_uint32 (mate_panel_applet_frame_activating_get_size (frame_act))); + g_variant_builder_add (&builder, "{sv}", + "locked", + g_variant_new_boolean (mate_panel_applet_frame_activating_get_locked (frame_act))); + g_variant_builder_add (&builder, "{sv}", + "locked-down", + g_variant_new_boolean (mate_panel_applet_frame_activating_get_locked_down (frame_act))); + if (background) { + g_variant_builder_add (&builder, "{sv}", + "background", + g_variant_new_string (background)); + } + + g_object_set_data (G_OBJECT (frame), "mate-panel-applet-frame-activating", frame_act); + + mate_panel_applet_container_add (dbus_frame->priv->container, + iid, NULL, + (GAsyncReadyCallback) mate_panel_applet_frame_dbus_activated, + frame, + g_variant_builder_end (&builder)); + + g_free (conf_path); + g_free (background); + + return TRUE; +} diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.h b/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.h new file mode 100644 index 00000000..e42e792b --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.h @@ -0,0 +1,65 @@ +/* + * mate-panel-applet-frame-dbus.h: panel side container for applets + * + * Copyright (C) 2001 - 2003 Sun Microsystems, Inc. + * Copyright (C) 2010 Vincent Untz <[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 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Authors: + * Mark McLoughlin <[email protected]> + */ + +#ifndef __MATE_PANEL_APPLET_FRAME_DBUS_H__ +#define __MATE_PANEL_APPLET_FRAME_DBUS_H__ + +#include <mate-panel-applet-frame.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define PANEL_TYPE_APPLET_FRAME_DBUS (mate_panel_applet_frame_dbus_get_type ()) +#define MATE_PANEL_APPLET_FRAME_DBUS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET_FRAME_DBUS, MatePanelAppletFrameDBus)) +#define MATE_PANEL_APPLET_FRAME_DBUS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_APPLET_FRAME_DBUS, MatePanelAppletFrameDBusClass)) +#define PANEL_IS_APPLET_FRAME_DBUS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_TYPE_APPLET_FRAME_DBUS)) +#define PANEL_IS_APPLET_FRAME_DBUS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_TYPE_APPLET_FRAME_DBUS)) +#define MATE_PANEL_APPLET_FRAME_DBUS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_APPLET_FRAME_DBUS, MatePanelAppletFrameDBusClass)) + +typedef struct _MatePanelAppletFrameDBus MatePanelAppletFrameDBus; +typedef struct _MatePanelAppletFrameDBusClass MatePanelAppletFrameDBusClass; +typedef struct _MatePanelAppletFrameDBusPrivate MatePanelAppletFrameDBusPrivate; + +struct _MatePanelAppletFrameDBusClass { + MatePanelAppletFrameClass parent_class; +}; + +struct _MatePanelAppletFrameDBus{ + MatePanelAppletFrame parent; + + MatePanelAppletFrameDBusPrivate *priv; +}; + +GType mate_panel_applet_frame_dbus_get_type (void) G_GNUC_CONST; + +gboolean mate_panel_applet_frame_dbus_load (const gchar *iid, + MatePanelAppletFrameActivating *frame_act); + +#ifdef __cplusplus +} +#endif + +#endif /* __MATE_PANEL_APPLET_FRAME_DBUS_H__ */ diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applet-mini.c b/mate-panel/libmate-panel-applet-private/mate-panel-applet-mini.c new file mode 100644 index 00000000..13112376 --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applet-mini.c @@ -0,0 +1,5 @@ +/* Symbols needed for libmate-panel-applet-private-mini, which is used by the test + * program */ +#include <glib.h> +gboolean mate_panel_applet_frame_dbus_load (const gchar *iid, gpointer frame_act); +gboolean mate_panel_applet_frame_dbus_load (const gchar *iid, gpointer frame_act) { return FALSE; } diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applets-manager-dbus.c b/mate-panel/libmate-panel-applet-private/mate-panel-applets-manager-dbus.c new file mode 100644 index 00000000..9e330f9e --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applets-manager-dbus.c @@ -0,0 +1,604 @@ +/* + * mate-panel-applets-manager-dbus.c + * + * Copyright (C) 2010 Carlos Garcia Campos <[email protected]> + * Copyright (C) 2010 Vincent Untz <[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 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <config.h> + +#include <gio/gio.h> +#include <gmodule.h> +#include <string.h> + +#include <mate-panel-applets-manager.h> + +#include "mate-panel-applet-frame-dbus.h" + +#include "mate-panel-applets-manager-dbus.h" + +G_DEFINE_TYPE_WITH_CODE (MatePanelAppletsManagerDBus, + mate_panel_applets_manager_dbus, + PANEL_TYPE_APPLETS_MANAGER, + g_io_extension_point_implement (MATE_PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME, + g_define_type_id, + "dbus", + 10)) + +struct _MatePanelAppletsManagerDBusPrivate +{ + GHashTable *applet_factories; + GList *monitors; +}; + +typedef gint (* ActivateAppletFunc) (void); + +typedef struct _MatePanelAppletFactoryInfo { + gchar *id; + gchar *location; + gboolean in_process; + GModule *module; + ActivateAppletFunc activate_applet; + guint n_applets; + + gchar *srcdir; + + GList *applet_list; + gboolean has_old_ids; +} MatePanelAppletFactoryInfo; + +#define MATE_PANEL_APPLET_FACTORY_GROUP "Applet Factory" +#define MATE_PANEL_APPLETS_EXTENSION ".mate-panel-applet" + +static void +mate_panel_applet_factory_info_free (MatePanelAppletFactoryInfo *info) +{ + if (!info) + return; + + g_free (info->id); + g_free (info->location); + g_list_foreach (info->applet_list, + (GFunc) mate_panel_applet_info_free, + NULL); + g_list_free (info->applet_list); + info->applet_list = NULL; + g_free (info->srcdir); + + g_slice_free (MatePanelAppletFactoryInfo, info); +} + +static MatePanelAppletInfo * +_mate_panel_applets_manager_get_applet_info (GKeyFile *applet_file, + const gchar *group, + const gchar *factory_id) +{ + MatePanelAppletInfo *info; + char *iid; + char *name; + char *comment; + char *icon; + char **old_ids; + + iid = g_strdup_printf ("%s::%s", factory_id, group); + name = g_key_file_get_locale_string (applet_file, group, + "Name", NULL, NULL); + comment = g_key_file_get_locale_string (applet_file, group, + "Description", NULL, NULL); + icon = g_key_file_get_string (applet_file, group, "Icon", NULL); + /* MateComponent compatibility */ + old_ids = g_key_file_get_string_list (applet_file, group, + "MateComponentId", NULL, NULL); + + info = mate_panel_applet_info_new (iid, name, comment, icon, (const char **) old_ids); + + g_free (iid); + g_free (name); + g_free (comment); + g_free (icon); + g_strfreev (old_ids); + + return info; +} + +static MatePanelAppletFactoryInfo * +mate_panel_applets_manager_get_applet_factory_info_from_file (const gchar *filename) +{ + MatePanelAppletFactoryInfo *info; + GKeyFile *applet_file; + gchar **groups; + gsize n_groups; + gint i; + GError *error = NULL; + + applet_file = g_key_file_new (); + if (!g_key_file_load_from_file (applet_file, filename, G_KEY_FILE_NONE, &error)) { + g_warning ("Error opening panel applet file %s: %s", + filename, error->message); + g_error_free (error); + g_key_file_free (applet_file); + + return NULL; + } + + info = g_slice_new0 (MatePanelAppletFactoryInfo); + info->id = g_key_file_get_string (applet_file, MATE_PANEL_APPLET_FACTORY_GROUP, "Id", NULL); + if (!info->id) { + g_warning ("Bad panel applet file %s: Could not find 'Id' in group '%s'", + filename, MATE_PANEL_APPLET_FACTORY_GROUP); + mate_panel_applet_factory_info_free (info); + g_key_file_free (applet_file); + + return NULL; + } + + info->in_process = g_key_file_get_boolean (applet_file, MATE_PANEL_APPLET_FACTORY_GROUP, + "InProcess", NULL); + if (info->in_process) { + info->location = g_key_file_get_string (applet_file, MATE_PANEL_APPLET_FACTORY_GROUP, + "Location", NULL); + if (!info->location) { + g_warning ("Bad panel applet file %s: In-process applet without 'Location'", + filename); + mate_panel_applet_factory_info_free (info); + g_key_file_free (applet_file); + + return NULL; + } + } + + info->has_old_ids = FALSE; + + groups = g_key_file_get_groups (applet_file, &n_groups); + for (i = 0; i < n_groups; i++) { + MatePanelAppletInfo *ainfo; + + if (g_strcmp0 (groups[i], MATE_PANEL_APPLET_FACTORY_GROUP) == 0) + continue; + + ainfo = _mate_panel_applets_manager_get_applet_info (applet_file, + groups[i], info->id); + if (mate_panel_applet_info_get_old_ids (ainfo) != NULL) + info->has_old_ids = TRUE; + + info->applet_list = g_list_prepend (info->applet_list, ainfo); + } + g_strfreev (groups); + + g_key_file_free (applet_file); + + if (!info->applet_list) { + mate_panel_applet_factory_info_free (info); + return NULL; + } + + info->srcdir = g_path_get_dirname (filename); + + return info; +} + +static GSList * +mate_panel_applets_manager_get_applets_dirs (void) +{ + const gchar *dir = NULL; + gchar **paths; + guint i; + GSList *retval = NULL; + + dir = g_getenv ("MATE_PANEL_APPLETS_DIR"); + if (!dir || g_strcmp0 (dir, "") == 0) { + return g_slist_prepend (NULL, g_strdup (MATE_PANEL_APPLETS_DIR)); + } + + paths = g_strsplit (dir, ":", 0); + for (i = 0; paths[i]; i++) { + if (g_slist_find_custom (retval, paths[i], (GCompareFunc) g_strcmp0)) + continue; + retval = g_slist_prepend (retval, g_strdup (paths[i])); + } + g_strfreev (paths); + + return g_slist_reverse (retval); +} + +static void +applets_directory_changed (GFileMonitor *monitor, + GFile *file, + GFile *other_file, + GFileMonitorEvent event_type, + gpointer user_data) +{ + MatePanelAppletsManagerDBus *manager = MATE_PANEL_APPLETS_MANAGER_DBUS (user_data); + + switch (event_type) { + case G_FILE_MONITOR_EVENT_CHANGED: + case G_FILE_MONITOR_EVENT_CREATED: { + MatePanelAppletFactoryInfo *info; + MatePanelAppletFactoryInfo *old_info; + gchar *filename; + GSList *dirs, *d; + + filename = g_file_get_path (file); + if (!g_str_has_suffix (filename, MATE_PANEL_APPLETS_EXTENSION)) { + g_free (filename); + return; + } + + info = mate_panel_applets_manager_get_applet_factory_info_from_file (filename); + g_free (filename); + + if (!info) + return; + + old_info = g_hash_table_lookup (manager->priv->applet_factories, info->id); + if (!old_info) { + /* New applet, just insert it */ + g_hash_table_insert (manager->priv->applet_factories, g_strdup (info->id), info); + return; + } + + /* Make sure we don't update an applet that has changed in + * another source dir unless it takes precedence over the + * current one */ + if (g_strcmp0 (info->srcdir, old_info->srcdir) == 0) { + g_hash_table_replace (manager->priv->applet_factories, g_strdup (info->id), info); + return; + } + + dirs = mate_panel_applets_manager_get_applets_dirs (); + + for (d = dirs; d; d = g_slist_next (d)) { + gchar *path = (gchar *) d->data; + + if (g_strcmp0 (path, old_info->srcdir) == 0) { + mate_panel_applet_factory_info_free (info); + break; + } else if (g_strcmp0 (path, info->srcdir) == 0) { + g_hash_table_replace (manager->priv->applet_factories, g_strdup (info->id), info); + break; + } + } + + g_slist_foreach (dirs, (GFunc) g_free, NULL); + g_slist_free (dirs); + } + break; + default: + /* Ignore any other change */ + break; + } +} + +static void +mate_panel_applets_manager_dbus_load_applet_infos (MatePanelAppletsManagerDBus *manager) +{ + GSList *dirs, *d; + GDir *dir; + const gchar *dirent; + GError *error = NULL; + + dirs = mate_panel_applets_manager_get_applets_dirs (); + for (d = dirs; d; d = g_slist_next (d)) { + GFileMonitor *monitor; + GFile *dir_file; + gchar *path = (gchar *) d->data; + + dir = g_dir_open (path, 0, &error); + if (!dir) { + g_warning ("%s", error->message); + g_error_free (error); + g_free (path); + + continue; + } + + /* Monitor dir */ + dir_file = g_file_new_for_path (path); + monitor = g_file_monitor_directory (dir_file, + G_FILE_MONITOR_NONE, + NULL, NULL); + if (monitor) { + g_signal_connect (monitor, "changed", + G_CALLBACK (applets_directory_changed), + manager); + manager->priv->monitors = g_list_prepend (manager->priv->monitors, monitor); + } + g_object_unref (dir_file); + + while ((dirent = g_dir_read_name (dir))) { + MatePanelAppletFactoryInfo *info; + gchar *file; + + if (!g_str_has_suffix (dirent, MATE_PANEL_APPLETS_EXTENSION)) + continue; + + file = g_build_filename (path, dirent, NULL); + info = mate_panel_applets_manager_get_applet_factory_info_from_file (file); + g_free (file); + + if (!info) + continue; + + if (g_hash_table_lookup (manager->priv->applet_factories, info->id)) { + mate_panel_applet_factory_info_free (info); + continue; + } + + g_hash_table_insert (manager->priv->applet_factories, g_strdup (info->id), info); + } + + g_dir_close (dir); + g_free (path); + } + + g_slist_free (dirs); +} + +static GList * +mate_panel_applets_manager_dbus_get_applets (MatePanelAppletsManager *manager) +{ + MatePanelAppletsManagerDBus *dbus_manager = MATE_PANEL_APPLETS_MANAGER_DBUS (manager); + + GHashTableIter iter; + gpointer key, value; + GList *retval = NULL; + + g_hash_table_iter_init (&iter, dbus_manager->priv->applet_factories); + while (g_hash_table_iter_next (&iter, &key, &value)) { + MatePanelAppletFactoryInfo *info; + + info = (MatePanelAppletFactoryInfo *) value; + retval = g_list_concat (retval, g_list_copy (info->applet_list)); + } + + return retval; +} + +static MatePanelAppletFactoryInfo * +get_applet_factory_info (MatePanelAppletsManager *manager, + const gchar *iid) +{ + MatePanelAppletsManagerDBus *dbus_manager = MATE_PANEL_APPLETS_MANAGER_DBUS (manager); + + MatePanelAppletFactoryInfo *info; + const gchar *sp; + gchar *factory_id; + + sp = g_strrstr (iid, "::"); + if (!sp) + return NULL; + + factory_id = g_strndup (iid, strlen (iid) - strlen (sp)); + info = g_hash_table_lookup (dbus_manager->priv->applet_factories, factory_id); + g_free (factory_id); + + return info; +} + +static gboolean +mate_panel_applets_manager_dbus_factory_activate (MatePanelAppletsManager *manager, + const gchar *iid) +{ + MatePanelAppletFactoryInfo *info; + ActivateAppletFunc activate_applet; + + info = get_applet_factory_info (manager, iid); + if (!info) + return FALSE; + + /* Out-of-process applets are activated by the session bus */ + if (!info->in_process) + return TRUE; + + if (info->module) { + if (info->n_applets == 0) { + if (info->activate_applet () != 0) { + g_warning ("Failed to reactivate factory %s\n", iid); + return FALSE; + } + } + info->n_applets++; + + return TRUE; + } + + info->module = g_module_open (info->location, G_MODULE_BIND_LAZY); + if (!info->module) { + /* FIXME: use a GError? */ + g_warning ("Failed to load applet %s: %s\n", + iid, g_module_error ()); + return FALSE; + } + + if (!g_module_symbol (info->module, "_mate_panel_applet_shlib_factory", (gpointer *) &activate_applet)) { + /* FIXME: use a GError? */ + g_warning ("Failed to load applet %s: %s\n", + iid, g_module_error ()); + g_module_close (info->module); + info->module = NULL; + + return FALSE; + } + + /* Activate the applet */ + if (activate_applet () != 0) { + /* FIXME: use a GError? */ + g_warning ("Failed to load applet %s\n", iid); + g_module_close (info->module); + info->module = NULL; + + return FALSE; + } + info->activate_applet = activate_applet; + + info->n_applets = 1; + + return TRUE; +} + +static gboolean +mate_panel_applets_manager_dbus_factory_deactivate (MatePanelAppletsManager *manager, + const gchar *iid) +{ + MatePanelAppletFactoryInfo *info; + + info = get_applet_factory_info (manager, iid); + if (!info) + return FALSE; + + /* Out-of-process applets are deactivated by the session bus */ + if (!info->in_process) + return TRUE; + + if (!info->module) + return TRUE; + + info->n_applets--; + if (info->n_applets == 0) { + /* FIXME: we should close the module here, however applet types + * are registered static */ +#if 0 + g_module_close (info->module); + info->module = NULL; +#endif + } + + return TRUE; +} + +static MatePanelAppletInfo * +mate_panel_applets_manager_dbus_get_applet_info (MatePanelAppletsManager *manager, + const gchar *iid) +{ + MatePanelAppletFactoryInfo *info; + GList *l; + + info = get_applet_factory_info (manager, iid); + if (!info) + return NULL; + + for (l = info->applet_list; l; l = g_list_next (l)) { + MatePanelAppletInfo *ainfo = (MatePanelAppletInfo *) l->data; + + if (g_strcmp0 (mate_panel_applet_info_get_iid (ainfo), iid) == 0) + return ainfo; + } + + return NULL; +} + +static MatePanelAppletInfo * +mate_panel_applets_manager_dbus_get_applet_info_from_old_id (MatePanelAppletsManager *manager, + const gchar *iid) +{ + MatePanelAppletsManagerDBus *dbus_manager = MATE_PANEL_APPLETS_MANAGER_DBUS (manager); + + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init (&iter, dbus_manager->priv->applet_factories); + while (g_hash_table_iter_next (&iter, &key, &value)) { + MatePanelAppletFactoryInfo *info; + GList *l; + + info = (MatePanelAppletFactoryInfo *) value; + if (!info->has_old_ids) + continue; + + for (l = info->applet_list; l; l = g_list_next (l)) { + MatePanelAppletInfo *ainfo; + gint i = 0; + const gchar * const *old_ids; + + ainfo = (MatePanelAppletInfo *) l->data; + + old_ids = mate_panel_applet_info_get_old_ids (ainfo); + + if (old_ids == NULL) + continue; + + while (old_ids[i]) { + if (g_strcmp0 (old_ids[i], iid) == 0) + return ainfo; + i++; + } + } + } + + return NULL; +} + +static gboolean +mate_panel_applets_manager_dbus_load_applet (MatePanelAppletsManager *manager, + const gchar *iid, + MatePanelAppletFrameActivating *frame_act) +{ + return mate_panel_applet_frame_dbus_load (iid, frame_act); +} + +static void +mate_panel_applets_manager_dbus_finalize (GObject *object) +{ + MatePanelAppletsManagerDBus *manager = MATE_PANEL_APPLETS_MANAGER_DBUS (object); + + if (manager->priv->monitors) { + g_list_foreach (manager->priv->monitors, (GFunc) g_object_unref, NULL); + g_list_free (manager->priv->monitors); + manager->priv->monitors = NULL; + } + + if (manager->priv->applet_factories) { + g_hash_table_destroy (manager->priv->applet_factories); + manager->priv->applet_factories = NULL; + } + + G_OBJECT_CLASS (mate_panel_applets_manager_dbus_parent_class)->finalize (object); +} + +static void +mate_panel_applets_manager_dbus_init (MatePanelAppletsManagerDBus *manager) +{ + manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, + PANEL_TYPE_APPLETS_MANAGER_DBUS, + MatePanelAppletsManagerDBusPrivate); + + manager->priv->applet_factories = g_hash_table_new_full (g_str_hash, + g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) mate_panel_applet_factory_info_free); + + mate_panel_applets_manager_dbus_load_applet_infos (manager); +} + +static void +mate_panel_applets_manager_dbus_class_init (MatePanelAppletsManagerDBusClass *class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + MatePanelAppletsManagerClass *manager_class = MATE_PANEL_APPLETS_MANAGER_CLASS (class); + + gobject_class->finalize = mate_panel_applets_manager_dbus_finalize; + + manager_class->get_applets = mate_panel_applets_manager_dbus_get_applets; + manager_class->factory_activate = mate_panel_applets_manager_dbus_factory_activate; + manager_class->factory_deactivate = mate_panel_applets_manager_dbus_factory_deactivate; + manager_class->get_applet_info = mate_panel_applets_manager_dbus_get_applet_info; + manager_class->get_applet_info_from_old_id = mate_panel_applets_manager_dbus_get_applet_info_from_old_id; + manager_class->load_applet = mate_panel_applets_manager_dbus_load_applet; + + g_type_class_add_private (class, sizeof (MatePanelAppletsManagerDBusPrivate)); +} diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applets-manager-dbus.h b/mate-panel/libmate-panel-applet-private/mate-panel-applets-manager-dbus.h new file mode 100644 index 00000000..808795be --- /dev/null +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applets-manager-dbus.h @@ -0,0 +1,60 @@ +/* + * mate-panel-applets-manager-dbus.h + * + * Copyright (C) 2010 Carlos Garcia Campos <[email protected]> + * Copyright (C) 2010 Vincent Untz <[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 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef __MATE_PANEL_APPLETS_MANAGER_DBUS_H__ +#define __MATE_PANEL_APPLETS_MANAGER_DBUS_H__ + +#include <mate-panel-applets-manager.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define PANEL_TYPE_APPLETS_MANAGER_DBUS (mate_panel_applets_manager_dbus_get_type ()) +#define MATE_PANEL_APPLETS_MANAGER_DBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLETS_MANAGER_DBUS, MatePanelAppletsManagerDBus)) +#define MATE_PANEL_APPLETS_MANAGER_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANEL_TYPE_APPLETS_MANAGER_DBUS, MatePanelAppletsManagerDBusClass)) +#define PANEL_IS_APPLETS_MANAGER_DBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLETS_MANAGER_DBUS)) +#define PANEL_IS_APPLETS_MANAGER_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLETS_MANAGER_DBUS)) +#define MATE_PANEL_APPLETS_MANAGER_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PANEL_TYPE_APPLETS_MANAGER_DBUS, MatePanelAppletsManagerDBusClass)) + +typedef struct _MatePanelAppletsManagerDBus MatePanelAppletsManagerDBus; +typedef struct _MatePanelAppletsManagerDBusClass MatePanelAppletsManagerDBusClass; +typedef struct _MatePanelAppletsManagerDBusPrivate MatePanelAppletsManagerDBusPrivate; + +struct _MatePanelAppletsManagerDBusClass { + MatePanelAppletsManagerClass parent_class; +}; + +struct _MatePanelAppletsManagerDBus { + MatePanelAppletsManager parent; + + /*< private > */ + MatePanelAppletsManagerDBusPrivate *priv; +}; + +GType mate_panel_applets_manager_dbus_get_type (void); + +#ifdef __cplusplus +} +#endif + +#endif /* __MATE_PANEL_APPLETS_MANAGER_DBUS_H__ */ |